gpsync.h 2.4 KB

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