diff --git a/inc/hgl/log/LogInfo.h b/inc/hgl/log/LogInfo.h index fdb6f31..4aa37bf 100644 --- a/inc/hgl/log/LogInfo.h +++ b/inc/hgl/log/LogInfo.h @@ -34,11 +34,6 @@ namespace hgl std::cout<<(char *)str.c_str()<>LogFrom(\"")+to_u16((u8char *)filename)+U16_TEXT("\", ")+UTF16String::valueOf(line)+U16_TEXT(" line,func:\"")+to_u16((u8char *)funcname)+U16_TEXT("\")")); diff --git a/inc/hgl/platform/Platform.h b/inc/hgl/platform/Platform.h index e9aafff..1869c1a 100644 --- a/inc/hgl/platform/Platform.h +++ b/inc/hgl/platform/Platform.h @@ -37,6 +37,7 @@ #define HGL_COMPILER_Microsoft HGL_MERGE32('M','S','C',' ') #define HGL_COMPILER_GNU HGL_MERGE32('G','N','U',' ') #define HGL_COMPILER_MinGW32 HGL_MERGE32('M','G','3','2') +#define HGL_COMPILER_MinGW64 HGL_MERGE32('M','G','6','4') #define HGL_COMPILER_Intel HGL_MERGE32('I','n','t','e') #define HGL_COMPILER_IBM HGL_MERGE32('I','B','M',' ') #define HGL_COMPILER_DigitalMars HGL_MERGE32('D','i','M','a') @@ -191,6 +192,8 @@ #define HGL_COMPILER HGL_COMPILER_PGI #elif defined(__MINGW32__) #define HGL_COMPILER HGL_COMPILER_MinGW32 +#elif defined(__MINGW64__) + #define HGL_COMPILER HGL_COMPILER_MinGW64 #elif defined(__GNUC__) #define HGL_COMPILER HGL_COMPILER_GNU #else @@ -221,7 +224,9 @@ #include #elif HGL_COMPILER == HGL_COMPILER_IBM #include - #elif HGL_COMPILER == HGL_COMPILER_MINGW32 + #elif HGL_COMPILER == HGL_COMPILER_MinGW32 + #include + #elif HGL_COMPILER == HGL_COMPILER_MinGW64 #include #elif HGL_COMPILER == HGL_COMPILER_GNU #include diff --git a/inc/hgl/platform/compiler/GNU.h b/inc/hgl/platform/compiler/GNU.h index e15facd..ca9e2dc 100644 --- a/inc/hgl/platform/compiler/GNU.h +++ b/inc/hgl/platform/compiler/GNU.h @@ -72,6 +72,13 @@ #endif//__GNUC__ +#ifdef char8_t +using u8char =char8_t; +#else +using u8char =char; +#endif + + #define HGL_THREAD_LOCAL_STORAGE __thread //线程本地储存 //-------------------------------------------------------------------------------------------------- #define HGL_LIB_FRONT HGL_LIB_OS "_" HGL_LIB_COMPILER_NAME "_" HGL_LIB_DEBUG_NAME "_" diff --git a/inc/hgl/platform/os/MSWindows.h b/inc/hgl/platform/os/MSWindows.h index 5155a4e..b070911 100644 --- a/inc/hgl/platform/os/MSWindows.h +++ b/inc/hgl/platform/os/MSWindows.h @@ -51,33 +51,36 @@ using os_char =wchar_t; #define HGL_GL_WINDOW_INCLUDE_FILE //指定OpenGL窗口引用头文件 #define HGL_GL_WINDOW_CLASS WinGLWindow //指定OpenGL窗口类名称 //-------------------------------------------------------------------------------------------------- -#if HGL_COMPILER == HGL_COMPILER_Microsoft - #define hgl_malloc(size) _aligned_malloc(size,HGL_MEM_ALIGN) - #define hgl_realloc(ptr,size) _aligned_realloc(ptr,size,HGL_MEM_ALIGN) - #define hgl_free _aligned_free - template - inline T *hgl_aligned_malloc(size_t n) - { - return (T *)_aligned_malloc(n*sizeof(T),alignof(T)); - } -#else - #define hgl_malloc(size) memalign(HGL_MEM_ALIGN,size) - #define hgl_realloc(ptr,size) realloc(ptr,size) - #define hgl_free free -#endif// +// == 目前MINGW和MSVC在以下接口上应该能保持一致了 + +#define hgl_malloc(size) _aligned_malloc(size,HGL_MEM_ALIGN) +#define hgl_realloc(ptr,size) _aligned_realloc(ptr,size,HGL_MEM_ALIGN) +#define hgl_free _aligned_free + +template +inline T *hgl_aligned_malloc(size_t n) +{ + return (T *)_aligned_malloc(n*sizeof(T),alignof(T)); +} #define OS_EXTERNAL_H using ExternalModulePointer =HMODULE; #define pi_get GetProcAddress #define pi_close FreeLibrary -#define struct_stat64 struct _stat64 +#ifdef HGL_64_BITS + #define struct_stat64 struct _stat64 + #define hgl_lstat64 _wstat64 +#endif +#if HGL_32_BITS + #define struct_stat64 struct _stati64 + #define hgl_lstat64 _wstat32i64 +#endif //#define hgl_stat64 _stat64 #define hgl_lseek64 _lseeki64 #define hgl_tell64(fp) _telli64(fp) #define hgl_fstat64 _fstati64 -#define hgl_lstat64 _wstat64 #define hgl_read64 _read #define hgl_write64 _write diff --git a/inc/hgl/type/List.cpp b/inc/hgl/type/List.cpp index ed39490..7792411 100644 --- a/inc/hgl/type/List.cpp +++ b/inc/hgl/type/List.cpp @@ -1,6 +1,10 @@ #ifndef HGL_LIST_CPP #define HGL_LIST_CPP +#ifdef _WIN32 + #include +#endif + //-------------------------------------------------------------------------------------------------- // 代码中的部分memcpy可替换为memmove,但这样会引起CodeGuard/Valgrind之类的内存调试器报错 //-------------------------------------------------------------------------------------------------- @@ -41,8 +45,12 @@ namespace hgl { if(!items||count<=0) return(false); - +#ifdef _WIN32 + srand( time(0) ); + memcpy(&ti,items+(rand()%count),sizeof(T)); +#else memcpy(&ti,items+(lrand48()%count),sizeof(T)); +#endif return(true); } diff --git a/src/PlugIn/ExternalModule.cpp b/src/PlugIn/ExternalModule.cpp index 0f721de..d6717af 100644 --- a/src/PlugIn/ExternalModule.cpp +++ b/src/PlugIn/ExternalModule.cpp @@ -32,16 +32,16 @@ namespace hgl { if(fp) { - void *func=pi_get(fp,name); + void *func=(void*)pi_get(fp,name); if(!func) - LOG_ERROR("don't find "+AnsiString(name)); + LOG_ERROR("don't find "+UTF8String(name)); return(func); } else { - LOG_ERROR("Get func <"+AnsiString(name)+"> error: no load module!"); + LOG_ERROR("Get func <"+UTF8String(name)+"> error: no load module!"); return(nullptr); } @@ -51,7 +51,7 @@ namespace hgl { if(fp) { - void *func=pi_get(fp,name); + void *func=(void*)pi_get(fp,name); if(func)return(func); @@ -60,12 +60,12 @@ namespace hgl _name[0]='_'; strcpy(_name+1,HGL_MAX_PATH-1,name); - func=pi_get(fp,_name); + func=(void*)pi_get(fp,_name); if(func)return(func); } - return(nullptr); + return(nullptr); } /**