diff --git a/configure.ac b/configure.ac index b3bba70..464ab05 100644 --- a/configure.ac +++ b/configure.ac @@ -46,11 +46,7 @@ AC_ARG_ENABLE( ) AM_CONDITIONAL([BUILD_RPC], [test "x$enable_rpc" = "xyes"]) -AC_C_BIGENDIAN( - [AC_DEFINE([IS_LITTLE_ENDIAN], [0], [Define to 1 if system is little endian])], - [AC_DEFINE([IS_LITTLE_ENDIAN], [1], [Define to 1 if system is little endian])], - [AC_MSG_FAILURE([unable to determine endianness])] -) +AC_C_BIGENDIAN AC_OUTPUT AC_MSG_RESULT([ diff --git a/protobuf-c-rpc/protobuf-c-rpc.c b/protobuf-c-rpc/protobuf-c-rpc.c index 5597ef9..113809c 100644 --- a/protobuf-c-rpc/protobuf-c-rpc.c +++ b/protobuf-c-rpc/protobuf-c-rpc.c @@ -444,7 +444,7 @@ grow_closure_array (ProtobufC_RPC_Client *client) static uint32_t uint32_to_le (uint32_t le) { -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) return le; #else return (le << 24) | (le >> 24) diff --git a/protobuf-c/protobuf-c.c b/protobuf-c/protobuf-c.c index 2659f21..5912a87 100644 --- a/protobuf-c/protobuf-c.c +++ b/protobuf-c/protobuf-c.c @@ -619,7 +619,7 @@ sint64_pack (int64_t value, uint8_t *out) static inline size_t fixed32_pack (uint32_t value, void *out) { -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) memcpy (out, &value, 4); #else uint8_t *buf = out; @@ -639,7 +639,7 @@ fixed32_pack (uint32_t value, void *out) static inline size_t fixed64_pack (uint64_t value, void *out) { -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) memcpy (out, &value, 8); #else fixed32_pack (value, out); @@ -843,7 +843,7 @@ sizeof_elt_in_repeated_array (ProtobufCType type) static void copy_to_little_endian_32 (void *out, const void *in, unsigned N) { -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) memcpy (out, in, N * 4); #else unsigned i; @@ -855,7 +855,7 @@ copy_to_little_endian_32 (void *out, const void *in, unsigned N) static void copy_to_little_endian_64 (void *out, const void *in, unsigned N) { -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) memcpy (out, in, N * 8); #else unsigned i; @@ -1246,7 +1246,7 @@ pack_buffer_packed_payload (const ProtobufCFieldDescriptor *field, case PROTOBUF_C_TYPE_SFIXED32: case PROTOBUF_C_TYPE_FIXED32: case PROTOBUF_C_TYPE_FLOAT: -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) rv = count * 4; goto no_packing_needed; #else @@ -1261,7 +1261,7 @@ pack_buffer_packed_payload (const ProtobufCFieldDescriptor *field, case PROTOBUF_C_TYPE_SFIXED64: case PROTOBUF_C_TYPE_FIXED64: case PROTOBUF_C_TYPE_DOUBLE: -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) rv = count * 8; goto no_packing_needed; #else @@ -1635,7 +1635,7 @@ unzigzag32 (uint32_t v) static inline uint32_t parse_fixed_uint32 (const uint8_t *data) { -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) uint32_t t; memcpy (&t, data, 4); return t; @@ -1673,7 +1673,7 @@ unzigzag64 (uint64_t v) static inline uint64_t parse_fixed_uint64 (const uint8_t *data) { -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) uint64_t t; memcpy (&t, data, 8); return t; @@ -1878,7 +1878,7 @@ parse_packed_repeated_member (ScannedMember *scanned_member, case PROTOBUF_C_TYPE_FIXED32: case PROTOBUF_C_TYPE_FLOAT: count = (scanned_member->len - scanned_member->length_prefix_len) / 4; -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) goto no_unpacking_needed; #else for (i = 0; i < count; i++) @@ -1892,7 +1892,7 @@ parse_packed_repeated_member (ScannedMember *scanned_member, case PROTOBUF_C_TYPE_FIXED64: case PROTOBUF_C_TYPE_DOUBLE: count = (scanned_member->len - scanned_member->length_prefix_len) / 8; -#if IS_LITTLE_ENDIAN +#if !defined(WORDS_BIGENDIAN) goto no_unpacking_needed; #else for (i = 0; i < count; i++)