This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bug in sysdeps/generic/bits/byteswap.h


This is from sysdeps/generic/bits/byteswap.h

/* Swap bytes in 32 bit value.  */
#ifdef __GNUC__
# define __bswap_32(x) \
    (__extension__                                                            \
     ({ unsigned int __bsx = (x);                                             \
        ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >>  8) |    \
         (((__bsx) & 0x0000ff00) <<  8) | (((__bsx) & 0x000000ff) << 24)); }))
#else
static __inline unsigned int
__bswap32 (unsigned int x)
{
  return ((((__bsx) & 0xff000000) >> 24) | (((__bsx) & 0x00ff0000) >>  8) |
          (((__bsx) & 0x0000ff00) <<  8) | (((__bsx) & 0x000000ff) << 24));
}
#endif

If __GNUC__ is not defined, this will fail to compile.  Need to change __bsx to
x or rename the parameter to __bsx.  Also, while we are looking at this, I'm
curious why glibc defines __bswap_32 if __GNUC__ and __bswap32 if not?  The same
is done for the 16 bit version.  This code is from the 2.0.102 snapshot I
downloaded from alpha.gnu.org.


Scott


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]