mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-27 22:01:02 +08:00
IS_LITTLE_ENDIAN -> !defined(WORDS_BIGENDIAN)
this simplifies the AC_C_BIGENDIAN invocation.
This commit is contained in:
parent
97c43baba3
commit
49faa55bc2
@ -46,11 +46,7 @@ AC_ARG_ENABLE(
|
|||||||
)
|
)
|
||||||
AM_CONDITIONAL([BUILD_RPC], [test "x$enable_rpc" = "xyes"])
|
AM_CONDITIONAL([BUILD_RPC], [test "x$enable_rpc" = "xyes"])
|
||||||
|
|
||||||
AC_C_BIGENDIAN(
|
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_OUTPUT
|
AC_OUTPUT
|
||||||
AC_MSG_RESULT([
|
AC_MSG_RESULT([
|
||||||
|
@ -444,7 +444,7 @@ grow_closure_array (ProtobufC_RPC_Client *client)
|
|||||||
static uint32_t
|
static uint32_t
|
||||||
uint32_to_le (uint32_t le)
|
uint32_to_le (uint32_t le)
|
||||||
{
|
{
|
||||||
#if IS_LITTLE_ENDIAN
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
return le;
|
return le;
|
||||||
#else
|
#else
|
||||||
return (le << 24) | (le >> 24)
|
return (le << 24) | (le >> 24)
|
||||||
|
@ -619,7 +619,7 @@ sint64_pack (int64_t value, uint8_t *out)
|
|||||||
static inline size_t
|
static inline size_t
|
||||||
fixed32_pack (uint32_t value, void *out)
|
fixed32_pack (uint32_t value, void *out)
|
||||||
{
|
{
|
||||||
#if IS_LITTLE_ENDIAN
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
memcpy (out, &value, 4);
|
memcpy (out, &value, 4);
|
||||||
#else
|
#else
|
||||||
uint8_t *buf = out;
|
uint8_t *buf = out;
|
||||||
@ -639,7 +639,7 @@ fixed32_pack (uint32_t value, void *out)
|
|||||||
static inline size_t
|
static inline size_t
|
||||||
fixed64_pack (uint64_t value, void *out)
|
fixed64_pack (uint64_t value, void *out)
|
||||||
{
|
{
|
||||||
#if IS_LITTLE_ENDIAN
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
memcpy (out, &value, 8);
|
memcpy (out, &value, 8);
|
||||||
#else
|
#else
|
||||||
fixed32_pack (value, out);
|
fixed32_pack (value, out);
|
||||||
@ -843,7 +843,7 @@ sizeof_elt_in_repeated_array (ProtobufCType type)
|
|||||||
static void
|
static void
|
||||||
copy_to_little_endian_32 (void *out, const void *in, unsigned N)
|
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);
|
memcpy (out, in, N * 4);
|
||||||
#else
|
#else
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@ -855,7 +855,7 @@ copy_to_little_endian_32 (void *out, const void *in, unsigned N)
|
|||||||
static void
|
static void
|
||||||
copy_to_little_endian_64 (void *out, const void *in, unsigned N)
|
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);
|
memcpy (out, in, N * 8);
|
||||||
#else
|
#else
|
||||||
unsigned i;
|
unsigned i;
|
||||||
@ -1246,7 +1246,7 @@ pack_buffer_packed_payload (const ProtobufCFieldDescriptor *field,
|
|||||||
case PROTOBUF_C_TYPE_SFIXED32:
|
case PROTOBUF_C_TYPE_SFIXED32:
|
||||||
case PROTOBUF_C_TYPE_FIXED32:
|
case PROTOBUF_C_TYPE_FIXED32:
|
||||||
case PROTOBUF_C_TYPE_FLOAT:
|
case PROTOBUF_C_TYPE_FLOAT:
|
||||||
#if IS_LITTLE_ENDIAN
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
rv = count * 4;
|
rv = count * 4;
|
||||||
goto no_packing_needed;
|
goto no_packing_needed;
|
||||||
#else
|
#else
|
||||||
@ -1261,7 +1261,7 @@ pack_buffer_packed_payload (const ProtobufCFieldDescriptor *field,
|
|||||||
case PROTOBUF_C_TYPE_SFIXED64:
|
case PROTOBUF_C_TYPE_SFIXED64:
|
||||||
case PROTOBUF_C_TYPE_FIXED64:
|
case PROTOBUF_C_TYPE_FIXED64:
|
||||||
case PROTOBUF_C_TYPE_DOUBLE:
|
case PROTOBUF_C_TYPE_DOUBLE:
|
||||||
#if IS_LITTLE_ENDIAN
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
rv = count * 8;
|
rv = count * 8;
|
||||||
goto no_packing_needed;
|
goto no_packing_needed;
|
||||||
#else
|
#else
|
||||||
@ -1635,7 +1635,7 @@ unzigzag32 (uint32_t v)
|
|||||||
static inline uint32_t
|
static inline uint32_t
|
||||||
parse_fixed_uint32 (const uint8_t *data)
|
parse_fixed_uint32 (const uint8_t *data)
|
||||||
{
|
{
|
||||||
#if IS_LITTLE_ENDIAN
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
uint32_t t;
|
uint32_t t;
|
||||||
memcpy (&t, data, 4);
|
memcpy (&t, data, 4);
|
||||||
return t;
|
return t;
|
||||||
@ -1673,7 +1673,7 @@ unzigzag64 (uint64_t v)
|
|||||||
static inline uint64_t
|
static inline uint64_t
|
||||||
parse_fixed_uint64 (const uint8_t *data)
|
parse_fixed_uint64 (const uint8_t *data)
|
||||||
{
|
{
|
||||||
#if IS_LITTLE_ENDIAN
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
uint64_t t;
|
uint64_t t;
|
||||||
memcpy (&t, data, 8);
|
memcpy (&t, data, 8);
|
||||||
return t;
|
return t;
|
||||||
@ -1878,7 +1878,7 @@ parse_packed_repeated_member (ScannedMember *scanned_member,
|
|||||||
case PROTOBUF_C_TYPE_FIXED32:
|
case PROTOBUF_C_TYPE_FIXED32:
|
||||||
case PROTOBUF_C_TYPE_FLOAT:
|
case PROTOBUF_C_TYPE_FLOAT:
|
||||||
count = (scanned_member->len - scanned_member->length_prefix_len) / 4;
|
count = (scanned_member->len - scanned_member->length_prefix_len) / 4;
|
||||||
#if IS_LITTLE_ENDIAN
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
goto no_unpacking_needed;
|
goto no_unpacking_needed;
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < count; i++)
|
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_FIXED64:
|
||||||
case PROTOBUF_C_TYPE_DOUBLE:
|
case PROTOBUF_C_TYPE_DOUBLE:
|
||||||
count = (scanned_member->len - scanned_member->length_prefix_len) / 8;
|
count = (scanned_member->len - scanned_member->length_prefix_len) / 8;
|
||||||
#if IS_LITTLE_ENDIAN
|
#if !defined(WORDS_BIGENDIAN)
|
||||||
goto no_unpacking_needed;
|
goto no_unpacking_needed;
|
||||||
#else
|
#else
|
||||||
for (i = 0; i < count; i++)
|
for (i = 0; i < count; i++)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user