2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
11 /* ------------------------------------------------------------------------ */
15 * sem.h: Attempt to provide multi-process semaphores across platforms
27 /* All of the implementations currently use int as the semaphore type */
29 typedef HANDLE SEMAPHORE
;
31 /* That oughta hold them (I hope) */
32 #define SEM_MAXVALUE 32767
34 #else /* ! SEM_WIN32 */
35 typedef int SEMAPHORE
;
37 #endif /* SEM_WIN32 */
40 * sem_init creates a semaphore using the given name and unique
41 * identification number. filename should be a file accessible to the
42 * process. Returns SEM_ERROR on error.
45 SEMAPHORE
sem_init(char *name
, int number
);
48 * sem_terminate de-allocates the given semaphore.
51 void sem_terminate(SEMAPHORE id
);
54 * sem_grab attempts to gain exclusive access to the given semaphore. If
55 * it can't get it, the caller will block. Returns -1 on error.
58 int sem_grab(SEMAPHORE id
);
61 * sem_release releases this process's exclusive control over the given
62 * semaphore. Returns -1 on error.
65 int sem_release(SEMAPHORE id
);