xcbint.h

00001 /*
00002  * Copyright (C) 2001-2004 Bart Massey and Jamey Sharp.
00003  * All Rights Reserved.
00004  *
00005  * Permission is hereby granted, free of charge, to any person obtaining a
00006  * copy of this software and associated documentation files (the "Software"),
00007  * to deal in the Software without restriction, including without limitation
00008  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00009  * and/or sell copies of the Software, and to permit persons to whom the
00010  * Software is furnished to do so, subject to the following conditions:
00011  * 
00012  * The above copyright notice and this permission notice shall be included in
00013  * all copies or substantial portions of the Software.
00014  * 
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018  * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
00019  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00020  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00021  * 
00022  * Except as contained in this notice, the names of the authors or their
00023  * institutions shall not be used in advertising or otherwise to promote the
00024  * sale, use or other dealings in this Software without prior written
00025  * authorization from the authors.
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 };
00045 
00046 enum lazy_reply_tag
00047 {
00048     LAZY_NONE = 0,
00049     LAZY_COOKIE,
00050     LAZY_FORCED
00051 };
00052 
00053 #define XCB_PAD(i) (-(i) & 3)
00054 
00055 #define XCB_SEQUENCE_COMPARE(a,op,b)    ((int) ((a) - (b)) op 0)
00056 
00057 /* xcb_list.c */
00058 
00059 typedef void (*xcb_list_free_func_t)(void *);
00060 
00061 typedef struct _xcb_map _xcb_map;
00062 
00063 _xcb_map *_xcb_map_new(void);
00064 void _xcb_map_delete(_xcb_map *q, xcb_list_free_func_t do_free);
00065 int _xcb_map_put(_xcb_map *q, unsigned int key, void *data);
00066 void *_xcb_map_remove(_xcb_map *q, unsigned int key);
00067 
00068 
00069 /* xcb_out.c */
00070 
00071 typedef struct _xcb_out {
00072     pthread_cond_t cond;
00073     int writing;
00074 
00075     char queue[4096];
00076     int queue_len;
00077 
00078     unsigned int request;
00079     unsigned int request_written;
00080 
00081     pthread_mutex_t reqlenlock;
00082     enum lazy_reply_tag maximum_request_length_tag;
00083     union {
00084         xcb_big_requests_enable_cookie_t cookie;
00085         uint32_t value;
00086     } maximum_request_length;
00087 } _xcb_out;
00088 
00089 int _xcb_out_init(_xcb_out *out);
00090 void _xcb_out_destroy(_xcb_out *out);
00091 
00092 int _xcb_out_send(xcb_connection_t *c, struct iovec **vector, int *count);
00093 int _xcb_out_flush_to(xcb_connection_t *c, unsigned int request);
00094 
00095 
00096 /* xcb_in.c */
00097 
00098 typedef struct _xcb_in {
00099     pthread_cond_t event_cond;
00100     int reading;
00101 
00102     char queue[4096];
00103     int queue_len;
00104 
00105     unsigned int request_expected;
00106     unsigned int request_read;
00107     unsigned int request_completed;
00108     struct reply_list *current_reply;
00109     struct reply_list **current_reply_tail;
00110 
00111     _xcb_map *replies;
00112     struct event_list *events;
00113     struct event_list **events_tail;
00114     struct reader_list *readers;
00115 
00116     struct pending_reply *pending_replies;
00117     struct pending_reply **pending_replies_tail;
00118 } _xcb_in;
00119 
00120 int _xcb_in_init(_xcb_in *in);
00121 void _xcb_in_destroy(_xcb_in *in);
00122 
00123 int _xcb_in_expect_reply(xcb_connection_t *c, unsigned int request, enum workarounds workaround, int flags);
00124 
00125 int _xcb_in_read(xcb_connection_t *c);
00126 int _xcb_in_read_block(xcb_connection_t *c, void *buf, int nread);
00127 
00128 
00129 /* xcb_xlib.c */
00130 
00131 typedef struct _xcb_xlib {
00132     int lock;
00133     pthread_t thread;
00134     pthread_cond_t cond;
00135 } _xcb_xlib;
00136 
00137 
00138 /* xcb_xid.c */
00139 
00140 typedef struct _xcb_xid {
00141     pthread_mutex_t lock;
00142     uint32_t last;
00143     uint32_t base;
00144     uint32_t max;
00145     uint32_t inc;
00146 } _xcb_xid;
00147 
00148 int _xcb_xid_init(xcb_connection_t *c);
00149 void _xcb_xid_destroy(xcb_connection_t *c);
00150 
00151 
00152 /* xcb_ext.c */
00153 
00154 typedef struct _xcb_ext {
00155     pthread_mutex_t lock;
00156     struct lazyreply *extensions;
00157     int extensions_size;
00158 } _xcb_ext;
00159 
00160 int _xcb_ext_init(xcb_connection_t *c);
00161 void _xcb_ext_destroy(xcb_connection_t *c);
00162 
00163 
00164 /* xcb_conn.c */
00165 
00166 struct xcb_connection_t {
00167     int has_error;
00168 
00169     /* constant data */
00170     xcb_setup_t *setup;
00171     int fd;
00172 
00173     /* I/O data */
00174     pthread_mutex_t iolock;
00175     _xcb_xlib xlib;
00176     _xcb_in in;
00177     _xcb_out out;
00178 
00179     /* misc data */
00180     _xcb_ext ext;
00181     _xcb_xid xid;
00182 };
00183 
00184 void _xcb_conn_shutdown(xcb_connection_t *c);
00185 int _xcb_conn_wait(xcb_connection_t *c, pthread_cond_t *cond, struct iovec **vector, int *count);
00186 
00187 
00188 /* xcb_auth.c */
00189 
00190 int _xcb_get_auth_info(int fd, xcb_auth_info_t *info, int display);
00191 
00192 #ifdef GCC_HAS_VISIBILITY
00193 #pragma GCC visibility pop
00194 #endif
00195 
00196 
00197 /* xcb_conn.c symbols visible to xcb-xlib */
00198 
00199 void _xcb_lock_io(xcb_connection_t *c);
00200 void _xcb_unlock_io(xcb_connection_t *c);
00201 
00202 #endif

Generated on Sat Sep 1 20:18:55 2007 for XCB by  doxygen 1.5.2