_DBUS_STRUCT_OFFSET
Miloslav Trmac
mitr@volny.cz
Sat, 28 Jun 2003 05:08:47 +0200
--NtwzykIc2mflq5ck
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hello,
attached patch removes _DBUS_STRUCT_OFFSET. The offsetof macro in
<stddef.h> is defined by ANSI C and its usage does not invoke undefined
behavior, which _DBUS_STRUCT_OFFSET does, strictly speaking.
Mirek
--NtwzykIc2mflq5ck
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch-offsetof
diff -ur dbus/dbus/dbus-internals.h sw/dbus/dbus/dbus-internals.h
--- dbus/dbus/dbus-internals.h 2003-06-28 01:16:52.000000000 +0200
+++ sw/dbus/dbus/dbus-internals.h 2003-06-28 01:39:01.000000000 +0200
@@ -117,9 +117,6 @@
#define _DBUS_ZERO(object) (memset (&(object), '\0', sizeof ((object))))
-#define _DBUS_STRUCT_OFFSET(struct_type, member) \
- ((long) ((unsigned char*) &((struct_type*) 0)->member))
-
#define _DBUS_ASSERT_ERROR_IS_SET(error) _dbus_assert ((error) == NULL || dbus_error_is_set ((error)))
#define _DBUS_ASSERT_ERROR_IS_CLEAR(error) _dbus_assert ((error) == NULL || !dbus_error_is_set ((error)))
diff -ur dbus/dbus/dbus-sysdeps.c sw/dbus/dbus/dbus-sysdeps.c
--- dbus/dbus/dbus-sysdeps.c 2003-06-28 01:16:52.000000000 +0200
+++ sw/dbus/dbus/dbus-sysdeps.c 2003-06-28 01:39:50.000000000 +0200
@@ -1933,12 +1933,9 @@
_DBUS_POLLHUP == POLLHUP &&
_DBUS_POLLNVAL == POLLNVAL &&
sizeof (DBusPollFD) == sizeof (struct pollfd) &&
- _DBUS_STRUCT_OFFSET (DBusPollFD, fd) ==
- _DBUS_STRUCT_OFFSET (struct pollfd, fd) &&
- _DBUS_STRUCT_OFFSET (DBusPollFD, events) ==
- _DBUS_STRUCT_OFFSET (struct pollfd, events) &&
- _DBUS_STRUCT_OFFSET (DBusPollFD, revents) ==
- _DBUS_STRUCT_OFFSET (struct pollfd, revents))
+ offsetof (DBusPollFD, fd) == offsetof (struct pollfd, fd) &&
+ offsetof (DBusPollFD, events) == offsetof (struct pollfd, events) &&
+ offsetof (DBusPollFD, revents) == offsetof (struct pollfd, revents))
{
return poll ((struct pollfd*) fds,
n_fds,
diff -ur dbus/ChangeLog sw/dbus/ChangeLog
--- dbus/ChangeLog 2003-06-28 01:16:52.000000000 +0200
+++ sw/dbus/ChangeLog 2003-06-28 01:51:46.000000000 +0200
@@ -1,3 +1,9 @@
+2003-06-28 Miloslav Trmac <mitr@volny.cz>
+
+ * dbus/dbus-internals.h (_DBUS_STRUCT_OFFSET): Remove
+ * dbus/dbus-sysdeps.c (_dbus_poll): Replace _DBUS_STRUCT_OFFSET
+ by offsetof
+
2003-06-24 Havoc Pennington <hp@pobox.com>
* mono/*.cs: Use IntPtr.Zero instead of ((IntPtr) 0)
--NtwzykIc2mflq5ck--