GNOME Bugzilla – Bug 672406
glib/tests/include.c fails to build on FreeBSD
Last modified: 2012-03-22 15:02:53 UTC
glib/tests/include.c #defines _POSIX_C_SOURCE to 0 before #including <pthread.h>, which causes compilation problems on FreeBSD (and perhaps other platforms as well). FreeBSD's pthread.h gets its clockid_t typedef from time.h, which is included per the standard. However, the typedef is created only if _POSIX_C_SOURCE has a valid value (ie. it's bigger than 199309L). At first I thought this was a problem on the FreeBSD side, but per [1] it looks like the problem should be fixed on the glib side. Simply removing the line defining _POSIX_C_SOURCE to 0 should be enough to fix the problem and make the test still test for bug 659866. [1] http://lists.freebsd.org/pipermail/freebsd-threads/2012-March/005251.html
(In reply to comment #0) > Simply removing the line defining _POSIX_C_SOURCE to 0 should be enough to fix > the problem and make the test still test for bug 659866. Sorry about this part; removing that define will make glibc set _POSIX_C_SOURCE to 200809L, which is not what we want. Setting it to 199309 should make it work as expected on both glibc (doesn't turn __USE_UNIX98 or __USE_XOPEN2K on) and FreeBSD's libc (creates the clockid_t typedef, __USE_UNIX98 and __USE_XOPEN2K are never defined or used anywhere).
Created attachment 210102 [details] [review] Proposed fix. Proposed patch for master (dunno if it needs to be applied to other branches too).
Review of attachment 210102 [details] [review]: Testing include semantics is kind of painful...but let's keep it working. Patch looks OK to me.