patched the #ifdef stuff to work nicely on OS X - not sure why defined(unix) is false

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@418786 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-07-03 15:03:02 +00:00
parent 8a960016ed
commit 96f78a2c08
7 changed files with 36 additions and 36 deletions

View File

@ -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 @@ ServerSocket::ServerSocket()
{
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 @@ void ServerSocket::close() throw (cms::CMSException){
if (isBound()) {
#if defined(unix) && !defined(__CYGWIN__)
#if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
::close(socketHandle);
#else
::closesocket(socketHandle);
@ -186,7 +186,7 @@ Socket* ServerSocket::accept () throw (SocketException)
{
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);

View File

@ -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 @@ namespace network{
public:
// Define the SocketHandle type.
#if defined( unix ) && !defined( __CYGWIN__ )
#if defined( unix ) || defined(__APPLE__) && !defined( __CYGWIN__ )
typedef int SocketHandle;
#else
typedef SOCKET SocketHandle;

View File

@ -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 @@ SocketInputStream::~SocketInputStream()
int SocketInputStream::available() const{
#if defined(unix) && !defined(__CYGWIN__)
#if (defined(unix) || defined(__APPLE__)) && !defined(__CYGWIN__)
// Poll the socket for input.
pollfd fd;

View File

@ -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::network;
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 @@ TcpSocket::TcpSocket() {
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 @@ void TcpSocket::close() throw( cms::CMSException )
::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::setSendBufferSize( const int size ) throw(SocketException){
////////////////////////////////////////////////////////////////////////////////
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 @@ void TcpSocket::setSoTimeout ( const int millisecs ) throw (SocketException)
////////////////////////////////////////////////////////////////////////////////
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 @@ int TcpSocket::getSoTimeout() const throw(SocketException)
::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;

View File

@ -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__)

View File

@ -25,7 +25,7 @@ using namespace std;
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 @@ Guid::~Guid(void)
////////////////////////////////////////////////////////////////////////////////
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 @@ bool Guid::isNull(void) const
////////////////////////////////////////////////////////////////////////////////
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 @@ void Guid::setNull(void)
////////////////////////////////////////////////////////////////////////////////
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 Guid::toString(void) const throw( RuntimeException )
{
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 @@ const unsigned char* Guid::toBytes(void) const
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 @@ Guid& Guid::fromBytes(const unsigned char* bytes)
}
// 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 @@ Guid& Guid::fromBytes(const unsigned char* bytes)
////////////////////////////////////////////////////////////////////////////////
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 @@ int Guid::getRawBytesSize(void) const
////////////////////////////////////////////////////////////////////////////////
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::operator const unsigned char*() const
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 Guid& source)
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 @@ Guid& Guid::operator=(const std::string& source)
////////////////////////////////////////////////////////////////////////////////
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 std::string& source) const
////////////////////////////////////////////////////////////////////////////////
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 std::string& source) const
////////////////////////////////////////////////////////////////////////////////
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 std::string& source) const
////////////////////////////////////////////////////////////////////////////////
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 std::string& source) const
////////////////////////////////////////////////////////////////////////////////
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)),

View File

@ -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 @@ namespace util{
private:
// the uuid that this object represents.
#ifdef unix
#if defined( unix ) || defined(__APPLE__)
uuid_t uuid;
#else
::GUID uuid;