1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 #ifndef _LX_SYSV_IPC_H
  28 #define _LX_SYSV_IPC_H
  29 
  30 #pragma ident   "%Z%%M% %I%     %E% SMI"
  31 
  32 #ifdef __cplusplus
  33 extern "C" {
  34 #endif
  35 
  36 /*
  37  * msg-related definitions.
  38  */
  39 #define LX_IPC_CREAT    00001000
  40 #define LX_IPC_EXCL     00002000
  41 #define LX_IPC_NOWAIT   00004000
  42 
  43 #define LX_IPC_RMID     0
  44 #define LX_IPC_SET      1
  45 #define LX_IPC_STAT     2
  46 #define LX_IPC_INFO     3
  47 
  48 #define LX_IPC_64       0x0100
  49 
  50 #define LX_SEMOP        1
  51 #define LX_SEMGET       2
  52 #define LX_SEMCTL       3
  53 #define LX_MSGSND       11
  54 #define LX_MSGRCV       12
  55 #define LX_MSGGET       13
  56 #define LX_MSGCTL       14
  57 #define LX_SHMAT        21
  58 #define LX_SHMDT        22
  59 #define LX_SHMGET       23
  60 #define LX_SHMCTL       24
  61 
  62 #define LX_MSG_STAT     11
  63 #define LX_MSG_INFO     12
  64 
  65 #define LX_MSG_NOERROR  010000
  66 
  67 /*
  68  * Linux hard codes the maximum msgbuf length to be 8192 bytes.  Really.
  69  */
  70 #define LX_MSGMAX       8192
  71 
  72 struct lx_ipc_perm {
  73         key_t           key;
  74         uid_t           uid;
  75         uid_t           gid;
  76         uid_t           cuid;
  77         uid_t           cgid;
  78         ushort_t        mode;
  79         ushort_t        _pad1;
  80         ushort_t        seq;
  81         ushort_t        _pad2;
  82         ulong_t         _unused1;
  83         ulong_t         _unused2;
  84 };
  85 
  86 struct lx_msqid_ds {
  87         struct lx_ipc_perm      msg_perm;
  88         time_t                  msg_stime;
  89         ulong_t                 _unused1;
  90         time_t                  msg_rtime;
  91         ulong_t                 _unused2;
  92         time_t                  msg_ctime;
  93         ulong_t                 _unused3;
  94         ulong_t                 msg_cbytes;
  95         ulong_t                 msg_qnum;
  96         ulong_t                 msg_qbytes;
  97         pid_t                   msg_lspid;
  98         pid_t                   msg_lrpid;
  99         ulong_t                 _unused4;
 100         ulong_t                 _unused5;
 101 };
 102 
 103 struct lx_msginfo {
 104         int             msgpool;
 105         int             msgmap;
 106         int             msgmax;
 107         int             msgmnb;
 108         int             msgmni;
 109         int             msgssz;
 110         int             msgtql;
 111         ushort_t        msgseg;
 112 };
 113 
 114 /*
 115  * semaphore-related definitions.
 116  */
 117 #define LX_GETPID       11
 118 #define LX_GETVAL       12
 119 #define LX_GETALL       13
 120 #define LX_GETNCNT      14
 121 #define LX_GETZCNT      15
 122 #define LX_SETVAL       16
 123 #define LX_SETALL       17
 124 #define LX_SEM_STAT     18
 125 #define LX_SEM_INFO     19
 126 #define LX_SEM_UNDO     0x1000
 127 #define LX_SEMVMX       32767
 128 
 129 struct lx_semid_ds {
 130         struct lx_ipc_perm      sem_perm;
 131         time_t                  sem_otime;
 132         ulong_t                 _unused1;
 133         time_t                  sem_ctime;
 134         ulong_t                 _unused2;
 135         ulong_t                 sem_nsems;
 136         ulong_t                 _unused3;
 137         ulong_t                 _unused4;
 138 };
 139 
 140 struct lx_seminfo {
 141         int semmap;
 142         int semmni;
 143         int semmns;
 144         int semmnu;
 145         int semmsl;
 146         int semopm;
 147         int semume;
 148         int semusz;
 149         int semvmx;
 150         int semaem;
 151 };
 152 
 153 union lx_semun {
 154         int val;
 155         struct lx_semid_ds *semds;
 156         ushort_t *sems;
 157         struct lx_seminfo *info;
 158         uintptr_t dummy;
 159 };
 160 
 161 /*
 162  * shm-related definitions
 163  */
 164 #define LX_SHM_LOCKED   02000
 165 #define LX_SHM_RDONLY   010000
 166 #define LX_SHM_RND      020000
 167 #define LX_SHM_REMAP    040000
 168 
 169 #define LX_SHM_LOCK     11
 170 #define LX_SHM_UNLOCK   12
 171 #define LX_SHM_STAT     13
 172 #define LX_SHM_INFO     14
 173 
 174 struct lx_shmid_ds {
 175         struct lx_ipc_perm      shm_perm;
 176         size_t                  shm_segsz;
 177         time_t                  shm_atime;
 178         ulong_t                 _unused1;
 179         time_t                  shm_dtime;
 180         ulong_t                 _unused2;
 181         time_t                  shm_ctime;
 182         ulong_t                 _unused3;
 183         pid_t                   shm_cpid;
 184         pid_t                   shm_lpid;
 185         ushort_t                shm_nattch;
 186         ulong_t                 _unused4;
 187         ulong_t                 _unused5;
 188 };
 189 
 190 struct lx_shm_info {
 191         int     used_ids;
 192         ulong_t shm_tot;
 193         ulong_t shm_rss;
 194         ulong_t shm_swp;
 195         ulong_t swap_attempts;
 196         ulong_t swap_successes;
 197 };
 198 
 199 struct lx_shminfo {
 200         int     shmmax;
 201         int     shmmin;
 202         int     shmmni;
 203         int     shmseg;
 204         int     shmall;
 205 };
 206 
 207 #ifdef  __cplusplus
 208 }
 209 #endif
 210 
 211 #endif  /* _LX_SYSV_IPC_H */