qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tr...@apache.org
Subject svn commit: r1104662 - in /qpid/trunk/qpid/cpp: include/qpid/sys/ include/qpid/sys/windows/ src/ src/qpid/broker/windows/ src/qpid/sys/ src/qpid/sys/windows/ src/tests/ src/tests/windows/
Date Wed, 18 May 2011 02:14:08 GMT
Author: tross
Date: Wed May 18 02:14:07 2011
New Revision: 1104662

URL: http://svn.apache.org/viewvc?rev=1104662&view=rev
Log:
QPID-2905 - Code modifications to enable Windows builds with the mingw32 compiler.

Added:
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/mingw32_compat.h
Modified:
    qpid/trunk/qpid/cpp/include/qpid/sys/Thread.h
    qpid/trunk/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h
    qpid/trunk/qpid/cpp/src/CMakeLists.txt
    qpid/trunk/qpid/cpp/src/qpid/broker/windows/BrokerDefaults.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/alloca.h
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/SocketAddress.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/StrError.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/Time.cpp
    qpid/trunk/qpid/cpp/src/qpid/sys/windows/uuid.cpp
    qpid/trunk/qpid/cpp/src/tests/TimerTest.cpp
    qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp

Modified: qpid/trunk/qpid/cpp/include/qpid/sys/Thread.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/sys/Thread.h?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/sys/Thread.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/sys/Thread.h Wed May 18 02:14:07 2011
@@ -25,7 +25,11 @@
 #include "qpid/CommonImportExport.h"
 
 #ifdef _WIN32
-#  define QPID_TSS __declspec(thread)
+#  ifdef _MSC_VER
+#    define QPID_TSS __declspec(thread)
+#  else
+#    define QPID_TSS __thread
+#  endif
 #elif defined (__GNUC__)
 #  define QPID_TSS __thread
 #elif defined (__SUNPRO_CC)

Modified: qpid/trunk/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h (original)
+++ qpid/trunk/qpid/cpp/include/qpid/sys/windows/IntegerTypes.h Wed May 18 02:14:07 2011
@@ -22,13 +22,17 @@
  */
 
 typedef unsigned char    uint8_t;
-typedef char             int8_t;
 typedef unsigned short   uint16_t;
 typedef short            int16_t;
 typedef unsigned int     uint32_t;
 typedef int              int32_t;
+#if defined(_MSC_VER)
+typedef char             int8_t;
 typedef unsigned __int64 uint64_t;
 typedef          __int64 int64_t;
+#else
+#include <stdint.h>
+#endif
 
 // Visual Studio doesn't define other common types, so set them up here too.
 typedef unsigned int     uint;

Modified: qpid/trunk/qpid/cpp/src/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/CMakeLists.txt?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/CMakeLists.txt (original)
+++ qpid/trunk/qpid/cpp/src/CMakeLists.txt Wed May 18 02:14:07 2011
@@ -636,8 +636,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL Windows)
   )
 
   set (qpidcommon_platform_LIBS
-    ${windows_ssl_libs} ws2_32
-  )
+    ${Boost_THREAD_LIBRARY} ${windows_ssl_libs} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_DATE_TIME_LIBRARY}
${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY} ws2_32  )
   set (qpidbroker_platform_SOURCES
     qpid/broker/windows/BrokerDefaults.cpp
     qpid/broker/windows/SaslAuthenticator.cpp
@@ -938,7 +937,7 @@ if (NOT QPID_GENERATED_HEADERS_IN_SOURCE
 endif (NOT QPID_GENERATED_HEADERS_IN_SOURCE)
 
 
-if (WIN32)
+if (_MSC_VER)
     # Install the DtcPlugin project and call it qpidxarm.
     set(AMQP_WCF_DIR ${qpid-cpp_SOURCE_DIR}/../wcf)
     set(qpidxarm_SOURCES ${AMQP_WCF_DIR}/src/Apache/Qpid/DtcPlugin/DtcPlugin.cpp)
@@ -951,7 +950,7 @@ if (WIN32)
                  COMPONENT ${QPID_COMPONENT_CLIENT})
         install_pdb (qpidxarm ${QPID_COMPONENT_CLIENT})
     endif (EXISTS ${qpidxarm_SOURCES})
-endif (WIN32)
+endif (_MSC_VER)
 
 set (qpidbroker_SOURCES
      ${mgen_broker_cpp}

Modified: qpid/trunk/qpid/cpp/src/qpid/broker/windows/BrokerDefaults.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/broker/windows/BrokerDefaults.cpp?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/broker/windows/BrokerDefaults.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/broker/windows/BrokerDefaults.cpp Wed May 18 02:14:07 2011
@@ -31,10 +31,16 @@ const std::string Broker::Options::DEFAU
 std::string
 Broker::Options::getHome() {
     std::string home;
+#ifdef _MSC_VER
     char home_c[MAX_PATH+1];
     size_t unused;
     if (0 == getenv_s (&unused, home_c, sizeof(home_c), "HOME"))
         home += home_c;
+#else
+    char *home_c = getenv("HOME");
+    if (home_c)
+        home += home_c;
+#endif
     return home;
 }
 

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/alloca.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/alloca.h?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/alloca.h (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/alloca.h Wed May 18 02:14:07 2011
@@ -21,19 +21,22 @@
  *
  */
 
-#if (defined(_WINDOWS) || defined (WIN32)) && defined(_MSC_VER)
-#include <malloc.h>
-#ifdef alloc
-#  undef alloc
-#endif
-#define alloc _alloc
-#ifdef alloca
-#  undef alloca
-#endif
-#define alloca _alloca
-#endif
-#if !defined _WINDOWS && !defined WIN32
-#include <alloca.h>
+#if (defined(_WINDOWS) || defined (WIN32))
+#  include <malloc.h>
+
+#  if defined(_MSC_VER)
+#    ifdef alloc
+#      undef alloc
+#    endif
+#    define alloc _alloc
+#    ifdef alloca
+#      undef alloca
+#    endif
+#    define alloca _alloca
+#  endif
+#  if !defined _WINDOWS && !defined WIN32
+#    include <alloca.h>
+#  endif
 #endif
 
 #endif  /*!QPID_SYS_ALLOCA_H*/

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/AsynchIO.cpp Wed May 18 02:14:07 2011
@@ -30,6 +30,7 @@
 #include "qpid/log/Statement.h"
 
 #include "qpid/sys/windows/check.h"
+#include "qpid/sys/windows/mingw32_compat.h"
 
 #include <boost/thread/once.hpp>
 
@@ -114,7 +115,8 @@ AsynchAcceptor::~AsynchAcceptor()
 }
 
 void AsynchAcceptor::start(Poller::shared_ptr poller) {
-    poller->monitorHandle(PollerHandle(socket), Poller::INPUT);
+    PollerHandle ph = PollerHandle(socket);
+    poller->monitorHandle(ph, Poller::INPUT);
     restart ();
 }
 
@@ -154,7 +156,7 @@ void AsynchAcceptResult::success(size_t 
     delete this;
 }
 
-void AsynchAcceptResult::failure(int status) {
+void AsynchAcceptResult::failure(int /*status*/) {
     //if (status != WSA_OPERATION_ABORTED)
     // Can there be anything else?  ;
     delete this;
@@ -410,8 +412,9 @@ void AsynchIO::queueForDeletion() {
 }
 
 void AsynchIO::start(Poller::shared_ptr poller0) {
+    PollerHandle ph = PollerHandle(socket);
     poller = poller0;
-    poller->monitorHandle(PollerHandle(socket), Poller::INPUT);
+    poller->monitorHandle(ph, Poller::INPUT);
     if (writeQueue.size() > 0)  // Already have data queued for write
         notifyPendingWrite();
     startReading();
@@ -584,7 +587,6 @@ void AsynchIO::notifyIdle(void) {
 void AsynchIO::startWrite(AsynchIO::BufferBase* buff) {
     writeInProgress = true;
     InterlockedIncrement(&opsInProgress);
-    int writeCount = buff->byteCount-buff->dataCount;
     AsynchWriteResult *result =
         new AsynchWriteResult(boost::bind(&AsynchIO::completion, this, _1),
                               buff,

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/Socket.cpp Wed May 18 02:14:07 2011
@@ -19,6 +19,11 @@
  *
  */
 
+// Ensure we get all of winsock2.h
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0501
+#endif
+
 #include "qpid/sys/Socket.h"
 #include "qpid/sys/SocketAddress.h"
 #include "qpid/sys/windows/IoHandlePrivate.h"

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/windows/SocketAddress.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/SocketAddress.cpp?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/SocketAddress.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/SocketAddress.cpp Wed May 18 02:14:07 2011
@@ -19,6 +19,11 @@
  *
  */
 
+// Ensure we get all of winsock2.h
+#ifndef _WIN32_WINNT
+#define _WIN32_WINNT 0x0501
+#endif
+
 #include "qpid/sys/SocketAddress.h"
 
 #include "qpid/sys/windows/check.h"

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/windows/StrError.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/StrError.cpp?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/StrError.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/StrError.cpp Wed May 18 02:14:07 2011
@@ -30,6 +30,7 @@ namespace sys {
 std::string strError(int err) {
     const size_t bufsize = 512;
     char buf[bufsize];
+    buf[0] = 0;
     if (0 == FormatMessage (FORMAT_MESSAGE_MAX_WIDTH_MASK
                             | FORMAT_MESSAGE_FROM_SYSTEM,
                             0,
@@ -39,7 +40,11 @@ std::string strError(int err) {
                             bufsize,
                             0))
     {
-        strerror_s (buf, bufsize, err);
+#ifdef _MSC_VER
+        strerror_s(buf, bufsize, err);
+#else
+        return std::string(strerror(err));
+#endif
     }
     return std::string(buf);
 }

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/windows/Time.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/Time.cpp?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/Time.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/Time.cpp Wed May 18 02:14:07 2011
@@ -102,7 +102,11 @@ void outputFormattedNow(std::ostream& o)
     char time_string[100];
 
     ::time( &rawtime );
+#ifdef _MSC_VER
     ::localtime_s(&timeinfo, &rawtime);
+#else
+    timeinfo = *(::localtime(&rawtime));
+#endif
     ::strftime(time_string, 100,
                "%Y-%m-%d %H:%M:%S",
                &timeinfo);

Added: qpid/trunk/qpid/cpp/src/qpid/sys/windows/mingw32_compat.h
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/mingw32_compat.h?rev=1104662&view=auto
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/mingw32_compat.h (added)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/mingw32_compat.h Wed May 18 02:14:07 2011
@@ -0,0 +1,39 @@
+#ifndef _sys_windows_mingw32_compat
+#define _sys_windows_mingw32_compat
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#ifdef WIN32
+#ifndef _MSC_VER
+
+//
+// The following definitions for extension function GUIDs and signatures are taken from
+// MswSock.h in the Windows32 SDK.  These rightfully belong in the mingw32 version of
+// mswsock.h, but are not included presently.
+//
+
+#define WSAID_ACCEPTEX {0xb5367df1,0xcbac,0x11cf,{0x95,0xca,0x00,0x80,0x5f,0x48,0xa1,0x92}}
+typedef BOOL (PASCAL *LPFN_ACCEPTEX)(SOCKET,SOCKET,PVOID,DWORD,DWORD,DWORD,LPDWORD,LPOVERLAPPED);
+
+#endif
+#endif
+
+#endif

Modified: qpid/trunk/qpid/cpp/src/qpid/sys/windows/uuid.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/qpid/sys/windows/uuid.cpp?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/qpid/sys/windows/uuid.cpp (original)
+++ qpid/trunk/qpid/cpp/src/qpid/sys/windows/uuid.cpp Wed May 18 02:14:07 2011
@@ -19,7 +19,7 @@
  *
  */
 
-#include <Rpc.h>
+#include <rpc.h>
 #ifdef uuid_t   /*  Done in rpcdce.h */
 #  undef uuid_t
 #endif
@@ -52,7 +52,11 @@ int uuid_parse (const char *in, uuid_t u
 void uuid_unparse (const uuid_t uu, char *out) {
     unsigned char *formatted;
     if (UuidToString((UUID*)uu, &formatted) == RPC_S_OK) {
+#ifdef _MSC_VER
         strncpy_s (out, 36+1, (char*)formatted, _TRUNCATE);
+#else
+        strncpy (out, (char*)formatted, 36+1);
+#endif
         RpcStringFree(&formatted);
     }
 }

Modified: qpid/trunk/qpid/cpp/src/tests/TimerTest.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/TimerTest.cpp?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/TimerTest.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/TimerTest.cpp Wed May 18 02:14:07 2011
@@ -77,8 +77,10 @@ class TestTask : public TimerTask
         BOOST_CHECK(fired);
         BOOST_CHECK_EQUAL(expected_position, position);
         Duration actual(start, end);
-#ifdef _WIN32
+#ifdef _MSC_VER
         uint64_t difference = _abs64(expected - actual);
+#elif defined(_WIN32)
+        uint64_t difference = labs(expected - actual);
 #else
         uint64_t difference = abs(expected - actual);
 #endif

Modified: qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp?rev=1104662&r1=1104661&r2=1104662&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp (original)
+++ qpid/trunk/qpid/cpp/src/tests/windows/DisableWin32ErrorWindows.cpp Wed May 18 02:14:07
2011
@@ -26,7 +26,9 @@
 // include this file with the executable being built. If the default
 // behaviors are desired, don't include this file in the build.
 
+#if defined(_MSC_VER)
 #include <crtdbg.h>
+#endif
 #include <windows.h>
 #include <iostream>
 
@@ -53,12 +55,14 @@ static redirect_errors_to_stderr block;
 
 redirect_errors_to_stderr::redirect_errors_to_stderr()
 {
+#if defined(_MSC_VER)
     _CrtSetReportMode (_CRT_WARN, _CRTDBG_MODE_FILE);
     _CrtSetReportFile (_CRT_WARN, _CRTDBG_FILE_STDERR);
     _CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_FILE);
     _CrtSetReportFile (_CRT_ERROR, _CRTDBG_FILE_STDERR);
     _CrtSetReportMode (_CRT_ASSERT, _CRTDBG_MODE_FILE);
     _CrtSetReportFile (_CRT_ASSERT, _CRTDBG_FILE_STDERR);
+#endif
 
     // Prevent the system from displaying the critical-error-handler
     // and can't-open-file message boxes.



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message