Back to index

glibc  2.9
sem.h
Go to the documentation of this file.
00001 /* Copyright (C) 1995, 1996, 1997, 1998
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   __time_t sem_otime;                     /* last semop() time */
00044   __time_t sem_ctime;                     /* last time changed by semctl() */
00045   unsigned short int sem_nsems;           /* number of semaphores in set */
00046 };
00047 
00048 /* The user should define a union like the following to use it for arguments
00049    for `semctl'.
00050 
00051    union semun
00052    {
00053      int val;                      <= value for SETVAL
00054      struct semid_ds *buf;         <= buffer for IPC_STAT & IPC_SET
00055      unsigned short int *array;           <= array for GETALL & SETALL
00056      struct seminfo *__buf;        <= buffer for IPC_INFO
00057    };
00058 
00059    Previous versions of this file used to define this union but this is
00060    incorrect.  One can test the macro _SEM_SEMUN_UNDEFINED to see whether
00061    one must define the union or not.  */
00062 #define _SEM_SEMUN_UNDEFINED       1