sync.pp 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. (*
  2. Copyright 1991, 1993, 1994, 1998 The Open Group
  3. Permission to use, copy, modify, distribute, and sell this software and its
  4. documentation for any purpose is hereby granted without fee, provided that
  5. the above copyright notice appear in all copies and that both that
  6. copyright notice and this permission notice appear in supporting
  7. documentation.
  8. The above copyright notice and this permission notice shall be included in
  9. all copies or substantial portions of the Software.
  10. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  11. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  12. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  13. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  14. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  15. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  16. Except as contained in this notice, the name of The Open Group shall not be
  17. used in advertising or otherwise to promote the sale, use or other dealings
  18. in this Software without prior written authorization from The Open Group.
  19. *)
  20. (***********************************************************
  21. Copyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
  22. and Olivetti Research Limited, Cambridge, England.
  23. All Rights Reserved
  24. Permission to use, copy, modify, and distribute this software and its
  25. documentation for any purpose and without fee is hereby granted,
  26. provided that the above copyright notice appear in all copies and that
  27. both that copyright notice and this permission notice appear in
  28. supporting documentation, and that the names of Digital or Olivetti
  29. not be used in advertising or publicity pertaining to distribution of the
  30. software without specific, written prior permission.
  31. DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  32. SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  33. FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  34. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  35. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  36. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  37. PERFORMANCE OF THIS SOFTWARE.
  38. ******************************************************************)
  39. {$IFNDEF FPC_DOTTEDUNITS}
  40. unit sync;
  41. {$ENDIF FPC_DOTTEDUNITS}
  42. {$PACKRECORDS c}
  43. interface
  44. {$IFDEF FPC_DOTTEDUNITS}
  45. uses
  46. System.CTypes, Api.X11.X, Api.X11.Xlib;
  47. {$ELSE FPC_DOTTEDUNITS}
  48. uses
  49. ctypes, x, xlib;
  50. {$ENDIF FPC_DOTTEDUNITS}
  51. const
  52. libXext = 'Xext';
  53. {$I syncconst.inc}
  54. type
  55. PXSyncSystemCounter = ^TXSyncSystemCounter;
  56. TXSyncSystemCounter = record
  57. name: PAnsiChar; { null-terminated name of system counter }
  58. counter: TXSyncCounter; { counter id of this system counter }
  59. resolution: TXSyncValue; { resolution of this system counter }
  60. end;
  61. PXSyncTrigger = ^TXSyncTrigger;
  62. TXSyncTrigger = record
  63. counter: TXSyncCounter; { counter to trigger on }
  64. value_type: TXSyncValueType; { absolute/relative }
  65. wait_value: TXSyncValue; { value to compare counter to }
  66. test_type: TXSyncTestType; { pos/neg comparison/transtion }
  67. end;
  68. PXSyncWaitCondition = ^TXSyncWaitCondition;
  69. TXSyncWaitCondition = record
  70. trigger: TXSyncTrigger; { trigger for await }
  71. event_threshold: TXSyncValue; { send event if past threshold }
  72. end;
  73. PXSyncAlarmAttributes = ^TXSyncAlarmAttributes;
  74. TXSyncAlarmAttributes = record
  75. trigger: TXSyncTrigger;
  76. delta: TXSyncValue;
  77. events: TBool;
  78. state: TXSyncAlarmState;
  79. end;
  80. (*
  81. * Events
  82. *)
  83. PXSyncCounterNotifyEvent = ^TXSyncCounterNotifyEvent;
  84. TXSyncCounterNotifyEvent = record
  85. _type: cint; { event base + XSyncCounterNotify }
  86. serial: culong; { # of last request processed by server }
  87. send_event: TBool; { true if this came from a SendEvent request }
  88. display: PDisplay; { Display the event was read from }
  89. counter: TXSyncCounter; { counter involved in await }
  90. wait_value: TXSyncValue; { value being waited for }
  91. counter_value: TXSyncValue; { counter value when this event was sent }
  92. time: TTime; { milliseconds }
  93. count: cint; { how many more events to come }
  94. destroyed: TBool; { True if counter was destroyed }
  95. end;
  96. PXSyncAlarmNotifyEvent = ^TXSyncAlarmNotifyEvent;
  97. TXSyncAlarmNotifyEvent = record
  98. _type: cint; { event base + XSyncAlarmNotify }
  99. serial: culong; { # of last request processed by server }
  100. send_event: TBool; { true if this came from a SendEvent request }
  101. display: PDisplay; { Display the event was read from }
  102. alarm: TXSyncAlarm; { alarm that triggered }
  103. counter_value: TXSyncValue; { value that triggered the alarm }
  104. alarm_value: TXSyncValue; { test value of trigger in alarm }
  105. time: TTime; { milliseconds }
  106. state: TXSyncAlarmState; { new state of alarm }
  107. end;
  108. (*
  109. * Errors
  110. *)
  111. PXSyncAlarmError = ^TXSyncAlarmError;
  112. TXSyncAlarmError = record
  113. _type: cint;
  114. display: PDisplay; { Display the event was read from }
  115. alarm: TXSyncAlarm; { resource id }
  116. serial: culong; { serial number of failed request }
  117. error_code: cuchar; { error base + XSyncBadAlarm }
  118. request_code: cuchar; { Major op-code of failed request }
  119. minor_code: cuchar; { Minor op-code of failed request }
  120. end;
  121. PXSyncCounterError = ^TXSyncCounterError;
  122. TXSyncCounterError = record
  123. _type: cint;
  124. display: PDisplay; { Display the event was read from }
  125. counter: TXSyncCounter; { resource id }
  126. serial: culong; { serial number of failed request }
  127. error_code: cuchar; { error base + XSyncBadCounter }
  128. request_code: cuchar; { Major op-code of failed request }
  129. minor_code: cuchar; { Minor op-code of failed request }
  130. end;
  131. procedure XSyncIntToValue(
  132. pv: PXSyncValue;
  133. i: cint
  134. ); cdecl; external libXext;
  135. procedure XSyncIntsToValue(
  136. pv: PXSyncValue;
  137. l: cuint;
  138. h: cint
  139. ); cdecl; external libXext;
  140. function XSyncValueGreaterThan(
  141. a: TXSyncValue;
  142. b: TXSyncValue
  143. ): TBoolResult; cdecl; external libXext;
  144. function XSyncValueLessThan(
  145. a: TXSyncValue;
  146. b: TXSyncValue
  147. ): TBoolResult; cdecl; external libXext;
  148. function XSyncValueGreaterOrEqual(
  149. a: TXSyncValue;
  150. b: TXSyncValue
  151. ): TBoolResult; cdecl; external libXext;
  152. function XSyncValueLessOrEqual(
  153. a: TXSyncValue;
  154. b: TXSyncValue
  155. ): TBoolResult; cdecl; external libXext;
  156. function XSyncValueEqual(
  157. a: TXSyncValue;
  158. b: TXSyncValue
  159. ): TBoolResult; cdecl; external libXext;
  160. function XSyncValueIsNegative(
  161. v: TXSyncValue
  162. ): TBoolResult; cdecl; external libXext;
  163. function XSyncValueIsZero(
  164. a: TXSyncValue
  165. ): TBoolResult; cdecl; external libXext;
  166. function XSyncValueIsPositive(
  167. v: TXSyncValue
  168. ): TBoolResult; cdecl; external libXext;
  169. function XSyncValueLow32(
  170. v: TXSyncValue
  171. ): cuint; cdecl; external libXext;
  172. function XSyncValueHigh32(
  173. v: TXSyncValue
  174. ): cint; cdecl; external libXext;
  175. procedure XSyncValueAdd(
  176. presult: PXSyncValue;
  177. a: TXSyncValue;
  178. b: TXSyncValue;
  179. poverflow: Pcint
  180. ); cdecl; external libXext;
  181. procedure XSyncValueSubtract(
  182. presult: PXSyncValue;
  183. a: TXSyncValue;
  184. b: TXSyncValue;
  185. poverflow: Pcint
  186. ); cdecl; external libXext;
  187. procedure XSyncMaxValue(
  188. pv: PXSyncValue
  189. ); cdecl; external libXext;
  190. procedure XSyncMinValue(
  191. pv: PXSyncValue
  192. ); cdecl; external libXext;
  193. function XSyncQueryExtension(
  194. dpy: PDisplay;
  195. event_base_return,
  196. error_base_return: Pcint
  197. ): TStatus; cdecl; external libXext;
  198. function XSyncInitialize(
  199. dpy: PDisplay;
  200. major_version_return,
  201. minor_version_return: Pcint
  202. ): TStatus; cdecl; external libXext;
  203. function XSyncListSystemCounters(
  204. dpy: PDisplay;
  205. n_counters_return: Pcint
  206. ): PXSyncSystemCounter; cdecl; external libXext;
  207. procedure XSyncFreeSystemCounterList(
  208. list: PXSyncSystemCounter
  209. ); cdecl; external libXext;
  210. function XSyncCreateCounter(
  211. dpy: PDisplay;
  212. initial_value: TXSyncValue
  213. ): TXSyncCounter; cdecl; external libXext;
  214. function XSyncSetCounter(
  215. dpy: PDisplay;
  216. counter: TXSyncCounter;
  217. value: TXSyncValue
  218. ): TStatus; cdecl; external libXext;
  219. function XSyncChangeCounter(
  220. dpy: PDisplay;
  221. counter: TXSyncCounter;
  222. value: TXSyncValue
  223. ): TStatus; cdecl; external libXext;
  224. function XSyncDestroyCounter(
  225. dpy: PDisplay;
  226. counter: TXSyncCounter
  227. ): TStatus; cdecl; external libXext;
  228. function XSyncQueryCounter(
  229. dpy: PDisplay;
  230. counter: TXSyncCounter;
  231. value_return: PXSyncValue
  232. ): TStatus; cdecl; external libXext;
  233. function XSyncAwait(
  234. dpy: PDisplay;
  235. wait_list: PXSyncWaitCondition;
  236. n_conditions: cint
  237. ): TStatus; cdecl; external libXext;
  238. function XSyncCreateAlarm(
  239. dpy: PDisplay;
  240. values_mask: culong;
  241. values: PXSyncAlarmAttributes
  242. ): TXSyncAlarm; cdecl; external libXext;
  243. function XSyncDestroyAlarm(
  244. dpy: PDisplay;
  245. alarm: TXSyncAlarm
  246. ): TStatus; cdecl; external libXext;
  247. function XSyncQueryAlarm(
  248. dpy: PDisplay;
  249. alarm: TXSyncAlarm;
  250. values_return: PXSyncAlarmAttributes
  251. ): TStatus; cdecl; external libXext;
  252. function XSyncChangeAlarm(
  253. dpy: PDisplay;
  254. alarm: TXSyncAlarm;
  255. values_mask: culong;
  256. values: PXSyncAlarmAttributes
  257. ): TStatus; cdecl; external libXext;
  258. function XSyncSetPriority(
  259. dpy: PDisplay;
  260. client_resource_id: TXID;
  261. priority: cint
  262. ): TStatus; cdecl; external libXext;
  263. function XSyncGetPriority(
  264. dpy: PDisplay;
  265. client_resource_id: TXID;
  266. return_priority: Pcint
  267. ): TStatus; cdecl; external libXext;
  268. function XSyncCreateFence(
  269. dpy: PDisplay;
  270. d: TDrawable;
  271. initially_triggered: TBool
  272. ): TXSyncFence; cdecl; external libXext;
  273. function XSyncTriggerFence(
  274. dpy: PDisplay;
  275. fence: TXSyncFence
  276. ): TBoolResult; cdecl; external libXext;
  277. function XSyncResetFence(
  278. dpy: PDisplay;
  279. fence: TXSyncFence
  280. ): TBoolResult; cdecl; external libXext;
  281. function XSyncDestroyFence(
  282. dpy: PDisplay;
  283. fence: TXSyncFence
  284. ): TBoolResult; cdecl; external libXext;
  285. function XSyncQueryFence(
  286. dpy: PDisplay;
  287. fence: TXSyncFence;
  288. triggered: PBool
  289. ): TBoolResult; cdecl; external libXext;
  290. function XSyncAwaitFence(
  291. dpy: PDisplay;
  292. fence_list: PXSyncFence;
  293. n_fences: cint
  294. ): TBoolResult; cdecl; external libXext;
  295. implementation
  296. end.