Ticket #68144: endian.patch
File endian.patch, 6.0 KB (added by ryandesign (Ryan Carsten Schmidt), 14 months ago) |
---|
-
configure
old new 21319 21319 21320 21320 fi 21321 21321 21322 if test "$cross_compiling" = yes; then21323 { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cross compiling; assuming big endianess" >&521324 $as_echo "$as_me: WARNING: cross compiling; assuming big endianess" >&2;}21325 fi21326 { $as_echo "$as_me:${as_lineno-$LINENO}: checking endianess" >&521327 $as_echo_n "checking endianess... " >&6; }21328 if ${gnupg_cv_c_endian+:} false; then :21329 $as_echo_n "(cached) " >&621330 else21331 gnupg_cv_c_endian=unknown21332 # See if sys/param.h defines the BYTE_ORDER macro.21333 cat confdefs.h - <<_ACEOF >conftest.$ac_ext21334 /* end confdefs.h. */21335 #include <sys/types.h>21336 #include <sys/param.h>21337 int21338 main ()21339 {21340 21341 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN21342 bogus endian macros21343 #endif21344 ;21345 return 0;21346 }21347 _ACEOF21348 if ac_fn_c_try_compile "$LINENO"; then :21349 # It does; now see whether it defined to BIG_ENDIAN or not.21350 cat confdefs.h - <<_ACEOF >conftest.$ac_ext21351 /* end confdefs.h. */21352 #include <sys/types.h>21353 #include <sys/param.h>21354 int21355 main ()21356 {21357 21358 #if BYTE_ORDER != BIG_ENDIAN21359 not big endian21360 #endif21361 ;21362 return 0;21363 }21364 _ACEOF21365 if ac_fn_c_try_compile "$LINENO"; then :21366 gnupg_cv_c_endian=big21367 else21368 gnupg_cv_c_endian=little21369 fi21370 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext21371 fi21372 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext21373 if test "$gnupg_cv_c_endian" = unknown; then21374 if test "$cross_compiling" = yes; then :21375 gnupg_cv_c_endian=big21376 21377 else21378 cat confdefs.h - <<_ACEOF >conftest.$ac_ext21379 /* end confdefs.h. */21380 main () {21381 /* Are we little or big endian? From Harbison&Steele. */21382 union21383 {21384 long l;21385 char c[sizeof (long)];21386 } u;21387 u.l = 1;21388 exit (u.c[sizeof (long) - 1] == 1);21389 }21390 _ACEOF21391 if ac_fn_c_try_run "$LINENO"; then :21392 gnupg_cv_c_endian=little21393 else21394 gnupg_cv_c_endian=big21395 fi21396 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \21397 conftest.$ac_objext conftest.beam conftest.$ac_ext21398 fi21399 21400 fi21401 21402 fi21403 21404 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gnupg_cv_c_endian" >&521405 $as_echo "$gnupg_cv_c_endian" >&6; }21406 if test "$gnupg_cv_c_endian" = little; then21407 21408 $as_echo "#define LITTLE_ENDIAN_HOST 1" >>confdefs.h21409 21410 else21411 21412 $as_echo "#define BIG_ENDIAN_HOST 1" >>confdefs.h21413 21414 fi21415 21416 21322 21417 21323 # Checks for library functions. 21418 21324 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working memcmp" >&5 -
src/common/le_architecture.h
old new 28 28 #include <sys/param.h> /* #define BYTE_ORDER */ 29 29 #endif 30 30 31 /* This is copied directlyfrom GNUnet headers */31 /* This is descended from code copied from GNUnet headers */ 32 32 33 #ifndef __BYTE_ORDER 33 #ifdef __BYTE_ORDER__ 34 #define LE_BYTE_ORDER __BYTE_ORDER__ 35 #else 36 #ifdef __BYTE_ORDER 37 #define LE_BYTE_ORDER __BYTE_ORDER 38 #else 34 39 #ifdef _BYTE_ORDER 35 #define __BYTE_ORDER _BYTE_ORDER40 #define LE_BYTE_ORDER _BYTE_ORDER 36 41 #else 37 42 #ifdef BYTE_ORDER 38 #define __BYTE_ORDER BYTE_ORDER 43 #define LE_BYTE_ORDER BYTE_ORDER 44 #else 45 #error Could not find a byte order macro 46 #endif 39 47 #endif 40 48 #endif 41 49 #endif 42 #ifndef __BIG_ENDIAN 50 51 #ifdef __ORDER_BIG_ENDIAN__ 52 #define LE_ORDER_BIG_ENDIAN __ORDER_BIG_ENDIAN__ 53 #else 54 #ifdef __BIG_ENDIAN 55 #define LE_ORDER_BIG_ENDIAN __BIG_ENDIAN 56 #else 43 57 #ifdef _BIG_ENDIAN 44 #define __BIG_ENDIAN _BIG_ENDIAN58 #define LE_ORDER_BIG_ENDIAN _BIG_ENDIAN 45 59 #else 46 60 #ifdef BIG_ENDIAN 47 #define __BIG_ENDIAN BIG_ENDIAN 61 #define LE_ORDER_BIG_ENDIAN BIG_ENDIAN 62 #else 63 #error Could not find a big endian macro 48 64 #endif 49 65 #endif 50 66 #endif 51 #ifndef __LITTLE_ENDIAN 67 #endif 68 69 #ifdef __ORDER_LITTLE_ENDIAN__ 70 #define LE_ORDER_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ 71 #else 72 #ifdef __LITTLE_ENDIAN 73 #define LE_ORDER_LITTLE_ENDIAN __LITTLE_ENDIAN 74 #else 52 75 #ifdef _LITTLE_ENDIAN 53 #define __LITTLE_ENDIAN _LITTLE_ENDIAN76 #define LE_ORDER_LITTLE_ENDIAN _LITTLE_ENDIAN 54 77 #else 55 78 #ifdef LITTLE_ENDIAN 56 #define __LITTLE_ENDIAN LITTLE_ENDIAN 79 #define LE_ORDER_LITTLE_ENDIAN LITTLE_ENDIAN 80 #else 81 #error Could not find a little endian macro 82 #endif 57 83 #endif 58 84 #endif 59 85 #endif 60 86 87 61 88 /** 62 89 * Endian operations 63 90 */ 64 91 65 #if __BYTE_ORDER == __LITTLE_ENDIAN92 #if LE_BYTE_ORDER == LE_ORDER_LITTLE_ENDIAN 66 93 #define LE_htobe16(x) __bswap_16 (x) 67 94 #define LE_htole16(x) (x) 68 95 #define LE_be16toh(x) __bswap_16 (x) … … 78 105 #define LE_be64toh(x) __bswap_64 (x) 79 106 #define LE_le64toh(x) (x) 80 107 #endif 81 #if __BYTE_ORDER == __BIG_ENDIAN 108 109 #if LE_BYTE_ORDER == LE_ORDER_BIG_ENDIAN 82 110 #define LE_htobe16(x) (x) 83 111 #define LE_htole16(x) __bswap_16 (x) 84 112 #define LE_be16toh(x) (x) -
src/plugins/wav_extractor.c
old new 32 32 33 33 #include "platform.h" 34 34 #include "extractor.h" 35 36 37 #if BIG_ENDIAN_HOST 38 static uint16_t 39 little_endian_to_host16 (uint16_t in) 40 { 41 unsigned char *ptr = (unsigned char *) ∈ 42 43 return ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF); 44 } 45 46 47 static uint32_t 48 little_endian_to_host32 (uint32_t in) 49 { 50 unsigned char *ptr = (unsigned char *) ∈ 51 52 return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) 53 | ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF); 54 } 55 56 57 #endif 35 #include "le_architecture.h" 58 36 59 37 60 38 /** … … 100 78 sample_size = *((uint16_t *) &buf[34]); 101 79 data_len = *((uint32_t *) &buf[40]); 102 80 103 #if BIG_ENDIAN_HOST 104 channels = little_endian_to_host16 (channels); 105 sample_size = little_endian_to_host16 (sample_size); 106 sample_rate = little_endian_to_host32 (sample_rate); 107 data_len = little_endian_to_host32 (data_len); 108 #endif 81 channels = LE_le16toh (channels); 82 sample_size = LE_le16toh (sample_size); 83 sample_rate = LE_le32toh (sample_rate); 84 data_len = LE_le32toh (data_len); 109 85 110 86 if ( (8 != sample_size) && 111 87 (16 != sample_size) )