You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by js...@apache.org on 2006/07/03 17:03:02 UTC

svn commit: r418786 - in /incubator/activemq/trunk/activemq-cpp/src/main/activemq: network/ServerSocket.cpp network/Socket.h network/SocketInputStream.cpp network/TcpSocket.cpp util/Endian.h util/Guid.cpp util/Guid.h

Author: jstrachan
Date: Mon Jul  3 08:03:02 2006
New Revision: 418786

URL: http://svn.apache.org/viewvc?rev=418786&view=rev
Log:
patched the #ifdef stuff to work nicely on OS X - not sure why defined(unix) is false

Modified:
    incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.cpp
    incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/Socket.h
    incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp
    incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/TcpSocket.cpp
    incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Endian.h
    incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.cpp
    incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.h

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.cpp?rev=418786&r1=418785&r2=418786&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/ServerSocket.cpp Mon Jul  3 08:03:02 2006
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-#if defined(unix) && !defined(__CYGWIN__)
+#if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
    #include <unistd.h>
    #include <netdb.h>
    #include <fcntl.h>
@@ -48,7 +48,7 @@
 
 using namespace activemq::network;
 
-#if !defined( unix ) || defined( __CYGWIN__ )
+#if !(defined( unix ) || defined(__APPLE__)) || defined( __CYGWIN__ )
 
    // Static socket initializer needed for winsock
 
@@ -79,7 +79,7 @@
 {
    socketHandle = Socket::INVALID_SOCKET_HANDLE;
    
-#if !defined( unix ) || defined( __CYGWIN__ )
+#if !(defined( unix ) || defined(__APPLE__)) || defined( __CYGWIN__ )
    if (ServerSocket::staticSocketInitializer.getSocketInitError() != NULL) {
       throw *ServerSocket::staticSocketInitializer.getSocketInitError();
    }
@@ -166,7 +166,7 @@
    
    if (isBound()) {
         
-      #if defined(unix) && !defined(__CYGWIN__)
+      #if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
          ::close(socketHandle);
       #else
          ::closesocket(socketHandle);
@@ -186,7 +186,7 @@
 {
    struct sockaddr_in temp;
 
-#if defined( unix ) && !defined( __CYGWIN__ )
+#if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
    socklen_t temp_len = sizeof (sockaddr_in);
 #else
    int temp_len = sizeof (sockaddr_in);

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/Socket.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/Socket.h?rev=418786&r1=418785&r2=418786&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/Socket.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/Socket.h Mon Jul  3 08:03:02 2006
@@ -22,7 +22,7 @@
 #include <activemq/io/OutputStream.h>
 #include <cms/Closeable.h>
 
-#if !defined( unix ) || defined( __CYGWIN__ )
+#if !(defined( unix ) || defined(__APPLE__)) || defined( __CYGWIN__ )
 #include <Winsock2.h> // SOCKET
 #endif
 
@@ -34,7 +34,7 @@
    public:
    
       // Define the SocketHandle type.
-      #if defined( unix ) && !defined( __CYGWIN__ )
+      #if defined( unix ) || defined(__APPLE__) && !defined( __CYGWIN__ )
           typedef int SocketHandle;
       #else
           typedef SOCKET SocketHandle;

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp?rev=418786&r1=418785&r2=418786&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/SocketInputStream.cpp Mon Jul  3 08:03:02 2006
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
  
-#if defined(unix) && !defined(__CYGWIN__)
+#if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
    #include <sys/poll.h>
    #include <sys/socket.h>
    #include <errno.h>
@@ -50,7 +50,7 @@
 int SocketInputStream::available() const{
    
    
-#if defined(unix) && !defined(__CYGWIN__)
+#if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
     
     // Poll the socket for input.
     pollfd fd;

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/TcpSocket.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/TcpSocket.cpp?rev=418786&r1=418785&r2=418786&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/TcpSocket.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/network/TcpSocket.cpp Mon Jul  3 08:03:02 2006
@@ -15,7 +15,7 @@
  * limitations under the License.
  */
 
-#if defined(unix) && !defined(__CYGWIN__)
+#if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
    #include <unistd.h>
    #include <netdb.h>
    #include <fcntl.h>
@@ -46,7 +46,7 @@
 using namespace activemq::io;
 
 
-#if !defined( unix ) || defined( __CYGWIN__ )
+#if !(defined( unix ) || defined(__APPLE__)) || defined( __CYGWIN__ )
 
    // Static socket initializer needed for winsock
 
@@ -77,7 +77,7 @@
    inputStream = NULL;
    outputStream = NULL;
    
-#if !defined( unix ) || defined( __CYGWIN__ )
+#if !(defined( unix ) || defined(__APPLE__)) || defined( __CYGWIN__ )
     if (staticSocketInitializer.getSocketInitError() != NULL) {
         throw *staticSocketInitializer.getSocketInitError();
     }
@@ -192,7 +192,7 @@
       
       ::shutdown(socketHandle, 2);
         
-      #if defined(unix) && !defined(__CYGWIN__)
+      #if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
          ::close(socketHandle);
       #else
          ::closesocket(socketHandle);
@@ -286,7 +286,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 void TcpSocket::setSoTimeout ( const int millisecs ) throw (SocketException)
 {
-#if defined( unix ) && !defined( __CYGWIN__ )
+#if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
   timeval timot;
   timot.tv_sec = millisecs / 1000;
   timot.tv_usec = (millisecs % 1000) * 1000;
@@ -301,7 +301,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 int TcpSocket::getSoTimeout() const throw(SocketException)
 {
-#if defined( unix ) && !defined( __CYGWIN__ )
+#if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
   timeval timot;
   timot.tv_sec = 0;
   timot.tv_usec = 0;
@@ -313,7 +313,7 @@
   
   ::getsockopt(socketHandle, SOL_SOCKET, SO_RCVTIMEO, (char*) &timot, &size);
   
-#if defined( unix ) && !defined( __CYGWIN__ )
+#if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
   return (timot.tv_sec * 1000) + (timot.tv_usec / 1000);
 #else
   return timot;

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Endian.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Endian.h?rev=418786&r1=418785&r2=418786&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Endian.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Endian.h Mon Jul  3 08:03:02 2006
@@ -17,7 +17,7 @@
 #ifndef ACTIVEMQ_UTIL_ENDIAN_H
 #define ACTIVEMQ_UTIL_ENDIAN_H
 
-#ifdef unix
+#if defined( unix ) || defined(__APPLE__)
 #include <netinet/in.h>
 #else
 #include <Winsock2.h>
@@ -25,7 +25,7 @@
 
 // First try - check __BYTE_ORDER macro
 #if !defined IFR_IS_BIG_ENDIAN && !defined IFR_IS_LITTLE_ENDIAN && !defined IFR_IS_DPD_ENDIAN
-# ifdef unix
+# if defined( unix ) || defined(__APPLE__)
 #  include <sys/param.h> // defines __BYTE_ORDER (or sometimes __LITTLE_ENDIAN or __BIG_ENDIAN or __PDP_ENDIAN)
 # endif
 # if defined (__GLIBC__)

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.cpp
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.cpp?rev=418786&r1=418785&r2=418786&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.cpp (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.cpp Mon Jul  3 08:03:02 2006
@@ -25,7 +25,7 @@
 Guid::Guid(void)
 {
    // Clear internal uuid, would pass isNull
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       memset(&uuid, 0, sizeof(uuid_t));
    #else
       ::UuidCreateNil(&uuid);
@@ -62,7 +62,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 bool Guid::isNull(void) const
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // Check the uuid APIs is null method
       return uuid_is_null(*(const_cast<uuid_t*>(&uuid))) == 1 ? true : false;
    #else
@@ -77,7 +77,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 void Guid::setNull(void)
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // use the uuid function to clear
       uuid_clear(uuid);
    #else
@@ -88,7 +88,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 Guid& Guid::createGUID(void) throw( RuntimeException )
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // Use the uuid_generate method to create a new GUID
       uuid_generate(uuid);
    #else
@@ -111,7 +111,7 @@
 {
    std::string uuid_str = "";
 
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // Create storage for the string buffer
       char buffer[36] = {0};
       
@@ -156,7 +156,7 @@
    unsigned char* buffer = new unsigned char[getRawBytesSize()];
    
    // copy our buffer
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       uuid_copy(buffer, *(const_cast<uuid_t*>(&uuid)));
    #else
       memcpy(buffer, &uuid, getRawBytesSize());
@@ -177,7 +177,7 @@
    }
    
    // Copy the data
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       memcpy(uuid, bytes, getRawBytesSize());
    #else
       memcpy(&uuid, bytes, getRawBytesSize());
@@ -189,7 +189,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 int Guid::getRawBytesSize(void) const
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       return sizeof(uuid_t);
    #else
       return sizeof(::GUID);
@@ -199,7 +199,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 Guid::operator const unsigned char*() const
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       return &uuid[0];
    #else
       return reinterpret_cast<const unsigned char*>(&uuid);
@@ -210,7 +210,7 @@
 Guid& Guid::operator=(const Guid& source)
    throw ( IllegalArgumentException )
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // Use the uuid method to copy
       uuid_copy(uuid, *(const_cast<uuid_t*>(&source.uuid)));
    #else
@@ -225,7 +225,7 @@
 Guid& Guid::operator=(const std::string& source) 
    throw ( IllegalArgumentException )
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // Parse a uuid from the passed in string
       uuid_parse( const_cast<char*>(source.c_str()), uuid );
    #else
@@ -253,7 +253,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 bool Guid::operator==(const Guid& source) const
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // uuid_compare returns 0 for equal
       return uuid_compare(
                *(const_cast<uuid_t*>(&uuid)), 
@@ -291,7 +291,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 bool Guid::operator<(const Guid& source) const
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // uuid_compare returns 0 for equal
       return uuid_compare(
                *(const_cast<uuid_t*>(&uuid)), 
@@ -317,7 +317,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 bool Guid::operator<=(const Guid& source) const
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // uuid_compare returns 0 for equal
       return uuid_compare(
                *(const_cast<uuid_t*>(&uuid)), 
@@ -343,7 +343,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 bool Guid::operator>(const Guid& source) const
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // uuid_compare returns 0 for equal
       return uuid_compare(
                *(const_cast<uuid_t*>(&uuid)), 
@@ -369,7 +369,7 @@
 ////////////////////////////////////////////////////////////////////////////////
 bool Guid::operator>=(const Guid& source) const
 {
-   #if defined( unix ) && !defined( __CYGWIN__ )
+   #if (defined( unix ) || defined(__APPLE__)) && !defined( __CYGWIN__ )
       // uuid_compare returns 0 for equal
       return uuid_compare(
                *(const_cast<uuid_t*>(&uuid)), 

Modified: incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.h
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.h?rev=418786&r1=418785&r2=418786&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.h (original)
+++ incubator/activemq/trunk/activemq-cpp/src/main/activemq/util/Guid.h Mon Jul  3 08:03:02 2006
@@ -17,7 +17,7 @@
 #ifndef ACTIVEMQ_UTIL_GUID_H
 #define ACTIVEMQ_UTIL_GUID_H
 
-#if defined( unix ) && !defined( __CYGWIN__ )
+#if defined( unix ) || defined(__APPLE__) && !defined( __CYGWIN__ ) 
    #include <uuid/uuid.h>
 #elif defined(_WIN32) || defined( __CYGWIN__ )
 	#include <objbase.h>
@@ -187,7 +187,7 @@
    private:
    
       // the uuid that this object represents.
-      #ifdef unix
+      #if defined( unix ) || defined(__APPLE__)
          uuid_t uuid;
       #else
          ::GUID uuid;