The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

build,a/{os,util},xrt,ipc: Fix compilation with Mingw64 on MSYS2

Main changes:
- use the pthread lib provided by Mingw64
- include windows.h where needed
- define XRT_ENV_MINGW

authored by

sdegrande and committed by
Ryan Pavlik
2f3f9e0c eab742ad

+31 -10
+5 -4
CMakeLists.txt
··· 114 114 find_package(OpenGLES MODULE COMPONENTS V3) 115 115 find_library(RT_LIBRARY rt) 116 116 endif() 117 - if(NOT ANDROID AND NOT WIN32) 117 + if(NOT ANDROID AND NOT MSVC) 118 118 find_package(PkgConfig MODULE) 119 119 endif() 120 120 if(ANDROID) 121 121 find_library(ANDROID_LIBRARY android) 122 122 find_library(ANDROID_LOG_LIBRARY log) 123 123 endif() 124 - if(WIN32) 124 + if(MSVC) 125 125 find_package(wil CONFIG) 126 126 find_library(D3D11_LIBRARY d3d11) 127 127 find_library(D3D12_LIBRARY d3d12) ··· 133 133 find_package(Sanitizers MODULE) 134 134 135 135 add_library(xrt-pthreads INTERFACE) 136 - if(WIN32) 136 + if(MSVC) 137 137 find_package(pthreads_windows REQUIRED) 138 138 target_link_libraries(xrt-pthreads INTERFACE PThreads4W::PThreads4W_CXXEXC) 139 139 else() ··· 173 173 find_package(OpenGL COMPONENTS GLX) 174 174 pkg_search_module(DBUS dbus-1) 175 175 pkg_search_module(LIBBSD libbsd) 176 + endif() 176 177 178 + if(XRT_HAVE_LINUX OR MINGW) 177 179 pkg_check_modules(GST gstreamer-1.0 gstreamer-app-1.0 gstreamer-video-1.0) 178 - 179 180 pkg_check_modules(SURVIVE IMPORTED_TARGET survive) 180 181 endif() 181 182
+2 -2
src/xrt/auxiliary/os/os_threading.h
··· 17 17 18 18 #include "os/os_time.h" 19 19 20 - #if defined(XRT_OS_LINUX) 20 + #if defined(XRT_OS_LINUX) || defined(XRT_ENV_MINGW) 21 21 #include <pthread.h> 22 22 #include <semaphore.h> 23 23 #include <assert.h> ··· 333 333 static inline int 334 334 os_semaphore_get_realtime_clock(struct timespec *ts, uint64_t timeout_ns) 335 335 { 336 - #if defined(XRT_OS_WINDOWS) 336 + #if defined(XRT_OS_WINDOWS) && !defined(XRT_ENV_MINGW) 337 337 struct timespec relative; 338 338 os_ns_to_timespec(timeout_ns, &relative); 339 339 pthread_win32_getabstime_np(ts, &relative);
+11 -2
src/xrt/auxiliary/os/os_time.h
··· 29 29 #define XRT_HAVE_TIMEVAL 30 30 31 31 #elif defined(XRT_OS_WINDOWS) 32 + #if defined(XRT_ENV_MINGW) 33 + // That define is needed before to include windows.h, to avoid a collision 34 + // between the 'byte' type defined by windows and std::byte defined in cstddef 35 + // since C++17 36 + #define byte win_byte_override 37 + #include <windows.h> 38 + #undef byte 39 + #endif 40 + 32 41 #include <time.h> 33 42 #include <timeapi.h> 34 43 #define XRT_HAVE_TIMESPEC ··· 162 171 * @ingroup aux_os_time 163 172 */ 164 173 static inline int64_t 165 - os_ns_per_qpc_tick_get(); 174 + os_ns_per_qpc_tick_get(void); 166 175 #endif 167 176 168 177 ··· 273 282 274 283 #if defined(XRT_OS_WINDOWS) 275 284 static inline int64_t 276 - os_ns_per_qpc_tick_get() 285 + os_ns_per_qpc_tick_get(void) 277 286 { 278 287 static int64_t ns_per_qpc_tick = 0; 279 288 if (ns_per_qpc_tick == 0) {
+1 -1
src/xrt/auxiliary/util/u_file.c
··· 17 17 #include <string.h> 18 18 19 19 20 - #ifdef XRT_OS_WINDOWS 20 + #if defined(XRT_OS_WINDOWS) && !defined(XRT_ENV_MINGW) 21 21 #define PATH_MAX MAX_PATH 22 22 #endif 23 23
+8
src/xrt/auxiliary/util/u_time.h
··· 22 22 #include <stdint.h> 23 23 #include <time.h> 24 24 25 + #if defined(XRT_ENV_MINGW) 26 + // That define is needed before to include windows.h, to avoid a collision 27 + // between the 'byte' type defined by windows and std::byte defined in cstddef 28 + // since C++17 29 + #define byte win_byte_override 30 + #include <windows.h> 31 + #undef byte 32 + #endif 25 33 26 34 #ifdef __cplusplus 27 35 extern "C" {
+3
src/xrt/include/xrt/xrt_config_os.h
··· 34 34 #define XRT_OS_WAS_AUTODETECTED 35 35 #endif 36 36 37 + #if defined(__MINGW32__) 38 + #define XRT_ENV_MINGW 39 + #endif 37 40 38 41 #ifndef XRT_OS_WAS_AUTODETECTED 39 42 #error "OS type not found during compile"
+1 -1
src/xrt/ipc/shared/ipc_protocol.h
··· 42 42 // example: v21.0.0-560-g586d33b5 43 43 #define IPC_VERSION_NAME_LEN 64 44 44 45 - #ifdef XRT_OS_WINDOWS 45 + #if defined(XRT_OS_WINDOWS) && !defined(XRT_ENV_MINGW) 46 46 typedef int pid_t; 47 47 #endif 48 48