GNOME Bugzilla – Bug 337207
msg_limits.c build broken in NetBSD
Last modified: 2006-04-09 10:51:17 UTC
The msg_limits.c file has this chunk of code in it: #if (defined(__FreeBSD__) && (__FreeBSD_version < 410000)) || (defined __bsdi__) #define KERNEL 1 #else #define _KERNEL 1 #endif Under NetBSD this conditional obviously falls to the #else part, which defines the _KERNEL macro. This causes later problems during the inclusion of sys/ipc.h and sys/msg.h because they try to pull in many stuff that is not available in userland -- as the _KERNEL macro name implies, defining it means that you are building the kernel! As an example, see what the compiler emits based on a simple test case that defines _KERNEL and later includes sys/msg.h: In file included from test.c:2: /usr/include/sys/msg.h:193:23: sys/systm.h: No such file or directory In file included from test.c:2: /usr/include/sys/msg.h:200: error: parse error before "copyin_t" /usr/include/sys/msg.h:202: error: parse error before "copyout_t" One possible fix could be to change the #else line with '#elif !defined(__NetBSD__)', but that is ugly and extremely delicate (e.g. OpenBSD probably has the same problem, but I do not know). It does not fix the real problem in a clean way. The best solution to address this problem is to add a check in the configure script that detects if we need to define anything (be it KERNEL or _KERNEL) to get the definition of 'struct msginfo' regarless of the BSD flavour/version. This can be achieved by using the AC_COMPILE_IFELSE macro. The attached patch implements the latter solution.
Created attachment 62737 [details] [review] Proposed patch.