2 * Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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 * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
19 * 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.
22 * Except as contained in this notice, the names of the authors or their
23 * institutions shall not be used in advertising or otherwise to promote the
24 * sale, use or other dealings in this Software without prior written
25 * authorization from the authors.
37 #ifdef GCC_HAS_VISIBILITY
38 #pragma GCC visibility push(hidden)
43 WORKAROUND_GLX_GET_FB_CONFIGS_BUG,
44 WORKAROUND_EXTERNAL_SOCKET_OWNER
54 #define XCB_PAD(i) (-(i) & 3)
56 #define XCB_SEQUENCE_COMPARE(a,op,b) ((int64_t) ((a) - (b)) op 0)
57 #define XCB_SEQUENCE_COMPARE_32(a,op,b) (((int) (a) - (int) (b)) op 0)
60 #define offsetof(type,member) ((size_t) &((type *)0)->member)
63 #define container_of(pointer,type,member) ((type *)(((char *)(pointer)) - offsetof(type, member)))
67 typedef void (*xcb_list_free_func_t)(void *);
69 typedef struct _xcb_map _xcb_map;
71 _xcb_map *_xcb_map_new(void);
72 void _xcb_map_delete(_xcb_map *q, xcb_list_free_func_t do_free);
73 int _xcb_map_put(_xcb_map *q, unsigned int key, void *data);
74 void *_xcb_map_remove(_xcb_map *q, unsigned int key);
79 typedef struct _xcb_out {
83 pthread_cond_t socket_cond;
84 void (*return_socket)(void *closure);
88 char queue[XCB_QUEUE_BUFFER_SIZE];
92 uint64_t request_written;
94 pthread_mutex_t reqlenlock;
95 enum lazy_reply_tag maximum_request_length_tag;
97 xcb_big_requests_enable_cookie_t cookie;
99 } maximum_request_length;
102 int _xcb_out_init(_xcb_out *out);
103 void _xcb_out_destroy(_xcb_out *out);
105 int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count);
106 int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request);
111 typedef struct _xcb_in {
112 pthread_cond_t event_cond;
118 uint64_t request_expected;
119 uint64_t request_read;
120 uint64_t request_completed;
121 struct reply_list *current_reply;
122 struct reply_list **current_reply_tail;
125 struct event_list *events;
126 struct event_list **events_tail;
127 struct reader_list *readers;
129 struct pending_reply *pending_replies;
130 struct pending_reply **pending_replies_tail;
133 int _xcb_in_init(_xcb_in *in);
134 void _xcb_in_destroy(_xcb_in *in);
136 int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds workaround, int flags);
137 void _xcb_in_replies_done(xcb_connection_t *c);
139 int _xcb_in_read(xcb_connection_t *c);
140 int _xcb_in_read_block(xcb_connection_t *c, void *buf, int nread);
145 typedef struct _xcb_xid {
146 pthread_mutex_t lock;
153 int _xcb_xid_init(xcb_connection_t *c);
154 void _xcb_xid_destroy(xcb_connection_t *c);
159 typedef struct _xcb_ext {
160 pthread_mutex_t lock;
161 struct lazyreply *extensions;
165 int _xcb_ext_init(xcb_connection_t *c);
166 void _xcb_ext_destroy(xcb_connection_t *c);
171 struct xcb_connection_t {
179 pthread_mutex_t iolock;
188 void _xcb_conn_shutdown(xcb_connection_t *c);
189 int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count);
194 int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display);
196 #ifdef GCC_HAS_VISIBILITY
197 #pragma GCC visibility pop