1 # defines HAVE_BYTESWAP
2 # optionally defines BYTESWAP_HEADER
3 # optionally defines BYTESWAP_32
5 # checks whether the following compiles:
6 # __builtin_bswap32(): defines HAVE_BUILTIN_BSWAP32
9 # byteswap.h: defines HAVE_BYTESWAP_H
10 # bswap_32() in byteswap.h: defines HAVE_BSWAP_32
13 # sys/endian.h: defines HAVE_SYS_ENDIAN_H
14 # bswap32() in sys/endian.h: defines HAVE_BSWAP32
17 include(TestBigEndian)
18 test_big_endian(WORDS_BIGENDIAN)
19 configure_define(WORDS_BIGENDIAN)
21 configure_define(HAVE_BYTESWAP)
22 configure_define_header(BYTESWAP_HEADER)
23 configure_define_literal(BYTESWAP_32)
28 uint32_t a = 1, b = __builtin_bswap32(a);
34 if(HAVE_BUILTIN_BSWAP32)
35 configure_undef(BYTESWAP_HEADER)
36 set(BYTESWAP_32 __builtin_bswap32 CACHE INTERNAL "BYTESWAP_32")
37 set(HAVE_BYTESWAP 1 CACHE INTERNAL "HAVE_BYTESWAP")
41 check_include(byteswap.h)
42 check_symbol(bswap_32 byteswap.h)
46 set(BYTESWAP_HEADER byteswap.h CACHE INTERNAL "BYTESWAP_HEADER")
48 set(BYTESWAP_32 bswap_32 CACHE INTERNAL "BYTESWAP_32")
49 set(HAVE_BYTESWAP 1 CACHE INSTERNAL "HAVE_BYTESWAP")
53 check_include(sys/endian.h)
54 check_symbol(bswap32 sys/endian.h)
58 set(BYTESWAP_HEADER sys/endian.h CACHE INTERNAL "BYTESWAP_HEADER")
60 set(BYTESWAP_32 bswap32 CACHE INTERNAL "BYTESWAP_32")
61 set(HAVE_BYTESWAP 1 CACHE INTERNAL "HAVE_BYTESWAP")
65 configure_undef(BYTESWAP_HEADER)
66 configure_undef(BYTESWAP_32)