[Speex-dev] [patch] Mac Universal Binaries
Jean-Marc Valin
jean-marc.valin at usherbrooke.ca
Wed May 2 16:00:28 PDT 2007
Well, I don't quite understand why AC_C_BIGENDIAN and the solution
you're proposing is likely to break other big endian machines (the ones
that don't have __BIG_ENDIAN__). Can you send a patch that addresses
that (i.e. still uses AC_C_BIGENDIAN when it works)?
Jean-Marc
Peter Grayson a écrit :
> Hi all,
>
> Speex currently decides endianness at configure-time. This causes the
> ppc half of Mac universal binaries to have some endianness problems.
> Most notably, the header built by speex_packet_to_header() has
> incorrect byte-ordering.
>
> This Apple developer page describes the incantation that can be used
> to build universal binaries on Mac. It also highlights the
> configure-time versus compile-time endianess problem
>
> http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/compiling/chapter_4_section_3.html
>
>
> I have included a patch that applies Apple's recommendation to use the
> gcc-defined __BIG_ENDIAN__ preprocessor variable to determine
> endianness at compile-time. This technique works like a champ on Mac.
> It also works fine on Linux variants with modern a modern gcc. And
> Windows works like before.
>
> The patch was made against the head of the subversion trunk.
>
> Hope this helps.
>
> Pete
>
>
> ------------------------------------------------------------------------
>
> Index: src/wav_io.h
> ===================================================================
> --- src/wav_io.h (revision 12905)
> +++ src/wav_io.h (working copy)
> @@ -35,7 +35,7 @@
> #include <stdio.h>
> #include "speex/speex_types.h"
>
> -#ifdef WORDS_BIGENDIAN
> +#ifdef __BIG_ENDIAN__
> #define le_short(s) ((short) ((unsigned short) (s) << 8) | ((unsigned short) (s) >> 8))
> #define be_short(s) ((short) (s))
> #else
> @@ -46,7 +46,7 @@
> /** Convert little endian */
> static inline spx_int32_t le_int(spx_int32_t i)
> {
> -#ifdef WORDS_BIGENDIAN
> +#ifdef __BIG_ENDIAN__
> spx_uint32_t ui, ret;
> ui = i;
> ret = ui>>24;
> Index: configure.ac
> ===================================================================
> --- configure.ac (revision 12905)
> +++ configure.ac (working copy)
> @@ -32,7 +32,6 @@
> AC_CANONICAL_HOST
> AM_PROG_LIBTOOL
>
> -AC_C_BIGENDIAN
> AC_C_CONST
> AC_C_INLINE
> AC_C_RESTRICT
> Index: libspeex/misc.h
> ===================================================================
> --- libspeex/misc.h (revision 12905)
> +++ libspeex/misc.h (working copy)
> @@ -78,7 +78,7 @@
> /** Convert little endian */
> static inline spx_int32_t le_int(spx_int32_t i)
> {
> -#ifdef WORDS_BIGENDIAN
> +#ifdef __BIG_ENDIAN__
> spx_uint32_t ui, ret;
> ui = i;
> ret = ui>>24;
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Speex-dev mailing list
> Speex-dev at xiph.org
> http://lists.xiph.org/mailman/listinfo/speex-dev
More information about the Speex-dev
mailing list