ithewei 5 роки тому
батько
коміт
5ef3d4e236
6 змінених файлів з 14 додано та 14 видалено
  1. 1 1
      base/hbase.h
  2. 1 1
      event/hloop.c
  3. 1 1
      event/hloop.h
  4. 1 1
      event/kqueue.c
  5. 2 2
      examples/hloop_test.c
  6. 8 8
      examples/htimer_test.c

+ 1 - 1
base/hbase.h

@@ -19,7 +19,7 @@ void* safe_zalloc(size_t size);
     do {\
         void** pptr = (void**)&(ptr);\
         *pptr = safe_zalloc(size);\
-        printd("alloc(%p, size=%lu)\tat [%s:%d:%s]\n", ptr, size, __FILE__, __LINE__, __FUNCTION__);\
+        printd("alloc(%p, size=%llu)\tat [%s:%d:%s]\n", ptr, (unsigned long long)size, __FILE__, __LINE__, __FUNCTION__);\
     } while(0)
 
 #define SAFE_ALLOC_SIZEOF(ptr)  SAFE_ALLOC(ptr, sizeof(*(ptr)))

+ 1 - 1
event/hloop.c

@@ -348,7 +348,7 @@ void hidle_del(hidle_t* idle) {
     __hidle_del(idle);
 }
 
-htimer_t* htimer_add(hloop_t* loop, htimer_cb cb, uint64_t timeout, uint32_t repeat) {
+htimer_t* htimer_add(hloop_t* loop, htimer_cb cb, uint32_t timeout, uint32_t repeat) {
     if (timeout == 0)   return NULL;
     htimeout_t* timer;
     SAFE_ALLOC_SIZEOF(timer);

+ 1 - 1
event/hloop.h

@@ -126,7 +126,7 @@ void        hidle_del(hidle_t* idle);
 
 // timer
 // @param timeout: unit(ms)
-htimer_t*   htimer_add(hloop_t* loop, htimer_cb cb, uint64_t timeout, uint32_t repeat DEFAULT(INFINITE));
+htimer_t*   htimer_add(hloop_t* loop, htimer_cb cb, uint32_t timeout, uint32_t repeat DEFAULT(INFINITE));
 /*
  * minute   hour    day     week    month       cb
  * 0~59     0~23    1~31    0~6     1~12

+ 1 - 1
event/kqueue.c

@@ -107,7 +107,7 @@ static int __del_event(hloop_t* loop, int fd, int event) {
         tmp = kqueue_ctx->changes[idx];
         kqueue_ctx->changes[idx] = kqueue_ctx->changes[lastidx];
         kqueue_ctx->changes[lastidx] = tmp;
-        hio_t* last = kqueue_ctx->changes[idx].ident;
+        hio_t* last = loop->ios.ptr[kqueue_ctx->changes[idx].ident];
         if (last) {
             last->event_index[EVENT_INDEX(kqueue_ctx->changes[idx].filter)] = idx;
         }

+ 2 - 2
examples/hloop_test.c

@@ -15,12 +15,12 @@ void mylogger(int loglevel, const char* buf, int len) {
 }
 
 void on_idle(hidle_t* idle) {
-    printf("on_idle: event_id=%lu\tpriority=%d\tuserdata=%ld\n", hevent_id(idle), hevent_priority(idle), (long)(hevent_userdata(idle)));
+    printf("on_idle: event_id=%llu\tpriority=%d\tuserdata=%ld\n", hevent_id(idle), hevent_priority(idle), (long)(hevent_userdata(idle)));
 }
 
 void on_timer(htimer_t* timer) {
     hloop_t* loop = hevent_loop(timer);
-    printf("on_timer: event_id=%lu\tpriority=%d\tuserdata=%ld\ttime=%lus\thrtime=%luus\n",
+    printf("on_timer: event_id=%llu\tpriority=%d\tuserdata=%ld\ttime=%llus\thrtime=%lluus\n",
         hevent_id(timer), hevent_priority(timer), (long)(hevent_userdata(timer)), hloop_now(loop), hloop_now_hrtime(loop));
 }
 

+ 8 - 8
examples/htimer_test.c

@@ -2,33 +2,33 @@
 #include "hbase.h"
 
 void on_timer(htimer_t* timer) {
-    printf("time=%lus on_timer\n", hloop_now(hevent_loop(timer)));
+    printf("time=%llus on_timer\n", hloop_now(hevent_loop(timer)));
 }
 
 void on_timer_add(htimer_t* timer) {
-    printf("time=%lus on_timer_add\n", hloop_now(hevent_loop(timer)));
+    printf("time=%llus on_timer_add\n", hloop_now(hevent_loop(timer)));
     htimer_add(hevent_loop(timer), on_timer_add, 1000, 1);
 }
 
 void on_timer_del(htimer_t* timer) {
-    printf("time=%lus on_timer_del\n", hloop_now(hevent_loop(timer)));
+    printf("time=%llus on_timer_del\n", hloop_now(hevent_loop(timer)));
     htimer_del(timer);
 }
 
 void on_timer_reset(htimer_t* timer) {
-    printf("time=%lus on_timer_reset\n", hloop_now(hevent_loop(timer)));
+    printf("time=%llus on_timer_reset\n", hloop_now(hevent_loop(timer)));
     htimer_reset((htimer_t*)hevent_userdata(timer));
 }
 
 void on_timer_quit(htimer_t* timer) {
-    printf("time=%lus on_timer_quit\n", hloop_now(hevent_loop(timer)));
+    printf("time=%llus on_timer_quit\n", hloop_now(hevent_loop(timer)));
     hloop_stop(hevent_loop(timer));
 }
 
 void cron_hourly(htimer_t* timer) {
     time_t tt;
     time(&tt);
-    printf("time=%lus cron_hourly: %s\n", hloop_now(hevent_loop(timer)), ctime(&tt));
+    printf("time=%llus cron_hourly: %s\n", hloop_now(hevent_loop(timer)), ctime(&tt));
 }
 
 int main() {
@@ -52,9 +52,9 @@ int main() {
     // quit application after 1 min
     htimer_add(loop, on_timer_quit, 60000, 1);
 
-    printf("time=%lus begin\n", hloop_now(loop));
+    printf("time=%llus begin\n", hloop_now(loop));
     hloop_run(loop);
-    printf("time=%lus stop\n", hloop_now(loop));
+    printf("time=%llus stop\n", hloop_now(loop));
     hloop_free(&loop);
     return 0;
 }