freebsd-nq/sys/sys/sem.h
Peter Wemm ab063af911 Move the MSG* and SEM* options to opt_sysvipc.h
Remove evil allocation macros from machdep.c (why was that there???) and
use malloc() instead.
Move paramters out of param.h and into the code itself.
Move a bunch of internal definitions from public sys/*.h headers (without
#ifdef _KERNEL even) into the code itself.

I had hoped to make some of this more dynamic, but the cost of doing
wakeups on all sleeping processes on old arrays was too frightening.
The other possibility is to initialize on the first use, and allow
dynamic sysctl changes to parameters right until that point. That would
allow /etc/rc.sysctl to change SEM* and MSG* defaults as we presently
do with SHM*, but without the nightmare of changing a running system.
2000-05-01 13:33:56 +00:00

109 lines
2.8 KiB
C

/* $FreeBSD$ */
/* $NetBSD: sem.h,v 1.5 1994/06/29 06:45:15 cgd Exp $ */
/*
* SVID compatible sem.h file
*
* Author: Daniel Boulet
*/
#ifndef _SYS_SEM_H_
#define _SYS_SEM_H_
#include <sys/ipc.h>
struct sem;
struct semid_ds {
struct ipc_perm sem_perm; /* operation permission struct */
struct sem *sem_base; /* pointer to first semaphore in set */
u_short sem_nsems; /* number of sems in set */
time_t sem_otime; /* last operation time */
long sem_pad1; /* SVABI/386 says I need this here */
time_t sem_ctime; /* last change time */
/* Times measured in secs since */
/* 00:00:00 GMT, Jan. 1, 1970 */
long sem_pad2; /* SVABI/386 says I need this here */
long sem_pad3[4]; /* SVABI/386 says I need this here */
};
/*
* semop's sops parameter structure
*/
struct sembuf {
u_short sem_num; /* semaphore # */
short sem_op; /* semaphore operation */
short sem_flg; /* operation flags */
};
#define SEM_UNDO 010000
#define MAX_SOPS 5 /* maximum # of sembuf's per semop call */
/*
* semctl's arg parameter structure
*/
union semun {
int val; /* value for SETVAL */
struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
u_short *array; /* array for GETALL & SETALL */
};
/*
* commands for semctl
*/
#define GETNCNT 3 /* Return the value of semncnt {READ} */
#define GETPID 4 /* Return the value of sempid {READ} */
#define GETVAL 5 /* Return the value of semval {READ} */
#define GETALL 6 /* Return semvals into arg.array {READ} */
#define GETZCNT 7 /* Return the value of semzcnt {READ} */
#define SETVAL 8 /* Set the value of semval to arg.val {ALTER} */
#define SETALL 9 /* Set semvals from arg.array {ALTER} */
/*
* Permissions
*/
#define SEM_A 0200 /* alter permission */
#define SEM_R 0400 /* read permission */
#ifdef _KERNEL
/*
* semaphore info struct
*/
struct seminfo {
int semmap, /* # of entries in semaphore map */
semmni, /* # of semaphore identifiers */
semmns, /* # of semaphores in system */
semmnu, /* # of undo structures in system */
semmsl, /* max # of semaphores per id */
semopm, /* max # of operations per semop call */
semume, /* max # of undo entries per process */
semusz, /* size in bytes of undo structure */
semvmx, /* semaphore maximum value */
semaem; /* adjust on exit max value */
};
extern struct seminfo seminfo;
/* internal "mode" bits */
#define SEM_ALLOC 01000 /* semaphore is allocated */
#define SEM_DEST 02000 /* semaphore will be destroyed on last detach */
/*
* Process sem_undo vectors at proc exit.
*/
void semexit __P((struct proc *p));
#endif /* _KERNEL */
#ifndef _KERNEL
#include <sys/cdefs.h>
__BEGIN_DECLS
int semsys __P((int, ...));
int semctl __P((int, int, int, ...));
int semget __P((key_t, int, int));
int semop __P((int, struct sembuf *,unsigned));
__END_DECLS
#endif /* !_KERNEL */
#endif /* !_SEM_H_ */