Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mingw64 #414

Closed
wants to merge 13 commits into from
4 changes: 2 additions & 2 deletions Foundation/include/Poco/Foundation.h
Expand Up @@ -66,7 +66,7 @@
// Foundation_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
//
#if (defined(_WIN32) || defined(_WIN32_WCE)) && defined(POCO_DLL)
#if (defined(_WIN32) || defined(_WIN64) || defined(_WIN32_WCE)) && defined(POCO_DLL)
#if defined(Foundation_EXPORTS)
#define Foundation_API __declspec(dllexport)
#else
Expand Down Expand Up @@ -118,7 +118,7 @@
// Include platform-specific definitions
//
#include "Poco/Platform.h"
#if defined(_WIN32)
#if defined(_WIN32) || defined(_WIN64)
#include "Poco/Platform_WIN32.h"
#elif defined(__VMS)
#include "Poco/Platform_VMS.h"
Expand Down
4 changes: 3 additions & 1 deletion Foundation/include/Poco/Platform_WIN32.h
Expand Up @@ -160,7 +160,9 @@


// Enable C++11 support for VS 2010 and newer
#if defined(_MSC_VER) && (_MSC_VER >= 1700) && !defined(POCO_ENABLE_CPP11)
#if __cplusplus >= 201103L
#define POCO_ENABLE_CPP11
#elif defined(_MSC_VER) && (_MSC_VER >= 1700) && !defined(POCO_ENABLE_CPP11)
#define POCO_ENABLE_CPP11
#endif

Expand Down
15 changes: 13 additions & 2 deletions Foundation/include/Poco/Types.h
Expand Up @@ -42,6 +42,9 @@

#include "Poco/Foundation.h"

#if defined(_WIN64)
#define __LLP64__
#endif

namespace Poco {

Expand Down Expand Up @@ -77,14 +80,22 @@ namespace Poco {
typedef unsigned short UInt16;
typedef signed int Int32;
typedef unsigned int UInt32;
typedef signed long IntPtr;
typedef unsigned long UIntPtr;
#if defined(__LP64__)
#define POCO_PTR_IS_64_BIT 1
#define POCO_LONG_IS_64_BIT 1
typedef signed long IntPtr;
typedef unsigned long UIntPtr;
typedef signed long Int64;
typedef unsigned long UInt64;
#elif defined(__LLP64__)
#define POCO_PTR_IS_64_BIT 1
typedef signed long long IntPtr;
typedef unsigned long long UIntPtr;
typedef signed long long Int64;
typedef unsigned long long UInt64;
#else
typedef signed long IntPtr;
typedef unsigned long UIntPtr;
typedef signed long long Int64;
typedef unsigned long long UInt64;
#endif
Expand Down
3 changes: 3 additions & 0 deletions Foundation/src/Environment_WIN32.cpp
Expand Up @@ -39,6 +39,9 @@
#include <sstream>
#include <cstring>
#include "Poco/UnWindows.h"
#include <winsock2.h>
#include <ws2ipdef.h>
#include <wincrypt.h>
#include <iphlpapi.h>


Expand Down
3 changes: 3 additions & 0 deletions Foundation/src/Environment_WIN32U.cpp
Expand Up @@ -41,6 +41,9 @@
#include <sstream>
#include <cstring>
#include "Poco/UnWindows.h"
#include <winsock2.h>
#include <ws2ipdef.h>
#include <wincrypt.h>
#include <iphlpapi.h>


Expand Down
12 changes: 6 additions & 6 deletions Foundation/src/File_WIN32.cpp
Expand Up @@ -112,7 +112,7 @@ bool FileImpl::existsImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributes(_path.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
{
switch (GetLastError())
{
Expand All @@ -134,7 +134,7 @@ bool FileImpl::canReadImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributes(_path.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
{
switch (GetLastError())
{
Expand All @@ -153,7 +153,7 @@ bool FileImpl::canWriteImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributes(_path.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_READONLY) == 0;
}
Expand All @@ -177,7 +177,7 @@ bool FileImpl::isDirectoryImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributes(_path.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ bool FileImpl::isHiddenImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributes(_path.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
}
Expand Down Expand Up @@ -275,7 +275,7 @@ void FileImpl::setSizeImpl(FileSizeImpl size)
FileHandle fh(_path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
LARGE_INTEGER li;
li.QuadPart = size;
if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == -1)
if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
handleLastErrorImpl(_path);
if (SetEndOfFile(fh.get()) == 0)
handleLastErrorImpl(_path);
Expand Down
14 changes: 7 additions & 7 deletions Foundation/src/File_WIN32U.cpp
Expand Up @@ -116,7 +116,7 @@ bool FileImpl::existsImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
{
switch (GetLastError())
{
Expand All @@ -138,7 +138,7 @@ bool FileImpl::canReadImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
{
switch (GetLastError())
{
Expand All @@ -157,7 +157,7 @@ bool FileImpl::canWriteImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_READONLY) == 0;
}
Expand All @@ -181,7 +181,7 @@ bool FileImpl::isDirectoryImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
}
Expand Down Expand Up @@ -214,7 +214,7 @@ bool FileImpl::isHiddenImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
}
Expand Down Expand Up @@ -279,7 +279,7 @@ void FileImpl::setSizeImpl(FileSizeImpl size)
FileHandle fh(_path, _upath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
LARGE_INTEGER li;
li.QuadPart = size;
if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == -1)
if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
handleLastErrorImpl(_path);
if (SetEndOfFile(fh.get()) == 0)
handleLastErrorImpl(_path);
Expand All @@ -291,7 +291,7 @@ void FileImpl::setWriteableImpl(bool flag)
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == -1)
if (attr == INVALID_FILE_ATTRIBUTES)
handleLastErrorImpl(_path);
if (flag)
attr &= ~FILE_ATTRIBUTE_READONLY;
Expand Down
12 changes: 6 additions & 6 deletions Foundation/src/File_WINCE.cpp
Expand Up @@ -117,7 +117,7 @@ bool FileImpl::existsImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
{
switch (GetLastError())
{
Expand All @@ -139,7 +139,7 @@ bool FileImpl::canReadImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
{
switch (GetLastError())
{
Expand All @@ -158,7 +158,7 @@ bool FileImpl::canWriteImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_READONLY) == 0;
}
Expand All @@ -182,7 +182,7 @@ bool FileImpl::isDirectoryImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
}
Expand All @@ -205,7 +205,7 @@ bool FileImpl::isHiddenImpl() const
poco_assert (!_path.empty());

DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
if (attr == INVALID_FILE_ATTRIBUTES)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
}
Expand Down Expand Up @@ -270,7 +270,7 @@ void FileImpl::setSizeImpl(FileSizeImpl size)
FileHandle fh(_path, _upath, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, OPEN_EXISTING);
LARGE_INTEGER li;
li.QuadPart = size;
if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == -1)
if (SetFilePointer(fh.get(), li.LowPart, &li.HighPart, FILE_BEGIN) == INVALID_SET_FILE_POINTER)
handleLastErrorImpl(_path);
if (SetEndOfFile(fh.get()) == 0)
handleLastErrorImpl(_path);
Expand Down
2 changes: 1 addition & 1 deletion Foundation/src/Logger.cpp
Expand Up @@ -273,7 +273,7 @@ void Logger::formatDump(std::string& message, const void* buffer, std::size_t le
message.reserve(message.size() + length*6);
if (!message.empty()) message.append("\n");
unsigned char* base = (unsigned char*) buffer;
int addr = 0;
std::size_t addr = 0;
while (addr < length)
{
if (addr > 0) message.append("\n");
Expand Down
31 changes: 11 additions & 20 deletions Foundation/src/NumberFormatter.cpp
Expand Up @@ -36,22 +36,15 @@

#include "Poco/NumberFormatter.h"
#include "Poco/MemoryStream.h"
#include <ios>
#include <sstream>
#include <iomanip>
#if !defined(POCO_NO_LOCALE)
#include <locale>
#endif
#include <cstdio>


#if defined(_MSC_VER) || defined(__MINGW32__)
#define I64_FMT "I64"
#elif defined(__APPLE__)
#define I64_FMT "q"
#else
#define I64_FMT "ll"
#endif


namespace Poco {


Expand Down Expand Up @@ -384,17 +377,15 @@ void NumberFormatter::append(std::string& str, double value, int width, int prec

void NumberFormatter::append(std::string& str, const void* ptr)
{
char buffer[24];
#if defined(POCO_PTR_IS_64_BIT)
#if defined(POCO_LONG_IS_64_BIT)
std::sprintf(buffer, "%016lX", (UIntPtr) ptr);
#else
std::sprintf(buffer, "%016" I64_FMT "X", (UIntPtr) ptr);
#endif
#else
std::sprintf(buffer, "%08lX", (UIntPtr) ptr);
#endif
str.append(buffer);
std::ostringstream os;

os << std::hex
<< std::setw(sizeof(ptr) * 2)
<< std::setfill('0')
<< setiosflags(std::ios::uppercase)
<< ptr;

str.append(os.str());
}


Expand Down
15 changes: 9 additions & 6 deletions Foundation/src/NumericString.cpp
Expand Up @@ -63,6 +63,9 @@ void pad(std::string& str, int precision, int width, char prefix = ' ', char dec
poco_assert_dbg (precision > 0);
poco_assert_dbg (str.length());

std::string::size_type _precision = static_cast<std::string::size_type>(precision);
std::string::size_type _width = static_cast<std::string::size_type>(width);

std::string::size_type decSepPos = str.find(decSep);
if (decSepPos == std::string::npos)
{
Expand All @@ -81,17 +84,17 @@ void pad(std::string& str, int precision, int width, char prefix = ' ', char dec
str = str.substr(0, str.length() - eStr->length());
}

if (frac != precision)
if (frac != _precision)
{
if (frac < precision)
str.append(precision - frac, '0');
else if ((frac > precision) && (decSepPos != std::string::npos))
str = str.substr(0, decSepPos + 1 + precision);
if (frac < _precision)
str.append(_precision - frac, '0');
else if ((frac > _precision) && (decSepPos != std::string::npos))
str = str.substr(0, decSepPos + 1 + _precision);
}

if (eStr.get()) str += *eStr;

if (width && (str.length() < width)) str.insert(str.begin(), width - str.length(), prefix);
if (_width && (str.length() < _width)) str.insert(str.begin(), _width - str.length(), prefix);
}


Expand Down
7 changes: 6 additions & 1 deletion Foundation/src/utils.h
Expand Up @@ -35,6 +35,11 @@
#ifndef ASSERT
#define ASSERT(condition) (assert(condition))
#endif
#if __cplusplus >= 201103L
#define STATIC_ASSERT(b, str) static_assert(b, str)
#else
#define STATIC_ASSERT(b, str) typedef char __StaticAssertCheck[b ? 1 : -1]
#endif
#ifndef UNIMPLEMENTED
#define UNIMPLEMENTED() (abort())
#endif
Expand Down Expand Up @@ -296,7 +301,7 @@ template <class Dest, class Source>
inline Dest BitCast(const Source& source) {
// Compile time assertion: sizeof(Dest) == sizeof(Source)
// A compile error here means your Dest and Source have different sizes.
typedef char VerifySizesAreEqual[sizeof(Dest) == sizeof(Source) ? 1 : -1];
STATIC_ASSERT(sizeof(Dest) == sizeof(Source), "Dest and Source must have the same size");

Dest dest;
memmove(&dest, &source, sizeof(dest));
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -9,7 +9,7 @@ sinclude config.build

ifndef POCO_BASE
$(warning WARNING: POCO_BASE is not defined. Assuming current directory.)
export POCO_BASE=$(shell pwd)
export POCO_BASE=$(CURDIR)
endif

ifndef POCO_PREFIX
Expand Down
4 changes: 2 additions & 2 deletions Net/include/Poco/Net/Net.h
Expand Up @@ -53,7 +53,7 @@
// Net_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
//
#if defined(_WIN32) && defined(POCO_DLL)
#if (defined(_WIN32) || defined(_WIN64)) && defined(POCO_DLL)
#if defined(Net_EXPORTS)
#define Net_API __declspec(dllexport)
#else
Expand Down Expand Up @@ -110,7 +110,7 @@ inline void Net_API uninitializeNetwork();
// Automate network initialization (only relevant on Windows).
//

#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_NO_AUTOMATIC_LIB_INIT)
#if defined(POCO_OS_FAMILY_WINDOWS) && !defined(POCO_NO_AUTOMATIC_LIB_INIT) && !defined(__GNUC__)

extern "C" const struct Net_API NetworkInitializer pocoNetworkInitializer;

Expand Down