1  #ifdef __INT32_TYPE__
       2  typedef __INT32_TYPE__ int32_t;
       3  #else
       4  typedef int int32_t;
       5  #endif
       6  
       7  #ifdef __UINT32_TYPE__
       8  typedef __UINT32_TYPE__ uint32_t;
       9  #else
      10  typedef unsigned uint32_t;
      11  #endif
      12  
      13  #define __fake_const_swab32(x) ((uint32_t)(		      \
      14  	(((uint32_t)(x) & (uint32_t)0x000000ffUL) << 24) |    \
      15  	(((uint32_t)(x) & (uint32_t)0x0000ff00UL) <<  8) |    \
      16  	(((uint32_t)(x) & (uint32_t)0x00ff0000UL) >>  8) |    \
      17  	(( (int32_t)(x) &  (int32_t)0xff000000UL) >> 24)))
      18  
      19  /* Previous version of bswap optimization failed to consider sign extension
      20     and as a result would replace an expression *not* doing a bswap by a
      21     bswap.  */
      22  
      23  __attribute__ ((noinline, noclone)) uint32_t
      24  fake_bswap32 (uint32_t in)
      25  {
      26    return __fake_const_swab32 (in);
      27  }
      28  
      29  int
      30  main(void)
      31  {
      32    if (sizeof (int32_t) * __CHAR_BIT__ != 32)
      33      return 0;
      34    if (sizeof (uint32_t) * __CHAR_BIT__ != 32)
      35      return 0;
      36    if (fake_bswap32 (0x87654321) != 0xffffff87)
      37      __builtin_abort ();
      38    return 0;
      39  }