From: Mikko Rasa Date: Sun, 26 Aug 2012 08:58:18 +0000 (+0300) Subject: Fix things for 64-bit systems X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;ds=inline;p=gldbg.git Fix things for 64-bit systems --- diff --git a/Makefile b/Makefile index 99486f9..ca938f2 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ DEPS_all := $(call deps,$(SOURCES_all) $(TEMPLATES)) $(OBJECTS_gldbg): CXXFLAGS += $(shell pkg-config --cflags $(PACKAGES_gldbg)) gldbg: LIBS += $(shell pkg-config --libs $(PACKAGES_gldbg)) -lreadline -lrt gldump gldbg: LIBS += ./libgldbg.a +$(OBJECTS_glwrap): CFLAGS += -fPIC glwrap.so: LDFLAGS += -s glwrap.so: LIBS += -ldl diff --git a/flavors/gl/gl.io b/flavors/gl/gl.io index b4bc0a5..f7ab981 100644 --- a/flavors/gl/gl.io +++ b/flavors/gl/gl.io @@ -9,8 +9,8 @@ int, int, %i uint, int, %u unsigned int, int, %u sizei, int, %i -intptr, int, %i -sizeiptr, int, %i +intptr, int, %i, (int) +sizeiptr, int, %i, (int) handle, int, %i int64, long long, %lli uint64, long long, %llu diff --git a/flavors/gl/source/glstate.cpp b/flavors/gl/source/glstate.cpp index fc355c7..9bfe7b5 100644 --- a/flavors/gl/source/glstate.cpp +++ b/flavors/gl/source/glstate.cpp @@ -442,7 +442,7 @@ void GlState::glBindBufferBase(void *user_data, GLenum target, unsigned index, u glBindBufferRange(user_data, target, index, id, 0, buffer->size); } -void GlState::glBindBufferRange(void *user_data, GLenum target, unsigned index, unsigned id, int offset, int size) +void GlState::glBindBufferRange(void *user_data, GLenum target, unsigned index, unsigned id, ptrdiff_t offset, ptrdiff_t size) { GlState *self = reinterpret_cast(user_data); if(BufferBindingState *binding = self->get_buffer_binding(target, index)) @@ -453,13 +453,13 @@ void GlState::glBindBufferRange(void *user_data, GLenum target, unsigned index, } } -void GlState::glBufferData(void *user_data, GLenum target, int size, const void *data, GLenum usage) +void GlState::glBufferData(void *user_data, GLenum target, ptrdiff_t size, const void *data, GLenum usage) { if(BufferState *buf = reinterpret_cast(user_data)->get_current_buffer(target)) buf->set_data(size, data, usage); } -void GlState::glBufferSubData(void *user_data, GLenum target, int offset, int size, const void *data) +void GlState::glBufferSubData(void *user_data, GLenum target, ptrdiff_t offset, ptrdiff_t size, const void *data) { if(BufferState *buf = reinterpret_cast(user_data)->get_current_buffer(target)) buf->set_sub_data(offset, size, data); diff --git a/flavors/gl/source/glstate.h b/flavors/gl/source/glstate.h index ae16deb..8cba1d2 100644 --- a/flavors/gl/source/glstate.h +++ b/flavors/gl/source/glstate.h @@ -123,9 +123,9 @@ private: static void glBindBuffer(void *, GLenum, unsigned); static void glBindBufferBase(void *, GLenum, unsigned, unsigned); - static void glBindBufferRange(void *, GLenum, unsigned, unsigned, int, int); - static void glBufferData(void *, GLenum, int, const void *, GLenum); - static void glBufferSubData(void *, GLenum, int, int, const void *); + static void glBindBufferRange(void *, GLenum, unsigned, unsigned, ptrdiff_t, ptrdiff_t); + static void glBufferData(void *, GLenum, ptrdiff_t, const void *, GLenum); + static void glBufferSubData(void *, GLenum, ptrdiff_t, ptrdiff_t, const void *); static void glDeleteBuffers(void *, int, const unsigned *); public: diff --git a/flavors/gl/source/inspector.cpp b/flavors/gl/source/inspector.cpp index b641b05..5db0d3d 100644 --- a/flavors/gl/source/inspector.cpp +++ b/flavors/gl/source/inspector.cpp @@ -189,12 +189,12 @@ void Inspector::cmd_texture(const string &args) if(args.empty()) { const map &textures = state.get_textures(); - printf("%d texture objects:\n", textures.size()); + printf("%lu texture objects:\n", textures.size()); for(map::const_iterator i = textures.begin(); i!=textures.end(); ++i) { const TextureState &tex = i->second; string descr = tex.describe(); - printf(" %d: %s, %d images\n", i->first, descr.c_str(), tex.images.size()); + printf(" %d: %s, %lu images\n", i->first, descr.c_str(), tex.images.size()); } } else @@ -246,7 +246,7 @@ void Inspector::cmd_buffer(const string &args) if(args.empty()) { const GlState::BufferMap &buffers = state.get_buffers(); - printf("%d buffers:\n", buffers.size()); + printf("%lu buffers:\n", buffers.size()); for(GlState::BufferMap::const_iterator i=buffers.begin(); i!=buffers.end(); ++i) { string descr = i->second.describe(); @@ -389,7 +389,7 @@ void Inspector::cmd_shader(const string &args) if(args.empty()) { const GlState::ShaderMap &shaders = state.get_shaders(); - printf("%d shader objects:\n", shaders.size()); + printf("%lu shader objects:\n", shaders.size()); for(GlState::ShaderMap::const_iterator i=shaders.begin(); i!=shaders.end(); ++i) { string descr = i->second.describe(); @@ -432,7 +432,7 @@ void Inspector::cmd_program(const std::string &args) if(args.empty()) { const GlState::ProgramMap &programs = state.get_programs(); - printf("%d program objects:\n", programs.size()); + printf("%lu program objects:\n", programs.size()); for(GlState::ProgramMap::const_iterator i=programs.begin(); i!=programs.end(); ++i) { string descr = i->second.describe(); diff --git a/source/commandinterpreter.cpp b/source/commandinterpreter.cpp index b8a10a9..3227d40 100644 --- a/source/commandinterpreter.cpp +++ b/source/commandinterpreter.cpp @@ -61,7 +61,7 @@ CommandInterpreter::~CommandInterpreter() void CommandInterpreter::execute(const string &cmd) { - unsigned space = cmd.find(' '); + string::size_type space = cmd.find(' '); string name = cmd.substr(0, space); CommandMap::const_iterator i = commands.lower_bound(name); if(i==commands.end() || i->first.compare(0, name.size(), name)) diff --git a/source/gldump.c b/source/gldump.c index 2b4c20b..ab79c39 100644 --- a/source/gldump.c +++ b/source/gldump.c @@ -40,7 +40,8 @@ int main(int argc, char **argv) ret = gldecoder_decode(dec, ptr, end-ptr); if(ret<0) { - fprintf(stderr, "Decode error with %d bytes left\n", end-ptr); + int bytes_left = end-ptr; + fprintf(stderr, "Decode error with %d bytes left\n", bytes_left); break; } ptr += ret; diff --git a/source/glprint.c b/source/glprint.c index 01883e8..21f7fe5 100644 --- a/source/glprint.c +++ b/source/glprint.c @@ -100,9 +100,14 @@ static const char *print_array(const char *fmt, const void *data, unsigned elem_ *ptr++ = ' '; } memcpy(&element, (const char *)data+i*elem_size, elem_size); - if(type>='e' && type<='g' && elem_size==sizeof(float)) - *(double *)&element = *(float *)&element; - len = snprintf(ptr, buf_size, fmt, element); + if(type>='e' && type<='g') + { + if(elem_size==sizeof(float)) + *(double *)&element = *(float *)&element; + len = snprintf(ptr, buf_size, fmt, *(double *)&element); + } + else + len = snprintf(ptr, buf_size, fmt, element); ptr += len; buf_size -= len; } diff --git a/source/glprint.funcs.t b/source/glprint.funcs.t index 047c9fa..111748e 100644 --- a/source/glprint.funcs.t +++ b/source/glprint.funcs.t @@ -38,7 +38,10 @@ for p in params+[ret]: elif p.type=="TextureComponentCount": w(', print_internal_format(%s)', p.name) elif len(p.io)>=3 and p.io[2]: - w(', %s(%s, "%s")', p.io[2], p.name, p.type) + if p.io[2][0]=='(': + w(', %s%s', p.io[2], p.name) + else: + w(', %s(%s, "%s")', p.io[2], p.name, p.type) else: w(', %s', p.name) elif p.kind=="reference" and not p.io: