From 2d887db3b973df8c9e00671b704070a280a77889 Mon Sep 17 00:00:00 2001 From: Stefan Sayer Date: Fri, 15 Feb 2008 13:09:30 +0000 Subject: [PATCH] fixed endianness testing (_BIG_ENDIAN is always defined in endian.h) git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@724 8eb893ce-cfd4-0310-b710-fb5ebe64c474 --- core/AmAudioFile.cpp | 3 ++- core/compat/solaris.h | 15 +++++++++++++++ core/plug-in/sipctrl/hash.cpp | 2 ++ core/plug-in/wav/wav_hdr.c | 3 +-- core/rtp/rtp.h | 2 +- core/rtp/telephone_event.h | 3 ++- 6 files changed, 23 insertions(+), 5 deletions(-) diff --git a/core/AmAudioFile.cpp b/core/AmAudioFile.cpp index f9324ec1..7eb2f1f1 100644 --- a/core/AmAudioFile.cpp +++ b/core/AmAudioFile.cpp @@ -28,6 +28,7 @@ #include "AmAudioFile.h" #include "AmPlugIn.h" #include "AmUtils.h" +#include "compat/solaris.h" #include @@ -303,7 +304,7 @@ int AmAudioFile::read(unsigned int user_ts, unsigned int size) ret = (!ferror(fp) ? s : -1); -#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN) +#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) #define bswap_16(A) ((((u_int16_t)(A) & 0xff00) >> 8) | \ (((u_int16_t)(A) & 0x00ff) << 8)) diff --git a/core/compat/solaris.h b/core/compat/solaris.h index 355b0aea..4e3ddb32 100644 --- a/core/compat/solaris.h +++ b/core/compat/solaris.h @@ -1,5 +1,7 @@ #ifndef __SOLARIS_H__ #define __SOLARIS_H__ + +#ifdef SOLARIS /* * New compatibility code for Solaris. */ @@ -62,4 +64,17 @@ typedef unsigned long long int u_int64_t; #endif + +#if defined(sun) +#include +#if defined(_BIG_ENDIAN) +#define BYTE_ORDER BIG_ENDIAN +#else +#define BYTE_ORDER LITTLE_ENDIAN +#endif +#else +#include +#endif + +#endif /* SOLARIS */ #endif diff --git a/core/plug-in/sipctrl/hash.cpp b/core/plug-in/sipctrl/hash.cpp index 2d7f2f5f..7b0e9839 100644 --- a/core/plug-in/sipctrl/hash.cpp +++ b/core/plug-in/sipctrl/hash.cpp @@ -40,6 +40,8 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy. # include /* attempt to define endianness */ #endif +#include "compat/solaris.h" + /* * My best guess at if you are big-endian or little-endian. This may * need adjustment. diff --git a/core/plug-in/wav/wav_hdr.c b/core/plug-in/wav/wav_hdr.c index 463fe3b9..1f11b790 100644 --- a/core/plug-in/wav/wav_hdr.c +++ b/core/plug-in/wav/wav_hdr.c @@ -32,7 +32,7 @@ #include #include -#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN) +#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) #define bswap_16(A) ((((u_int16_t)(A) & 0xff00) >> 8) | \ (((u_int16_t)(A) & 0x00ff) << 8)) #define bswap_32(A) ((((u_int32_t)(A) & 0xff000000) >> 24) | \ @@ -173,7 +173,6 @@ static int wav_read_header(FILE* fp, struct amci_file_desc_t* fmt_desc) fseek(fp,chunk_size,SEEK_CUR); } - fmt_desc->data_size = chunk_size; return 0; diff --git a/core/rtp/rtp.h b/core/rtp/rtp.h index 29c6a0bb..ac326a12 100644 --- a/core/rtp/rtp.h +++ b/core/rtp/rtp.h @@ -50,7 +50,7 @@ typedef unsigned int u_int32; */ typedef struct { -#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN) +#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) u_int16 version:2; /* protocol version */ u_int16 p:1; /* padding flag */ u_int16 x:1; /* header extension flag */ diff --git a/core/rtp/telephone_event.h b/core/rtp/telephone_event.h index a19270f2..a06a603a 100644 --- a/core/rtp/telephone_event.h +++ b/core/rtp/telephone_event.h @@ -33,6 +33,7 @@ #define _telephone_event_h_ #include +#include "../compat/solaris.h" /* * The type definitions below are valid for 32-bit architectures and @@ -49,7 +50,7 @@ typedef struct { u_int8 event; -#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) || defined(_BIG_ENDIAN) || defined(__BIG_ENDIAN) +#if (defined(__BYTE_ORDER) && (__BYTE_ORDER == __BIG_ENDIAN)) u_int8 e:1; u_int8 r:1; u_int8 volume:6;