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   __time_t sem_ctime;                     /* last time changed by semctl() */
00044   struct sem *__sembase;           /* ptr to first semaphore in array */
00045   struct __sem_queue *__sem_pending;      /* pending operations */
00046   struct __sem_queue *__sem_pending_last;/* last pending operation */
00047   struct __sem_undo *__undo;              /* ondo requests on this array */
00048   unsigned short int sem_nsems;           /* number of semaphores in set */
00049 };
00050 
00051 
00052 /* The user should define a union like the following to use it for arguments
00053    for `semctl'.
00054 
00055    union semun
00056    {
00057      int val;                      <= value for SETVAL
00058      struct semid_ds *buf;         <= buffer for IPC_STAT & IPC_SET
00059      unsigned short int *array;           <= array for GETALL & SETALL
00060      struct seminfo *__buf;        <= buffer for IPC_INFO
00061    };
00062 
00063    Previous versions of this file used to define this union but this is
00064    incorrect.  One can test the macro _SEM_SEMUN_UNDEFINED to see whether
00065    one must define the union or not.  */
00066 #define _SEM_SEMUN_UNDEFINED       1
00067 
00068 #ifdef __USE_MISC
00069 
00070 /* ipcs ctl cmds */
00071 # define SEM_STAT 18
00072 # define SEM_INFO 19
00073 
00074 struct  seminfo
00075 {
00076   int semmap;
00077   int semmni;
00078   int semmns;
00079   int semmnu;
00080   int semmsl;
00081   int semopm;
00082   int semume;
00083   int semusz;
00084   int semvmx;
00085   int semaem;
00086 };
00087 
00088 #endif /* __USE_MISC */