EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: motorRecord on linux-arm
From: Till Straumann <[email protected]>
To: "[email protected]" <[email protected]>, "[email protected]" <[email protected]>
Date: Fri, 07 Feb 2014 08:15:13 -0800
Shudder!

If you absolutely have to test for endianness w/o external help
then let the compiler figure it out, e.g., like this:


int
is_little_endian()
{
const union {
    unsigned short us;
    unsigned char  uc[2];
} tester = { us: 1 };
    return !! tester.uc[0];
}

rather than getting lost in a maze of #ifdefs

FWIW: gcc will optimize all of this away and just use the appropriate result
which is known at compile time.

- Till

On 02/07/2014 07:21 AM, [email protected] wrote:
I recently tried to run a motor on a Raspberry Pi and found that the DMOV
field would never
return to 1 after the move completed. The reason is, that the following
cpu-architecture
switch in motor.h doesn't have an entry for armv6

#if defined(_WIN32) || defined(_M_IX86) || defined(_X86_)
     #define LSB_First (TRUE)  /* LSB is packed first. */
#elif defined(__i386__) || defined(_armv4l_) || defined(_X86_64_) ||
defined(__APPLE__)
     #define LSB_First (TRUE)  /* LSB is packed first. */
#elif defined(i386)
     #define LSB_First (TRUE)  /* LSB is packed first. */
#elif defined(sparc) || defined(m68k) || defined(powerpc)
     #define MSB_First (TRUE)  /* MSB is packed first. */
#elif (CPU == PPC604) || (CPU == PPC603) || (CPU == PPC85XX) || (CPU ==
MC68040) || (CPU == PPC32)
     #define MSB_First (TRUE)  /* MSB is packed first. */
#else
     #error: unknown bit order!
#endif

Since (CPU == PPC604) is true for all cases where CPU is undefined, the
arm compiler did not
fall through to the error message in the else case.

I suggest to remove the switch and replace the occurrence of  MSB_First
with the EPICS
provided endianness switch:
+#include <epicsEndian.h>

-#ifdef MSB_First
+#if (EPICS_BYTE_ORDER == EPICS_ENDIAN_BIG)

Jens



References:
motorRecord on linux-arm Jens . Eden

Navigate by Date:
Prev: Re: motorRecord on linux-arm Ron Sluiter
Next: RE: asyn driver problem running Linux 3.8.13 with arm processor Jim Chen
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: motorRecord on linux-arm Till Straumann
Next: WG: Re: motorRecord on linux-arm Jens . Eden
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  <20142015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 17 Dec 2015 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·