gcc-3 support

Johan Kiviniemi netsplit.com-upstart-devel at johan.kiviniemi.name
Mon Sep 4 13:32:59 BST 2006


Making upstart compile with gcc-3 seems to be as simple as using
offsetof instead of __builtin_offsetof (see the attached patch).

It should not cause any difference in performance (or anything else)
with gcc-4 because gcc-4's <stddef.h> defines offsetof as:

#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)

Of course, i might be missing the point of using __builtin_offsetof in
the first place.

-- 
Jοhan Kiviniemi  http://johan.kiviniemi.name/
-------------- next part --------------
diff -ur upstart-0.2.1.orig/upstart/control.c upstart-0.2.1/upstart/control.c
--- upstart-0.2.1.orig/upstart/control.c	2006-08-31 04:14:14.000000000 +0300
+++ upstart-0.2.1/upstart/control.c	2006-09-04 15:16:27.000000000 +0300
@@ -31,6 +31,7 @@
 
 #include <stdio.h>
 #include <string.h>
+#include <stddef.h>
 #include <unistd.h>
 
 #include <nih/macros.h>
@@ -206,7 +207,7 @@
 	addr->sun_family = AF_UNIX;
 	addr->sun_path[0] = '\0';
 
-	addrlen = __builtin_offsetof (struct sockaddr_un, sun_path) + 1;
+	addrlen = offsetof (struct sockaddr_un, sun_path) + 1;
 	if (pid == INIT_DAEMON) {
 		addrlen += snprintf (addr->sun_path + 1,
 				     sizeof (addr->sun_path) - 1,
diff -ur upstart-0.2.1.orig/upstart/tests/test_control.c upstart-0.2.1/upstart/tests/test_control.c
--- upstart-0.2.1.orig/upstart/tests/test_control.c	2006-08-31 03:49:24.000000000 +0300
+++ upstart-0.2.1/upstart/tests/test_control.c	2006-09-04 15:16:47.000000000 +0300
@@ -171,7 +171,7 @@
 	addr.sun_family = AF_UNIX;
 	addr.sun_path[0] = '\0';
 
-	addrlen = __builtin_offsetof (struct sockaddr_un, sun_path) + 1;
+	addrlen = offsetof (struct sockaddr_un, sun_path) + 1;
 	addrlen += snprintf (addr.sun_path + 1, sizeof (addr.sun_path) -1,
 			     "/com/ubuntu/upstart/%d", getpid ());
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/upstart-devel/attachments/20060904/d0c71c63/attachment.pgp 


More information about the Upstart-devel mailing list