Debian Codegraph @

nx-X11/include/extensions/syncstr.h

raw
1 /*
2
3 Copyright 1991, 1993, 1994, 1998 The Open Group
4
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
9 documentation.
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21 Except as contained in this notice, the name of The Open Group shall not be
22 used in advertising or otherwise to promote the sale, use or other dealings
23 in this Software without prior written authorization from The Open Group.
24
25 */
26
27 /***********************************************************
28 Copyright 1991,1993 by Digital Equipment Corporation, Maynard, Massachusetts,
29 and Olivetti Research Limited, Cambridge, England.
30
31 All Rights Reserved
32
33 Permission to use, copy, modify, and distribute this software and its
34 documentation for any purpose and without fee is hereby granted,
35 provided that the above copyright notice appear in all copies and that
36 both that copyright notice and this permission notice appear in
37 supporting documentation, and that the names of Digital or Olivetti
38 not be used in advertising or publicity pertaining to distribution of the
39 software without specific, written prior permission.
40
41 DIGITAL AND OLIVETTI DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
42 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
43 FITNESS, IN NO EVENT SHALL THEY BE LIABLE FOR ANY SPECIAL, INDIRECT OR
44 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
45 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
46 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
47 PERFORMANCE OF THIS SOFTWARE.
48
49 ******************************************************************/
50
51 #ifndef _SYNCSTR_H_
52 #define _SYNCSTR_H_
53
54 #include "sync.h"
55
56 #ifndef _SYNC_OS
57
58 /* cover up types from sync.h to make sure they're the right size for
59 * protocol packaging. These will be undef'ed after all the protocol
60 * structures are defined.
61 */
62 #define XSyncCounter CARD32
63 #define XSyncAlarm CARD32
64
65 /*
66 * Initialize
67 */
68 typedef struct _xSyncInitialize {
69 CARD8 reqType;
70 CARD8 syncReqType;
71 CARD16 length B16;
72 CARD8 majorVersion;
73 CARD8 minorVersion;
74 CARD16 pad B16;
75 } xSyncInitializeReq;
76 #define sz_xSyncInitializeReq 8
77
78 typedef struct {
79 BYTE type;
80 CARD8 unused;
81 CARD16 sequenceNumber B16;
82 CARD32 length B32;
83 CARD8 majorVersion;
84 CARD8 minorVersion;
85 CARD16 pad B16;
86 CARD32 pad0 B32;
87 CARD32 pad1 B32;
88 CARD32 pad2 B32;
89 CARD32 pad3 B32;
90 CARD32 pad4 B32;
91 } xSyncInitializeReply;
92 #define sz_xSyncInitializeReply 32
93
94 /*
95 * ListSystemCounters
96 */
97 typedef struct _xSyncListSystemCounters
98 {
99 CARD8 reqType;
100 CARD8 syncReqType;
101 CARD16 length B16;
102 } xSyncListSystemCountersReq;
103 #define sz_xSyncListSystemCountersReq 4
104
105 typedef struct {
106 BYTE type;
107 CARD8 unused;
108 CARD16 sequenceNumber B16;
109 CARD32 length B32;
110 INT32 nCounters B32;
111 CARD32 pad0 B32;
112 CARD32 pad1 B32;
113 CARD32 pad2 B32;
114 CARD32 pad3 B32;
115 CARD32 pad4 B32;
116 } xSyncListSystemCountersReply;
117 #define sz_xSyncListSystemCountersReply 32
118
119 typedef struct {
120 XSyncCounter counter B32;
121 INT32 resolution_hi B32;
122 CARD32 resolution_lo B32;
123 CARD16 name_length B16;
124 } xSyncSystemCounter;
125 #define sz_xSyncSystemCounter 14
126
127 /*
128 * Create Counter
129 */
130 typedef struct _xSyncCreateCounterReq {
131 CARD8 reqType;
132 CARD8 syncReqType;
133 CARD16 length B16;
134 XSyncCounter cid B32;
135 INT32 initial_value_hi B32;
136 CARD32 initial_value_lo B32;
137 } xSyncCreateCounterReq;
138 #define sz_xSyncCreateCounterReq 16
139
140 /*
141 * Change Counter
142 */
143 typedef struct _xSyncChangeCounterReq {
144 CARD8 reqType;
145 CARD8 syncReqType;
146 CARD16 length B16;
147 XSyncCounter cid B32;
148 INT32 value_hi B32;
149 CARD32 value_lo B32;
150 } xSyncChangeCounterReq;
151 #define sz_xSyncChangeCounterReq 16
152
153 /*
154 * Set Counter
155 */
156 typedef struct _xSyncSetCounterReq {
157 CARD8 reqType;
158 CARD8 syncReqType;
159 CARD16 length B16;
160 XSyncCounter cid B32;
161 INT32 value_hi B32;
162 CARD32 value_lo B32;
163 } xSyncSetCounterReq;
164 #define sz_xSyncSetCounterReq 16
165
166 /*
167 * Destroy Counter
168 */
169 typedef struct _xSyncDestroyCounterReq {
170 CARD8 reqType;
171 CARD8 syncReqType;
172 CARD16 length B16;
173 XSyncCounter counter B32;
174 } xSyncDestroyCounterReq;
175 #define sz_xSyncDestroyCounterReq 8
176
177 /*
178 * Query Counter
179 */
180 typedef struct _xSyncQueryCounterReq {
181 CARD8 reqType;
182 CARD8 syncReqType;
183 CARD16 length B16;
184 XSyncCounter counter B32;
185 } xSyncQueryCounterReq;
186 #define sz_xSyncQueryCounterReq 8
187
188
189 typedef struct {
190 BYTE type;
191 CARD8 unused;
192 CARD16 sequenceNumber B16;
193 CARD32 length B32;
194 INT32 value_hi B32;
195 CARD32 value_lo B32;
196 CARD32 pad0 B32;
197 CARD32 pad1 B32;
198 CARD32 pad2 B32;
199 CARD32 pad3 B32;
200 } xSyncQueryCounterReply;
201 #define sz_xSyncQueryCounterReply 32
202
203 /*
204 * Await
205 */
206 typedef struct _xSyncAwaitReq {
207 CARD8 reqType;
208 CARD8 syncReqType;
209 CARD16 length B16;
210 } xSyncAwaitReq;
211 #define sz_xSyncAwaitReq 4
212
213 typedef struct _xSyncWaitCondition {
214 XSyncCounter counter B32;
215 CARD32 value_type B32;
216 INT32 wait_value_hi B32;
217 CARD32 wait_value_lo B32;
218 CARD32 test_type B32;
219 INT32 event_threshold_hi B32;
220 CARD32 event_threshold_lo B32;
221 } xSyncWaitCondition;
222 #define sz_xSyncWaitCondition 28
223
224 /*
225 * Create Alarm
226 */
227 typedef struct _xSyncCreateAlarmReq {
228 CARD8 reqType;
229 CARD8 syncReqType;
230 CARD16 length B16;
231 XSyncAlarm id B32;
232 CARD32 valueMask B32;
233 } xSyncCreateAlarmReq;
234 #define sz_xSyncCreateAlarmReq 12
235
236 /*
237 * Destroy Alarm
238 */
239 typedef struct _xSyncDestroyAlarmReq {
240 CARD8 reqType;
241 CARD8 syncReqType;
242 CARD16 length B16;
243 XSyncAlarm alarm B32;
244 } xSyncDestroyAlarmReq;
245 #define sz_xSyncDestroyAlarmReq 8
246
247 /*
248 * Query Alarm
249 */
250 typedef struct _xSyncQueryAlarmReq {
251 CARD8 reqType;
252 CARD8 syncReqType;
253 CARD16 length B16;
254 XSyncAlarm alarm B32;
255 } xSyncQueryAlarmReq;
256 #define sz_xSyncQueryAlarmReq 8
257
258 typedef struct {
259 BYTE type;
260 CARD8 unused;
261 CARD16 sequenceNumber B16;
262 CARD32 length B32;
263 XSyncCounter counter B32;
264 CARD32 value_type B32;
265 INT32 wait_value_hi B32;
266 CARD32 wait_value_lo B32;
267 CARD32 test_type B32;
268 INT32 delta_hi B32;
269 CARD32 delta_lo B32;
270 BOOL events;
271 BYTE state;
272 BYTE pad0;
273 BYTE pad1;
274 } xSyncQueryAlarmReply;
275 #define sz_xSyncQueryAlarmReply 40
276
277 /*
278 * Change Alarm
279 */
280 typedef struct _xSyncChangeAlarmReq {
281 CARD8 reqType;
282 CARD8 syncReqType;
283 CARD16 length B16;
284 XSyncAlarm alarm B32;
285 CARD32 valueMask B32;
286 } xSyncChangeAlarmReq;
287 #define sz_xSyncChangeAlarmReq 12
288
289 /*
290 * SetPriority
291 */
292 typedef struct _xSyncSetPriority{
293 CARD8 reqType;
294 CARD8 syncReqType;
295 CARD16 length B16;
296 CARD32 id B32;
297 INT32 priority B32;
298 } xSyncSetPriorityReq;
299 #define sz_xSyncSetPriorityReq 12
300
301 /*
302 * Get Priority
303 */
304 typedef struct _xSyncGetPriority{
305 CARD8 reqType;
306 CARD8 syncReqType;
307 CARD16 length B16;
308 CARD32 id B32; /*XXX XID? */
309 } xSyncGetPriorityReq;
310 #define sz_xSyncGetPriorityReq 8
311
312 typedef struct {
313 BYTE type;
314 CARD8 unused;
315 CARD16 sequenceNumber B16;
316 CARD32 length B32;
317 INT32 priority B32;
318 CARD32 pad0 B32;
319 CARD32 pad1 B32;
320 CARD32 pad2 B32;
321 CARD32 pad3 B32;
322 CARD32 pad4 B32;
323 } xSyncGetPriorityReply;
324 #define sz_xSyncGetPriorityReply 32
325
326 /*
327 * Events
328 */
329
330 typedef struct _xSyncCounterNotifyEvent {
331 BYTE type;
332 BYTE kind;
333 CARD16 sequenceNumber B16;
334 XSyncCounter counter B32;
335 INT32 wait_value_hi B32;
336 CARD32 wait_value_lo B32;
337 INT32 counter_value_hi B32;
338 CARD32 counter_value_lo B32;
339 CARD32 time B32;
340 CARD16 count B16;
341 BOOL destroyed;
342 BYTE pad0;
343 } xSyncCounterNotifyEvent;
344
345 typedef struct _xSyncAlarmNotifyEvent {
346 BYTE type;
347 BYTE kind;
348 CARD16 sequenceNumber B16;
349 XSyncAlarm alarm B32;
350 INT32 counter_value_hi B32;
351 CARD32 counter_value_lo B32;
352 INT32 alarm_value_hi B32;
353 CARD32 alarm_value_lo B32;
354 CARD32 time B32;
355 CARD8 state;
356 BYTE pad0;
357 BYTE pad1;
358 BYTE pad2;
359 } xSyncAlarmNotifyEvent;
360
361 #undef XSyncCounter
362 #undef XSyncAlarm
363
364 #endif /* _SYNC_OS */
365
366 #ifdef _SYNC_SERVER
367
368 #define CARD64 XSyncValue /* XXX temporary! need real 64 bit values for Alpha */
369
370 typedef struct _SyncCounter {
371 ClientPtr client; /* Owning client. 0 for system counters */
372 XSyncCounter id; /* resource ID */
373 CARD64 value; /* counter value */
374 struct _SyncTriggerList *pTriglist; /* list of triggers */
375 Bool beingDestroyed; /* in process of going away */
376 struct _SysCounterInfo *pSysCounterInfo; /* NULL if not a system counter */
377 } SyncCounter;
378
379 /*
380 * The System Counter interface
381 */
382
383 typedef enum {
384 XSyncCounterNeverChanges,
385 XSyncCounterNeverIncreases,
386 XSyncCounterNeverDecreases,
387 XSyncCounterUnrestricted
388 } SyncCounterType;
389
390 typedef struct _SysCounterInfo {
391 char *name;
392 CARD64 resolution;
393 CARD64 bracket_greater;
394 CARD64 bracket_less;
395 SyncCounterType counterType; /* how can this counter change */
396 void (*QueryValue)(
397 void * /*pCounter*/,
398 CARD64 * /*freshvalue*/
399 );
400 void (*BracketValues)(
401 void * /*pCounter*/,
402 CARD64 * /*lessthan*/,
403 CARD64 * /*greaterthan*/
404 );
405 } SysCounterInfo;
406
407
408
409 typedef struct _SyncTrigger {
410 SyncCounter *pCounter;
411 CARD64 wait_value; /* wait value */
412 unsigned int value_type; /* Absolute or Relative */
413 unsigned int test_type; /* transition or Comparision type */
414 CARD64 test_value; /* trigger event threshold value */
415 Bool (*CheckTrigger)(
416 struct _SyncTrigger * /*pTrigger*/,
417 CARD64 /*newval*/
418 );
419 void (*TriggerFired)(
420 struct _SyncTrigger * /*pTrigger*/
421 );
422 void (*CounterDestroyed)(
423 struct _SyncTrigger * /*pTrigger*/
424 );
425 } SyncTrigger;
426
427 typedef struct _SyncTriggerList {
428 SyncTrigger *pTrigger;
429 struct _SyncTriggerList *next;
430 } SyncTriggerList;
431
432 typedef struct _SyncAlarmClientList {
433 ClientPtr client;
434 XID delete_id;
435 struct _SyncAlarmClientList *next;
436 } SyncAlarmClientList;
437
438 typedef struct _SyncAlarm {
439 SyncTrigger trigger;
440 ClientPtr client;
441 XSyncAlarm alarm_id;
442 CARD64 delta;
443 int events;
444 int state;
445 SyncAlarmClientList *pEventClients;
446 } SyncAlarm;
447
448 typedef struct {
449 ClientPtr client;
450 CARD32 delete_id;
451 int num_waitconditions;
452 } SyncAwaitHeader;
453
454 typedef struct {
455 SyncTrigger trigger;
456 CARD64 event_threshold;
457 SyncAwaitHeader *pHeader;
458 } SyncAwait;
459
460 typedef union {
461 SyncAwaitHeader header;
462 SyncAwait await;
463 } SyncAwaitUnion;
464
465
466 extern void * SyncCreateSystemCounter(
467 char * /* name */,
468 CARD64 /* inital_value */,
469 CARD64 /* resolution */,
470 SyncCounterType /* change characterization */,
471 void (* /*QueryValue*/ ) (
472 void * /* pCounter */,
473 CARD64 * /* pValue_return */), /* XXX prototype */
474 void (* /*BracketValues*/) (
475 void * /* pCounter */,
476 CARD64 * /* pbracket_less */,
477 CARD64 * /* pbracket_greater */)
478 );
479
480 extern void SyncChangeCounter(
481 SyncCounter * /* pCounter*/,
482 CARD64 /* new_value */
483 );
484
485 extern void SyncDestroySystemCounter(
486 void * pCounter
487 );
488 extern void InitServertime(void);
489
490 #endif /* _SYNC_SERVER */
491
492 #endif /* _SYNCSTR_H_ */