mirror of https://github.com/aria2/aria2
Fix mingw32 build with gcc 4.8.2
Now mingw-w64 C++ compiler defines __USE_MINGW_ANSI_STDIO to 1, we have to follow it as well. We hope that mingw version of stdio function behaves like Linux ones. We have not tested them thoroughly yet. pthread for windows defines its own HAVE_STRUCT_TIMESPEC macro. To avoid warning, we rename our version of it as HAVE_A2_STRUCT_TIMESPEC.pull/220/merge
parent
96ffc3dfd4
commit
1188e4f1a2
18
configure.ac
18
configure.ac
|
@ -29,9 +29,9 @@ case "$host" in
|
||||||
*mingw*)
|
*mingw*)
|
||||||
win_build=yes
|
win_build=yes
|
||||||
LIBS="$LIBS -lws2_32 -lwsock32 -lgdi32 -lwinmm -liphlpapi -lpsapi"
|
LIBS="$LIBS -lws2_32 -lwsock32 -lgdi32 -lwinmm -liphlpapi -lpsapi"
|
||||||
# Deactivate __USE_MINGW_ANSI_STDIO because it causes lots of errors for
|
# C++ headers defines __USE_MINGW_ANSI_STDIO to 1 unconditionally.
|
||||||
# PRId64.
|
# We have to use it as well nonetheless.
|
||||||
CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=0 $CPPFLAGS"
|
CPPFLAGS="-D__USE_MINGW_ANSI_STDIO=1 $CPPFLAGS"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -667,10 +667,16 @@ AC_TYPE_UINT64_T
|
||||||
AC_TYPE_UINT8_T
|
AC_TYPE_UINT8_T
|
||||||
AC_TYPE_PID_T
|
AC_TYPE_PID_T
|
||||||
AC_C_VOLATILE
|
AC_C_VOLATILE
|
||||||
AC_CHECK_TYPES([ptrdiff_t, struct timespec])
|
AC_CHECK_TYPES([ptrdiff_t])
|
||||||
|
AC_CHECK_TYPE([struct timespec], [have_timespec=yes], [have_timespec=no])
|
||||||
AC_C_BIGENDIAN
|
AC_C_BIGENDIAN
|
||||||
AC_SYS_LARGEFILE
|
AC_SYS_LARGEFILE
|
||||||
|
|
||||||
|
if test "x$have_timespec" = "xyes"; then
|
||||||
|
AC_DEFINE([HAVE_A2_STRUCT_TIMESPEC], [1],
|
||||||
|
[Define to 1 if the system has the type `struct timespec'.])
|
||||||
|
fi
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AM_GNU_GETTEXT([external])
|
AM_GNU_GETTEXT([external])
|
||||||
AM_GNU_GETTEXT_VERSION([0.18])
|
AM_GNU_GETTEXT_VERSION([0.18])
|
||||||
|
@ -847,9 +853,7 @@ case "$host" in
|
||||||
AM_CONDITIONAL([HAVE_GETADDRINFO], true)
|
AM_CONDITIONAL([HAVE_GETADDRINFO], true)
|
||||||
dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
|
dnl defined in ws2tcpip.h, but missing in C:\mingw\lib\libws2_32.a
|
||||||
AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
|
AM_CONDITIONAL([HAVE_GAI_STRERROR], false)
|
||||||
if test "x$have_clock_gettime" != "xyes"; then
|
AM_CONDITIONAL([HAVE_TIMEGETTIME], [test "x$have_clock_gettime" != "xyes"])
|
||||||
AM_CONDITIONAL([HAVE_TIMEGETTIME], true)
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
AM_CONDITIONAL([MINGW_BUILD], false)
|
AM_CONDITIONAL([MINGW_BUILD], false)
|
||||||
|
|
|
@ -159,26 +159,7 @@ int GZipFile::onFlush()
|
||||||
int GZipFile::onVprintf(const char* format, va_list va)
|
int GZipFile::onVprintf(const char* format, va_list va)
|
||||||
{
|
{
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
#ifdef __MINGW32__
|
|
||||||
// Windows vsnprintf returns -1 when output is truncated, so we
|
|
||||||
// cannot use same logic in non-MINGW32 code.
|
|
||||||
len = _vscprintf(format, va);
|
|
||||||
if(len == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// Include terminate null
|
|
||||||
++len;
|
|
||||||
if(len > static_cast<ssize_t>(buflen_)) {
|
|
||||||
while(static_cast<ssize_t>(buflen_) < len) {
|
|
||||||
buflen_ *= 2;
|
|
||||||
}
|
|
||||||
buf_ = reinterpret_cast<char*>(realloc(buf_, buflen_));
|
|
||||||
}
|
|
||||||
len = vsnprintf(buf_, buflen_, format, va);
|
|
||||||
if(len < 0) {
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
#else // !__MINGW32__
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
len = vsnprintf(buf_, buflen_, format, va);
|
len = vsnprintf(buf_, buflen_, format, va);
|
||||||
// len does not include terminating null
|
// len does not include terminating null
|
||||||
|
@ -196,7 +177,7 @@ int GZipFile::onVprintf(const char* format, va_list va)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // !__MINGW32__
|
|
||||||
return gzwrite(fp_, buf_, len);
|
return gzwrite(fp_, buf_, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ size_t WinConsoleFile::write(const char* str)
|
||||||
|
|
||||||
int WinConsoleFile::vprintf(const char* format, va_list va)
|
int WinConsoleFile::vprintf(const char* format, va_list va)
|
||||||
{
|
{
|
||||||
ssize_t r = _vscprintf(format, va);
|
ssize_t r = vsnprintf(NULL, 0, format, va);
|
||||||
if (r <= 0) {
|
if (r <= 0) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,10 +36,10 @@
|
||||||
#ifndef D_WIN_CONSOLE_FILE_H
|
#ifndef D_WIN_CONSOLE_FILE_H
|
||||||
#define D_WIN_CONSOLE_FILE_H
|
#define D_WIN_CONSOLE_FILE_H
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#include "OutputFile.h"
|
#include "OutputFile.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
// This is a wrapper class for WriteConsoleW
|
// This is a wrapper class for WriteConsoleW
|
||||||
|
|
|
@ -42,7 +42,13 @@
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
std::string fmt(const char* fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
std::string fmt(const char* fmt, ...)
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
__attribute__ ((format (__MINGW_PRINTF_FORMAT, 1, 2)))
|
||||||
|
#else // !__MINGW32__
|
||||||
|
__attribute__ ((format (printf, 1, 2)))
|
||||||
|
#endif // !__MINGW32__
|
||||||
|
;
|
||||||
|
|
||||||
} // namespace aria2
|
} // namespace aria2
|
||||||
|
|
||||||
|
|
|
@ -38,8 +38,8 @@
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
#ifndef HAVE_STRUCT_TIMESPEC
|
#ifndef HAVE_A2_STRUCT_TIMESPEC
|
||||||
struct timespec { time_t tv_sec; long tv_nsec; };
|
struct timespec { time_t tv_sec; long tv_nsec; };
|
||||||
#endif // !HAVE_STRUCT_TIMESPEC
|
#endif // !HAVE_A2_STRUCT_TIMESPEC
|
||||||
|
|
||||||
#endif // D_TIMESPEC_H
|
#endif // D_TIMESPEC_H
|
||||||
|
|
Loading…
Reference in New Issue