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

Cache object: 8a380f25f4fa00053c0d6969253aa8e2


[ 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.