Parcourir la source

fix #396: blocking macro conflict with eigen

ithewei il y a 1 an
Parent
commit
f0e11406ac
1 fichiers modifiés avec 11 ajouts et 3 suppressions
  1. 11 3
      base/hsocket.h

+ 11 - 3
base/hsocket.h

@@ -66,13 +66,21 @@ HV_INLINE int nonblocking(int sockfd) {
 
 typedef int     hsocket_t;
 
-#define blocking(s)     fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK)
-#define nonblocking(s)  fcntl(s, F_SETFL, fcntl(s, F_GETFL) |  O_NONBLOCK)
-
 #ifndef SOCKET
 #define SOCKET int
 #endif
+
+#ifndef INVALID_SOCKET
 #define INVALID_SOCKET  -1
+#endif
+
+HV_INLINE int blocking(int s) {
+    return fcntl(s, F_SETFL, fcntl(s, F_GETFL) & ~O_NONBLOCK);
+}
+
+HV_INLINE int nonblocking(int s) {
+    return fcntl(s, F_SETFL, fcntl(s, F_GETFL) |  O_NONBLOCK);
+}
 
 HV_INLINE int closesocket(int sockfd) {
     return close(sockfd);