Procházet zdrojové kódy

make windows happy

ithewei před 5 roky
rodič
revize
7e93e3a283
2 změnil soubory, kde provedl 12 přidání a 2 odebrání
  1. 11 1
      base/hsocket.c
  2. 1 1
      hconfig.h

+ 11 - 1
base/hsocket.c

@@ -2,6 +2,10 @@
 
 #include "hdef.h"
 
+#ifdef OS_WIN
+static int s_wsa_initialized = 0;
+#endif
+
 static inline int socket_errno_negative() {
     int err = socket_errno();
     return err > 0 ? -err : -1;
@@ -147,7 +151,6 @@ error:
 
 int Bind(int port, const char* host, int type) {
 #ifdef OS_WIN
-    static int s_wsa_initialized = 0;
     if (s_wsa_initialized == 0) {
         s_wsa_initialized = 1;
         WSADATA wsadata;
@@ -170,6 +173,13 @@ int Listen(int port, const char* host) {
 }
 
 int Connect(const char* host, int port, int nonblock) {
+#ifdef OS_WIN
+    if (s_wsa_initialized == 0) {
+        s_wsa_initialized = 1;
+        WSADATA wsadata;
+        WSAStartup(MAKEWORD(2,2), &wsadata);
+    }
+#endif
     sockaddr_u peeraddr;
     memset(&peeraddr, 0, sizeof(peeraddr));
     int ret = sockaddr_set_ipport(&peeraddr, host, port);

+ 1 - 1
hconfig.h

@@ -10,7 +10,7 @@
 #endif
 
 #ifndef HAVE_STDATOMIC_H
-#define HAVE_STDATOMIC_H 1
+#define HAVE_STDATOMIC_H 0
 #endif
 
 #ifndef HAVE_SYS_TYPES_H