Kaynağa Gözat

windows 7 support (#387)

peter23 2 yıl önce
ebeveyn
işleme
78e2e53556
2 değiştirilmiş dosya ile 84 ekleme ve 1 silme
  1. 83 0
      base/hendian.h
  2. 1 1
      base/hmutex.h

+ 83 - 0
base/hendian.h

@@ -18,6 +18,89 @@
 #define le32toh(v) OSSwapLittleToHostInt32(v)
 #define le64toh(v) OSSwapLittleToHostInt64(v)
 #elif defined(OS_WIN)
+
+#if _WIN32_WINNT < _WIN32_WINNT_WIN8
+    /*
+    * Byte order conversion functions for 64-bit integers and 32 + 64 bit
+    * floating-point numbers.  IEEE big-endian format is used for the
+    * network floating point format.
+    */
+    #define _WS2_32_WINSOCK_SWAP_LONG(l)                \
+                ( ( ((l) >> 24) & 0x000000FFL ) |       \
+                ( ((l) >>  8) & 0x0000FF00L ) |       \
+                ( ((l) <<  8) & 0x00FF0000L ) |       \
+                ( ((l) << 24) & 0xFF000000L ) )
+
+    #define _WS2_32_WINSOCK_SWAP_LONGLONG(l)            \
+                ( ( ((l) >> 56) & 0x00000000000000FFLL ) |       \
+                ( ((l) >> 40) & 0x000000000000FF00LL ) |       \
+                ( ((l) >> 24) & 0x0000000000FF0000LL ) |       \
+                ( ((l) >>  8) & 0x00000000FF000000LL ) |       \
+                ( ((l) <<  8) & 0x000000FF00000000LL ) |       \
+                ( ((l) << 24) & 0x0000FF0000000000LL ) |       \
+                ( ((l) << 40) & 0x00FF000000000000LL ) |       \
+                ( ((l) << 56) & 0xFF00000000000000LL ) )
+
+
+    #ifndef htonll
+    __inline unsigned __int64 htonll ( unsigned __int64 Value )
+    {
+        const unsigned __int64 Retval = _WS2_32_WINSOCK_SWAP_LONGLONG (Value);
+        return Retval;
+    }
+    #endif /* htonll */
+
+    #ifndef ntohll
+    __inline unsigned __int64 ntohll ( unsigned __int64 Value )
+    {
+        const unsigned __int64 Retval = _WS2_32_WINSOCK_SWAP_LONGLONG (Value);
+        return Retval;
+    }
+    #endif /* ntohll */
+
+    #ifndef htonf
+    __inline unsigned __int32 htonf ( float Value )
+    {
+        unsigned __int32 Tempval;
+        unsigned __int32 Retval;
+        Tempval = *(unsigned __int32*)(&Value);
+        Retval = _WS2_32_WINSOCK_SWAP_LONG (Tempval);
+        return Retval;
+    }
+    #endif /* htonf */
+
+    #ifndef ntohf
+    __inline float ntohf ( unsigned __int32 Value )
+    {
+        const unsigned __int32 Tempval = _WS2_32_WINSOCK_SWAP_LONG (Value);
+        float Retval;
+        *((unsigned __int32*)&Retval) = Tempval;
+        return Retval;
+    }
+    #endif /* ntohf */
+
+    #ifndef htond
+    __inline unsigned __int64 htond ( double Value )
+    {
+        unsigned __int64 Tempval;
+        unsigned __int64 Retval;
+        Tempval = *(unsigned __int64*)(&Value);
+        Retval = _WS2_32_WINSOCK_SWAP_LONGLONG (Tempval);
+        return Retval;
+    }
+    #endif /* htond */
+
+    #ifndef ntohd
+    __inline double ntohd ( unsigned __int64 Value )
+    {
+        const unsigned __int64 Tempval = _WS2_32_WINSOCK_SWAP_LONGLONG (Value);
+        double Retval;
+        *((unsigned __int64*)&Retval) = Tempval;
+        return Retval;
+    }
+    #endif /* ntohd */
+#endif
+
 #define htobe16(v) htons(v)
 #define htobe32(v) htonl(v)
 #define htobe64(v) htonll(v)

+ 1 - 1
base/hmutex.h

@@ -7,7 +7,7 @@
 
 BEGIN_EXTERN_C
 
-#ifdef _MSC_VER
+#ifdef OS_WIN
 #define hmutex_t                CRITICAL_SECTION
 #define hmutex_init             InitializeCriticalSection
 #define hmutex_destroy          DeleteCriticalSection