From 3c49d305e546bc9cf421e2afb9c4487170a3b7e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Thu, 3 Sep 2020 23:26:47 -0700 Subject: [PATCH] Fixed build. --- include/bx/bx.h | 5 +---- include/bx/inline/bx.inl | 2 +- include/bx/inline/os.inl | 18 ++++++++++++++++++ include/bx/os.h | 6 ++++++ src/thread.cpp | 7 +++---- 5 files changed, 29 insertions(+), 9 deletions(-) create mode 100644 include/bx/inline/os.inl diff --git a/include/bx/bx.h b/include/bx/bx.h index a3f592a..72b1691 100644 --- a/include/bx/bx.h +++ b/include/bx/bx.h @@ -38,12 +38,9 @@ namespace bx template constexpr bool isTriviallyCopyable(); - /// - typedef void (*AnyFn)(void); - /// template - constexpr ProtoT functionCast(AnyFn _fn); + constexpr ProtoT functionCast(void* _fn); /// Swap two values. template diff --git a/include/bx/inline/bx.inl b/include/bx/inline/bx.inl index 152084e..17e9b98 100644 --- a/include/bx/inline/bx.inl +++ b/include/bx/inline/bx.inl @@ -34,7 +34,7 @@ namespace bx } template - inline constexpr ProtoT functionCast(AnyFn _fn) + inline constexpr ProtoT functionCast(void* _fn) { return reinterpret_cast(_fn); } diff --git a/include/bx/inline/os.inl b/include/bx/inline/os.inl new file mode 100644 index 0000000..f4fb1e6 --- /dev/null +++ b/include/bx/inline/os.inl @@ -0,0 +1,18 @@ +/* + * Copyright 2010-2020 Branimir Karadzic. All rights reserved. + * License: https://github.com/bkaradzic/bx#license-bsd-2-clause + */ + +#ifndef BX_H_HEADER_GUARD +# error "Must be included from bx/os.h!" +#endif // BX_H_HEADER_GUARD + +namespace bx +{ + template + inline ProtoT dlsym(void* _handle, const StringView& _symbol) + { + return reinterpret_cast(dlsym(_handle, _symbol) ); + } + +} // namespace bx diff --git a/include/bx/os.h b/include/bx/os.h index 505d79a..f7a63f7 100644 --- a/include/bx/os.h +++ b/include/bx/os.h @@ -40,6 +40,10 @@ namespace bx /// void* dlsym(void* _handle, const StringView& _symbol); + /// + template + ProtoT dlsym(void* _handle, const StringView& _symbol); + /// bool getEnv(char* _out, uint32_t* _inOutSize, const StringView& _name); @@ -54,4 +58,6 @@ namespace bx } // namespace bx +#include "inline/os.inl" + #endif // BX_OS_H_HEADER_GUARD diff --git a/src/thread.cpp b/src/thread.cpp index ca7d0a4..f534b51 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -280,10 +280,9 @@ namespace bx #elif BX_PLATFORM_WINDOWS // Try to use the new thread naming API from Win10 Creators update onwards if we have it typedef HRESULT (WINAPI *SetThreadDescriptionProc)(HANDLE, PCWSTR); - SetThreadDescriptionProc SetThreadDescription = functionCast( - dlsym(GetModuleHandleA("Kernel32.dll"), "SetThreadDescription") - ); - if (SetThreadDescription) + SetThreadDescriptionProc SetThreadDescription = dlsym((void*)GetModuleHandleA("Kernel32.dll"), "SetThreadDescription"); + + if (NULL != SetThreadDescription) { uint32_t length = (uint32_t)bx::strLen(_name)+1; uint32_t size = length*sizeof(wchar_t);