瀏覽代碼

_MSC_VER => _WIN32

ithewei 7 年之前
父節點
當前提交
f7f867362a
共有 5 個文件被更改,包括 24 次插入23 次删除
  1. 1 1
      hmutex.h
  2. 16 10
      hplatform.h
  3. 3 8
      hthread.h
  4. 3 3
      htime.cpp
  5. 1 1
      htime.h

+ 1 - 1
hmutex.h

@@ -5,7 +5,7 @@
 
 #include "hplatform.h"
 
-#ifdef _MSC_VER
+#ifdef _WIN32
 class RWLock {
  public:
     RWLock() { InitializeSRWLock(&_rwlock); }

+ 16 - 10
hplatform.h

@@ -1,25 +1,31 @@
 #ifndef HW_PLATFORM_H_
 #define HW_PLATFORM_H_
 
-#ifdef _MSC_VER
+#include <sys/types.h>
+
+#ifndef _MSC_VER
+#include <sys/time.h>  // for gettimeofday
+
+#include <pthread.h>
+
+#include <strings.h>
+#define stricmp     strcasecmp
+#define strnicmp    strncasecmp
+#endif
+
+#ifdef _WIN32
     #ifndef WIN32_LEAN_AND_MEAN
     #define WIN32_LEAN_AND_MEAN
     #endif
     #include <winsock2.h>
     #include <windows.h>
-    #undef  WIN32_LEAN_AND_MEAN
 
     #define strcasecmp stricmp
     #define strncasecmp strnicmp
-#else
-    #include <sys/types.h>
-    #include <sys/time.h>  // for gettimeofday
-    #include <unistd.h>
-    #include <pthread.h>
+#endif
 
-    #include <strings.h>
-    #define stricmp     strcasecmp
-    #define strnicmp    strncasecmp
+#ifdef __unix__
+    #include <unistd.h>
 #endif
 
 #ifdef __GNUC__

+ 3 - 8
hthread.h

@@ -8,14 +8,9 @@
 #include "hdef.h"
 #include "hplatform.h"
 
-#ifdef _MSC_VER
-inline uint32 getpid() {
-    return GetCurrentProcessId();
-}
-
-inline uint32 gettid() {
-    return GetCurrentThreadId();
-}
+#ifdef _WIN32
+#define getpid GetCurrentProcessId
+#define gettid GetCurrentThreadId
 #endif
 
 #if defined(__unix__) && !defined(__ANDROID__)

+ 3 - 3
htime.cpp

@@ -4,7 +4,7 @@
 #include <string.h>
 
 void msleep(unsigned long ms) {
-#ifdef _MSC_VER
+#ifdef _WIN32
     Sleep(ms);
 #else
     usleep(ms*1000);
@@ -12,7 +12,7 @@ void msleep(unsigned long ms) {
 }
 
 uint64 gettick() {
-#ifdef _MSC_VER
+#ifdef _WIN32
     return GetTickCount();
 #else
     struct timeval tv;
@@ -23,7 +23,7 @@ uint64 gettick() {
 
 datetime_t get_datetime() {
     datetime_t  dt;
-#ifdef _MSC_VER
+#ifdef _WIN32
     SYSTEMTIME tm;
     GetLocalTime(&tm);
     dt.year     = tm.wYear;

+ 1 - 1
htime.h

@@ -18,7 +18,7 @@ typedef struct datetime_s {
 
 void msleep(unsigned long ms);
 
-#ifdef _MSC_VER
+#ifdef _WIN32
 inline void sleep(unsigned int s) {
     Sleep(s*1000);
 }