about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2005-03-03 13:34:35 +0000
committerJakub Jelinek <jakub@redhat.com>2005-03-03 13:34:35 +0000
commitd0fec8d06cc2234c8114b51f630466eff9d5f841 (patch)
tree223a7fdae69137bd5670e59249442bc6a2db1ad1 /sysdeps/unix/sysv/linux
parent00e4559b612f179492ff3721f86c92498894432f (diff)
downloadglibc-d0fec8d06cc2234c8114b51f630466eff9d5f841.tar.gz
glibc-d0fec8d06cc2234c8114b51f630466eff9d5f841.tar.xz
glibc-d0fec8d06cc2234c8114b51f630466eff9d5f841.zip
Updated to fedora-glibc-20050302T1820
Diffstat (limited to 'sysdeps/unix/sysv/linux')
-rw-r--r--sysdeps/unix/sysv/linux/alpha/syscalls.list1
-rw-r--r--sysdeps/unix/sysv/linux/ia64/syscalls.list1
-rw-r--r--sysdeps/unix/sysv/linux/libc_fatal.c32
-rw-r--r--sysdeps/unix/sysv/linux/mips/Makefile110
-rwxr-xr-xsysdeps/unix/sysv/linux/mips/configure4
-rw-r--r--sysdeps/unix/sysv/linux/mips/configure.in4
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h36
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h6
-rw-r--r--sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h6
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h4
-rw-r--r--sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h6
-rw-r--r--sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list1
-rw-r--r--sysdeps/unix/sysv/linux/sys/kd.h10
13 files changed, 145 insertions, 76 deletions
diff --git a/sysdeps/unix/sysv/linux/alpha/syscalls.list b/sysdeps/unix/sysv/linux/alpha/syscalls.list
index 3bbce1c6fd..7b3f233566 100644
--- a/sysdeps/unix/sysv/linux/alpha/syscalls.list
+++ b/sysdeps/unix/sysv/linux/alpha/syscalls.list
@@ -16,7 +16,6 @@ oldsemctl	EXTRA	semctl		i:iiii	__old_semctl	semctl@GLIBC_2.0
 sigstack	-	sigstack	2	sigstack
 vfork		-	vfork		0	__vfork		vfork
 
-getpeername	-	getpeername	i:ipp	__getpeername	getpeername
 getpriority	-	getpriority	i:ii	__getpriority	getpriority
 open		-	open		Ci:siv	__libc_open	__open open !__libc_open64 __open64 open64
 open64		open	-
diff --git a/sysdeps/unix/sysv/linux/ia64/syscalls.list b/sysdeps/unix/sysv/linux/ia64/syscalls.list
index 31c7718d8b..c55c70ef54 100644
--- a/sysdeps/unix/sysv/linux/ia64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/ia64/syscalls.list
@@ -2,7 +2,6 @@
 
 umount2		-	umount		2	__umount2	umount2
 
-getpeername	-	getpeername	i:ipp	__getpeername	getpeername
 getpriority	-	getpriority	i:ii	__getpriority	getpriority
 
 # semaphore and shm system calls
diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c
index a79cfbabb9..c7fac6ab51 100644
--- a/sysdeps/unix/sysv/linux/libc_fatal.c
+++ b/sysdeps/unix/sysv/linux/libc_fatal.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-1995,1997,2000,2002-2004 Free Software Foundation, Inc.
+/* Copyright (C) 1993-1995,1997,2000,2002-2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -27,6 +27,7 @@
 #include <sysdep.h>
 #include <unistd.h>
 #include <sys/syslog.h>
+#include <execinfo.h>
 
 /* Abort with an error message.  */
 #include <not-cancel.h>
@@ -141,8 +142,33 @@ __libc_message (int do_abort, const char *fmt, ...)
   va_end (ap_copy);
 
   if (do_abort)
-    /* Terminate the process.  */
-    abort ();
+    {
+      if (do_abort > 1 && written)
+	{
+	  void *addrs[64];
+#define naddrs (sizeof (addrs) / sizeof (addrs[0]))
+	  int n = __backtrace (addrs, naddrs);
+	  if (n > 2)
+	    {
+#define strnsize(str) str, strlen (str)
+#define writestr(str) write_not_cancel (fd, str)
+	      writestr (strnsize ("======= Backtrace: =========\n"));
+	      __backtrace_symbols_fd (addrs + 1, n - 1, fd);
+
+	      writestr (strnsize ("======= Memory map: ========\n"));
+	      int fd2 = open_not_cancel_2 ("/proc/self/maps", O_RDONLY);
+	      char buf[1024];
+	      ssize_t n2;
+	      while ((n2 = read_not_cancel (fd2, buf, sizeof (buf))) > 0)
+		if (write_not_cancel (fd, buf, n2) != n2)
+		  break;
+	      close_not_cancel_no_status (fd2);
+	    }
+	}
+
+      /* Terminate the process.  */
+      abort ();
+    }
 }
 
 
diff --git a/sysdeps/unix/sysv/linux/mips/Makefile b/sysdeps/unix/sysv/linux/mips/Makefile
index d5e4f6b72d..72fa87b3ff 100644
--- a/sysdeps/unix/sysv/linux/mips/Makefile
+++ b/sysdeps/unix/sysv/linux/mips/Makefile
@@ -9,11 +9,73 @@ sysdep_headers += sys/cachectl.h sys/sysmips.h sys/tas.h
 
 no_syscall_list_h = 1
 
-# Generate the list of SYS_* macros for the system calls (__NR_* macros).
-# We generate not only SYS_<syscall>, pointing at SYS_<abi>_<syscall> if
-# it exists, but also define SYS_<abi>_<syscall> for all ABIs.
+# A callable macro that expands to a shell command.  Preprocess file $(1)
+# using ABI option $(2) and see which macros it defines.  Print FOO for each
+# macro of the form __NR$(3)_FOO, filtering out ABI-specific __NR macros
+# that have a prefix other than $(3).
+mips_list_syscalls =	$(filter-out -m%,$(CC)) -E -x c $(+includes) \
+			    $(sysincludes) -D_LIBC -dM -mabi=$(2) $(1) | \
+			sed -n 's@^\#define __NR$(3)_\([^ ]*\) .*@\1@p' | \
+			sed -e '/^[ON]32_/d' -e '/^N64_/d' -e '/^64_/d' | \
+			LC_ALL=C sort
+
+# Generate a list of SYS_* macros from the linux __NR macros.
+#
+# Before version 2.6, linux had separate 32-bit and 64-bit MIPS ports,
+# each with its own set of headers.  The ports were merged for 2.6 and
+# this merged port defines the syscalls in a slightly different way.
+# There are therefore three sets of headers that we need to consider:
+#
+#    (1) Headers from the separate 32-bit MIPS port.  They just define
+#	 a single list of __NR macros.
+#
+#    (2) Headers from the separate 64-bit MIPS port.  They unconditionally
+#	 define syscalls for all three ABIs, with o32 syscalls prefixed
+#	 by __NR_O32, n32 syscalls prefixed by __NR_N32 and n64 syscalls
+#	 prefixed by plain __NR.
+#
+#    (3) Headers from the combined port.  They use the _MIPS_SIM macro to
+#	 define the right set of syscalls for the current ABI.  The syscalls
+#	 themselves have no special ABI prefix, but the headers also define:
+#
+#	    __NR_O32_Linux{,_syscalls}
+#	    __NR_N32_Linux{,_syscalls}
+#	    __NR_64_Linux{,_syscalls}
+#
+# In case (1) we just want a simple list of SYS_* macros.  In cases (2)
+# and (3) we want a file that will work for all three ABIs, regardless
+# of which ABI we are currently using.  We also want the file to work
+# if the user later moves from (2) to (3).  Thus the file we create
+# for (2) and (3) has the form:
+#
+#    #if _MIPS_SIM == _ABIN32
+#    # ifdef __NR_N32_open
+#    #  define SYS_n32syscall1 __NR_N32_n32syscall1
+#    #  ...
+#    # else
+#    #  define SYS_n32syscall1 __NR_n32syscall1
+#    #  ...
+#    # endif
+#    #elif _MIPS_SIM == _ABI64
+#    # define SYS_n64syscall1 __NR_n64syscall1
+#    # ...
+#    #else
+#    # ifdef __NR_O32_open
+#    #  define SYS_o32syscall1 __NR_O32_o32syscall1
+#    #  ...
+#    # else
+#    #  define SYS_o32syscall1 __NR_o32syscall1
+#    #  ...
+#    # endif
+#    #endif
+#
+# Here, __NR_N32_open and __NR_O32_open are used to detect case (2)
+# over case (3).  The n64 SYS_* macros can always use the normal
+# ABI-less names.
 $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/mips/sys/syscall.h
 	$(make-target-directory)
+	$(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC $< -MD -MP \
+	      -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' > /dev/null
 	{ \
 	 echo '/* Generated at libc build time from kernel syscall list.  */';\
 	 echo ''; \
@@ -22,28 +84,38 @@ $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/mips/sys/s
 	 echo '#endif'; \
 	 echo ''; \
 	 echo '#include <sgidefs.h>'; \
-	 rm -f $(@:.d=.h).newt; \
-	 $(CC) -E -MD -MP -MF $(@:.h=.d)-t -MT '$(@:.d=.h) $(@:.h=.d)' \
-	       -x c $(+includes) $(sysincludes) $< -D_LIBC -dM | \
-	 sed -n 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' \
-	     > $(@:.d=.h).newt; \
-	 if grep SYS_O32_ $(@:.d=.h).newt > /dev/null; then \
+	 rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \
+	 $(call mips_list_syscalls,$<,n32,_N32) > $(@:.d=.h).newn32; \
+	 if test -s $(@:.d=.h).newn32; then \
+	   if grep open $(@:.d=.h).newn32 > /dev/null; then \
+	     $(call mips_list_syscalls,$<,32,_O32) > $(@:.d=.h).new32; \
+	     $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \
+	   else \
+	     $(call mips_list_syscalls,$<,32,) > $(@:.d=.h).new32; \
+	     $(call mips_list_syscalls,$<,n32,) > $(@:.d=.h).newn32; \
+	     $(call mips_list_syscalls,$<,64,) > $(@:.d=.h).new64; \
+	   fi; \
 	   echo '#if _MIPS_SIM == _ABIN32'; \
-	   sed -n 's/^\(#define SYS_\)N32_/\1/p' < $(@:.d=.h).newt | \
-		LC_ALL=C sort; \
+	   echo '# ifdef __NR_N32_open'; \
+	   sed 's@\(.*\)@#  define SYS_\1 __NR_N32_\1@' < $(@:.d=.h).newn32; \
+	   echo '# else'; \
+	   sed 's@\(.*\)@#  define SYS_\1 __NR_\1@' < $(@:.d=.h).newn32; \
+	   echo '# endif'; \
 	   echo '#elif _MIPS_SIM == _ABI64'; \
-	   sed -n 's/^\(#define SYS_\)N64_/\1/p' < $(@:.d=.h).newt | \
-		LC_ALL=C sort; \
+	   sed 's@\(.*\)@# define SYS_\1 __NR_\1@' < $(@:.d=.h).new64; \
 	   echo '#else'; \
-	   sed -n 's/^\(#define SYS_\)O32_/\1/p' < $(@:.d=.h).newt | \
-		LC_ALL=C sort; \
+	   echo '# ifdef __NR_O32_open'; \
+	   sed 's@\(.*\)@#  define SYS_\1 __NR_O32_\1@' < $(@:.d=.h).new32; \
+	   echo '# else'; \
+	   sed 's@\(.*\)@#  define SYS_\1 __NR_\1@' < $(@:.d=.h).new32; \
+	   echo '# endif'; \
 	   echo '#endif'; \
-	   sed -n '/^#define SYS_\([ON]32\|N64\)_/p' < $(@:.d=.h).newt | \
-		LC_ALL=C sort +1.8; \
 	 else \
-	   cat $(@:.d=.h).newt; \
+	   $(CC) -E -x c $(+includes) $(sysincludes) -D_LIBC -dM $< | \
+	   sed -n 's@^\#define __NR_\([^ ]*\) .*@\#define SYS_\1 __NR_\1@p' | \
+	   LC_ALL=C sort; \
 	 fi; \
-	 rm $(@:.d=.h).newt; \
+	 rm -f $(@:.d=.h).new32 $(@:.d=.h).newn32 $(@:.d=.h).new64; \
 	} > $(@:.d=.h).new
 	mv -f $(@:.d=.h).new $(@:.d=.h)
 ifneq (,$(objpfx))
diff --git a/sysdeps/unix/sysv/linux/mips/configure b/sysdeps/unix/sysv/linux/mips/configure
index c081795aa1..4d9568f001 100755
--- a/sysdeps/unix/sysv/linux/mips/configure
+++ b/sysdeps/unix/sysv/linux/mips/configure
@@ -18,7 +18,7 @@ mips*64*)
     { echo "$as_me:$LINENO: WARNING: *** asm/unistd.h not found, it will not be pre-processed" >&5
 echo "$as_me: WARNING: *** asm/unistd.h not found, it will not be pre-processed" >&2;}
     echo '#include <asm/unistd.h>' > asm-unistd.h
-  else
+  elif grep __NR_N32_open "$asm_unistd_h" > /dev/null; then
     # The point of this preprocessing is to turn __NR_<syscall> into
     # __NR_N64_<syscall>, as well as to define __NR_<syscall> to
     # __NR_<abi>_<syscall>, if __NR_<abi>_<syscall> is defined
@@ -68,6 +68,8 @@ BEGIN { print "#include <sgidefs.h>"; }
 {
 	print;
 }'
+  else
+    echo '#include <asm/unistd.h>' > asm-unistd.h
   fi ;;
 mips*)
   rm -f asm-unistd.h
diff --git a/sysdeps/unix/sysv/linux/mips/configure.in b/sysdeps/unix/sysv/linux/mips/configure.in
index 67d965dfda..e2e5d16c55 100644
--- a/sysdeps/unix/sysv/linux/mips/configure.in
+++ b/sysdeps/unix/sysv/linux/mips/configure.in
@@ -18,7 +18,7 @@ mips*64*)
   if test ! -f "$asm_unistd_h"; then
     AC_MSG_WARN([*** asm/unistd.h not found, it will not be pre-processed])
     echo '#include <asm/unistd.h>' > asm-unistd.h
-  else
+  elif grep __NR_N32_open "$asm_unistd_h" > /dev/null; then
     # The point of this preprocessing is to turn __NR_<syscall> into
     # __NR_N64_<syscall>, as well as to define __NR_<syscall> to
     # __NR_<abi>_<syscall>, if __NR_<abi>_<syscall> is defined
@@ -68,6 +68,8 @@ BEGIN { print "#include <sgidefs.h>"; }
 {
 	print;
 }'
+  else
+    echo '#include <asm/unistd.h>' > asm-unistd.h
   fi ;;
 mips*)
   rm -f asm-unistd.h
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h
index b0316b657b..e69de29bb2 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/kern64/sysdep.h
@@ -1,36 +0,0 @@
-/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
-
-#ifndef _LINUX_MIPS_MIPS32_KERN64_SYSDEP_H
-#define _LINUX_MIPS_MIPS32_KERN64_SYSDEP_H 1
-
-/* There is some commonality.  */
-#include <sysdeps/unix/sysv/linux/mips/mips32/sysdep.h>
-
-/* For Linux we can use the system call table in the header file
-	/usr/include/asm/unistd.h
-   of the kernel.  But these symbols do not follow the SYS_* syntax
-   so we have to redefine the `SYS_ify' macro here.  */
-#undef SYS_ify
-#ifdef __STDC__
-# define SYS_ify(syscall_name)	__NR_O32_##syscall_name
-#else
-# define SYS_ify(syscall_name)	__NR_O32_/**/syscall_name
-#endif
-
-#endif /* linux/mips/mips32/kern64/sysdep.h */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
index be343aabca..e6013669a4 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -28,9 +28,9 @@
    so we have to redefine the `SYS_ify' macro here.  */
 #undef SYS_ify
 #ifdef __STDC__
-# define SYS_ify(syscall_name)	__NR_N32_##syscall_name
+# define SYS_ify(syscall_name)	__NR_##syscall_name
 #else
-# define SYS_ify(syscall_name)	__NR_N32_/**/syscall_name
+# define SYS_ify(syscall_name)	__NR_/**/syscall_name
 #endif
 
 #ifdef __ASSEMBLER__
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
index f30a465081..dc0a1a0edc 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002, 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -28,9 +28,9 @@
    so we have to redefine the `SYS_ify' macro here.  */
 #undef SYS_ify
 #ifdef __STDC__
-# define SYS_ify(syscall_name)	__NR_N64_##syscall_name
+# define SYS_ify(syscall_name)	__NR_##syscall_name
 #else
-# define SYS_ify(syscall_name)	__NR_N64_/**/syscall_name
+# define SYS_ify(syscall_name)	__NR_/**/syscall_name
 #endif
 
 #ifdef __ASSEMBLER__
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
index 2ee3e60229..81f37c5103 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,1997-2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 1992,1997-2003,2004,2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -109,7 +109,7 @@
 
 # undef INTERNAL_SYSCALL_ERROR_P
 # define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  (__builtin_expect (err & (1 << 28), 0))
+  ((void) (val), __builtin_expect ((err) & (1 << 28), 0))
 
 # undef INTERNAL_SYSCALL_ERRNO
 # define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index 38a376fa90..17bfa9014f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -1,5 +1,5 @@
-/* Copyright (C) 1992, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
-   Free Software Foundation, Inc.
+/* Copyright (C) 1992,1997,1998,1999,2000,2001,2002,2003,2004,2005
+	Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -122,7 +122,7 @@
 
 #undef INTERNAL_SYSCALL_ERROR_P
 #define INTERNAL_SYSCALL_ERROR_P(val, err) \
-  (__builtin_expect (err & (1 << 28), 0))
+  ((void) (err), __builtin_expect ((err) & (1 << 28), 0))
 
 #undef INTERNAL_SYSCALL_ERRNO
 #define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
index 477f8a9f09..791ab9ba52 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list
@@ -1,6 +1,5 @@
 # File name	Caller	Syscall name	# args	Strong name	Weak names
 
-getpeername	-	getpeername	i:ipp	__getpeername	getpeername
 vfork		-	vfork		0	__vfork		vfork
 
 # semaphore and shm system calls
diff --git a/sysdeps/unix/sysv/linux/sys/kd.h b/sysdeps/unix/sysv/linux/sys/kd.h
index e0d2e869cf..d459c079ed 100644
--- a/sysdeps/unix/sysv/linux/sys/kd.h
+++ b/sysdeps/unix/sysv/linux/sys/kd.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 2005 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -21,9 +21,15 @@
 
 /* Make sure the <linux/types.h> header is not loaded.  */
 #ifndef _LINUX_TYPES_H
-# define _LINUX_TYPES_H	1
+# define _LINUX_TYPES_H		1
+# define __undef_LINUX_TYPES_H
 #endif
 
 #include <linux/kd.h>
 
+#ifdef __undef_LINUX_TYPES_H
+# undef _LINUX_TYPES_H
+# undef __undef_LINUX_TYPES_H
+#endif
+
 #endif	/* sys/kd.h */