PageRenderTime 27ms CodeModel.GetById 17ms RepoModel.GetById 1ms app.codeStats 0ms

/user/microwin/nxlib/nxlib-0.45/X11/include/X11/extensions/sync.h

https://bitbucket.org/thelearninglabs/uclinux-distro-tll-public
C Header | 469 lines | 312 code | 73 blank | 84 comment | 18 complexity | c7037e171ada3601bf62049e176ede00 MD5 | raw file
Possible License(s): LGPL-2.1, BSD-3-Clause, MPL-2.0-no-copyleft-exception, LGPL-3.0, Unlicense, GPL-2.0, GPL-3.0, CC-BY-SA-3.0, AGPL-1.0, ISC, MIT, 0BSD, LGPL-2.0
  1. /* $Xorg: sync.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $ */
  2. /*
  3. Copyright 1991, 1993, 1994, 1998 The Open Group
  4. Permission to use, copy, modify, distribute, and sell this software and its
  5. documentation for any purpose is hereby granted without fee, provided that
  6. the above copyright notice appear in all copies and that both that
  7. copyright notice and this permission notice appear in supporting
  8. documentation.
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  15. AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  16. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  17. Except as contained in this notice, the name of The Open Group shall not be
  18. used in advertising or otherwise to promote the sale, use or other dealings
  19. in this Software without prior written authorization from The Open Group.
  20. */
  21. /***********************************************************
  22. Copyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
  23. and Olivetti Research Limited, Cambridge, England.
  24. All Rights Reserved
  25. Permission to use, copy, modify, and distribute this software and its
  26. documentation for any purpose and without fee is hereby granted,
  27. provided that the above copyright notice appear in all copies and that
  28. both that copyright notice and this permission notice appear in
  29. supporting documentation, and that the names of Digital or Olivetti
  30. not be used in advertising or publicity pertaining to distribution of the
  31. software without specific, written prior permission.
  32. DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
  33. SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
  34. FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  35. CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  36. USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  37. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  38. PERFORMANCE OF THIS SOFTWARE.
  39. ******************************************************************/
  40. /* $XFree86: xc/include/extensions/sync.h,v 1.4 2001/12/20 19:40:59 tsi Exp $ */
  41. #ifndef _SYNC_H_
  42. #define _SYNC_H_
  43. #include <X11/Xfuncproto.h>
  44. _XFUNCPROTOBEGIN
  45. #define SYNC_NAME "SYNC"
  46. #define SYNC_MAJOR_VERSION 3
  47. #define SYNC_MINOR_VERSION 0
  48. #define X_SyncInitialize 0
  49. #define X_SyncListSystemCounters 1
  50. #define X_SyncCreateCounter 2
  51. #define X_SyncSetCounter 3
  52. #define X_SyncChangeCounter 4
  53. #define X_SyncQueryCounter 5
  54. #define X_SyncDestroyCounter 6
  55. #define X_SyncAwait 7
  56. #define X_SyncCreateAlarm 8
  57. #define X_SyncChangeAlarm 9
  58. #define X_SyncQueryAlarm 10
  59. #define X_SyncDestroyAlarm 11
  60. #define X_SyncSetPriority 12
  61. #define X_SyncGetPriority 13
  62. #define XSyncCounterNotify 0
  63. #define XSyncAlarmNotify 1
  64. #define XSyncAlarmNotifyMask (1L << XSyncAlarmNotify)
  65. #define XSyncNumberEvents 2L
  66. #define XSyncBadCounter 0L
  67. #define XSyncBadAlarm 1L
  68. #define XSyncNumberErrors (XSyncBadAlarm + 1)
  69. /*
  70. * Flags for Alarm Attributes
  71. */
  72. #define XSyncCACounter (1L<<0)
  73. #define XSyncCAValueType (1L<<1)
  74. #define XSyncCAValue (1L<<2)
  75. #define XSyncCATestType (1L<<3)
  76. #define XSyncCADelta (1L<<4)
  77. #define XSyncCAEvents (1L<<5)
  78. /*
  79. * Constants for the value_type argument of various requests
  80. */
  81. typedef enum {
  82. XSyncAbsolute,
  83. XSyncRelative
  84. } XSyncValueType;
  85. /*
  86. * Alarm Test types
  87. */
  88. typedef enum {
  89. XSyncPositiveTransition,
  90. XSyncNegativeTransition,
  91. XSyncPositiveComparison,
  92. XSyncNegativeComparison
  93. } XSyncTestType;
  94. /*
  95. * Alarm state constants
  96. */
  97. typedef enum {
  98. XSyncAlarmActive,
  99. XSyncAlarmInactive,
  100. XSyncAlarmDestroyed
  101. } XSyncAlarmState;
  102. typedef XID XSyncCounter;
  103. typedef XID XSyncAlarm;
  104. typedef struct _XSyncValue {
  105. int hi;
  106. unsigned int lo;
  107. } XSyncValue;
  108. /*
  109. * Macros/functions for manipulating 64 bit values
  110. */
  111. /* have to put these prototypes before the corresponding macro definitions */
  112. extern void XSyncIntToValue(
  113. XSyncValue* /*pv*/,
  114. int /*i*/
  115. );
  116. extern void XSyncIntsToValue(
  117. XSyncValue* /*pv*/,
  118. unsigned int /*l*/,
  119. int /*h*/
  120. );
  121. extern Bool XSyncValueGreaterThan(
  122. XSyncValue /*a*/,
  123. XSyncValue /*b*/
  124. );
  125. extern Bool XSyncValueLessThan(
  126. XSyncValue /*a*/,
  127. XSyncValue /*b*/
  128. );
  129. extern Bool XSyncValueGreaterOrEqual(
  130. XSyncValue /*a*/,
  131. XSyncValue /*b*/
  132. );
  133. extern Bool XSyncValueLessOrEqual(
  134. XSyncValue /*a*/,
  135. XSyncValue /*b*/
  136. );
  137. extern Bool XSyncValueEqual(
  138. XSyncValue /*a*/,
  139. XSyncValue /*b*/
  140. );
  141. extern Bool XSyncValueIsNegative(
  142. XSyncValue /*v*/
  143. );
  144. extern Bool XSyncValueIsZero(
  145. XSyncValue /*a*/
  146. );
  147. extern Bool XSyncValueIsPositive(
  148. XSyncValue /*v*/
  149. );
  150. extern unsigned int XSyncValueLow32(
  151. XSyncValue /*v*/
  152. );
  153. extern int XSyncValueHigh32(
  154. XSyncValue /*v*/
  155. );
  156. extern void XSyncValueAdd(
  157. XSyncValue* /*presult*/,
  158. XSyncValue /*a*/,
  159. XSyncValue /*b*/,
  160. int* /*poverflow*/
  161. );
  162. extern void XSyncValueSubtract(
  163. XSyncValue* /*presult*/,
  164. XSyncValue /*a*/,
  165. XSyncValue /*b*/,
  166. int* /*poverflow*/
  167. );
  168. extern void XSyncMaxValue(
  169. XSyncValue* /*pv*/
  170. );
  171. extern void XSyncMinValue(
  172. XSyncValue* /*pv*/
  173. );
  174. _XFUNCPROTOEND
  175. /* The _XSync macros below are for library internal use only. They exist
  176. * so that if we have to make a fix, we can change it in this one place
  177. * and have both the macro and function variants inherit the fix.
  178. */
  179. #define _XSyncIntToValue(pv, i) ((pv)->hi=((i<0)?~0:0),(pv)->lo=(i))
  180. #define _XSyncIntsToValue(pv, l, h) ((pv)->lo = (l), (pv)->hi = (h))
  181. #define _XSyncValueGreaterThan(a, b)\
  182. ((a).hi>(b).hi || ((a).hi==(b).hi && (a).lo>(b).lo))
  183. #define _XSyncValueLessThan(a, b)\
  184. ((a).hi<(b).hi || ((a).hi==(b).hi && (a).lo<(b).lo))
  185. #define _XSyncValueGreaterOrEqual(a, b)\
  186. ((a).hi>(b).hi || ((a).hi==(b).hi && (a).lo>=(b).lo))
  187. #define _XSyncValueLessOrEqual(a, b)\
  188. ((a).hi<(b).hi || ((a).hi==(b).hi && (a).lo<=(b).lo))
  189. #define _XSyncValueEqual(a, b) ((a).lo==(b).lo && (a).hi==(b).hi)
  190. #define _XSyncValueIsNegative(v) (((v).hi & 0x80000000) ? 1 : 0)
  191. #define _XSyncValueIsZero(a) ((a).lo==0 && (a).hi==0)
  192. #define _XSyncValueIsPositive(v) (((v).hi & 0x80000000) ? 0 : 1)
  193. #define _XSyncValueLow32(v) ((v).lo)
  194. #define _XSyncValueHigh32(v) ((v).hi)
  195. #define _XSyncValueAdd(presult,a,b,poverflow) {\
  196. int t = (a).lo;\
  197. Bool signa = XSyncValueIsNegative(a);\
  198. Bool signb = XSyncValueIsNegative(b);\
  199. ((presult)->lo = (a).lo + (b).lo);\
  200. ((presult)->hi = (a).hi + (b).hi);\
  201. if (t>(presult)->lo) (presult)->hi++;\
  202. *poverflow = ((signa == signb) && !(signa == XSyncValueIsNegative(*presult)));\
  203. }
  204. #define _XSyncValueSubtract(presult,a,b,poverflow) {\
  205. int t = (a).lo;\
  206. Bool signa = XSyncValueIsNegative(a);\
  207. Bool signb = XSyncValueIsNegative(b);\
  208. ((presult)->lo = (a).lo - (b).lo);\
  209. ((presult)->hi = (a).hi - (b).hi);\
  210. if (t>(presult)->lo) (presult)->hi--;\
  211. *poverflow = ((signa == signb) && !(signa == XSyncValueIsNegative(*presult)));\
  212. }
  213. #define _XSyncMaxValue(pv) ((pv)->hi = 0x7fffffff, (pv)->lo = 0xffffffff)
  214. #define _XSyncMinValue(pv) ((pv)->hi = 0x80000000, (pv)->lo = 0)
  215. /*
  216. * These are the publically usable macros. If you want the function version
  217. * of one of these, just #undef the macro to uncover the function.
  218. * (This is the same convention that the ANSI C library uses.)
  219. */
  220. #define XSyncIntToValue(pv, i) _XSyncIntToValue(pv, i)
  221. #define XSyncIntsToValue(pv, l, h) _XSyncIntsToValue(pv, l, h)
  222. #define XSyncValueGreaterThan(a, b) _XSyncValueGreaterThan(a, b)
  223. #define XSyncValueLessThan(a, b) _XSyncValueLessThan(a, b)
  224. #define XSyncValueGreaterOrEqual(a, b) _XSyncValueGreaterOrEqual(a, b)
  225. #define XSyncValueLessOrEqual(a, b) _XSyncValueLessOrEqual(a, b)
  226. #define XSyncValueEqual(a, b) _XSyncValueEqual(a, b)
  227. #define XSyncValueIsNegative(v) _XSyncValueIsNegative(v)
  228. #define XSyncValueIsZero(a) _XSyncValueIsZero(a)
  229. #define XSyncValueIsPositive(v) _XSyncValueIsPositive(v)
  230. #define XSyncValueLow32(v) _XSyncValueLow32(v)
  231. #define XSyncValueHigh32(v) _XSyncValueHigh32(v)
  232. #define XSyncValueAdd(presult,a,b,poverflow) _XSyncValueAdd(presult,a,b,poverflow)
  233. #define XSyncValueSubtract(presult,a,b,poverflow) _XSyncValueSubtract(presult,a,b,poverflow)
  234. #define XSyncMaxValue(pv) _XSyncMaxValue(pv)
  235. #define XSyncMinValue(pv) _XSyncMinValue(pv)
  236. #ifndef _SYNC_SERVER
  237. typedef struct _XSyncSystemCounter {
  238. char *name; /* null-terminated name of system counter */
  239. XSyncCounter counter; /* counter id of this system counter */
  240. XSyncValue resolution; /* resolution of this system counter */
  241. } XSyncSystemCounter;
  242. typedef struct {
  243. XSyncCounter counter; /* counter to trigger on */
  244. XSyncValueType value_type; /* absolute/relative */
  245. XSyncValue wait_value; /* value to compare counter to */
  246. XSyncTestType test_type; /* pos/neg comparison/transtion */
  247. } XSyncTrigger;
  248. typedef struct {
  249. XSyncTrigger trigger; /* trigger for await */
  250. XSyncValue event_threshold; /* send event if past threshold */
  251. } XSyncWaitCondition;
  252. typedef struct {
  253. XSyncTrigger trigger;
  254. XSyncValue delta;
  255. Bool events;
  256. XSyncAlarmState state;
  257. } XSyncAlarmAttributes;
  258. /*
  259. * Events
  260. */
  261. typedef struct {
  262. int type; /* event base + XSyncCounterNotify */
  263. unsigned long serial; /* # of last request processed by server */
  264. Bool send_event; /* true if this came from a SendEvent request */
  265. Display *display; /* Display the event was read from */
  266. XSyncCounter counter; /* counter involved in await */
  267. XSyncValue wait_value; /* value being waited for */
  268. XSyncValue counter_value; /* counter value when this event was sent */
  269. Time time; /* milliseconds */
  270. int count; /* how many more events to come */
  271. Bool destroyed; /* True if counter was destroyed */
  272. } XSyncCounterNotifyEvent;
  273. typedef struct {
  274. int type; /* event base + XSyncCounterNotify */
  275. unsigned long serial; /* # of last request processed by server */
  276. Bool send_event; /* true if this came from a SendEvent request */
  277. Display *display; /* Display the event was read from */
  278. XSyncAlarm alarm; /* alarm that triggered */
  279. XSyncValue counter_value; /* value that triggered the alarm */
  280. XSyncValue alarm_value; /* test value of trigger in alarm */
  281. Time time; /* milliseconds */
  282. XSyncAlarmState state; /* new state of alarm */
  283. } XSyncAlarmNotifyEvent;
  284. /*
  285. * Errors
  286. */
  287. typedef struct {
  288. int type;
  289. Display *display; /* Display the event was read from */
  290. XSyncAlarm alarm; /* resource id */
  291. unsigned long serial; /* serial number of failed request */
  292. unsigned char error_code; /* error base + XSyncBadAlarm */
  293. unsigned char request_code; /* Major op-code of failed request */
  294. unsigned char minor_code; /* Minor op-code of failed request */
  295. } XSyncAlarmError;
  296. typedef struct {
  297. int type;
  298. Display *display; /* Display the event was read from */
  299. XSyncCounter counter; /* resource id */
  300. unsigned long serial; /* serial number of failed request */
  301. unsigned char error_code; /* error base + XSyncBadCounter */
  302. unsigned char request_code; /* Major op-code of failed request */
  303. unsigned char minor_code; /* Minor op-code of failed request */
  304. } XSyncCounterError;
  305. /*
  306. * Prototypes
  307. */
  308. _XFUNCPROTOBEGIN
  309. extern Status XSyncQueryExtension(
  310. Display* /*dpy*/,
  311. int* /*event_base_return*/,
  312. int* /*error_base_return*/
  313. );
  314. extern Status XSyncInitialize(
  315. Display* /*dpy*/,
  316. int* /*major_version_return*/,
  317. int* /*minor_version_return*/
  318. );
  319. extern XSyncSystemCounter *XSyncListSystemCounters(
  320. Display* /*dpy*/,
  321. int* /*n_counters_return*/
  322. );
  323. extern void XSyncFreeSystemCounterList(
  324. XSyncSystemCounter* /*list*/
  325. );
  326. extern XSyncCounter XSyncCreateCounter(
  327. Display* /*dpy*/,
  328. XSyncValue /*initial_value*/
  329. );
  330. extern Status XSyncSetCounter(
  331. Display* /*dpy*/,
  332. XSyncCounter /*counter*/,
  333. XSyncValue /*value*/
  334. );
  335. extern Status XSyncChangeCounter(
  336. Display* /*dpy*/,
  337. XSyncCounter /*counter*/,
  338. XSyncValue /*value*/
  339. );
  340. extern Status XSyncDestroyCounter(
  341. Display* /*dpy*/,
  342. XSyncCounter /*counter*/
  343. );
  344. extern Status XSyncQueryCounter(
  345. Display* /*dpy*/,
  346. XSyncCounter /*counter*/,
  347. XSyncValue* /*value_return*/
  348. );
  349. extern Status XSyncAwait(
  350. Display* /*dpy*/,
  351. XSyncWaitCondition* /*wait_list*/,
  352. int /*n_conditions*/
  353. );
  354. extern XSyncAlarm XSyncCreateAlarm(
  355. Display* /*dpy*/,
  356. unsigned long /*values_mask*/,
  357. XSyncAlarmAttributes* /*values*/
  358. );
  359. extern Status XSyncDestroyAlarm(
  360. Display* /*dpy*/,
  361. XSyncAlarm /*alarm*/
  362. );
  363. extern Status XSyncQueryAlarm(
  364. Display* /*dpy*/,
  365. XSyncAlarm /*alarm*/,
  366. XSyncAlarmAttributes* /*values_return*/
  367. );
  368. extern Status XSyncChangeAlarm(
  369. Display* /*dpy*/,
  370. XSyncAlarm /*alarm*/,
  371. unsigned long /*values_mask*/,
  372. XSyncAlarmAttributes* /*values*/
  373. );
  374. extern Status XSyncSetPriority(
  375. Display* /*dpy*/,
  376. XID /*client_resource_id*/,
  377. int /*priority*/
  378. );
  379. extern Status XSyncGetPriority(
  380. Display* /*dpy*/,
  381. XID /*client_resource_id*/,
  382. int* /*return_priority*/
  383. );
  384. #endif /* _SYNC_SERVER */
  385. _XFUNCPROTOEND
  386. #endif /* _SYNC_H_ */