a00d9c58a3d47dccdef1588c68afe062a3802433
[framework/uifw/xorg/lib/libxext.git] / include / X11 / extensions / sync.h
1 /*
2
3 Copyright 1991, 1993, 1994, 1998  The Open Group
4
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
24
25 */
26
27 /***********************************************************
28 Copyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
29 and Olivetti Research Limited, Cambridge, England.
30
31                         All Rights Reserved
32
33 Permission to use, copy, modify, and distribute this software and its 
34 documentation for any purpose and without fee is hereby granted, 
35 provided that the above copyright notice appear in all copies and that
36 both that copyright notice and this permission notice appear in 
37 supporting documentation, and that the names of Digital or Olivetti
38 not be used in advertising or publicity pertaining to distribution of the
39 software without specific, written prior permission.  
40
41 DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
42 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
43 FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
44 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
45 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
46 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
47 PERFORMANCE OF THIS SOFTWARE.
48
49 ******************************************************************/
50
51 #ifndef _SYNC_H_
52 #define _SYNC_H_
53
54 #include <X11/Xfuncproto.h>
55 #include <X11/extensions/syncconst.h>
56
57 #ifdef _SYNC_SERVER
58 #include <X11/extensions/syncproto.h>
59 #else
60
61 _XFUNCPROTOBEGIN
62 /* get rid of macros so we can define corresponding functions */
63 #undef XSyncIntToValue
64 #undef XSyncIntsToValue
65 #undef XSyncValueGreaterThan
66 #undef XSyncValueLessThan
67 #undef XSyncValueGreaterOrEqual
68 #undef XSyncValueLessOrEqual
69 #undef XSyncValueEqual
70 #undef XSyncValueIsNegative
71 #undef XSyncValueIsZero
72 #undef XSyncValueIsPositive
73 #undef XSyncValueLow32
74 #undef XSyncValueHigh32
75 #undef XSyncValueAdd
76 #undef XSyncValueSubtract
77 #undef XSyncMaxValue
78 #undef XSyncMinValue
79
80 extern void XSyncIntToValue(
81     XSyncValue* /*pv*/,
82     int /*i*/
83 );
84
85 extern void XSyncIntsToValue(
86     XSyncValue* /*pv*/,
87     unsigned int /*l*/,
88     int /*h*/
89 );
90
91 extern Bool XSyncValueGreaterThan(
92     XSyncValue /*a*/,
93     XSyncValue /*b*/
94 );
95
96 extern Bool XSyncValueLessThan(
97     XSyncValue /*a*/,
98     XSyncValue /*b*/
99 );
100
101 extern Bool XSyncValueGreaterOrEqual(
102     XSyncValue /*a*/,
103     XSyncValue /*b*/
104 );
105
106 extern Bool XSyncValueLessOrEqual(
107     XSyncValue /*a*/,
108     XSyncValue /*b*/
109 );
110
111 extern Bool XSyncValueEqual(
112     XSyncValue /*a*/,
113     XSyncValue /*b*/
114 );
115
116 extern Bool XSyncValueIsNegative(
117     XSyncValue /*v*/
118 );
119
120 extern Bool XSyncValueIsZero(
121     XSyncValue /*a*/
122 );
123
124 extern Bool XSyncValueIsPositive(
125     XSyncValue /*v*/
126 );
127
128 extern unsigned int XSyncValueLow32(
129     XSyncValue /*v*/
130 );
131
132 extern int XSyncValueHigh32(
133     XSyncValue /*v*/
134 );
135
136 extern void XSyncValueAdd(
137     XSyncValue* /*presult*/,
138     XSyncValue /*a*/,
139     XSyncValue /*b*/,
140     int* /*poverflow*/
141 );
142
143 extern void XSyncValueSubtract(
144     XSyncValue* /*presult*/,
145     XSyncValue /*a*/,
146     XSyncValue /*b*/,
147     int* /*poverflow*/
148 );
149
150 extern void XSyncMaxValue(
151     XSyncValue* /*pv*/
152 );
153
154 extern void XSyncMinValue(
155     XSyncValue* /*pv*/
156 );
157
158 _XFUNCPROTOEND
159
160
161 typedef struct _XSyncSystemCounter {
162     char *name;                 /* null-terminated name of system counter */
163     XSyncCounter counter;       /* counter id of this system counter */
164     XSyncValue resolution;      /* resolution of this system counter */
165 } XSyncSystemCounter;
166
167
168 typedef struct {
169     XSyncCounter counter;       /* counter to trigger on */
170     XSyncValueType value_type;  /* absolute/relative */
171     XSyncValue wait_value;      /* value to compare counter to */
172     XSyncTestType test_type;    /* pos/neg comparison/transtion */
173 } XSyncTrigger;
174
175 typedef struct {
176     XSyncTrigger trigger;       /* trigger for await */
177     XSyncValue event_threshold; /* send event if past threshold */
178 } XSyncWaitCondition;
179
180
181 typedef struct {
182     XSyncTrigger trigger;
183     XSyncValue  delta;
184     Bool events;
185     XSyncAlarmState state;
186 } XSyncAlarmAttributes;
187
188 /*
189  *  Events
190  */
191
192 typedef struct {
193     int type;                   /* event base + XSyncCounterNotify */
194     unsigned long serial;       /* # of last request processed by server */
195     Bool send_event;            /* true if this came from a SendEvent request */
196     Display *display;           /* Display the event was read from */
197     XSyncCounter counter;       /* counter involved in await */
198     XSyncValue wait_value;      /* value being waited for */
199     XSyncValue counter_value;   /* counter value when this event was sent */
200     Time time;                  /* milliseconds */
201     int count;                  /* how many more events to come */
202     Bool destroyed;             /* True if counter was destroyed */
203 } XSyncCounterNotifyEvent;
204
205 typedef struct {
206     int type;                   /* event base + XSyncCounterNotify */
207     unsigned long serial;       /* # of last request processed by server */
208     Bool send_event;            /* true if this came from a SendEvent request */
209     Display *display;           /* Display the event was read from */
210     XSyncAlarm alarm;           /* alarm that triggered */
211     XSyncValue counter_value;   /* value that triggered the alarm */
212     XSyncValue alarm_value;     /* test  value of trigger in alarm */
213     Time time;                  /* milliseconds */
214     XSyncAlarmState state;      /* new state of alarm */
215 } XSyncAlarmNotifyEvent;
216
217 /*
218  *  Errors 
219  */
220
221 typedef struct {
222     int type;                   
223     Display *display;           /* Display the event was read from */
224     XSyncAlarm alarm;           /* resource id */
225     unsigned long serial;       /* serial number of failed request */
226     unsigned char error_code;   /* error base + XSyncBadAlarm */
227     unsigned char request_code; /* Major op-code of failed request */
228     unsigned char minor_code;   /* Minor op-code of failed request */
229 } XSyncAlarmError;
230
231 typedef struct {
232     int type;                   
233     Display *display;           /* Display the event was read from */
234     XSyncCounter counter;       /* resource id */
235     unsigned long serial;       /* serial number of failed request */
236     unsigned char error_code;   /* error base + XSyncBadCounter */
237     unsigned char request_code; /* Major op-code of failed request */
238     unsigned char minor_code;   /* Minor op-code of failed request */
239 } XSyncCounterError;
240
241 /* 
242  *  Prototypes
243  */
244
245 _XFUNCPROTOBEGIN
246
247 extern Status XSyncQueryExtension(
248     Display* /*dpy*/,
249     int* /*event_base_return*/,
250     int* /*error_base_return*/
251 );
252
253 extern Status XSyncInitialize(
254     Display* /*dpy*/,
255     int* /*major_version_return*/,
256     int* /*minor_version_return*/
257 );
258
259 extern XSyncSystemCounter *XSyncListSystemCounters(
260     Display* /*dpy*/,
261     int* /*n_counters_return*/
262 );
263
264 extern void XSyncFreeSystemCounterList(
265     XSyncSystemCounter* /*list*/
266 );
267
268 extern XSyncCounter XSyncCreateCounter(
269     Display* /*dpy*/,
270     XSyncValue /*initial_value*/
271 );
272
273 extern Status XSyncSetCounter(
274     Display* /*dpy*/,
275     XSyncCounter /*counter*/,
276     XSyncValue /*value*/
277 );
278
279 extern Status XSyncChangeCounter(
280     Display* /*dpy*/,
281     XSyncCounter /*counter*/,
282     XSyncValue /*value*/
283 );
284
285 extern Status XSyncDestroyCounter(
286     Display* /*dpy*/,
287     XSyncCounter /*counter*/
288 );
289
290 extern Status XSyncQueryCounter(
291     Display* /*dpy*/,
292     XSyncCounter /*counter*/,
293     XSyncValue* /*value_return*/
294 );
295
296 extern Status XSyncAwait(
297     Display* /*dpy*/,
298     XSyncWaitCondition* /*wait_list*/,
299     int /*n_conditions*/
300 );
301
302 extern XSyncAlarm XSyncCreateAlarm(
303     Display* /*dpy*/,
304     unsigned long /*values_mask*/,
305     XSyncAlarmAttributes* /*values*/
306 );
307
308 extern Status XSyncDestroyAlarm(
309     Display* /*dpy*/,
310     XSyncAlarm /*alarm*/
311 );
312
313 extern Status XSyncQueryAlarm(
314     Display* /*dpy*/,
315     XSyncAlarm /*alarm*/,
316     XSyncAlarmAttributes* /*values_return*/
317 );
318
319 extern Status XSyncChangeAlarm(
320     Display* /*dpy*/,
321     XSyncAlarm /*alarm*/,
322     unsigned long /*values_mask*/,
323     XSyncAlarmAttributes* /*values*/
324 );
325
326 extern Status XSyncSetPriority(
327     Display* /*dpy*/,
328     XID /*client_resource_id*/,
329     int /*priority*/
330 );
331
332 extern Status XSyncGetPriority(
333     Display* /*dpy*/,
334     XID /*client_resource_id*/,
335     int* /*return_priority*/
336 );
337
338 extern XSyncFence XSyncCreateFence(
339     Display* /*dpy*/,
340     Drawable /*d*/,
341     Bool /*initially_triggered*/
342 );
343
344 extern Bool XSyncTriggerFence(
345     Display* /*dpy*/,
346     XSyncFence /*fence*/
347 );
348
349 extern Bool XSyncResetFence(
350     Display* /*dpy*/,
351     XSyncFence /*fence*/
352 );
353
354 extern Bool XSyncDestroyFence(
355     Display* /*dpy*/,
356     XSyncFence /*fence*/
357 );
358
359 extern Bool XSyncQueryFence(
360     Display* /*dpy*/,
361     XSyncFence /*fence*/,
362     Bool* /*triggered*/
363 );
364
365 extern Bool XSyncAwaitFence(
366     Display* /*dpy*/,
367     const XSyncFence* /*fence_list*/,
368     int /*n_fences*/
369 );
370
371 _XFUNCPROTOEND
372
373 #endif /* _SYNC_SERVER */
374
375 #endif /* _SYNC_H_ */