Ticket #68144: endian.patch

File endian.patch, 6.0 KB (added by ryandesign (Ryan Carsten Schmidt), 14 months ago)
  • configure

    old new  
    2131921319
    2132021320fi
    2132121321
    21322  if test "$cross_compiling" = yes; then
    21323         { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cross compiling; assuming big endianess" >&5
    21324 $as_echo "$as_me: WARNING: cross compiling; assuming big endianess" >&2;}
    21325     fi
    21326     { $as_echo "$as_me:${as_lineno-$LINENO}: checking endianess" >&5
    21327 $as_echo_n "checking endianess... " >&6; }
    21328     if ${gnupg_cv_c_endian+:} false; then :
    21329   $as_echo_n "(cached) " >&6
    21330 else
    21331    gnupg_cv_c_endian=unknown
    21332         # See if sys/param.h defines the BYTE_ORDER macro.
    21333         cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    21334 /* end confdefs.h.  */
    21335 #include <sys/types.h>
    21336         #include <sys/param.h>
    21337 int
    21338 main ()
    21339 {
    21340 
    21341         #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
    21342          bogus endian macros
    21343         #endif
    21344   ;
    21345   return 0;
    21346 }
    21347 _ACEOF
    21348 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_ext
    21351 /* end confdefs.h.  */
    21352 #include <sys/types.h>
    21353         #include <sys/param.h>
    21354 int
    21355 main ()
    21356 {
    21357 
    21358         #if BYTE_ORDER != BIG_ENDIAN
    21359          not big endian
    21360         #endif
    21361   ;
    21362   return 0;
    21363 }
    21364 _ACEOF
    21365 if ac_fn_c_try_compile "$LINENO"; then :
    21366   gnupg_cv_c_endian=big
    21367 else
    21368   gnupg_cv_c_endian=little
    21369 fi
    21370 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    21371 fi
    21372 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    21373         if test "$gnupg_cv_c_endian" = unknown; then
    21374             if test "$cross_compiling" = yes; then :
    21375   gnupg_cv_c_endian=big
    21376 
    21377 else
    21378   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    21379 /* end confdefs.h.  */
    21380 main () {
    21381               /* Are we little or big endian?  From Harbison&Steele.  */
    21382               union
    21383               {
    21384                 long l;
    21385                 char c[sizeof (long)];
    21386               } u;
    21387               u.l = 1;
    21388               exit (u.c[sizeof (long) - 1] == 1);
    21389               }
    21390 _ACEOF
    21391 if ac_fn_c_try_run "$LINENO"; then :
    21392   gnupg_cv_c_endian=little
    21393 else
    21394   gnupg_cv_c_endian=big
    21395 fi
    21396 rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
    21397   conftest.$ac_objext conftest.beam conftest.$ac_ext
    21398 fi
    21399 
    21400         fi
    21401 
    21402 fi
    21403 
    21404     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gnupg_cv_c_endian" >&5
    21405 $as_echo "$gnupg_cv_c_endian" >&6; }
    21406     if test "$gnupg_cv_c_endian" = little; then
    21407 
    21408 $as_echo "#define LITTLE_ENDIAN_HOST 1" >>confdefs.h
    21409 
    21410     else
    21411 
    21412 $as_echo "#define BIG_ENDIAN_HOST 1" >>confdefs.h
    21413 
    21414     fi
    21415 
    2141621322
    2141721323# Checks for library functions.
    2141821324{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working memcmp" >&5
  • src/common/le_architecture.h

    old new  
    2828#include <sys/param.h>          /* #define BYTE_ORDER */
    2929#endif
    3030
    31 /* This is copied directly from GNUnet headers */
     31/* This is descended from code copied from GNUnet headers */
    3232
    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
    3439#ifdef _BYTE_ORDER
    35 #define __BYTE_ORDER _BYTE_ORDER
     40#define LE_BYTE_ORDER _BYTE_ORDER
    3641#else
    3742#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
    3947#endif
    4048#endif
    4149#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
    4357#ifdef _BIG_ENDIAN
    44 #define __BIG_ENDIAN _BIG_ENDIAN
     58#define LE_ORDER_BIG_ENDIAN _BIG_ENDIAN
    4559#else
    4660#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
    4864#endif
    4965#endif
    5066#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
    5275#ifdef _LITTLE_ENDIAN
    53 #define __LITTLE_ENDIAN _LITTLE_ENDIAN
     76#define LE_ORDER_LITTLE_ENDIAN _LITTLE_ENDIAN
    5477#else
    5578#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
    5783#endif
    5884#endif
    5985#endif
    6086
     87
    6188/**
    6289 * Endian operations
    6390 */
    6491
    65 #if __BYTE_ORDER == __LITTLE_ENDIAN
     92#if LE_BYTE_ORDER == LE_ORDER_LITTLE_ENDIAN
    6693#define LE_htobe16(x) __bswap_16 (x)
    6794#define LE_htole16(x) (x)
    6895#define LE_be16toh(x) __bswap_16 (x)
     
    78105#define LE_be64toh(x) __bswap_64 (x)
    79106#define LE_le64toh(x) (x)
    80107#endif
    81 #if __BYTE_ORDER == __BIG_ENDIAN
     108
     109#if LE_BYTE_ORDER == LE_ORDER_BIG_ENDIAN
    82110#define LE_htobe16(x) (x)
    83111#define LE_htole16(x) __bswap_16 (x)
    84112#define LE_be16toh(x) (x)
  • src/plugins/wav_extractor.c

    old new  
    3232
    3333#include "platform.h"
    3434#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 *) &in;
    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 *) &in;
    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"
    5836
    5937
    6038/**
     
    10078  sample_size = *((uint16_t *) &buf[34]);
    10179  data_len = *((uint32_t *) &buf[40]);
    10280
    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);
    10985
    11086  if ( (8 != sample_size) &&
    11187       (16 != sample_size) )