dbus/dbus dbus-sysdeps.h,1.44,1.45

Havoc Pennington hp at freedesktop.org
Sat Jan 1 12:53:44 PST 2005


Update of /cvs/dbus/dbus/dbus
In directory gabe:/tmp/cvs-serv1641/dbus

Modified Files:
	dbus-sysdeps.h 
Log Message:
voc Pennington  <hp at redhat.com>

	* dbus/dbus-sysdeps.h: add _DBUS_DOUBLES_BITWISE_EQUAL macro, 
	for a variety of reasons '==' doesn't do this.



Index: dbus-sysdeps.h
===================================================================
RCS file: /cvs/dbus/dbus/dbus/dbus-sysdeps.h,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- dbus-sysdeps.h	29 Oct 2004 19:59:14 -0000	1.44
+++ dbus-sysdeps.h	1 Jan 2005 20:53:42 -0000	1.45
@@ -329,6 +329,21 @@
 #  endif /* va_list is a pointer */
 #endif /* !DBUS_VA_COPY */
 
+/* On x86 there is an 80-bit FPU, and if you do "a == b" it may have a
+ * or b in an 80-bit register, thus failing to compare the two 64-bit
+ * doubles for bitwise equality.
+ */
+#define _DBUS_BYTE_OF_PRIMITIVE(p, i) \
+    (((const char*)&(p))[(i)])
+#define _DBUS_DOUBLES_BITWISE_EQUAL(a, b)                                       \
+     (_DBUS_BYTE_OF_PRIMITIVE (a, 0) == _DBUS_BYTE_OF_PRIMITIVE (b, 0) &&       \
+      _DBUS_BYTE_OF_PRIMITIVE (a, 1) == _DBUS_BYTE_OF_PRIMITIVE (b, 1) &&       \
+      _DBUS_BYTE_OF_PRIMITIVE (a, 2) == _DBUS_BYTE_OF_PRIMITIVE (b, 2) &&       \
+      _DBUS_BYTE_OF_PRIMITIVE (a, 3) == _DBUS_BYTE_OF_PRIMITIVE (b, 3) &&       \
+      _DBUS_BYTE_OF_PRIMITIVE (a, 4) == _DBUS_BYTE_OF_PRIMITIVE (b, 4) &&       \
+      _DBUS_BYTE_OF_PRIMITIVE (a, 5) == _DBUS_BYTE_OF_PRIMITIVE (b, 5) &&       \
+      _DBUS_BYTE_OF_PRIMITIVE (a, 6) == _DBUS_BYTE_OF_PRIMITIVE (b, 6) &&       \
+      _DBUS_BYTE_OF_PRIMITIVE (a, 7) == _DBUS_BYTE_OF_PRIMITIVE (b, 7))
 
 DBUS_END_DECLS
 



More information about the dbus-commit mailing list