The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/sem.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $FreeBSD$ */
    2 /*      $NetBSD: sem.h,v 1.5 1994/06/29 06:45:15 cgd Exp $      */
    3 
    4 /*
    5  * SVID compatible sem.h file
    6  *
    7  * Author:  Daniel Boulet
    8  */
    9 
   10 #ifndef _SYS_SEM_H_
   11 #define _SYS_SEM_H_
   12 
   13 #ifdef _WANT_SYSVSEM_INTERNALS
   14 #define _WANT_SYSVIPC_INTERNALS
   15 #endif
   16 #include <sys/ipc.h>
   17 
   18 #ifndef _PID_T_DECLARED
   19 typedef __pid_t         pid_t;
   20 #define _PID_T_DECLARED
   21 #endif
   22 
   23 #ifndef _SIZE_T_DECLARED
   24 typedef __size_t        size_t;
   25 #define _SIZE_T_DECLARED
   26 #endif
   27 
   28 #ifndef _TIME_T_DECLARED
   29 typedef __time_t        time_t;
   30 #define _TIME_T_DECLARED
   31 #endif
   32 
   33 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
   34     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
   35 struct semid_ds_old {
   36         struct ipc_perm_old sem_perm;   /* operation permission struct */
   37         struct sem      *sem_base;      /* pointer to first semaphore in set */
   38         unsigned short  sem_nsems;      /* number of sems in set */
   39         time_t          sem_otime;      /* last operation time */
   40         long            sem_pad1;       /* SVABI/386 says I need this here */
   41         time_t          sem_ctime;      /* last change time */
   42                                         /* Times measured in secs since */
   43                                         /* 00:00:00 UTC, Jan. 1, 1970, without leap seconds */
   44         long            sem_pad2;       /* SVABI/386 says I need this here */
   45         long            sem_pad3[4];    /* SVABI/386 says I need this here */
   46 };
   47 #endif
   48 
   49 struct semid_ds {
   50         struct ipc_perm sem_perm;       /* operation permission struct */
   51         struct sem      *sem_base;      /* pointer to first semaphore in set */
   52         unsigned short  sem_nsems;      /* number of sems in set */
   53         time_t          sem_otime;      /* last operation time */
   54         time_t          sem_ctime;      /* last change time */
   55                                         /* Times measured in secs since */
   56                                         /* 00:00:00 UTC, Jan. 1, 1970, without leap seconds */
   57 };
   58 
   59 /*
   60  * semop's sops parameter structure
   61  */
   62 struct sembuf {
   63         unsigned short  sem_num;        /* semaphore # */
   64         short           sem_op;         /* semaphore operation */
   65         short           sem_flg;        /* operation flags */
   66 };
   67 #define SEM_UNDO        010000
   68 
   69 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
   70     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) || \
   71     defined(_WANT_SEMUN_OLD)
   72 union semun_old {
   73         int             val;            /* value for SETVAL */
   74         struct          semid_ds_old *buf; /* buffer for IPC_STAT & IPC_SET */
   75         unsigned short  *array;         /* array for GETALL & SETALL */
   76 };
   77 #endif
   78 
   79 /*
   80  * semctl's arg parameter structure
   81  */
   82 union semun {
   83         int             val;            /* value for SETVAL */
   84         struct          semid_ds *buf;  /* buffer for IPC_STAT & IPC_SET */
   85         unsigned short  *array;         /* array for GETALL & SETALL */
   86 };
   87 
   88 /*
   89  * commands for semctl
   90  */
   91 #define GETNCNT 3       /* Return the value of semncnt {READ} */
   92 #define GETPID  4       /* Return the value of sempid {READ} */
   93 #define GETVAL  5       /* Return the value of semval {READ} */
   94 #define GETALL  6       /* Return semvals into arg.array {READ} */
   95 #define GETZCNT 7       /* Return the value of semzcnt {READ} */
   96 #define SETVAL  8       /* Set the value of semval to arg.val {ALTER} */
   97 #define SETALL  9       /* Set semvals from arg.array {ALTER} */
   98 #define SEM_STAT 10     /* Like IPC_STAT but treats semid as sema-index */
   99 #define SEM_INFO 11     /* Like IPC_INFO but treats semid as sema-index */
  100 
  101 /*
  102  * Permissions
  103  */
  104 #define SEM_A           IPC_W   /* alter permission */
  105 #define SEM_R           IPC_R   /* read permission */
  106 
  107 #if defined(_KERNEL) || defined(_WANT_SYSVSEM_INTERNALS)
  108 /*
  109  * semaphore info struct
  110  */
  111 struct seminfo {
  112         int     semmni,         /* # of semaphore identifiers */
  113                 semmns,         /* # of semaphores in system */
  114                 semmnu,         /* # of undo structures in system */
  115                 semmsl,         /* max # of semaphores per id */
  116                 semopm,         /* max # of operations per semop call */
  117                 semume,         /* max # of undo entries per process */
  118                 semusz,         /* size in bytes of undo structure */
  119                 semvmx,         /* semaphore maximum value */
  120                 semaem;         /* adjust on exit max value */
  121 };
  122 
  123 /*
  124  * Kernel wrapper for the user-level structure
  125  */
  126 struct semid_kernel {
  127         struct  semid_ds u;
  128         struct  label *label;   /* MAC framework label */
  129         struct  ucred *cred;    /* creator's credentials */
  130 };
  131 
  132 /* internal "mode" bits */
  133 #define SEM_ALLOC       01000   /* semaphore is allocated */
  134 #define SEM_DEST        02000   /* semaphore will be destroyed on last detach */
  135 #endif
  136 
  137 #ifdef _KERNEL
  138 extern struct seminfo   seminfo;
  139 /*
  140  * Process sem_undo vectors at proc exit.
  141  */
  142 void    semexit(struct proc *p);
  143 
  144 #else /* !_KERNEL */
  145 
  146 __BEGIN_DECLS
  147 #if __BSD_VISIBLE
  148 int semsys(int, ...);
  149 #endif
  150 int semctl(int, int, int, ...);
  151 int semget(key_t, int, int);
  152 int semop(int, struct sembuf *, size_t);
  153 __END_DECLS
  154 
  155 #endif /* !_KERNEL */
  156 
  157 #endif /* !_SYS_SEM_H_ */

Cache object: c227592e1f369dabcd052bda9ae8976f


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.