epoc32/include/stdapis/sys/sem.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /* $FreeBSD: src/sys/sys/sem.h,v 1.29 2004/11/17 13:12:06 rwatson Exp $ */
     2 /*	$NetBSD: sem.h,v 1.5 1994/06/29 06:45:15 cgd Exp $	*/
     3 
     4 /*
     5  *© * © * Portions Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
     6  * SVID compatible sem.h file
     7  *
     8  * Author:  Daniel Boulet
     9  */
    10 
    11 #ifndef _SYS_SEM_H_
    12 #define _SYS_SEM_H_
    13 
    14 #include <sys/ipc.h>
    15 
    16 
    17 struct sem {
    18 	u_short	semval;		/* semaphore value */
    19 	pid_t	sempid;		/* process ID of last operation */
    20 	u_short	semncnt;	/* number of processes waiting for semval
    21                            to become greater than current value */
    22 	u_short	semzcnt;	/* number of processes waiting for semval
    23                            to become 0 */
    24     };
    25 
    26 struct semid_ds {
    27 	struct ipc_perm	sem_perm;	/* operation permission struct */
    28 	struct sem	*sem_base;	/* pointer to first semaphore in set */
    29 	unsigned short	sem_nsems;	/* number of sems in set */
    30 	time_t		sem_otime;	/* last operation time */
    31 	long		sem_pad1;	/* SVABI/386 says I need this here */
    32 	time_t		sem_ctime;	/* last change time */
    33     					/* Times measured in secs since */
    34     					/* 00:00:00 GMT, Jan. 1, 1970 */
    35 	long		sem_pad2;	/* SVABI/386 says I need this here */
    36 	long		sem_pad3[4];	/* SVABI/386 says I need this here */
    37 };
    38 
    39 /*
    40  * semop's sops parameter structure
    41  */
    42 struct sembuf {
    43 	unsigned short	sem_num;	/* semaphore # */
    44 	short		sem_op;		/* semaphore operation */
    45 	short		sem_flg;	/* operation flags */
    46 };
    47 #define SEM_UNDO	010000
    48 
    49 /*
    50  * semctl's arg parameter structure
    51  */
    52 union semun {
    53 	int		val;		/* value for SETVAL */
    54 	struct		semid_ds *buf;	/* buffer for IPC_STAT & IPC_SET */
    55 	unsigned short	*array;		/* array for GETALL & SETALL */
    56 };
    57 
    58 /*
    59  * commands for semctl
    60  */
    61 #define GETNCNT	3	/* Return the value of semncnt {READ} */
    62 #define GETPID	4	/* Return the value of sempid {READ} */
    63 #define GETVAL	5	/* Return the value of semval {READ} */
    64 #define GETALL	6	/* Return semvals into arg.array {READ} */
    65 #define GETZCNT	7	/* Return the value of semzcnt {READ} */
    66 #define SETVAL	8	/* Set the value of semval to arg.val {ALTER} */
    67 #define SETALL	9	/* Set semvals from arg.array {ALTER} */
    68 #define SEM_STAT 10	/* Like IPC_STAT but treats semid as sema-index */
    69 #define SEM_INFO 11	/* Like IPC_INFO but treats semid as sema-index */
    70 
    71 /*
    72  * Permissions
    73  */
    74 #define SEM_A		IPC_W	/* alter permission */
    75 #define SEM_R		IPC_R	/* read permission */
    76 
    77 #ifdef _KERNEL
    78 
    79 /*
    80  * semaphore info struct
    81  */
    82 struct seminfo {
    83 	int	semmap,		/* # of entries in semaphore map */
    84 		semmni,		/* # of semaphore identifiers */
    85 		semmns,		/* # of semaphores in system */
    86 		semmnu,		/* # of undo structures in system */
    87 		semmsl,		/* max # of semaphores per id */
    88 		semopm,		/* max # of operations per semop call */
    89 		semume,		/* max # of undo entries per process */
    90 		semusz,		/* size in bytes of undo structure */
    91 		semvmx,		/* semaphore maximum value */
    92 		semaem;		/* adjust on exit max value */
    93 };
    94 extern struct seminfo	seminfo;
    95 
    96 /*
    97  * Kernel wrapper for the user-level structure
    98  */
    99 struct semid_kernel {
   100 	struct	semid_ds u;
   101 	struct	label *label;	/* MAC framework label */
   102 };
   103 
   104 /* internal "mode" bits */
   105 #define	SEM_ALLOC	01000	/* semaphore is allocated */
   106 #define	SEM_DEST	02000	/* semaphore will be destroyed on last detach */
   107 
   108 /*
   109  * Process sem_undo vectors at proc exit.
   110  */
   111 void	semexit(struct proc *p);
   112 #endif /* _KERNEL */
   113 
   114 #ifndef _KERNEL
   115 #include <sys/cdefs.h>
   116 #include <sys/_types.h>
   117 
   118 #ifndef _SIZE_T_DECLARED
   119 typedef __size_t        size_t;
   120 #define _SIZE_T_DECLARED
   121 #endif
   122 
   123 #ifndef _PID_T_DECLARED
   124 typedef __pid_t         pid_t;
   125 #define _PID_T_DECLARED
   126 #endif
   127 
   128 // FUNCTION PROTOTYPES
   129 
   130 
   131 // FORWARD DECLARATIONS
   132 
   133 
   134 // CLASS/STRUCT/FUNCTION DECLARATION
   135 
   136 __BEGIN_DECLS
   137 
   138 /*
   139 * Get semaphore identifier using the IPC key generated by ftok.
   140 */
   141 
   142 IMPORT_C int semget(key_t key, int nsems, int semflg);
   143 
   144 
   145 /*
   146 * Perform atomically a user-defined array of semaphore operations on the set of 
   147 * semaphores associated with the semaphore identifier specified by the argument semid.
   148 */
   149 
   150 IMPORT_C int semop(int semid, struct sembuf *sops, unsigned nsops);
   151 
   152 
   153 /*
   154 * Provides a variety of semaphore control operations as specified by cmd.
   155 */
   156 IMPORT_C int semctl(int semid, int semnum, int cmd, ...);
   157 
   158 
   159 __END_DECLS
   160 #endif // #ifndef _KERNEL
   161 
   162 #endif // _SYS_SEM_H_
   163 
   164 //  End of File