Some fixes for MinGW

* Rename Windows.h uses to windows.h
  * Comment out structured exception handling usage

Makes MinGW happier. Mostly the same as previous work by
Nicolas Dufresne <nicolas.dufresne@collabora.com>, with the exception
that we now don't try to invoke RaiseException which would fail in MinGW
as it raises a Windows structured exception.
This commit is contained in:
Arun Raghavan 2021-06-18 18:40:32 -04:00
parent 57ec282d4f
commit ff85c98683
4 changed files with 6 additions and 2 deletions

View File

@ -105,6 +105,8 @@ elif host_system == 'linux'
have_posix = true have_posix = true
elif host_system == 'windows' elif host_system == 'windows'
platform_cflags += ['-DWEBRTC_WIN', '-D_WIN32', '-U__STRICT_ANSI__'] platform_cflags += ['-DWEBRTC_WIN', '-D_WIN32', '-U__STRICT_ANSI__']
# this one is for MinGW to get format specifiers from inttypes.h in C++
platform_cflags += ['-D__STDC_FORMAT_MACROS=1']
os_deps += [cc.find_library('winmm')] os_deps += [cc.find_library('winmm')]
have_win = true have_win = true
endif endif

View File

@ -99,11 +99,13 @@ void SetCurrentThreadName(const char* name) {
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 6320 6322) #pragma warning(disable : 6320 6322)
#ifndef __MINGW32__
__try { __try {
::RaiseException(0x406D1388, 0, sizeof(threadname_info) / sizeof(ULONG_PTR), ::RaiseException(0x406D1388, 0, sizeof(threadname_info) / sizeof(ULONG_PTR),
reinterpret_cast<ULONG_PTR*>(&threadname_info)); reinterpret_cast<ULONG_PTR*>(&threadname_info));
} __except (EXCEPTION_EXECUTE_HANDLER) { // NOLINT } __except (EXCEPTION_EXECUTE_HANDLER) { // NOLINT
} }
#endif
#pragma warning(pop) #pragma warning(pop)
#elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID) #elif defined(WEBRTC_LINUX) || defined(WEBRTC_ANDROID)
prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(name)); // NOLINT prctl(PR_SET_NAME, reinterpret_cast<unsigned long>(name)); // NOLINT

View File

@ -11,7 +11,7 @@
#ifndef RTC_BASE_SYNCHRONIZATION_RW_LOCK_WIN_H_ #ifndef RTC_BASE_SYNCHRONIZATION_RW_LOCK_WIN_H_
#define RTC_BASE_SYNCHRONIZATION_RW_LOCK_WIN_H_ #define RTC_BASE_SYNCHRONIZATION_RW_LOCK_WIN_H_
#include <Windows.h> #include <windows.h>
#include "rtc_base/synchronization/rw_lock_wrapper.h" #include "rtc_base/synchronization/rw_lock_wrapper.h"

View File

@ -14,7 +14,7 @@
#include <cerrno> #include <cerrno>
#ifdef _WIN32 #ifdef _WIN32
#include <Windows.h> #include <windows.h>
#else #else
#include <string.h> #include <string.h>
#endif #endif