aboutsummaryrefslogtreecommitdiff
path: root/libX11/src/XlibInt.c
diff options
context:
space:
mode:
Diffstat (limited to 'libX11/src/XlibInt.c')
-rw-r--r--libX11/src/XlibInt.c1540
1 files changed, 2 insertions, 1538 deletions
diff --git a/libX11/src/XlibInt.c b/libX11/src/XlibInt.c
index ce62ae36d..9ce5a43ef 100644
--- a/libX11/src/XlibInt.c
+++ b/libX11/src/XlibInt.c
@@ -42,10 +42,6 @@ from The Open Group.
#include "Xlibint.h"
#include "Xprivate.h"
#include <X11/Xpoll.h>
-#if !USE_XCB
-#include <X11/Xtrans/Xtrans.h>
-#include <X11/extensions/xcmiscstr.h>
-#endif /* !USE_XCB */
#include <assert.h>
#include <stdio.h>
#ifdef WIN32
@@ -78,24 +74,7 @@ xthread_t (*_Xthread_self_fn)(void) = NULL;
#define XThread_Self() ((*_Xthread_self_fn)())
-#if !USE_XCB
-#define UnlockNextReplyReader(d) if ((d)->lock) \
- (*(d)->lock->pop_reader)((d),&(d)->lock->reply_awaiters,&(d)->lock->reply_awaiters_tail)
-
-#define QueueReplyReaderLock(d) ((d)->lock ? \
- (*(d)->lock->push_reader)(d,&(d)->lock->reply_awaiters_tail) : NULL)
-#define QueueEventReaderLock(d) ((d)->lock ? \
- (*(d)->lock->push_reader)(d,&(d)->lock->event_awaiters_tail) : NULL)
-#endif /* !USE_XCB */
-
-#else /* XTHREADS else */
-
-#if !USE_XCB
-#define UnlockNextReplyReader(d)
-#define UnlockNextEventReader(d)
-#endif /* !USE_XCB */
-
-#endif /* XTHREADS else */
+#endif /* XTHREADS */
/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
* systems are broken and return EWOULDBLOCK when they should return EAGAIN
@@ -144,50 +123,10 @@ xthread_t (*_Xthread_self_fn)(void) = NULL;
#endif
#ifdef __UNIXOS2__
-#if !USE_XCB
-#define select(n,r,w,x,t) os2ClientSelect(n,r,w,x,t)
-#endif /* !USE_XCB */
#include <limits.h>
#define MAX_PATH _POSIX_PATH_MAX
#endif
-#if !USE_XCB
-#ifdef MUSTCOPY
-
-#define STARTITERATE(tpvar,type,start,endcond) \
- { register char *cpvar; \
- for (cpvar = (char *) (start); endcond; ) { \
- type dummy; memcpy ((char *) &dummy, cpvar, SIZEOF(type)); \
- tpvar = &dummy;
-#define ITERPTR(tpvar) cpvar
-#define RESETITERPTR(tpvar,type,start) cpvar = start
-#define INCITERPTR(tpvar,type) cpvar += SIZEOF(type)
-#define ENDITERATE }}
-
-#else
-
-#define STARTITERATE(tpvar,type,start,endcond) \
- for (tpvar = (type *) (start); endcond; )
-#define ITERPTR(tpvar) (char *)tpvar
-#define RESETITERPTR(tpvar,type,start) tpvar = (type *) (start)
-#define INCITERPTR(tpvar,type) tpvar++
-#define ENDITERATE
-
-#endif /* MUSTCOPY */
-
-typedef union {
- xReply rep;
- char buf[BUFSIZE];
-} _XAlignedBuffer;
-
-static char *_XAsyncReply(
- Display *dpy,
- register xReply *rep,
- char *buf,
- register int *lenp,
- Bool discard);
-#endif /* !USE_XCB */
-
/*
* The following routines are internal routines used by Xlib for protocol
* packet transmission and reception.
@@ -206,163 +145,6 @@ static char *_XAsyncReply(
* the object they have created.
*/
-#if !USE_XCB
-static xReq _dummy_request = {
- 0, 0, 0
-};
-
-/*
- * This is an OS dependent routine which:
- * 1) returns as soon as the connection can be written on....
- * 2) if the connection can be read, must enqueue events and handle errors,
- * until the connection is writable.
- */
-static void
-_XWaitForWritable(
- Display *dpy
-#ifdef XTHREADS
- ,
- xcondition_t cv /* our reading condition variable */
-#endif
- )
-{
-#ifdef USE_POLL
- struct pollfd filedes;
-#else
- fd_set r_mask;
- fd_set w_mask;
-#endif
- int nfound;
-
-#ifdef USE_POLL
- filedes.fd = dpy->fd;
- filedes.events = 0;
-#else
- FD_ZERO(&r_mask);
- FD_ZERO(&w_mask);
-#endif
-
- for (;;) {
-#ifdef XTHREADS
- /* We allow only one thread at a time to read, to minimize
- passing of read data between threads.
- Now, who is it? If there is a non-NULL reply_awaiters and
- we (i.e., our cv) are not at the head of it, then whoever
- is at the head is the reader, and we don't read.
- Otherwise there is no reply_awaiters or we are at the
- head, having just appended ourselves.
- In this case, if there is a event_awaiters, then whoever
- is at the head of it got there before we did, and they are the
- reader.
-
- Last cases: no event_awaiters and we are at the head of
- reply_awaiters or reply_awaiters is NULL: we are the reader,
- since there is obviously no one else involved.
-
- XXX - what if cv is NULL and someone else comes along after
- us while we are waiting?
- */
-
- if (!dpy->lock ||
- (!dpy->lock->event_awaiters &&
- (!dpy->lock->reply_awaiters ||
- dpy->lock->reply_awaiters->cv == cv)))
-#endif
-#ifdef USE_POLL
- filedes.events = POLLIN;
- filedes.events |= POLLOUT;
-#else
- FD_SET(dpy->fd, &r_mask);
- FD_SET(dpy->fd, &w_mask);
-#endif
-
- do {
- UnlockDisplay(dpy);
-#ifdef USE_POLL
- nfound = poll (&filedes, 1, -1);
-#else
- nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL);
-#endif
- InternalLockDisplay(dpy, cv != NULL);
- if (nfound < 0 && !(ECHECK(EINTR) || ETEST()))
- _XIOError(dpy);
- } while (nfound <= 0);
-
- if (
-#ifdef USE_POLL
- filedes.revents & POLLIN
-#else
- FD_ISSET(dpy->fd, &r_mask)
-#endif
- )
- {
- _XAlignedBuffer buf;
- BytesReadable_t pend;
- register int len;
- register xReply *rep;
-
- /* find out how much data can be read */
- if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
- _XIOError(dpy);
- len = pend;
-
- /* must read at least one xEvent; if none is pending, then
- we'll just block waiting for it */
- if (len < SIZEOF(xReply)
-#ifdef XTHREADS
- || dpy->async_handlers
-#endif
- )
- len = SIZEOF(xReply);
-
- /* but we won't read more than the max buffer size */
- if (len > BUFSIZE) len = BUFSIZE;
-
- /* round down to an integral number of XReps */
- len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
-
- (void) _XRead (dpy, buf.buf, (long) len);
-
- STARTITERATE(rep,xReply,buf.buf,len > 0) {
- if (rep->generic.type == X_Reply) {
- int tmp = len;
- RESETITERPTR(rep,xReply,
- _XAsyncReply (dpy, rep,
- ITERPTR(rep), &tmp, True));
- len = tmp;
- pend = len;
- } else {
- if (rep->generic.type == X_Error)
- _XError (dpy, (xError *)rep);
- else /* must be an event packet */
- _XEnq (dpy, (xEvent *)rep);
- INCITERPTR(rep,xReply);
- len -= SIZEOF(xReply);
- }
- } ENDITERATE
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->event_awaiters)
- ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
-#endif
- }
-#ifdef USE_POLL
- if (filedes.revents & (POLLOUT|POLLHUP|POLLERR))
-#else
- if (FD_ISSET(dpy->fd, &w_mask))
-#endif
- {
-#ifdef XTHREADS
- if (dpy->lock) {
- ConditionBroadcast(dpy, dpy->lock->writers);
- }
-#endif
- return;
- }
- }
-}
-#endif /* !USE_XCB */
-
-
#define POLLFD_CACHE_SIZE 5
/* initialize the struct array passed to poll() below */
@@ -418,138 +200,6 @@ void _XPollfdCacheDel(
#endif
}
-#if !USE_XCB
-/* returns True iff there is an event in the queue newer than serial_num */
-
-static Bool
-_XNewerQueuedEvent(
- Display *dpy,
- int serial_num)
-{
- _XQEvent *qev;
-
- if (dpy->next_event_serial_num == serial_num)
- return False;
-
- qev = dpy->head;
- while (qev) {
- if (qev->qserial_num >= serial_num) {
- return True;
- }
- qev = qev->next;
- }
- return False;
-}
-
-static int
-_XWaitForReadable(
- Display *dpy)
-{
- int result;
- int fd = dpy->fd;
- struct _XConnectionInfo *ilist;
- register int saved_event_serial = 0;
- int in_read_events = 0;
- register Bool did_proc_conni = False;
-#ifdef USE_POLL
- struct pollfd *filedes;
-#else
- fd_set r_mask;
- int highest_fd = fd;
-#endif
-
-#ifdef USE_POLL
- if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE
- && !(dpy->flags & XlibDisplayProcConni)) {
- /* XXX - this fallback is gross */
- int i;
-
- filedes = (struct pollfd *)Xmalloc(dpy->im_fd_length * sizeof(struct pollfd));
- filedes[0].fd = fd;
- filedes[0].events = POLLIN;
- for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
- filedes[i].fd = ilist->fd;
- filedes[i].events = POLLIN;
- }
- } else {
- filedes = (struct pollfd *)dpy->filedes;
- }
-#else
- FD_ZERO(&r_mask);
-#endif
- for (;;) {
-#ifndef USE_POLL
- FD_SET(fd, &r_mask);
- if (!(dpy->flags & XlibDisplayProcConni))
- for (ilist=dpy->im_fd_info; ilist; ilist=ilist->next) {
- FD_SET(ilist->fd, &r_mask);
- if (ilist->fd > highest_fd)
- highest_fd = ilist->fd;
- }
-#endif
- UnlockDisplay(dpy);
-#ifdef USE_POLL
- result = poll(filedes,
- (dpy->flags & XlibDisplayProcConni) ? 1 : 1+dpy->im_fd_length,
- -1);
-#else
- result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL);
-#endif
- InternalLockDisplay(dpy, dpy->flags & XlibDisplayReply);
- if (result == -1 && !(ECHECK(EINTR) || ETEST())) _XIOError(dpy);
- if (result <= 0)
- continue;
-#ifdef USE_POLL
- if (filedes[0].revents & (POLLIN|POLLHUP|POLLERR))
-#else
- if (FD_ISSET(fd, &r_mask))
-#endif
- break;
- if (!(dpy->flags & XlibDisplayProcConni)) {
- int i;
-
- saved_event_serial = dpy->next_event_serial_num;
- /* dpy flags can be clobbered by internal connection callback */
- in_read_events = dpy->flags & XlibDisplayReadEvents;
- for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
-#ifdef USE_POLL
- if (filedes[i].revents & POLLIN)
-#else
- if (FD_ISSET(ilist->fd, &r_mask))
-#endif
- {
- _XProcessInternalConnection(dpy, ilist);
- did_proc_conni = True;
- }
- }
-#ifdef USE_POLL
- if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE)
- Xfree(filedes);
-#endif
- }
- if (did_proc_conni) {
- /* some internal connection callback might have done an
- XPutBackEvent. We notice it here and if we needed an event,
- we can return all the way. */
- if (_XNewerQueuedEvent(dpy, saved_event_serial)
- && (in_read_events
-#ifdef XTHREADS
- || (dpy->lock && dpy->lock->event_awaiters)
-#endif
- ))
- return -2;
- did_proc_conni = False;
- }
- }
-#ifdef XTHREADS
-#ifdef XTHREADS_DEBUG
- printf("thread %x _XWaitForReadable returning\n", XThread_Self());
-#endif
-#endif
- return 0;
-}
-#endif /* !USE_XCB */
-
static int sync_hazard(Display *dpy)
{
unsigned long span = dpy->request - dpy->last_request_read;
@@ -625,548 +275,6 @@ void _XSetSeqSyncFunction(Display *dpy)
_XSetPrivSyncFunction (dpy);
}
-#if !USE_XCB
-#ifdef XTHREADS
-static void _XFlushInt(
- register Display *dpy,
- register xcondition_t cv);
-#endif
-
-/*
- * _XFlush - Flush the X request buffer. If the buffer is empty, no
- * action is taken. This routine correctly handles incremental writes.
- * This routine may have to be reworked if int < long.
- */
-void _XFlush(
- register Display *dpy)
-{
-#ifdef XTHREADS
- /* With multi-threading we introduce an internal routine to which
- we can pass a condition variable to do locking correctly. */
-
- _XFlushInt(dpy, NULL);
-}
-
-/* _XFlushInt - Internal version of _XFlush used to do multi-threaded
- * locking correctly.
- */
-
-static void _XFlushInt(
- register Display *dpy,
- register xcondition_t cv)
-{
-#endif /* XTHREADS*/
- register long size, todo;
- register int write_stat;
- register char *bufindex;
- _XExtension *ext;
-
- /* This fix resets the bufptr to the front of the buffer so
- * additional appends to the bufptr will not corrupt memory. Since
- * the server is down, these appends are no-op's anyway but
- * callers of _XFlush() are not verifying this before they call it.
- */
- if (dpy->flags & XlibDisplayIOError)
- {
- dpy->bufptr = dpy->buffer;
- dpy->last_req = (char *)&_dummy_request;
- return;
- }
-
-#ifdef XTHREADS
- while (dpy->flags & XlibDisplayWriting) {
- if (dpy->lock) {
- ConditionWait(dpy, dpy->lock->writers);
- } else {
- _XWaitForWritable (dpy, cv);
- }
- }
-#endif
- size = todo = dpy->bufptr - dpy->buffer;
- if (!size) return;
-#ifdef XTHREADS
- dpy->flags |= XlibDisplayWriting;
- /* make sure no one else can put in data */
- dpy->bufptr = dpy->bufmax;
-#endif
- for (ext = dpy->flushes; ext; ext = ext->next_flush)
- (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, size);
- bufindex = dpy->buffer;
- /*
- * While write has not written the entire buffer, keep looping
- * until the entire buffer is written. bufindex will be
- * incremented and size decremented as buffer is written out.
- */
- while (size) {
- ESET(0);
- write_stat = _X11TransWrite(dpy->trans_conn,
- bufindex, (int) todo);
- if (write_stat >= 0) {
- size -= write_stat;
- todo = size;
- bufindex += write_stat;
- } else if (ETEST()) {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , cv
-#endif
- );
-#ifdef SUNSYSV
- } else if (ECHECK(0)) {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , cv
-#endif
- );
-#endif
-#ifdef ESZTEST
- } else if (ESZTEST()) {
- if (todo > 1)
- todo >>= 1;
- else {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , cv
-#endif
- );
- }
-#endif
- } else if (!ECHECK(EINTR)) {
- /* Write failed! */
- /* errno set by write system call. */
- _XIOError(dpy);
- }
- }
- dpy->last_req = (char *)&_dummy_request;
- _XSetSeqSyncFunction(dpy);
- dpy->bufptr = dpy->buffer;
-#ifdef XTHREADS
- dpy->flags &= ~XlibDisplayWriting;
-#endif
-}
-
-int
-_XEventsQueued(
- register Display *dpy,
- int mode)
-{
- register int len;
- BytesReadable_t pend;
- _XAlignedBuffer buf;
- register xReply *rep;
- char *read_buf;
-#ifdef XTHREADS
- int entry_event_serial_num;
- struct _XCVList *cvl = NULL;
- xthread_t self;
-
-#ifdef XTHREADS_DEBUG
- printf("_XEventsQueued called in thread %x\n", XThread_Self());
-#endif
-#endif /* XTHREADS*/
-
- if (mode == QueuedAfterFlush)
- {
- _XFlush(dpy);
- if (dpy->qlen)
- return(dpy->qlen);
- }
- if (dpy->flags & XlibDisplayIOError) return(dpy->qlen);
-
-#ifdef XTHREADS
- /* create our condition variable and append to list,
- * unless we were called from within XProcessInternalConnection
- * or XLockDisplay
- */
- xthread_clear_id(self);
- if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
- || xthread_have_id (dpy->lock->locking_thread)))
- /* some thread is in XProcessInternalConnection or XLockDisplay
- so we have to see if we are it */
- self = XThread_Self();
- if (!xthread_have_id(self)
- || (!xthread_equal(self, dpy->lock->conni_thread)
- && !xthread_equal(self, dpy->lock->locking_thread))) {
- /* In the multi-threaded case, if there is someone else
- reading events, then there aren't any available, so
- we just return. If we waited we would block.
- */
- if (dpy->lock && dpy->lock->event_awaiters)
- return dpy->qlen;
- /* nobody here but us, so lock out any newcomers */
- cvl = QueueEventReaderLock(dpy);
- }
-
- while (dpy->lock && cvl && dpy->lock->reply_first) {
- /* note which events we have already seen so we'll know
- if _XReply (in another thread) reads one */
- entry_event_serial_num = dpy->next_event_serial_num;
- ConditionWait(dpy, cvl->cv);
- /* did _XReply read an event we can return? */
- if (_XNewerQueuedEvent(dpy, entry_event_serial_num))
- {
- UnlockNextEventReader(dpy);
- return 0;
- }
- }
-#endif /* XTHREADS*/
-
- if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
- _XIOError(dpy);
-#ifdef XCONN_CHECK_FREQ
- /* This is a crock, required because FIONREAD or equivalent is
- * not guaranteed to detect a broken connection.
- */
- if (!pend && !dpy->qlen && ++dpy->conn_checker >= XCONN_CHECK_FREQ)
- {
- int result;
-#ifdef USE_POLL
- struct pollfd filedes;
-#else
- fd_set r_mask;
- static struct timeval zero_time;
-#endif
-
- dpy->conn_checker = 0;
-#ifdef USE_POLL
- filedes.fd = dpy->fd;
- filedes.events = POLLIN;
- if ((result = poll(&filedes, 1, 0)))
-#else
- FD_ZERO(&r_mask);
- FD_SET(dpy->fd, &r_mask);
- if ((result = Select(dpy->fd + 1, &r_mask, NULL, NULL, &zero_time)))
-#endif
- {
- if (result > 0)
- {
- if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
- _XIOError(dpy);
- /* we should not get zero, if we do, force a read */
- if (!pend)
- pend = SIZEOF(xReply);
- }
- else if (result < 0 && !(ECHECK(EINTR) || ETEST()))
- _XIOError(dpy);
- }
- }
-#endif /* XCONN_CHECK_FREQ */
- if (!(len = pend)) {
- /* _XFlush can enqueue events */
-#ifdef XTHREADS
- if (cvl)
-#endif
- {
- UnlockNextEventReader(dpy);
- }
- return(dpy->qlen);
- }
- /* Force a read if there is not enough data. Otherwise,
- * a select() loop at a higher-level will spin undesirably,
- * and we've seen at least one OS that appears to not update
- * the result from FIONREAD once it has returned nonzero.
- */
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->reply_awaiters) {
- read_buf = (char *)dpy->lock->reply_awaiters->buf;
- len = SIZEOF(xReply);
- } else
-#endif /* XTHREADS*/
- {
- read_buf = buf.buf;
-
- if (len < SIZEOF(xReply)
-#ifdef XTHREADS
- || dpy->async_handlers
-#endif
- )
- len = SIZEOF(xReply);
- else if (len > BUFSIZE)
- len = BUFSIZE;
- len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
- }
-#ifdef XCONN_CHECK_FREQ
- dpy->conn_checker = 0;
-#endif
-
- (void) _XRead (dpy, read_buf, (long) len);
-
-#ifdef XTHREADS
- /* what did we actually read: reply or event? */
- if (dpy->lock && dpy->lock->reply_awaiters) {
- if (((xReply *)read_buf)->generic.type == X_Reply ||
- ((xReply *)read_buf)->generic.type == X_Error)
- {
- dpy->lock->reply_was_read = True;
- dpy->lock->reply_first = True;
- if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
- memcpy(dpy->lock->reply_awaiters->buf, read_buf,
- len);
- if (cvl) {
- UnlockNextEventReader(dpy);
- }
- return(dpy->qlen); /* we read, so we can return */
- } else if (read_buf != buf.buf)
- memcpy(buf.buf, read_buf, len);
- }
-#endif /* XTHREADS*/
-
- STARTITERATE(rep,xReply,buf.buf,len > 0) {
- if (rep->generic.type == X_Reply) {
- int tmp = len;
- RESETITERPTR(rep,xReply,
- _XAsyncReply (dpy, rep,
- ITERPTR(rep), &tmp, True));
- len = tmp;
- pend = len;
- } else {
- if (rep->generic.type == X_Error)
- _XError (dpy, (xError *)rep);
- else /* must be an event packet */
- _XEnq (dpy, (xEvent *)rep);
- INCITERPTR(rep,xReply);
- len -= SIZEOF(xReply);
- }
- } ENDITERATE
-
-#ifdef XTHREADS
- if (cvl)
-#endif
- {
- UnlockNextEventReader(dpy);
- }
- return(dpy->qlen);
-}
-
-/* _XReadEvents - Flush the output queue,
- * then read as many events as possible (but at least 1) and enqueue them
- */
-void _XReadEvents(
- register Display *dpy)
-{
- _XAlignedBuffer buf;
- BytesReadable_t pend;
- int len;
- register xReply *rep;
- Bool not_yet_flushed = True;
- char *read_buf;
- int i;
- int entry_event_serial_num = dpy->next_event_serial_num;
-#ifdef XTHREADS
- struct _XCVList *cvl = NULL;
- xthread_t self;
-
-#ifdef XTHREADS_DEBUG
- printf("_XReadEvents called in thread %x\n",
- XThread_Self());
-#endif
- /* create our condition variable and append to list,
- * unless we were called from within XProcessInternalConnection
- * or XLockDisplay
- */
- xthread_clear_id(self);
- if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
- || xthread_have_id (dpy->lock->locking_thread)))
- /* some thread is in XProcessInternalConnection or XLockDisplay
- so we have to see if we are it */
- self = XThread_Self();
- if (!xthread_have_id(self)
- || (!xthread_equal(self, dpy->lock->conni_thread)
- && !xthread_equal(self, dpy->lock->locking_thread)))
- cvl = QueueEventReaderLock(dpy);
-#endif /* XTHREADS */
-
- do {
-#ifdef XTHREADS
- /* if it is not our turn to read an event off the wire,
- wait til we're at head of list */
- if (dpy->lock && cvl &&
- (dpy->lock->event_awaiters != cvl ||
- dpy->lock->reply_first)) {
- ConditionWait(dpy, cvl->cv);
- continue;
- }
-#endif /* XTHREADS */
- /* find out how much data can be read */
- if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
- _XIOError(dpy);
- len = pend;
-
- /* must read at least one xEvent; if none is pending, then
- we'll just flush and block waiting for it */
- if (len < SIZEOF(xEvent)
-#ifdef XTHREADS
- || dpy->async_handlers
-#endif
- ) {
- len = SIZEOF(xEvent);
- /* don't flush until the first time we would block */
- if (not_yet_flushed) {
- _XFlush (dpy);
- if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) {
- /* _XReply has read an event for us */
- goto got_event;
- }
- not_yet_flushed = False;
- }
- }
-
-#ifdef XTHREADS
- /* If someone is waiting for a reply, gamble that
- the reply will be the next thing on the wire
- and read it into their buffer. */
- if (dpy->lock && dpy->lock->reply_awaiters) {
- read_buf = (char *)dpy->lock->reply_awaiters->buf;
- len = SIZEOF(xReply);
- } else
-#endif /* XTHREADS*/
- {
- read_buf = buf.buf;
-
- /* but we won't read more than the max buffer size */
- if (len > BUFSIZE)
- len = BUFSIZE;
-
- /* round down to an integral number of XReps */
- len = (len / SIZEOF(xEvent)) * SIZEOF(xEvent);
- }
-
-#ifdef XTHREADS
- if (xthread_have_id(self))
- /* save value we may have to stick in conni_thread */
- dpy->lock->reading_thread = self;
-#endif /* XTHREADS */
- dpy->flags |= XlibDisplayReadEvents;
- i = _XRead (dpy, read_buf, (long) len);
- dpy->flags &= ~XlibDisplayReadEvents;
- if (i == -2) {
- /* special flag from _XRead to say that internal connection has
- done XPutBackEvent. Which we can use so we're done. */
- got_event:
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->lock_wait) {
- if (dpy->lock->event_awaiters != cvl)
- /* since it is not us, must be user lock thread */
- ConditionSignal(dpy,
- dpy->lock->event_awaiters->cv);
- (*dpy->lock->lock_wait)(dpy);
- continue;
- }
-#endif
- break;
- }
-#ifdef XTHREADS
- if (xthread_have_id(self))
- xthread_clear_id(dpy->lock->reading_thread);
-
- /* what did we actually read: reply or event? */
- if (dpy->lock && dpy->lock->reply_awaiters) {
- if (((xReply *)read_buf)->generic.type == X_Reply ||
- ((xReply *)read_buf)->generic.type == X_Error)
- {
- dpy->lock->reply_was_read = True;
- dpy->lock->reply_first = True;
- if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
- memcpy(dpy->lock->reply_awaiters->buf,
- read_buf, len);
- ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
- continue;
- } else if (read_buf != buf.buf)
- memcpy(buf.buf, read_buf, len);
- }
-#endif /* XTHREADS */
-
- STARTITERATE(rep,xReply,buf.buf,len > 0) {
- if (rep->generic.type == X_Reply) {
- RESETITERPTR(rep,xReply,
- _XAsyncReply (dpy, rep,
- ITERPTR(rep), &len, True));
- pend = len;
- } else {
- if (rep->generic.type == X_Error)
- _XError (dpy, (xError *) rep);
- else /* must be an event packet */
- {
- if (rep->generic.type == GenericEvent)
- {
- int evlen;
- evlen = (rep->generic.length << 2);
- if (_XRead(dpy, &read_buf[len], evlen) == -2)
- goto got_event; /* XXX: aargh! */
- }
-
- _XEnq (dpy, (xEvent *)rep);
- }
- INCITERPTR(rep,xReply);
- len -= SIZEOF(xReply);
- }
- } ENDITERATE;
- } while (!_XNewerQueuedEvent(dpy, entry_event_serial_num));
-
- UnlockNextEventReader(dpy);
-}
-
-/*
- * _XRead - Read bytes from the socket taking into account incomplete
- * reads. This routine may have to be reworked if int < long.
- */
-int _XRead(
- register Display *dpy,
- register char *data,
- register long size)
-{
- register long bytes_read;
-#ifdef XTHREADS
- int original_size = size;
-#endif
-
- if ((dpy->flags & XlibDisplayIOError) || size == 0)
- return 0;
- ESET(0);
- while ((bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size))
- != size) {
-
- if (bytes_read > 0) {
- size -= bytes_read;
- data += bytes_read;
- }
- else if (ETEST()) {
- if (_XWaitForReadable(dpy) == -2)
- return -2; /* internal connection did XPutBackEvent */
- ESET(0);
- }
-#ifdef SUNSYSV
- else if (ECHECK(0)) {
- if (_XWaitForReadable(dpy) == -2)
- return -2; /* internal connection did XPutBackEvent */
- }
-#endif
- else if (bytes_read == 0) {
- /* Read failed because of end of file! */
- ESET(EPIPE);
- _XIOError(dpy);
- }
-
- else /* bytes_read is less than 0; presumably -1 */ {
- /* If it's a system call interrupt, it's not an error. */
- if (!ECHECK(EINTR))
- _XIOError(dpy);
- }
- }
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->reply_bytes_left > 0)
- {
- dpy->lock->reply_bytes_left -= original_size;
- if (dpy->lock->reply_bytes_left == 0) {
- dpy->flags &= ~XlibDisplayReply;
- UnlockNextReplyReader(dpy);
- }
- }
-#endif /* XTHREADS*/
- return 0;
-}
-#endif /* !USE_XCB */
-
#ifdef LONG64
void _XRead32(
Display *dpy,
@@ -1306,348 +414,6 @@ void _XRead16Pad(
}
#endif /* WORD64 */
-
-#if !USE_XCB
-/*
- * _XReadPad - Read bytes from the socket taking into account incomplete
- * reads. If the number of bytes is not 0 mod 4, read additional pad
- * bytes. This routine may have to be reworked if int < long.
- */
-void _XReadPad(
- register Display *dpy,
- register char *data,
- register long size)
-{
- register long bytes_read;
- struct iovec iov[2];
- char pad[3];
-#ifdef XTHREADS
- int original_size;
-#endif
-
- if ((dpy->flags & XlibDisplayIOError) || size == 0) return;
- iov[0].iov_len = (int)size;
- iov[0].iov_base = data;
- /*
- * The following hack is used to provide 32 bit long-word
- * aligned padding. The [1] vector is of length 0, 1, 2, or 3,
- * whatever is needed.
- */
-
- iov[1].iov_len = -size & 3;
- iov[1].iov_base = pad;
- size += iov[1].iov_len;
-#ifdef XTHREADS
- original_size = size;
-#endif
- ESET(0);
- while ((bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2)) != size) {
-
- if (bytes_read > 0) {
- size -= bytes_read;
- if (iov[0].iov_len < bytes_read) {
- int pad_bytes_read = bytes_read - iov[0].iov_len;
- iov[1].iov_len -= pad_bytes_read;
- iov[1].iov_base =
- (char *)iov[1].iov_base + pad_bytes_read;
- iov[0].iov_len = 0;
- }
- else {
- iov[0].iov_len -= bytes_read;
- iov[0].iov_base = (char *)iov[0].iov_base + bytes_read;
- }
- }
- else if (ETEST()) {
- _XWaitForReadable(dpy);
- ESET(0);
- }
-#ifdef SUNSYSV
- else if (ECHECK(0)) {
- _XWaitForReadable(dpy);
- }
-#endif
- else if (bytes_read == 0) {
- /* Read failed because of end of file! */
- ESET(EPIPE);
- _XIOError(dpy);
- }
-
- else /* bytes_read is less than 0; presumably -1 */ {
- /* If it's a system call interrupt, it's not an error. */
- if (!ECHECK(EINTR))
- _XIOError(dpy);
- }
- }
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->reply_bytes_left > 0)
- {
- dpy->lock->reply_bytes_left -= original_size;
- if (dpy->lock->reply_bytes_left == 0) {
- dpy->flags &= ~XlibDisplayReply;
- UnlockNextReplyReader(dpy);
- }
- }
-#endif /* XTHREADS*/
-}
-
-/*
- * _XSend - Flush the buffer and send the client data. 32 bit word aligned
- * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
- * This routine may have to be reworked if int < long;
- */
-void
-_XSend (
- register Display *dpy,
- _Xconst char *data,
- register long size)
-{
- struct iovec iov[3];
- static char const pad[3] = {0, 0, 0};
- /* XText8 and XText16 require that the padding bytes be zero! */
-
- long skip, dbufsize, padsize, total, todo;
- _XExtension *ext;
-
- if (!size || (dpy->flags & XlibDisplayIOError)) return;
- dbufsize = dpy->bufptr - dpy->buffer;
-#ifdef XTHREADS
- dpy->flags |= XlibDisplayWriting;
- /* make sure no one else can put in data */
- dpy->bufptr = dpy->bufmax;
-#endif
- padsize = -size & 3;
- for (ext = dpy->flushes; ext; ext = ext->next_flush) {
- (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, dbufsize);
- (*ext->before_flush)(dpy, &ext->codes, (char *)data, size);
- if (padsize)
- (*ext->before_flush)(dpy, &ext->codes, pad, padsize);
- }
- skip = 0;
- todo = total = dbufsize + size + padsize;
-
- /*
- * There are 3 pieces that may need to be written out:
- *
- * o whatever is in the display buffer
- * o the data passed in by the user
- * o any padding needed to 32bit align the whole mess
- *
- * This loop looks at all 3 pieces each time through. It uses skip
- * to figure out whether or not a given piece is needed.
- */
- while (total) {
- long before = skip; /* amount of whole thing written */
- long remain = todo; /* amount to try this time, <= total */
- int i = 0;
- long len;
-
- /* You could be very general here and have "in" and "out" iovecs
- * and write a loop without using a macro, but what the heck. This
- * translates to:
- *
- * how much of this piece is new?
- * if more new then we are trying this time, clamp
- * if nothing new
- * then bump down amount already written, for next piece
- * else put new stuff in iovec, will need all of next piece
- *
- * Note that todo had better be at least 1 or else we'll end up
- * writing 0 iovecs.
- */
-#define InsertIOV(pointer, length) \
- len = (length) - before; \
- if (len > remain) \
- len = remain; \
- if (len <= 0) { \
- before = (-len); \
- } else { \
- iov[i].iov_len = len; \
- iov[i].iov_base = (pointer) + before; \
- i++; \
- remain -= len; \
- before = 0; \
- }
-
- InsertIOV (dpy->buffer, dbufsize)
- InsertIOV ((char *)data, size)
- InsertIOV ((char *)pad, padsize)
-
- ESET(0);
- if ((len = _X11TransWritev(dpy->trans_conn, iov, i)) >= 0) {
- skip += len;
- total -= len;
- todo = total;
- } else if (ETEST()) {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , NULL
-#endif
- );
-#ifdef SUNSYSV
- } else if (ECHECK(0)) {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , NULL
-#endif
- );
-#endif
-#ifdef ESZTEST
- } else if (ESZTEST()) {
- if (todo > 1)
- todo >>= 1;
- else {
- _XWaitForWritable(dpy
-#ifdef XTHREADS
- , NULL
-#endif
- );
- }
-#endif
- } else if (!ECHECK(EINTR)) {
- _XIOError(dpy);
- }
- }
- dpy->last_req = (char *) & _dummy_request;
- _XSetSeqSyncFunction(dpy);
- dpy->bufptr = dpy->buffer;
-#ifdef XTHREADS
- dpy->flags &= ~XlibDisplayWriting;
-#endif
- return;
-}
-
-static void
-_XGetMiscCode(
- register Display *dpy)
-{
- xQueryExtensionReply qrep;
- register xQueryExtensionReq *qreq;
- xXCMiscGetVersionReply vrep;
- register xXCMiscGetVersionReq *vreq;
-
- if (dpy->xcmisc_opcode)
- return;
- GetReq(QueryExtension, qreq);
- qreq->nbytes = sizeof(XCMiscExtensionName) - 1;
- qreq->length += (qreq->nbytes+(unsigned)3)>>2;
- _XSend(dpy, XCMiscExtensionName, (long)qreq->nbytes);
- if (!_XReply (dpy, (xReply *)&qrep, 0, xTrue))
- dpy->xcmisc_opcode = -1;
- else {
- GetReq(XCMiscGetVersion, vreq);
- vreq->reqType = qrep.major_opcode;
- vreq->miscReqType = X_XCMiscGetVersion;
- vreq->majorVersion = XCMiscMajorVersion;
- vreq->minorVersion = XCMiscMinorVersion;
- if (!_XReply (dpy, (xReply *)&vrep, 0, xTrue))
- dpy->xcmisc_opcode = -1;
- else
- dpy->xcmisc_opcode = qrep.major_opcode;
- }
-}
-
-void
-_XIDHandler(
- register Display *dpy)
-{
- xXCMiscGetXIDRangeReply grep;
- register xXCMiscGetXIDRangeReq *greq;
-
- if (dpy->resource_max == dpy->resource_mask + 1) {
- _XGetMiscCode(dpy);
- if (dpy->xcmisc_opcode > 0) {
- GetReq(XCMiscGetXIDRange, greq);
- greq->reqType = dpy->xcmisc_opcode;
- greq->miscReqType = X_XCMiscGetXIDRange;
- if (_XReply (dpy, (xReply *)&grep, 0, xTrue) && grep.count) {
- dpy->resource_id = ((grep.start_id - dpy->resource_base) >>
- dpy->resource_shift);
- dpy->resource_max = dpy->resource_id;
- if (grep.count > 5)
- dpy->resource_max += grep.count - 6;
- dpy->resource_max <<= dpy->resource_shift;
- }
- sync_while_locked(dpy);
- }
- }
-}
-
-/*
- * _XAllocID - resource ID allocation routine.
- */
-XID _XAllocID(
- register Display *dpy)
-{
- XID id;
-
- id = dpy->resource_id << dpy->resource_shift;
- if (id >= dpy->resource_max) {
- _XSetPrivSyncFunction(dpy);
- dpy->resource_max = dpy->resource_mask + 1;
- }
- if (id <= dpy->resource_mask) {
- dpy->resource_id++;
- return (dpy->resource_base + id);
- }
- if (id != 0x10000000) {
- (void) fprintf(stderr,
- "Xlib: resource ID allocation space exhausted!\n");
- id = 0x10000000;
- dpy->resource_id = id >> dpy->resource_shift;
- }
- return id;
-}
-
-/*
- * _XAllocIDs - multiple resource ID allocation routine.
- */
-void _XAllocIDs(
- register Display *dpy,
- XID *ids,
- int count)
-{
- XID id;
- int i;
- xXCMiscGetXIDListReply grep;
- register xXCMiscGetXIDListReq *greq;
-
- id = dpy->resource_id << dpy->resource_shift;
- if (dpy->resource_max <= dpy->resource_mask &&
- id <= dpy->resource_mask &&
- (dpy->resource_max - id) > ((count - 1) << dpy->resource_shift)) {
- id += dpy->resource_base;
- for (i = 0; i < count; i++) {
- ids[i] = id;
- id += (1 << dpy->resource_shift);
- dpy->resource_id++;
- }
- return;
- }
- grep.count = 0;
- _XGetMiscCode(dpy);
- if (dpy->xcmisc_opcode > 0) {
- GetReq(XCMiscGetXIDList, greq);
- greq->reqType = dpy->xcmisc_opcode;
- greq->miscReqType = X_XCMiscGetXIDList;
- greq->count = count;
- if (_XReply(dpy, (xReply *)&grep, 0, xFalse) && grep.count) {
- _XRead32(dpy, (long *) ids, 4L * (long) (grep.count));
- for (i = 0; i < grep.count; i++) {
- id = (ids[i] - dpy->resource_base) >> dpy->resource_shift;
- if (id >= dpy->resource_id)
- dpy->resource_id = id;
- }
- if (id >= dpy->resource_max) {
- _XSetPrivSyncFunction(dpy);
- dpy->resource_max = dpy->resource_mask + 1;
- }
- }
- }
- for (i = grep.count; i < count; i++)
- ids[i] = XAllocID(dpy);
-}
-#endif /* !USE_XCB */
-
/*
* The hard part about this is that we only get 16 bits from a reply.
* We have three values that will march along, with the following invariant:
@@ -1691,263 +457,6 @@ _XSetLastRequestRead(
return(newseq);
}
-#if !USE_XCB
-/*
- * _XReply - Wait for a reply packet and copy its contents into the
- * specified rep. Meanwhile we must handle error and event packets that
- * we may encounter.
- */
-Status
-_XReply (
- register Display *dpy,
- register xReply *rep,
- int extra, /* number of 32-bit words expected after the reply */
- Bool discard) /* should I discard data following "extra" words? */
-{
- /* Pull out the serial number now, so that (currently illegal) requests
- * generated by an error handler don't confuse us.
- */
- unsigned long cur_request = dpy->request;
-#ifdef XTHREADS
- struct _XCVList *cvl;
-#endif
-
- if (dpy->flags & XlibDisplayIOError)
- return 0;
-
-#ifdef XTHREADS
- /* create our condition variable and append to list */
- cvl = QueueReplyReaderLock(dpy);
- if (cvl) {
- cvl->buf = rep;
- if (dpy->lock->reply_awaiters == cvl && !dpy->lock->event_awaiters)
- dpy->lock->reply_first = True;
- }
-
-#ifdef XTHREADS_DEBUG
- printf("_XReply called in thread %x, adding %x to cvl\n",
- XThread_Self(), cvl);
-#endif
-
- _XFlushInt(dpy, cvl ? cvl->cv : NULL);
- /* if it is not our turn to read a reply off the wire,
- * wait til we're at head of list. if there is an event waiter,
- * and our reply hasn't been read, they'll be in select and will
- * hand control back to us next.
- */
- if(dpy->lock &&
- (dpy->lock->reply_awaiters != cvl || !dpy->lock->reply_first)) {
- ConditionWait(dpy, cvl->cv);
- }
- dpy->flags |= XlibDisplayReply;
-#else /* XTHREADS else */
- _XFlush(dpy);
-#endif
-
- for (;;) {
-#ifdef XTHREADS
- /* Did another thread's _XReadEvents get our reply by accident? */
- if (!dpy->lock || !dpy->lock->reply_was_read)
-#endif
- (void) _XRead(dpy, (char *)rep, (long)SIZEOF(xReply));
-#ifdef XTHREADS
- if (dpy->lock)
- dpy->lock->reply_was_read = False;
-#endif
-
- switch ((int)rep->generic.type) {
-
- case X_Reply:
- /* Reply received. Fast update for synchronous replies,
- * but deal with multiple outstanding replies.
- */
- if (rep->generic.sequenceNumber == (cur_request & 0xffff))
- dpy->last_request_read = cur_request;
- else {
- int pend = SIZEOF(xReply);
- if (_XAsyncReply(dpy, rep, (char *)rep, &pend, False)
- != (char *)rep)
- continue;
- }
- if (extra <= rep->generic.length) {
- if (extra > 0)
- /*
- * Read the extra data into storage immediately
- * following the GenericReply structure.
- */
- (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
- ((long)extra) << 2);
- if (discard) {
- if (extra < rep->generic.length)
- _XEatData(dpy, (rep->generic.length - extra) << 2);
- }
-#ifdef XTHREADS
- if (dpy->lock) {
- if (discard) {
- dpy->lock->reply_bytes_left = 0;
- } else {
- dpy->lock->reply_bytes_left =
- (rep->generic.length - extra) << 2;
- }
- if (dpy->lock->reply_bytes_left == 0) {
- dpy->flags &= ~XlibDisplayReply;
- UnlockNextReplyReader(dpy);
- }
- } else
- dpy->flags &= ~XlibDisplayReply;
-#endif
- return 1;
- }
- /*
- *if we get here, then extra > rep->generic.length--meaning we
- * read a reply that's shorter than we expected. This is an
- * error, but we still need to figure out how to handle it...
- */
- (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
- ((long) rep->generic.length) << 2);
- dpy->flags &= ~XlibDisplayReply;
- UnlockNextReplyReader(dpy);
- _XIOError (dpy);
- return (0);
-
- case X_Error:
- {
- register _XExtension *ext;
- register Bool ret = False;
- int ret_code;
- xError *err = (xError *) rep;
- unsigned long serial;
-
- dpy->flags &= ~XlibDisplayReply;
- serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
- if (serial == cur_request)
- /* do not die on "no such font", "can't allocate",
- "can't grab" failures */
- switch ((int)err->errorCode) {
- case BadName:
- switch (err->majorCode) {
- case X_LookupColor:
- case X_AllocNamedColor:
- UnlockNextReplyReader(dpy);
- return(0);
- }
- break;
- case BadFont:
- if (err->majorCode == X_QueryFont) {
- UnlockNextReplyReader(dpy);
- return (0);
- }
- break;
- case BadAlloc:
- case BadAccess:
- UnlockNextReplyReader(dpy);
- return (0);
- }
- /*
- * we better see if there is an extension who may
- * want to suppress the error.
- */
- for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) {
- if (ext->error)
- ret = (*ext->error)(dpy, err, &ext->codes, &ret_code);
- }
- if (!ret) {
- _XError(dpy, err);
- ret_code = 0;
- }
- if (serial == cur_request) {
- UnlockNextReplyReader(dpy);
- return(ret_code);
- }
-
- } /* case X_Error */
- break;
- default:
- _XEnq(dpy, (xEvent *) rep);
-#ifdef XTHREADS
- if (dpy->lock && dpy->lock->event_awaiters)
- ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
-#endif
- break;
- }
- }
-}
-
-static char *
-_XAsyncReply(
- Display *dpy,
- register xReply *rep,
- char *buf,
- register int *lenp,
- Bool discard)
-{
- register _XAsyncHandler *async, *next;
- register int len;
- register Bool consumed = False;
- char *nbuf;
-
- (void) _XSetLastRequestRead(dpy, &rep->generic);
- len = SIZEOF(xReply) + (rep->generic.length << 2);
- if (len < SIZEOF(xReply)) {
- _XIOError (dpy);
- buf += *lenp;
- *lenp = 0;
- return buf;
- }
-
- for (async = dpy->async_handlers; async; async = next) {
- next = async->next;
- if ((consumed = (*async->handler)(dpy, rep, buf, *lenp, async->data)))
- break;
- }
- if (!consumed) {
- if (!discard)
- return buf;
- (void) fprintf(stderr,
- "Xlib: unexpected async reply (sequence 0x%lx)!\n",
- dpy->last_request_read);
-#ifdef XTHREADS
-#ifdef XTHREADS_DEBUG
- printf("thread %x, unexpected async reply\n", XThread_Self());
-#endif
-#endif
- if (len > *lenp)
- _XEatData(dpy, len - *lenp);
- }
- if (len < SIZEOF(xReply))
- {
- _XIOError (dpy);
- buf += *lenp;
- *lenp = 0;
- return buf;
- }
- if (len >= *lenp) {
- buf += *lenp;
- *lenp = 0;
- return buf;
- }
- *lenp -= len;
- buf += len;
- len = *lenp;
- nbuf = buf;
- while (len > SIZEOF(xReply)) {
- if (*buf == X_Reply)
- return nbuf;
- buf += SIZEOF(xReply);
- len -= SIZEOF(xReply);
- }
- if (len > 0 && len < SIZEOF(xReply)) {
- buf = nbuf;
- len = SIZEOF(xReply) - len;
- nbuf -= len;
- memmove(nbuf, buf, *lenp);
- (void) _XRead(dpy, nbuf + *lenp, (long)len);
- *lenp += len;
- }
- return nbuf;
-}
-#endif /* !USE_XCB */
-
/*
* Support for internal connections, such as an IM might use.
* By Stephen Gildea, X Consortium, September 1993
@@ -2097,22 +606,9 @@ void _XProcessInternalConnection(
struct _XConnectionInfo *conn_info)
{
dpy->flags |= XlibDisplayProcConni;
-#if defined(XTHREADS) && !USE_XCB
- if (dpy->lock) {
- /* check cache to avoid call to thread_self */
- if (xthread_have_id(dpy->lock->reading_thread))
- dpy->lock->conni_thread = dpy->lock->reading_thread;
- else
- dpy->lock->conni_thread = XThread_Self();
- }
-#endif /* XTHREADS && !USE_XCB */
UnlockDisplay(dpy);
(*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data);
LockDisplay(dpy);
-#if defined(XTHREADS) && !USE_XCB
- if (dpy->lock)
- xthread_clear_id(dpy->lock->conni_thread);
-#endif /* XTHREADS && !USE_XCB */
dpy->flags &= ~XlibDisplayProcConni;
}
@@ -2240,26 +736,6 @@ XRemoveConnectionWatch(
/* end of internal connections support */
-
-#if !USE_XCB
-/* Read and discard "n" 8-bit bytes of data */
-
-void _XEatData(
- Display *dpy,
- register unsigned long n)
-{
-#define SCRATCHSIZE 2048
- char buf[SCRATCHSIZE];
-
- while (n > 0) {
- register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n;
- (void) _XRead (dpy, buf, bytes_read);
- n -= bytes_read;
- }
-#undef SCRATCHSIZE
-}
-#endif /* !USE_XCB */
-
/* Cookie jar implementation
dpy->cookiejar is a linked list. _XEnq receives the events but leaves
them in the normal EQ. _XStoreEvent returns the cookie event (minus
@@ -3096,19 +1572,7 @@ int _XError (
!(*dpy->error_vec[rep->errorCode])(dpy, &event.xerror, rep))
return 0;
if (_XErrorFunction != NULL) {
- int rtn_val;
-#if defined(XTHREADS) && !USE_XCB
- if (dpy->lock)
- (*dpy->lock->user_lock_display)(dpy);
- UnlockDisplay(dpy);
-#endif /* XTHREADS && !USE_XCB */
- rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */
-#if defined(XTHREADS) && !USE_XCB
- LockDisplay(dpy);
- if (dpy->lock)
- (*dpy->lock->user_unlock_display)(dpy);
-#endif /* XTHREADS && !USE_XCB */
- return rtn_val;
+ return (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */
} else {
return _XDefaultError(dpy, (XErrorEvent *)&event);
}