ithewei 6 tahun lalu
induk
melakukan
be9bd46457
4 mengubah file dengan 8 tambahan dan 8 penghapusan
  1. 1 1
      hdef.h
  2. 1 1
      hlog.cpp
  3. 3 3
      hthread.h
  4. 3 3
      hvar.h

+ 1 - 1
hdef.h

@@ -131,7 +131,7 @@ typedef std::map<std::string, std::string> keyval_t;
 #endif
 
 #ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
+#define ARRAY_SIZE(a) (sizeof(a)/sizeof(*(a)))
 #endif
 
 #ifndef SAFE_FREE

+ 1 - 1
hlog.cpp

@@ -124,7 +124,7 @@ int hlog_printf(int level, const char* fmt, ...) {
     else {
         fprintf(fp, "%s\n", s_logbuf);
     }
-    fflush(fp);
+    //fflush(fp); // note: fflush cache page => disk, slow
 
     return len;
 }

+ 3 - 3
hthread.h

@@ -99,7 +99,7 @@ class HThread {
         PAUSE,
     };
     std::atomic<Status> status;
-    uint32 dotask_cnt;
+    uint32_t dotask_cnt;
 
     enum SleepPolicy {
         YIELD,
@@ -108,7 +108,7 @@ class HThread {
         NO_SLEEP,
     };
 
-    void setSleepPolicy(SleepPolicy policy, int64 ms = 0) {
+    void setSleepPolicy(SleepPolicy policy, uint32_t ms = 0) {
         status_switch = true;
         sleep_policy = policy;
         sleep_ms = ms;
@@ -145,7 +145,7 @@ class HThread {
     std::atomic<bool> status_switch;
     SleepPolicy sleep_policy;
     std::chrono::system_clock::time_point base_tp;   // for SLEEP_UNTIL
-    int64 sleep_ms;
+    uint32_t sleep_ms;
 };
 
 #endif  // HW_THREAD_H_

+ 3 - 3
hvar.h

@@ -19,7 +19,7 @@ class HVar {
 
     union DATA {
         bool b;
-        int64 i;
+        int64_t i;
         float64 f;
         char* str;
         void* ptr;
@@ -27,7 +27,7 @@ class HVar {
 
     HVar()          {memset(&data, 0, sizeof(data)); type = UNKNOWN;}
     HVar(bool b)    {data.b = b; type = BOOLEAN;}
-    HVar(int64 i)   {data.i = i; type = INTEGER;}
+    HVar(int64_t i)   {data.i = i; type = INTEGER;}
     HVar(float64 f) {data.f = f; type = FLOAT;}
     HVar(char* str) {
         data.str = (char*)malloc(strlen(str)+1);
@@ -46,7 +46,7 @@ class HVar {
     bool    isValid()   {return type != UNKNOWN;}
 
     bool    toBool()    {return data.b;}
-    int64   toInt()     {return data.i;}
+    int64_t toInt()     {return data.i;}
     float64 toFloat()   {return data.f;}
     char*   toString()  {return data.str;}
     void*   toPointer() {return data.ptr;}