VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/x11include/4.2/include/extensions/sync.h@ 1

Last change on this file since 1 was 1, checked in by vboxsync, 55 years ago

import

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette