From f8e0a05652e1fbccc92bd190a4d0d766d21fa630 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 10 Dec 2019 14:38:47 +0800 Subject: [PATCH 1/8] cross-platform define update --- src/Apple/Semaphore.cpp | 2 -- src/UNIX/CondVar.cpp | 14 +++++++------- src/UNIX/RWLock.cpp | 20 ++++++++++---------- src/UNIX/Semaphore.cpp | 20 ++++++++++---------- src/Win/CondVar.cpp | 12 ++++++------ src/Win/RWLock.cpp | 18 +++++++++--------- src/Win/Semaphore.cpp | 2 +- 7 files changed, 43 insertions(+), 45 deletions(-) diff --git a/src/Apple/Semaphore.cpp b/src/Apple/Semaphore.cpp index 7e0af7c..d4301aa 100644 --- a/src/Apple/Semaphore.cpp +++ b/src/Apple/Semaphore.cpp @@ -1,7 +1,5 @@ #include #include -#include -#include namespace hgl { diff --git a/src/UNIX/CondVar.cpp b/src/UNIX/CondVar.cpp index 395133c..320b76d 100644 --- a/src/UNIX/CondVar.cpp +++ b/src/UNIX/CondVar.cpp @@ -10,13 +10,13 @@ namespace hgl { cond_var=new pthread_cond_t; - pthread_cond_init((pthread_cond_t *)cond_var,nullptr); + pthread_cond_init(cond_var,nullptr); } CondVar::~CondVar() { - pthread_cond_destroy((pthread_cond_t *)cond_var); - delete (pthread_cond_t *)cond_var; + pthread_cond_destroy(cond_var); + delete cond_var; } bool CondVar::Wait(ThreadMutex *tm,double t) @@ -27,21 +27,21 @@ namespace hgl GetWaitTime(abstime,t); - return(!pthread_cond_timedwait((pthread_cond_t *)cond_var,tm->GetThreadMutex(),&abstime)); + return(!pthread_cond_timedwait(cond_var,tm->GetThreadMutex(),&abstime)); } else { - return(!pthread_cond_wait((pthread_cond_t *)cond_var,tm->GetThreadMutex())); + return(!pthread_cond_wait(cond_var,tm->GetThreadMutex())); } } void CondVar::Signal() { - pthread_cond_signal((pthread_cond_t *)cond_var); + pthread_cond_signal(cond_var); } void CondVar::Broadcast() { - pthread_cond_broadcast((pthread_cond_t *)cond_var); + pthread_cond_broadcast(cond_var); } }//namespace hgl diff --git a/src/UNIX/RWLock.cpp b/src/UNIX/RWLock.cpp index 26707ff..57c99a0 100644 --- a/src/UNIX/RWLock.cpp +++ b/src/UNIX/RWLock.cpp @@ -9,15 +9,15 @@ namespace hgl { lock=new pthread_rwlock_t; - pthread_rwlock_init((pthread_rwlock_t *)lock,nullptr); + pthread_rwlock_init(lock,nullptr); } RWLock::~RWLock() { - pthread_rwlock_destroy((pthread_rwlock_t *)lock); + pthread_rwlock_destroy(lock); } - bool RWLock::TryReadLock() {return !pthread_rwlock_tryrdlock((pthread_rwlock_t *)lock);} + bool RWLock::TryReadLock() {return !pthread_rwlock_tryrdlock(lock);} #if HGL_OS != HGL_OS_macOS bool RWLock::WaitReadLock(double t) @@ -26,14 +26,14 @@ namespace hgl GetWaitTime(abstime,t); - return !pthread_rwlock_timedrdlock((pthread_rwlock_t *)lock,&abstime); + return !pthread_rwlock_timedrdlock(lock,&abstime); } #endif//HGL_OS != HGL_OS_macOS - bool RWLock::ReadLock() {return !pthread_rwlock_rdlock((pthread_rwlock_t *)lock);} - bool RWLock::ReadUnlock() {return !pthread_rwlock_unlock((pthread_rwlock_t *)lock);} + bool RWLock::ReadLock() {return !pthread_rwlock_rdlock(lock);} + bool RWLock::ReadUnlock() {return !pthread_rwlock_unlock(lock);} - bool RWLock::TryWriteLock() {return !pthread_rwlock_trywrlock((pthread_rwlock_t *)lock);} + bool RWLock::TryWriteLock() {return !pthread_rwlock_trywrlock(lock);} #if HGL_OS != HGL_OS_macOS bool RWLock::WaitWriteLock(double t) @@ -42,10 +42,10 @@ namespace hgl GetWaitTime(abstime,t); - return !pthread_rwlock_timedwrlock((pthread_rwlock_t *)lock,&abstime); + return !pthread_rwlock_timedwrlock(lock,&abstime); } #endif//HGL_OS != HGL_OS_macOS - bool RWLock::WriteLock() {return !pthread_rwlock_wrlock((pthread_rwlock_t *)lock);} - bool RWLock::WriteUnlock() {return !pthread_rwlock_unlock((pthread_rwlock_t *)lock);} + bool RWLock::WriteLock() {return !pthread_rwlock_wrlock(lock);} + bool RWLock::WriteUnlock() {return !pthread_rwlock_unlock(lock);} }//namespace hgl diff --git a/src/UNIX/Semaphore.cpp b/src/UNIX/Semaphore.cpp index ea62c15..399acd7 100644 --- a/src/UNIX/Semaphore.cpp +++ b/src/UNIX/Semaphore.cpp @@ -14,10 +14,10 @@ namespace hgl { ptr=new sem_t; - if(sem_init((sem_t *)ptr,PTHREAD_PROCESS_PRIVATE,0)) + if(sem_init(ptr,PTHREAD_PROCESS_PRIVATE,0)) { LOG_ERROR(OS_TEXT("sem_init error,max_count=")+OSString(max_count)); - delete (sem_t *)ptr; + delete ptr; ptr=nullptr; } } @@ -26,8 +26,8 @@ namespace hgl { if(!ptr)return; - sem_destroy((sem_t *)ptr); - delete (sem_t *)ptr; + sem_destroy(ptr); + delete ptr; } /** @@ -43,14 +43,14 @@ namespace hgl int result=0; for(int i=0;iGetThreadMutex()),(DWORD)(time>0?time*1000:INFINITE)); + return SleepConditionVariableCS(cond_var,tm->GetThreadMutex(),(DWORD)(time>0?time*1000:INFINITE)); } bool CondVar::Wait(RWLock *lock, double time, bool read) { - return SleepConditionVariableSRW((CONDITION_VARIABLE *)cond_var,(SRWLOCK *)(lock->GetRWLock()),(DWORD)(time>0?time*1000:INFINITE),read?CONDITION_VARIABLE_LOCKMODE_SHARED:0); + return SleepConditionVariableSRW(cond_var,lock->GetRWLock(),(DWORD)(time>0?time*1000:INFINITE),read?CONDITION_VARIABLE_LOCKMODE_SHARED:0); } void CondVar::Signal() { - WakeConditionVariable((CONDITION_VARIABLE *)cond_var); + WakeConditionVariable(cond_var); } void CondVar::Broadcast() { - WakeAllConditionVariable((CONDITION_VARIABLE *)cond_var); + WakeAllConditionVariable(cond_var); } }//namespace hgl diff --git a/src/Win/RWLock.cpp b/src/Win/RWLock.cpp index 3a1018b..c05aa56 100644 --- a/src/Win/RWLock.cpp +++ b/src/Win/RWLock.cpp @@ -1,4 +1,4 @@ -#include +#include #pragma warning(disable:4800) // BOOL -> bool 性能损失警告 namespace hgl @@ -7,19 +7,19 @@ namespace hgl { lock = new SRWLOCK; - InitializeSRWLock((SRWLOCK *)lock); + InitializeSRWLock(lock); } RWLock::~RWLock() { - delete (SRWLOCK *)lock; + delete lock; } - bool RWLock::TryReadLock() { return TryAcquireSRWLockShared((SRWLOCK *)lock); } - bool RWLock::ReadLock() { AcquireSRWLockShared((SRWLOCK *)lock); return(true); } - bool RWLock::ReadUnlock() { ReleaseSRWLockShared((SRWLOCK *)lock); return(true); } + bool RWLock::TryReadLock(){ return TryAcquireSRWLockShared(lock); } + bool RWLock::ReadLock (){ AcquireSRWLockShared(lock); return(true); } + bool RWLock::ReadUnlock (){ ReleaseSRWLockShared(lock); return(true); } - bool RWLock::TryWriteLock() { return TryAcquireSRWLockExclusive((SRWLOCK *)lock); } - bool RWLock::WriteLock() { AcquireSRWLockExclusive((SRWLOCK *)lock); return(true); } - bool RWLock::WriteUnlock() { ReleaseSRWLockExclusive((SRWLOCK *)lock); return(true); } + bool RWLock::TryWriteLock (){ return TryAcquireSRWLockExclusive(lock); } + bool RWLock::WriteLock (){ AcquireSRWLockExclusive(lock); return(true); } + bool RWLock::WriteUnlock (){ ReleaseSRWLockExclusive(lock); return(true); } }//namespace hgl diff --git a/src/Win/Semaphore.cpp b/src/Win/Semaphore.cpp index a937a30..e0d33ca 100644 --- a/src/Win/Semaphore.cpp +++ b/src/Win/Semaphore.cpp @@ -11,7 +11,7 @@ namespace hgl */ Semaphore::Semaphore(int max_count) { - ptr=CreateSemaphore(nullptr,0,max_count,nullptr); + ptr=CreateSemaphoreW(nullptr,0,max_count,nullptr); if(!ptr) LOG_ERROR(OS_TEXT("CreateSemaphore error,max_count=")+OSString(max_count)); From ddf56c70160fcb96b12af58beceed22e1a1a1aea Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 10 Dec 2019 15:02:08 +0800 Subject: [PATCH 2/8] update ProcMutex.cpp (Win32) --- src/Win/ProcMutex.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Win/ProcMutex.cpp b/src/Win/ProcMutex.cpp index 403d341..582323e 100644 --- a/src/Win/ProcMutex.cpp +++ b/src/Win/ProcMutex.cpp @@ -1,5 +1,4 @@ #include -#include namespace hgl { From e12b8a9e5c5a65b4662a4c02fb5c7c67558a4490 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Tue, 24 Dec 2019 16:49:30 +0800 Subject: [PATCH 3/8] split Acquire function of Semaphore --- src/Apple/Semaphore.cpp | 26 ++++++++++++++------------ src/UNIX/Semaphore.cpp | 22 ++++++++++++++-------- src/Win/Semaphore.cpp | 9 +++++++++ 3 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/Apple/Semaphore.cpp b/src/Apple/Semaphore.cpp index d4301aa..2161e6d 100644 --- a/src/Apple/Semaphore.cpp +++ b/src/Apple/Semaphore.cpp @@ -3,8 +3,6 @@ namespace hgl { - void GetWaitTime(struct timespec &,double); - /** * @param max_count 最大计数 */ @@ -50,7 +48,18 @@ namespace hgl { if(!ptr)return(false); - return !dispatch_semaphore_wait(ptr, DISPATCH_TIME_NOW); + return !dispatch_semaphore_wait(ptr,DISPATCH_TIME_NOW); + } + + /** + * 等待并获取一个信号 + * @return 是否等待到了,如果超过最长时间,仍未等到即为超时,返回false + */ + bool Semaphore::Acquire() + { + if(!ptr)return(false); + + return !dispatch_semaphore_wait(ptr,DISPATCH_TIME_FOREVER); } /** @@ -62,15 +71,8 @@ namespace hgl { if(!ptr)return(false); - if(t<=0) - { - return !dispatch_semaphore_wait(ptr, DISPATCH_TIME_FOREVER); - } - else - { - dispatch_time_t when=dispatch_time(DISPATCH_TIME_NOW,t*HGL_NANO_SEC_PER_SEC); + dispatch_time_t when=dispatch_time(DISPATCH_TIME_NOW,t*HGL_NANO_SEC_PER_SEC); - return !dispatch_semaphore_wait(ptr,when); - } + return !dispatch_semaphore_wait(ptr,when); } }//namespace hgl diff --git a/src/UNIX/Semaphore.cpp b/src/UNIX/Semaphore.cpp index 399acd7..424bfbb 100644 --- a/src/UNIX/Semaphore.cpp +++ b/src/UNIX/Semaphore.cpp @@ -64,6 +64,17 @@ namespace hgl return !sem_trywait(ptr); } + /** + * 等待并获取一个信号 + * @return 是否等待到了,如果超过最长时间,仍未等到即为超时,返回false + */ + bool Semaphore::Acquire() + { + if(!ptr)return(false); + + return !sem_wait(ptr); + } + /** * 等待并获取一个信号 * @param t 等待的最长时间,使用0表示无限等待.(单位秒) @@ -73,15 +84,10 @@ namespace hgl { if(!ptr)return(false); - if(t<=0) - return !sem_wait(ptr); - else - { - struct timespec abstime; + struct timespec abstime; - GetWaitTime(abstime,t); + GetWaitTime(abstime,t); - return !sem_timedwait(ptr,&abstime); - } + return !sem_timedwait(ptr,&abstime); } }//namespace hgl diff --git a/src/Win/Semaphore.cpp b/src/Win/Semaphore.cpp index e0d33ca..876571d 100644 --- a/src/Win/Semaphore.cpp +++ b/src/Win/Semaphore.cpp @@ -41,6 +41,15 @@ namespace hgl { return(WaitForSingleObject(ptr,0)==WAIT_OBJECT_0); } + + /** + * 等待并获取一个信号 + * @return 是否等待到了,如果超过最长时间,仍未等到即为超时,返回false + */ + bool Semaphore::Acquire() + { + return(WaitForSingleObject(ptr,INFINITE)==WAIT_OBJECT_0); + } /** * 等待并获取一个信号 From d33bcd601c0a4c1c2c2cb830c09f5147a87acabd Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 23 Jan 2020 22:06:04 +0800 Subject: [PATCH 4/8] fix include pathname --- src/Apple/Semaphore.cpp | 4 ++-- src/UNIX/EnumFile.cpp | 2 +- src/UNIX/ExternalModule.cpp | 2 +- src/UNIX/Fifo.cpp | 2 +- src/UNIX/File.cpp | 2 +- src/UNIX/FileAccess.cpp | 2 +- src/UNIX/LogConsole.cpp | 2 +- src/UNIX/Semaphore.cpp | 2 +- src/UNIX/Thread.cpp | 4 ++-- src/UNIX/XCBWindow.cpp | 8 ++++++++ src/UNIX/XCBWindow.h | 5 ++++- src/Win/SystemInfo.cpp | 4 ++-- 12 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/Apple/Semaphore.cpp b/src/Apple/Semaphore.cpp index 2161e6d..87c1d54 100644 --- a/src/Apple/Semaphore.cpp +++ b/src/Apple/Semaphore.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include namespace hgl { diff --git a/src/UNIX/EnumFile.cpp b/src/UNIX/EnumFile.cpp index 67c6b5c..20affd4 100644 --- a/src/UNIX/EnumFile.cpp +++ b/src/UNIX/EnumFile.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/UNIX/ExternalModule.cpp b/src/UNIX/ExternalModule.cpp index bf1ccc4..4e3c212 100644 --- a/src/UNIX/ExternalModule.cpp +++ b/src/UNIX/ExternalModule.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include diff --git a/src/UNIX/Fifo.cpp b/src/UNIX/Fifo.cpp index 5ab161d..9ea17e4 100644 --- a/src/UNIX/Fifo.cpp +++ b/src/UNIX/Fifo.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include namespace hgl diff --git a/src/UNIX/File.cpp b/src/UNIX/File.cpp index 78b0910..8f894d3 100644 --- a/src/UNIX/File.cpp +++ b/src/UNIX/File.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/src/UNIX/FileAccess.cpp b/src/UNIX/FileAccess.cpp index f695222..15e4174 100644 --- a/src/UNIX/FileAccess.cpp +++ b/src/UNIX/FileAccess.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include diff --git a/src/UNIX/LogConsole.cpp b/src/UNIX/LogConsole.cpp index 3946652..2875bf8 100644 --- a/src/UNIX/LogConsole.cpp +++ b/src/UNIX/LogConsole.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include diff --git a/src/UNIX/Semaphore.cpp b/src/UNIX/Semaphore.cpp index 424bfbb..c045210 100644 --- a/src/UNIX/Semaphore.cpp +++ b/src/UNIX/Semaphore.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include #include diff --git a/src/UNIX/Thread.cpp b/src/UNIX/Thread.cpp index 3bdef9a..9e40af2 100644 --- a/src/UNIX/Thread.cpp +++ b/src/UNIX/Thread.cpp @@ -1,9 +1,9 @@ #include #include -#include +#include #include #include -#include +#include namespace hgl { diff --git a/src/UNIX/XCBWindow.cpp b/src/UNIX/XCBWindow.cpp index f1209b5..851014b 100644 --- a/src/UNIX/XCBWindow.cpp +++ b/src/UNIX/XCBWindow.cpp @@ -91,6 +91,14 @@ namespace hgl win_name.Length(), win_name.c_str()); } + void XCBWindow::ToMinWindow() + { + } + + void XCBWindow::ToMaxWindow() + { + } + bool XCBWindow::MessageProc() { return(true); diff --git a/src/UNIX/XCBWindow.h b/src/UNIX/XCBWindow.h index 6df4f21..726b2d3 100644 --- a/src/UNIX/XCBWindow.h +++ b/src/UNIX/XCBWindow.h @@ -13,7 +13,6 @@ namespace hgl private: bool InitConnection(); - VkSurfaceKHR CreateSurface(VkInstance) override; public: @@ -32,6 +31,10 @@ namespace hgl void Show()override{} void Hide()override{} + + void ToMinWindow() override; + void ToMaxWindow() override; + bool MessageProc() override; bool WaitMessage() override; };//class XCBWindow:public Window diff --git a/src/Win/SystemInfo.cpp b/src/Win/SystemInfo.cpp index b26d4b6..839a399 100644 --- a/src/Win/SystemInfo.cpp +++ b/src/Win/SystemInfo.cpp @@ -1,6 +1,6 @@ -#include +#include //#include -#include +#include #include #include #include From 622f4faab39b912ba7ddc8dc29af6087c1dc08d5 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 24 Jan 2020 00:16:44 +0800 Subject: [PATCH 5/8] update "CreateLoggerConsole" param --- src/UNIX/LogConsole.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UNIX/LogConsole.cpp b/src/UNIX/LogConsole.cpp index 2875bf8..ad5e323 100644 --- a/src/UNIX/LogConsole.cpp +++ b/src/UNIX/LogConsole.cpp @@ -115,7 +115,7 @@ namespace hgl } };//class LogInterface - Logger *CreateLoggerConsole(const OSString &,LogLevel ll) + Logger *CreateLoggerConsole(LogLevel ll) { if(ll Date: Fri, 24 Apr 2020 21:11:52 +0800 Subject: [PATCH 6/8] update to support the new BaseString --- src/Win/EnumVolume.cpp | 4 ++-- src/Win/ExternalModule.cpp | 4 ++-- src/Win/File.cpp | 2 +- src/Win/Semaphore.cpp | 2 +- src/Win/Thread.cpp | 2 +- src/Win/WinMessage.cpp | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Win/EnumVolume.cpp b/src/Win/EnumVolume.cpp index 5d3ae3e..7fae473 100644 --- a/src/Win/EnumVolume.cpp +++ b/src/Win/EnumVolume.cpp @@ -63,7 +63,7 @@ namespace hgl } else { - LOG_PROBLEM(U16_TEXT("Get <")+UTF16String(path_name)+U16_TEXT("> info failed!Windows error code: ")+UTF16String((uint)GetLastError())); + LOG_PROBLEM(U16_TEXT("Get <")+UTF16String(path_name)+U16_TEXT("> info failed!Windows error code: ")+UTF16String::valueOf((uint)GetLastError())); } if(GetDiskFreeSpaceExW(path_name, @@ -75,7 +75,7 @@ namespace hgl } else { - LOG_PROBLEM(U16_TEXT("Get disk free space <")+UTF16String(path_name)+U16_TEXT("> data failed,Windows error code: ")+UTF16String((uint)GetLastError())); + LOG_PROBLEM(U16_TEXT("Get disk free space <")+UTF16String(path_name)+U16_TEXT("> data failed,Windows error code: ")+UTF16String::valueOf((uint)GetLastError())); } count++; diff --git a/src/Win/ExternalModule.cpp b/src/Win/ExternalModule.cpp index c817b79..15e2376 100644 --- a/src/Win/ExternalModule.cpp +++ b/src/Win/ExternalModule.cpp @@ -16,7 +16,7 @@ namespace hgl FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,nullptr,dw, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),str,0,nullptr); - LOG_ERROR(OS_TEXT("LoadModule <")+OSString(filename)+OS_TEXT("> error! os info: ")+OSString(dw)+OSString::charOf(',')+str); + LOG_ERROR(OS_TEXT("LoadModule <")+OSString(filename)+OS_TEXT("> error! os info: ")+OSString::valueOf(dw)+OSString::charOf(',')+str); return(nullptr); } @@ -43,7 +43,7 @@ namespace hgl FormatMessageW( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,nullptr,dw, MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),str,0,nullptr); - LOG_ERROR(L"LoadModule <"+UTF16String(name)+L"> error! os info: "+UTF16String(dw)+UTF16String::charOf(L',')+str); + LOG_ERROR(L"LoadModule <"+UTF16String(name)+L"> error! os info: "+UTF16String::valueOf(dw)+UTF16String::charOf(L',')+str); return(false); } diff --git a/src/Win/File.cpp b/src/Win/File.cpp index e99e04b..3f084d9 100644 --- a/src/Win/File.cpp +++ b/src/Win/File.cpp @@ -162,7 +162,7 @@ namespace hgl const uint win_error=GetLastError(); - LOG_PROBLEM(OS_TEXT("Create Directory <")+OSString(name)+OS_TEXT("> failed,errno: ")+OSString(win_error)); + LOG_PROBLEM(OS_TEXT("Create Directory <")+OSString(name)+OS_TEXT("> failed,errno: ")+OSString::valueOf(win_error)); return(false); } diff --git a/src/Win/Semaphore.cpp b/src/Win/Semaphore.cpp index 876571d..b0aece2 100644 --- a/src/Win/Semaphore.cpp +++ b/src/Win/Semaphore.cpp @@ -14,7 +14,7 @@ namespace hgl ptr=CreateSemaphoreW(nullptr,0,max_count,nullptr); if(!ptr) - LOG_ERROR(OS_TEXT("CreateSemaphore error,max_count=")+OSString(max_count)); + LOG_ERROR(OS_TEXT("CreateSemaphore error,max_count=")+OSString::valueOf(max_count)); } Semaphore::~Semaphore() diff --git a/src/Win/Thread.cpp b/src/Win/Thread.cpp index 43428db..e12fa9b 100644 --- a/src/Win/Thread.cpp +++ b/src/Win/Thread.cpp @@ -21,7 +21,7 @@ namespace hgl if(!tp) { exit_lock.Unlock(); - LOG_ERROR(OS_TEXT("Create Thread failed,Windows ErrorCode: ")+OSString((uint)GetLastError())); + LOG_ERROR(OS_TEXT("Create Thread failed,Windows ErrorCode: ")+OSString::valueOf((uint)GetLastError())); return(false); } diff --git a/src/Win/WinMessage.cpp b/src/Win/WinMessage.cpp index 8e31e6f..4388d24 100644 --- a/src/Win/WinMessage.cpp +++ b/src/Win/WinMessage.cpp @@ -182,7 +182,7 @@ namespace hgl ::GetKeyNameTextW(key,name,64); - LOG_INFO(WideString(L"Unknow Key: " )+WideString(key) + LOG_INFO(WideString(L"Unknow Key: " )+WideString::valueOf(key) +WideString(L" ,name: " )+WideString(name)); } #endif _DEBUG From f1f3acdaa30d84d7c8a3e155f52a19a7f2c1e526 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 18 Jun 2020 03:35:55 +0800 Subject: [PATCH 7/8] fix and update on Linux platform --- src/UNIX/EnumFile.cpp | 2 +- src/UNIX/File.cpp | 2 +- src/UNIX/FileAccess.cpp | 4 ++-- src/UNIX/Semaphore.cpp | 4 ++-- src/UNIX/Thread.cpp | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/UNIX/EnumFile.cpp b/src/UNIX/EnumFile.cpp index 20affd4..f5b5548 100644 --- a/src/UNIX/EnumFile.cpp +++ b/src/UNIX/EnumFile.cpp @@ -27,7 +27,7 @@ namespace hgl if(config->folder_name.IsEmpty()) { - fullname='.'; + fullname=OS_TEXT("."); } else { diff --git a/src/UNIX/File.cpp b/src/UNIX/File.cpp index 8f894d3..4b2b822 100644 --- a/src/UNIX/File.cpp +++ b/src/UNIX/File.cpp @@ -170,7 +170,7 @@ namespace hgl { if(!mkdir(name,S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))return(true); - LOG_PROBLEM(OS_TEXT("Create Directory <")+OSString(name)+OS_TEXT("> failed,errno: ")+OSString(errno)); + LOG_PROBLEM(OS_TEXT("Create Directory <")+OSString(name)+OS_TEXT("> failed,errno: ")+OSString::valueOf(errno)); return(false); } diff --git a/src/UNIX/FileAccess.cpp b/src/UNIX/FileAccess.cpp index 15e4174..563a610 100644 --- a/src/UNIX/FileAccess.cpp +++ b/src/UNIX/FileAccess.cpp @@ -35,13 +35,13 @@ namespace hgl if(fom==fomReadWrite )fp=hgl_open64(fn,O_RDWR );else if(fom==fomAppend )fp=hgl_open64(fn,O_APPEND );else { - LOG_ERROR(OS_TEXT("UNIX,FileAccess,OpenFile(")+OSString(fn)+OS_TEXT(" mode error: "+OSString(fom))); + LOG_ERROR(OS_TEXT("UNIX,FileAccess,OpenFile(")+OSString(fn)+OS_TEXT(" mode error: "+OSString::valueOf(fom))); RETURN_ERROR(-1); } if(fp==-1) { - LOG_ERROR(OS_TEXT("UNIX,FileAccess,OpenFile(")+OSString(fn)+OS_TEXT(") open return error: "+OSString(errno))); + LOG_ERROR(OS_TEXT("UNIX,FileAccess,OpenFile(")+OSString(fn)+OS_TEXT(") open return error: "+OSString::valueOf(errno))); } return fp; diff --git a/src/UNIX/Semaphore.cpp b/src/UNIX/Semaphore.cpp index c045210..9266271 100644 --- a/src/UNIX/Semaphore.cpp +++ b/src/UNIX/Semaphore.cpp @@ -16,8 +16,8 @@ namespace hgl if(sem_init(ptr,PTHREAD_PROCESS_PRIVATE,0)) { - LOG_ERROR(OS_TEXT("sem_init error,max_count=")+OSString(max_count)); - delete ptr; + LOG_ERROR(OS_TEXT("sem_init error,max_count=")+OSString::valueOf(max_count)); + delete (sem_t *)ptr; ptr=nullptr; } } diff --git a/src/UNIX/Thread.cpp b/src/UNIX/Thread.cpp index 9e40af2..590d4e4 100644 --- a/src/UNIX/Thread.cpp +++ b/src/UNIX/Thread.cpp @@ -35,7 +35,7 @@ namespace hgl tp=0; pthread_attr_destroy(&attr); - LOG_ERROR(OS_TEXT("Create Thread (pthread_create) failed.errno:")+OSString(errno)); + LOG_ERROR(OS_TEXT("Create Thread (pthread_create) failed.errno:")+OSString::valueOf(errno)); return(false); } From a58e1ee99c6bb25533ebe2f323e5f7025fe0d114 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Thu, 18 Jun 2020 03:40:32 +0800 Subject: [PATCH 8/8] delete force convert of type, it's no necessary --- src/UNIX/Semaphore.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/UNIX/Semaphore.cpp b/src/UNIX/Semaphore.cpp index 9266271..dcc40cd 100644 --- a/src/UNIX/Semaphore.cpp +++ b/src/UNIX/Semaphore.cpp @@ -17,7 +17,7 @@ namespace hgl if(sem_init(ptr,PTHREAD_PROCESS_PRIVATE,0)) { LOG_ERROR(OS_TEXT("sem_init error,max_count=")+OSString::valueOf(max_count)); - delete (sem_t *)ptr; + delete ptr; ptr=nullptr; } }