ValveSoftware / vogl

OpenGL capture / playback debugger.
MIT License
1.42k stars 126 forks source link

32-bit compilation fails #197

Closed computerquip closed 10 months ago

computerquip commented 9 years ago

Output

[  2%] Built target pxfmt
[  2%] [  3%] Built target backtrace_testlib
Built target glxspheres
[  4%] Building CXX object src/voglcore/CMakeFiles/voglcore.dir/vogl_port_posix.cpp.o
/home/computerquip/Projects/vogl/src/voglcore/vogl_port_posix.cpp: In function ‘uint64_t plat_posix_gettid()’:
/home/computerquip/Projects/vogl/src/voglcore/vogl_port_posix.cpp:111:54: error: invalid cast from type ‘pthread_t {aka long unsigned int}’ to type ‘uintptr_t {aka unsigned int}’
     return reinterpret_cast<uintptr_t>(pthread_self());
                                                      ^
/home/computerquip/Projects/vogl/src/voglcore/vogl_port_posix.cpp:112:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
/home/computerquip/Projects/vogl/src/voglcore/vogl_port_posix.cpp: In function ‘void* plat_virtual_alloc(size_t, uint32_t, size_t*)’:
/home/computerquip/Projects/vogl/src/voglcore/vogl_port_posix.cpp:207:47: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
         write(STDERR_FILENO, buf, strlen(buf));
                                               ^
/home/computerquip/Projects/vogl/src/voglcore/vogl_port_posix.cpp: In function ‘void plat_virtual_free(void*, size_t)’:
/home/computerquip/Projects/vogl/src/voglcore/vogl_port_posix.cpp:231:47: warning: ignoring return value of ‘ssize_t write(int, const void*, size_t)’, declared with attribute warn_unused_result [-Wunused-result]
         write(STDERR_FILENO, buf, strlen(buf));
                                               ^
make[2]: *** [src/voglcore/CMakeFiles/voglcore.dir/vogl_port_posix.cpp.o] Error 1
make[1]: *** [src/voglcore/CMakeFiles/voglcore.dir/all] Error 2
make: *** [all] Error 2

I'm not fully aware of the goal of the code (nor am I familiar with the code at all) so a patch from me might be slow.

computerquip commented 9 years ago

It seems the use of pthread_getunique_np might be good here. I'll implement and provide a patch.

computerquip commented 9 years ago

Bah, BSD-specific. Never mind... will look into something else.

computerquip commented 9 years ago

So, there's a few more appropriate ways to go about this. One is to create your own map to provide a linear integral value that increases per thread lookup: https://gist.github.com/computerquip/ffc7ba7965930669ac4c

Another is to not use an integral value at all. The only thing that the thread ID is used for is... well... identification. We don't need integral values for that. Just returning a comparable type should work: https://gist.github.com/computerquip/34091bb40b4998450b18

Alternatively, we can try and force pthread_t to turn into an integral type which it might not be anyways and it might not fit into uintptr_t since it might not even be a pointer on platforms other than Linux: https://sourceware.org/ml/gdb-patches/2011-09/msg00328.html

Note that any of the above diffs aren't finalized code. It's just ideas on what might be a solution and both could probably be implemented better.

EDIT: Obligatory mention that perhaps threading shouldn't be in vogl_port.h but left to vogl_threading.h.

computerquip commented 9 years ago

Actually, solution #2 above won't work as pthread_t might not be comparable. pthread_equal must be used in this case....