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.13 by root, Wed Aug 19 23:44:51 2009 UTC vs.
Revision 1.17 by root, Sat Oct 17 21:47:56 2015 UTC

4 * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de> 4 * Copyright (c) 2007,2008,2009 Marc Alexander Lehmann <libev@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright notice, 10 * 1. Redistributions of source code must retain the above copyright notice,
11 * this list of conditions and the following disclaimer. 11 * this list of conditions and the following disclaimer.
12 * 12 *
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution. 15 * documentation and/or other materials provided with the distribution.
16 * 16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER- 18 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
19 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 19 * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE- 20 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
21 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
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
131 return -1; 138 return -1;
132} 139}
133 140
134#undef pipe 141#undef pipe
135#define pipe(filedes) ev_pipe (filedes) 142#define pipe(filedes) ev_pipe (filedes)
136 143
137#define EV_HAVE_EV_TIME 1 144#define EV_HAVE_EV_TIME 1
138ev_tstamp 145ev_tstamp
139ev_time (void) 146ev_time (void)
140{ 147{
141 FILETIME ft; 148 FILETIME ft;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines