Created
August 6, 2013 17:46
Revisions
-
nddrylliog created this gist
Aug 6, 2013 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ diff --git a/src/systems.h b/src/systems.h index c83cd9c..f194318 100644 --- a/src/systems.h +++ b/src/systems.h @@ -70,6 +70,13 @@ # define STDERR_FILENO 2 #endif +/* fsync emulation for MinGW */ +#ifdef __MINGW32__ +#include <windows.h> +#define HAVE_FSYNC 1 +#define fsync(fd) (FlushFileBuffers ((HANDLE) _get_osfhandle(fd)) ? 0 : -1) +#endif + /* I/O macros. */ #if HAVE_MMAP # define __read(_dbf, _buf, _size) _gdbm_mapped_read(_dbf, _buf, _size) This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ diff --git a/src/testgdbm.c b/src/testgdbm.c index b2b9c6c..eb85f74 100644 --- a/src/testgdbm.c +++ b/src/testgdbm.c @@ -27,7 +27,9 @@ #include <errno.h> #include <ctype.h> #include <signal.h> -#include <sys/ioctl.h> +#ifndef __MINGW32__ +# include <sys/ioctl.h> +#endif #ifdef HAVE_SYS_TERMIOS_H # include <sys/termios.h> #endif @@ -326,7 +328,7 @@ read_from_file (const char *name, int replace) int get_screen_lines () { -#ifdef TIOCGWINSZ +#if defined(TIOCGWINSZ) && !defined(__MINGW32__) if (isatty (1)) { struct winsize ws; @@ -1126,7 +1128,9 @@ main (int argc, char *argv[]) -1) error (2, _("gdbm_setopt failed: %s"), gdbm_strerror (gdbm_errno)); +#ifndef __MINGW32__ signal (SIGPIPE, SIG_IGN); +#endif /* Welcome message. */ if (interactive) This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ diff --git a/configure.ac b/configure.ac index 421e230..24b0f57 100644 --- a/configure.ac +++ b/configure.ac @@ -97,6 +97,19 @@ AC_CHECK_LIB(dbm, main) AC_CHECK_LIB(ndbm, main) AC_CHECK_FUNCS([rename ftruncate flock lockf fsync setlocale]) +AC_SEARCH_LIBS([gethostbyname], [nsl socket], [], [ +dnl Can't search ws2_32 for gethostbyname using AC_SEARCH_LIBS, because +dnl it requires #include <winsocks2.h> to work. +my_old_LIBS=$LIBS +LIBS="-lws2_32 $LIBS" +ws2_res=yes +AC_MSG_CHECKING([for gethostbyname in ws2_32]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <winsock2.h>]], + [[gethostbyname ("");]])], + [], [LIBS=$my_ac_save_LIBS ws2_res=no]) +AC_MSG_RESULT([$ws2_res]) +]) + if test x$mapped_io = xyes then AC_FUNC_MMAP() This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ diff --git a/src/flatfile.c b/src/flatfile.c index c0f9422..c762438 100644 --- a/src/flatfile.c +++ b/src/flatfile.c @@ -20,7 +20,11 @@ /* Include system configuration before all else. */ # include "autoconf.h" +# ifdef __MINGW32__ +# include <winsock.h> +# else # include <arpa/inet.h> +# endif # include "gdbmdefs.h" # include "gdbm.h"