#ifndef _X_locking_H_
#define _X_locking_H_
#define xmalloc(s) Xmalloc(s)
#define xfree(s) Xfree(s)
#include <X11/Xthreads.h>
struct _XCVList {
xcondition_t cv;
xReply *buf;
struct _XCVList *next;
};
extern xthread_t (*_Xthread_self_fn)(
void
);
struct _XLockInfo {
xmutex_t mutex;
int reply_bytes_left;
Bool reply_was_read;
struct _XCVList *reply_awaiters;
struct _XCVList **reply_awaiters_tail;
struct _XCVList *event_awaiters;
struct _XCVList **event_awaiters_tail;
Bool reply_first;
int locking_level;
xthread_t locking_thread;
xcondition_t cv;
xthread_t reading_thread;
xthread_t conni_thread;
xcondition_t writers;
int num_free_cvls;
struct _XCVList *free_cvls;
void (*pop_reader)(
Display* ,
struct _XCVList** ,
struct _XCVList***
);
struct _XCVList *(*push_reader)(
Display * ,
struct _XCVList***
);
void (*condition_wait)(
xcondition_t ,
xmutex_t
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
, char* ,
int
#endif
);
void (*internal_lock_display)(
Display* ,
Bool
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
, char* ,
int
#endif
);
void (*condition_signal)(
xcondition_t
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
, char* ,
int
#endif
);
void (*condition_broadcast)(
xcondition_t
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
, char* ,
int
#endif
);
void (*lock_wait)(
Display*
);
void (*user_lock_display)(
Display*
);
void (*user_unlock_display)(
Display*
);
struct _XCVList *(*create_cvl)(
Display *
);
};
#define UnlockNextEventReader(d) if ((d)->lock) \
(*(d)->lock->pop_reader)((d),&(d)->lock->event_awaiters,&(d)->lock->event_awaiters_tail)
#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
#define ConditionWait(d,c) if ((d)->lock) \
(*(d)->lock->condition_wait)(c, (d)->lock->mutex,__FILE__,__LINE__)
#define ConditionSignal(d,c) if ((d)->lock) \
(*(d)->lock->condition_signal)(c,__FILE__,__LINE__)
#define ConditionBroadcast(d,c) if ((d)->lock) \
(*(d)->lock->condition_broadcast)(c,__FILE__,__LINE__)
#else
#define ConditionWait(d,c) if ((d)->lock) \
(*(d)->lock->condition_wait)(c, (d)->lock->mutex)
#define ConditionSignal(d,c) if ((d)->lock) \
(*(d)->lock->condition_signal)(c)
#define ConditionBroadcast(d,c) if ((d)->lock) \
(*(d)->lock->condition_broadcast)(c)
#endif
typedef struct _LockInfoRec {
xmutex_t lock;
} LockInfoRec;
extern int (*_XInitDisplayLock_fn)(Display *dpy);
extern void (*_XFreeDisplayLock_fn)(Display *dpy);
#endif