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