From f9bba0a50fafc7868630767a55cde9f5a16b8d76 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Mon, 5 Jan 2015 21:18:10 +0000 Subject: Changes to allow building with MinGW-w64 --- archival/libarchive/decompress_gunzip.c | 3 +++ archival/unzip.c | 3 +++ include/mingw.h | 5 +++++ include/platform.h | 2 ++ libbb/appletlib.c | 12 ++++++++++++ win32/mingw.c | 5 +++++ 6 files changed, 30 insertions(+) diff --git a/archival/libarchive/decompress_gunzip.c b/archival/libarchive/decompress_gunzip.c index 1360abef7..2dcc138f9 100644 --- a/archival/libarchive/decompress_gunzip.c +++ b/archival/libarchive/decompress_gunzip.c @@ -36,6 +36,9 @@ #include #include "libbb.h" #include "bb_archive.h" +#if ENABLE_PLATFORM_MINGW32 +#pragma pack(2) +#endif typedef struct huft_t { unsigned char e; /* number of extra bits or operation */ diff --git a/archival/unzip.c b/archival/unzip.c index 38a07e212..9b6ceb25f 100644 --- a/archival/unzip.c +++ b/archival/unzip.c @@ -44,6 +44,9 @@ #include "libbb.h" #include "bb_archive.h" +#if ENABLE_PLATFORM_MINGW32 +#pragma pack(2) +#endif enum { #if BB_BIG_ENDIAN diff --git a/include/mingw.h b/include/mingw.h index 5f6016dee..12c5ef71d 100644 --- a/include/mingw.h +++ b/include/mingw.h @@ -122,6 +122,7 @@ NOIMPL(FAST_FUNC sigaction_set,int signo UNUSED_PARAM, const struct sigaction *s /* * stdio.h */ +#undef fseeko #define fseeko(f,o,w) fseek(f,o,w) int fdprintf(int fd, const char *format, ...); @@ -252,6 +253,7 @@ int mingw_mkdir(const char *path, int mode); #if ENABLE_LFS # define off_t off64_t #endif +#undef lseek #define lseek _lseeki64 typedef int nlink_t; @@ -277,6 +279,9 @@ struct mingw_stat { int mingw_lstat(const char *file_name, struct mingw_stat *buf); int mingw_stat(const char *file_name, struct mingw_stat *buf); int mingw_fstat(int fd, struct mingw_stat *buf); +#undef lstat +#undef stat +#undef fstat #define lstat mingw_lstat #define stat mingw_stat #define fstat mingw_fstat diff --git a/include/platform.h b/include/platform.h index d9b82b2ed..e2b61592e 100644 --- a/include/platform.h +++ b/include/platform.h @@ -425,7 +425,9 @@ typedef unsigned smalluint; # undef HAVE_STRSEP # undef HAVE_STRSIGNAL # undef HAVE_STRVERSCMP +#if !defined(__MINGW64_VERSION_MAJOR) # undef HAVE_VASPRINTF +#endif # undef HAVE_UNLOCKED_STDIO # undef HAVE_UNLOCKED_LINE_OPS #endif diff --git a/libbb/appletlib.c b/libbb/appletlib.c index b74b6e724..dba66cc93 100644 --- a/libbb/appletlib.c +++ b/libbb/appletlib.c @@ -828,6 +828,18 @@ int main(int argc UNUSED_PARAM, char **argv) } #endif +#if defined(__MINGW64_VERSION_MAJOR) + if ( stdin ) { + _setmode(fileno(stdin), _O_BINARY); + } + if ( stdout ) { + _setmode(fileno(stdout), _O_BINARY); + } + if ( stderr ) { + _setmode(fileno(stderr), _O_BINARY); + } +#endif + #if defined(SINGLE_APPLET_MAIN) /* Only one applet is selected in .config */ if (argv[1] && strncmp(argv[0], "busybox", 7) == 0) { diff --git a/win32/mingw.c b/win32/mingw.c index 8a124147a..83a7ab3a7 100644 --- a/win32/mingw.c +++ b/win32/mingw.c @@ -6,7 +6,12 @@ int _CRT_glob = 0; #endif +#if !defined(__MINGW64_VERSION_MAJOR) unsigned int _CRT_fmode = _O_BINARY; +#else +#undef _fmode +int _fmode = _O_BINARY; +#endif smallint bb_got_signal; -- cgit v1.2.3-55-g6feb