]>
Commit | Line | Data |
---|---|---|
568035b7 | 1 | /* Copyright (C) 1995-2013 Free Software Foundation, Inc. |
cd090f71 UD |
2 | This file is part of the GNU C Library. |
3 | Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
cd090f71 UD |
9 | |
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
cd090f71 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 PE |
16 | License along with the GNU C Library; if not, see |
17 | <http://www.gnu.org/licenses/>. */ | |
cd090f71 UD |
18 | |
19 | #include <errno.h> | |
20 | #include <stdarg.h> | |
21 | #include <sys/sem.h> | |
22 | #include <ipc_priv.h> | |
23 | ||
24 | #include <sysdep.h> | |
25 | #include <string.h> | |
26 | #include <sys/syscall.h> | |
27 | ||
b5567b2a | 28 | #include <shlib-compat.h> |
cd090f71 UD |
29 | |
30 | struct __old_semid_ds | |
31 | { | |
32 | struct __old_ipc_perm sem_perm; /* operation permission struct */ | |
33 | __time_t sem_otime; /* last semop() time */ | |
34 | __time_t sem_ctime; /* last time changed by semctl() */ | |
35 | struct sem *__sembase; /* ptr to first semaphore in array */ | |
36 | struct sem_queue *__sem_pending; /* pending operations */ | |
37 | struct sem_queue *__sem_pending_last; /* last pending operation */ | |
38 | struct sem_undo *__undo; /* ondo requests on this array */ | |
39 | unsigned short int sem_nsems; /* number of semaphores in set */ | |
40 | }; | |
41 | ||
42 | /* Define a `union semun' suitable for Linux here. */ | |
43 | union semun | |
44 | { | |
45 | int val; /* value for SETVAL */ | |
46 | struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ | |
47 | unsigned short int *array; /* array for GETALL & SETALL */ | |
48 | struct seminfo *__buf; /* buffer for IPC_INFO */ | |
d347a4ab | 49 | struct __old_semid_ds *__old_buf; |
cd090f71 UD |
50 | }; |
51 | ||
d25c879d GM |
52 | #include <bp-checks.h> |
53 | #include <bp-semctl.h> /* definition of CHECK_SEMCTL needs union semum */ | |
54 | ||
cd090f71 UD |
55 | /* Return identifier for array of NSEMS semaphores associated with |
56 | KEY. */ | |
b5567b2a | 57 | #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2) |
cd090f71 | 58 | int __old_semctl (int semid, int semnum, int cmd, ...); |
b5567b2a | 59 | #endif |
cd090f71 UD |
60 | int __new_semctl (int semid, int semnum, int cmd, ...); |
61 | ||
b5567b2a | 62 | #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2) |
cd090f71 | 63 | int |
4a381a81 | 64 | attribute_compat_text_section |
cd090f71 UD |
65 | __old_semctl (int semid, int semnum, int cmd, ...) |
66 | { | |
67 | union semun arg; | |
68 | va_list ap; | |
69 | ||
70 | va_start (ap, cmd); | |
71 | ||
72 | /* Get the argument. */ | |
73 | arg = va_arg (ap, union semun); | |
74 | ||
75 | va_end (ap); | |
76 | ||
d25c879d GM |
77 | return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd, |
78 | CHECK_SEMCTL (&arg, semid, cmd)); | |
cd090f71 | 79 | } |
b5567b2a UD |
80 | compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0); |
81 | #endif | |
cd090f71 UD |
82 | |
83 | int | |
84 | __new_semctl (int semid, int semnum, int cmd, ...) | |
85 | { | |
86 | union semun arg; | |
87 | va_list ap; | |
88 | ||
89 | va_start (ap, cmd); | |
90 | ||
91 | /* Get the argument. */ | |
92 | arg = va_arg (ap, union semun); | |
93 | ||
94 | va_end (ap); | |
95 | ||
d25c879d GM |
96 | return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64, |
97 | CHECK_SEMCTL (&arg, semid, cmd | __IPC_64)); | |
cd090f71 UD |
98 | } |
99 | ||
b5567b2a | 100 | versioned_symbol (libc, __new_semctl, semctl, GLIBC_2_2); |