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