setxid.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright (C) 2004, 2007 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <pthreadP.h>
  15. #include <sysdep.h>
  16. #define __SETXID_1(cmd, arg1) \
  17. cmd.id[0] = arg1
  18. #define __SETXID_2(cmd, arg1, arg2) \
  19. __SETXID_1 (cmd, arg1); cmd.id[1] = arg2
  20. #define __SETXID_3(cmd, arg1, arg2, arg3) \
  21. __SETXID_2 (cmd, arg1, arg2); cmd.id[2] = arg3
  22. #ifdef SINGLE_THREAD
  23. # define INLINE_SETXID_SYSCALL(name, nr, args...) \
  24. INLINE_SYSCALL (name, nr, args)
  25. #elif defined SHARED
  26. # define INLINE_SETXID_SYSCALL(name, nr, args...) \
  27. ({ \
  28. int __result; \
  29. struct xid_command __cmd; \
  30. __cmd.syscall_no = __NR_##name; \
  31. __SETXID_##nr (__cmd, args); \
  32. __result = PTHFCT_CALL (__nptl_setxid, (&__cmd)); \
  33. } \
  34. __result; \
  35. })
  36. #else
  37. # define INLINE_SETXID_SYSCALL(name, nr, args...) \
  38. ({ \
  39. extern __typeof (__nptl_setxid) __nptl_setxid __attribute__((weak));\
  40. int __result; \
  41. if (__builtin_expect (__nptl_setxid != NULL, 0)) \
  42. { \
  43. struct xid_command __cmd; \
  44. __cmd.syscall_no = __NR_##name; \
  45. __SETXID_##nr (__cmd, args); \
  46. __result =__nptl_setxid (&__cmd); \
  47. } \
  48. else \
  49. __result = INLINE_SYSCALL (name, nr, args); \
  50. __result; \
  51. })
  52. #endif