setxid.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. if (__builtin_expect (__libc_pthread_functions_init, 0)) \
  30. { \
  31. struct xid_command __cmd; \
  32. __cmd.syscall_no = __NR_##name; \
  33. __SETXID_##nr (__cmd, args); \
  34. __result = PTHFCT_CALL (ptr__nptl_setxid, (&__cmd)); \
  35. } \
  36. else \
  37. __result = INLINE_SYSCALL (name, nr, args); \
  38. __result; \
  39. })
  40. #else
  41. # define INLINE_SETXID_SYSCALL(name, nr, args...) \
  42. ({ \
  43. extern __typeof (__nptl_setxid) __nptl_setxid __attribute__((weak));\
  44. int __result; \
  45. if (__builtin_expect (__nptl_setxid != NULL, 0)) \
  46. { \
  47. struct xid_command __cmd; \
  48. __cmd.syscall_no = __NR_##name; \
  49. __SETXID_##nr (__cmd, args); \
  50. __result =__nptl_setxid (&__cmd); \
  51. } \
  52. else \
  53. __result = INLINE_SYSCALL (name, nr, args); \
  54. __result; \
  55. })
  56. #endif