1 #ifdef __INT16_TYPE__
2 typedef __INT16_TYPE__ int16_t;
3 #else
4 typedef short int16_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)(int16_t)(x) & (uint32_t)0x00ffff00UL) <<  8) |   \
16 	(((uint32_t)         (x) & (uint32_t)0x00ff0000UL) >>  8) |   \
17 	(((uint32_t)         (x) & (uint32_t)0xff000000UL) >> 24)))
18 
19 
20 /* Previous version of bswap optimization failed to consider sign extension
21    and as a result would replace an expression *not* doing a bswap by a
22    bswap.  */
23 
24 __attribute__ ((noinline, noclone)) uint32_t
fake_bswap32(uint32_t in)25 fake_bswap32 (uint32_t in)
26 {
27   return __fake_const_swab32 (in);
28 }
29 
30 int
main(void)31 main(void)
32 {
33   if (sizeof (uint32_t) * __CHAR_BIT__ != 32)
34     return 0;
35   if (sizeof (int16_t) * __CHAR_BIT__ != 16)
36     return 0;
37   if (fake_bswap32 (0x81828384) != 0xff838281)
38     __builtin_abort ();
39   return 0;
40 }
41