diff options
author | Havoc Pennington <hp@redhat.com> | 2005-01-01 02:35:09 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2005-01-01 02:35:09 +0000 |
commit | bb8f518d07adffbefcc7d592af0655b2afa4ab19 (patch) | |
tree | d9be27772fcb06c3619f1946c0884d7827870459 /dbus/dbus-marshal-basic.c | |
parent | 394d57c76529c688368c88b7098a11f78ed03bd6 (diff) |
add int64 to test suites, fix minor bug where marshaling assumed that DBusOctets8 was aligned when passed in as a function argument
Diffstat (limited to 'dbus/dbus-marshal-basic.c')
-rw-r--r-- | dbus/dbus-marshal-basic.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/dbus/dbus-marshal-basic.c b/dbus/dbus-marshal-basic.c index 9b430a56..f7859d30 100644 --- a/dbus/dbus-marshal-basic.c +++ b/dbus/dbus-marshal-basic.c @@ -195,6 +195,20 @@ pack_4_octets (dbus_uint32_t value, } static void +swap_8_octets (DBusOctets8 *value, + int byte_order) +{ + if (byte_order != DBUS_COMPILER_BYTE_ORDER) + { +#ifdef DBUS_HAVE_INT64 + value->u = DBUS_UINT64_SWAP_LE_BE (value->u); +#else + swap_bytes ((unsigned char *)value, 8); +#endif + } +} + +static void pack_8_octets (DBusOctets8 value, int byte_order, unsigned char *data) @@ -208,8 +222,7 @@ pack_8_octets (DBusOctets8 value, *((dbus_uint64_t*)(data)) = DBUS_UINT64_TO_BE (value.u); #else memcpy (data, &value, 8); - if (byte_order != DBUS_COMPILER_BYTE_ORDER) - swap_bytes ((unsigned char *)data, 8); + swap_8_octets ((DBusOctets8*)data, byte_order); #endif } @@ -483,10 +496,9 @@ marshal_8_octets (DBusString *str, DBusOctets8 value) { _dbus_assert (sizeof (value) == 8); - - if (byte_order != DBUS_COMPILER_BYTE_ORDER) - pack_8_octets (value, byte_order, (unsigned char*) &value); /* pack into self, swapping as we go */ + swap_8_octets (&value, byte_order); + return _dbus_string_insert_8_aligned (str, insert_at, (const unsigned char *)&value); } |