sem.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // Copyright 2026 Aarav Ravindra Kharade
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. /* Copyright (C) 1995-2026 Free Software Foundation, Inc.
  17. This file is part of the GNU C Library.
  18. The GNU C Library is free software; you can redistribute it and/or
  19. modify it under the terms of the GNU Lesser General Public
  20. License as published by the Free Software Foundation; either
  21. version 2.1 of the License, or (at your option) any later version.
  22. The GNU C Library is distributed in the hope that it will be useful,
  23. but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  25. Lesser General Public License for more details.
  26. You should have received a copy of the GNU Lesser General Public
  27. License along with the GNU C Library; if not, see
  28. <https://www.gnu.org/licenses/>. */
  29. #ifndef _SYS_SEM_H
  30. #define _SYS_SEM_H 1
  31. #include <features.h>
  32. #define __need_size_t
  33. #include <stddef.h>
  34. /* Get common definition of System V style IPC. */
  35. #include <sys/ipc.h>
  36. /* Get system dependent definition of `struct semid_ds' and more. */
  37. #include <bits/sem.h>
  38. #ifdef __USE_GNU
  39. # include <bits/types/struct_timespec.h>
  40. #endif
  41. /* The following System V style IPC functions implement a semaphore
  42. handling. The definition is found in XPG2. */
  43. /* Structure used for argument to `semop' to describe operations. */
  44. struct sembuf
  45. {
  46. unsigned short int sem_num; /* semaphore number */
  47. short int sem_op; /* semaphore operation */
  48. short int sem_flg; /* operation flag */
  49. };
  50. __BEGIN_DECLS
  51. /* Semaphore control operation. */
  52. #ifndef __USE_TIME64_REDIRECTS
  53. extern int semctl (int __semid, int __semnum, int __cmd, ...) __THROW;
  54. #else
  55. # ifdef __REDIRECT_NTH
  56. extern int __REDIRECT_NTH (semctl,
  57. (int __semid, int __semnum, int __cmd, ...),
  58. __semctl64);
  59. # else
  60. # define semctl __semctl64
  61. # endif
  62. #endif
  63. /* Get semaphore. */
  64. extern int semget (key_t __key, int __nsems, int __semflg) __THROW;
  65. /* Operate on semaphore. */
  66. extern int semop (int __semid, struct sembuf *__sops, size_t __nsops) __THROW;
  67. #ifdef __USE_GNU
  68. /* Operate on semaphore with timeout. */
  69. # ifndef __USE_TIME64_REDIRECTS
  70. extern int semtimedop (int __semid, struct sembuf *__sops, size_t __nsops,
  71. const struct timespec *__timeout) __THROW;
  72. # else
  73. # ifdef __REDIRECT_NTH
  74. extern int __REDIRECT_NTH (semtimedop, (int __semid, struct sembuf *__sops,
  75. size_t __nsops,
  76. const struct timespec *__timeout),
  77. __semtimedop64);
  78. # else
  79. # define semtimedop __semtimedop64
  80. # endif
  81. # endif
  82. #endif
  83. __END_DECLS
  84. #endif /* sys/sem.h */