blob: 2de222ab5b9bc57d571f79af410a24289a758c70 [file] [log] [blame]
David 'Digit' Turner1b0544d2014-03-27 13:51:24 +01001/* $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#include <X11/extensions/syncconst.h>
58
59_XFUNCPROTOBEGIN
60/* get rid of macros so we can define corresponding functions */
61#undef XSyncIntToValue
62#undef XSyncIntsToValue
63#undef XSyncValueGreaterThan
64#undef XSyncValueLessThan
65#undef XSyncValueGreaterOrEqual
66#undef XSyncValueLessOrEqual
67#undef XSyncValueEqual
68#undef XSyncValueIsNegative
69#undef XSyncValueIsZero
70#undef XSyncValueIsPositive
71#undef XSyncValueLow32
72#undef XSyncValueHigh32
73#undef XSyncValueAdd
74#undef XSyncValueSubtract
75#undef XSyncMaxValue
76#undef XSyncMinValue
77
78extern void XSyncIntToValue(
79 XSyncValue* /*pv*/,
80 int /*i*/
81);
82
83extern void XSyncIntsToValue(
84 XSyncValue* /*pv*/,
85 unsigned int /*l*/,
86 int /*h*/
87);
88
89extern Bool XSyncValueGreaterThan(
90 XSyncValue /*a*/,
91 XSyncValue /*b*/
92);
93
94extern Bool XSyncValueLessThan(
95 XSyncValue /*a*/,
96 XSyncValue /*b*/
97);
98
99extern Bool XSyncValueGreaterOrEqual(
100 XSyncValue /*a*/,
101 XSyncValue /*b*/
102);
103
104extern Bool XSyncValueLessOrEqual(
105 XSyncValue /*a*/,
106 XSyncValue /*b*/
107);
108
109extern Bool XSyncValueEqual(
110 XSyncValue /*a*/,
111 XSyncValue /*b*/
112);
113
114extern Bool XSyncValueIsNegative(
115 XSyncValue /*v*/
116);
117
118extern Bool XSyncValueIsZero(
119 XSyncValue /*a*/
120);
121
122extern Bool XSyncValueIsPositive(
123 XSyncValue /*v*/
124);
125
126extern unsigned int XSyncValueLow32(
127 XSyncValue /*v*/
128);
129
130extern int XSyncValueHigh32(
131 XSyncValue /*v*/
132);
133
134extern void XSyncValueAdd(
135 XSyncValue* /*presult*/,
136 XSyncValue /*a*/,
137 XSyncValue /*b*/,
138 int* /*poverflow*/
139);
140
141extern void XSyncValueSubtract(
142 XSyncValue* /*presult*/,
143 XSyncValue /*a*/,
144 XSyncValue /*b*/,
145 int* /*poverflow*/
146);
147
148extern void XSyncMaxValue(
149 XSyncValue* /*pv*/
150);
151
152extern void XSyncMinValue(
153 XSyncValue* /*pv*/
154);
155
156_XFUNCPROTOEND
157
158
159typedef struct _XSyncSystemCounter {
160 char *name; /* null-terminated name of system counter */
161 XSyncCounter counter; /* counter id of this system counter */
162 XSyncValue resolution; /* resolution of this system counter */
163} XSyncSystemCounter;
164
165
166typedef struct {
167 XSyncCounter counter; /* counter to trigger on */
168 XSyncValueType value_type; /* absolute/relative */
169 XSyncValue wait_value; /* value to compare counter to */
170 XSyncTestType test_type; /* pos/neg comparison/transtion */
171} XSyncTrigger;
172
173typedef struct {
174 XSyncTrigger trigger; /* trigger for await */
175 XSyncValue event_threshold; /* send event if past threshold */
176} XSyncWaitCondition;
177
178
179typedef struct {
180 XSyncTrigger trigger;
181 XSyncValue delta;
182 Bool events;
183 XSyncAlarmState state;
184} XSyncAlarmAttributes;
185
186/*
187 * Events
188 */
189
190typedef struct {
191 int type; /* event base + XSyncCounterNotify */
192 unsigned long serial; /* # of last request processed by server */
193 Bool send_event; /* true if this came from a SendEvent request */
194 Display *display; /* Display the event was read from */
195 XSyncCounter counter; /* counter involved in await */
196 XSyncValue wait_value; /* value being waited for */
197 XSyncValue counter_value; /* counter value when this event was sent */
198 Time time; /* milliseconds */
199 int count; /* how many more events to come */
200 Bool destroyed; /* True if counter was destroyed */
201} XSyncCounterNotifyEvent;
202
203typedef struct {
204 int type; /* event base + XSyncCounterNotify */
205 unsigned long serial; /* # of last request processed by server */
206 Bool send_event; /* true if this came from a SendEvent request */
207 Display *display; /* Display the event was read from */
208 XSyncAlarm alarm; /* alarm that triggered */
209 XSyncValue counter_value; /* value that triggered the alarm */
210 XSyncValue alarm_value; /* test value of trigger in alarm */
211 Time time; /* milliseconds */
212 XSyncAlarmState state; /* new state of alarm */
213} XSyncAlarmNotifyEvent;
214
215/*
216 * Errors
217 */
218
219typedef struct {
220 int type;
221 Display *display; /* Display the event was read from */
222 XSyncAlarm alarm; /* resource id */
223 unsigned long serial; /* serial number of failed request */
224 unsigned char error_code; /* error base + XSyncBadAlarm */
225 unsigned char request_code; /* Major op-code of failed request */
226 unsigned char minor_code; /* Minor op-code of failed request */
227} XSyncAlarmError;
228
229typedef struct {
230 int type;
231 Display *display; /* Display the event was read from */
232 XSyncCounter counter; /* resource id */
233 unsigned long serial; /* serial number of failed request */
234 unsigned char error_code; /* error base + XSyncBadCounter */
235 unsigned char request_code; /* Major op-code of failed request */
236 unsigned char minor_code; /* Minor op-code of failed request */
237} XSyncCounterError;
238
239/*
240 * Prototypes
241 */
242
243_XFUNCPROTOBEGIN
244
245extern Status XSyncQueryExtension(
246 Display* /*dpy*/,
247 int* /*event_base_return*/,
248 int* /*error_base_return*/
249);
250
251extern Status XSyncInitialize(
252 Display* /*dpy*/,
253 int* /*major_version_return*/,
254 int* /*minor_version_return*/
255);
256
257extern XSyncSystemCounter *XSyncListSystemCounters(
258 Display* /*dpy*/,
259 int* /*n_counters_return*/
260);
261
262extern void XSyncFreeSystemCounterList(
263 XSyncSystemCounter* /*list*/
264);
265
266extern XSyncCounter XSyncCreateCounter(
267 Display* /*dpy*/,
268 XSyncValue /*initial_value*/
269);
270
271extern Status XSyncSetCounter(
272 Display* /*dpy*/,
273 XSyncCounter /*counter*/,
274 XSyncValue /*value*/
275);
276
277extern Status XSyncChangeCounter(
278 Display* /*dpy*/,
279 XSyncCounter /*counter*/,
280 XSyncValue /*value*/
281);
282
283extern Status XSyncDestroyCounter(
284 Display* /*dpy*/,
285 XSyncCounter /*counter*/
286);
287
288extern Status XSyncQueryCounter(
289 Display* /*dpy*/,
290 XSyncCounter /*counter*/,
291 XSyncValue* /*value_return*/
292);
293
294extern Status XSyncAwait(
295 Display* /*dpy*/,
296 XSyncWaitCondition* /*wait_list*/,
297 int /*n_conditions*/
298);
299
300extern XSyncAlarm XSyncCreateAlarm(
301 Display* /*dpy*/,
302 unsigned long /*values_mask*/,
303 XSyncAlarmAttributes* /*values*/
304);
305
306extern Status XSyncDestroyAlarm(
307 Display* /*dpy*/,
308 XSyncAlarm /*alarm*/
309);
310
311extern Status XSyncQueryAlarm(
312 Display* /*dpy*/,
313 XSyncAlarm /*alarm*/,
314 XSyncAlarmAttributes* /*values_return*/
315);
316
317extern Status XSyncChangeAlarm(
318 Display* /*dpy*/,
319 XSyncAlarm /*alarm*/,
320 unsigned long /*values_mask*/,
321 XSyncAlarmAttributes* /*values*/
322);
323
324extern Status XSyncSetPriority(
325 Display* /*dpy*/,
326 XID /*client_resource_id*/,
327 int /*priority*/
328);
329
330extern Status XSyncGetPriority(
331 Display* /*dpy*/,
332 XID /*client_resource_id*/,
333 int* /*return_priority*/
334);
335
336_XFUNCPROTOEND
337
338#endif /* _SYNC_H_ */