Git init
[framework/uifw/xorg/proto/x11proto-xext.git] / syncstr.h
1 /* $Xorg: syncstr.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $ */
2 /*
3
4 Copyright 1991, 1993, 1994, 1998  The Open Group
5
6 Permission to use, copy, modify, distribute, and sell this software and its
7 documentation for any purpose is hereby granted without fee, provided that
8 the above copyright notice appear in all copies and that both that
9 copyright notice and this permission notice appear in supporting
10 documentation.
11
12 The above copyright notice and this permission notice shall be included in
13 all copies or substantial portions of the Software.
14
15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
18 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Except as contained in this notice, the name of The Open Group shall not be
23 used in advertising or otherwise to promote the sale, use or other dealings
24 in this Software without prior written authorization from The Open Group.
25
26 */
27
28 /***********************************************************
29 Copyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
30 and Olivetti Research Limited, Cambridge, England.
31
32                         All Rights Reserved
33
34 Permission to use, copy, modify, and distribute this software and its 
35 documentation for any purpose and without fee is hereby granted, 
36 provided that the above copyright notice appear in all copies and that
37 both that copyright notice and this permission notice appear in 
38 supporting documentation, and that the names of Digital or Olivetti
39 not be used in advertising or publicity pertaining to distribution of the
40 software without specific, written prior permission.  
41
42 DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
43 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
44 FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
45 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
46 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
47 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
48 PERFORMANCE OF THIS SOFTWARE.
49
50 ******************************************************************/
51 /* $XFree86: xc/include/extensions/syncstr.h,v 1.3 2003/07/16 01:38:24 dawes Exp $ */
52
53 #ifndef _SYNCSTR_H_
54 #define _SYNCSTR_H_
55
56 #include <X11/extensions/syncproto.h>
57
58 #ifdef _SYNC_SERVER
59
60 #define CARD64 XSyncValue /* XXX temporary! need real 64 bit values for Alpha */
61
62 typedef struct _SyncCounter {
63     ClientPtr           client; /* Owning client. 0 for system counters */
64     XSyncCounter        id;             /* resource ID */
65     CARD64              value;          /* counter value */
66     struct _SyncTriggerList *pTriglist; /* list of triggers */
67     Bool                beingDestroyed; /* in process of going away */
68     struct _SysCounterInfo *pSysCounterInfo; /* NULL if not a system counter */
69 } SyncCounter;
70
71 /*
72  * The System Counter interface
73  */
74
75 typedef enum {
76     XSyncCounterNeverChanges,
77     XSyncCounterNeverIncreases,
78     XSyncCounterNeverDecreases,
79     XSyncCounterUnrestricted
80 } SyncCounterType;
81
82 typedef struct _SysCounterInfo {
83     char        *name;
84     CARD64      resolution;
85     CARD64      bracket_greater;
86     CARD64      bracket_less;
87     SyncCounterType counterType;  /* how can this counter change */
88     void        (*QueryValue)(
89                               pointer /*pCounter*/,
90                               CARD64 * /*freshvalue*/
91 );
92     void        (*BracketValues)(
93                                  pointer /*pCounter*/,
94                                  CARD64 * /*lessthan*/,
95                                  CARD64 * /*greaterthan*/
96 );
97 } SysCounterInfo;
98
99
100
101 typedef struct _SyncTrigger {
102     SyncCounter *pCounter;
103     CARD64      wait_value;     /* wait value */
104     unsigned int value_type;     /* Absolute or Relative */
105     unsigned int test_type;     /* transition or Comparision type */
106     CARD64      test_value;     /* trigger event threshold value */
107     Bool        (*CheckTrigger)(
108                                 struct _SyncTrigger * /*pTrigger*/,
109                                 CARD64 /*newval*/
110                                 );
111     void        (*TriggerFired)(
112                                 struct _SyncTrigger * /*pTrigger*/
113                                 );
114     void        (*CounterDestroyed)(
115                                 struct _SyncTrigger * /*pTrigger*/
116                                     );
117 } SyncTrigger;
118
119 typedef struct _SyncTriggerList {
120     SyncTrigger *pTrigger;
121     struct _SyncTriggerList *next;
122 } SyncTriggerList;
123
124 typedef struct _SyncAlarmClientList {
125     ClientPtr   client;
126     XID         delete_id;
127     struct _SyncAlarmClientList *next;
128 } SyncAlarmClientList;
129
130 typedef struct _SyncAlarm {
131     SyncTrigger trigger;
132     ClientPtr   client;
133     XSyncAlarm  alarm_id;
134     CARD64      delta;
135     int         events;
136     int         state;
137     SyncAlarmClientList *pEventClients;
138 } SyncAlarm;
139
140 typedef struct {
141     ClientPtr   client;
142     CARD32      delete_id;
143     int         num_waitconditions;
144 } SyncAwaitHeader;
145
146 typedef struct {
147     SyncTrigger trigger;
148     CARD64      event_threshold;
149     SyncAwaitHeader *pHeader;
150 } SyncAwait;
151
152 typedef union {
153     SyncAwaitHeader header;
154     SyncAwait       await;
155 } SyncAwaitUnion;
156
157
158 extern pointer SyncCreateSystemCounter(
159     char *      /* name */,
160     CARD64      /* inital_value */,
161     CARD64      /* resolution */,
162     SyncCounterType /* change characterization */,
163     void        (* /*QueryValue*/ ) (
164         pointer /* pCounter */,
165         CARD64 * /* pValue_return */), /* XXX prototype */
166     void        (* /*BracketValues*/) (
167         pointer /* pCounter */, 
168         CARD64 * /* pbracket_less */,
169         CARD64 * /* pbracket_greater */)
170 );
171
172 extern void SyncChangeCounter(
173     SyncCounter *       /* pCounter*/,
174     CARD64              /* new_value */
175 );
176
177 extern void SyncDestroySystemCounter(
178     pointer pCounter
179 );
180 extern void InitServertime(void);
181
182 #endif /* _SYNC_SERVER */
183
184 #endif /* _SYNCSTR_H_ */