haiku/headers/posix/sys/sem.h
Axel Dörfler 47ca7595ca First patch by Salvatore to implement XSI semaphores with a few changes
by myself:
* renamed xsi_do_undo() to xsi_sem_undo() (there is more to XSI than sems).
* Fixed coding style issues in sys/sem.h and xsi_sem.cpp.
* Added _kern_*() syscall prototypes to syscalls.h.
* Added a TODO in xsi_sem.cpp and xsi_semaphore.h about moving union semun to
  a shared header.
* Made the team::xsi_sem_undo_requests int32 - due to padding, it would have
  needed 4 bytes anyway; please always use specific types over int/short/long.
* xsi_sem_undo() now checks if it needs to do anything - the calls in team.cpp
  no longer needs to do this.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26676 a95241bf-73f2-0310-859d-f6bbb57e9c96
2008-07-29 12:03:41 +00:00

65 lines
1.8 KiB
C

/*
* Copyright 2008, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _SYS_SEM_H
#define _SYS_SEM_H
#include <sys/cdefs.h>
#include <sys/ipc.h>
#include <sys/types.h>
/* Semaphore operation flags */
#define SEM_UNDO 10
/* Command definition for semctl */
#define GETPID 3 /* Get process ID of last element manipulating */
#define GETVAL 4 /* Get semval */
#define GETALL 5 /* Get all semval */
#define GETNCNT 6 /* Get semncnt */
#define GETZCNT 7 /* Get semzcnt */
#define SETVAL 8 /* Set semval */
#define SETALL 9 /* Set all semval */
struct semid_ds {
struct ipc_perm sem_perm; /* Operation permission structure */
unsigned short sem_nsems; /* Number of semaphores in set */
time_t sem_otime; /* Last semop */
time_t sem_ctime; /* Last time changed by semctl */
};
/* Structure passed as parameter to the semop function */
struct sembuf {
unsigned short sem_num; /* Semaphore number */
short sem_op; /* Semaphore operation */
short sem_flg; /* Operation flags */
};
/*
* Semaphore info structure. Useful for the ipcs
* standard utily
*/
struct seminfo {
int semmni; /* Number of semaphore identifies */
int semmns; /* Number of semaphore in system */
int semmnu; /* Number of undo structures in system */
int semmsl; /* Max number of semaphores per id */
int semopm; /* Max number of operations per semop call */
int semume; /* Max number of undo entries per process */
int semusz; /* Size in bytes of undo structure */
int semvmx; /* Semaphore maximum valure */
int semaem; /* adjust on exit max value */
};
__BEGIN_DECLS
int semctl(int semID, int semNum, int command, ...);
int semget(key_t key, int numSems, int semFlags);
int semop(int semID, struct sembuf *semOps, size_t numSemOps);
__END_DECLS
#endif /* _SYS_SEM_H */