Home | History | Annotate | Download | only in extensions
      1 /* $Xorg: sync.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/sync.h,v 1.4 2001/12/20 19:40:59 tsi Exp $ */
     52 
     53 #ifndef _SYNC_H_
     54 #define _SYNC_H_
     55 
     56 #include <X11/Xfuncproto.h>
     57 #include <X11/extensions/syncconst.h>
     58 
     59 _XFUNCPROTOBEGIN
     60 /* get rid of macros so we can define corresponding functions */
     61 #undef XSyncIntToValue
     62 #undef XSyncIntsToValue
     63 #undef XSyncValueGreaterThan
     64 #undef XSyncValueLessThan
     65 #undef XSyncValueGreaterOrEqual
     66 #undef XSyncValueLessOrEqual
     67 #undef XSyncValueEqual
     68 #undef XSyncValueIsNegative
     69 #undef XSyncValueIsZero
     70 #undef XSyncValueIsPositive
     71 #undef XSyncValueLow32
     72 #undef XSyncValueHigh32
     73 #undef XSyncValueAdd
     74 #undef XSyncValueSubtract
     75 #undef XSyncMaxValue
     76 #undef XSyncMinValue
     77 
     78 extern void XSyncIntToValue(
     79     XSyncValue* /*pv*/,
     80     int /*i*/
     81 );
     82 
     83 extern void XSyncIntsToValue(
     84     XSyncValue* /*pv*/,
     85     unsigned int /*l*/,
     86     int /*h*/
     87 );
     88 
     89 extern Bool XSyncValueGreaterThan(
     90     XSyncValue /*a*/,
     91     XSyncValue /*b*/
     92 );
     93 
     94 extern Bool XSyncValueLessThan(
     95     XSyncValue /*a*/,
     96     XSyncValue /*b*/
     97 );
     98 
     99 extern Bool XSyncValueGreaterOrEqual(
    100     XSyncValue /*a*/,
    101     XSyncValue /*b*/
    102 );
    103 
    104 extern Bool XSyncValueLessOrEqual(
    105     XSyncValue /*a*/,
    106     XSyncValue /*b*/
    107 );
    108 
    109 extern Bool XSyncValueEqual(
    110     XSyncValue /*a*/,
    111     XSyncValue /*b*/
    112 );
    113 
    114 extern Bool XSyncValueIsNegative(
    115     XSyncValue /*v*/
    116 );
    117 
    118 extern Bool XSyncValueIsZero(
    119     XSyncValue /*a*/
    120 );
    121 
    122 extern Bool XSyncValueIsPositive(
    123     XSyncValue /*v*/
    124 );
    125 
    126 extern unsigned int XSyncValueLow32(
    127     XSyncValue /*v*/
    128 );
    129 
    130 extern int XSyncValueHigh32(
    131     XSyncValue /*v*/
    132 );
    133 
    134 extern void XSyncValueAdd(
    135     XSyncValue* /*presult*/,
    136     XSyncValue /*a*/,
    137     XSyncValue /*b*/,
    138     int* /*poverflow*/
    139 );
    140 
    141 extern void XSyncValueSubtract(
    142     XSyncValue* /*presult*/,
    143     XSyncValue /*a*/,
    144     XSyncValue /*b*/,
    145     int* /*poverflow*/
    146 );
    147 
    148 extern void XSyncMaxValue(
    149     XSyncValue* /*pv*/
    150 );
    151 
    152 extern void XSyncMinValue(
    153     XSyncValue* /*pv*/
    154 );
    155 
    156 _XFUNCPROTOEND
    157 
    158 
    159 typedef struct _XSyncSystemCounter {
    160     char *name;			/* null-terminated name of system counter */
    161     XSyncCounter counter;	/* counter id of this system counter */
    162     XSyncValue resolution;	/* resolution of this system counter */
    163 } XSyncSystemCounter;
    164 
    165 
    166 typedef struct {
    167     XSyncCounter counter;	/* counter to trigger on */
    168     XSyncValueType value_type;	/* absolute/relative */
    169     XSyncValue wait_value;	/* value to compare counter to */
    170     XSyncTestType test_type;	/* pos/neg comparison/transtion */
    171 } XSyncTrigger;
    172 
    173 typedef struct {
    174     XSyncTrigger trigger;	/* trigger for await */
    175     XSyncValue event_threshold; /* send event if past threshold */
    176 } XSyncWaitCondition;
    177 
    178 
    179 typedef struct {
    180     XSyncTrigger trigger;
    181     XSyncValue  delta;
    182     Bool events;
    183     XSyncAlarmState state;
    184 } XSyncAlarmAttributes;
    185 
    186 /*
    187  *  Events
    188  */
    189 
    190 typedef struct {
    191     int type;			/* event base + XSyncCounterNotify */
    192     unsigned long serial;	/* # of last request processed by server */
    193     Bool send_event;		/* true if this came from a SendEvent request */
    194     Display *display;		/* Display the event was read from */
    195     XSyncCounter counter;	/* counter involved in await */
    196     XSyncValue wait_value;	/* value being waited for */
    197     XSyncValue counter_value;	/* counter value when this event was sent */
    198     Time time;			/* milliseconds */
    199     int count;			/* how many more events to come */
    200     Bool destroyed;		/* True if counter was destroyed */
    201 } XSyncCounterNotifyEvent;
    202 
    203 typedef struct {
    204     int type;			/* event base + XSyncCounterNotify */
    205     unsigned long serial;	/* # of last request processed by server */
    206     Bool send_event;		/* true if this came from a SendEvent request */
    207     Display *display;		/* Display the event was read from */
    208     XSyncAlarm alarm;		/* alarm that triggered */
    209     XSyncValue counter_value;	/* value that triggered the alarm */
    210     XSyncValue alarm_value;	/* test  value of trigger in alarm */
    211     Time time;			/* milliseconds */
    212     XSyncAlarmState state;	/* new state of alarm */
    213 } XSyncAlarmNotifyEvent;
    214 
    215 /*
    216  *  Errors
    217  */
    218 
    219 typedef struct {
    220     int type;
    221     Display *display;		/* Display the event was read from */
    222     XSyncAlarm alarm;		/* resource id */
    223     unsigned long serial;	/* serial number of failed request */
    224     unsigned char error_code;	/* error base + XSyncBadAlarm */
    225     unsigned char request_code;	/* Major op-code of failed request */
    226     unsigned char minor_code;	/* Minor op-code of failed request */
    227 } XSyncAlarmError;
    228 
    229 typedef struct {
    230     int type;
    231     Display *display;		/* Display the event was read from */
    232     XSyncCounter counter;	/* resource id */
    233     unsigned long serial;	/* serial number of failed request */
    234     unsigned char error_code;	/* error base + XSyncBadCounter */
    235     unsigned char request_code;	/* Major op-code of failed request */
    236     unsigned char minor_code;	/* Minor op-code of failed request */
    237 } XSyncCounterError;
    238 
    239 /*
    240  *  Prototypes
    241  */
    242 
    243 _XFUNCPROTOBEGIN
    244 
    245 extern Status XSyncQueryExtension(
    246     Display* /*dpy*/,
    247     int* /*event_base_return*/,
    248     int* /*error_base_return*/
    249 );
    250 
    251 extern Status XSyncInitialize(
    252     Display* /*dpy*/,
    253     int* /*major_version_return*/,
    254     int* /*minor_version_return*/
    255 );
    256 
    257 extern XSyncSystemCounter *XSyncListSystemCounters(
    258     Display* /*dpy*/,
    259     int* /*n_counters_return*/
    260 );
    261 
    262 extern void XSyncFreeSystemCounterList(
    263     XSyncSystemCounter* /*list*/
    264 );
    265 
    266 extern XSyncCounter XSyncCreateCounter(
    267     Display* /*dpy*/,
    268     XSyncValue /*initial_value*/
    269 );
    270 
    271 extern Status XSyncSetCounter(
    272     Display* /*dpy*/,
    273     XSyncCounter /*counter*/,
    274     XSyncValue /*value*/
    275 );
    276 
    277 extern Status XSyncChangeCounter(
    278     Display* /*dpy*/,
    279     XSyncCounter /*counter*/,
    280     XSyncValue /*value*/
    281 );
    282 
    283 extern Status XSyncDestroyCounter(
    284     Display* /*dpy*/,
    285     XSyncCounter /*counter*/
    286 );
    287 
    288 extern Status XSyncQueryCounter(
    289     Display* /*dpy*/,
    290     XSyncCounter /*counter*/,
    291     XSyncValue* /*value_return*/
    292 );
    293 
    294 extern Status XSyncAwait(
    295     Display* /*dpy*/,
    296     XSyncWaitCondition* /*wait_list*/,
    297     int /*n_conditions*/
    298 );
    299 
    300 extern XSyncAlarm XSyncCreateAlarm(
    301     Display* /*dpy*/,
    302     unsigned long /*values_mask*/,
    303     XSyncAlarmAttributes* /*values*/
    304 );
    305 
    306 extern Status XSyncDestroyAlarm(
    307     Display* /*dpy*/,
    308     XSyncAlarm /*alarm*/
    309 );
    310 
    311 extern Status XSyncQueryAlarm(
    312     Display* /*dpy*/,
    313     XSyncAlarm /*alarm*/,
    314     XSyncAlarmAttributes* /*values_return*/
    315 );
    316 
    317 extern Status XSyncChangeAlarm(
    318     Display* /*dpy*/,
    319     XSyncAlarm /*alarm*/,
    320     unsigned long /*values_mask*/,
    321     XSyncAlarmAttributes* /*values*/
    322 );
    323 
    324 extern Status XSyncSetPriority(
    325     Display* /*dpy*/,
    326     XID /*client_resource_id*/,
    327     int /*priority*/
    328 );
    329 
    330 extern Status XSyncGetPriority(
    331     Display* /*dpy*/,
    332     XID /*client_resource_id*/,
    333     int* /*return_priority*/
    334 );
    335 
    336 _XFUNCPROTOEND
    337 
    338 #endif /* _SYNC_H_ */
    339