check whether enums from <linux/personality.h> are available before using
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 15 Jul 2005 19:40:15 +0000 (19:40 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Fri, 15 Jul 2005 19:40:15 +0000 (19:40 +0000)
them (https://savannah.nongnu.org/bugs/?func=detailitem&item_id=12921)

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2159 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/configure.ac
util-vserver/lib/personalityflag.c
util-vserver/lib/personalitytype.c
util-vserver/m4/ensc_personality.m4 [new file with mode: 0644]

index e506253..9054520 100644 (file)
@@ -121,6 +121,8 @@ AC_MSG_RESULT($use_expensive_tests)
 AC_SUBST(ENSC_USE_EXPENSIVE_TESTS, "$use_expensive_tests")
 
 
+ENSC_CHECK_PERSONALITY_FLAGS
+
 AC_ARG_VAR(CC, [The C compiler])
 
 ENSC_INITRDDIR(initrddir)
index 2cb6b11..84e19df 100644 (file)
 #define DECL(VAL) { #VAL, sizeof(#VAL)-1, (VAL) }
 
 static struct Mapping_uint32 const VALUES[] = {
+#if HAVE_DECL_MMAP_PAGE_ZERO
   DECL(MMAP_PAGE_ZERO),
+#endif
+
+#if HAVE_DECL_ADDR_LIMIT_32BIT  
   DECL(ADDR_LIMIT_32BIT),
+#endif
+
+#if HAVE_DECL_SHORT_INODE
   DECL(SHORT_INODE),
+#endif
+
+#if HAVE_DECL_WHOLE_SECONDS
   DECL(WHOLE_SECONDS),
+#endif
+
+#if HAVE_DECL_STICKY_TIMEOUTS
   DECL(STICKY_TIMEOUTS),
-  DECL(ADDR_LIMIT_3GB)
+#endif
+
+#if HAVE_DECL_ADDR_LIMIT_3GB
+  DECL(ADDR_LIMIT_3GB),
+#endif
 };
 
 uint_least32_t
index 731948e..f5cd0c8 100644 (file)
 #define DECL(VAL) { #VAL, sizeof(#VAL)-1, (PER_ ## VAL) }
 
 static struct Mapping_uint32 const VALUES[] = {
+#if HAVE_DECL_PER_LINUX
   DECL(LINUX),
+#endif
+
+#if HAVE_DECL_PER_LINUX_32BIT
   DECL(LINUX_32BIT),
+#endif
+
+#if HAVE_DECL_PER_SVR4
   DECL(SVR4),
+#endif
+
+#if HAVE_DECL_PER_SVR3
   DECL(SVR3),
+#endif
+
+#if HAVE_DECL_PER_SCOSVR3
   DECL(SCOSVR3),
+#endif
+
+#if HAVE_DECL_PER_OSR5
   DECL(OSR5),
+#endif
+
+#if HAVE_DECL_PER_WYSEV386
   DECL(WYSEV386),
+#endif
+
+#if HAVE_DECL_PER_ISCR4
   DECL(ISCR4),
+#endif
+
+#if HAVE_DECL_PER_BSD
   DECL(BSD),
+#endif
+
+#if HAVE_DECL_PER_SUNOS
   DECL(SUNOS),
+#endif
+
+#if HAVE_DECL_PER_XENIX
   DECL(XENIX),
+#endif
+
+#if HAVE_DECL_PER_LINUX32
   DECL(LINUX32),
+#endif
+
+#if HAVE_DECL_PER_LINUX32_3GB
   DECL(LINUX32_3GB),
+#endif
+
+#if HAVE_DECL_PER_IRIX32
   DECL(IRIX32),
+#endif
+
+#if HAVE_DECL_PER_IRIXN32
   DECL(IRIXN32),
+#endif
+
+#if HAVE_DECL_PER_IRIX64
   DECL(IRIX64),
+#endif
+
+#if HAVE_DECL_PER_RISCOS
   DECL(RISCOS),
+#endif
+
+#if HAVE_DECL_PER_SOLARIS
   DECL(SOLARIS),
+#endif
+
+#if HAVE_DECL_PER_UW7
   DECL(UW7),
+#endif
+
+#if HAVE_DECL_PER_HPUX
   DECL(HPUX),
-  DECL(OSF4)
+#endif
+
+#if HAVE_DECL_PER_OSF4
+  DECL(OSF4),
+#endif
+
 };
 
 static char const *
diff --git a/util-vserver/m4/ensc_personality.m4 b/util-vserver/m4/ensc_personality.m4
new file mode 100644 (file)
index 0000000..d6065ae
--- /dev/null
@@ -0,0 +1,44 @@
+dnl $Id$
+
+dnl Copyright (C) 2002 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+dnl  
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of the GNU General Public License as published by
+dnl the Free Software Foundation; version 2 of the License.
+dnl  
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+dnl GNU General Public License for more details.
+dnl  
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+dnl Usage: ENSC_CHECK_PERSONALITY_FLAGS
+AC_DEFUN([ENSC_CHECK_PERSONALITY_FLAGS],
+[
+       AC_MSG_CHECKING([for declarations in <linux/personality.h>])
+       AC_MSG_RESULT([])
+
+       AC_LANG_PUSH(C)
+       AC_CHECK_DECLS([MMAP_PAGE_ZERO, ADDR_LIMIT_32BIT, SHORT_INODE,
+                       WHOLE_SECONDS, STICKY_TIMEOUTS, ADDR_LIMIT_3GB],
+                      [],[],
+                      [
+#include <linux/personality.h>
+                       ])
+
+       AC_CHECK_DECLS([PER_LINUX, PER_LINUX_32BIT, PER_SVR4, PER_SVR3,
+                        PER_SCOSVR3, PER_OSR5, PER_WYSEV386, PER_ISCR4,
+                       PER_BSD, PER_SUNOS, PER_XENIX, PER_LINUX32,
+                       PER_LINUX32_3GB, PER_IRIX32, PER_IRIXN32,
+                       PER_IRIX64, PER_RISCOS, PER_SOLARIS, PER_UW7,
+                       PER_HPUX, PER_OSF4],
+                      [], [],
+                      [
+#include <linux/personality.h>
+                       ])
+       AC_LANG_POP
+])
+