I gave the openbsd src patches a spin last night. I wonder if there's a way we could instead coerce mingw into pretending to be more POSIX by way of header tricks in the portable tree:
Create a stubs for each POSIX network header, e.g. include/sys/socket.h: #ifndef _WIN32 #include_next <sys/socket.h> #else #include <win32netcompat.h> #endif Then, include/win32netcompat.h contains: #ifndef LIBCRYPTOCOMPAT_WIN32NETCOMPAT_H #define LIBCRYPTOCOMPAT_WIN32NETCOMPAT_H #include <ws2tcpip.h> #define SHUT_RDWR SD_BOTH #define SHUT_RD SD_RECEIVE #define SHUT_WR SD_SEND #endif Repeat for each missing networking header. Mingw seens to already be full of little hacks like this (e.g. look at all the _POSIX sections in the headers). On Fri, Nov 7, 2014 at 8:26 PM, Dongsheng Song <dongsheng.s...@gmail.com> wrote: > On Fri, Nov 7, 2014 at 11:07 PM, Brent Cook <bust...@gmail.com> wrote: >> >>> On Nov 7, 2014, at 8:21 AM, Dongsheng Song <dongsheng.s...@gmail.com> wrote: >>> >>> I need some code changes for Windows support. >>> e.g. >>> >>> --- a/src/lib/libssl/src/crypto/bio/bss_dgram.c >>> +++ b/src/lib/libssl/src/crypto/bio/bss_dgram.c >>> @@ -57,13 +57,17 @@ >>> * >>> */ >>> >>> +#ifdef _WIN32 >>> +#include <ws2tcpip.h> >>> +#else >>> #include <sys/socket.h> >>> -#include <sys/time.h> >>> - >>> #include <netinet/in.h> >>> +#include <netdb.h> >>> +#endif >>> + >>> +#include <sys/time.h> >>> >>> #include <errno.h> >>> -#include <netdb.h> >>> #include <stdio.h> >>> #include <string.h> >>> #include <unistd.h> >> >> Thanks for the first set of patches on the portable tree! >> >> I would think the #ifdef _WIN32 is probably the lesser of two evils. >> >> Hopefully this will be largely confined to bio and the openssl app? >> > > yes, I can generate openssl.exe with my local patches. > I use #ifdef _WIN32 to guard headres, socket functions, signal > functions, tty functions. > fork is more painful, so I defined OPENSSL_NO_SPEED. maybe I'll write > a Windows version speed_main. > >> You'll also need to audit file descriptor usage carefully, so they >> are closed properly: >> > > Thanks.