summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulio M. Merino Vidal <jmmv@NetBSD.org>2006-04-09 10:50:43 +0000
committerBenoƮt Dejean <bdejean@src.gnome.org>2006-04-09 10:50:43 +0000
commit3c21c70b6446bba94829d17c18ce89f1124c07d1 (patch)
treea6867ec29a53778d92b1a90cc0d86ec5c0281243
parent9e6115f32274de354766659715ad0fb347bf7d00 (diff)
downloadlibgtop-3c21c70b6446bba94829d17c18ce89f1124c07d1.tar.gz
Use configure checks to detect whether we need to define either KERNEL or
2006-04-04 Julio M. Merino Vidal <jmmv@NetBSD.org> * libgtop-sysdeps.m4: * sysdeps/freebsd/msg_limits.c: Use configure checks to detect whether we need to define either KERNEL or _KERNEL to get the definition of 'struct msginfo' in a BSD system. This replaces the previous checks in the code that relied on __FreeBSD__ and similar macros. Before this change, the explicit definition of _KERNEL in the msg_limits.c file broke the build in NetBSD because it made the system headers pull in stuff unavailable to userland. Fixes bug #337207.
-rw-r--r--ChangeLog16
-rw-r--r--libgtop-sysdeps.m435
-rw-r--r--sysdeps/freebsd/msg_limits.c8
3 files changed, 55 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 888b7f9a..5c3687e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,22 @@
2006-04-04 Julio M. Merino Vidal <jmmv@NetBSD.org>
* libgtop-sysdeps.m4:
+ * sysdeps/freebsd/msg_limits.c:
+
+ Use configure checks to detect whether we need to define either
+ KERNEL or _KERNEL to get the definition of 'struct msginfo' in a
+ BSD system. This replaces the previous checks in the code that
+ relied on __FreeBSD__ and similar macros.
+
+ Before this change, the explicit definition of _KERNEL in the
+ msg_limits.c file broke the build in NetBSD because it made the
+ system headers pull in stuff unavailable to userland.
+
+ Fixes bug #337207.
+
+2006-04-04 Julio M. Merino Vidal <jmmv@NetBSD.org>
+
+ * libgtop-sysdeps.m4:
* sysdeps/freebsd/Makefile.am:
Check for the kvm library and use it to link the suid freebsd
diff --git a/libgtop-sysdeps.m4 b/libgtop-sysdeps.m4
index 953742ad..98b75466 100644
--- a/libgtop-sysdeps.m4
+++ b/libgtop-sysdeps.m4
@@ -192,6 +192,41 @@ AC_DEFUN([GNOME_LIBGTOP_SYSDEPS],[
*** to see how to enable it.])
fi
fi
+
+ AC_MSG_CHECKING(what we need to define to get struct msginfo)
+ AC_CACHE_VAL(msginfo_needs,
+ msginfo_needs=
+ for def in nothing KERNEL _KERNEL; do
+ AC_COMPILE_IFELSE([#define $def
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <stdio.h>
+
+int
+main (void)
+{
+ struct msginfo mi;
+ mi.msgmax = 0;
+ return 0;
+}],
+ [
+ msginfo_needs=$def
+ if test ${msginfo_needs} = KERNEL; then
+ AC_DEFINE(STRUCT_MSGINFO_NEEDS_KERNEL, 1,
+ [Define to 1 if we need to define KERNEL to get 'struct msginfo'])
+ elif test ${msginfo_needs} = _KERNEL; then
+ AC_DEFINE(STRUCT_MSGINFO_NEEDS__KERNEL, 1,
+ [Define to 1 if we need to define _KERNEL to get 'struct msginfo'])
+ fi
+ ]
+ )
+ test -n "${msginfo_needs}" && break
+ done
+ )
+ AC_MSG_RESULT($msginfo_needs)
+ if test -z "${msginfo_needs}"; then
+ AC_MSG_ERROR([Could not find the definition of 'struct msginfo'])
+ fi
;;
linux*)
os_major_version=`uname -r | sed 's/-pre[[0-9]]*//' | \
diff --git a/sysdeps/freebsd/msg_limits.c b/sysdeps/freebsd/msg_limits.c
index 4886e9ad..4d40dc69 100644
--- a/sysdeps/freebsd/msg_limits.c
+++ b/sysdeps/freebsd/msg_limits.c
@@ -45,11 +45,11 @@ glibtop_get_msg_limits_p (glibtop *server, glibtop_msg_limits *buf)
#else
-/* #define KERNEL to get declaration of `struct msginfo'. */
-
-#if (defined(__FreeBSD__) && (__FreeBSD_version < 410000)) || (defined __bsdi__)
+/* Define the appropriate macro (if any) to get declaration of `struct
+ * msginfo'. Needed on, at least, FreeBSD. */
+#if defined (STRUCT_MSGINFO_NEEDS_KERNEL)
#define KERNEL 1
-#else
+#elif defined (STRUCT_MSGINFO_NEEDS__KERNEL)
#define _KERNEL 1
#endif