ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev_win32.c
(Generate patch)

Comparing libev/ev_win32.c (file contents):
Revision 1.14 by root, Wed Feb 16 08:02:50 2011 UTC vs.
Revision 1.18 by root, Thu Nov 12 07:02:37 2015 UTC

37 * either the BSD or the GPL. 37 * either the BSD or the GPL.
38 */ 38 */
39 39
40#ifdef _WIN32 40#ifdef _WIN32
41 41
42/* timeb.h is actually xsi legacy functionality */
43#include <sys/timeb.h>
44
45/* note: the comment below could not be substantiated, but what would I care */ 42/* note: the comment below could not be substantiated, but what would I care */
46/* MSDN says this is required to handle SIGFPE */ 43/* MSDN says this is required to handle SIGFPE */
47/* my wild guess would be that using something floating-pointy is required */ 44/* my wild guess would be that using something floating-pointy is required */
48/* for the crt to do something about it */ 45/* for the crt to do something about it */
49volatile double SIGFPE_REQ = 0.0f; 46volatile double SIGFPE_REQ = 0.0f;
47
48static SOCKET
49ev_tcp_socket (void)
50{
51#if EV_USE_WSASOCKET
52 return WSASocket (AF_INET, SOCK_STREAM, 0, 0, 0, 0);
53#else
54 return socket (AF_INET, SOCK_STREAM, 0);
55#endif
56}
50 57
51/* oh, the humanity! */ 58/* oh, the humanity! */
52static int 59static int
53ev_pipe (int filedes [2]) 60ev_pipe (int filedes [2])
54{ 61{
57 struct sockaddr_in adr2; 64 struct sockaddr_in adr2;
58 int adr2_size = sizeof (adr2); 65 int adr2_size = sizeof (adr2);
59 SOCKET listener; 66 SOCKET listener;
60 SOCKET sock [2] = { -1, -1 }; 67 SOCKET sock [2] = { -1, -1 };
61 68
62 if ((listener = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) 69 if ((listener = ev_tcp_socket ()) == INVALID_SOCKET)
63 return -1; 70 return -1;
64 71
65 addr.sin_family = AF_INET; 72 addr.sin_family = AF_INET;
66 addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK); 73 addr.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
67 addr.sin_port = 0; 74 addr.sin_port = 0;
73 goto fail; 80 goto fail;
74 81
75 if (listen (listener, 1)) 82 if (listen (listener, 1))
76 goto fail; 83 goto fail;
77 84
78 if ((sock [0] = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) 85 if ((sock [0] = ev_tcp_socket ()) == INVALID_SOCKET)
79 goto fail; 86 goto fail;
80 87
81 if (connect (sock [0], (struct sockaddr *)&addr, addr_size)) 88 if (connect (sock [0], (struct sockaddr *)&addr, addr_size))
82 goto fail; 89 goto fail;
83 90
91 /* TODO: returns INVALID_SOCKET on winsock accept, not < 0. fix it */
92 /* when convenient, probably by just removing error checking altogether? */
84 if ((sock [1] = accept (listener, 0, 0)) < 0) 93 if ((sock [1] = accept (listener, 0, 0)) < 0)
85 goto fail; 94 goto fail;
86 95
87 /* windows vista returns fantasy port numbers for sockets: 96 /* windows vista returns fantasy port numbers for sockets:
88 * example for two interconnected tcp sockets: 97 * example for two interconnected tcp sockets:
131 return -1; 140 return -1;
132} 141}
133 142
134#undef pipe 143#undef pipe
135#define pipe(filedes) ev_pipe (filedes) 144#define pipe(filedes) ev_pipe (filedes)
136 145
137#define EV_HAVE_EV_TIME 1 146#define EV_HAVE_EV_TIME 1
138ev_tstamp 147ev_tstamp
139ev_time (void) 148ev_time (void)
140{ 149{
141 FILETIME ft; 150 FILETIME ft;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines