Sun Jul 26 22:13:33 2015 UTC ()
Reduce diffs to upstream.
Probably merge issue, mostly whitespace.


(wiz)
diff -r1.3 -r1.4 xsrc/external/mit/libxcb/dist/src/xcb_in.c

cvs diff -r1.3 -r1.4 xsrc/external/mit/libxcb/dist/src/xcb_in.c (expand / switch to unified diff)

--- xsrc/external/mit/libxcb/dist/src/xcb_in.c 2014/03/17 03:08:52 1.3
+++ xsrc/external/mit/libxcb/dist/src/xcb_in.c 2015/07/26 22:13:33 1.4
@@ -26,41 +26,42 @@ @@ -26,41 +26,42 @@
26/* Stuff that reads stuff from the server. */ 26/* Stuff that reads stuff from the server. */
27 27
28#ifdef HAVE_CONFIG_H 28#ifdef HAVE_CONFIG_H
29#include "config.h" 29#include "config.h"
30#endif 30#endif
31 31
32#include <assert.h> 32#include <assert.h>
33#include <string.h> 33#include <string.h>
34#include <stdlib.h> 34#include <stdlib.h>
35#include <unistd.h> 35#include <unistd.h>
36#include <stdio.h> 36#include <stdio.h>
37#include <errno.h> 37#include <errno.h>
38 38
39#include "xcb.h" 
40#include "xcbext.h" 
41#include "xcbint.h" 
42#if USE_POLL 39#if USE_POLL
43#include <poll.h> 40#include <poll.h>
44#endif 41#endif
45#ifndef _WIN32 42#ifndef _WIN32
46#include <sys/select.h> 43#include <sys/select.h>
47#include <sys/socket.h> 44#include <sys/socket.h>
48#endif 45#endif
49 46
50#ifdef _WIN32 47#ifdef _WIN32
51#include "xcb_windefs.h" 48#include "xcb_windefs.h"
52#endif /* _WIN32 */ 49#endif /* _WIN32 */
53 50
 51#include "xcb.h"
 52#include "xcbext.h"
 53#include "xcbint.h"
 54
54#define XCB_ERROR 0 55#define XCB_ERROR 0
55#define XCB_REPLY 1 56#define XCB_REPLY 1
56#define XCB_XGE_EVENT 35 57#define XCB_XGE_EVENT 35
57 58
58struct event_list { 59struct event_list {
59 xcb_generic_event_t *event; 60 xcb_generic_event_t *event;
60 struct event_list *next; 61 struct event_list *next;
61}; 62};
62 63
63struct xcb_special_event { 64struct xcb_special_event {
64 65
65 struct xcb_special_event *next; 66 struct xcb_special_event *next;
66 67
@@ -190,29 +191,29 @@ static int read_packet(xcb_connection_t  @@ -190,29 +191,29 @@ static int read_packet(xcb_connection_t
190 c->in.request_expected = c->in.request_read; 191 c->in.request_expected = c->in.request_read;
191 192
192 if(c->in.request_read != lastread) 193 if(c->in.request_read != lastread)
193 { 194 {
194 if(c->in.current_reply) 195 if(c->in.current_reply)
195 { 196 {
196 _xcb_map_put(c->in.replies, lastread, c->in.current_reply); 197 _xcb_map_put(c->in.replies, lastread, c->in.current_reply);
197 c->in.current_reply = 0; 198 c->in.current_reply = 0;
198 c->in.current_reply_tail = &c->in.current_reply; 199 c->in.current_reply_tail = &c->in.current_reply;
199 } 200 }
200 c->in.request_completed = c->in.request_read - 1; 201 c->in.request_completed = c->in.request_read - 1;
201 } 202 }
202 203
203 while(c->in.pending_replies &&  204 while(c->in.pending_replies &&
204 c->in.pending_replies->workaround != WORKAROUND_EXTERNAL_SOCKET_OWNER && 205 c->in.pending_replies->workaround != WORKAROUND_EXTERNAL_SOCKET_OWNER &&
205 XCB_SEQUENCE_COMPARE (c->in.pending_replies->last_request, <=, c->in.request_completed)) 206 XCB_SEQUENCE_COMPARE (c->in.pending_replies->last_request, <=, c->in.request_completed))
206 { 207 {
207 pending_reply *oldpend = c->in.pending_replies; 208 pending_reply *oldpend = c->in.pending_replies;
208 c->in.pending_replies = oldpend->next; 209 c->in.pending_replies = oldpend->next;
209 if(!oldpend->next) 210 if(!oldpend->next)
210 c->in.pending_replies_tail = &c->in.pending_replies; 211 c->in.pending_replies_tail = &c->in.pending_replies;
211 free(oldpend); 212 free(oldpend);
212 } 213 }
213 214
214 if(genrep.response_type == XCB_ERROR) 215 if(genrep.response_type == XCB_ERROR)
215 c->in.request_completed = c->in.request_read; 216 c->in.request_completed = c->in.request_read;
216 217
217 remove_finished_readers(&c->in.readers, c->in.request_completed); 218 remove_finished_readers(&c->in.readers, c->in.request_completed);
218 } 219 }
@@ -376,31 +377,31 @@ static int read_block(const int fd, void @@ -376,31 +377,31 @@ static int read_block(const int fd, void
376#if USE_POLL 377#if USE_POLL
377 struct pollfd pfd; 378 struct pollfd pfd;
378 pfd.fd = fd; 379 pfd.fd = fd;
379 pfd.events = POLLIN; 380 pfd.events = POLLIN;
380 pfd.revents = 0; 381 pfd.revents = 0;
381 do { 382 do {
382 ret = poll(&pfd, 1, -1); 383 ret = poll(&pfd, 1, -1);
383 } while (ret == -1 && errno == EINTR); 384 } while (ret == -1 && errno == EINTR);
384#else 385#else
385 fd_set fds; 386 fd_set fds;
386 FD_ZERO(&fds); 387 FD_ZERO(&fds);
387 FD_SET(fd, &fds); 388 FD_SET(fd, &fds);
388 389
389 /* Initializing errno here makes sure that for Win32 this loop will execute only once */ 390 /* Initializing errno here makes sure that for Win32 this loop will execute only once */
390 errno = 0;  391 errno = 0;
391 do { 392 do {
392 ret = select(fd + 1, &fds, 0, 0, 0); 393 ret = select(fd + 1, &fds, 0, 0, 0);
393 } while (ret == -1 && errno == EINTR); 394 } while (ret == -1 && errno == EINTR);
394#endif /* USE_POLL */ 395#endif /* USE_POLL */
395 } 396 }
396 if(ret <= 0) 397 if(ret <= 0)
397 return ret; 398 return ret;
398 } 399 }
399 return len; 400 return len;
400} 401}
401 402
402static int poll_for_reply(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error) 403static int poll_for_reply(xcb_connection_t *c, uint64_t request, void **reply, xcb_generic_error_t **error)
403{ 404{
404 struct reply_list *head; 405 struct reply_list *head;
405 406
406 /* If an error occurred when issuing the request, fail immediately. */ 407 /* If an error occurred when issuing the request, fail immediately. */
@@ -736,27 +737,27 @@ xcb_register_for_special_xge(xcb_connect @@ -736,27 +737,27 @@ xcb_register_for_special_xge(xcb_connect
736 pthread_mutex_lock(&c->iolock); 737 pthread_mutex_lock(&c->iolock);
737 for (se = c->in.special_events; se; se = se->next) { 738 for (se = c->in.special_events; se; se = se->next) {
738 if (se->extension == ext_reply->major_opcode && 739 if (se->extension == ext_reply->major_opcode &&
739 se->eid == eid) { 740 se->eid == eid) {
740 pthread_mutex_unlock(&c->iolock); 741 pthread_mutex_unlock(&c->iolock);
741 return NULL; 742 return NULL;
742 } 743 }
743 } 744 }
744 se = calloc(1, sizeof(xcb_special_event_t)); 745 se = calloc(1, sizeof(xcb_special_event_t));
745 if (!se) { 746 if (!se) {
746 pthread_mutex_unlock(&c->iolock); 747 pthread_mutex_unlock(&c->iolock);
747 return NULL; 748 return NULL;
748 } 749 }
749  750
750 se->extension = ext_reply->major_opcode; 751 se->extension = ext_reply->major_opcode;
751 se->eid = eid; 752 se->eid = eid;
752 753
753 se->events = NULL; 754 se->events = NULL;
754 se->events_tail = &se->events; 755 se->events_tail = &se->events;
755 se->stamp = stamp; 756 se->stamp = stamp;
756 757
757 pthread_cond_init(&se->special_event_cond, 0); 758 pthread_cond_init(&se->special_event_cond, 0);
758 759
759 se->next = c->in.special_events; 760 se->next = c->in.special_events;
760 c->in.special_events = se; 761 c->in.special_events = se;
761 pthread_mutex_unlock(&c->iolock); 762 pthread_mutex_unlock(&c->iolock);
762 return se; 763 return se;