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 _SYNCSTR_H_
     52 #define _SYNCSTR_H_
     53 
     54 #include <X11/extensions/syncproto.h>
     55 
     56 #ifdef _SYNC_SERVER
     57 
     58 #define CARD64 XSyncValue /* XXX temporary! need real 64 bit values for Alpha */
     59 
     60 typedef struct _SyncCounter {
     61     ClientPtr		client;	/* Owning client. 0 for system counters */
     62     XSyncCounter	id;		/* resource ID */
     63     CARD64		value;		/* counter value */
     64     struct _SyncTriggerList *pTriglist;	/* list of triggers */
     65     Bool		beingDestroyed; /* in process of going away */
     66     struct _SysCounterInfo *pSysCounterInfo; /* NULL if not a system counter */
     67 } SyncCounter;
     68 
     69 /*
     70  * The System Counter interface
     71  */
     72 
     73 typedef enum {
     74     XSyncCounterNeverChanges,
     75     XSyncCounterNeverIncreases,
     76     XSyncCounterNeverDecreases,
     77     XSyncCounterUnrestricted
     78 } SyncCounterType;
     79 
     80 typedef struct _SysCounterInfo {
     81     char	*name;
     82     CARD64	resolution;
     83     CARD64	bracket_greater;
     84     CARD64	bracket_less;
     85     SyncCounterType counterType;  /* how can this counter change */
     86     void        (*QueryValue)(
     87 			      pointer /*pCounter*/,
     88 			      CARD64 * /*freshvalue*/
     89 );
     90     void	(*BracketValues)(
     91 				 pointer /*pCounter*/,
     92 				 CARD64 * /*lessthan*/,
     93 				 CARD64 * /*greaterthan*/
     94 );
     95 } SysCounterInfo;
     96 
     97 
     98 
     99 typedef struct _SyncTrigger {
    100     SyncCounter *pCounter;
    101     CARD64	wait_value;	/* wait value */
    102     unsigned int value_type;     /* Absolute or Relative */
    103     unsigned int test_type;	/* transition or Comparision type */
    104     CARD64	test_value;	/* trigger event threshold value */
    105     Bool	(*CheckTrigger)(
    106 				struct _SyncTrigger * /*pTrigger*/,
    107 				CARD64 /*newval*/
    108 				);
    109     void	(*TriggerFired)(
    110 				struct _SyncTrigger * /*pTrigger*/
    111 				);
    112     void	(*CounterDestroyed)(
    113 				struct _SyncTrigger * /*pTrigger*/
    114 				    );
    115 } SyncTrigger;
    116 
    117 typedef struct _SyncTriggerList {
    118     SyncTrigger *pTrigger;
    119     struct _SyncTriggerList *next;
    120 } SyncTriggerList;
    121 
    122 typedef struct _SyncAlarmClientList {
    123     ClientPtr	client;
    124     XID		delete_id;
    125     struct _SyncAlarmClientList *next;
    126 } SyncAlarmClientList;
    127 
    128 typedef struct _SyncAlarm {
    129     SyncTrigger trigger;
    130     ClientPtr	client;
    131     XSyncAlarm 	alarm_id;
    132     CARD64	delta;
    133     int		events;
    134     int		state;
    135     SyncAlarmClientList *pEventClients;
    136 } SyncAlarm;
    137 
    138 typedef struct {
    139     ClientPtr	client;
    140     CARD32 	delete_id;
    141     int		num_waitconditions;
    142 } SyncAwaitHeader;
    143 
    144 typedef struct {
    145     SyncTrigger trigger;
    146     CARD64	event_threshold;
    147     SyncAwaitHeader *pHeader;
    148 } SyncAwait;
    149 
    150 typedef union {
    151     SyncAwaitHeader header;
    152     SyncAwait	    await;
    153 } SyncAwaitUnion;
    154 
    155 
    156 extern pointer SyncCreateSystemCounter(
    157     char *	/* name */,
    158     CARD64  	/* inital_value */,
    159     CARD64  	/* resolution */,
    160     SyncCounterType /* change characterization */,
    161     void        (* /*QueryValue*/ ) (
    162         pointer /* pCounter */,
    163         CARD64 * /* pValue_return */), /* XXX prototype */
    164     void        (* /*BracketValues*/) (
    165         pointer /* pCounter */,
    166         CARD64 * /* pbracket_less */,
    167         CARD64 * /* pbracket_greater */)
    168 );
    169 
    170 extern void SyncChangeCounter(
    171     SyncCounter *	/* pCounter*/,
    172     CARD64  		/* new_value */
    173 );
    174 
    175 extern void SyncDestroySystemCounter(
    176     pointer pCounter
    177 );
    178 extern void InitServertime(void);
    179 
    180 #endif /* _SYNC_SERVER */
    181 
    182 #endif /* _SYNCSTR_H_ */
    183