|
Packit Service |
82fcde |
/* Copyright (C) 1995-2018 Free Software Foundation, Inc.
|
|
Packit Service |
82fcde |
This file is part of the GNU C Library.
|
|
Packit Service |
82fcde |
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
82fcde |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License as published by the Free Software Foundation; either
|
|
Packit Service |
82fcde |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
82fcde |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
82fcde |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
82fcde |
Lesser General Public License for more details.
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
82fcde |
License along with the GNU C Library; if not, see
|
|
Packit Service |
82fcde |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#include <sys/sem.h>
|
|
Packit Service |
82fcde |
#include <stdarg.h>
|
|
Packit Service |
82fcde |
#include <ipc_priv.h>
|
|
Packit Service |
82fcde |
#include <sysdep.h>
|
|
Packit Service |
82fcde |
#include <shlib-compat.h>
|
|
Packit Service |
82fcde |
#include <errno.h>
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Define a `union semun' suitable for Linux here. */
|
|
Packit Service |
82fcde |
union semun
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
int val; /* value for SETVAL */
|
|
Packit Service |
82fcde |
struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
|
|
Packit Service |
82fcde |
unsigned short int *array; /* array for GETALL & SETALL */
|
|
Packit Service |
82fcde |
struct seminfo *__buf; /* buffer for IPC_INFO */
|
|
Packit Service |
82fcde |
};
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifndef DEFAULT_VERSION
|
|
Packit Service |
82fcde |
# define DEFAULT_VERSION GLIBC_2_2
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
int
|
|
Packit Service |
82fcde |
__new_semctl (int semid, int semnum, int cmd, ...)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
union semun arg = { 0 };
|
|
Packit Service |
82fcde |
va_list ap;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Get the argument only if required. */
|
|
Packit Service |
82fcde |
switch (cmd)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
case SETVAL: /* arg.val */
|
|
Packit Service |
82fcde |
case GETALL: /* arg.array */
|
|
Packit Service |
82fcde |
case SETALL:
|
|
Packit Service |
82fcde |
case IPC_STAT: /* arg.buf */
|
|
Packit Service |
82fcde |
case IPC_SET:
|
|
Packit Service |
82fcde |
case SEM_STAT:
|
|
Packit Service |
82fcde |
case IPC_INFO: /* arg.__buf */
|
|
Packit Service |
82fcde |
case SEM_INFO:
|
|
Packit Service |
82fcde |
va_start (ap, cmd);
|
|
Packit Service |
82fcde |
arg = va_arg (ap, union semun);
|
|
Packit Service |
82fcde |
va_end (ap);
|
|
Packit Service |
82fcde |
break;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
|
|
Packit Service |
82fcde |
return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd | __IPC_64,
|
|
Packit Service |
82fcde |
arg.array);
|
|
Packit Service |
82fcde |
#else
|
|
Packit Service |
82fcde |
return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd | __IPC_64,
|
|
Packit Service |
82fcde |
SEMCTL_ARG_ADDRESS (arg));
|
|
Packit Service |
82fcde |
#endif
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
versioned_symbol (libc, __new_semctl, semctl, DEFAULT_VERSION);
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
|
|
Packit Service |
82fcde |
/* Since semctl use a variadic argument for semid_ds there is not need to
|
|
Packit Service |
82fcde |
define and tie the compatibility symbol to the old 'union semun'
|
|
Packit Service |
82fcde |
definition. */
|
|
Packit Service |
82fcde |
int
|
|
Packit Service |
82fcde |
attribute_compat_text_section
|
|
Packit Service |
82fcde |
__old_semctl (int semid, int semnum, int cmd, ...)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
union semun arg = { 0 };
|
|
Packit Service |
82fcde |
va_list ap;
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
/* Get the argument only if required. */
|
|
Packit Service |
82fcde |
switch (cmd)
|
|
Packit Service |
82fcde |
{
|
|
Packit Service |
82fcde |
case SETVAL: /* arg.val */
|
|
Packit Service |
82fcde |
case GETALL: /* arg.array */
|
|
Packit Service |
82fcde |
case SETALL:
|
|
Packit Service |
82fcde |
case IPC_STAT: /* arg.buf */
|
|
Packit Service |
82fcde |
case IPC_SET:
|
|
Packit Service |
82fcde |
case SEM_STAT:
|
|
Packit Service |
82fcde |
case IPC_INFO: /* arg.__buf */
|
|
Packit Service |
82fcde |
case SEM_INFO:
|
|
Packit Service |
82fcde |
va_start (ap, cmd);
|
|
Packit Service |
82fcde |
arg = va_arg (ap, union semun);
|
|
Packit Service |
82fcde |
va_end (ap);
|
|
Packit Service |
82fcde |
break;
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
|
|
Packit Service |
82fcde |
# ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
|
|
Packit Service |
82fcde |
return INLINE_SYSCALL_CALL (semctl, semid, semnum, cmd, arg.array);
|
|
Packit Service |
82fcde |
# else
|
|
Packit Service |
82fcde |
return INLINE_SYSCALL_CALL (ipc, IPCOP_semctl, semid, semnum, cmd,
|
|
Packit Service |
82fcde |
SEMCTL_ARG_ADDRESS (arg));
|
|
Packit Service |
82fcde |
# endif
|
|
Packit Service |
82fcde |
}
|
|
Packit Service |
82fcde |
compat_symbol (libc, __old_semctl, semctl, GLIBC_2_0);
|
|
Packit Service |
82fcde |
#endif
|