From a96ee8d3287489bcc6bca9d7841bb62b87992047 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Mon, 23 Mar 2009 08:56:20 +0000 Subject: [PATCH] ebl Tweak code to compile win64 version with mingw git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8584 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/baconfig.h | 7 ------- bacula/src/bc_types.h | 6 ++++++ bacula/src/win32/compat/compat.cpp | 10 ++++++---- bacula/src/win32/compat/compat.h | 13 ++++++++++++- bacula/src/win32/filed/plugins/dbi_node.c | 2 +- bacula/src/win32/filed/vss.cpp | 2 +- bacula/src/win32/libwin32/main.cpp | 6 +++++- bacula/technotes-2.5 | 2 ++ 8 files changed, 33 insertions(+), 15 deletions(-) diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index f7d2327b01..c341826e7c 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -43,13 +43,6 @@ #define TRUE 1 #define FALSE 0 -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif - #ifdef HAVE_TLS #define have_tls 1 #else diff --git a/bacula/src/bc_types.h b/bacula/src/bc_types.h index 4a7c30de53..bd08067dd6 100644 --- a/bacula/src/bc_types.h +++ b/bacula/src/bc_types.h @@ -247,5 +247,11 @@ enum { CF_CREATED /* file created, no data to extract */ }; +#ifndef MAX +#define MAX(a, b) ((a) > (b) ? (a) : (b)) +#endif +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif #endif /* __bc_types_INCLUDED */ diff --git a/bacula/src/win32/compat/compat.cpp b/bacula/src/win32/compat/compat.cpp index cb1ebc9829..dc91721651 100644 --- a/bacula/src/win32/compat/compat.cpp +++ b/bacula/src/win32/compat/compat.cpp @@ -733,7 +733,7 @@ statDir(const char *file, struct stat *sb) } int -fstat(int fd, struct stat *sb) +fstat(intptr_t fd, struct stat *sb) { BY_HANDLE_FILE_INFORMATION info; @@ -827,7 +827,7 @@ stat2(const char *file, struct stat *sb) return -1; } - rval = fstat((int)h, sb); + rval = fstat((intprt_t)h, sb); CloseHandle(h); if (attr & FILE_ATTRIBUTE_DIRECTORY && @@ -2201,7 +2201,7 @@ open_bpipe(char *prog, int wait, const char *mode) // process terminates we can // detect eof. // ugly but convert WIN32 HANDLE to FILE* - int rfd = _open_osfhandle((long)hChildStdoutRdDup, O_RDONLY | O_BINARY); + int rfd = _open_osfhandle((intptr_t)hChildStdoutRdDup, O_RDONLY | O_BINARY); if (rfd >= 0) { bpipe->rfd = _fdopen(rfd, "rb"); } @@ -2210,7 +2210,7 @@ open_bpipe(char *prog, int wait, const char *mode) CloseHandle(hChildStdinRd); // close our read side so as not // to interfre with child's copy // ugly but convert WIN32 HANDLE to FILE* - int wfd = _open_osfhandle((long)hChildStdinWrDup, O_WRONLY | O_BINARY); + int wfd = _open_osfhandle((intptr_t)hChildStdinWrDup, O_WRONLY | O_BINARY); if (wfd >= 0) { bpipe->wfd = _fdopen(wfd, "wb"); } @@ -2316,6 +2316,7 @@ close_wpipe(BPIPE *bpipe) return result; } +#ifndef MINGW64 int utime(const char *fname, struct utimbuf *times) { @@ -2367,6 +2368,7 @@ utime(const char *fname, struct utimbuf *times) } return rval; } +#endif #if 0 int diff --git a/bacula/src/win32/compat/compat.h b/bacula/src/win32/compat/compat.h index 184e7fe170..4df0e732b8 100644 --- a/bacula/src/win32/compat/compat.h +++ b/bacula/src/win32/compat/compat.h @@ -57,6 +57,15 @@ #include +#ifdef MINGW64 +#include +#define _declspec __declspec +#endif + +#ifdef _WIN64 +# define GWL_USERDATA GWLP_USERDATA +#endif + #ifndef INT64 #define INT64 long long int #endif @@ -255,10 +264,12 @@ ssize_t win32_read(int fd, void *buffer, size_t count); ssize_t win32_write(int fd, const void *buffer, size_t count); int win32_ioctl(int fd, unsigned long int req, ...); +#ifndef MINGW64 #define open _open +#endif int fcntl(int fd, int cmd, long arg); -int fstat(int fd, struct stat *sb); +int fstat(intptr_t fd, struct stat *sb); int inet_aton(const char *cp, struct in_addr *inp); int kill(int pid, int signo); diff --git a/bacula/src/win32/filed/plugins/dbi_node.c b/bacula/src/win32/filed/plugins/dbi_node.c index 7744b040f5..d00ac2f043 100644 --- a/bacula/src/win32/filed/plugins/dbi_node.c +++ b/bacula/src/win32/filed/plugins/dbi_node.c @@ -172,7 +172,7 @@ dbi_node_t::pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io) io->status = 0; io->io_errno = 0; - io->status = min(io->count, (int)(buffer_size - buffer_pos)); + io->status = MIN(io->count, (int)(buffer_size - buffer_pos)); if (io->status == 0) return bRC_OK; memcpy(io->buf, buffer + buffer_pos, io->status); diff --git a/bacula/src/win32/filed/vss.cpp b/bacula/src/win32/filed/vss.cpp index 706565ae16..7a73c32fe4 100644 --- a/bacula/src/win32/filed/vss.cpp +++ b/bacula/src/win32/filed/vss.cpp @@ -215,7 +215,7 @@ const char* VSSClient::GetWriterInfo(int nIndex) const int VSSClient::GetWriterState(int nIndex) { alist* pV = (alist*)m_pAlistWriterState; - return (int)pV->get(nIndex); + return (intptr_t)pV->get(nIndex); } void VSSClient::AppendWriterInfo(int nState, const char* pszInfo) diff --git a/bacula/src/win32/libwin32/main.cpp b/bacula/src/win32/libwin32/main.cpp index a195eef056..4c6bc3ef36 100644 --- a/bacula/src/win32/libwin32/main.cpp +++ b/bacula/src/win32/libwin32/main.cpp @@ -53,7 +53,11 @@ #include #undef _WIN32_IE -#define _WIN32_IE 0x0401 +#ifdef MINGW64 +# define _WIN32_IE 0x0501 +#else +# define _WIN32_IE 0x0401 +#endif // MINGW64 #undef _WIN32_WINNT #define _WIN32_WINNT 0x0501 #include diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index f61d1f3628..05e49296e4 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -49,6 +49,8 @@ Code to be completed before 3.0.0 is released: General: +23Mar09 +ebl Tweak code to compile win64 version with mingw 21Mar09 Kes Attempt to correct timing problems with starting bat and obtaining lists. Maintain in_command counter to know when a list is coming. -- 2.39.5