1 /* Copyright (C) 1995-2018 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/>. */
23 #include <shlib-compat.h>
26 /* Define a `union semun' suitable for Linux here. */
29 int val
; /* value for SETVAL */
30 struct semid_ds
*buf
; /* buffer for IPC_STAT & IPC_SET */
31 unsigned short int *array
; /* array for GETALL & SETALL */
32 struct seminfo
*__buf
; /* buffer for IPC_INFO */
35 #ifndef DEFAULT_VERSION
36 # define DEFAULT_VERSION GLIBC_2_2
40 __new_semctl (int semid
, int semnum
, int cmd
, ...)
42 union semun arg
= { 0 };
45 /* Get the argument only if required. */
48 case SETVAL
: /* arg.val */
49 case GETALL
: /* arg.array */
51 case IPC_STAT
: /* arg.buf */
54 case IPC_INFO
: /* arg.__buf */
57 arg
= va_arg (ap
, union semun
);
62 #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
63 return INLINE_SYSCALL_CALL (semctl
, semid
, semnum
, cmd
| __IPC_64
,
66 return INLINE_SYSCALL_CALL (ipc
, IPCOP_semctl
, semid
, semnum
, cmd
| __IPC_64
,
67 SEMCTL_ARG_ADDRESS (arg
));
70 versioned_symbol (libc
, __new_semctl
, semctl
, DEFAULT_VERSION
);
73 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
74 /* Since semctl use a variadic argument for semid_ds there is not need to
75 define and tie the compatibility symbol to the old 'union semun'
78 attribute_compat_text_section
79 __old_semctl (int semid
, int semnum
, int cmd
, ...)
81 union semun arg
= { 0 };
84 /* Get the argument only if required. */
87 case SETVAL
: /* arg.val */
88 case GETALL
: /* arg.array */
90 case IPC_STAT
: /* arg.buf */
93 case IPC_INFO
: /* arg.__buf */
96 arg
= va_arg (ap
, union semun
);
101 # ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
102 return INLINE_SYSCALL_CALL (semctl
, semid
, semnum
, cmd
, arg
.array
);
104 return INLINE_SYSCALL_CALL (ipc
, IPCOP_semctl
, semid
, semnum
, cmd
,
105 SEMCTL_ARG_ADDRESS (arg
));
108 compat_symbol (libc
, __old_semctl
, semctl
, GLIBC_2_0
);