hewei há 6 anos atrás
pai
commit
e67c7a2d35
5 ficheiros alterados com 16 adições e 12 exclusões
  1. 2 1
      BUILD.md
  2. 8 4
      base/hplatform.h
  3. 2 3
      base/htime.h
  4. 2 2
      event/nio.c
  5. 2 2
      main.cpp.tmpl

+ 2 - 1
BUILD.md

@@ -26,9 +26,10 @@ winbuild/libhv/libhv.sln
 ### mingw
 see CROSS_COMPILE
 
-for examples
+For example:
 ```
 sudo apt-get install mingw-w64 # ubuntu
+#export CROSS_COMPILE=i686-w64-mingw32-
 export CROSS_COMPILE=x86_64-w64-mingw32-
 ./configure
 make

+ 8 - 4
base/hplatform.h

@@ -55,9 +55,6 @@
 #pragma warning (disable: 4100) // unused param
 #pragma warning (disable: 4819) // Unicode
 #pragma warning (disable: 4996) // _CRT_SECURE_NO_WARNINGS
-
-#undef  HAVE_PTHREAD_H
-#define HAVE_PTHREAD_H  0
 #endif
 
 // __MINGW32__
@@ -138,7 +135,6 @@
 #else
     #include <unistd.h>
     #include <dirent.h>     // for mkdir,rmdir,chdir,getcwd
-    #include <sys/time.h>   // for gettimeofday
 
     // socket
     #include <sys/socket.h>
@@ -196,8 +192,16 @@ typedef unsigned __int64    uint64_t;
 #include <fcntl.h>
 #endif
 
+#ifndef _MSC_VER
+
+#if HAVE_SYS_TIME_H
+#include <sys/time.h>   // for gettimeofday
+#endif
+
 #if HAVE_PTHREAD_H
 #include <pthread.h>
 #endif
 
+#endif
+
 #endif // HV_PLATFORM_H_

+ 2 - 3
base/htime.h

@@ -34,8 +34,6 @@ static inline void usleep(unsigned int us) {
     Sleep(us/1000);
 }
 
-#include <sys/timeb.h>
-
 #ifdef _MSC_VER
 /* @see winsock2.h
 // Structure used in select() call, taken from the BSD file sys/time.h
@@ -49,8 +47,8 @@ struct timezone {
     int tz_minuteswest; /* of Greenwich */
     int tz_dsttime;     /* type of dst correction to apply */
 };
-#endif
 
+#include <sys/timeb.h>
 static inline int gettimeofday(struct timeval *tv, struct timezone *tz) {
     struct _timeb tb;
 
@@ -69,6 +67,7 @@ static inline int gettimeofday(struct timeval *tv, struct timezone *tz) {
     return 0;
 }
 #endif
+#endif
 
 static inline void msleep(unsigned int ms) {
 #ifdef OS_WIN

+ 2 - 2
event/nio.c

@@ -427,9 +427,9 @@ int hio_close (hio_t* io) {
     }
 #endif
     if (io->close_cb) {
-        printd("close_cb------\n");
+        //printd("close_cb------\n");
         io->close_cb(io);
-        printd("close_cb======\n");
+        //printd("close_cb======\n");
     }
     return 0;
 }

+ 2 - 2
main.cpp.tmpl

@@ -269,13 +269,13 @@ int main(int argc, char** argv) {
     // pidfile
     create_pidfile();
 
-    master_workers_run(worker_fn, (void*)100L, g_conf_ctx.worker_processes, g_conf_ctx.worker_threads);
+    master_workers_run(worker_fn, (void*)(intptr_t)100L, g_conf_ctx.worker_processes, g_conf_ctx.worker_threads);
 
     return 0;
 }
 
 void worker_fn(void* userdata) {
-    int num = (int)(long)(userdata);
+    int num = (int)(intptr_t)(userdata);
     while (1) {
         printf("num=%d pid=%d tid=%d\n", num, getpid(), gettid());
         sleep(60);