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: WG: Re: motorRecord on linux-arm
From: Torsten Bögershausen <[email protected]>
To: <[email protected]>, <[email protected]>
Date: Mon, 2 Jun 2014 09:28:10 +0200


On 2/7/14 18:02, [email protected] wrote:
Am 07.02.2014 16:56, schrieb Ron Sluiter:
On 2/7/2014 9:21 AM, [email protected] wrote:
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)

Thanks for the suggestion but MSB_First/LSB_First is set to indicate how
C/C++ bit fields are packed, not endianness.

To my knowledge and experience
(arm gcc & RVCT, x86 gcc & MSVC, powerpc gcc, sparc gcc) the compiler fills
a bitfield with bits the same way it fills a machine word with bytes.
In other words: the endianess for bits and bytes is the same, either big or little.

Is there any chance to get Jens patch into motor.h ?
Either the short one (my favorite) or the long one ?





What compiler and compiler version are you using?


I verified with the following compilers:
Linux 32bit/64bit (gcc4.7.4)
linux arm gcc-Version 4.7.2 20120731 (prerelease) (crosstool-NG
linaro-1.13.1+bzr2458 - Linaro GCC 2012.08)
powerpc-rtems4.10.2 (mvme2100 cpu=603e)
tornado-2.2 (CPU=MC68040)

At least for gcc bit field packing is LSB_first for little endian and
MSB_first for big endian machines.

If you are afraid of breaking existing code, how about this:

#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 defined(ppc603e)
      #define MSB_First (TRUE)  /* MSB is packed first. */
#elif defined(CPU) && ((CPU == PPC604) || (CPU == PPC603) || (CPU ==
PPC85XX) || (CPU == MC68040) || (CPU == PPC32))
      #define MSB_First (TRUE)  /* MSB is packed first. */
#elif defined(__GNUC__)
      #include <epicsEndian.h>
      #if (EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE)
          #define LSB_First (TRUE)
      #else
          #define MSB_First (TRUE)
      #endif
#else
      #error: unknown bit order!
#endif

Jens




Replies:
Re: WG: Re: motorRecord on linux-arm Ron Sluiter
References:
WG: Re: motorRecord on linux-arm Jens . Eden

Navigate by Date:
Prev: TD20 classic : Turbo molecular pump controller "최숙"
Next: Re: WG: Re: motorRecord on linux-arm Ron Sluiter
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: WG: Re: motorRecord on linux-arm Jens . Eden
Next: Re: WG: Re: motorRecord on linux-arm Ron Sluiter
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 ·