[glib] GDBusMessage: Make endianness for D-Bus messages match host byte order
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GDBusMessage: Make endianness for D-Bus messages match host byte order
- Date: Wed, 14 Jul 2010 15:44:01 +0000 (UTC)
commit 14e37ef7967a2da594faaab24fe2c9c117cf099f
Author: David Zeuthen <davidz redhat com>
Date: Wed Jul 14 11:39:22 2010 -0400
GDBusMessage: Make endianness for D-Bus messages match host byte order
Signed-off-by: David Zeuthen <davidz redhat com>
gio/gdbusmessage.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/gio/gdbusmessage.c b/gio/gdbusmessage.c
index 412c983..32668d0 100644
--- a/gio/gdbusmessage.c
+++ b/gio/gdbusmessage.c
@@ -1945,8 +1945,18 @@ g_dbus_message_to_blob (GDBusMessage *message,
mos = G_MEMORY_OUTPUT_STREAM (g_memory_output_stream_new (NULL, 0, g_realloc, g_free));
dos = g_data_output_stream_new (G_OUTPUT_STREAM (mos));
- /* TODO: detect endianess... */
+ /* Any D-Bus implementation is supposed to handle both Big and
+ * Little Endian encodings and the Endianness is part of the D-Bus
+ * message - we prefer to use Big Endian (since it's Network Byte
+ * Order and just easier to read for humans) but if the machine is
+ * Little Endian we use that for performance reasons.
+ */
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
byte_order = G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN;
+#else
+ /* this could also be G_PDP_ENDIAN */
+ byte_order = G_DATA_STREAM_BYTE_ORDER_BIG_ENDIAN;
+#endif
g_data_output_stream_set_byte_order (dos, byte_order);
/* Core header */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]