pthrbsd.inc 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by Michael Van Canneyt,
  5. BSD parts (c) 2000 by Marco van de Voort
  6. members of the Free Pascal development team.
  7. New linux unit. Linux only calls only. Will be renamed to linux.pp
  8. when 1.0.x support is killed off.
  9. See the file COPYING.FPC, included in this distribution,
  10. for details about the copyright.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY;without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. **********************************************************************}
  15. {
  16. Automatically converted by H2Pas 0.99.15 from pthrwrk2.h
  17. }
  18. {$linklib pthread} // The compiler changes this to c_r if needed.
  19. {$linklib c} // (parameter -Xf)
  20. {$PACKRECORDS C}
  21. {
  22. Copyright (c) 1993, 1994 by Chris Provenzano, [email protected]
  23. Copyright (c) 1995-1998 by John Birrell <[email protected]>
  24. All rights reserved.
  25. Redistribution and use in source and binary forms, with or without
  26. modification, are permitted provided that the following conditions
  27. are met:
  28. 1. Redistributions of source code must retain the above copyright
  29. notice, this list of conditions and the following disclaimer.
  30. 2. Redistributions in binary form must reproduce the above copyright
  31. notice, this list of conditions and the following disclaimer in the
  32. documentation and/or other materials provided with the distribution.
  33. 3. All advertising materials mentioning features or use of this software
  34. must display the following acknowledgement:
  35. This product includes software developed by Chris Provenzano.
  36. 4. The name of Chris Provenzano may not be used to endorse or promote
  37. products derived from this software without specific prior written
  38. permission.
  39. THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
  40. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  41. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  42. ARE DISCLAIMED. IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY
  43. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  44. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  45. SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  46. CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  47. LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  48. OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  49. SUCH DAMAGE.
  50. $FreeBSD: src/include/pthread.h,v 1.20.2.4 2003/05/27 18:18:01 jdp Exp $
  51. }
  52. {
  53. Run-time invariant values:
  54. }
  55. CONST ULONG_MAX= high(cardinal);
  56. type
  57. {$ifdef ver1_0}
  58. cint = longint;
  59. pcint = ^cint;
  60. size_t = cardinal;
  61. {$endif}
  62. psize_t = ^size_t;
  63. psigset_t = ^sigset;
  64. const
  65. PTHREAD_DESTRUCTOR_ITERATIONS = 4;
  66. PTHREAD_KEYS_MAX = 256;
  67. PTHREAD_STACK_MIN = 1024;
  68. PTHREAD_THREADS_MAX = ULONG_MAX;
  69. {
  70. Flags for threads and thread attributes.
  71. }
  72. PTHREAD_DETACHED = $1;
  73. PTHREAD_SCOPE_SYSTEM = $2;
  74. PTHREAD_INHERIT_SCHED = $4;
  75. PTHREAD_NOFLOAT = $8;
  76. PTHREAD_CREATE_DETACHED = PTHREAD_DETACHED;
  77. PTHREAD_CREATE_JOINABLE = 0;
  78. PTHREAD_SCOPE_PROCESS = 0;
  79. PTHREAD_EXPLICIT_SCHED = 0;
  80. {
  81. Flags for read/write lock attributes
  82. }
  83. PTHREAD_PROCESS_PRIVATE = 0;
  84. PTHREAD_PROCESS_SHARED = 1;
  85. {
  86. Flags for cancelling threads
  87. }
  88. PTHREAD_CANCEL_ENABLE = 0;
  89. PTHREAD_CANCEL_DISABLE = 1;
  90. PTHREAD_CANCEL_DEFERRED = 0;
  91. PTHREAD_CANCEL_ASYNCHRONOUS = 2;
  92. PTHREAD_CANCELED = pointer(1);
  93. {
  94. Forward structure definitions.
  95. These are mostly opaque to the user.
  96. }
  97. type
  98. pthread = record
  99. end;
  100. pthread_attr = record
  101. end;
  102. pthread_cond = record
  103. end;
  104. pthread_cond_attr = record
  105. end;
  106. pthread_mutex = record
  107. end;
  108. pthread_mutex_attr = record
  109. end;
  110. {
  111. pthread_once = record
  112. end;
  113. }
  114. pthread_rwlock = record
  115. end;
  116. pthread_rwlockattr = record
  117. end;
  118. { from semaphore.h }
  119. sem = record end;
  120. sem_t = ^sem;
  121. psem_t = ^sem_t;
  122. TSemaphore = sem_t;
  123. PSemaphore = ^TSemaphore;
  124. {
  125. Primitive system data type definitions required by P1003.1c.
  126. Note that P1003.1c specifies that there are no defined comparison
  127. or assignment operators for the types pthread_attr_t, pthread_cond_t,
  128. pthread_condattr_t, pthread_mutex_t, pthread_mutexattr_t.
  129. }
  130. pthread_t = ^pthread;
  131. pthread_attr_t = ^pthread_attr;
  132. pthread_mutex_t = ^pthread_mutex;
  133. pthread_mutexattr_t = ^pthread_mutex_attr;
  134. pthread_cond_t = ^pthread_cond;
  135. pthread_condattr_t = ^pthread_cond_attr;
  136. pthread_key_t = cint;
  137. pthread_rwlock_t = ^pthread_rwlock;
  138. pthread_rwlockattr_t = ^pthread_rwlockattr;
  139. TThreadID = pthread_t;
  140. PThreadID = ^TThreadID;
  141. TThreadAttr = pthread_attr_t;
  142. PThreadAttr = ^TThreadAttr;
  143. TPthreadMutex = pthread_mutex_t;
  144. PTpthreadmutex= ^pthread_mutex;
  145. TMutexAttribute = pthread_mutexattr_t;
  146. PMutexAttribute = ^TMutexAttribute;
  147. TPthreadCondattr = pthread_condattr_t;
  148. PPthreadCondattr = ^TPthreadCondattr;
  149. {added, adjust these if hdr conv went wrong}
  150. {from sched.h}
  151. sched_param = record
  152. sched_priority : cint;
  153. end;
  154. {for pthread.h}
  155. ppthread_attr_t = ^pthread_attr_t;
  156. ppthread_cond_t = ^pthread_cond_t;
  157. ppthread_condattr_t = ^pthread_condattr_t;
  158. ppthread_mutex_t = ^pthread_mutex_t;
  159. ppthread_t = ^pthread_t;
  160. ppthread_key_t = ^pthread_key_t;
  161. ppthread_mutexattr_t = ^pthread_mutexattr_t;
  162. ppthread_rwlock_t = ^pthread_rwlock_t;
  163. ppthread_rwlockattr_t = ^pthread_rwlockattr_t;
  164. ppthread_once_t = ^pthread_once_t;
  165. psched_param = ^sched_param;
  166. TSchedParam = sched_param;
  167. PSchedParam = ^TSchedParam;
  168. {
  169. Additional type definitions:
  170. Note that P1003.1c reserves the prefixes pthread_ and PTHREAD_ for
  171. use in header symbols.
  172. }
  173. pthread_addr_t = packed record end;
  174. pthread_startroutine_t = procedure; cdecl;
  175. {
  176. Once definitions.
  177. }
  178. _pthread_once = record
  179. state : cint;
  180. mutex : pthread_mutex_t;
  181. end;
  182. pthread_once_t = _pthread_once;
  183. {
  184. Flags for once initialization.
  185. }
  186. const
  187. PTHREAD_NEEDS_INIT = 0;
  188. PTHREAD_DONE_INIT = 1;
  189. {
  190. Static once initialization values.
  191. }
  192. { ????
  193. #define PTHREAD_ONCE_INIT ( PTHREAD_NEEDS_INIT, NULL )
  194. }
  195. {
  196. Static initialization values.
  197. }
  198. PTHREAD_MUTEX_INITIALIZER = NIL;
  199. PTHREAD_COND_INITIALIZER = NIL;
  200. PTHREAD_RWLOCK_INITIALIZER = NIL;
  201. {
  202. Default attribute arguments (draft 4, deprecated).
  203. }
  204. {$ifndef PTHREAD_KERNEL}
  205. const
  206. pthread_condattr_default = NIL;
  207. pthread_mutexattr_default = NIL;
  208. pthread_attr_default = NiL;
  209. {$endif}
  210. const
  211. PTHREAD_PRIO_NONE = 0;
  212. PTHREAD_PRIO_INHERIT = 1;
  213. PTHREAD_PRIO_PROTECT = 2;
  214. {
  215. Mutex types (Single UNIX Specification, Version 2, 1997).
  216. Note that a mutex attribute with one of the following types:
  217. PTHREAD_MUTEX_NORMAL
  218. PTHREAD_MUTEX_RECURSIVE
  219. MUTEX_TYPE_FAST (deprecated)
  220. MUTEX_TYPE_COUNTING_FAST (deprecated)
  221. will deviate from POSIX specified semantics.
  222. }
  223. { Default POSIX mutex }
  224. { Recursive mutex }
  225. { No error checking }
  226. type
  227. pthread_mutextype = (
  228. PTHREAD_MUTEX_ERRORCHECK := 1,
  229. PTHREAD_MUTEX_RECURSIVE := 2,
  230. PTHREAD_MUTEX_NORMAL := 3,
  231. MUTEX_TYPE_MAX
  232. );
  233. const
  234. PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK;
  235. MUTEX_TYPE_FAST = PTHREAD_MUTEX_NORMAL;
  236. MUTEX_TYPE_COUNTING_FAST = PTHREAD_MUTEX_RECURSIVE;
  237. {
  238. Thread function prototype definitions:
  239. }
  240. function pthread_attr_destroy (p : ppthread_attr_t ):cint; cdecl; external;
  241. function pthread_attr_getstack (p : ppthread_attr_t; stackaddr : ppointer;
  242. stacksize : psize_t):cint; cdecl; external;
  243. function pthread_attr_getstacksize(_para1:Ppthread_attr_t; _para2:Psize_t):cint;cdecl; external;
  244. function pthread_attr_getstackaddr(_para1:Ppthread_attr_t; _para2:Ppointer):cint;cdecl;external;
  245. function pthread_attr_getdetachstate(_para1:Ppthread_attr_t; _para2:Pcint):cint;cdecl; external;
  246. function pthread_attr_init(_para1:Ppthread_attr_t):cint;cdecl;external;
  247. function pthread_attr_setstack(_para1:Ppthread_attr_t; _para2:pointer; _para3:size_t):cint;cdecl;external;
  248. function pthread_attr_setstacksize(_para1:Ppthread_attr_t; _para2:size_t):cint;cdecl;external;
  249. function pthread_attr_setstackaddr(_para1:Ppthread_attr_t; _para2:pointer):cint;cdecl;external;
  250. function pthread_attr_setdetachstate(_para1:Ppthread_attr_t; _para2:cint):cint;cdecl;external;
  251. procedure pthread_cleanup_pop(_para1:cint);cdecl;external;
  252. type cleanuproutine= function (a:pointer):pointer;cdecl;
  253. procedure pthread_cleanup_push(_para1:cleanuproutine; routine_arg:pointer);cdecl;external;
  254. function pthread_condattr_destroy(_para1:Ppthread_condattr_t):cint;cdecl;external;
  255. function pthread_condattr_init(_para1:Ppthread_condattr_t):cint;cdecl;external;
  256. {$ifdef POSIX_THREAD_PROCESS_SHARED}
  257. function pthread_condattr_getpshared(_para1:Ppthread_condattr_t; _para2:Pcint):cint;cdecl;external;
  258. function pthread_condattr_setpshared(_para1:Ppthread_condattr_t; _para2:cint):cint;cdecl;external;
  259. {$endif}
  260. function pthread_cond_broadcast(_para1:Ppthread_cond_t):cint;cdecl;external;
  261. function pthread_cond_destroy(_para1:Ppthread_cond_t):cint;cdecl;external;
  262. function pthread_cond_init(_para1:Ppthread_cond_t; _para2:Ppthread_condattr_t):cint;cdecl;external;
  263. function pthread_cond_signal(_para1:Ppthread_cond_t):cint;cdecl;external;
  264. function pthread_cond_timedwait(_para1:Ppthread_cond_t; _para2:Ppthread_mutex_t; _para3:Ptimespec):cint;cdecl;external;
  265. function pthread_cond_wait(_para1:Ppthread_cond_t; _para2:Ppthread_mutex_t):cint;cdecl;external;
  266. type pthreadcreateroutine = function (p:pointer):pointer;
  267. function pthread_create(_para1:Ppthread_t; _para2:Ppthread_attr_t; _para3:Pthreadcreateroutine; _para4:pointer):cint;cdecl;external;
  268. function pthread_detach(_para1:pthread_t):cint;cdecl;external;
  269. function pthread_equal(_para1:pthread_t; _para2:pthread_t):cint;cdecl;external;
  270. procedure pthread_exit ( p: pointer); cdecl;external; { __dead2}
  271. function pthread_getspecific(_para1:pthread_key_t):pointer;cdecl;external;
  272. function pthread_join(_para1:pthread_t; _para2:Ppointer):cint;cdecl;external;
  273. type pthreadkeycreateroutine = function (p:pointer):pointer;
  274. function pthread_key_create(_para1:Ppthread_key_t; _para2:pthreadkeycreateroutine):cint;cdecl;external;
  275. function pthread_key_delete(_para1:pthread_key_t):cint;cdecl;external;
  276. function pthread_kill(_para1:pthread_t; _para2:cint):cint;cdecl;external;
  277. function pthread_mutexattr_init(_para1:Ppthread_mutexattr_t):cint;cdecl;external;
  278. function pthread_mutexattr_destroy(_para1:Ppthread_mutexattr_t):cint;cdecl;external;
  279. function pthread_mutexattr_gettype(_para1:Ppthread_mutexattr_t; _para2:Pcint):cint;cdecl;external;
  280. function pthread_mutexattr_settype(_para1:Ppthread_mutexattr_t; _para2:cint):cint;cdecl;external;
  281. function pthread_mutex_destroy(_para1:Ppthread_mutex_t):cint;cdecl;external;
  282. function pthread_mutex_init(_para1:Ppthread_mutex_t; _para2:Ppthread_mutexattr_t):cint;cdecl;external;
  283. function pthread_mutex_lock(_para1:Ppthread_mutex_t):cint;cdecl;external;
  284. function pthread_mutex_trylock(_para1:Ppthread_mutex_t):cint;cdecl;external;
  285. function pthread_mutex_unlock(_para1:Ppthread_mutex_t):cint;cdecl;external;
  286. type pthreadonceroutine = procedure (p:pointer);
  287. function pthread_once(_para1:Ppthread_once_t; _para2:pthreadonceroutine ):cint;cdecl;external;
  288. function pthread_rwlock_destroy(_para1:Ppthread_rwlock_t):cint;cdecl;external;
  289. function pthread_rwlock_init(_para1:Ppthread_rwlock_t; _para2:Ppthread_rwlockattr_t):cint;cdecl;external;
  290. function pthread_rwlock_rdlock(_para1:Ppthread_rwlock_t):cint;cdecl;external;
  291. function pthread_rwlock_tryrdlock(_para1:Ppthread_rwlock_t):cint;cdecl;external;
  292. function pthread_rwlock_trywrlock(_para1:Ppthread_rwlock_t):cint;cdecl;external;
  293. function pthread_rwlock_unlock(_para1:Ppthread_rwlock_t):cint;cdecl;external;
  294. function pthread_rwlock_wrlock(_para1:Ppthread_rwlock_t):cint;cdecl;external;
  295. function pthread_rwlockattr_init(_para1:Ppthread_rwlockattr_t):cint;cdecl;external;
  296. function pthread_rwlockattr_getpshared(_para1:Ppthread_rwlockattr_t; _para2:Pcint):cint;cdecl;external;
  297. function pthread_rwlockattr_setpshared(_para1:Ppthread_rwlockattr_t; _para2:cint):cint;cdecl;external;
  298. function pthread_rwlockattr_destroy(_para1:Ppthread_rwlockattr_t):cint;cdecl;external;
  299. function pthread_self:pthread_t;cdecl;external;
  300. function pthread_setspecific(_para1:pthread_key_t; _para2:pointer):cint;cdecl;external;
  301. function pthread_sigmask(_para1:cint; _para2:Psigset_t; _para3:Psigset_t):cint;cdecl;external;
  302. function pthread_cancel(_para1:pthread_t):cint;cdecl;external;
  303. function pthread_setcancelstate(_para1:cint; _para2:Pcint):cint;cdecl;external;
  304. function pthread_setcanceltype(_para1:cint; _para2:Pcint):cint;cdecl;external;
  305. procedure pthread_testcancel;cdecl;external;
  306. function pthread_getprio(_para1:pthread_t):cint;cdecl;external;
  307. function pthread_setprio(_para1:pthread_t; _para2:cint):cint;cdecl;external;
  308. procedure pthread_yield;cdecl;external;
  309. {$ifdef POSIX_THREAD_PROCESS_SHARED}
  310. function pthread_mutexattr_getpshared(_para1:Ppthread_mutexattr_t; pshared:Pcint):cint;cdecl;external;
  311. function pthread_mutexattr_setpshared(_para1:Ppthread_mutexattr_t; pshared:cint):cint;cdecl;external;
  312. {$endif}
  313. function pthread_mutexattr_getprioceiling(_para1:Ppthread_mutexattr_t; _para2:Pcint):cint;cdecl;external;
  314. function pthread_mutexattr_setprioceiling(_para1:Ppthread_mutexattr_t; _para2:cint):cint;cdecl;external;
  315. function pthread_mutex_getprioceiling(_para1:Ppthread_mutex_t; _para2:Pcint):cint;cdecl;external;
  316. function pthread_mutex_setprioceiling(_para1:Ppthread_mutex_t; _para2:cint; _para3:Pcint):cint;cdecl;external;
  317. function pthread_mutexattr_getprotocol(_para1:Ppthread_mutexattr_t; _para2:Pcint):cint;cdecl;external;
  318. function pthread_mutexattr_setprotocol(_para1:Ppthread_mutexattr_t; _para2:cint):cint;cdecl;external;
  319. function pthread_attr_getinheritsched(_para1:Ppthread_attr_t; _para2:Pcint):cint;cdecl;external;
  320. function pthread_attr_getschedparam(_para1:Ppthread_attr_t; _para2:Psched_param):cint;cdecl;external;
  321. function pthread_attr_getschedpolicy(_para1:Ppthread_attr_t; _para2:Pcint):cint;cdecl;external;
  322. function pthread_attr_getscope(_para1:Ppthread_attr_t; _para2:Pcint):cint;cdecl;external;
  323. function pthread_attr_setinheritsched(_para1:Ppthread_attr_t; _para2:cint):cint;cdecl;external;
  324. function pthread_attr_setschedparam(_para1:Ppthread_attr_t; _para2:Psched_param):cint;cdecl;external;
  325. function pthread_attr_setschedpolicy(_para1:Ppthread_attr_t; _para2:cint):cint;cdecl;external;
  326. function pthread_attr_setscope(_para1:Ppthread_attr_t; _para2:cint):cint;cdecl;external;
  327. function pthread_getschedparam(pthread:pthread_t; _para2:Pcint; _para3:Psched_param):cint;cdecl;external;
  328. function pthread_setschedparam(_para1:pthread_t; _para2:cint; _para3:Psched_param):cint;cdecl;external;
  329. function pthread_getconcurrency:cint;cdecl;external;
  330. function pthread_setconcurrency(_para1:cint):cint;cdecl;external;
  331. function pthread_attr_setfloatstate(_para1:Ppthread_attr_t; _para2:cint):cint;cdecl;external;
  332. function pthread_attr_getfloatstate(_para1:Ppthread_attr_t; _para2:Pcint):cint;cdecl;external;
  333. { semaphore.h }
  334. function sem_init(__sem:Psem_t; __pshared:cint;__value:dword):cint;cdecl; external;
  335. function sem_destroy(__sem:Psem_t):cint;cdecl;external ;
  336. function sem_close(__sem:Psem_t):cint;cdecl;external ;
  337. function sem_unlink(__name:Pchar):cint;cdecl;external ;
  338. function sem_wait(__sem:Psem_t):cint;cdecl;external ;
  339. function sem_trywait(__sem:Psem_t):cint;cdecl;external ;
  340. function sem_post(__sem:Psem_t):cint;cdecl;external ;
  341. function sem_getvalue(__sem:Psem_t; __sval:Pcint):cint;cdecl;external;
  342. function sem_init(var __sem: sem_t; __pshared:cint; __value:dword):cint cdecl;external;
  343. function sem_destroy(var __sem: sem_t):cint;cdecl;external;
  344. function sem_close(var __sem: sem_t):cint;cdecl;external;
  345. function sem_wait(var __sem: sem_t):cint;cdecl;external;
  346. function sem_trywait(var __sem: sem_t):cint;cdecl;external;
  347. function sem_post(var __sem: sem_t):cint;cdecl;external;
  348. function sem_getvalue(var __sem: sem_t; var __sval:cint):cint;cdecl;external;
  349. {
  350. $Log$
  351. Revision 1.4 2004-02-15 19:59:20 marco
  352. * linklib pthread from now on
  353. Revision 1.3 2003/11/16 21:30:24 marco
  354. * now linklib's
  355. Revision 1.2 2003/11/04 09:02:18 marco
  356. * freebsd fixes to get syncobjs running
  357. Revision 1.1 2003/11/03 11:38:38 marco
  358. * freebsd translation
  359. }