XCB 1.17.0
xcbint.h
1/*
2 * Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
3 * All Rights Reserved.
4 *
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:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
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.
21 *
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.
26 */
27
28#ifndef __XCBINT_H
29#define __XCBINT_H
30
31#include "bigreq.h"
32
33#ifdef HAVE_CONFIG_H
34#include "config.h"
35#endif
36
37#ifdef GCC_HAS_VISIBILITY
38#pragma GCC visibility push(hidden)
39#endif
40
41#ifndef __has_attribute
42# define __has_attribute(x) 0 /* Compatibility with older compilers. */
43#endif
44
45#if __has_attribute(fallthrough)
46# define XCB_ALLOW_FALLTHRU __attribute__ ((fallthrough));
47#else
48# define XCB_ALLOW_FALLTHRU /* FALLTHRU */
49#endif
50
51enum workarounds {
52 WORKAROUND_NONE,
53 WORKAROUND_GLX_GET_FB_CONFIGS_BUG,
54 WORKAROUND_EXTERNAL_SOCKET_OWNER
55};
56
57enum lazy_reply_tag
58{
59 LAZY_NONE = 0,
60 LAZY_COOKIE,
61 LAZY_FORCED
62};
63
64#define XCB_PAD(i) (-(i) & 3)
65
66#define XCB_SEQUENCE_COMPARE(a,op,b) ((int64_t) ((a) - (b)) op 0)
67
68#ifndef offsetof
69#define offsetof(type,member) ((size_t) &((type *)0)->member)
70#endif
71
72#ifndef MIN
73#define MIN(x,y) ((x) < (y) ? (x) : (y))
74#endif
75
76#define container_of(pointer,type,member) ((type *)(((char *)(pointer)) - offsetof(type, member)))
77
78/* xcb_list.c */
79
80typedef void (*xcb_list_free_func_t)(void *);
81
82typedef struct _xcb_map _xcb_map;
83
84_xcb_map *_xcb_map_new(void);
85void _xcb_map_delete(_xcb_map *q, xcb_list_free_func_t do_free);
86int _xcb_map_put(_xcb_map *q, uint64_t key, void *data);
87void *_xcb_map_remove(_xcb_map *q, uint64_t key);
88
89
90/* xcb_out.c */
91
92#if HAVE_SENDMSG
93#define XCB_MAX_PASS_FD 16
94
95typedef struct _xcb_fd {
96 int fd[XCB_MAX_PASS_FD];
97 int nfd;
98 int ifd;
99} _xcb_fd;
100#endif
101
102typedef struct _xcb_out {
103 pthread_cond_t cond;
104 int writing;
105
106 pthread_cond_t socket_cond;
107 void (*return_socket)(void *closure);
108 void *socket_closure;
109 int socket_moving;
110
111 char queue[XCB_QUEUE_BUFFER_SIZE];
112 int queue_len;
113
114 uint64_t request;
115 uint64_t request_written;
116 uint64_t request_expected_written;
117 uint64_t total_written;
118
119 pthread_mutex_t reqlenlock;
120 enum lazy_reply_tag maximum_request_length_tag;
121 union {
123 uint32_t value;
124 } maximum_request_length;
125#if HAVE_SENDMSG
126 _xcb_fd out_fd;
127#endif
128} _xcb_out;
129
130int _xcb_out_init(_xcb_out *out);
131void _xcb_out_destroy(_xcb_out *out);
132
133int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count);
134void _xcb_out_send_sync(xcb_connection_t *c);
135int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request);
136
137
138/* xcb_in.c */
139
140typedef struct _xcb_in {
141 pthread_cond_t event_cond;
142 int reading;
143
144 char queue[4096];
145 int queue_len;
146
147 uint64_t request_expected;
148 uint64_t request_read;
149 uint64_t request_completed;
150 uint64_t total_read;
151 struct reply_list *current_reply;
152 struct reply_list **current_reply_tail;
153
154 _xcb_map *replies;
155 struct event_list *events;
156 struct event_list **events_tail;
157 struct reader_list *readers;
158 struct special_list *special_waiters;
159
160 struct pending_reply *pending_replies;
161 struct pending_reply **pending_replies_tail;
162#if HAVE_SENDMSG
163 _xcb_fd in_fd;
164#endif
165 struct xcb_special_event *special_events;
166} _xcb_in;
167
168int _xcb_in_init(_xcb_in *in);
169void _xcb_in_destroy(_xcb_in *in);
170
171void _xcb_in_wake_up_next_reader(xcb_connection_t *c);
172
173int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds workaround, int flags);
174void _xcb_in_replies_done(xcb_connection_t *c);
175
176int _xcb_in_read(xcb_connection_t *c);
177int _xcb_in_read_block(xcb_connection_t *c, void *buf, int nread);
178
179
180/* xcb_xid.c */
181
182typedef struct _xcb_xid {
183 pthread_mutex_t lock;
184 uint32_t last;
185 uint32_t base;
186 uint32_t max;
187 uint32_t inc;
188} _xcb_xid;
189
190int _xcb_xid_init(xcb_connection_t *c);
191void _xcb_xid_destroy(xcb_connection_t *c);
192
193
194/* xcb_ext.c */
195
196typedef struct _xcb_ext {
197 pthread_mutex_t lock;
198 struct lazyreply *extensions;
199 int extensions_size;
200} _xcb_ext;
201
202int _xcb_ext_init(xcb_connection_t *c);
203void _xcb_ext_destroy(xcb_connection_t *c);
204
205
206/* xcb_conn.c */
207
209 /* This must be the first field; see _xcb_conn_ret_error(). */
210 int has_error;
211
212 /* constant data */
213 xcb_setup_t *setup;
214 int fd;
215
216 /* I/O data */
217 pthread_mutex_t iolock;
218 _xcb_in in;
219 _xcb_out out;
220
221 /* misc data */
222 _xcb_ext ext;
223 _xcb_xid xid;
224};
225
226void _xcb_conn_shutdown(xcb_connection_t *c, int err);
227
228xcb_connection_t *_xcb_conn_ret_error(int err);
229
230int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count);
231
232
233/* xcb_auth.c */
234
235int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display);
236
237#ifdef GCC_HAS_VISIBILITY
238#pragma GCC visibility pop
239#endif
240
241#endif
Definition xcbint.h:196
Definition xcbint.h:140
Definition xcb_list.c:43
Definition xcbint.h:102
Definition xcbint.h:182
Definition xcb_in.c:59
Definition xcb_windefs.h:38
Definition xcb_ext.c:39
Definition xcb_in.c:86
Definition xcb_in.c:94
Definition xcb_in.c:81
Definition xcb_in.c:100
Container for authorization information.
Definition xcb.h:232
Definition xcbint.h:208
xcb_setup_t
Definition xproto.h:475
Definition xcb_in.c:64