pthread.inc 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. pthread_t = pointer;
  22. ppthread_t = ^pthread_t;
  23. pthread_key_t = cint;
  24. ppthread_key_t = ^pthread_key_t;
  25. pthread_mutex_t = TRTLCriticalSection;
  26. ppthread_mutex_t= PRTLCriticalSection;
  27. pthread_attr_t = pointer; // opague
  28. ppthread_attr_t = ^pthread_attr_t; // opague
  29. __destr_func_t = procedure (p :pointer);cdecl;
  30. __startroutine_t= function (p :pointer):pointer;cdecl;
  31. pthread_mutex_attr_t = pointer;
  32. ppthread_mutex_attr_t = ^pthread_mutex_t;
  33. function pthread_getspecific (t : pthread_key_t):pointer; cdecl; external 'c';
  34. function pthread_setspecific (t : pthread_key_t;p:pointer):cint; cdecl; external 'c';
  35. function pthread_key_create (p : ppthread_key_t;f: __destr_func_t):cint; cdecl;external 'c';
  36. function pthread_attr_init (p : ppthread_key_t):cint; cdecl; external 'c';
  37. function pthread_attr_setinheritsched(p : ppthread_attr_t;i:cint):cint; cdecl; external 'c';
  38. function pthread_attr_setscope (p : ppthread_attr_t;i:cint):cint;cdecl;external 'c';
  39. function pthread_attr_setdetachstate (p : ppthread_attr_t;i:cint):cint;cdecl;external 'c';
  40. function pthread_create ( p: ppthread_t;attr : ppthread_attr_t;f:__startroutine_t;arg:pointer):cint;cdecl;external 'c';
  41. procedure pthread_exit ( p: pointer); cdecl;external 'c';
  42. function pthread_self:cint; cdecl;external 'c';
  43. function pthread_mutex_init (p:ppthread_mutex_t;o:ppthread_mutex_attr_t):cint; cdecl;external 'c';
  44. function pthread_mutex_destroy (p:ppthread_mutex_attr_t):cint; cdecl;external 'c';
  45. function pthread_mutex_lock (p:ppthread_mutex_attr_t):cint; cdecl;external 'c';
  46. function pthread_mutex_unlock (p:ppthread_mutex_attr_t):cint; cdecl;external 'c';
  47. function pthread_cancel(_para1:pthread_t):cint;cdecl;external 'c';
  48. function pthread_detach(_para1:pthread_t):cint;cdecl;external 'c';
  49. function pthread_join(_para1:pthread_t; _para2:Ppointer):cint;cdecl;external 'c';
  50. {
  51. $Log$
  52. Revision 1.1 2004-01-04 20:05:38 jonas
  53. * first working version of the Darwin/Mac OS X (for PowerPC) RTL
  54. Several non-essential units are still missing, but make cycle works
  55. Revision 1.2 2003/11/27 20:24:10 michael
  56. + Redefined ppthread_mutex_t
  57. Revision 1.1 2003/11/18 22:33:42 marco
  58. * moved from systhrds.pp
  59. }