sync.h revision b9b4fd27
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
59b9b4fd27Smrg#ifdef _SYNC_SERVER
60b9b4fd27Smrg#include <X11/extensions/syncproto.h>
61b9b4fd27Smrg#else
62b9b4fd27Smrg
63485f0483Smrg_XFUNCPROTOBEGIN
64485f0483Smrg/* get rid of macros so we can define corresponding functions */
65485f0483Smrg#undef XSyncIntToValue
66485f0483Smrg#undef XSyncIntsToValue
67485f0483Smrg#undef XSyncValueGreaterThan
68485f0483Smrg#undef XSyncValueLessThan
69485f0483Smrg#undef XSyncValueGreaterOrEqual
70485f0483Smrg#undef XSyncValueLessOrEqual
71485f0483Smrg#undef XSyncValueEqual
72485f0483Smrg#undef XSyncValueIsNegative
73485f0483Smrg#undef XSyncValueIsZero
74485f0483Smrg#undef XSyncValueIsPositive
75485f0483Smrg#undef XSyncValueLow32
76485f0483Smrg#undef XSyncValueHigh32
77485f0483Smrg#undef XSyncValueAdd
78485f0483Smrg#undef XSyncValueSubtract
79485f0483Smrg#undef XSyncMaxValue
80485f0483Smrg#undef XSyncMinValue
81485f0483Smrg
82485f0483Smrgextern void XSyncIntToValue(
83485f0483Smrg    XSyncValue* /*pv*/,
84485f0483Smrg    int /*i*/
85485f0483Smrg);
86485f0483Smrg
87485f0483Smrgextern void XSyncIntsToValue(
88485f0483Smrg    XSyncValue* /*pv*/,
89485f0483Smrg    unsigned int /*l*/,
90485f0483Smrg    int /*h*/
91485f0483Smrg);
92485f0483Smrg
93485f0483Smrgextern Bool XSyncValueGreaterThan(
94485f0483Smrg    XSyncValue /*a*/,
95485f0483Smrg    XSyncValue /*b*/
96485f0483Smrg);
97485f0483Smrg
98485f0483Smrgextern Bool XSyncValueLessThan(
99485f0483Smrg    XSyncValue /*a*/,
100485f0483Smrg    XSyncValue /*b*/
101485f0483Smrg);
102485f0483Smrg
103485f0483Smrgextern Bool XSyncValueGreaterOrEqual(
104485f0483Smrg    XSyncValue /*a*/,
105485f0483Smrg    XSyncValue /*b*/
106485f0483Smrg);
107485f0483Smrg
108485f0483Smrgextern Bool XSyncValueLessOrEqual(
109485f0483Smrg    XSyncValue /*a*/,
110485f0483Smrg    XSyncValue /*b*/
111485f0483Smrg);
112485f0483Smrg
113485f0483Smrgextern Bool XSyncValueEqual(
114485f0483Smrg    XSyncValue /*a*/,
115485f0483Smrg    XSyncValue /*b*/
116485f0483Smrg);
117485f0483Smrg
118485f0483Smrgextern Bool XSyncValueIsNegative(
119485f0483Smrg    XSyncValue /*v*/
120485f0483Smrg);
121485f0483Smrg
122485f0483Smrgextern Bool XSyncValueIsZero(
123485f0483Smrg    XSyncValue /*a*/
124485f0483Smrg);
125485f0483Smrg
126485f0483Smrgextern Bool XSyncValueIsPositive(
127485f0483Smrg    XSyncValue /*v*/
128485f0483Smrg);
129485f0483Smrg
130485f0483Smrgextern unsigned int XSyncValueLow32(
131485f0483Smrg    XSyncValue /*v*/
132485f0483Smrg);
133485f0483Smrg
134485f0483Smrgextern int XSyncValueHigh32(
135485f0483Smrg    XSyncValue /*v*/
136485f0483Smrg);
137485f0483Smrg
138485f0483Smrgextern void XSyncValueAdd(
139485f0483Smrg    XSyncValue* /*presult*/,
140485f0483Smrg    XSyncValue /*a*/,
141485f0483Smrg    XSyncValue /*b*/,
142485f0483Smrg    int* /*poverflow*/
143485f0483Smrg);
144485f0483Smrg
145485f0483Smrgextern void XSyncValueSubtract(
146485f0483Smrg    XSyncValue* /*presult*/,
147485f0483Smrg    XSyncValue /*a*/,
148485f0483Smrg    XSyncValue /*b*/,
149485f0483Smrg    int* /*poverflow*/
150485f0483Smrg);
151485f0483Smrg
152485f0483Smrgextern void XSyncMaxValue(
153485f0483Smrg    XSyncValue* /*pv*/
154485f0483Smrg);
155485f0483Smrg
156485f0483Smrgextern void XSyncMinValue(
157485f0483Smrg    XSyncValue* /*pv*/
158485f0483Smrg);
159485f0483Smrg
160485f0483Smrg_XFUNCPROTOEND
161485f0483Smrg
162485f0483Smrg
163485f0483Smrgtypedef struct _XSyncSystemCounter {
164485f0483Smrg    char *name;			/* null-terminated name of system counter */
165485f0483Smrg    XSyncCounter counter;	/* counter id of this system counter */
166485f0483Smrg    XSyncValue resolution;	/* resolution of this system counter */
167485f0483Smrg} XSyncSystemCounter;
168485f0483Smrg
169485f0483Smrg
170485f0483Smrgtypedef struct {
171485f0483Smrg    XSyncCounter counter;	/* counter to trigger on */
172485f0483Smrg    XSyncValueType value_type;	/* absolute/relative */
173485f0483Smrg    XSyncValue wait_value;	/* value to compare counter to */
174485f0483Smrg    XSyncTestType test_type;	/* pos/neg comparison/transtion */
175485f0483Smrg} XSyncTrigger;
176485f0483Smrg
177485f0483Smrgtypedef struct {
178485f0483Smrg    XSyncTrigger trigger;	/* trigger for await */
179485f0483Smrg    XSyncValue event_threshold; /* send event if past threshold */
180485f0483Smrg} XSyncWaitCondition;
181485f0483Smrg
182485f0483Smrg
183485f0483Smrgtypedef struct {
184485f0483Smrg    XSyncTrigger trigger;
185485f0483Smrg    XSyncValue  delta;
186485f0483Smrg    Bool events;
187485f0483Smrg    XSyncAlarmState state;
188485f0483Smrg} XSyncAlarmAttributes;
189485f0483Smrg
190485f0483Smrg/*
191485f0483Smrg *  Events
192485f0483Smrg */
193485f0483Smrg
194485f0483Smrgtypedef struct {
195485f0483Smrg    int type;			/* event base + XSyncCounterNotify */
196485f0483Smrg    unsigned long serial;	/* # of last request processed by server */
197485f0483Smrg    Bool send_event;		/* true if this came from a SendEvent request */
198485f0483Smrg    Display *display;		/* Display the event was read from */
199485f0483Smrg    XSyncCounter counter;	/* counter involved in await */
200485f0483Smrg    XSyncValue wait_value;	/* value being waited for */
201485f0483Smrg    XSyncValue counter_value;	/* counter value when this event was sent */
202485f0483Smrg    Time time;			/* milliseconds */
203485f0483Smrg    int count;			/* how many more events to come */
204485f0483Smrg    Bool destroyed;		/* True if counter was destroyed */
205485f0483Smrg} XSyncCounterNotifyEvent;
206485f0483Smrg
207485f0483Smrgtypedef struct {
208485f0483Smrg    int type;			/* event base + XSyncCounterNotify */
209485f0483Smrg    unsigned long serial;	/* # of last request processed by server */
210485f0483Smrg    Bool send_event;		/* true if this came from a SendEvent request */
211485f0483Smrg    Display *display;		/* Display the event was read from */
212485f0483Smrg    XSyncAlarm alarm;		/* alarm that triggered */
213485f0483Smrg    XSyncValue counter_value;	/* value that triggered the alarm */
214485f0483Smrg    XSyncValue alarm_value;	/* test  value of trigger in alarm */
215485f0483Smrg    Time time;			/* milliseconds */
216485f0483Smrg    XSyncAlarmState state;	/* new state of alarm */
217485f0483Smrg} XSyncAlarmNotifyEvent;
218485f0483Smrg
219485f0483Smrg/*
220485f0483Smrg *  Errors
221485f0483Smrg */
222485f0483Smrg
223485f0483Smrgtypedef struct {
224485f0483Smrg    int type;
225485f0483Smrg    Display *display;		/* Display the event was read from */
226485f0483Smrg    XSyncAlarm alarm;		/* resource id */
227485f0483Smrg    unsigned long serial;	/* serial number of failed request */
228485f0483Smrg    unsigned char error_code;	/* error base + XSyncBadAlarm */
229485f0483Smrg    unsigned char request_code;	/* Major op-code of failed request */
230485f0483Smrg    unsigned char minor_code;	/* Minor op-code of failed request */
231485f0483Smrg} XSyncAlarmError;
232485f0483Smrg
233485f0483Smrgtypedef struct {
234485f0483Smrg    int type;
235485f0483Smrg    Display *display;		/* Display the event was read from */
236485f0483Smrg    XSyncCounter counter;	/* resource id */
237485f0483Smrg    unsigned long serial;	/* serial number of failed request */
238485f0483Smrg    unsigned char error_code;	/* error base + XSyncBadCounter */
239485f0483Smrg    unsigned char request_code;	/* Major op-code of failed request */
240485f0483Smrg    unsigned char minor_code;	/* Minor op-code of failed request */
241485f0483Smrg} XSyncCounterError;
242485f0483Smrg
243485f0483Smrg/*
244485f0483Smrg *  Prototypes
245485f0483Smrg */
246485f0483Smrg
247485f0483Smrg_XFUNCPROTOBEGIN
248485f0483Smrg
249485f0483Smrgextern Status XSyncQueryExtension(
250485f0483Smrg    Display* /*dpy*/,
251485f0483Smrg    int* /*event_base_return*/,
252485f0483Smrg    int* /*error_base_return*/
253485f0483Smrg);
254485f0483Smrg
255485f0483Smrgextern Status XSyncInitialize(
256485f0483Smrg    Display* /*dpy*/,
257485f0483Smrg    int* /*major_version_return*/,
258485f0483Smrg    int* /*minor_version_return*/
259485f0483Smrg);
260485f0483Smrg
261485f0483Smrgextern XSyncSystemCounter *XSyncListSystemCounters(
262485f0483Smrg    Display* /*dpy*/,
263485f0483Smrg    int* /*n_counters_return*/
264485f0483Smrg);
265485f0483Smrg
266485f0483Smrgextern void XSyncFreeSystemCounterList(
267485f0483Smrg    XSyncSystemCounter* /*list*/
268485f0483Smrg);
269485f0483Smrg
270485f0483Smrgextern XSyncCounter XSyncCreateCounter(
271485f0483Smrg    Display* /*dpy*/,
272485f0483Smrg    XSyncValue /*initial_value*/
273485f0483Smrg);
274485f0483Smrg
275485f0483Smrgextern Status XSyncSetCounter(
276485f0483Smrg    Display* /*dpy*/,
277485f0483Smrg    XSyncCounter /*counter*/,
278485f0483Smrg    XSyncValue /*value*/
279485f0483Smrg);
280485f0483Smrg
281485f0483Smrgextern Status XSyncChangeCounter(
282485f0483Smrg    Display* /*dpy*/,
283485f0483Smrg    XSyncCounter /*counter*/,
284485f0483Smrg    XSyncValue /*value*/
285485f0483Smrg);
286485f0483Smrg
287485f0483Smrgextern Status XSyncDestroyCounter(
288485f0483Smrg    Display* /*dpy*/,
289485f0483Smrg    XSyncCounter /*counter*/
290485f0483Smrg);
291485f0483Smrg
292485f0483Smrgextern Status XSyncQueryCounter(
293485f0483Smrg    Display* /*dpy*/,
294485f0483Smrg    XSyncCounter /*counter*/,
295485f0483Smrg    XSyncValue* /*value_return*/
296485f0483Smrg);
297485f0483Smrg
298485f0483Smrgextern Status XSyncAwait(
299485f0483Smrg    Display* /*dpy*/,
300485f0483Smrg    XSyncWaitCondition* /*wait_list*/,
301485f0483Smrg    int /*n_conditions*/
302485f0483Smrg);
303485f0483Smrg
304485f0483Smrgextern XSyncAlarm XSyncCreateAlarm(
305485f0483Smrg    Display* /*dpy*/,
306485f0483Smrg    unsigned long /*values_mask*/,
307485f0483Smrg    XSyncAlarmAttributes* /*values*/
308485f0483Smrg);
309485f0483Smrg
310485f0483Smrgextern Status XSyncDestroyAlarm(
311485f0483Smrg    Display* /*dpy*/,
312485f0483Smrg    XSyncAlarm /*alarm*/
313485f0483Smrg);
314485f0483Smrg
315485f0483Smrgextern Status XSyncQueryAlarm(
316485f0483Smrg    Display* /*dpy*/,
317485f0483Smrg    XSyncAlarm /*alarm*/,
318485f0483Smrg    XSyncAlarmAttributes* /*values_return*/
319485f0483Smrg);
320485f0483Smrg
321485f0483Smrgextern Status XSyncChangeAlarm(
322485f0483Smrg    Display* /*dpy*/,
323485f0483Smrg    XSyncAlarm /*alarm*/,
324485f0483Smrg    unsigned long /*values_mask*/,
325485f0483Smrg    XSyncAlarmAttributes* /*values*/
326485f0483Smrg);
327485f0483Smrg
328485f0483Smrgextern Status XSyncSetPriority(
329485f0483Smrg    Display* /*dpy*/,
330485f0483Smrg    XID /*client_resource_id*/,
331485f0483Smrg    int /*priority*/
332485f0483Smrg);
333485f0483Smrg
334485f0483Smrgextern Status XSyncGetPriority(
335485f0483Smrg    Display* /*dpy*/,
336485f0483Smrg    XID /*client_resource_id*/,
337485f0483Smrg    int* /*return_priority*/
338485f0483Smrg);
339485f0483Smrg
340485f0483Smrg_XFUNCPROTOEND
341485f0483Smrg
342b9b4fd27Smrg#endif /* _SYNC_SERVER */
343b9b4fd27Smrg
344485f0483Smrg#endif /* _SYNC_H_ */
345