Merge lp:~brianaker/libdrizzle/windows-support-via-mingw into lp:libdrizzle
- windows-support-via-mingw
- Merge into libdrizzle-redux
Proposed by
Brian Aker
Status: | Merged |
---|---|
Approved by: | Andrew Hutchings |
Approved revision: | 81 |
Merged at revision: | 81 |
Proposed branch: | lp:~brianaker/libdrizzle/windows-support-via-mingw |
Merge into: | lp:libdrizzle |
Diff against target: |
1359 lines (+509/-354) 24 files modified
cli/drizzle_binlogs.c (+13/-3) cli/include.am (+3/-1) configure.ac (+20/-6) libdrizzle-5.1/drizzle.h (+8/-44) libdrizzle-5.1/drizzle_client.h (+11/-2) libdrizzle-5.1/visibility.h (+9/-51) libdrizzle/binlog.cc (+1/-0) libdrizzle/common.h (+24/-8) libdrizzle/conn.cc (+55/-138) libdrizzle/drizzle.cc (+3/-1) libdrizzle/error.cc (+3/-1) libdrizzle/include.am (+11/-3) libdrizzle/poll.cc (+86/-0) libdrizzle/poll.h (+47/-0) libdrizzle/query.cc (+2/-0) libdrizzle/ssl.cc (+13/-1) libdrizzle/statement_local.h (+0/-7) libdrizzle/structs.h (+13/-5) libdrizzle/windows.hpp (+123/-0) m4/ax_platform.m4 (+10/-6) m4/bottom.m4 (+6/-23) m4/socket_send_flags.m4 (+47/-48) tests/unit/binlog.c (+0/-1) tests/unit/row.c (+1/-5) |
To merge this branch: | bzr merge lp:~brianaker/libdrizzle/windows-support-via-mingw |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Andrew Hutchings | Approve | ||
Review via email: mp+142013@code.launchpad.net |
Commit message
Description of the change
Windows support via compiling with Mingw.
To post a comment you must log in.
- 81. By Brian Aker
-
Merge mingw tree with trunk.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'cli/drizzle_binlogs.c' |
2 | --- cli/drizzle_binlogs.c 2013-01-05 10:27:32 +0000 |
3 | +++ cli/drizzle_binlogs.c 2013-01-05 15:58:23 +0000 |
4 | @@ -34,16 +34,26 @@ |
5 | * |
6 | */ |
7 | |
8 | -#define _GNU_SOURCE 1 |
9 | +#include "config.h" |
10 | + |
11 | #include <libdrizzle-5.1/libdrizzle.h> |
12 | #include <stdlib.h> |
13 | #include <sys/types.h> |
14 | -#include <pwd.h> |
15 | + |
16 | +#ifdef HAVE_PWD_H |
17 | +# include <pwd.h> |
18 | +#endif |
19 | + |
20 | #include <unistd.h> |
21 | #include <errno.h> |
22 | -#include <argp.h> |
23 | #include <time.h> |
24 | |
25 | +#ifdef HAVE_ARGP_H |
26 | +# include <argp.h> |
27 | +#else |
28 | +# error "drizzle_binlogs requires <argp.h>" |
29 | +#endif |
30 | + |
31 | #define STR_HELPER(x) #x |
32 | #define STR(x) STR_HELPER(x) |
33 | |
34 | |
35 | === modified file 'cli/include.am' |
36 | --- cli/include.am 2012-12-28 21:23:12 +0000 |
37 | +++ cli/include.am 2013-01-05 15:58:23 +0000 |
38 | @@ -2,10 +2,12 @@ |
39 | # included from Top Level Makefile.am |
40 | # All paths should be given relative to the root |
41 | |
42 | +if BUILD_WIN32 |
43 | +else |
44 | bin_PROGRAMS+= cli/drizzle_binlogs |
45 | cli_drizzle_binlogs_SOURCES= cli/drizzle_binlogs.c |
46 | cli_drizzle_binlogs_LDADD= libdrizzle/libdrizzle.la |
47 | |
48 | check_SCRIPTS+= cli/drizzle_binlogs_check.sh |
49 | EXTRA_DIST+= ${check_SCRIPTS} |
50 | - |
51 | +endif |
52 | |
53 | === modified file 'configure.ac' |
54 | --- configure.ac 2013-01-04 20:47:22 +0000 |
55 | +++ configure.ac 2013-01-05 15:58:23 +0000 |
56 | @@ -57,23 +57,37 @@ |
57 | |
58 | # Checks for libraries. |
59 | AX_CXX_GCC_ABI_DEMANGLE |
60 | -AX_CHECK_OPENSSL |
61 | + |
62 | +AS_IF([test "x${target_os}" != "xmingw32"], [AX_CHECK_OPENSSL]) |
63 | + |
64 | AC_PATH_ZLIB |
65 | |
66 | # Checks for header files. |
67 | AC_DEFUN([CHECK_FOR_CXXABI], |
68 | [AC_LANG_PUSH([C++]) |
69 | AC_CHECK_HEADERS([cxxabi.h]) |
70 | - AC_LANG_POP |
71 | - ]) |
72 | + AC_LANG_POP]) |
73 | + |
74 | CHECK_FOR_CXXABI |
75 | -AC_CHECK_HEADERS_ONCE([errno.h]) |
76 | -AC_CHECK_HEADERS_ONCE([sys/socket.h]) |
77 | -AC_CHECK_HEADERS_ONCE([poll.h]) |
78 | +AC_CHECK_HEADERS([argp.h]) |
79 | +AC_CHECK_HEADERS([errno.h]) |
80 | +AC_CHECK_HEADERS([fcntl.h]) |
81 | +AC_CHECK_HEADERS([io.h]) |
82 | +AC_CHECK_HEADERS([openssl/ssl.h]) |
83 | +AC_CHECK_HEADERS([poll.h]) |
84 | +AC_CHECK_HEADERS([pwd.h]) |
85 | +AC_CHECK_HEADERS([sys/socket.h]) |
86 | +AC_CHECK_HEADERS([windows.h]) |
87 | +AC_CHECK_HEADERS([winsock2.h]) |
88 | +AC_CHECK_HEADERS([ws2tcpip.h]) |
89 | |
90 | # Checks for typedefs, structures, and compiler characteristics. |
91 | +AC_CHECK_TYPES([in_port_t]) |
92 | +AC_TYPE_SSIZE_T |
93 | +AC_TYPE_SIZE_T |
94 | |
95 | # Checks for library functions. |
96 | +AC_CHECK_FUNCS([fcntl]) |
97 | AC_CHECK_FUNCS([poll]) |
98 | AC_CHECK_FUNCS([ppoll]) |
99 | |
100 | |
101 | === modified file 'libdrizzle-5.1/drizzle.h' |
102 | --- libdrizzle-5.1/drizzle.h 2012-12-30 11:18:18 +0000 |
103 | +++ libdrizzle-5.1/drizzle.h 2013-01-05 15:58:23 +0000 |
104 | @@ -36,63 +36,27 @@ |
105 | |
106 | #pragma once |
107 | |
108 | +#ifndef DRIZZLE_CLIENT_INTERFACE |
109 | +# error "You need to include libdrizzle-5.1/drizzle_client.h in your application" |
110 | +#endif |
111 | + |
112 | /** |
113 | * @file |
114 | * @brief Drizzle Declarations |
115 | */ |
116 | |
117 | -#include <sys/types.h> |
118 | - |
119 | #ifdef _WIN32 |
120 | -# define WIN32_LEAN_AND_MEAN |
121 | - |
122 | -# include <Windows.h> |
123 | -# include <winsock2.h> |
124 | -# include <ws2tcpip.h> |
125 | -# include <io.h> |
126 | - |
127 | -# undef close |
128 | -# define close _close |
129 | -typedef unsigned int in_port_t; |
130 | -typedef long ssize_t; |
131 | - |
132 | -# define snprintf _snprintf |
133 | -# define inline __inline |
134 | - |
135 | -struct sockaddr_un |
136 | -{ |
137 | - short int sun_family; |
138 | - char sun_path[108]; |
139 | -}; |
140 | - |
141 | -# define poll WSAPoll |
142 | -//# define pollfd WSAPOLLFD |
143 | - |
144 | -#if defined(__GNUC__) |
145 | -# include <stdbool.h> |
146 | -#else |
147 | -# if !defined(__cplusplus) |
148 | -typedef enum { false = 0, true = 1 } _Bool; |
149 | -typedef _Bool bool; |
150 | -#endif |
151 | -#endif |
152 | - |
153 | -#else |
154 | -# if !defined(__cplusplus) |
155 | -# include <stdbool.h> |
156 | -# endif |
157 | + |
158 | +typedef int in_port_t; |
159 | + |
160 | +#else |
161 | # include <sys/socket.h> |
162 | # include <netinet/in.h> |
163 | # include <arpa/inet.h> |
164 | # include <sys/un.h> |
165 | # include <netdb.h> |
166 | -# include <poll.h> |
167 | -#endif |
168 | -#ifdef USE_OPENSSL |
169 | -#include <openssl/ssl.h> |
170 | #endif |
171 | |
172 | -#include <libdrizzle-5.1/visibility.h> |
173 | #include <libdrizzle-5.1/constants.h> |
174 | #include <libdrizzle-5.1/structs.h> |
175 | #include <libdrizzle-5.1/conn.h> |
176 | |
177 | === modified file 'libdrizzle-5.1/drizzle_client.h' |
178 | --- libdrizzle-5.1/drizzle_client.h 2012-12-24 10:20:04 +0000 |
179 | +++ libdrizzle-5.1/drizzle_client.h 2013-01-05 15:58:23 +0000 |
180 | @@ -42,6 +42,17 @@ |
181 | |
182 | #pragma once |
183 | |
184 | +#ifndef DRIZZLE_CLIENT_INTERFACE |
185 | +# define DRIZZLE_CLIENT_INTERFACE 1 |
186 | +#endif |
187 | + |
188 | +#include <stdbool.h> |
189 | +#include <stdint.h> |
190 | +#include <sys/types.h> |
191 | + |
192 | +/* Visibility must come first */ |
193 | +#include <libdrizzle-5.1/visibility.h> |
194 | + |
195 | #include <libdrizzle-5.1/drizzle.h> |
196 | #include <libdrizzle-5.1/conn_client.h> |
197 | #include <libdrizzle-5.1/handshake_client.h> |
198 | @@ -52,9 +63,7 @@ |
199 | #include <libdrizzle-5.1/row_client.h> |
200 | #include <libdrizzle-5.1/field_client.h> |
201 | #include <libdrizzle-5.1/error.h> |
202 | -#ifdef USE_OPENSSL |
203 | #include <libdrizzle-5.1/ssl.h> |
204 | -#endif |
205 | #include <libdrizzle-5.1/binlog.h> |
206 | #include <libdrizzle-5.1/statement.h> |
207 | #include <libdrizzle-5.1/version.h> |
208 | |
209 | === modified file 'libdrizzle-5.1/visibility.h' |
210 | --- libdrizzle-5.1/visibility.h 2012-12-18 11:36:28 +0000 |
211 | +++ libdrizzle-5.1/visibility.h 2013-01-05 15:58:23 +0000 |
212 | @@ -1,44 +1,11 @@ |
213 | -/* |
214 | - * Drizzle Client & Protocol Library |
215 | - * |
216 | - * Copyright (C) 2008 Eric Day (eday@oddments.org) |
217 | +/* libdrizzle |
218 | + * Copyright (C) 2013 Drizzle Developers Group |
219 | * All rights reserved. |
220 | * |
221 | - * Redistribution and use in source and binary forms, with or without |
222 | - * modification, are permitted provided that the following conditions are |
223 | - * met: |
224 | - * |
225 | - * * Redistributions of source code must retain the above copyright |
226 | - * notice, this list of conditions and the following disclaimer. |
227 | - * |
228 | - * * Redistributions in binary form must reproduce the above |
229 | - * copyright notice, this list of conditions and the following disclaimer |
230 | - * in the documentation and/or other materials provided with the |
231 | - * distribution. |
232 | - * |
233 | - * * The names of its contributors may not be used to endorse or |
234 | - * promote products derived from this software without specific prior |
235 | - * written permission. |
236 | - * |
237 | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
238 | - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
239 | - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
240 | - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
241 | - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
242 | - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
243 | - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
244 | - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
245 | - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
246 | - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
247 | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
248 | - * |
249 | - * |
250 | - * Implementation drawn from visibility.texi in gnulib. |
251 | - */ |
252 | - |
253 | -/** |
254 | - * @file |
255 | - * @brief Visibility Control Macros |
256 | + * Use and distribution licensed under the BSD license. See |
257 | + * the COPYING file in the parent directory for full text. |
258 | + * |
259 | + * |
260 | */ |
261 | |
262 | #pragma once |
263 | @@ -48,31 +15,22 @@ |
264 | * DRIZZLE_API is used for the public API symbols. It either DLL imports or |
265 | * DLL exports (or does nothing for static build). |
266 | * |
267 | - * DRIZZLE_LOCAL is used for non-api symbols. |
268 | */ |
269 | |
270 | -#if defined(_WIN32) |
271 | -# define DRIZZLE_API |
272 | -# define DRIZZLE_LOCAL |
273 | -#else |
274 | #if defined(BUILDING_LIBDRIZZLE) |
275 | -# if defined(HAVE_VISIBILITY) |
276 | +# if defined(HAVE_VISIBILITY) && HAVE_VISIBILITY |
277 | # define DRIZZLE_API __attribute__ ((visibility("default"))) |
278 | -# define DRIZZLE_LOCAL __attribute__ ((visibility("hidden"))) |
279 | # elif defined (__SUNPRO_C) && (__SUNPRO_C >= 0x550) |
280 | # define DRIZZLE_API __global |
281 | -# define DRIZZLE_API __hidden |
282 | # elif defined(_MSC_VER) |
283 | # define DRIZZLE_API extern __declspec(dllexport) |
284 | -# define DRIZZLE_LOCAL |
285 | +# else |
286 | +# define DRIZZLE_API |
287 | # endif /* defined(HAVE_VISIBILITY) */ |
288 | #else /* defined(BUILDING_LIBDRIZZLE) */ |
289 | # if defined(_MSC_VER) |
290 | # define DRIZZLE_API extern __declspec(dllimport) |
291 | -# define DRIZZLE_LOCAL |
292 | # else |
293 | # define DRIZZLE_API |
294 | -# define DRIZZLE_LOCAL |
295 | # endif /* defined(_MSC_VER) */ |
296 | #endif /* defined(BUILDING_LIBDRIZZLE) */ |
297 | -#endif /* _WIN32 */ |
298 | |
299 | === modified file 'libdrizzle/binlog.cc' |
300 | --- libdrizzle/binlog.cc 2013-01-05 10:27:32 +0000 |
301 | +++ libdrizzle/binlog.cc 2013-01-05 15:58:23 +0000 |
302 | @@ -37,6 +37,7 @@ |
303 | |
304 | #include "config.h" |
305 | #include "libdrizzle/common.h" |
306 | + |
307 | #include <zlib.h> |
308 | |
309 | drizzle_result_st *drizzle_start_binlog(drizzle_st *con, |
310 | |
311 | === modified file 'libdrizzle/common.h' |
312 | --- libdrizzle/common.h 2012-12-31 07:11:30 +0000 |
313 | +++ libdrizzle/common.h 2013-01-05 15:58:23 +0000 |
314 | @@ -41,18 +41,35 @@ |
315 | |
316 | #pragma once |
317 | |
318 | -#include "config.h" |
319 | - |
320 | #include <libdrizzle-5.1/drizzle_client.h> |
321 | |
322 | -#include <assert.h> |
323 | -#include <errno.h> |
324 | - |
325 | -#include <fcntl.h> |
326 | -#ifndef _WIN32 |
327 | +#include <cassert> |
328 | + |
329 | +#ifdef HAVE_FCNTL_H |
330 | +# include <fcntl.h> |
331 | +#endif |
332 | + |
333 | +#if defined(WIN32) || defined(__MINGW32__) |
334 | +# include "libdrizzle/windows.hpp" |
335 | +# define get_socket_errno() WSAGetLastError() |
336 | + |
337 | +#else |
338 | # include <netinet/tcp.h> |
339 | # include <sys/uio.h> |
340 | # include <unistd.h> |
341 | +# include <cerrno> |
342 | +# define INVALID_SOCKET -1 |
343 | +# define SOCKET_ERROR -1 |
344 | +# define closesocket(a) close(a) |
345 | +# define get_socket_errno() errno |
346 | + |
347 | +#endif // defined(WIN32) || defined(__MINGW32__) |
348 | + |
349 | +#if defined(HAVE_POLL_H) && HAVE_POLL_H |
350 | +# include <poll.h> |
351 | +typedef struct pollfd pollfd_t; |
352 | +#else |
353 | +# include "libdrizzle/poll.h" |
354 | #endif |
355 | |
356 | #include <stddef.h> |
357 | @@ -60,7 +77,6 @@ |
358 | #include <stdio.h> |
359 | #include <stdlib.h> |
360 | #include <string.h> |
361 | -#include <signal.h> |
362 | |
363 | #include "libdrizzle/structs.h" |
364 | #include "libdrizzle/drizzle_local.h" |
365 | |
366 | === modified file 'libdrizzle/conn.cc' |
367 | --- libdrizzle/conn.cc 2013-01-05 11:41:26 +0000 |
368 | +++ libdrizzle/conn.cc 2013-01-05 15:58:23 +0000 |
369 | @@ -56,10 +56,24 @@ |
370 | # define FD_CLOEXEC 0 |
371 | #endif |
372 | |
373 | +#ifndef F_GETFD |
374 | +# define F_GETFD 0 |
375 | +#endif |
376 | + |
377 | #ifndef MSG_DONTWAIT |
378 | # define MSG_DONTWAIT 0 |
379 | #endif |
380 | |
381 | +#ifndef MSG_NOSIGNAL |
382 | +# define MSG_NOSIGNAL 0 |
383 | +#endif |
384 | + |
385 | +#ifndef EWOULDBLOCK |
386 | +# define EWOULDBLOCK EAGAIN |
387 | +#endif |
388 | + |
389 | +#include <cerrno> |
390 | + |
391 | /** |
392 | * @addtogroup drizzle_static Static Connection Declarations |
393 | * @ingroup drizzle_con |
394 | @@ -75,52 +89,15 @@ |
395 | */ |
396 | static drizzle_return_t _setsockopt(drizzle_st *con); |
397 | |
398 | -static void __closesocket(int& fd) |
399 | +static void __closesocket(socket_t& fd) |
400 | { |
401 | - if (fd != -1) |
402 | + if (fd != INVALID_SOCKET) |
403 | { |
404 | (void)shutdown(fd, SHUT_RDWR); |
405 | (void)closesocket(fd); |
406 | - fd= -1; |
407 | - } |
408 | -} |
409 | - |
410 | -#ifdef WIN32 |
411 | -static void translate_windows_error() |
412 | -{ |
413 | - errno= WSAGetLastError(); |
414 | - switch(errno) { |
415 | - case WSAEINVAL: |
416 | - case WSAEALREADY: |
417 | - case WSAEWOULDBLOCK: |
418 | - errno= EINPROGRESS; |
419 | - break; |
420 | - case WSAECONNREFUSED: |
421 | - errno= ECONNREFUSED; |
422 | - break; |
423 | - case WSAENETUNREACH: |
424 | - errno= ENETUNREACH; |
425 | - break; |
426 | - case WSAETIMEDOUT: |
427 | - errno= ETIMEDOUT; |
428 | - break; |
429 | - case WSAECONNRESET: |
430 | - errno= ECONNRESET; |
431 | - break; |
432 | - case WSAEADDRINUSE: |
433 | - errno= EADDRINUSE; |
434 | - break; |
435 | - case WSAEOPNOTSUPP: |
436 | - errno= EOPNOTSUPP; |
437 | - break; |
438 | - case WSAENOPROTOOPT: |
439 | - errno= ENOPROTOOPT; |
440 | - break; |
441 | - default: |
442 | - break; |
443 | - } |
444 | -} |
445 | -#endif |
446 | + fd= INVALID_SOCKET; |
447 | + } |
448 | +} |
449 | |
450 | static bool connect_poll(drizzle_st *con) |
451 | { |
452 | @@ -148,7 +125,11 @@ |
453 | |
454 | if (fds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) |
455 | { |
456 | +#ifdef __MINGW32__ |
457 | + char err; |
458 | +#else |
459 | int err; |
460 | +#endif |
461 | socklen_t len= sizeof (err); |
462 | // We replace errno with err if getsockopt() passes, but err has been |
463 | // set. |
464 | @@ -232,7 +213,7 @@ |
465 | return; |
466 | } |
467 | |
468 | - if (con->fd == -1) |
469 | + if (con->fd == INVALID_SOCKET) |
470 | { |
471 | return; |
472 | } |
473 | @@ -935,7 +916,9 @@ |
474 | |
475 | if (con->socket_type == DRIZZLE_CON_SOCKET_UDS) |
476 | { |
477 | -#ifndef WIN32 |
478 | +#if defined _WIN32 || defined __CYGWIN__ |
479 | + return DRIZZLE_RETURN_COULD_NOT_CONNECT; |
480 | +#else // defined _WIN32 || defined __CYGWIN__ |
481 | if ((con->fd= socket(AF_UNIX, SOCK_STREAM, 0)) < 0) |
482 | { |
483 | con->last_errno= errno; |
484 | @@ -971,9 +954,7 @@ |
485 | } while (0); |
486 | |
487 | return DRIZZLE_RETURN_OK; |
488 | -#else |
489 | - return DRIZZLE_RETURN_COULD_NOT_CONNECT; |
490 | -#endif |
491 | +#endif // defined _WIN32 || defined __CYGWIN__ |
492 | } |
493 | else |
494 | { |
495 | @@ -1020,7 +1001,7 @@ |
496 | { |
497 | int ret= connect(con->fd, con->addrinfo_next->ai_addr, con->addrinfo_next->ai_addrlen); |
498 | |
499 | -#ifdef _WIN32 |
500 | +#if defined _WIN32 || defined __CYGWIN__ |
501 | translate_windows_error(); |
502 | #endif /* _WIN32 */ |
503 | |
504 | @@ -1086,7 +1067,7 @@ |
505 | drizzle_state_pop(con); |
506 | socklen_t error_length= sizeof(error); |
507 | int getsockopt_error; |
508 | - if ((getsockopt_error= getsockopt(con->fd, SOL_SOCKET, SO_ERROR, (void*)&error, &error_length)) < 1) |
509 | + if ((getsockopt_error= getsockopt(con->fd, SOL_SOCKET, SO_ERROR, (char*)&error, &error_length)) < 1) |
510 | { |
511 | drizzle_set_error(con, __func__, strerror(getsockopt_error)); |
512 | return DRIZZLE_RETURN_COULD_NOT_CONNECT; |
513 | @@ -1177,46 +1158,10 @@ |
514 | { |
515 | read_size= recv(con->fd, (char *)con->buffer_ptr + con->buffer_size, available_buffer, MSG_NOSIGNAL); |
516 | } |
517 | -#ifdef _WIN32 |
518 | - if (_WIN32) |
519 | - { |
520 | - errno= WSAGetLastError(); |
521 | - switch (errno) |
522 | - { |
523 | - case WSAENOTCONN: |
524 | - case WSAEWOULDBLOCK: |
525 | - errno= EAGAIN; |
526 | - break; |
527 | - case WSAEINVAL: |
528 | - case WSAEALREADY: |
529 | - errno= EINPROGRESS; |
530 | - break; |
531 | - case WSAECONNREFUSED: |
532 | - errno= ECONNREFUSED; |
533 | - break; |
534 | - case WSAENETUNREACH: |
535 | - errno= ENETUNREACH; |
536 | - break; |
537 | - case WSAETIMEDOUT: |
538 | - errno= ETIMEDOUT; |
539 | - break; |
540 | - case WSAECONNRESET: |
541 | - errno= ECONNRESET; |
542 | - break; |
543 | - case WSAEADDRINUSE: |
544 | - errno= EADDRINUSE; |
545 | - break; |
546 | - case WSAEOPNOTSUPP: |
547 | - errno= EOPNOTSUPP; |
548 | - break; |
549 | - case WSAENOPROTOOPT: |
550 | - errno= ENOPROTOOPT; |
551 | - break; |
552 | - default: |
553 | - break; |
554 | - } |
555 | - } |
556 | -#endif /* _WIN32 */ |
557 | + |
558 | +#if defined _WIN32 || defined __CYGWIN__ |
559 | + errno= translate_windows_error(); |
560 | +#endif // defined _WIN32 || defined __CYGWIN__ |
561 | |
562 | drizzle_log_crazy(con, "read fd=%d recv=%zd ssl= %d errno=%s", |
563 | con->fd, read_size, |
564 | @@ -1337,42 +1282,9 @@ |
565 | write_size= send(con->fd,(char *) con->buffer_ptr, con->buffer_size, MSG_NOSIGNAL); |
566 | } |
567 | |
568 | -#ifdef _WIN32 |
569 | - errno = WSAGetLastError(); |
570 | - switch(errno) { |
571 | - case WSAENOTCONN: |
572 | - case WSAEWOULDBLOCK: |
573 | - errno= EAGAIN; |
574 | - break; |
575 | - case WSAEINVAL: |
576 | - case WSAEALREADY: |
577 | - errno= EINPROGRESS; |
578 | - break; |
579 | - case WSAECONNREFUSED: |
580 | - errno= ECONNREFUSED; |
581 | - break; |
582 | - case WSAENETUNREACH: |
583 | - errno= ENETUNREACH; |
584 | - break; |
585 | - case WSAETIMEDOUT: |
586 | - errno= ETIMEDOUT; |
587 | - break; |
588 | - case WSAECONNRESET: |
589 | - errno= ECONNRESET; |
590 | - break; |
591 | - case WSAEADDRINUSE: |
592 | - errno= EADDRINUSE; |
593 | - break; |
594 | - case WSAEOPNOTSUPP: |
595 | - errno= EOPNOTSUPP; |
596 | - break; |
597 | - case WSAENOPROTOOPT: |
598 | - errno= ENOPROTOOPT; |
599 | - break; |
600 | - default: |
601 | - break; |
602 | - } |
603 | -#endif /* _WIN32 */ |
604 | +#if defined _WIN32 || defined __CYGWIN__ |
605 | + errno= translate_windows_error(); |
606 | +#endif // defined _WIN32 || defined __CYGWIN__ |
607 | |
608 | drizzle_log_crazy(con, "write fd=%d return=%zd ssl=%d errno=%s", |
609 | con->fd, write_size, |
610 | @@ -1448,27 +1360,32 @@ |
611 | return DRIZZLE_RETURN_INVALID_ARGUMENT; |
612 | } |
613 | |
614 | - if (SOCK_CLOEXEC == 0) |
615 | +#ifdef HAVE_FCNTL |
616 | + if (HAVE_FCNTL) |
617 | { |
618 | - if (FD_CLOEXEC) |
619 | + if (SOCK_CLOEXEC == 0) |
620 | { |
621 | - int flags; |
622 | - do |
623 | + if (FD_CLOEXEC and F_GETFD) |
624 | { |
625 | - flags= fcntl(con->fd, F_GETFD, 0); |
626 | - } while (flags == -1 and (errno == EINTR or errno == EAGAIN)); |
627 | - |
628 | - if (flags != -1) |
629 | - { |
630 | - int rval; |
631 | + int flags; |
632 | do |
633 | + { |
634 | + flags= fcntl(con->fd, F_GETFD, 0); |
635 | + } while (flags == -1 and (errno == EINTR or errno == EAGAIN)); |
636 | + |
637 | + if (flags != -1) |
638 | { |
639 | - rval= fcntl (con->fd, F_SETFD, flags | FD_CLOEXEC); |
640 | - } while (rval == -1 && (errno == EINTR or errno == EAGAIN)); |
641 | - // we currently ignore the case where rval is -1 |
642 | + int rval; |
643 | + do |
644 | + { |
645 | + rval= fcntl (con->fd, F_SETFD, flags | FD_CLOEXEC); |
646 | + } while (rval == -1 && (errno == EINTR or errno == EAGAIN)); |
647 | + // we currently ignore the case where rval is -1 |
648 | + } |
649 | } |
650 | } |
651 | } |
652 | +#endif // HAVE_FCNTL |
653 | |
654 | |
655 | int ret= 1; |
656 | |
657 | === modified file 'libdrizzle/drizzle.cc' |
658 | --- libdrizzle/drizzle.cc 2013-01-05 11:31:45 +0000 |
659 | +++ libdrizzle/drizzle.cc 2013-01-05 15:58:23 +0000 |
660 | @@ -43,6 +43,8 @@ |
661 | #include "config.h" |
662 | #include "libdrizzle/common.h" |
663 | |
664 | +#include <cerrno> |
665 | + |
666 | /** |
667 | * @addtogroup drizzle_static Static Drizzle Declarations |
668 | * @ingroup drizzle |
669 | @@ -242,7 +244,7 @@ |
670 | |
671 | drizzle_result_free_all(con); |
672 | |
673 | - if (con->fd != -1) |
674 | + if (con->fd != INVALID_SOCKET) |
675 | { |
676 | drizzle_close(con); |
677 | } |
678 | |
679 | === modified file 'libdrizzle/error.cc' |
680 | --- libdrizzle/error.cc 2013-01-05 11:25:32 +0000 |
681 | +++ libdrizzle/error.cc 2013-01-05 15:58:23 +0000 |
682 | @@ -34,7 +34,9 @@ |
683 | * |
684 | */ |
685 | |
686 | -#include <libdrizzle/common.h> |
687 | +#include "config.h" |
688 | + |
689 | +#include "libdrizzle/common.h" |
690 | |
691 | const char *drizzle_strerror(const drizzle_return_t arg) |
692 | { |
693 | |
694 | === modified file 'libdrizzle/include.am' |
695 | --- libdrizzle/include.am 2012-12-31 07:11:30 +0000 |
696 | +++ libdrizzle/include.am 2013-01-05 15:58:23 +0000 |
697 | @@ -9,10 +9,12 @@ |
698 | noinst_HEADERS+= libdrizzle/datetime.h |
699 | noinst_HEADERS+= libdrizzle/drizzle_local.h |
700 | noinst_HEADERS+= libdrizzle/pack.h |
701 | +noinst_HEADERS+= libdrizzle/poll.h |
702 | noinst_HEADERS+= libdrizzle/sha1.h |
703 | noinst_HEADERS+= libdrizzle/state.h |
704 | noinst_HEADERS+= libdrizzle/statement_local.h |
705 | noinst_HEADERS+= libdrizzle/structs.h |
706 | +noinst_HEADERS+= libdrizzle/windows.hpp |
707 | |
708 | lib_LTLIBRARIES+= libdrizzle/libdrizzle.la |
709 | libdrizzle_libdrizzle_la_SOURCES= |
710 | @@ -23,12 +25,17 @@ |
711 | |
712 | libdrizzle_libdrizzle_la_CFLAGS+= @OPENSSL_INCLUDES@ |
713 | libdrizzle_libdrizzle_la_CXXFLAGS+= @OPENSSL_INCLUDES@ |
714 | +libdrizzle_libdrizzle_la_LDFLAGS+= @OPENSSL_LDFLAGS@ |
715 | +libdrizzle_libdrizzle_la_LIBADD+= @OPENSSL_LIBS@ |
716 | + |
717 | libdrizzle_libdrizzle_la_CFLAGS+= @ZLIB_CFLAGS@ |
718 | libdrizzle_libdrizzle_la_CXXFLAGS+= @ZLIB_CFLAGS@ |
719 | -libdrizzle_libdrizzle_la_LIBADD+= @OPENSSL_LIBS@ |
720 | +libdrizzle_libdrizzle_la_LDFLAGS+= @ZLIB_LDFLAGS@ |
721 | libdrizzle_libdrizzle_la_LIBADD+= @ZLIB_LIBS@ |
722 | -libdrizzle_libdrizzle_la_LDFLAGS+= @OPENSSL_LDFLAGS@ |
723 | -libdrizzle_libdrizzle_la_LDFLAGS+= @ZLIB_LDFLAGS@ |
724 | + |
725 | +if BUILD_WIN32 |
726 | +libdrizzle_libdrizzle_la_LIBADD+= -lmingw32 -lws2_32 -lgdi32 |
727 | +endif |
728 | |
729 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/binlog.cc |
730 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/command.cc |
731 | @@ -43,6 +50,7 @@ |
732 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/drizzle.cc |
733 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/field.cc |
734 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/pack.cc |
735 | +libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/poll.cc |
736 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/result.cc |
737 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/sha1.cc |
738 | libdrizzle_libdrizzle_la_SOURCES+= libdrizzle/state.cc |
739 | |
740 | === added file 'libdrizzle/poll.cc' |
741 | --- libdrizzle/poll.cc 1970-01-01 00:00:00 +0000 |
742 | +++ libdrizzle/poll.cc 2013-01-05 15:58:23 +0000 |
743 | @@ -0,0 +1,86 @@ |
744 | +/* LibMemcached |
745 | + * Copyright (C) 2010 Brian Aker, Trond Norbye |
746 | + * All rights reserved. |
747 | + * |
748 | + * Use and distribution licensed under the BSD license. See |
749 | + * the COPYING file in the parent directory for full text. |
750 | + * |
751 | + * Summary: Implementation of poll by using select |
752 | + * |
753 | + */ |
754 | + |
755 | +#include "config.h" |
756 | + |
757 | +#include "libdrizzle/common.h" |
758 | + |
759 | +#if defined(WIN32) || defined(__MINGW32__) |
760 | +#include "libdrizzle/poll.h" |
761 | + |
762 | +#include <sys/time.h> |
763 | +#include <strings.h> |
764 | + |
765 | +int poll(struct pollfd fds[], nfds_t nfds, int tmo) |
766 | +{ |
767 | + fd_set readfds, writefds, errorfds; |
768 | + FD_ZERO(&readfds); |
769 | + FD_ZERO(&writefds); |
770 | + FD_ZERO(&errorfds); |
771 | + |
772 | + int maxfd= 0; |
773 | + |
774 | + for (nfds_t x= 0; x < nfds; ++x) |
775 | + { |
776 | + if (fds[x].events & (POLLIN | POLLOUT)) |
777 | + { |
778 | +#ifndef WIN32 |
779 | + if (fds[x].fd > maxfd) |
780 | + { |
781 | + maxfd= fds[x].fd; |
782 | + } |
783 | +#endif |
784 | + if (fds[x].events & POLLIN) |
785 | + { |
786 | + FD_SET(fds[x].fd, &readfds); |
787 | + } |
788 | + if (fds[x].events & POLLOUT) |
789 | + { |
790 | + FD_SET(fds[x].fd, &writefds); |
791 | + } |
792 | + } |
793 | + } |
794 | + |
795 | + struct timeval timeout= { .tv_sec = tmo / 1000, |
796 | + .tv_usec= (tmo % 1000) * 1000 }; |
797 | + struct timeval *tp= &timeout; |
798 | + if (tmo == -1) |
799 | + { |
800 | + tp= NULL; |
801 | + } |
802 | + int ret= select(maxfd + 1, &readfds, &writefds, &errorfds, tp); |
803 | + if (ret <= 0) |
804 | + { |
805 | + return ret; |
806 | + } |
807 | + |
808 | + /* Iterate through all of them because I need to clear the revent map */ |
809 | + for (nfds_t x= 0; x < nfds; ++x) |
810 | + { |
811 | + fds[x].revents= 0; |
812 | + if (FD_ISSET(fds[x].fd, &readfds)) |
813 | + { |
814 | + fds[x].revents |= POLLIN; |
815 | + } |
816 | + if (FD_ISSET(fds[x].fd, &writefds)) |
817 | + { |
818 | + fds[x].revents |= POLLOUT; |
819 | + } |
820 | + if (FD_ISSET(fds[x].fd, &errorfds)) |
821 | + { |
822 | + fds[x].revents |= POLLERR; |
823 | + } |
824 | + } |
825 | + |
826 | + return ret; |
827 | +} |
828 | + |
829 | +#endif // defined(WIN32) || defined(__MINGW32__) |
830 | |
831 | === added file 'libdrizzle/poll.h' |
832 | --- libdrizzle/poll.h 1970-01-01 00:00:00 +0000 |
833 | +++ libdrizzle/poll.h 2013-01-05 15:58:23 +0000 |
834 | @@ -0,0 +1,47 @@ |
835 | +/* LibMemcached |
836 | + * Copyright (C) 2010 Brian Aker, Trond Norbye |
837 | + * All rights reserved. |
838 | + * |
839 | + * Use and distribution licensed under the BSD license. See |
840 | + * the COPYING file in the parent directory for full text. |
841 | + * |
842 | + * Summary: Implementation of poll by using select |
843 | + * |
844 | + */ |
845 | + |
846 | +#pragma once |
847 | + |
848 | +#if defined(WIN32) || defined(__MINGW32__) |
849 | + |
850 | +#include <winsock2.h> |
851 | + |
852 | +#ifdef __cplusplus |
853 | +extern "C" { |
854 | +#endif |
855 | + |
856 | +typedef struct pollfd |
857 | +{ |
858 | +#ifdef WIN32 |
859 | + SOCKET fd; |
860 | +#else |
861 | + int fd; |
862 | +#endif |
863 | + short events; |
864 | + short revents; |
865 | +} pollfd_t; |
866 | + |
867 | +typedef int nfds_t; |
868 | + |
869 | +#define POLLIN 0x0001 |
870 | +#define POLLOUT 0x0004 |
871 | +#define POLLERR 0x0008 |
872 | +#define POLLHUP 0x010 /* Hung up. */ |
873 | +#define POLLNVAL 0x020 /* Invalid polling request. */ |
874 | + |
875 | +int poll(struct pollfd fds[], nfds_t nfds, int tmo); |
876 | + |
877 | +#ifdef __cplusplus |
878 | +} |
879 | +#endif |
880 | + |
881 | +#endif // defined(WIN32) || defined(__MINGW32__) |
882 | |
883 | === modified file 'libdrizzle/query.cc' |
884 | --- libdrizzle/query.cc 2013-01-05 10:27:32 +0000 |
885 | +++ libdrizzle/query.cc 2013-01-05 15:58:23 +0000 |
886 | @@ -40,6 +40,8 @@ |
887 | * @brief Query definitions |
888 | */ |
889 | |
890 | +#include "config.h" |
891 | + |
892 | #include <libdrizzle/common.h> |
893 | |
894 | drizzle_result_st *drizzle_query(drizzle_st *con, |
895 | |
896 | === modified file 'libdrizzle/ssl.cc' |
897 | --- libdrizzle/ssl.cc 2012-12-24 10:20:04 +0000 |
898 | +++ libdrizzle/ssl.cc 2013-01-05 15:58:23 +0000 |
899 | @@ -36,10 +36,13 @@ |
900 | */ |
901 | |
902 | #include "config.h" |
903 | + |
904 | #include "libdrizzle/common.h" |
905 | |
906 | #include <libdrizzle-5.1/ssl.h> |
907 | -#include <openssl/ssl.h> |
908 | + |
909 | +#if defined(USE_OPENSSL) |
910 | +# include <openssl/ssl.h> |
911 | |
912 | drizzle_return_t drizzle_set_ssl(drizzle_st *con, const char *key, const char *cert, const char *ca, const char *capath, const char *cipher) |
913 | { |
914 | @@ -85,3 +88,12 @@ |
915 | |
916 | return DRIZZLE_RETURN_OK; |
917 | } |
918 | + |
919 | +#else |
920 | + |
921 | +drizzle_return_t drizzle_set_ssl(drizzle_st*, const char*, const char*, const char*, const char*, const char*) |
922 | +{ |
923 | + return DRIZZLE_RETURN_INVALID_ARGUMENT; |
924 | +} |
925 | + |
926 | +#endif |
927 | |
928 | === modified file 'libdrizzle/statement_local.h' |
929 | --- libdrizzle/statement_local.h 2013-01-05 11:25:32 +0000 |
930 | +++ libdrizzle/statement_local.h 2013-01-05 15:58:23 +0000 |
931 | @@ -41,25 +41,18 @@ |
932 | extern "C" { |
933 | #endif |
934 | |
935 | -DRIZZLE_LOCAL |
936 | drizzle_return_t drizzle_stmt_set_param(drizzle_stmt_st *stmt, uint16_t param_num, drizzle_column_type_t type, void *data, uint32_t length, bool is_unsigned, bool is_allocated); |
937 | |
938 | -DRIZZLE_LOCAL |
939 | char *long_to_string(drizzle_bind_st *param, uint32_t val); |
940 | |
941 | -DRIZZLE_LOCAL |
942 | char *longlong_to_string(drizzle_bind_st *param, uint64_t val); |
943 | |
944 | -DRIZZLE_LOCAL |
945 | char *double_to_string(drizzle_bind_st *param, double val); |
946 | |
947 | -DRIZZLE_LOCAL |
948 | char *time_to_string(drizzle_bind_st *param, drizzle_datetime_st *time); |
949 | |
950 | -DRIZZLE_LOCAL |
951 | char *timestamp_to_string(drizzle_bind_st *param, drizzle_datetime_st *timestamp); |
952 | |
953 | -DRIZZLE_LOCAL |
954 | uint16_t drizzle_stmt_column_lookup(drizzle_result_st *result, const char *column_name, drizzle_return_t *ret_ptr); |
955 | |
956 | #ifdef __cplusplus |
957 | |
958 | === modified file 'libdrizzle/structs.h' |
959 | --- libdrizzle/structs.h 2013-01-05 10:27:32 +0000 |
960 | +++ libdrizzle/structs.h 2013-01-05 15:58:23 +0000 |
961 | @@ -43,9 +43,11 @@ |
962 | #pragma once |
963 | |
964 | #include <sys/types.h> |
965 | -#ifdef USE_OPENSSL |
966 | -#include <openssl/ssl.h> |
967 | + |
968 | +#if defined(HAVE_OPENSSL_SSL_H) |
969 | +# include <openssl/ssl.h> |
970 | #endif |
971 | + |
972 | #ifdef NI_MAXHOST |
973 | # define LIBDRIZZLE_NI_MAXHOST NI_MAXHOST |
974 | #else |
975 | @@ -53,7 +55,7 @@ |
976 | #endif |
977 | |
978 | #ifdef __cplusplus |
979 | -#include <cstddef> |
980 | +# include <cstddef> |
981 | #endif |
982 | |
983 | #ifdef __cplusplus |
984 | @@ -62,6 +64,12 @@ |
985 | |
986 | #include "libdrizzle/datetime.h" |
987 | |
988 | +#if defined _WIN32 || defined __CYGWIN__ |
989 | +typedef SOCKET socket_t; |
990 | +#else |
991 | +typedef int socket_t; |
992 | +#endif |
993 | + |
994 | /** |
995 | * @ingroup drizzle_command |
996 | * Commands for drizzle_command functions. |
997 | @@ -159,7 +167,7 @@ |
998 | uint32_t result_count; |
999 | uint32_t thread_id; |
1000 | int backlog; |
1001 | - int fd; |
1002 | + socket_t fd; |
1003 | size_t buffer_size; |
1004 | size_t command_offset; |
1005 | size_t command_size; |
1006 | @@ -201,7 +209,7 @@ |
1007 | int timeout; |
1008 | drizzle_log_fn *log_fn; |
1009 | void *log_context; |
1010 | - struct pollfd pfds[1]; |
1011 | + pollfd_t pfds[1]; |
1012 | char sqlstate[DRIZZLE_MAX_SQLSTATE_SIZE + 1]; |
1013 | char last_error[DRIZZLE_MAX_ERROR_SIZE]; |
1014 | drizzle_stmt_st *stmt; |
1015 | |
1016 | === added file 'libdrizzle/windows.hpp' |
1017 | --- libdrizzle/windows.hpp 1970-01-01 00:00:00 +0000 |
1018 | +++ libdrizzle/windows.hpp 2013-01-05 15:58:23 +0000 |
1019 | @@ -0,0 +1,123 @@ |
1020 | +/* |
1021 | + * Drizzle Client & Protocol Library |
1022 | + * |
1023 | + * Copyright (C) 2012 Drizzle Developers (http://drizzle.org) |
1024 | + * All rights reserved. |
1025 | + * |
1026 | + * Redistribution and use in source and binary forms, with or without |
1027 | + * modification, are permitted provided that the following conditions are |
1028 | + * met: |
1029 | + * |
1030 | + * * Redistributions of source code must retain the above copyright |
1031 | + * notice, this list of conditions and the following disclaimer. |
1032 | + * |
1033 | + * * Redistributions in binary form must reproduce the above |
1034 | + * copyright notice, this list of conditions and the following disclaimer |
1035 | + * in the documentation and/or other materials provided with the |
1036 | + * distribution. |
1037 | + * |
1038 | + * * The names of its contributors may not be used to endorse or |
1039 | + * promote products derived from this software without specific prior |
1040 | + * written permission. |
1041 | + * |
1042 | + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
1043 | + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
1044 | + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
1045 | + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
1046 | + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
1047 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
1048 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
1049 | + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
1050 | + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
1051 | + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
1052 | + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
1053 | + * |
1054 | + */ |
1055 | + |
1056 | +#pragma once |
1057 | + |
1058 | +#ifdef __cplusplus |
1059 | +# include <cerrno> |
1060 | +#else |
1061 | +# include <errno.h> |
1062 | +#endif |
1063 | + |
1064 | +#ifndef WIN32_LEAN_AND_MEAN |
1065 | +# define WIN32_LEAN_AND_MEAN |
1066 | +#endif |
1067 | + |
1068 | +#ifndef _WIN32_WINNT |
1069 | +# define _WIN32_WINNT 0x0501 |
1070 | +#endif |
1071 | + |
1072 | +#ifdef __MINGW32__ |
1073 | +# if(_WIN32_WINNT >= 0x0501) |
1074 | +# else |
1075 | +# undef _WIN32_WINNT |
1076 | +# define _WIN32_WINNT 0x0501 |
1077 | +# endif /* _WIN32_WINNT >= 0x0501 */ |
1078 | +#endif /* __MINGW32__ */ |
1079 | + |
1080 | +#if defined(HAVE_WINSOCK2_H) && HAVE_WINSOCK2_H |
1081 | +# include <winsock2.h> |
1082 | +#endif |
1083 | + |
1084 | +#if defined(HAVE_WS2TCPIP_H) && HAVE_WS2TCPIP_H |
1085 | +# include <ws2tcpip.h> |
1086 | +#endif |
1087 | + |
1088 | +#if defined(HAVE_IO_H) && HAVE_IO_H |
1089 | +# include <io.h> |
1090 | +#endif |
1091 | + |
1092 | +struct sockaddr_un |
1093 | +{ |
1094 | + short int sun_family; |
1095 | + char sun_path[108]; |
1096 | +}; |
1097 | + |
1098 | +static inline int translate_windows_error() |
1099 | +{ |
1100 | + int local_errno= WSAGetLastError(); |
1101 | + |
1102 | + switch(local_errno) { |
1103 | + case WSAEINVAL: |
1104 | + case WSAEALREADY: |
1105 | + case WSAEWOULDBLOCK: |
1106 | + local_errno= EINPROGRESS; |
1107 | + break; |
1108 | + |
1109 | + case WSAECONNREFUSED: |
1110 | + local_errno= ECONNREFUSED; |
1111 | + break; |
1112 | + |
1113 | + case WSAENETUNREACH: |
1114 | + local_errno= ENETUNREACH; |
1115 | + break; |
1116 | + |
1117 | + case WSAETIMEDOUT: |
1118 | + local_errno= ETIMEDOUT; |
1119 | + break; |
1120 | + |
1121 | + case WSAECONNRESET: |
1122 | + local_errno= ECONNRESET; |
1123 | + break; |
1124 | + |
1125 | + case WSAEADDRINUSE: |
1126 | + local_errno= EADDRINUSE; |
1127 | + break; |
1128 | + |
1129 | + case WSAEOPNOTSUPP: |
1130 | + local_errno= EOPNOTSUPP; |
1131 | + break; |
1132 | + |
1133 | + case WSAENOPROTOOPT: |
1134 | + local_errno= ENOPROTOOPT; |
1135 | + break; |
1136 | + |
1137 | + default: |
1138 | + break; |
1139 | + } |
1140 | + |
1141 | + return local_errno; |
1142 | +} |
1143 | |
1144 | === modified file 'm4/ax_platform.m4' |
1145 | --- m4/ax_platform.m4 2012-12-17 11:57:49 +0000 |
1146 | +++ m4/ax_platform.m4 2013-01-05 15:58:23 +0000 |
1147 | @@ -19,7 +19,8 @@ |
1148 | # and this notice are preserved. This file is offered as-is, without any |
1149 | # warranty. |
1150 | |
1151 | -#serial 1 |
1152 | +#serial 3 |
1153 | +# |
1154 | AC_DEFUN([AX_PLATFORM], |
1155 | [AC_REQUIRE([AC_CANONICAL_HOST]) |
1156 | AC_REQUIRE([AC_CANONICAL_TARGET]) |
1157 | @@ -34,9 +35,8 @@ |
1158 | |
1159 | AS_CASE([$target_os], |
1160 | [*mingw32*], |
1161 | - [AC_DEFINE([TARGET_OS_WINDOWS], [1], [Whether we are building for Windows]) |
1162 | - AC_DEFINE([WINVER], [WindowsXP], [Version of Windows]) |
1163 | - AC_DEFINE([_WIN32_WINNT], [0x0501], [Magical number to make things work]) |
1164 | + [TARGET_WINDOWS="true" |
1165 | + AC_DEFINE([TARGET_OS_WINDOWS], [1], [Whether we are building for Windows]) |
1166 | AC_DEFINE([EAI_SYSTEM], [11], [Another magical number]) |
1167 | AH_BOTTOM([ |
1168 | #ifndef HAVE_SYS_SOCKET_H |
1169 | @@ -48,8 +48,12 @@ |
1170 | [*freebsd*],[AC_DEFINE([TARGET_OS_FREEBSD],[1],[Whether we are building for FreeBSD]) |
1171 | AC_DEFINE([__APPLE_CC__],[1],[Workaround for bug in FreeBSD headers])], |
1172 | [*solaris*],[AC_DEFINE([TARGET_OS_SOLARIS],[1],[Whether we are building for Solaris])], |
1173 | - [*darwin*],[AC_DEFINE([TARGET_OS_OSX],[1],[Whether we build for OSX])], |
1174 | - [*linux*],[AC_DEFINE([TARGET_OS_LINUX],[1],[Whether we build for Linux])]) |
1175 | + [*darwin*], |
1176 | + [TARGET_OSX="true" |
1177 | + AC_DEFINE([TARGET_OS_OSX],[1],[Whether we build for OSX])], |
1178 | + [*linux*], |
1179 | + [TARGET_LINUX="true" |
1180 | + AC_DEFINE([TARGET_OS_LINUX],[1],[Whether we build for Linux])]) |
1181 | |
1182 | AM_CONDITIONAL([BUILD_WIN32],[test "x${TARGET_WINDOWS}" = "xtrue"]) |
1183 | AM_CONDITIONAL([TARGET_OSX],[test "x${TARGET_OSX}" = "xtrue"]) |
1184 | |
1185 | === modified file 'm4/bottom.m4' |
1186 | --- m4/bottom.m4 2012-12-17 21:04:59 +0000 |
1187 | +++ m4/bottom.m4 2013-01-05 15:58:23 +0000 |
1188 | @@ -3,6 +3,11 @@ |
1189 | AH_TOP([ |
1190 | #pragma once |
1191 | |
1192 | +/* _SYS_FEATURE_TESTS_H is Solaris, _FEATURES_H is GCC */ |
1193 | +#if defined( _SYS_FEATURE_TESTS_H) || defined(_FEATURES_H) |
1194 | +# error "You should include config.h as your first include file" |
1195 | +#endif |
1196 | + |
1197 | ]) |
1198 | |
1199 | AH_BOTTOM([ |
1200 | @@ -23,30 +28,8 @@ |
1201 | typedef unsigned long int ulong; |
1202 | #endif |
1203 | |
1204 | -/* To hide the platform differences between MS Windows and Unix, I am |
1205 | - * going to use the Microsoft way and #define the Microsoft-specific |
1206 | - * functions to the unix way. Microsoft use a separate subsystem for sockets, |
1207 | - * but Unix normally just use a filedescriptor on the same functions. It is |
1208 | - * a lot easier to map back to the unix way with macros than going the other |
1209 | - * way without side effect. |
1210 | - */ |
1211 | -#ifdef TARGET_OS_WINDOWS |
1212 | -#define random() rand() |
1213 | -#define srandom(a) srand(a) |
1214 | -#define get_socket_errno() WSAGetLastError() |
1215 | -#else |
1216 | -#define INVALID_SOCKET -1 |
1217 | -#define SOCKET_ERROR -1 |
1218 | -#define closesocket(a) close(a) |
1219 | -#define get_socket_errno() errno |
1220 | -#endif // TARGET_OS_WINDOWS |
1221 | - |
1222 | -#ifndef HAVE_MSG_NOSIGNAL |
1223 | -#define MSG_NOSIGNAL 0 |
1224 | -#endif // HAVE_MSG_NOSIGNAL |
1225 | - |
1226 | #ifndef HAVE_MSG_DONTWAIT |
1227 | -#define MSG_DONTWAIT 0 |
1228 | +# define MSG_DONTWAIT 0 |
1229 | #endif // HAVE_MSG_DONTWAIT |
1230 | |
1231 | ]) |
1232 | |
1233 | === modified file 'm4/socket_send_flags.m4' |
1234 | --- m4/socket_send_flags.m4 2012-12-17 11:57:49 +0000 |
1235 | +++ m4/socket_send_flags.m4 2013-01-05 15:58:23 +0000 |
1236 | @@ -1,48 +1,47 @@ |
1237 | -dnl Copyright (C) 2012 Data Differential LLC |
1238 | -dnl Copyright (C) 2011 Trond Norbye |
1239 | -dnl This file is free software; Trond Norbye |
1240 | -dnl gives unlimited permission to copy and/or distribute it, |
1241 | -dnl with or without modifications, as long as this notice is preserved. |
1242 | -dnl --------------------------------------------------------------------------- |
1243 | -dnl Macro: SOCKET_SEND_FLAGS |
1244 | -dnl --------------------------------------------------------------------------- |
1245 | - |
1246 | -AC_DEFUN([SOCKET_SEND_FLAGS],[ |
1247 | - AC_CACHE_CHECK([for MSG_NOSIGNAL], [ac_cv_msg_nosignal], [ |
1248 | - AC_LANG_PUSH([C]) |
1249 | - AX_SAVE_FLAGS |
1250 | - CFLAGS="$CFLAGS -I${srcdir}" |
1251 | - |
1252 | - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [ int flags= MSG_NOSIGNAL ])], [ac_cv_msg_nosignal="yes"]) |
1253 | - AC_LANG_POP |
1254 | - AX_RESTORE_FLAGS |
1255 | - ]) |
1256 | - |
1257 | - AC_CACHE_CHECK([for MSG_DONTWAIT], [ac_cv_msg_dontwait], [ |
1258 | - AC_LANG_PUSH([C]) |
1259 | - AX_SAVE_FLAGS |
1260 | - CFLAGS="$CFLAGS -I${srcdir}" |
1261 | - |
1262 | - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [ int flags= MSG_DONTWAIT ])], [ac_cv_msg_dontwait="yes"]) |
1263 | - AC_LANG_POP |
1264 | - AX_RESTORE_FLAGS |
1265 | - ]) |
1266 | - |
1267 | - AC_CACHE_CHECK([for MSG_MORE], [ac_cv_msg_more], [ |
1268 | - AC_LANG_PUSH([C]) |
1269 | - AX_SAVE_FLAGS |
1270 | - CFLAGS="$CFLAGS -I${srcdir}" |
1271 | - |
1272 | - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [ int flags= MSG_MORE ])], [ac_cv_msg_more="yes"]) |
1273 | - AC_LANG_POP |
1274 | - AX_RESTORE_FLAGS |
1275 | - ]) |
1276 | - |
1277 | - AS_IF([test "x$ac_cv_msg_nosignal" = "xyes"],[ AC_DEFINE(HAVE_MSG_NOSIGNAL, 1, [Define to 1 if you have a MSG_NOSIGNAL])]) |
1278 | - AS_IF([test "x$ac_cv_msg_dontwait" = "xyes"],[ AC_DEFINE(HAVE_MSG_DONTWAIT, 1, [Define to 1 if you have a MSG_DONTWAIT])]) |
1279 | - AS_IF([test "x$ac_cv_msg_more" = "xyes"],[ AC_DEFINE(HAVE_MSG_MORE, 1, [Define to 1 if you have a MSG_MORE])]) |
1280 | -]) |
1281 | - |
1282 | -dnl --------------------------------------------------------------------------- |
1283 | -dnl End Macro: SOCKET_SEND_FLAGS |
1284 | -dnl --------------------------------------------------------------------------- |
1285 | +# Copyright (C) 2012-2013 Data Differential LLC |
1286 | +# Copyright (C) 2011 Trond Norbye |
1287 | +# This file is free software; Trond Norbye and Data Differential |
1288 | +# gives unlimited permission to copy and/or distribute it, |
1289 | +# with or without modifications, as long as this notice is preserved. |
1290 | +# --------------------------------------------------------------------------- |
1291 | +# Macro: SOCKET_SEND_FLAGS |
1292 | +# --------------------------------------------------------------------------- |
1293 | +# |
1294 | + |
1295 | +#serial 2 |
1296 | + |
1297 | +AC_DEFUN([SOCKET_SEND_FLAGS], |
1298 | + [AC_CACHE_CHECK([for MSG_NOSIGNAL],[ac_cv_msg_nosignal], |
1299 | + [AC_LANG_PUSH([C]) |
1300 | + AX_SAVE_FLAGS |
1301 | + CFLAGS="$CFLAGS -I${srcdir}" |
1302 | + |
1303 | + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [int flags= MSG_NOSIGNAL])], [ac_cv_msg_nosignal="yes"]) |
1304 | + AC_LANG_POP |
1305 | + AX_RESTORE_FLAGS]) |
1306 | + |
1307 | + AC_CACHE_CHECK([for MSG_DONTWAIT],[ac_cv_msg_dontwait], |
1308 | + [AC_LANG_PUSH([C]) |
1309 | + AX_SAVE_FLAGS |
1310 | + CFLAGS="$CFLAGS -I${srcdir}" |
1311 | + |
1312 | + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>],[int flags= MSG_DONTWAIT])],[ac_cv_msg_dontwait="yes"]) |
1313 | + AC_LANG_POP |
1314 | + AX_RESTORE_FLAGS]) |
1315 | + |
1316 | + AC_CACHE_CHECK([for MSG_MORE],[ac_cv_msg_more], |
1317 | + [AC_LANG_PUSH([C]) |
1318 | + AX_SAVE_FLAGS |
1319 | + CFLAGS="$CFLAGS -I${srcdir}" |
1320 | + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <netdb.h>], [int flags= MSG_MORE])], [ac_cv_msg_more="yes"]) |
1321 | + AC_LANG_POP |
1322 | + AX_RESTORE_FLAGS]) |
1323 | + |
1324 | + AS_IF([test "x$ac_cv_msg_nosignal" = "xyes"],[AC_DEFINE([HAVE_MSG_NOSIGNAL],[1],[Define to 1 if you have a MSG_NOSIGNAL])]) |
1325 | + AS_IF([test "x$ac_cv_msg_dontwait" = "xyes"],[AC_DEFINE([HAVE_MSG_DONTWAIT],[1],[Define to 1 if you have a MSG_DONTWAIT])]) |
1326 | + AS_IF([test "x$ac_cv_msg_more" = "xyes"],[AC_DEFINE([HAVE_MSG_MORE],[1],[Define to 1 if you have a MSG_MORE])]) |
1327 | + ]) |
1328 | + |
1329 | +# --------------------------------------------------------------------------- |
1330 | +# End Macro: SOCKET_SEND_FLAGS |
1331 | +# --------------------------------------------------------------------------- |
1332 | |
1333 | === modified file 'tests/unit/binlog.c' |
1334 | --- tests/unit/binlog.c 2012-12-31 00:06:53 +0000 |
1335 | +++ tests/unit/binlog.c 2013-01-05 15:58:23 +0000 |
1336 | @@ -38,7 +38,6 @@ |
1337 | #include <yatl/lite.h> |
1338 | |
1339 | #include <libdrizzle-5.1/libdrizzle.h> |
1340 | -#include "libdrizzle/structs.h" |
1341 | #include <stdio.h> |
1342 | #include <stdlib.h> |
1343 | #include <stdint.h> |
1344 | |
1345 | === modified file 'tests/unit/row.c' |
1346 | --- tests/unit/row.c 2013-01-05 11:41:26 +0000 |
1347 | +++ tests/unit/row.c 2013-01-05 15:58:23 +0000 |
1348 | @@ -143,11 +143,7 @@ |
1349 | return EXIT_FAILURE; |
1350 | } |
1351 | size_t *sizes= drizzle_row_field_sizes(result); |
1352 | - if (sizes[0] != 1) |
1353 | - { |
1354 | - printf("Row size mismatch (4 != %lu)\n", sizes[0]); |
1355 | - return EXIT_FAILURE; |
1356 | - } |
1357 | + ASSERT_EQ(sizes[0], 1); |
1358 | |
1359 | drizzle_result_free(result); |
1360 |
Incredible patch. I like you fixed poll for Windows :)