1485f0483Smrg/*
2485f0483Smrg
3485f0483SmrgCopyright 1991, 1993, 1994, 1998  The Open Group
4485f0483Smrg
5485f0483SmrgPermission to use, copy, modify, distribute, and sell this software and its
6485f0483Smrgdocumentation for any purpose is hereby granted without fee, provided that
7485f0483Smrgthe above copyright notice appear in all copies and that both that
8485f0483Smrgcopyright notice and this permission notice appear in supporting
9485f0483Smrgdocumentation.
10485f0483Smrg
11485f0483SmrgThe above copyright notice and this permission notice shall be included in
12485f0483Smrgall copies or substantial portions of the Software.
13485f0483Smrg
14485f0483SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15485f0483SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16485f0483SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
17485f0483SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18485f0483SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19485f0483SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20485f0483Smrg
21485f0483SmrgExcept as contained in this notice, the name of The Open Group shall not be
22485f0483Smrgused in advertising or otherwise to promote the sale, use or other dealings
23485f0483Smrgin this Software without prior written authorization from The Open Group.
24485f0483Smrg
25485f0483Smrg*/
26485f0483Smrg
27485f0483Smrg/***********************************************************
28485f0483SmrgCopyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
29485f0483Smrgand Olivetti Research Limited, Cambridge, England.
30485f0483Smrg
31485f0483Smrg                        All Rights Reserved
32485f0483Smrg
33af9a7ee5SmrgPermission to use, copy, modify, and distribute this software and its
34af9a7ee5Smrgdocumentation for any purpose and without fee is hereby granted,
35485f0483Smrgprovided that the above copyright notice appear in all copies and that
36af9a7ee5Smrgboth that copyright notice and this permission notice appear in
37485f0483Smrgsupporting documentation, and that the names of Digital or Olivetti
38485f0483Smrgnot be used in advertising or publicity pertaining to distribution of the
39af9a7ee5Smrgsoftware without specific, written prior permission.
40485f0483Smrg
41485f0483SmrgDIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
42485f0483SmrgSOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
43485f0483SmrgFITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
44485f0483SmrgCONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
45485f0483SmrgUSE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
46485f0483SmrgOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
47485f0483SmrgPERFORMANCE OF THIS SOFTWARE.
48485f0483Smrg
49485f0483Smrg******************************************************************/
50485f0483Smrg
51485f0483Smrg#ifndef _SYNC_H_
52485f0483Smrg#define _SYNC_H_
53485f0483Smrg
54485f0483Smrg#include <X11/Xfuncproto.h>
55485f0483Smrg#include <X11/extensions/syncconst.h>
56485f0483Smrg
57b9b4fd27Smrg#ifdef _SYNC_SERVER
58b9b4fd27Smrg#include <X11/extensions/syncproto.h>
59b9b4fd27Smrg#else
60b9b4fd27Smrg
61485f0483Smrg_XFUNCPROTOBEGIN
62485f0483Smrg/* get rid of macros so we can define corresponding functions */
63485f0483Smrg#undef XSyncIntToValue
64485f0483Smrg#undef XSyncIntsToValue
65485f0483Smrg#undef XSyncValueGreaterThan
66485f0483Smrg#undef XSyncValueLessThan
67485f0483Smrg#undef XSyncValueGreaterOrEqual
68485f0483Smrg#undef XSyncValueLessOrEqual
69485f0483Smrg#undef XSyncValueEqual
70485f0483Smrg#undef XSyncValueIsNegative
71485f0483Smrg#undef XSyncValueIsZero
72485f0483Smrg#undef XSyncValueIsPositive
73485f0483Smrg#undef XSyncValueLow32
74485f0483Smrg#undef XSyncValueHigh32
75485f0483Smrg#undef XSyncValueAdd
76485f0483Smrg#undef XSyncValueSubtract
77485f0483Smrg#undef XSyncMaxValue
78485f0483Smrg#undef XSyncMinValue
79485f0483Smrg
80485f0483Smrgextern void XSyncIntToValue(
81485f0483Smrg    XSyncValue* /*pv*/,
82485f0483Smrg    int /*i*/
83485f0483Smrg);
84485f0483Smrg
85485f0483Smrgextern void XSyncIntsToValue(
86485f0483Smrg    XSyncValue* /*pv*/,
87485f0483Smrg    unsigned int /*l*/,
88485f0483Smrg    int /*h*/
89485f0483Smrg);
90485f0483Smrg
91485f0483Smrgextern Bool XSyncValueGreaterThan(
92485f0483Smrg    XSyncValue /*a*/,
93485f0483Smrg    XSyncValue /*b*/
94485f0483Smrg);
95485f0483Smrg
96485f0483Smrgextern Bool XSyncValueLessThan(
97485f0483Smrg    XSyncValue /*a*/,
98485f0483Smrg    XSyncValue /*b*/
99485f0483Smrg);
100485f0483Smrg
101485f0483Smrgextern Bool XSyncValueGreaterOrEqual(
102485f0483Smrg    XSyncValue /*a*/,
103485f0483Smrg    XSyncValue /*b*/
104485f0483Smrg);
105485f0483Smrg
106485f0483Smrgextern Bool XSyncValueLessOrEqual(
107485f0483Smrg    XSyncValue /*a*/,
108485f0483Smrg    XSyncValue /*b*/
109485f0483Smrg);
110485f0483Smrg
111485f0483Smrgextern Bool XSyncValueEqual(
112485f0483Smrg    XSyncValue /*a*/,
113485f0483Smrg    XSyncValue /*b*/
114485f0483Smrg);
115485f0483Smrg
116485f0483Smrgextern Bool XSyncValueIsNegative(
117485f0483Smrg    XSyncValue /*v*/
118485f0483Smrg);
119485f0483Smrg
120485f0483Smrgextern Bool XSyncValueIsZero(
121485f0483Smrg    XSyncValue /*a*/
122485f0483Smrg);
123485f0483Smrg
124485f0483Smrgextern Bool XSyncValueIsPositive(
125485f0483Smrg    XSyncValue /*v*/
126485f0483Smrg);
127485f0483Smrg
128485f0483Smrgextern unsigned int XSyncValueLow32(
129485f0483Smrg    XSyncValue /*v*/
130485f0483Smrg);
131485f0483Smrg
132485f0483Smrgextern int XSyncValueHigh32(
133485f0483Smrg    XSyncValue /*v*/
134485f0483Smrg);
135485f0483Smrg
136485f0483Smrgextern void XSyncValueAdd(
137485f0483Smrg    XSyncValue* /*presult*/,
138485f0483Smrg    XSyncValue /*a*/,
139485f0483Smrg    XSyncValue /*b*/,
140485f0483Smrg    int* /*poverflow*/
141485f0483Smrg);
142485f0483Smrg
143485f0483Smrgextern void XSyncValueSubtract(
144485f0483Smrg    XSyncValue* /*presult*/,
145485f0483Smrg    XSyncValue /*a*/,
146485f0483Smrg    XSyncValue /*b*/,
147485f0483Smrg    int* /*poverflow*/
148485f0483Smrg);
149485f0483Smrg
150485f0483Smrgextern void XSyncMaxValue(
151485f0483Smrg    XSyncValue* /*pv*/
152485f0483Smrg);
153485f0483Smrg
154485f0483Smrgextern void XSyncMinValue(
155485f0483Smrg    XSyncValue* /*pv*/
156485f0483Smrg);
157485f0483Smrg
158485f0483Smrg_XFUNCPROTOEND
159485f0483Smrg
160485f0483Smrg
161485f0483Smrgtypedef struct _XSyncSystemCounter {
162485f0483Smrg    char *name;			/* null-terminated name of system counter */
163485f0483Smrg    XSyncCounter counter;	/* counter id of this system counter */
164485f0483Smrg    XSyncValue resolution;	/* resolution of this system counter */
165485f0483Smrg} XSyncSystemCounter;
166485f0483Smrg
167485f0483Smrg
168485f0483Smrgtypedef struct {
169485f0483Smrg    XSyncCounter counter;	/* counter to trigger on */
170485f0483Smrg    XSyncValueType value_type;	/* absolute/relative */
171485f0483Smrg    XSyncValue wait_value;	/* value to compare counter to */
1720760f5d2Smrg    XSyncTestType test_type;	/* pos/neg comparison/transition */
173485f0483Smrg} XSyncTrigger;
174485f0483Smrg
175485f0483Smrgtypedef struct {
176485f0483Smrg    XSyncTrigger trigger;	/* trigger for await */
177485f0483Smrg    XSyncValue event_threshold; /* send event if past threshold */
178485f0483Smrg} XSyncWaitCondition;
179485f0483Smrg
180485f0483Smrg
181485f0483Smrgtypedef struct {
182485f0483Smrg    XSyncTrigger trigger;
183485f0483Smrg    XSyncValue  delta;
184485f0483Smrg    Bool events;
185485f0483Smrg    XSyncAlarmState state;
186485f0483Smrg} XSyncAlarmAttributes;
187485f0483Smrg
188485f0483Smrg/*
189485f0483Smrg *  Events
190485f0483Smrg */
191485f0483Smrg
192485f0483Smrgtypedef struct {
193485f0483Smrg    int type;			/* event base + XSyncCounterNotify */
194485f0483Smrg    unsigned long serial;	/* # of last request processed by server */
195485f0483Smrg    Bool send_event;		/* true if this came from a SendEvent request */
196485f0483Smrg    Display *display;		/* Display the event was read from */
197485f0483Smrg    XSyncCounter counter;	/* counter involved in await */
198485f0483Smrg    XSyncValue wait_value;	/* value being waited for */
199485f0483Smrg    XSyncValue counter_value;	/* counter value when this event was sent */
200485f0483Smrg    Time time;			/* milliseconds */
201485f0483Smrg    int count;			/* how many more events to come */
202485f0483Smrg    Bool destroyed;		/* True if counter was destroyed */
203485f0483Smrg} XSyncCounterNotifyEvent;
204485f0483Smrg
205485f0483Smrgtypedef struct {
206af9a7ee5Smrg    int type;			/* event base + XSyncAlarmNotify */
207485f0483Smrg    unsigned long serial;	/* # of last request processed by server */
208485f0483Smrg    Bool send_event;		/* true if this came from a SendEvent request */
209485f0483Smrg    Display *display;		/* Display the event was read from */
210485f0483Smrg    XSyncAlarm alarm;		/* alarm that triggered */
211485f0483Smrg    XSyncValue counter_value;	/* value that triggered the alarm */
212485f0483Smrg    XSyncValue alarm_value;	/* test  value of trigger in alarm */
213485f0483Smrg    Time time;			/* milliseconds */
214485f0483Smrg    XSyncAlarmState state;	/* new state of alarm */
215485f0483Smrg} XSyncAlarmNotifyEvent;
216485f0483Smrg
217485f0483Smrg/*
218af9a7ee5Smrg *  Errors
219485f0483Smrg */
220485f0483Smrg
221485f0483Smrgtypedef struct {
222af9a7ee5Smrg    int type;
223485f0483Smrg    Display *display;		/* Display the event was read from */
224485f0483Smrg    XSyncAlarm alarm;		/* resource id */
225485f0483Smrg    unsigned long serial;	/* serial number of failed request */
226485f0483Smrg    unsigned char error_code;	/* error base + XSyncBadAlarm */
227485f0483Smrg    unsigned char request_code;	/* Major op-code of failed request */
228485f0483Smrg    unsigned char minor_code;	/* Minor op-code of failed request */
229485f0483Smrg} XSyncAlarmError;
230485f0483Smrg
231485f0483Smrgtypedef struct {
232af9a7ee5Smrg    int type;
233485f0483Smrg    Display *display;		/* Display the event was read from */
234485f0483Smrg    XSyncCounter counter;	/* resource id */
235485f0483Smrg    unsigned long serial;	/* serial number of failed request */
236485f0483Smrg    unsigned char error_code;	/* error base + XSyncBadCounter */
237485f0483Smrg    unsigned char request_code;	/* Major op-code of failed request */
238485f0483Smrg    unsigned char minor_code;	/* Minor op-code of failed request */
239485f0483Smrg} XSyncCounterError;
240485f0483Smrg
241af9a7ee5Smrg/*
242485f0483Smrg *  Prototypes
243485f0483Smrg */
244485f0483Smrg
245485f0483Smrg_XFUNCPROTOBEGIN
246485f0483Smrg
247485f0483Smrgextern Status XSyncQueryExtension(
248485f0483Smrg    Display* /*dpy*/,
249485f0483Smrg    int* /*event_base_return*/,
250485f0483Smrg    int* /*error_base_return*/
251485f0483Smrg);
252485f0483Smrg
253485f0483Smrgextern Status XSyncInitialize(
254485f0483Smrg    Display* /*dpy*/,
255485f0483Smrg    int* /*major_version_return*/,
256485f0483Smrg    int* /*minor_version_return*/
257485f0483Smrg);
258485f0483Smrg
259485f0483Smrgextern XSyncSystemCounter *XSyncListSystemCounters(
260485f0483Smrg    Display* /*dpy*/,
261485f0483Smrg    int* /*n_counters_return*/
262485f0483Smrg);
263485f0483Smrg
264485f0483Smrgextern void XSyncFreeSystemCounterList(
265485f0483Smrg    XSyncSystemCounter* /*list*/
266485f0483Smrg);
267485f0483Smrg
268485f0483Smrgextern XSyncCounter XSyncCreateCounter(
269485f0483Smrg    Display* /*dpy*/,
270485f0483Smrg    XSyncValue /*initial_value*/
271485f0483Smrg);
272485f0483Smrg
273485f0483Smrgextern Status XSyncSetCounter(
274485f0483Smrg    Display* /*dpy*/,
275485f0483Smrg    XSyncCounter /*counter*/,
276485f0483Smrg    XSyncValue /*value*/
277485f0483Smrg);
278485f0483Smrg
279485f0483Smrgextern Status XSyncChangeCounter(
280485f0483Smrg    Display* /*dpy*/,
281485f0483Smrg    XSyncCounter /*counter*/,
282485f0483Smrg    XSyncValue /*value*/
283485f0483Smrg);
284485f0483Smrg
285485f0483Smrgextern Status XSyncDestroyCounter(
286485f0483Smrg    Display* /*dpy*/,
287485f0483Smrg    XSyncCounter /*counter*/
288485f0483Smrg);
289485f0483Smrg
290485f0483Smrgextern Status XSyncQueryCounter(
291485f0483Smrg    Display* /*dpy*/,
292485f0483Smrg    XSyncCounter /*counter*/,
293485f0483Smrg    XSyncValue* /*value_return*/
294485f0483Smrg);
295485f0483Smrg
296485f0483Smrgextern Status XSyncAwait(
297485f0483Smrg    Display* /*dpy*/,
298485f0483Smrg    XSyncWaitCondition* /*wait_list*/,
299485f0483Smrg    int /*n_conditions*/
300485f0483Smrg);
301485f0483Smrg
302485f0483Smrgextern XSyncAlarm XSyncCreateAlarm(
303485f0483Smrg    Display* /*dpy*/,
304485f0483Smrg    unsigned long /*values_mask*/,
305485f0483Smrg    XSyncAlarmAttributes* /*values*/
306485f0483Smrg);
307485f0483Smrg
308485f0483Smrgextern Status XSyncDestroyAlarm(
309485f0483Smrg    Display* /*dpy*/,
310485f0483Smrg    XSyncAlarm /*alarm*/
311485f0483Smrg);
312485f0483Smrg
313485f0483Smrgextern Status XSyncQueryAlarm(
314485f0483Smrg    Display* /*dpy*/,
315485f0483Smrg    XSyncAlarm /*alarm*/,
316485f0483Smrg    XSyncAlarmAttributes* /*values_return*/
317485f0483Smrg);
318485f0483Smrg
319485f0483Smrgextern Status XSyncChangeAlarm(
320485f0483Smrg    Display* /*dpy*/,
321485f0483Smrg    XSyncAlarm /*alarm*/,
322485f0483Smrg    unsigned long /*values_mask*/,
323485f0483Smrg    XSyncAlarmAttributes* /*values*/
324485f0483Smrg);
325485f0483Smrg
326485f0483Smrgextern Status XSyncSetPriority(
327485f0483Smrg    Display* /*dpy*/,
328485f0483Smrg    XID /*client_resource_id*/,
329485f0483Smrg    int /*priority*/
330485f0483Smrg);
331485f0483Smrg
332485f0483Smrgextern Status XSyncGetPriority(
333485f0483Smrg    Display* /*dpy*/,
334485f0483Smrg    XID /*client_resource_id*/,
335485f0483Smrg    int* /*return_priority*/
336485f0483Smrg);
337485f0483Smrg
338a5602400Smrgextern XSyncFence XSyncCreateFence(
339a5602400Smrg    Display* /*dpy*/,
340a5602400Smrg    Drawable /*d*/,
341a5602400Smrg    Bool /*initially_triggered*/
342a5602400Smrg);
343a5602400Smrg
344a5602400Smrgextern Bool XSyncTriggerFence(
345a5602400Smrg    Display* /*dpy*/,
346a5602400Smrg    XSyncFence /*fence*/
347a5602400Smrg);
348a5602400Smrg
349a5602400Smrgextern Bool XSyncResetFence(
350a5602400Smrg    Display* /*dpy*/,
351a5602400Smrg    XSyncFence /*fence*/
352a5602400Smrg);
353a5602400Smrg
354a5602400Smrgextern Bool XSyncDestroyFence(
355a5602400Smrg    Display* /*dpy*/,
356a5602400Smrg    XSyncFence /*fence*/
357a5602400Smrg);
358a5602400Smrg
359a5602400Smrgextern Bool XSyncQueryFence(
360a5602400Smrg    Display* /*dpy*/,
361a5602400Smrg    XSyncFence /*fence*/,
362a5602400Smrg    Bool* /*triggered*/
363a5602400Smrg);
364a5602400Smrg
365a5602400Smrgextern Bool XSyncAwaitFence(
366a5602400Smrg    Display* /*dpy*/,
367a5602400Smrg    const XSyncFence* /*fence_list*/,
368a5602400Smrg    int /*n_fences*/
369a5602400Smrg);
370a5602400Smrg
371485f0483Smrg_XFUNCPROTOEND
372485f0483Smrg
373b9b4fd27Smrg#endif /* _SYNC_SERVER */
374b9b4fd27Smrg
375485f0483Smrg#endif /* _SYNC_H_ */
376