1 /* Copyright (C) 1998 artofcode LLC.  All rights reserved.
2 
3   This program is free software; you can redistribute it and/or modify it
4   under the terms of the GNU General Public License as published by the
5   Free Software Foundation; either version 2 of the License, or (at your
6   option) any later version.
7 
8   This program is distributed in the hope that it will be useful, but
9   WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11   General Public License for more details.
12 
13   You should have received a copy of the GNU General Public License along
14   with this program; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA, 02111-1307.
16 
17 */
18 
19 /*$Id: gpsync.h,v 1.2.6.1.2.1 2003/01/17 00:49:02 giles Exp $ */
20 /* Interface to platform-dependent synchronization primitives */
21 
22 #if !defined(gpsync_INCLUDED)
23 #  define gpsync_INCLUDED
24 
25 /* Initial version 4/1/98 by John Desrosiers (soho@crl.com). */
26 /* 8/9/98 L. Peter Deutsch (ghost@aladdin.com) Changed ...sizeof to
27    procedures, added some comments. */
28 
29 /* -------- Synchronization primitives ------- */
30 
31 /*
32  * Semaphores support wait/signal semantics: a wait operation will allow
33  * control to proceed iff the number of signals since semaphore creation
34  * is greater than the number of waits.
35  */
36 typedef struct {
37     void *dummy_;
38 } gp_semaphore;
39 
40 uint gp_semaphore_sizeof(P0());
41 /*
42  * Hack: gp_semaphore_open(0) succeeds iff it's OK for the memory manager
43  * to move a gp_semaphore in memory.
44  */
45 int gp_semaphore_open(P1(gp_semaphore * sema));
46 int gp_semaphore_close(P1(gp_semaphore * sema));
47 int gp_semaphore_wait(P1(gp_semaphore * sema));
48 int gp_semaphore_signal(P1(gp_semaphore * sema));
49 
50 /*
51  * Monitors support enter/leave semantics: at most one thread can have
52  * entered and not yet left a given monitor.
53  */
54 typedef struct {
55     void *dummy_;
56 } gp_monitor;
57 
58 uint gp_monitor_sizeof(P0());
59 /*
60  * Hack: gp_monitor_open(0) succeeds iff it's OK for the memory manager
61  * to move a gp_monitor in memory.
62  */
63 int gp_monitor_open(P1(gp_monitor * mon));
64 int gp_monitor_close(P1(gp_monitor * mon));
65 int gp_monitor_enter(P1(gp_monitor * mon));
66 int gp_monitor_leave(P1(gp_monitor * mon));
67 
68 /*
69  * A new thread starts by calling a procedure, passing it a void * that
70  * allows it to gain access to whatever data it needs.
71  */
72 typedef void (*gp_thread_creation_callback_t) (P1(void *));
73 int gp_create_thread(P2(gp_thread_creation_callback_t, void *));
74 
75 #endif /* !defined(gpsync_INCLUDED) */
76