pthread.inc 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Peter Vreman
  5. member of the Free Pascal development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This file contains a pthread.h headerconversion,
  9. and should contain an interface to the threading library to be
  10. used by systhrd, preferably in a somewhat compatible notation
  11. (compared to the other OSes).
  12. As a start, I simply used libc_r
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. **********************************************************************}
  17. CONST PTHREAD_EXPLICIT_SCHED = 0;
  18. PTHREAD_CREATE_DETACHED = 1;
  19. PTHREAD_SCOPE_PROCESS = 0;
  20. TYPE
  21. ppthread_t = ^pthread_t;
  22. ppthread_key_t = ^pthread_key_t;
  23. ppthread_mutex_t = ^pthread_mutex_t;
  24. ppthread_attr_t = ^pthread_attr_t;
  25. __destr_func_t = procedure (p :pointer);cdecl;
  26. __startroutine_t = function (p :pointer):pointer;cdecl;
  27. ppthread_mutexattr_t = ^pthread_mutexattr_t;
  28. ppthread_cond_t = ^pthread_cond_t;
  29. ppthread_condattr_t = ^pthread_condattr_t;
  30. sem_t = cint;
  31. psem_t = ^sem_t;
  32. TSemaphore = sem_t;
  33. PSemaphore = ^TSemaphore;
  34. function pthread_getspecific (t : pthread_key_t):pointer; cdecl; external 'c';
  35. function pthread_setspecific (t : pthread_key_t;p:pointer):cint; cdecl; external 'c';
  36. function pthread_key_create (p : ppthread_key_t;f: __destr_func_t):cint; cdecl;external 'c';
  37. function pthread_attr_init (p : ppthread_key_t):cint; cdecl; external 'c';
  38. function pthread_attr_setinheritsched(p : ppthread_attr_t;i:cint):cint; cdecl; external 'c';
  39. function pthread_attr_setscope (p : ppthread_attr_t;i:cint):cint;cdecl;external 'c';
  40. function pthread_attr_setdetachstate (p : ppthread_attr_t;i:cint):cint;cdecl;external 'c';
  41. function pthread_create ( p: ppthread_t;attr : ppthread_attr_t;f:__startroutine_t;arg:pointer):cint;cdecl;external 'c';
  42. procedure pthread_exit ( p: pointer); cdecl;external 'c';
  43. function pthread_self:cint; cdecl;external 'c';
  44. function pthread_mutex_init (p:ppthread_mutex_t;o:ppthread_mutexattr_t):cint; cdecl;external 'c';
  45. function pthread_mutex_destroy (p:ppthread_mutexattr_t):cint; cdecl;external 'c';
  46. function pthread_mutex_lock (p:ppthread_mutexattr_t):cint; cdecl;external 'c';
  47. function pthread_mutex_unlock (p:ppthread_mutexattr_t):cint; cdecl;external 'c';
  48. function pthread_cancel(_para1:pthread_t):cint;cdecl;external 'c';
  49. function pthread_detach(_para1:pthread_t):cint;cdecl;external 'c';
  50. function pthread_join(_para1:pthread_t; _para2:Ppointer):cint;cdecl;external 'c';
  51. function pthread_cond_destroy(_para1:Ppthread_cond_t):cint;cdecl;external 'c' name 'pthread_cond_destroy';
  52. function pthread_cond_init(_para1:Ppthread_cond_t;_para2:Ppthread_condattr_t):cint;cdecl;external 'c' name 'pthread_cond_init';
  53. function pthread_cond_signal(_para1:Ppthread_cond_t):cint;cdecl;external 'c' name 'pthread_cond_signal';
  54. function pthread_cond_wait(_para1:Ppthread_cond_t;_para2:Ppthread_mutex_t):cint;cdecl;external 'c' name 'pthread_cond_wait';
  55. function sem_init(__sem:Psem_t; __pshared:cint;__value:cuint):cint;cdecl; external 'c' name 'sem_init';
  56. function sem_destroy(__sem:Psem_t):cint;cdecl;external 'c' name 'sem_destroy';
  57. function sem_close(__sem:Psem_t):cint;cdecl;external 'c' name 'sem_close';
  58. function sem_unlink(__name:Pchar):cint;cdecl;external 'c' name 'sem_unlink';
  59. function sem_wait(__sem:Psem_t):cint;cdecl;external 'c' name 'sem_wait';
  60. function sem_trywait(__sem:Psem_t):cint;cdecl;external 'c' name 'sem_trywait';
  61. function sem_post(__sem:Psem_t):cint;cdecl;external 'c' name 'sem_post';
  62. function sem_getvalue(__sem:Psem_t; __sval:Pcint):cint;cdecl;external 'c' name 'sem_getvalue';
  63. function pthread_mutexattr_init(_para1:Ppthread_mutexattr_t):cint;cdecl;external 'c' name 'pthread_mutexattr_init';
  64. function pthread_mutexattr_destroy(_para1:Ppthread_mutexattr_t):cint;cdecl;external 'c' name 'pthread_mutexattr_destroy';
  65. function pthread_mutexattr_gettype(_para1:Ppthread_mutexattr_t; _para2:Pcint):cint;cdecl;external 'c' name 'pthread_mutexattr_gettype';
  66. function pthread_mutexattr_settype(_para1:Ppthread_mutexattr_t; _para2:cint):cint;cdecl;external 'c' name 'pthread_mutexattr_settype';
  67. {
  68. $Log$
  69. Revision 1.6 2004-12-22 21:29:24 marco
  70. * rtlevent kraam. Checked (compile): Linux, FreeBSD, Darwin, Windows
  71. Check work: ask Neli.
  72. Revision 1.5 2004/09/09 20:29:06 jonas
  73. * fixed definition of pthread_mutex_t for non-linux targets (and for
  74. linux as well, actually).
  75. * base libpthread definitions are now in ptypes.inc, included in unixtype
  76. They sometimes have an extra underscore in front of their name, in
  77. case they were also exported by the packages/base/pthreads unit, so
  78. they can keep their original name there
  79. * cthreadds unit now imports systuils, because it uses exceptions (it
  80. already did so before as well)
  81. * fixed many linux definitions of libpthread functions in pthrlinux.inc
  82. (integer -> cint etc)
  83. + added culonglong type to ctype.inc
  84. Revision 1.4 2004/05/28 18:23:55 marco
  85. * fixes for darwin specific external name '' behaviour. Must still be
  86. tested
  87. Revision 1.3 2004/05/26 20:05:21 marco
  88. * 2nd attempt
  89. Revision 1.2 2004/05/26 19:23:17 marco
  90. * first iteration
  91. Revision 1.1 2004/01/04 20:05:38 jonas
  92. * first working version of the Darwin/Mac OS X (for PowerPC) RTL
  93. Several non-essential units are still missing, but make cycle works
  94. Revision 1.2 2003/11/27 20:24:10 michael
  95. + Redefined ppthread_mutex_t
  96. Revision 1.1 2003/11/18 22:33:42 marco
  97. * moved from systhrds.pp
  98. }