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