Permalink
Browse files

add scaffold to test win32 build on *nix, improve readme, fix typo

  • Loading branch information...
1 parent b65f6dd commit bb835399684f3e0575fec08e7bc18eea877f2894 @ncm committed Apr 1, 2010
Showing with 43 additions and 0 deletions.
  1. +12 −0 Makefile
  2. 0 dummy_headers/io.h
  3. +31 −0 dummy_headers/windows.h
  4. 0 dummy_headers/winsock2.h
View
@@ -0,0 +1,12 @@
+# On Windows, add "-DWIN32"
+CC=gcc
+CFLAGS=-O3 -W -Wall -Wextra
+LIB=socketpair
+
+all: $(LIB).o
+
+dummy: # test win32 build on unix
+ $(CC) -DWIN32 $(CFLAGS) -Idummy_headers -c -o $(LIB).dummy $(LIB).c
+ rm $(LIB).dummy
+
+clean:; rm $(LIB).o
View
No changes.
View
@@ -0,0 +1,31 @@
+typedef void* SOCKET;
+typedef unsigned int DWORD;
+#define WSA_FLAG_OVERLAPPED 1
+extern void WSASetLastError(int);
+extern int WSAGetLastError();
+#define WSAEINVAL 22
+#define SOCKET_ERROR -1
+#define AF_INET 33
+#define SOCK_STREAM 44
+#define IPPROTO_TCP 55
+#define INVALID_SOCKET 0
+extern void* socket(int, int, int);
+struct sockaddr_in {
+ int sin_family;
+ struct { unsigned s_addr; } sin_addr;
+ unsigned short sin_port;
+};
+struct sockaddr { int dummy; };
+typedef unsigned socklen_t;
+#define SOL_SOCKET 66
+#define SO_REUSEADDR 77
+#define INADDR_LOOPBACK 88
+extern int setsockopt(SOCKET, int, int, char*, unsigned);
+extern int bind(SOCKET, struct sockaddr*, unsigned);
+extern int getsockname(SOCKET, struct sockaddr*, socklen_t*);
+extern int listen(SOCKET, int);
+extern SOCKET WSASocket(int, int, int, void*, int, int);
+extern int connect(SOCKET, struct sockaddr*, unsigned);
+extern SOCKET accept(SOCKET, void*, void*);
+extern int closesocket(SOCKET);
+extern unsigned htonl(unsigned);
View
No changes.

0 comments on commit bb83539

Please sign in to comment.