ithewei 6 年之前
父節點
當前提交
3c379bfc6c
共有 3 個文件被更改,包括 29 次插入20 次删除
  1. 14 3
      hdef.h
  2. 1 3
      hgui.h
  3. 14 14
      hplatform.h

+ 14 - 3
hdef.h

@@ -3,16 +3,21 @@
 
 #include "hplatform.h"
 
-#include <stdint.h>
 typedef unsigned char       uint8;
 typedef unsigned short      uint16;
 typedef unsigned int        uint32;
-typedef uint64_t            uint64;
 
 typedef char                int8;
 typedef short               int16;
 typedef int                 int32;
+
+#ifdef _MSC_VER
+typedef __int64             int64;
+typedef unsigned __int64    uint64;
+#else
 typedef int64_t             int64;
+typedef uint64_t            uint64;
+#endif
 
 typedef float               float32;
 typedef double              float64;
@@ -23,6 +28,12 @@ typedef int                 BOOL;
 
 typedef void*               handle;
 
+#ifdef _MSC_VER
+typedef int pid_t;
+typedef int gid_t;
+typedef int uid_t;
+#endif
+
 typedef int (*method_t)(void* userdata);
 typedef void (*procedure_t)(void* userdata);
 
@@ -144,7 +155,7 @@ typedef std::map<std::string, std::string> keyval_t;
 #define LOINI32(n)        ( (int32)(n & 0xffffffff) )
 
 #define FLOAT_PRECISION 1e-6
-#define FLOAT_EQUAL_ZERO(f) (-FLOAT_PRECISION < (f) && (f) < FLOAT_PRECISION)
+#define FLOAT_EQUAL_ZERO(f) (ABS(f) < FLOAT_PRECISION)
 
 #define STRINGIFY(x)    STRINGIFY_HELPER(x)
 #define STRINGIFY_HELPER(x)    #x

+ 1 - 3
hgui.h

@@ -1,9 +1,7 @@
 #ifndef HW_GUI_H_
 #define HW_GUI_H_
 
-#include "hdef.h"
-
-typedef uint32 HColor;  // 0xAARRGGBB
+typedef unsigned int HColor;  // 0xAARRGGBB
 
 #define CLR_B(c)    (c         & 0xff)
 #define CLR_G(c)    ((c >> 8)  & 0xff)

+ 14 - 14
hplatform.h

@@ -107,26 +107,26 @@
     #define MKDIR(dir) mkdir(dir, 0777)
 #endif
 
+// ANSI C
+#include <assert.h>
 #include <stddef.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <time.h>
+#include <math.h>
+#include <errno.h>
+#include <ctype.h>
+#include <wctype.h>
+#include <wchar.h>
+#include <uchar.h>
 
+// POSIX C
+#include <signal.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <signal.h>
-#include <errno.h>
-
-#ifdef _MSC_VER
-    typedef int pid_t;
-    typedef int gid_t;
-    typedef int uid_t;
-#endif
-
-#ifdef __GNUC__
-    #define GNUC_ALIGN(n)   __attribute__((aligned(n)))
-#else
-    #define GNUC_ALIGN(n)
-#endif
 
 #endif  // HW_PLATFORM_H_