X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fglwrap.c;h=10bfc77fcb12cd56f21149444593f8df57de8d52;hb=fab9ed5163a8f4ef5314bc67e48d1690d1126649;hp=4c17edfca772755f16a983253e96d37cf3ef0de6;hpb=4aba13fc7690cf79e949d9765b371e85e7530207;p=gldbg.git diff --git a/source/glwrap.c b/source/glwrap.c index 4c17edf..10bfc77 100644 --- a/source/glwrap.c +++ b/source/glwrap.c @@ -11,19 +11,16 @@ Distributed under the GPL #include #include #include -#include -#define INTERNAL __attribute__((visibility("internal"))) - -INTERNAL inline const char *get_lib_names(void) +static const char *get_lib_names(void) { const char *env = getenv("GLWRAP_LIBS"); if(env) return env; - return "libGL.so"; + return "libGL.so.1"; } -INTERNAL inline void *glsym(const char *name) +void *glsym(const char *name) { static void **gl_libs = NULL; unsigned i; @@ -77,117 +74,7 @@ INTERNAL inline void *glsym(const char *name) return NULL; } -INTERNAL char *buffer = 0; -INTERNAL char *write_pos; -INTERNAL struct iovec *iovecs = 0; -INTERNAL struct iovec *cur_vec; -INTERNAL unsigned length; - -INTERNAL inline void next_vec(void) -{ - if(write_pos!=cur_vec->iov_base) - { - cur_vec->iov_len = write_pos-(char *)cur_vec->iov_base; - length += cur_vec->iov_len; - ++cur_vec; - cur_vec->iov_base = write_pos; - } -} - -INTERNAL inline void write_bytes(const char *ptr, unsigned size) -{ - unsigned i; - for(i=0; iiov_base = (void *)data; - cur_vec->iov_len = size; - length += size; - ++cur_vec; - cur_vec->iov_base = write_pos; - } - else - write_int(0); -} - -INTERNAL inline void write_string(const char *s) -{ - write_data(s, strlen(s)+1); -} - -INTERNAL inline void write_string_array(const char **sa, unsigned size) -{ - unsigned i; - size /= sizeof(const char *); - write_int(size); - for(i=0; iiov_base = write_pos; - length = 0; - - write_int(0); - write_short(func); -} - -INTERNAL inline int get_out_fd(void) +int get_out_fd(void) { static int fd = -1; @@ -197,31 +84,21 @@ INTERNAL inline int get_out_fd(void) if(var) fd = strtol(var, NULL, 0); else - fd = 2; + { + var = getenv("GLWRAP_FILE"); + if(var) + { + fd = open(var, O_WRONLY|O_CREAT|O_TRUNC, 0644); + if(fd==-1) + { + fprintf(stderr, "Couldn't open dumpfile %s for output: %s", var, strerror(errno)); + abort(); + } + } + else + fd = 2; + } } return fd; } - -INTERNAL inline void send_partial_packet(void) -{ - next_vec(); - write_pos = buffer; - write_int(length|0x80000000); - writev(get_out_fd(), iovecs, cur_vec-iovecs); - - write_pos = buffer; - cur_vec = iovecs; - cur_vec->iov_base = write_pos; - length = 0; - - write_int(0); -} - -INTERNAL inline void send_packet(void) -{ - next_vec(); - write_pos = buffer; - write_int(length); - writev(get_out_fd(), iovecs, cur_vec-iovecs); -}