00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __XCBINT_H
00029 #define __XCBINT_H
00030
00031 #include "bigreq.h"
00032
00033 #ifdef HAVE_CONFIG_H
00034 #include "config.h"
00035 #endif
00036
00037 #ifdef GCC_HAS_VISIBILITY
00038 #pragma GCC visibility push(hidden)
00039 #endif
00040
00041 enum workarounds {
00042 WORKAROUND_NONE,
00043 WORKAROUND_GLX_GET_FB_CONFIGS_BUG,
00044 WORKAROUND_EXTERNAL_SOCKET_OWNER
00045 };
00046
00047 enum lazy_reply_tag
00048 {
00049 LAZY_NONE = 0,
00050 LAZY_COOKIE,
00051 LAZY_FORCED
00052 };
00053
00054 #define XCB_PAD(i) (-(i) & 3)
00055
00056 #define XCB_SEQUENCE_COMPARE(a,op,b) ((int64_t) ((a) - (b)) op 0)
00057 #define XCB_SEQUENCE_COMPARE_32(a,op,b) (((int) (a) - (int) (b)) op 0)
00058
00059 #ifndef offsetof
00060 #define offsetof(type,member) ((size_t) &((type *)0)->member)
00061 #endif
00062
00063 #define container_of(pointer,type,member) ((type *)(((char *)(pointer)) - offsetof(type, member)))
00064
00065
00066
00067 typedef void (*xcb_list_free_func_t)(void *);
00068
00069 typedef struct _xcb_map _xcb_map;
00070
00071 _xcb_map *_xcb_map_new(void);
00072 void _xcb_map_delete(_xcb_map *q, xcb_list_free_func_t do_free);
00073 int _xcb_map_put(_xcb_map *q, unsigned int key, void *data);
00074 void *_xcb_map_remove(_xcb_map *q, unsigned int key);
00075
00076
00077
00078
00079 typedef struct _xcb_out {
00080 pthread_cond_t cond;
00081 int writing;
00082
00083 pthread_cond_t socket_cond;
00084 void (*return_socket)(void *closure);
00085 void *socket_closure;
00086 int socket_moving;
00087
00088 char queue[XCB_QUEUE_BUFFER_SIZE];
00089 int queue_len;
00090
00091 uint64_t request;
00092 uint64_t request_written;
00093
00094 pthread_mutex_t reqlenlock;
00095 enum lazy_reply_tag maximum_request_length_tag;
00096 union {
00097 xcb_big_requests_enable_cookie_t cookie;
00098 uint32_t value;
00099 } maximum_request_length;
00100 } _xcb_out;
00101
00102 int _xcb_out_init(_xcb_out *out);
00103 void _xcb_out_destroy(_xcb_out *out);
00104
00105 int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count);
00106 int _xcb_out_flush_to(xcb_connection_t *c, uint64_t request);
00107
00108
00109
00110
00111 typedef struct _xcb_in {
00112 pthread_cond_t event_cond;
00113 int reading;
00114
00115 char queue[4096];
00116 int queue_len;
00117
00118 uint64_t request_expected;
00119 uint64_t request_read;
00120 uint64_t request_completed;
00121 struct reply_list *current_reply;
00122 struct reply_list **current_reply_tail;
00123
00124 _xcb_map *replies;
00125 struct event_list *events;
00126 struct event_list **events_tail;
00127 struct reader_list *readers;
00128
00129 struct pending_reply *pending_replies;
00130 struct pending_reply **pending_replies_tail;
00131 } _xcb_in;
00132
00133 int _xcb_in_init(_xcb_in *in);
00134 void _xcb_in_destroy(_xcb_in *in);
00135
00136 int _xcb_in_expect_reply(xcb_connection_t *c, uint64_t request, enum workarounds workaround, int flags);
00137 void _xcb_in_replies_done(xcb_connection_t *c);
00138
00139 int _xcb_in_read(xcb_connection_t *c);
00140 int _xcb_in_read_block(xcb_connection_t *c, void *buf, int nread);
00141
00142
00143
00144
00145 typedef struct _xcb_xid {
00146 pthread_mutex_t lock;
00147 uint32_t last;
00148 uint32_t base;
00149 uint32_t max;
00150 uint32_t inc;
00151 } _xcb_xid;
00152
00153 int _xcb_xid_init(xcb_connection_t *c);
00154 void _xcb_xid_destroy(xcb_connection_t *c);
00155
00156
00157
00158
00159 typedef struct _xcb_ext {
00160 pthread_mutex_t lock;
00161 struct lazyreply *extensions;
00162 int extensions_size;
00163 } _xcb_ext;
00164
00165 int _xcb_ext_init(xcb_connection_t *c);
00166 void _xcb_ext_destroy(xcb_connection_t *c);
00167
00168
00169
00170
00171 struct xcb_connection_t {
00172 int has_error;
00173
00174
00175 xcb_setup_t *setup;
00176 int fd;
00177
00178
00179 pthread_mutex_t iolock;
00180 _xcb_in in;
00181 _xcb_out out;
00182
00183
00184 _xcb_ext ext;
00185 _xcb_xid xid;
00186 };
00187
00188 void _xcb_conn_shutdown(xcb_connection_t *c);
00189 int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count);
00190
00191
00192
00193
00194 int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display);
00195
00196 #ifdef GCC_HAS_VISIBILITY
00197 #pragma GCC visibility pop
00198 #endif
00199
00200 #endif