xref: /plan9/sys/src/cmd/gs/src/gpsync.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1998 Aladdin Enterprises.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 /* $Id: gpsync.h,v 1.5 2002/06/16 06:59:02 lpd Exp $ */
18 /* Interface to platform-dependent synchronization primitives */
19 
20 #if !defined(gpsync_INCLUDED)
21 #  define gpsync_INCLUDED
22 
23 /* Initial version 4/1/98 by John Desrosiers (soho@crl.com). */
24 /* 8/9/98 L. Peter Deutsch (ghost@aladdin.com) Changed ...sizeof to
25    procedures, added some comments. */
26 
27 /* -------- Synchronization primitives ------- */
28 
29 /*
30  * Semaphores support wait/signal semantics: a wait operation will allow
31  * control to proceed iff the number of signals since semaphore creation
32  * is greater than the number of waits.
33  */
34 typedef struct {
35     void *dummy_;
36 } gp_semaphore;
37 
38 uint gp_semaphore_sizeof(void);
39 /*
40  * Hack: gp_semaphore_open(0) succeeds iff it's OK for the memory manager
41  * to move a gp_semaphore in memory.
42  */
43 int gp_semaphore_open(gp_semaphore * sema);
44 int gp_semaphore_close(gp_semaphore * sema);
45 int gp_semaphore_wait(gp_semaphore * sema);
46 int gp_semaphore_signal(gp_semaphore * sema);
47 
48 /*
49  * Monitors support enter/leave semantics: at most one thread can have
50  * entered and not yet left a given monitor.
51  */
52 typedef struct {
53     void *dummy_;
54 } gp_monitor;
55 
56 uint gp_monitor_sizeof(void);
57 /*
58  * Hack: gp_monitor_open(0) succeeds iff it's OK for the memory manager
59  * to move a gp_monitor in memory.
60  */
61 int gp_monitor_open(gp_monitor * mon);
62 int gp_monitor_close(gp_monitor * mon);
63 int gp_monitor_enter(gp_monitor * mon);
64 int gp_monitor_leave(gp_monitor * mon);
65 
66 /*
67  * A new thread starts by calling a procedure, passing it a void * that
68  * allows it to gain access to whatever data it needs.
69  */
70 typedef void (*gp_thread_creation_callback_t) (void *);
71 int gp_create_thread(gp_thread_creation_callback_t, void *);
72 
73 #endif /* !defined(gpsync_INCLUDED) */
74