shmctl.c 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Copyright (C) 1995-2019 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.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <sys/shm.h>
  16. #include <stdarg.h>
  17. #include <ipc_priv.h>
  18. #include <sysdep.h>
  19. #include <shlib-compat.h>
  20. #include <errno.h>
  21. #ifndef DEFAULT_VERSION
  22. # define DEFAULT_VERSION GLIBC_2_2
  23. #endif
  24. /* Provide operations to control over shared memory segments. */
  25. int
  26. __new_shmctl (int shmid, int cmd, struct shmid_ds *buf)
  27. {
  28. #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
  29. return INLINE_SYSCALL_CALL (shmctl, shmid, cmd | __IPC_64, buf);
  30. #else
  31. return INLINE_SYSCALL_CALL (ipc, IPCOP_shmctl, shmid, cmd | __IPC_64, 0,
  32. buf);
  33. #endif
  34. }
  35. versioned_symbol (libc, __new_shmctl, shmctl, DEFAULT_VERSION);
  36. #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
  37. struct __old_shmid_ds
  38. {
  39. struct __old_ipc_perm shm_perm; /* operation permission struct */
  40. int shm_segsz; /* size of segment in bytes */
  41. __time_t shm_atime; /* time of last shmat() */
  42. __time_t shm_dtime; /* time of last shmdt() */
  43. __time_t shm_ctime; /* time of last change by shmctl() */
  44. __ipc_pid_t shm_cpid; /* pid of creator */
  45. __ipc_pid_t shm_lpid; /* pid of last shmop */
  46. unsigned short int shm_nattch; /* number of current attaches */
  47. unsigned short int __shm_npages; /* size of segment (pages) */
  48. unsigned long int *__shm_pages; /* array of ptrs to frames -> SHMMAX */
  49. struct vm_area_struct *__attaches; /* descriptors for attaches */
  50. };
  51. int
  52. attribute_compat_text_section
  53. __old_shmctl (int shmid, int cmd, struct __old_shmid_ds *buf)
  54. {
  55. #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
  56. return INLINE_SYSCALL_CALL (shmctl, shmid, cmd, buf);
  57. #else
  58. return INLINE_SYSCALL_CALL (ipc, IPCOP_shmctl, shmid, cmd, 0, buf);
  59. #endif
  60. }
  61. compat_symbol (libc, __old_shmctl, shmctl, GLIBC_2_0);
  62. #endif