Back to index

glibc  2.9
setxid.h
Go to the documentation of this file.
00001 /* Copyright (C) 2004, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #include <pthreadP.h>
00020 #include <sysdep.h>
00021 
00022 #define __SETXID_1(cmd, arg1) \
00023   cmd.id[0] = arg1
00024 #define __SETXID_2(cmd, arg1, arg2) \
00025   __SETXID_1 (cmd, arg1); cmd.id[1] = arg2
00026 #define __SETXID_3(cmd, arg1, arg2, arg3) \
00027   __SETXID_2 (cmd, arg1, arg2); cmd.id[2] = arg3
00028 
00029 #ifdef SINGLE_THREAD
00030 # define INLINE_SETXID_SYSCALL(name, nr, args...) \
00031   INLINE_SYSCALL (name, nr, args)
00032 #elif defined SHARED
00033 # define INLINE_SETXID_SYSCALL(name, nr, args...) \
00034   ({                                                           \
00035     int __result;                                              \
00036     if (__builtin_expect (__libc_pthread_functions_init, 0))          \
00037       {                                                               \
00038        struct xid_command __cmd;                               \
00039        __cmd.syscall_no = __NR_##name;                                \
00040        __SETXID_##nr (__cmd, args);                                   \
00041        __result = PTHFCT_CALL (ptr__nptl_setxid, (&__cmd));           \
00042        }                                                       \
00043     else                                                       \
00044       __result = INLINE_SYSCALL (name, nr, args);                     \
00045     __result;                                                  \
00046    })
00047 #else
00048 # define INLINE_SETXID_SYSCALL(name, nr, args...) \
00049   ({                                                           \
00050     extern __typeof (__nptl_setxid) __nptl_setxid __attribute__((weak));\
00051     int __result;                                              \
00052     if (__builtin_expect (__nptl_setxid   != NULL, 0))                \
00053       {                                                               \
00054        struct xid_command __cmd;                               \
00055        __cmd.syscall_no = __NR_##name;                                \
00056        __SETXID_##nr (__cmd, args);                                   \
00057        __result =__nptl_setxid (&__cmd);                       \
00058       }                                                               \
00059     else                                                       \
00060       __result = INLINE_SYSCALL (name, nr, args);                     \
00061     __result;                                                  \
00062    })
00063 #endif