gpsync.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /* Copyright (C) 1998 Aladdin Enterprises. All rights reserved.
  2. This file is part of AFPL Ghostscript.
  3. AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  4. distributor accepts any responsibility for the consequences of using it, or
  5. for whether it serves any particular purpose or works at all, unless he or
  6. she says so in writing. Refer to the Aladdin Free Public License (the
  7. "License") for full details.
  8. Every copy of AFPL Ghostscript must include a copy of the License, normally
  9. in a plain ASCII text file named PUBLIC. The License grants you the right
  10. to copy, modify and redistribute AFPL Ghostscript, but only under certain
  11. conditions described in the License. Among other things, the License
  12. requires that the copyright notice and this notice be preserved on all
  13. copies.
  14. */
  15. /*$Id: gpsync.h,v 1.2 2000/09/19 19:00:25 lpd Exp $ */
  16. /* Interface to platform-dependent synchronization primitives */
  17. #if !defined(gpsync_INCLUDED)
  18. # define gpsync_INCLUDED
  19. /* Initial version 4/1/98 by John Desrosiers (soho@crl.com). */
  20. /* 8/9/98 L. Peter Deutsch (ghost@aladdin.com) Changed ...sizeof to
  21. procedures, added some comments. */
  22. /* -------- Synchronization primitives ------- */
  23. /*
  24. * Semaphores support wait/signal semantics: a wait operation will allow
  25. * control to proceed iff the number of signals since semaphore creation
  26. * is greater than the number of waits.
  27. */
  28. typedef struct {
  29. void *dummy_;
  30. } gp_semaphore;
  31. uint gp_semaphore_sizeof(P0());
  32. /*
  33. * Hack: gp_semaphore_open(0) succeeds iff it's OK for the memory manager
  34. * to move a gp_semaphore in memory.
  35. */
  36. int gp_semaphore_open(P1(gp_semaphore * sema));
  37. int gp_semaphore_close(P1(gp_semaphore * sema));
  38. int gp_semaphore_wait(P1(gp_semaphore * sema));
  39. int gp_semaphore_signal(P1(gp_semaphore * sema));
  40. /*
  41. * Monitors support enter/leave semantics: at most one thread can have
  42. * entered and not yet left a given monitor.
  43. */
  44. typedef struct {
  45. void *dummy_;
  46. } gp_monitor;
  47. uint gp_monitor_sizeof(P0());
  48. /*
  49. * Hack: gp_monitor_open(0) succeeds iff it's OK for the memory manager
  50. * to move a gp_monitor in memory.
  51. */
  52. int gp_monitor_open(P1(gp_monitor * mon));
  53. int gp_monitor_close(P1(gp_monitor * mon));
  54. int gp_monitor_enter(P1(gp_monitor * mon));
  55. int gp_monitor_leave(P1(gp_monitor * mon));
  56. /*
  57. * A new thread starts by calling a procedure, passing it a void * that
  58. * allows it to gain access to whatever data it needs.
  59. */
  60. typedef void (*gp_thread_creation_callback_t) (P1(void *));
  61. int gp_create_thread(P2(gp_thread_creation_callback_t, void *));
  62. #endif /* !defined(gpsync_INCLUDED) */