Back to index

glibc  2.9
sem.h
Go to the documentation of this file.
00001 /* Copyright (C) 1995, 1996, 1997, 1998, 2000, 2002 
00002    Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _SYS_SEM_H
00021 # error "Never include <bits/sem.h> directly; use <sys/sem.h> instead."
00022 #endif
00023 
00024 #include <sys/types.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 #if __WORDSIZE == 32
00044   unsigned int __unused1;
00045 #endif
00046   __time_t sem_otime;                  /* last semop() time */
00047 #if __WORDSIZE == 32
00048   unsigned int __unused2;
00049 #endif
00050   __time_t sem_ctime;                  /* last time changed by semctl() */
00051   unsigned long int sem_nsems;         /* number of semaphores in set */
00052   unsigned long __unused3;
00053   unsigned long __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 */