Update copyright notices with scripts/update-copyrights
[glibc.git] / sysdeps / unix / sysv / linux / i386 / semctl.c
blob64909ee32b4fd882ceaa010a62bf83dacabdad74
1 /* Copyright (C) 1995-2014 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
5 The GNU C Library is free software; you can redistribute it and/or
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.
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
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <errno.h>
20 #include <stdarg.h>
21 #include <sys/sem.h>
22 #include <ipc_priv.h>
24 #include <sysdep.h>
25 #include <string.h>
26 #include <sys/syscall.h>
28 #include <shlib-compat.h>
30 struct __old_semid_ds
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 */
42 /* Define a `union semun' suitable for Linux here. */
43 union semun
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 */
49 struct __old_semid_ds *__old_buf;
52 /* Return identifier for array of NSEMS semaphores associated with
53 KEY. */
54 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
55 int __old_semctl (int semid, int semnum, int cmd, ...);
56 #endif
57 int __new_semctl (int semid, int semnum, int cmd, ...);
59 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
60 int
61 attribute_compat_text_section
62 __old_semctl (int semid, int semnum, int cmd, ...)
64 union semun arg;
65 va_list ap;
67 va_start (ap, cmd);
69 /* Get the argument. */
70 arg = va_arg (ap, union semun);
72 va_end (ap);
74 return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd,
75 &arg);
77 compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0);
78 #endif
80 int
81 __new_semctl (int semid, int semnum, int cmd, ...)
83 union semun arg;
84 va_list ap;
86 va_start (ap, cmd);
88 /* Get the argument. */
89 arg = va_arg (ap, union semun);
91 va_end (ap);
93 return INLINE_SYSCALL (ipc, 5, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
94 &arg);
97 versioned_symbol (libc, __new_semctl, semctl, GLIBC_2_2);