Skip to content

Commit

Permalink
add scaffold to test win32 build on *nix, improve readme, fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ncm committed Apr 1, 2010
1 parent b65f6dd commit bb83539
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Makefile
@@ -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
Empty file added dummy_headers/io.h
Empty file.
31 changes: 31 additions & 0 deletions dummy_headers/windows.h
@@ -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);
Empty file added dummy_headers/winsock2.h
Empty file.

0 comments on commit bb83539

Please sign in to comment.