Back to index

glibc  2.9
sem.h
Go to the documentation of this file.
00001 /* Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef _SYS_SEM_H
00020 # error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
00021 #endif
00022 
00023 #include <sys/types.h>
00024 
00025 /* Flags for `semop'.  */
00026 #define SEM_UNDO     0x1000        /* undo the operation on exit */
00027 
00028 /* Commands for `semctl'.  */
00029 #define GETPID              11            /* get sempid */
00030 #define GETVAL              12            /* get semval */
00031 #define GETALL              13            /* get all semval's */
00032 #define GETNCNT             14            /* get semncnt */
00033 #define GETZCNT             15            /* get semzcnt */
00034 #define SETVAL              16            /* set semval */
00035 #define SETALL              17            /* set all semval's */
00036 
00037 
00038 /* Data structure describing a set of semaphores.  */
00039 struct semid_ds
00040 {
00041   struct ipc_perm sem_perm;        /* operation permission struct */
00042   __time_t sem_otime;                     /* last semop() time */
00043   unsigned long int __unused1;
00044   __time_t sem_ctime;                     /* last time changed by semctl() */
00045   unsigned long int __unused2;
00046   unsigned long int sem_nsems;            /* number of semaphores in set */
00047   unsigned long int __unused3;
00048   unsigned long int __unused4;
00049 };
00050 
00051 /* The user should define a union like the following to use it for arguments
00052    for `semctl'.
00053 
00054    union semun
00055    {
00056      int val;                      <= value for SETVAL
00057      struct semid_ds *buf;         <= buffer for IPC_STAT & IPC_SET
00058      unsigned short int *array;           <= array for GETALL & SETALL
00059      struct seminfo *__buf;        <= buffer for IPC_INFO
00060    };
00061 
00062    Previous versions of this file used to define this union but this is
00063    incorrect.  One can test the macro _SEM_SEMUN_UNDEFINED to see whether
00064    one must define the union or not.  */
00065 #define _SEM_SEMUN_UNDEFINED       1
00066 
00067 #ifdef __USE_MISC
00068 
00069 /* ipcs ctl cmds */
00070 # define SEM_STAT 18
00071 # define SEM_INFO 19
00072 
00073 struct  seminfo
00074 {
00075   int semmap;
00076   int semmni;
00077   int semmns;
00078   int semmnu;
00079   int semmsl;
00080   int semopm;
00081   int semume;
00082   int semusz;
00083   int semvmx;
00084   int semaem;
00085 };
00086 
00087 #endif /* __USE_MISC */