VirtualBox

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

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

import

File size: 13.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 XSyncValue* /*pv*/,
143 int /*i*/
144);
145
146extern void XSyncIntsToValue(
147 XSyncValue* /*pv*/,
148 unsigned int /*l*/,
149 int /*h*/
150);
151
152extern Bool XSyncValueGreaterThan(
153 XSyncValue /*a*/,
154 XSyncValue /*b*/
155);
156
157extern Bool XSyncValueLessThan(
158 XSyncValue /*a*/,
159 XSyncValue /*b*/
160);
161
162extern Bool XSyncValueGreaterOrEqual(
163 XSyncValue /*a*/,
164 XSyncValue /*b*/
165);
166
167extern Bool XSyncValueLessOrEqual(
168 XSyncValue /*a*/,
169 XSyncValue /*b*/
170);
171
172extern Bool XSyncValueEqual(
173 XSyncValue /*a*/,
174 XSyncValue /*b*/
175);
176
177extern Bool XSyncValueIsNegative(
178 XSyncValue /*v*/
179);
180
181extern Bool XSyncValueIsZero(
182 XSyncValue /*a*/
183);
184
185extern Bool XSyncValueIsPositive(
186 XSyncValue /*v*/
187);
188
189extern unsigned int XSyncValueLow32(
190 XSyncValue /*v*/
191);
192
193extern int XSyncValueHigh32(
194 XSyncValue /*v*/
195);
196
197extern void XSyncValueAdd(
198 XSyncValue* /*presult*/,
199 XSyncValue /*a*/,
200 XSyncValue /*b*/,
201 int* /*poverflow*/
202);
203
204extern void XSyncValueSubtract(
205 XSyncValue* /*presult*/,
206 XSyncValue /*a*/,
207 XSyncValue /*b*/,
208 int* /*poverflow*/
209);
210
211extern void XSyncMaxValue(
212 XSyncValue* /*pv*/
213);
214
215extern void XSyncMinValue(
216 XSyncValue* /*pv*/
217);
218
219_XFUNCPROTOEND
220
221/* The _XSync macros below are for library internal use only. They exist
222 * so that if we have to make a fix, we can change it in this one place
223 * and have both the macro and function variants inherit the fix.
224 */
225
226#define _XSyncIntToValue(pv, i) ((pv)->hi=((i<0)?~0:0),(pv)->lo=(i))
227#define _XSyncIntsToValue(pv, l, h) ((pv)->lo = (l), (pv)->hi = (h))
228#define _XSyncValueGreaterThan(a, b)\
229 ((a).hi>(b).hi || ((a).hi==(b).hi && (a).lo>(b).lo))
230#define _XSyncValueLessThan(a, b)\
231 ((a).hi<(b).hi || ((a).hi==(b).hi && (a).lo<(b).lo))
232#define _XSyncValueGreaterOrEqual(a, b)\
233 ((a).hi>(b).hi || ((a).hi==(b).hi && (a).lo>=(b).lo))
234#define _XSyncValueLessOrEqual(a, b)\
235 ((a).hi<(b).hi || ((a).hi==(b).hi && (a).lo<=(b).lo))
236#define _XSyncValueEqual(a, b) ((a).lo==(b).lo && (a).hi==(b).hi)
237#define _XSyncValueIsNegative(v) (((v).hi & 0x80000000) ? 1 : 0)
238#define _XSyncValueIsZero(a) ((a).lo==0 && (a).hi==0)
239#define _XSyncValueIsPositive(v) (((v).hi & 0x80000000) ? 0 : 1)
240#define _XSyncValueLow32(v) ((v).lo)
241#define _XSyncValueHigh32(v) ((v).hi)
242#define _XSyncValueAdd(presult,a,b,poverflow) {\
243 int t = (a).lo;\
244 Bool signa = XSyncValueIsNegative(a);\
245 Bool signb = XSyncValueIsNegative(b);\
246 ((presult)->lo = (a).lo + (b).lo);\
247 ((presult)->hi = (a).hi + (b).hi);\
248 if (t>(presult)->lo) (presult)->hi++;\
249 *poverflow = ((signa == signb) && !(signa == XSyncValueIsNegative(*presult)));\
250 }
251#define _XSyncValueSubtract(presult,a,b,poverflow) {\
252 int t = (a).lo;\
253 Bool signa = XSyncValueIsNegative(a);\
254 Bool signb = XSyncValueIsNegative(b);\
255 ((presult)->lo = (a).lo - (b).lo);\
256 ((presult)->hi = (a).hi - (b).hi);\
257 if (t>(presult)->lo) (presult)->hi--;\
258 *poverflow = ((signa == signb) && !(signa == XSyncValueIsNegative(*presult)));\
259 }
260#define _XSyncMaxValue(pv) ((pv)->hi = 0x7fffffff, (pv)->lo = 0xffffffff)
261#define _XSyncMinValue(pv) ((pv)->hi = 0x80000000, (pv)->lo = 0)
262
263/*
264 * These are the publically usable macros. If you want the function version
265 * of one of these, just #undef the macro to uncover the function.
266 * (This is the same convention that the ANSI C library uses.)
267 */
268
269#define XSyncIntToValue(pv, i) _XSyncIntToValue(pv, i)
270#define XSyncIntsToValue(pv, l, h) _XSyncIntsToValue(pv, l, h)
271#define XSyncValueGreaterThan(a, b) _XSyncValueGreaterThan(a, b)
272#define XSyncValueLessThan(a, b) _XSyncValueLessThan(a, b)
273#define XSyncValueGreaterOrEqual(a, b) _XSyncValueGreaterOrEqual(a, b)
274#define XSyncValueLessOrEqual(a, b) _XSyncValueLessOrEqual(a, b)
275#define XSyncValueEqual(a, b) _XSyncValueEqual(a, b)
276#define XSyncValueIsNegative(v) _XSyncValueIsNegative(v)
277#define XSyncValueIsZero(a) _XSyncValueIsZero(a)
278#define XSyncValueIsPositive(v) _XSyncValueIsPositive(v)
279#define XSyncValueLow32(v) _XSyncValueLow32(v)
280#define XSyncValueHigh32(v) _XSyncValueHigh32(v)
281#define XSyncValueAdd(presult,a,b,poverflow) _XSyncValueAdd(presult,a,b,poverflow)
282#define XSyncValueSubtract(presult,a,b,poverflow) _XSyncValueSubtract(presult,a,b,poverflow)
283#define XSyncMaxValue(pv) _XSyncMaxValue(pv)
284#define XSyncMinValue(pv) _XSyncMinValue(pv)
285
286#ifndef _SYNC_SERVER
287
288typedef struct _XSyncSystemCounter {
289 char *name; /* null-terminated name of system counter */
290 XSyncCounter counter; /* counter id of this system counter */
291 XSyncValue resolution; /* resolution of this system counter */
292} XSyncSystemCounter;
293
294
295typedef struct {
296 XSyncCounter counter; /* counter to trigger on */
297 XSyncValueType value_type; /* absolute/relative */
298 XSyncValue wait_value; /* value to compare counter to */
299 XSyncTestType test_type; /* pos/neg comparison/transtion */
300} XSyncTrigger;
301
302typedef struct {
303 XSyncTrigger trigger; /* trigger for await */
304 XSyncValue event_threshold; /* send event if past threshold */
305} XSyncWaitCondition;
306
307
308typedef struct {
309 XSyncTrigger trigger;
310 XSyncValue delta;
311 Bool events;
312 XSyncAlarmState state;
313} XSyncAlarmAttributes;
314
315/*
316 * Events
317 */
318
319typedef struct {
320 int type; /* event base + XSyncCounterNotify */
321 unsigned long serial; /* # of last request processed by server */
322 Bool send_event; /* true if this came from a SendEvent request */
323 Display *display; /* Display the event was read from */
324 XSyncCounter counter; /* counter involved in await */
325 XSyncValue wait_value; /* value being waited for */
326 XSyncValue counter_value; /* counter value when this event was sent */
327 Time time; /* milliseconds */
328 int count; /* how many more events to come */
329 Bool destroyed; /* True if counter was destroyed */
330} XSyncCounterNotifyEvent;
331
332typedef struct {
333 int type; /* event base + XSyncCounterNotify */
334 unsigned long serial; /* # of last request processed by server */
335 Bool send_event; /* true if this came from a SendEvent request */
336 Display *display; /* Display the event was read from */
337 XSyncAlarm alarm; /* alarm that triggered */
338 XSyncValue counter_value; /* value that triggered the alarm */
339 XSyncValue alarm_value; /* test value of trigger in alarm */
340 Time time; /* milliseconds */
341 XSyncAlarmState state; /* new state of alarm */
342} XSyncAlarmNotifyEvent;
343
344/*
345 * Errors
346 */
347
348typedef struct {
349 int type;
350 Display *display; /* Display the event was read from */
351 XSyncAlarm alarm; /* resource id */
352 unsigned long serial; /* serial number of failed request */
353 unsigned char error_code; /* error base + XSyncBadAlarm */
354 unsigned char request_code; /* Major op-code of failed request */
355 unsigned char minor_code; /* Minor op-code of failed request */
356} XSyncAlarmError;
357
358typedef struct {
359 int type;
360 Display *display; /* Display the event was read from */
361 XSyncCounter counter; /* resource id */
362 unsigned long serial; /* serial number of failed request */
363 unsigned char error_code; /* error base + XSyncBadCounter */
364 unsigned char request_code; /* Major op-code of failed request */
365 unsigned char minor_code; /* Minor op-code of failed request */
366} XSyncCounterError;
367
368/*
369 * Prototypes
370 */
371
372_XFUNCPROTOBEGIN
373
374extern Status XSyncQueryExtension(
375 Display* /*dpy*/,
376 int* /*event_base_return*/,
377 int* /*error_base_return*/
378);
379
380extern Status XSyncInitialize(
381 Display* /*dpy*/,
382 int* /*major_version_return*/,
383 int* /*minor_version_return*/
384);
385
386extern XSyncSystemCounter *XSyncListSystemCounters(
387 Display* /*dpy*/,
388 int* /*n_counters_return*/
389);
390
391extern void XSyncFreeSystemCounterList(
392 XSyncSystemCounter* /*list*/
393);
394
395extern XSyncCounter XSyncCreateCounter(
396 Display* /*dpy*/,
397 XSyncValue /*initial_value*/
398);
399
400extern Status XSyncSetCounter(
401 Display* /*dpy*/,
402 XSyncCounter /*counter*/,
403 XSyncValue /*value*/
404);
405
406extern Status XSyncChangeCounter(
407 Display* /*dpy*/,
408 XSyncCounter /*counter*/,
409 XSyncValue /*value*/
410);
411
412extern Status XSyncDestroyCounter(
413 Display* /*dpy*/,
414 XSyncCounter /*counter*/
415);
416
417extern Status XSyncQueryCounter(
418 Display* /*dpy*/,
419 XSyncCounter /*counter*/,
420 XSyncValue* /*value_return*/
421);
422
423extern Status XSyncAwait(
424 Display* /*dpy*/,
425 XSyncWaitCondition* /*wait_list*/,
426 int /*n_conditions*/
427);
428
429extern XSyncAlarm XSyncCreateAlarm(
430 Display* /*dpy*/,
431 unsigned long /*values_mask*/,
432 XSyncAlarmAttributes* /*values*/
433);
434
435extern Status XSyncDestroyAlarm(
436 Display* /*dpy*/,
437 XSyncAlarm /*alarm*/
438);
439
440extern Status XSyncQueryAlarm(
441 Display* /*dpy*/,
442 XSyncAlarm /*alarm*/,
443 XSyncAlarmAttributes* /*values_return*/
444);
445
446extern Status XSyncChangeAlarm(
447 Display* /*dpy*/,
448 XSyncAlarm /*alarm*/,
449 unsigned long /*values_mask*/,
450 XSyncAlarmAttributes* /*values*/
451);
452
453extern Status XSyncSetPriority(
454 Display* /*dpy*/,
455 XID /*client_resource_id*/,
456 int /*priority*/
457);
458
459extern Status XSyncGetPriority(
460 Display* /*dpy*/,
461 XID /*client_resource_id*/,
462 int* /*return_priority*/
463);
464
465#endif /* _SYNC_SERVER */
466
467_XFUNCPROTOEND
468
469#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