about summary refs log tree commit diff
path: root/sysdeps/unix/sysv/linux/i386
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-09-20 00:16:11 +0000
committerUlrich Drepper <drepper@redhat.com>2004-09-20 00:16:11 +0000
commit2edb61e3f955bfcc9dd3cb6b3b1acfe4806234a6 (patch)
treeeb3ba83120d92a0ea9955520f2df4e00a22bc884 /sysdeps/unix/sysv/linux/i386
parent29e11320c90722aec6335a5f8d8af84d12ba3c6b (diff)
downloadglibc-2edb61e3f955bfcc9dd3cb6b3b1acfe4806234a6.tar.gz
glibc-2edb61e3f955bfcc9dd3cb6b3b1acfe4806234a6.tar.xz
glibc-2edb61e3f955bfcc9dd3cb6b3b1acfe4806234a6.zip
Update.
	* sysdeps/unix/sysv/linux/setegid.c [HAVE_PTR__NPTL_SETXID]: Call
	callback to set IDs in all other threads as well.
	* sysdeps/unix/sysv/linux/seteuid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setegid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/seteuid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setgid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setuid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setreuid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setreuid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setresuid.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/setresuid.c: Likewise.
	* sysdeps/unix/sysv/linux/setuid.c: New file.
	* sysdeps/unix/sysv/linux/setgid.c: New file.
	* sysdeps/unix/sysv/linux/setreuid.c: New file.
	* sysdeps/unix/sysv/linux/setregid.c: New file.
	* sysdeps/unix/sysv/linux/setresuid.c: New file.
	* sysdeps/unix/sysv/linux/setresgid.c: New file.
	* sysdeps/unix/sysv/linux/i386/sysdep.h: Define INTERNAL_SYSCALL_NCS.
	* sysdeps/unix/sysv/linux/ia64/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setegid.c: Use x86 version.
	* sysdeps/unix/sysv/linux/sparc/sparc32/seteuid.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setresgid.c: New file.
	* sysdeps/unix/sysv/linux/sparc/sparc32/setresuid.c: New file.
	* sysdeps/unix/sysv/linux/sparc/sparc32/syscalls.list: Remove setresgid
	and setresuid.
	* nscd/aicache.c: Use pthread_seteuid_np instead of seteuid.
	* nscd/grpcache.c: Likewise.
	* nscd/hstcache.c: Likewise.
	* nscd/pwdcache.c: Likewise.
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386')
-rw-r--r--sysdeps/unix/sysv/linux/i386/setegid.c28
-rw-r--r--sysdeps/unix/sysv/linux/i386/seteuid.c28
-rw-r--r--sysdeps/unix/sysv/linux/i386/setgid.c33
-rw-r--r--sysdeps/unix/sysv/linux/i386/setregid.c32
-rw-r--r--sysdeps/unix/sysv/linux/i386/setresgid.c34
-rw-r--r--sysdeps/unix/sysv/linux/i386/setresuid.c34
-rw-r--r--sysdeps/unix/sysv/linux/i386/setreuid.c32
-rw-r--r--sysdeps/unix/sysv/linux/i386/setuid.c33
-rw-r--r--sysdeps/unix/sysv/linux/i386/sysdep.h42
9 files changed, 256 insertions, 40 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/setegid.c b/sysdeps/unix/sysv/linux/i386/setegid.c
index fcd6cf1827..b8682e3681 100644
--- a/sysdeps/unix/sysv/linux/i386/setegid.c
+++ b/sysdeps/unix/sysv/linux/i386/setegid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995-1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1998,2000,2002,2003,2004 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
@@ -22,6 +22,7 @@
 
 #include <sysdep.h>
 #include "kernel-features.h"
+#include <pthread-functions.h>
 
 
 #ifdef __NR_setresgid
@@ -32,10 +33,17 @@ int
 setegid (gid)
      gid_t gid;
 {
+  int result;
+
+  if (gid == (gid_t) ~0)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (setresgid32, 3, -1, gid, -1);
+  result = INLINE_SYSCALL (setresgid32, 3, -1, gid, -1);
 #else
-  int result;
   /* First try the syscall.  */
 # ifdef __NR_setresgid
   result = __setresgid (-1, gid, -1);
@@ -49,8 +57,20 @@ setegid (gid)
        equal to the real user ID, making it impossible to switch back.  */
 # endif
     result = __setregid (-1, gid);
+#endif
 
-  return result;
+#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
+  if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
+    {
+      struct xid_command cmd;
+      cmd.syscall_no = __NR_setresgid32;
+      cmd.id[0] = -1;
+      cmd.id[1] = gid;
+      cmd.id[2] = -1;
+      __libc_pthread_functions.ptr__nptl_setxid (&cmd);
+    }
 #endif
+
+  return result;
 }
 libc_hidden_def (setegid)
diff --git a/sysdeps/unix/sysv/linux/i386/seteuid.c b/sysdeps/unix/sysv/linux/i386/seteuid.c
index 87e348a646..0abdac832f 100644
--- a/sysdeps/unix/sysv/linux/i386/seteuid.c
+++ b/sysdeps/unix/sysv/linux/i386/seteuid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2002, 2003, 2004 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
@@ -22,6 +22,7 @@
 
 #include <sysdep.h>
 #include "kernel-features.h"
+#include <pthread-functions.h>
 
 
 #ifdef __NR_setresuid
@@ -31,10 +32,17 @@ extern int __setresuid (uid_t ruid, uid_t euid, uid_t suid);
 int
 seteuid (uid_t uid)
 {
+  int result;
+
+  if (uid == (uid_t) ~0)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (setresuid32, 3, -1, uid, -1);
+  result = INLINE_SYSCALL (setresuid32, 3, -1, uid, -1);
 #else
-  int result;
   /* First try the syscall.  */
 # ifdef __NR_setresuid
   result = __setresuid (-1, uid, -1);
@@ -48,8 +56,20 @@ seteuid (uid_t uid)
        equal to the real user ID, making it impossible to switch back.  */
 # endif
     result = __setreuid (-1, uid);
+#endif
 
-  return result;
+#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
+  if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
+    {
+      struct xid_command cmd;
+      cmd.syscall_no = __NR_setresuid32;
+      cmd.id[0] = -1;
+      cmd.id[1] = uid;
+      cmd.id[2] = -1;
+      __libc_pthread_functions.ptr__nptl_setxid (&cmd);
+    }
 #endif
+
+  return result;
 }
 libc_hidden_def (seteuid)
diff --git a/sysdeps/unix/sysv/linux/i386/setgid.c b/sysdeps/unix/sysv/linux/i386/setgid.c
index 1fdca94064..17bfc3e58a 100644
--- a/sysdeps/unix/sysv/linux/i386/setgid.c
+++ b/sysdeps/unix/sysv/linux/i386/setgid.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2003, 2004
+   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
@@ -26,6 +27,8 @@
 #include <linux/posix_types.h>
 
 #include "kernel-features.h"
+#include <pthread-functions.h>
+
 
 #ifdef __NR_setgid32
 # if __ASSUME_32BITUIDS == 0
@@ -38,18 +41,21 @@ extern int __libc_missing_32bit_uids;
 int
 __setgid (gid_t gid)
 {
+  int result;
+
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (setgid32, 1, gid);
+  result = INLINE_SYSCALL (setgid32, 1, gid);
 #else
 # ifdef __NR_setgid32
   if (__libc_missing_32bit_uids <= 0)
     {
-      int result;
       int saved_errno = errno;
 
       result = INLINE_SYSCALL (setgid32, 1, gid);
 
-      if (result == 0 || errno != ENOSYS)
+      if (result == 0)
+	goto out;
+      if (errno != ENOSYS)
 	return result;
 
       __set_errno (saved_errno);
@@ -64,7 +70,24 @@ __setgid (gid_t gid)
       return -1;
     }
 
-  return INLINE_SYSCALL (setgid, 1, gid);
+  result = INLINE_SYSCALL (setgid, 1, gid);
+# ifdef __NR_setgid32
+ out:
+# endif
+#endif
+
+#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
+  if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
+    {
+      struct xid_command cmd;
+      cmd.syscall_no = __NR_setgid32;
+      cmd.id[0] = gid;
+      __libc_pthread_functions.ptr__nptl_setxid (&cmd);
+    }
 #endif
+
+  return result;
 }
+#ifndef __setgid
 weak_alias (__setgid, setgid)
+#endif
diff --git a/sysdeps/unix/sysv/linux/i386/setregid.c b/sysdeps/unix/sysv/linux/i386/setregid.c
index be1d73cb99..f883497fae 100644
--- a/sysdeps/unix/sysv/linux/i386/setregid.c
+++ b/sysdeps/unix/sysv/linux/i386/setregid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2003, 2004 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
@@ -25,6 +25,7 @@
 
 #include <linux/posix_types.h>
 #include "kernel-features.h"
+#include <pthread-functions.h>
 
 
 #ifdef __NR_setregid32
@@ -38,18 +39,21 @@ extern int __libc_missing_32bit_uids;
 int
 __setregid (gid_t rgid, gid_t egid)
 {
+  int result;
+
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (setregid32, 2, rgid, egid);
+  result = INLINE_SYSCALL (setregid32, 2, rgid, egid);
 #else
 # ifdef __NR_setregid32
   if (__libc_missing_32bit_uids <= 0)
     {
-      int result;
       int saved_errno = errno;
 
       result = INLINE_SYSCALL (setregid32, 2, rgid, egid);
 
-      if (result == 0 || errno != ENOSYS)
+      if (result == 0)
+	goto out;
+      if (errno != ENOSYS)
 	return result;
 
       __set_errno (saved_errno);
@@ -63,7 +67,25 @@ __setregid (gid_t rgid, gid_t egid)
       return -1;
     }
 
-  return INLINE_SYSCALL (setregid, 2, rgid, egid);
+  result = INLINE_SYSCALL (setregid, 2, rgid, egid);
+# ifdef __NR_setregid32
+ out:
+# endif
 #endif
+
+#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
+  if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
+    {
+      struct xid_command cmd;
+      cmd.syscall_no = __NR_setregid32;
+      cmd.id[0] = rgid;
+      cmd.id[1] = egid;
+      __libc_pthread_functions.ptr__nptl_setxid (&cmd);
+    }
+#endif
+
+  return result;
 }
+#ifndef __setregid
 weak_alias (__setregid, setregid)
+#endif
diff --git a/sysdeps/unix/sysv/linux/i386/setresgid.c b/sysdeps/unix/sysv/linux/i386/setresgid.c
index 414a58b07e..ee782e49f3 100644
--- a/sysdeps/unix/sysv/linux/i386/setresgid.c
+++ b/sysdeps/unix/sysv/linux/i386/setresgid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2002, 2003, 2004 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
@@ -25,6 +25,8 @@
 #include <sysdep.h>
 #include <sys/syscall.h>
 #include "kernel-features.h"
+#include <pthread-functions.h>
+
 
 #ifdef __NR_setresgid
 
@@ -39,17 +41,20 @@ extern int __libc_missing_32bit_uids;
 int
 __setresgid (gid_t rgid, gid_t egid, gid_t sgid)
 {
+  int result;
+
 # if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (setresgid32, 3, rgid, egid, sgid);
+  result = INLINE_SYSCALL (setresgid32, 3, rgid, egid, sgid);
 # else
 #  ifdef __NR_setresgid32
   if (__libc_missing_32bit_uids <= 0)
     {
-      int result;
       int saved_errno = errno;
 
       result = INLINE_SYSCALL (setresgid32, 3, rgid, egid, sgid);
-      if (result == 0 || errno != ENOSYS)
+      if (result == 0)
+	goto out;
+      if (errno != ENOSYS)
 	return result;
 
       __set_errno (saved_errno);
@@ -65,11 +70,30 @@ __setresgid (gid_t rgid, gid_t egid, gid_t sgid)
       return -1;
     }
 
-  return INLINE_SYSCALL (setresgid, 3, rgid, egid, sgid);
+  result = INLINE_SYSCALL (setresgid, 3, rgid, egid, sgid);
+#  ifdef __NR_setresgid32
+ out:
+#  endif
 # endif
+
+#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
+  if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
+    {
+      struct xid_command cmd;
+      cmd.syscall_no = __NR_setresgid32;
+      cmd.id[0] = rgid;
+      cmd.id[1] = egid;
+      cmd.id[2] = sgid;
+      __libc_pthread_functions.ptr__nptl_setxid (&cmd);
+    }
+#endif
+
+  return result;
 }
 libc_hidden_def (__setresgid)
+#ifndef __setresgid
 weak_alias (__setresgid, setresgid)
+#endif
 
 #else
 
diff --git a/sysdeps/unix/sysv/linux/i386/setresuid.c b/sysdeps/unix/sysv/linux/i386/setresuid.c
index 537fb7995b..66e5a1c0c1 100644
--- a/sysdeps/unix/sysv/linux/i386/setresuid.c
+++ b/sysdeps/unix/sysv/linux/i386/setresuid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2002, 2003, 2004 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
@@ -25,6 +25,8 @@
 #include <sysdep.h>
 #include <sys/syscall.h>
 #include "kernel-features.h"
+#include <pthread-functions.h>
+
 
 #ifdef __NR_setresuid
 
@@ -39,17 +41,20 @@ extern int __libc_missing_32bit_uids;
 int
 __setresuid (uid_t ruid, uid_t euid, uid_t suid)
 {
+  int result;
+
 # if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (setresuid32, 3, ruid, euid, suid);
+  result = INLINE_SYSCALL (setresuid32, 3, ruid, euid, suid);
 # else
 #  ifdef __NR_setresuid32
   if (__libc_missing_32bit_uids <= 0)
     {
-      int result;
       int saved_errno = errno;
 
       result = INLINE_SYSCALL (setresuid32, 3, ruid, euid, suid);
-      if (result == 0 || errno != ENOSYS)
+      if (result == 0)
+	goto out;
+      if (errno != ENOSYS)
 	return result;
 
       __set_errno (saved_errno);
@@ -65,11 +70,30 @@ __setresuid (uid_t ruid, uid_t euid, uid_t suid)
       return -1;
     }
 
-  return INLINE_SYSCALL (setresuid, 3, ruid, euid, suid);
+  result = INLINE_SYSCALL (setresuid, 3, ruid, euid, suid);
+#  ifdef __NR_setresuid32
+ out:
+#  endif
 # endif
+
+#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
+  if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
+    {
+      struct xid_command cmd;
+      cmd.syscall_no = __NR_setresuid32;
+      cmd.id[0] = ruid;
+      cmd.id[1] = euid;
+      cmd.id[2] = suid;
+      __libc_pthread_functions.ptr__nptl_setxid (&cmd);
+    }
+#endif
+
+  return result;
 }
 libc_hidden_def (__setresuid)
+#ifndef __setresuid
 weak_alias (__setresuid, setresuid)
+#endif
 
 #else
 
diff --git a/sysdeps/unix/sysv/linux/i386/setreuid.c b/sysdeps/unix/sysv/linux/i386/setreuid.c
index 2aadf7437f..1e1bfcf0d4 100644
--- a/sysdeps/unix/sysv/linux/i386/setreuid.c
+++ b/sysdeps/unix/sysv/linux/i386/setreuid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2003, 2004 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
@@ -25,6 +25,7 @@
 
 #include <linux/posix_types.h>
 #include "kernel-features.h"
+#include <pthread-functions.h>
 
 
 #ifdef __NR_setreuid32
@@ -38,18 +39,21 @@ extern int __libc_missing_32bit_uids;
 int
 __setreuid (uid_t ruid, uid_t euid)
 {
+  int result;
+
 #if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (setreuid32, 2, ruid, euid);
+  result = INLINE_SYSCALL (setreuid32, 2, ruid, euid);
 #else
 # ifdef __NR_setreuid32
   if (__libc_missing_32bit_uids <= 0)
     {
-      int result;
       int saved_errno = errno;
 
       result = INLINE_SYSCALL (setreuid32, 2, ruid, euid);
 
-      if (result == 0 || errno != ENOSYS)
+      if (result == 0)
+	goto out;
+      if (errno != ENOSYS)
 	return result;
 
       __set_errno (saved_errno);
@@ -63,7 +67,25 @@ __setreuid (uid_t ruid, uid_t euid)
       return -1;
     }
 
-  return INLINE_SYSCALL (setreuid, 2, ruid, euid);
+  result = INLINE_SYSCALL (setreuid, 2, ruid, euid);
+# ifdef __NR_setreuid32
+ out:
+# endif
 #endif
+
+#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
+  if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
+    {
+      struct xid_command cmd;
+      cmd.syscall_no = __NR_setreuid32;
+      cmd.id[0] = ruid;
+      cmd.id[1] = euid;
+      __libc_pthread_functions.ptr__nptl_setxid (&cmd);
+    }
+#endif
+
+  return result;
 }
+#ifndef __setreuid
 weak_alias (__setreuid, setreuid)
+#endif
diff --git a/sysdeps/unix/sysv/linux/i386/setuid.c b/sysdeps/unix/sysv/linux/i386/setuid.c
index 69bf42596f..a11fb7f60c 100644
--- a/sysdeps/unix/sysv/linux/i386/setuid.c
+++ b/sysdeps/unix/sysv/linux/i386/setuid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 2000, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 2000, 2003, 2004 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
@@ -25,6 +25,8 @@
 
 #include <linux/posix_types.h>
 #include "kernel-features.h"
+#include <pthread-functions.h>
+
 
 #ifdef __NR_setuid32
 # if __ASSUME_32BITUIDS == 0
@@ -37,8 +39,10 @@ extern int __libc_missing_32bit_uids;
 int
 __setuid (uid_t uid)
 {
-#if __ASSUME_32BITUIDS > 0
-  return INLINE_SYSCALL (setuid32, 1, uid);
+  int result;
+
+#if __ASSUME_32BITUIDS > 0 && defined __NR_setuid32
+  result = INLINE_SYSCALL (setuid32, 1, uid);
 #else
 # ifdef __NR_setuid32
   if (__libc_missing_32bit_uids <= 0)
@@ -47,7 +51,9 @@ __setuid (uid_t uid)
       int saved_errno = errno;
 
       result = INLINE_SYSCALL (setuid32, 1, uid);
-      if (result == 0 || errno != ENOSYS)
+      if (result == 0)
+	goto out;
+      if (errno != ENOSYS)
 	return result;
 
       __set_errno (saved_errno);
@@ -62,7 +68,24 @@ __setuid (uid_t uid)
       return -1;
     }
 
-  return INLINE_SYSCALL (setuid, 1, uid);
+  result = INLINE_SYSCALL (setuid, 1, uid);
+# ifdef __NR_setuid32
+ out:
+# endif
+#endif
+
+#if defined HAVE_PTR__NPTL_SETXID && !defined SINGLE_THREAD
+  if (result == 0 && __libc_pthread_functions.ptr__nptl_setxid != NULL)
+    {
+      struct xid_command cmd;
+      cmd.syscall_no = __NR_setuid32;
+      cmd.id[0] = uid;
+      __libc_pthread_functions.ptr__nptl_setxid (&cmd);
+    }
 #endif
+
+  return result;
 }
+#ifndef __setuid
 weak_alias (__setuid, setuid)
+#endif
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 79ad72abff..8845e46157 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -1,4 +1,5 @@
-/* Copyright (C) 1992,1993,1995-2000,2002,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1992,1993,1995-2000,2002,2003,2004
+   Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper, <drepper@gnu.org>, August 1995.
 
@@ -343,7 +344,10 @@ asm (".L__X'%ebx = 1\n\t"
 /* Define a macro which expands inline into the wrapper code for a system
    call.  This use is for internal calls that do not need to handle errors
    normally.  It will never touch errno.  This returns just what the kernel
-   gave back.  */
+   gave back.
+
+   The _NCS variant allows non-constant syscall numbers but it is not
+   possible to use more than four parameters.  */
 #undef INTERNAL_SYSCALL
 #ifdef I386_USE_SYSENTER
 # ifdef SHARED
@@ -360,6 +364,18 @@ asm (".L__X'%ebx = 1\n\t"
     : "i" (__NR_##name), "i" (offsetof (tcbhead_t, sysinfo))		      \
       ASMFMT_##nr(args) : "memory", "cc");				      \
     (int) resultvar; })
+#  define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+  ({									      \
+    register unsigned int resultvar;					      \
+    EXTRAVAR_##nr							      \
+    asm volatile (							      \
+    LOADARGS_##nr							      \
+    "call *%%gs:%P2\n\t"						      \
+    RESTOREARGS_##nr							      \
+    : "=a" (resultvar)							      \
+    : "0" (name), "i" (offsetof (tcbhead_t, sysinfo))			      \
+      ASMFMT_##nr(args) : "memory", "cc");				      \
+    (int) resultvar; })
 # else
 #  define INTERNAL_SYSCALL(name, err, nr, args...) \
   ({									      \
@@ -373,6 +389,17 @@ asm (".L__X'%ebx = 1\n\t"
     : "=a" (resultvar)							      \
     : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc");		      \
     (int) resultvar; })
+#  define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+  ({									      \
+    register unsigned int resultvar;					      \
+    EXTRAVAR_##nr							      \
+    asm volatile (							      \
+    LOADARGS_##nr							      \
+    "call *_dl_sysinfo\n\t"						      \
+    RESTOREARGS_##nr							      \
+    : "=a" (resultvar)							      \
+    : "0" (name) ASMFMT_##nr(args) : "memory", "cc");			      \
+    (int) resultvar; })
 # endif
 #else
 # define INTERNAL_SYSCALL(name, err, nr, args...) \
@@ -387,6 +414,17 @@ asm (".L__X'%ebx = 1\n\t"
     : "=a" (resultvar)							      \
     : "i" (__NR_##name) ASMFMT_##nr(args) : "memory", "cc");		      \
     (int) resultvar; })
+# define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \
+  ({									      \
+    register unsigned int resultvar;					      \
+    EXTRAVAR_##nr							      \
+    asm volatile (							      \
+    LOADARGS_##nr							      \
+    "int $0x80\n\t"							      \
+    RESTOREARGS_##nr							      \
+    : "=a" (resultvar)							      \
+    : "0" (name) ASMFMT_##nr(args) : "memory", "cc");			      \
+    (int) resultvar; })
 #endif
 
 #undef INTERNAL_SYSCALL_DECL