XCB  1.9.3
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 enum workarounds {
42  WORKAROUND_NONE,
43  WORKAROUND_GLX_GET_FB_CONFIGS_BUG,
44  WORKAROUND_EXTERNAL_SOCKET_OWNER
45 };
46 
47 enum lazy_reply_tag
48 {
49  LAZY_NONE = 0,
50  LAZY_COOKIE,
51  LAZY_FORCED
52 };
53 
54 #define XCB_PAD(i) (-(i) & 3)
55 
56 #define XCB_SEQUENCE_COMPARE(a,op,b) ((int64_t) ((a) - (b)) op 0)
57 
58 #ifndef offsetof
59 #define offsetof(type,member) ((size_t) &((type *)0)->member)
60 #endif
61 
62 #ifndef MIN
63 #define MIN(x,y) ((x) < (y) ? (x) : (y))
64 #endif
65 
66 #define container_of(pointer,type,member) ((type *)(((char *)(pointer)) - offsetof(type, member)))
67 
68 /* xcb_list.c */
69 
70 typedef void (*xcb_list_free_func_t)(void *);
71 
72 typedef struct _xcb_map _xcb_map;
73 
74 _xcb_map *_xcb_map_new(void);
75 void _xcb_map_delete(_xcb_map *q, xcb_list_free_func_t do_free);
76 int _xcb_map_put(_xcb_map *q, unsigned int key, void *data);
77 void *_xcb_map_remove(_xcb_map *q, unsigned int key);
78 
79 
80 /* xcb_out.c */
81 
82 typedef void (*xcb_return_socket_func_t)(void *closure);
83 
84 #if HAVE_SENDMSG
85 #define XCB_MAX_PASS_FD 16
86 
87 typedef struct _xcb_fd {
88  int fd[XCB_MAX_PASS_FD];
89  int nfd;
90  int ifd;
91 } _xcb_fd;
92 #endif
93 
94 typedef struct _xcb_out {
95  pthread_cond_t cond;
96  int writing;
97 
98  pthread_cond_t socket_cond;
99  void (*return_socket)(void *closure);
100  void *socket_closure;
101  int socket_moving;
102 
103  char queue[XCB_QUEUE_BUFFER_SIZE];
104  int queue_len;
105 
106  uint64_t request;
107  uint64_t request_written;
108 
109  pthread_mutex_t reqlenlock;
110  enum lazy_reply_tag maximum_request_length_tag;
111  union {
113  uint32_t value;
114  } maximum_request_length;
115 #if HAVE_SENDMSG
116  _xcb_fd out_fd;
117 #endif
118 } _xcb_out;
119 
120 int _xcb_out_init(_xcb_out *out);
121 void _xcb_out_destroy(_xcb_out *out);
122 
123 int _xcb_out_send(xcb_connection_t *c, struct iovec *vector, int count);
124 void _xcb_out_send_sync(xcb_connection_t *c);
125 int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request);
126 
127 
128 /* xcb_in.c */
129 
130 typedef struct _xcb_in {
131  pthread_cond_t event_cond;
132  int reading;
133 
134  char queue[4096];
135  int queue_len;
136 
137  uint64_t request_expected;
138  uint64_t request_read;
139  uint64_t request_completed;
140  struct reply_list *current_reply;
141  struct reply_list **current_reply_tail;
142 
143  _xcb_map *replies;
144  struct event_list *events;
145  struct event_list **events_tail;
146  struct reader_list *readers;
147 
148  struct pending_reply *pending_replies;
149  struct pending_reply **pending_replies_tail;
150 #if HAVE_SENDMSG
151  _xcb_fd in_fd;
152 #endif
153  struct xcb_special_event *special_events;
154 } _xcb_in;
155 
156 int _xcb_in_init(_xcb_in *in);
157 void _xcb_in_destroy(_xcb_in *in);
158 
159 void _xcb_in_wake_up_next_reader(xcb_connection_t *c);
160 
161 int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds workaround, int flags);
162 void _xcb_in_replies_done(xcb_connection_t *c);
163 
164 int _xcb_in_read(xcb_connection_t *c);
165 int _xcb_in_read_block(xcb_connection_t *c, void *buf, int nread);
166 
167 
168 /* xcb_xid.c */
169 
170 typedef struct _xcb_xid {
171  pthread_mutex_t lock;
172  uint32_t last;
173  uint32_t base;
174  uint32_t max;
175  uint32_t inc;
176 } _xcb_xid;
177 
178 int _xcb_xid_init(xcb_connection_t *c);
179 void _xcb_xid_destroy(xcb_connection_t *c);
180 
181 
182 /* xcb_ext.c */
183 
184 typedef struct _xcb_ext {
185  pthread_mutex_t lock;
186  struct lazyreply *extensions;
187  int extensions_size;
188 } _xcb_ext;
189 
190 int _xcb_ext_init(xcb_connection_t *c);
191 void _xcb_ext_destroy(xcb_connection_t *c);
192 
193 
194 /* xcb_conn.c */
195 
197  int has_error;
198 
199  /* constant data */
200  xcb_setup_t *setup;
201  int fd;
202 
203  /* I/O data */
204  pthread_mutex_t iolock;
205  _xcb_in in;
206  _xcb_out out;
207 
208  /* misc data */
209  _xcb_ext ext;
210  _xcb_xid xid;
211 };
212 
213 void _xcb_conn_shutdown(xcb_connection_t *c, int err);
214 
215 xcb_connection_t *_xcb_conn_ret_error(int err);
216 
217 int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count);
218 
219 
220 /* xcb_auth.c */
221 
222 int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display);
223 
224 #ifdef GCC_HAS_VISIBILITY
225 #pragma GCC visibility pop
226 #endif
227 
228 #endif
Definition: xcbint.h:130
Definition: xcbint.h:184
Definition: xcbint.h:170
Definition: xcb_in.c:58
Definition: xcb_in.c:93
Definition: xcb_in.c:85
Definition: xcb_ext.c:39
Definition: xcb_windefs.h:38
Definition: xcb_in.c:63
Definition: xcbint.h:94
Definition: xcb_in.c:80
Definition: xcb_list.c:43
Definition: xcbint.h:196
xcb_setup_t
Definition: xproto.h:453
Container for authorization information.
Definition: xcb.h:194