Back to index

glibc  2.9
sem.h
Go to the documentation of this file.
00001 /* Copyright (C) 2001, 2002 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 <bits/types.h>
00024 #include <bits/wordsize.h>
00025 
00026 /* Flags for `semop'.  */
00027 #define SEM_UNDO     0x1000        /* undo the operation on exit */
00028 
00029 /* Commands for `semctl'.  */
00030 #define GETPID              11            /* get sempid */
00031 #define GETVAL              12            /* get semval */
00032 #define GETALL              13            /* get all semval's */
00033 #define GETNCNT             14            /* get semncnt */
00034 #define GETZCNT             15            /* get semzcnt */
00035 #define SETVAL              16            /* set semval */
00036 #define SETALL              17            /* set all semval's */
00037 
00038 
00039 /* Data structure describing a set of semaphores.  */
00040 struct semid_ds
00041 {
00042   struct ipc_perm sem_perm;        /* operation permission struct */
00043   __time_t sem_otime;                     /* last semop() time */
00044 #if __WORDSIZE != 64
00045   unsigned long int __unused1;
00046 #endif
00047   __time_t sem_ctime;                     /* last time changed by semctl() */
00048 #if __WORDSIZE != 64
00049   unsigned long int __unused2;
00050 #endif
00051   unsigned long int sem_nsems;            /* number of semaphores in set */
00052   unsigned long int __unused3;
00053   unsigned long int __unused4;
00054 };
00055 
00056 /* The user should define a union like the following to use it for arguments
00057    for `semctl'.
00058 
00059    union semun
00060    {
00061      int val;                      <= value for SETVAL
00062      struct semid_ds *buf;         <= buffer for IPC_STAT & IPC_SET
00063      unsigned short int *array;           <= array for GETALL & SETALL
00064      struct seminfo *__buf;        <= buffer for IPC_INFO
00065    };
00066 
00067    Previous versions of this file used to define this union but this is
00068    incorrect.  One can test the macro _SEM_SEMUN_UNDEFINED to see whether
00069    one must define the union or not.  */
00070 #define _SEM_SEMUN_UNDEFINED       1
00071 
00072 #ifdef __USE_MISC
00073 
00074 /* ipcs ctl cmds */
00075 # define SEM_STAT 18
00076 # define SEM_INFO 19
00077 
00078 struct seminfo
00079 {
00080   int semmap;
00081   int semmni;
00082   int semmns;
00083   int semmnu;
00084   int semmsl;
00085   int semopm;
00086   int semume;
00087   int semusz;
00088   int semvmx;
00089   int semaem;
00090 };
00091 
00092 #endif /* __USE_MISC */