diff options
author | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-03-22 09:37:17 +0100 |
---|---|---|
committer | Holger Hans Peter Freyther <holger@moiji-mobile.com> | 2015-03-22 09:38:36 +0100 |
commit | 86115434f1f60afe51a87d4c1674a3e2c0d18700 (patch) | |
tree | 42c3f4953443225a51421876077b84720825d42a | |
parent | d69c1ca8fab461ca5cdf65215261df0b2582f7ad (diff) |
endian: Use the new endian macros for portability
Use the new macros to deal with little/big endian. Im a bit
worried to make this change due the little test coverage in
this module but in case of a typo the elements would not be
defined.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | examples/rs232-write.c | 5 | ||||
-rw-r--r-- | include/osmocom/netif/amr.h | 6 | ||||
-rw-r--r-- | include/osmocom/netif/osmux.h | 10 | ||||
-rw-r--r-- | include/osmocom/netif/rtp.h | 6 | ||||
-rw-r--r-- | src/rtp.c | 1 |
6 files changed, 17 insertions, 13 deletions
diff --git a/configure.ac b/configure.ac index 28dde0c..47fba65 100644 --- a/configure.ac +++ b/configure.ac @@ -32,8 +32,6 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], CFLAGS="$saved_CFLAGS" AC_SUBST(SYMBOL_VISIBILITY) -AC_CHECK_HEADER([endian.h], [], [AC_MSG_ERROR([endian.h not found!]) ]) - dnl Generate the output AM_CONFIG_HEADER(config.h) diff --git a/examples/rs232-write.c b/examples/rs232-write.c index 370bd12..11498f3 100644 --- a/examples/rs232-write.c +++ b/examples/rs232-write.c @@ -9,6 +9,7 @@ #include <osmocom/core/msgb.h> #include <osmocom/core/logging.h> #include <osmocom/core/application.h> +#include <osmocom/core/endian.h> #include <osmocom/netif/rs232.h> @@ -110,13 +111,13 @@ static void ubx_checksum(struct msgb *msg, uint8_t *ck) } } -# if __BYTE_ORDER == __LITTLE_ENDIAN +# if OSMO_IS_LITTLE_ENDIAN # define utohl(x) (x) # define utohs(x) (x) # define htoul(x) (x) # define htous(x) (x) # else -# if __BYTE_ORDER == __BIG_ENDIAN +# if OSMO_IS_BIG_ENDIAN # define utohl(x) __bswap_32 (x) # define utohs(x) __bswap_16 (x) # define htoul(x) __bswap_32 (x) diff --git a/include/osmocom/netif/amr.h b/include/osmocom/netif/amr.h index 60dacf6..b0ab8a3 100644 --- a/include/osmocom/netif/amr.h +++ b/include/osmocom/netif/amr.h @@ -1,6 +1,8 @@ #ifndef _OSMO_AMR_H_ #define _OSMO_AMR_H_ +#include <osmocom/core/endian.h> + /* As defined by RFC3267: Adaptive Multi-Rate (AMR) */ /* @@ -41,7 +43,7 @@ */ struct amr_hdr { -#if __BYTE_ORDER == __BIG_ENDIAN +#if OSMO_IS_BIG_ENDIAN /* Payload Header */ uint8_t cmr:4, /* Codec Mode Request */ pad1:4; @@ -50,7 +52,7 @@ struct amr_hdr { ft:4, /* coding mode */ q:1, /* OK (not damaged) at origin? */ pad2:2; -#elif __BYTE_ORDER == __LITTLE_ENDIAN +#elif OSMO_IS_LITTLE_ENDIAN /* Payload Header */ uint8_t pad1:4, cmr:4; diff --git a/include/osmocom/netif/osmux.h b/include/osmocom/netif/osmux.h index 493f64f..0f6f5c9 100644 --- a/include/osmocom/netif/osmux.h +++ b/include/osmocom/netif/osmux.h @@ -1,6 +1,8 @@ #ifndef _OSMUX_H_ #define _OSMUX_H_ +#include <osmocom/core/endian.h> + /* OSmux header: * * ft (3 bits): 0=signalling, 1=voice @@ -17,12 +19,12 @@ #define OSMUX_FT_VOICE_AMR 1 struct osmux_hdr { -#if __BYTE_ORDER == __BIG_ENDIAN +#if OSMO_IS_BIG_ENDIAN uint8_t ft:3, ctr:3, amr_f:1, amr_q:1; -#elif __BYTE_ORDER == __LITTLE_ENDIAN +#elif OSMO_IS_LITTLE_ENDIAN uint8_t amr_q:1, amr_f:1, ctr:3, @@ -31,10 +33,10 @@ struct osmux_hdr { uint8_t seq; #define OSMUX_CID_MAX 255 /* determined by circuit_id */ uint8_t circuit_id; -#if __BYTE_ORDER == __BIG_ENDIAN +#if OSMO_IS_BIG_ENDIAN uint8_t amr_ft:4, amr_cmr:4; -#elif __BYTE_ORDER == __LITTLE_ENDIAN +#elif OSMO_IS_LITTLE_ENDIAN uint8_t amr_cmr:4, amr_ft:4; #endif diff --git a/include/osmocom/netif/rtp.h b/include/osmocom/netif/rtp.h index 1854d6c..729e5c9 100644 --- a/include/osmocom/netif/rtp.h +++ b/include/osmocom/netif/rtp.h @@ -1,16 +1,18 @@ #ifndef _OSMO_RTP_H_ #define _OSMO_RTP_H_ +#include <osmocom/core/endian.h> + /* RTP header as defined by RFC 3550 */ struct rtp_hdr { -#if __BYTE_ORDER == __LITTLE_ENDIAN +#if OSMO_IS_LITTLE_ENDIAN uint8_t csrc_count:4, extension:1, padding:1, version:2; uint8_t payload_type:7, marker:1; -#elif __BYTE_ORDER == __BIG_ENDIAN +#elif OSMO_IS_BIG_ENDIAN uint8_t version:2, padding:1, extension:1, @@ -1,6 +1,5 @@ #include <stdint.h> #include <sys/time.h> -#include <endian.h> #include <errno.h> #include <string.h> /* for memcpy. */ #include <arpa/inet.h> /* for ntohs. */ |