msgctl.c 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/msg.h>
  16. #include <ipc_priv.h>
  17. #include <sysdep.h>
  18. #include <shlib-compat.h>
  19. #include <errno.h>
  20. #ifndef DEFAULT_VERSION
  21. # define DEFAULT_VERSION GLIBC_2_2
  22. #endif
  23. int
  24. __new_msgctl (int msqid, int cmd, struct msqid_ds *buf)
  25. {
  26. #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
  27. return INLINE_SYSCALL_CALL (msgctl, msqid, cmd | __IPC_64, buf);
  28. #else
  29. return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd | __IPC_64, 0,
  30. buf);
  31. #endif
  32. }
  33. versioned_symbol (libc, __new_msgctl, msgctl, DEFAULT_VERSION);
  34. #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_2)
  35. struct __old_msqid_ds
  36. {
  37. struct __old_ipc_perm msg_perm; /* structure describing operation permission */
  38. struct msg *__msg_first; /* pointer to first message on queue */
  39. struct msg *__msg_last; /* pointer to last message on queue */
  40. __time_t msg_stime; /* time of last msgsnd command */
  41. __time_t msg_rtime; /* time of last msgrcv command */
  42. __time_t msg_ctime; /* time of last change */
  43. struct wait_queue *__wwait; /* ??? */
  44. struct wait_queue *__rwait; /* ??? */
  45. unsigned short int __msg_cbytes; /* current number of bytes on queue */
  46. unsigned short int msg_qnum; /* number of messages currently on queue */
  47. unsigned short int msg_qbytes; /* max number of bytes allowed on queue */
  48. __ipc_pid_t msg_lspid; /* pid of last msgsnd() */
  49. __ipc_pid_t msg_lrpid; /* pid of last msgrcv() */
  50. };
  51. int
  52. attribute_compat_text_section
  53. __old_msgctl (int msqid, int cmd, struct __old_msqid_ds *buf)
  54. {
  55. #ifdef __ASSUME_DIRECT_SYSVIPC_SYSCALLS
  56. return INLINE_SYSCALL_CALL (msgctl, msqid, cmd | __IPC_64, buf);
  57. #else
  58. return INLINE_SYSCALL_CALL (ipc, IPCOP_msgctl, msqid, cmd, 0, buf);
  59. #endif
  60. }
  61. compat_symbol (libc, __old_msgctl, msgctl, GLIBC_2_0);
  62. #endif