fix thread macro in Linux

This commit is contained in:
hyzboy 2020-01-23 20:37:42 +08:00
parent e90f8c9479
commit 25748fde9b
6 changed files with 12 additions and 16 deletions

View File

@ -7,7 +7,7 @@ using u32char =char32_t;
using u16char =char16_t; using u16char =char16_t;
using os_char =char; using os_char =char;
#define to_oschar to_u8 #define to_oschar to_u8
#define OS_TEXT(str) u8##str #define OS_TEXT(str) str
#define U8_TEXT(str) u8##str #define U8_TEXT(str) u8##str
#define U16_TEXT(str) u##str #define U16_TEXT(str) u##str

View File

@ -2,6 +2,7 @@
#define HGL_POSIX_THREAD_INCLUDE #define HGL_POSIX_THREAD_INCLUDE
#include<pthread.h> #include<pthread.h>
#include<semaphore.h>
#ifdef __APPLE__ #ifdef __APPLE__
#include<dispatch/dispatch.h> #include<dispatch/dispatch.h>
@ -12,19 +13,19 @@ namespace hgl
using thread_mutex_ptr =pthread_mutex_t; using thread_mutex_ptr =pthread_mutex_t;
using thread_ptr =pthread_t; using thread_ptr =pthread_t;
using rwlock_ptr =pthread_rwlock_t *; using rwlock_ptr =pthread_rwlock_t;
#ifdef __APPLE__ #ifdef __APPLE__
using semaphore_ptr =dispatch_semaphore_t *; using semaphore_ptr =dispatch_semaphore_t *;
#else #else
using semaphore_ptr =sem_t *; using semaphore_ptr =sem_t;
#endif// #endif//
using cond_var_ptr =pthread_cond_t *; using cond_var_ptr =pthread_cond_t;
#define THREAD_FUNC void * #define THREAD_FUNC void *
#define HGL_THREAD_DETACH_SELF pthread_detach(pthread_self()); #define HGL_THREAD_DETACH_SELF pthread_detach(pthread_self());
using proc_mutex_ptr =sem_t *; using proc_mutex_ptr =sem_t;
}//namespace hgl }//namespace hgl
#endif//HGL_POSIX_THREAD_INCLUDE #endif//HGL_POSIX_THREAD_INCLUDE

View File

@ -10,7 +10,7 @@ namespace hgl
*/ */
class ProcMutex ///进程排斥 class ProcMutex ///进程排斥
{ {
proc_mutex_ptr lock; proc_mutex_ptr *lock;
public: public:

View File

@ -12,7 +12,7 @@ namespace hgl
*/ */
class CondVar class CondVar
{ {
conv_var_ptr *cond_var; cond_var_ptr *cond_var;
public: public:

View File

@ -11,7 +11,7 @@ namespace hgl
*/ */
class Semaphore ///信号 class Semaphore ///信号
{ {
semaphore_ptr ptr; semaphore_ptr *ptr;
public: public:

View File

@ -51,7 +51,7 @@ namespace hgl
if(pi)return pi; if(pi)return pi;
if(!FileExist(filename))return(false); if(!FileExist(filename))return(nullptr);
ExternalPlugIn *epi=new ExternalPlugIn; ExternalPlugIn *epi=new ExternalPlugIn;
@ -76,12 +76,7 @@ namespace hgl
if(fp_count<=0)return(nullptr); if(fp_count<=0)return(nullptr);
#if HGL_OS == HGL_OS_Windows OSString pi_filename=name+OS_TEXT('.')+pi_name+HGL_PLUGIN_EXTNAME;
OSString pi_filename=name+L'.'+pi_name+HGL_PLUGIN_EXTNAME;
#else
OSString pi_filename=ToOSString(name)+'.'+ToOString(pi_name)+HGL_PLUGIN_EXTNAME;
#endif//HGL_OS == HGL_OS_Windows
OSString pi_fullfilename; OSString pi_fullfilename;
ExternalPlugIn *epi=new ExternalPlugIn; ExternalPlugIn *epi=new ExternalPlugIn;
@ -106,7 +101,7 @@ namespace hgl
bool PlugInManage::UnloadPlugin(const OSString &pi_name) bool PlugInManage::UnloadPlugin(const OSString &pi_name)
{ {
if(pi_name.IsEmpty())return(nullptr); if(pi_name.IsEmpty())return(false);
this->Release(pi_name); this->Release(pi_name);
return(true); return(true);