Fixed build.

This commit is contained in:
Бранимир Караџић
2020-09-03 23:26:47 -07:00
parent 5d286a29e0
commit 3c49d305e5
5 changed files with 29 additions and 9 deletions

View File

@@ -38,12 +38,9 @@ namespace bx
template<class Ty>
constexpr bool isTriviallyCopyable();
///
typedef void (*AnyFn)(void);
///
template<typename ProtoT>
constexpr ProtoT functionCast(AnyFn _fn);
constexpr ProtoT functionCast(void* _fn);
/// Swap two values.
template<typename Ty>

View File

@@ -34,7 +34,7 @@ namespace bx
}
template<typename ProtoT>
inline constexpr ProtoT functionCast(AnyFn _fn)
inline constexpr ProtoT functionCast(void* _fn)
{
return reinterpret_cast<ProtoT>(_fn);
}

18
include/bx/inline/os.inl Normal file
View File

@@ -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<typename ProtoT>
inline ProtoT dlsym(void* _handle, const StringView& _symbol)
{
return reinterpret_cast<ProtoT>(dlsym(_handle, _symbol) );
}
} // namespace bx

View File

@@ -40,6 +40,10 @@ namespace bx
///
void* dlsym(void* _handle, const StringView& _symbol);
///
template<typename ProtoT>
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

View File

@@ -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<SetThreadDescriptionProc>(
dlsym(GetModuleHandleA("Kernel32.dll"), "SetThreadDescription")
);
if (SetThreadDescription)
SetThreadDescriptionProc SetThreadDescription = dlsym<SetThreadDescriptionProc>((void*)GetModuleHandleA("Kernel32.dll"), "SetThreadDescription");
if (NULL != SetThreadDescription)
{
uint32_t length = (uint32_t)bx::strLen(_name)+1;
uint32_t size = length*sizeof(wchar_t);