- Timestamp:
- Sep 21, 2011 4:27:58 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.x/pjlib/src/pjlib-test/os.c
r3553 r3759 23 23 24 24 #if INCLUDE_OS_TEST 25 static int endianness_test32(void) 26 { 27 union t 28 { 29 pj_uint32_t u32; 30 pj_uint16_t u16[2]; 31 pj_uint8_t u8[4]; 32 } t; 33 34 PJ_LOG(3,("", " Testing endianness..")); 35 36 t.u32 = 0x11223344; 37 38 #if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN 39 PJ_LOG(3,("", " Library is set to little endian")); 40 41 # if defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN 42 # error Error: Both PJ_IS_LITTLE_ENDIAN and PJ_IS_BIG_ENDIAN are set! 43 # endif 44 45 if ((t.u16[0] & 0xFFFF) != 0x3344 || 46 (t.u16[1] & 0xFFFF) != 0x1122) 47 { 48 PJ_LOG(3,("", " Error: wrong 16bit values 0x%x and 0x%x", 49 (t.u16[0] & 0xFFFF), (t.u16[1] & 0xFFFF))); 50 return 10; 51 } 52 53 if ((t.u8[0] & 0xFF) != 0x44 || 54 (t.u8[1] & 0xFF) != 0x33 || 55 (t.u8[2] & 0xFF) != 0x22 || 56 (t.u8[3] & 0xFF) != 0x11) 57 { 58 PJ_LOG(3,("", " Error: wrong 8bit values")); 59 return 12; 60 } 61 62 #elif defined(PJ_IS_BIG_ENDIAN) && PJ_IS_BIG_ENDIAN 63 PJ_LOG(3,("", " Library is set to big endian")); 64 65 if ((t.u16[0] & 0xFFFF) != 0x1122 || 66 (t.u16[1] & 0xFFFF) != 0x3344) 67 { 68 PJ_LOG(3,("", " Error: wrong 16bit values 0x%x and 0x%x", 69 (t.u16[0] & 0xFFFF), (t.u16[1] & 0xFFFF))); 70 return 20; 71 } 72 73 if ((t.u8[0] & 0xFF) != 0x11 || 74 (t.u8[1] & 0xFF) != 0x22 || 75 (t.u8[2] & 0xFF) != 0x33 || 76 (t.u8[3] & 0xFF) != 0x44) 77 { 78 PJ_LOG(3,("", " Error: wrong 8bit values")); 79 return 22; 80 } 81 82 # if defined(PJ_IS_LITTLE_ENDIAN) && PJ_IS_LITTLE_ENDIAN 83 # error Error: Both PJ_IS_LITTLE_ENDIAN and PJ_IS_BIG_ENDIAN are set! 84 # endif 85 86 87 #else 88 # error Error: Endianness is not set properly! 89 #endif 90 91 return 0; 92 } 93 25 94 int os_test(void) 26 95 { … … 28 97 int rc = 0; 29 98 99 PJ_LOG(3,("", " Sys info:")); 30 100 si = pj_get_sys_info(); 31 101 PJ_LOG(3,("", " machine: %s", si->machine.ptr)); … … 36 106 PJ_LOG(3,("", " info: %s", si->info.ptr)); 37 107 108 rc = endianness_test32(); 109 38 110 return rc; 39 111 }
Note: See TracChangeset
for help on using the changeset viewer.