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);