Blame sysdeps/unix/sysv/linux/shmctl.c

Packit 6c4009
/* Copyright (C) 1995-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, August 1995.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sys/shm.h>
Packit 6c4009
#include <stdarg.h>
Packit 6c4009
#include <ipc_priv.h>
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
#include <shlib-compat.h>
Packit 6c4009
#include <errno.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
#ifndef DEFAULT_VERSION
Packit 6c4009
# define DEFAULT_VERSION GLIBC_2_2
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
/* Provide operations to control over shared memory segments.  */
Packit 6c4009
int
Packit 6c4009
__new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
Packit 6c4009
{
Packit 6c4009
#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
Packit 6c4009
  return INLINE_SYSCALL_CALL (shmctl, shmid, cmd | __IPC_64, buf);
Packit 6c4009
#else
Packit 6c4009
  return INLINE_SYSCALL_CALL (ipc, IPCOP_shmctl, shmid, cmd | __IPC_64, 0,
Packit 6c4009
			      buf);
Packit 6c4009
#endif
Packit 6c4009
}
Packit 6c4009
versioned_symbol (libc, __new_shmctl, shmctl, DEFAULT_VERSION);
Packit 6c4009
Packit 6c4009
Packit 6c4009
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
Packit 6c4009
struct __old_shmid_ds
Packit 6c4009
{
Packit 6c4009
  struct __old_ipc_perm shm_perm;	/* operation permission struct */
Packit 6c4009
  int shm_segsz;			/* size of segment in bytes */
Packit 6c4009
  __time_t shm_atime;			/* time of last shmat() */
Packit 6c4009
  __time_t shm_dtime;			/* time of last shmdt() */
Packit 6c4009
  __time_t shm_ctime;			/* time of last change by shmctl() */
Packit 6c4009
  __ipc_pid_t shm_cpid;			/* pid of creator */
Packit 6c4009
  __ipc_pid_t shm_lpid;			/* pid of last shmop */
Packit 6c4009
  unsigned short int shm_nattch;	/* number of current attaches */
Packit 6c4009
  unsigned short int __shm_npages;	/* size of segment (pages) */
Packit 6c4009
  unsigned long int *__shm_pages;	/* array of ptrs to frames -> SHMMAX */
Packit 6c4009
  struct vm_area_struct *__attaches;	/* descriptors for attaches */
Packit 6c4009
};
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
attribute_compat_text_section
Packit 6c4009
__old_shmctl (int shmid, int cmd, struct __old_shmid_ds *buf)
Packit 6c4009
{
Packit 6c4009
#ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
Packit 6c4009
  return INLINE_SYSCALL_CALL (shmctl, shmid, cmd, buf);
Packit 6c4009
#else
Packit 6c4009
  return INLINE_SYSCALL_CALL (ipc, IPCOP_shmctl, shmid, cmd, 0, buf);
Packit 6c4009
#endif
Packit 6c4009
}
Packit 6c4009
compat_symbol (libc, __old_shmctl, shmctl, GLIBC_2_0);
Packit 6c4009
#endif