diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2013-01-27 22:28:19 +0200 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2013-01-27 22:28:19 +0200 |
commit | 919fcbb6ef94a3db918c7d59edb11f61588c8039 (patch) | |
tree | 75d0f0cf5efa136a6b5920156f1fd1d85731df3f /test cases/26 endian/prog.c | |
parent | aef5ef362d5f0934df44951d20028b64e5529384 (diff) | |
download | meson-919fcbb6ef94a3db918c7d59edb11f61588c8039.zip meson-919fcbb6ef94a3db918c7d59edb11f61588c8039.tar.gz meson-919fcbb6ef94a3db918c7d59edb11f61588c8039.tar.bz2 |
Added endianness check.
Diffstat (limited to 'test cases/26 endian/prog.c')
-rw-r--r-- | test cases/26 endian/prog.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test cases/26 endian/prog.c b/test cases/26 endian/prog.c new file mode 100644 index 0000000..261ac0f --- /dev/null +++ b/test cases/26 endian/prog.c @@ -0,0 +1,26 @@ +#include<stdint.h> + +int is_big_endian(void) { + union { + uint32_t i; + char c[4]; + } bint = {0x01020304}; + + return bint.c[0] == 1; +} + + +int main(int argc, char **argv) { + int is_be_check = is_big_endian(); + int is_be; +#ifdef IS_BE + is_be = 1; +#else + is_be = 0; +#endif + if(is_be_check && is_be) + return 0; + if(!is_be_check && !is_be) + return 0; + return 1; +} |