Git init
[framework/uifw/xorg/proto/x11proto-xext.git] / syncconst.h
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 _SYNCCONST_H_
52 #define _SYNCCONST_H_
53
54 #define SYNC_NAME "SYNC"
55
56 #define SYNC_MAJOR_VERSION      3
57 #define SYNC_MINOR_VERSION      1
58
59
60 #define XSyncCounterNotify              0
61 #define XSyncAlarmNotify                1
62 #define XSyncAlarmNotifyMask            (1L << XSyncAlarmNotify)
63
64 #define XSyncNumberEvents               2L
65
66 #define XSyncBadCounter                 0L
67 #define XSyncBadAlarm                   1L
68 #define XSyncBadFence           2L
69 #define XSyncNumberErrors               (XSyncBadFence + 1)
70
71 /*
72  * Flags for Alarm Attributes
73  */
74 #define XSyncCACounter                  (1L<<0)
75 #define XSyncCAValueType                (1L<<1)
76 #define XSyncCAValue                    (1L<<2)
77 #define XSyncCATestType                 (1L<<3)
78 #define XSyncCADelta                    (1L<<4)
79 #define XSyncCAEvents                   (1L<<5)
80
81 /*  The _XSync macros below are for library internal use only.  They exist
82  *  so that if we have to make a fix, we can change it in this one place
83  *  and have both the macro and function variants inherit the fix.
84  */
85
86 #define _XSyncIntToValue(pv, i)     ((pv)->hi=((i<0)?~0:0),(pv)->lo=(i))
87 #define _XSyncIntsToValue(pv, l, h) ((pv)->lo = (l), (pv)->hi = (h))
88 #define _XSyncValueGreaterThan(a, b)\
89     ((a).hi>(b).hi || ((a).hi==(b).hi && (a).lo>(b).lo))
90 #define _XSyncValueLessThan(a, b)\
91     ((a).hi<(b).hi || ((a).hi==(b).hi && (a).lo<(b).lo))
92 #define _XSyncValueGreaterOrEqual(a, b)\
93     ((a).hi>(b).hi || ((a).hi==(b).hi && (a).lo>=(b).lo))
94 #define _XSyncValueLessOrEqual(a, b)\
95     ((a).hi<(b).hi || ((a).hi==(b).hi && (a).lo<=(b).lo))
96 #define _XSyncValueEqual(a, b)  ((a).lo==(b).lo && (a).hi==(b).hi)
97 #define _XSyncValueIsNegative(v) (((v).hi & 0x80000000) ? 1 : 0)
98 #define _XSyncValueIsZero(a)    ((a).lo==0 && (a).hi==0)
99 #define _XSyncValueIsPositive(v) (((v).hi & 0x80000000) ? 0 : 1)
100 #define _XSyncValueLow32(v)     ((v).lo)
101 #define _XSyncValueHigh32(v)    ((v).hi)
102 #define _XSyncValueAdd(presult,a,b,poverflow) {\
103         int t = (a).lo;\
104         Bool signa = XSyncValueIsNegative(a);\
105         Bool signb = XSyncValueIsNegative(b);\
106         ((presult)->lo = (a).lo + (b).lo);\
107         ((presult)->hi = (a).hi + (b).hi);\
108         if (t>(presult)->lo) (presult)->hi++;\
109         *poverflow = ((signa == signb) && !(signa == XSyncValueIsNegative(*presult)));\
110      }
111 #define _XSyncValueSubtract(presult,a,b,poverflow) {\
112         int t = (a).lo;\
113         Bool signa = XSyncValueIsNegative(a);\
114         Bool signb = XSyncValueIsNegative(b);\
115         ((presult)->lo = (a).lo - (b).lo);\
116         ((presult)->hi = (a).hi - (b).hi);\
117         if (t<(presult)->lo) (presult)->hi--;\
118         *poverflow = ((signa == signb) && !(signa == XSyncValueIsNegative(*presult)));\
119      }
120 #define _XSyncMaxValue(pv) ((pv)->hi = 0x7fffffff, (pv)->lo = 0xffffffff)
121 #define _XSyncMinValue(pv) ((pv)->hi = 0x80000000, (pv)->lo = 0)
122
123 /*
124  *  These are the publically usable macros.  If you want the function version
125  *  of one of these, just #undef the macro to uncover the function.
126  *  (This is the same convention that the ANSI C library uses.)
127  */
128
129 #define XSyncIntToValue(pv, i) _XSyncIntToValue(pv, i)
130 #define XSyncIntsToValue(pv, l, h) _XSyncIntsToValue(pv, l, h)
131 #define XSyncValueGreaterThan(a, b) _XSyncValueGreaterThan(a, b)
132 #define XSyncValueLessThan(a, b) _XSyncValueLessThan(a, b)
133 #define XSyncValueGreaterOrEqual(a, b) _XSyncValueGreaterOrEqual(a, b)
134 #define XSyncValueLessOrEqual(a, b) _XSyncValueLessOrEqual(a, b)
135 #define XSyncValueEqual(a, b) _XSyncValueEqual(a, b)
136 #define XSyncValueIsNegative(v) _XSyncValueIsNegative(v)
137 #define XSyncValueIsZero(a) _XSyncValueIsZero(a)
138 #define XSyncValueIsPositive(v) _XSyncValueIsPositive(v)
139 #define XSyncValueLow32(v) _XSyncValueLow32(v)
140 #define XSyncValueHigh32(v) _XSyncValueHigh32(v)
141 #define XSyncValueAdd(presult,a,b,poverflow) _XSyncValueAdd(presult,a,b,poverflow)
142 #define XSyncValueSubtract(presult,a,b,poverflow) _XSyncValueSubtract(presult,a,b,poverflow)
143 #define XSyncMaxValue(pv) _XSyncMaxValue(pv)
144 #define XSyncMinValue(pv) _XSyncMinValue(pv)
145
146 /*
147  * Constants for the value_type argument of various requests
148  */
149 typedef enum {
150     XSyncAbsolute,
151     XSyncRelative
152 } XSyncValueType;
153
154 /*
155  * Alarm Test types
156  */
157 typedef enum {
158     XSyncPositiveTransition,
159     XSyncNegativeTransition,
160     XSyncPositiveComparison,
161     XSyncNegativeComparison
162 } XSyncTestType;
163
164 /*
165  * Alarm state constants
166  */
167 typedef enum {
168     XSyncAlarmActive,
169     XSyncAlarmInactive,
170     XSyncAlarmDestroyed
171 } XSyncAlarmState;
172
173
174 typedef XID XSyncCounter;
175 typedef XID XSyncAlarm;
176 typedef XID XSyncFence;
177 typedef struct _XSyncValue {
178     int hi;
179     unsigned int lo;
180 } XSyncValue;
181 #endif /* _SYNCCONST_H_ */