Commit 2380b26d authored by Ian Craggs's avatar Ian Craggs

Add WIN64 to WIN32 conditional compilation statements

parent 72fe69ea
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include <time.h> #include <time.h>
#if defined(OPENSSL) #if defined(OPENSSL)
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#include "winsock2.h" #include "winsock2.h"
#endif #endif
#include <openssl/ssl.h> #include <openssl/ssl.h>
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -43,7 +43,7 @@ char* Broker_recordFFDC(char* symptoms); ...@@ -43,7 +43,7 @@ char* Broker_recordFFDC(char* symptoms);
#undef realloc #undef realloc
#undef free #undef free
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
mutex_type heap_mutex; mutex_type heap_mutex;
#else #else
static pthread_mutex_t heap_mutex_store = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t heap_mutex_store = PTHREAD_MUTEX_INITIALIZER;
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <time.h> #include <time.h>
#include <string.h> #include <string.h>
#if !defined(WIN32) #if !defined(WIN32) && !defined(WIN64)
#include <syslog.h> #include <syslog.h>
#include <sys/stat.h> #include <sys/stat.h>
#define GETTIMEOFDAY 1 #define GETTIMEOFDAY 1
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#include <sys/timeb.h> #include <sys/timeb.h>
#endif #endif
#if !defined(WIN32) #if !defined(WIN32) && !defined(WIN64)
/** /**
* _unlink mapping for linux * _unlink mapping for linux
*/ */
...@@ -112,7 +112,7 @@ struct timeb ts, last_ts; ...@@ -112,7 +112,7 @@ struct timeb ts, last_ts;
#endif #endif
static char msg_buf[512]; static char msg_buf[512];
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
mutex_type log_mutex; mutex_type log_mutex;
#else #else
static pthread_mutex_t log_mutex_store = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t log_mutex_store = PTHREAD_MUTEX_INITIALIZER;
...@@ -171,7 +171,7 @@ int Log_initialize(Log_nameValue* info) ...@@ -171,7 +171,7 @@ int Log_initialize(Log_nameValue* info)
info++; info++;
} }
} }
#if !defined(WIN32) #if !defined(WIN32) && !defined(WIN64)
struct stat buf; struct stat buf;
if (stat("/proc/version", &buf) != -1) if (stat("/proc/version", &buf) != -1)
{ {
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -72,7 +72,7 @@ enum MQTTAsync_threadStates ...@@ -72,7 +72,7 @@ enum MQTTAsync_threadStates
enum MQTTAsync_threadStates sendThread_state = STOPPED; enum MQTTAsync_threadStates sendThread_state = STOPPED;
enum MQTTAsync_threadStates receiveThread_state = STOPPED; enum MQTTAsync_threadStates receiveThread_state = STOPPED;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
static mutex_type mqttasync_mutex = NULL; static mutex_type mqttasync_mutex = NULL;
static mutex_type mqttcommand_mutex = NULL; static mutex_type mqttcommand_mutex = NULL;
static sem_type send_sem = NULL; static sem_type send_sem = NULL;
...@@ -148,7 +148,7 @@ void MQTTAsync_closeSession(Clients* client); ...@@ -148,7 +148,7 @@ void MQTTAsync_closeSession(Clients* client);
void MQTTProtocol_closeSession(Clients* client, int sendwill); void MQTTProtocol_closeSession(Clients* client, int sendwill);
void MQTTAsync_writeComplete(int socket); void MQTTAsync_writeComplete(int socket);
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#define START_TIME_TYPE DWORD #define START_TIME_TYPE DWORD
START_TIME_TYPE MQTTAsync_start_clock(void) START_TIME_TYPE MQTTAsync_start_clock(void)
{ {
...@@ -173,7 +173,7 @@ START_TIME_TYPE MQTTAsync_start_clock(void) ...@@ -173,7 +173,7 @@ START_TIME_TYPE MQTTAsync_start_clock(void)
#endif #endif
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
long MQTTAsync_elapsed(DWORD milliseconds) long MQTTAsync_elapsed(DWORD milliseconds)
{ {
return GetTickCount() - milliseconds; return GetTickCount() - milliseconds;
...@@ -296,7 +296,7 @@ int MQTTAsync_restoreMessageQueue(MQTTAsyncs* client); ...@@ -296,7 +296,7 @@ int MQTTAsync_restoreMessageQueue(MQTTAsyncs* client);
void MQTTAsync_sleep(long milliseconds) void MQTTAsync_sleep(long milliseconds)
{ {
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
Sleep(milliseconds); Sleep(milliseconds);
#else #else
usleep(milliseconds*1000); usleep(milliseconds*1000);
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
#if !defined(MQTTASYNC_H) #if !defined(MQTTASYNC_H)
#define MQTTASYNC_H #define MQTTASYNC_H
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#define DLLImport __declspec(dllimport) #define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport) #define DLLExport __declspec(dllexport)
#else #else
...@@ -1174,7 +1174,7 @@ int main(int argc, char* argv[]) ...@@ -1174,7 +1174,7 @@ int main(int argc, char* argv[])
"on topic %s for client with ClientID: %s\n", "on topic %s for client with ClientID: %s\n",
PAYLOAD, TOPIC, CLIENTID); PAYLOAD, TOPIC, CLIENTID);
while (!finished) while (!finished)
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
Sleep(100); Sleep(100);
#else #else
usleep(10000L); usleep(10000L);
...@@ -1324,7 +1324,7 @@ int main(int argc, char* argv[]) ...@@ -1324,7 +1324,7 @@ int main(int argc, char* argv[])
} }
while (!subscribed) while (!subscribed)
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
Sleep(100); Sleep(100);
#else #else
usleep(10000L); usleep(10000L);
...@@ -1345,7 +1345,7 @@ int main(int argc, char* argv[]) ...@@ -1345,7 +1345,7 @@ int main(int argc, char* argv[])
exit(-1); exit(-1);
} }
while (!disc_finished) while (!disc_finished)
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
Sleep(100); Sleep(100);
#else #else
usleep(10000L); usleep(10000L);
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -68,7 +68,7 @@ ClientStates* bstate = &ClientState; ...@@ -68,7 +68,7 @@ ClientStates* bstate = &ClientState;
MQTTProtocol state; MQTTProtocol state;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
static mutex_type mqttclient_mutex = NULL; static mutex_type mqttclient_mutex = NULL;
extern mutex_type stack_mutex; extern mutex_type stack_mutex;
extern mutex_type heap_mutex; extern mutex_type heap_mutex;
...@@ -161,7 +161,7 @@ typedef struct ...@@ -161,7 +161,7 @@ typedef struct
void MQTTClient_sleep(long milliseconds) void MQTTClient_sleep(long milliseconds)
{ {
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
Sleep(milliseconds); Sleep(milliseconds);
#else #else
usleep(milliseconds*1000); usleep(milliseconds*1000);
...@@ -170,7 +170,7 @@ void MQTTClient_sleep(long milliseconds) ...@@ -170,7 +170,7 @@ void MQTTClient_sleep(long milliseconds)
} }
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#define START_TIME_TYPE DWORD #define START_TIME_TYPE DWORD
START_TIME_TYPE MQTTClient_start_clock(void) START_TIME_TYPE MQTTClient_start_clock(void)
{ {
...@@ -195,7 +195,7 @@ START_TIME_TYPE MQTTClient_start_clock(void) ...@@ -195,7 +195,7 @@ START_TIME_TYPE MQTTClient_start_clock(void)
#endif #endif
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
long MQTTClient_elapsed(DWORD milliseconds) long MQTTClient_elapsed(DWORD milliseconds)
{ {
return GetTickCount() - milliseconds; return GetTickCount() - milliseconds;
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
#if !defined(MQTTCLIENT_H) #if !defined(MQTTCLIENT_H)
#define MQTTCLIENT_H #define MQTTCLIENT_H
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#define DLLImport __declspec(dllimport) #define DLLImport __declspec(dllimport)
#define DLLExport __declspec(dllexport) #define DLLExport __declspec(dllexport)
#else #else
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#include <windows.h> #include <windows.h>
#include <direct.h> #include <direct.h>
/* Windows doesn't have strtok_r, so remap it to strtok */ /* Windows doesn't have strtok_r, so remap it to strtok */
...@@ -122,7 +122,7 @@ int pstmkdir( char *pPathname ) ...@@ -122,7 +122,7 @@ int pstmkdir( char *pPathname )
int rc = 0; int rc = 0;
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
if ( _mkdir( pPathname ) != 0 ) if ( _mkdir( pPathname ) != 0 )
{ {
#else #else
...@@ -262,7 +262,7 @@ int pstremove(void* handle, char* key) ...@@ -262,7 +262,7 @@ int pstremove(void* handle, char* key)
file = malloc(strlen(clientDir) + strlen(key) + strlen(MESSAGE_FILENAME_EXTENSION) + 2); file = malloc(strlen(clientDir) + strlen(key) + strlen(MESSAGE_FILENAME_EXTENSION) + 2);
sprintf(file, "%s/%s%s", clientDir, key, MESSAGE_FILENAME_EXTENSION); sprintf(file, "%s/%s%s", clientDir, key, MESSAGE_FILENAME_EXTENSION);
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
if ( _unlink(file) != 0 ) if ( _unlink(file) != 0 )
{ {
#else #else
...@@ -296,7 +296,7 @@ int pstclose(void* handle) ...@@ -296,7 +296,7 @@ int pstclose(void* handle)
goto exit; goto exit;
} }
#if defined (WIN32) #if defined(WIN32) || defined(WIN64)
if ( _rmdir(clientDir) != 0 ) if ( _rmdir(clientDir) != 0 )
{ {
#else #else
...@@ -330,7 +330,7 @@ int pstcontainskey(void *handle, char *key) ...@@ -330,7 +330,7 @@ int pstcontainskey(void *handle, char *key)
goto exit; goto exit;
} }
#if defined (WIN32) #if defined(WIN32) || defined(WIN64)
rc = containskeyWin32(clientDir, key); rc = containskeyWin32(clientDir, key);
#else #else
rc = containskeyUnix(clientDir, key); rc = containskeyUnix(clientDir, key);
...@@ -342,7 +342,7 @@ exit: ...@@ -342,7 +342,7 @@ exit:
} }
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
int containskeyWin32(char *dirname, char *key) int containskeyWin32(char *dirname, char *key)
{ {
int notFound = MQTTCLIENT_PERSISTENCE_ERROR; int notFound = MQTTCLIENT_PERSISTENCE_ERROR;
...@@ -440,7 +440,7 @@ int pstclear(void *handle) ...@@ -440,7 +440,7 @@ int pstclear(void *handle)
goto exit; goto exit;
} }
#if defined (WIN32) #if defined(WIN32) || defined(WIN64)
rc = clearWin32(clientDir); rc = clearWin32(clientDir);
#else #else
rc = clearUnix(clientDir); rc = clearUnix(clientDir);
...@@ -452,7 +452,7 @@ exit: ...@@ -452,7 +452,7 @@ exit:
} }
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
int clearWin32(char *dirname) int clearWin32(char *dirname)
{ {
int rc = 0; int rc = 0;
...@@ -540,7 +540,7 @@ int pstkeys(void *handle, char ***keys, int *nkeys) ...@@ -540,7 +540,7 @@ int pstkeys(void *handle, char ***keys, int *nkeys)
goto exit; goto exit;
} }
#if defined (WIN32) #if defined(WIN32) || defined(WIN64)
rc = keysWin32(clientDir, keys, nkeys); rc = keysWin32(clientDir, keys, nkeys);
#else #else
rc = keysUnix(clientDir, keys, nkeys); rc = keysUnix(clientDir, keys, nkeys);
...@@ -552,7 +552,7 @@ exit: ...@@ -552,7 +552,7 @@ exit:
} }
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
int keysWin32(char *dirname, char ***keys, int *nkeys) int keysWin32(char *dirname, char ***keys, int *nkeys)
{ {
int rc = 0; int rc = 0;
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2012, 2013 IBM Corp. * Copyright (c) 2012, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include <ctype.h> #include <ctype.h>
#include "MQTTAsync.h" #include "MQTTAsync.h"
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#include <windows.h> #include <windows.h>
#include <tchar.h> #include <tchar.h>
#include <io.h> #include <io.h>
...@@ -123,7 +123,7 @@ int loadandcall(char* libname) ...@@ -123,7 +123,7 @@ int loadandcall(char* libname)
{ {
int rc = 0; int rc = 0;
MQTTAsync_nameValue* (*func_address)(void) = NULL; MQTTAsync_nameValue* (*func_address)(void) = NULL;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
HMODULE APILibrary = LoadLibrary(libname); HMODULE APILibrary = LoadLibrary(libname);
if (APILibrary == NULL) if (APILibrary == NULL)
...@@ -187,7 +187,7 @@ int main(int argc, char** argv) ...@@ -187,7 +187,7 @@ int main(int argc, char** argv)
for (i = 0; i < ARRAY_SIZE(libraries); ++i) for (i = 0; i < ARRAY_SIZE(libraries); ++i)
{ {
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
sprintf(namebuf, "%s.dll", libraries[i]); sprintf(namebuf, "%s.dll", libraries[i]);
#else #else
sprintf(namebuf, "lib%s.so.1", libraries[i]); sprintf(namebuf, "lib%s.so.1", libraries[i]);
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -44,7 +44,7 @@ void SSLSocket_addPendingRead(int sock); ...@@ -44,7 +44,7 @@ void SSLSocket_addPendingRead(int sock);
static ssl_mutex_type* sslLocks = NULL; static ssl_mutex_type* sslLocks = NULL;
static ssl_mutex_type sslCoreMutex; static ssl_mutex_type sslCoreMutex;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#define iov_len len #define iov_len len
#define iov_base buf #define iov_base buf
#endif #endif
...@@ -305,7 +305,7 @@ int SSL_create_mutex(ssl_mutex_type* mutex) ...@@ -305,7 +305,7 @@ int SSL_create_mutex(ssl_mutex_type* mutex)
int rc = 0; int rc = 0;
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
*mutex = CreateMutex(NULL, 0, NULL); *mutex = CreateMutex(NULL, 0, NULL);
#else #else
rc = pthread_mutex_init(mutex, NULL); rc = pthread_mutex_init(mutex, NULL);
...@@ -319,7 +319,7 @@ int SSL_lock_mutex(ssl_mutex_type* mutex) ...@@ -319,7 +319,7 @@ int SSL_lock_mutex(ssl_mutex_type* mutex)
int rc = -1; int rc = -1;
/* don't add entry/exit trace points, as trace gets lock too, and it might happen quite frequently */ /* don't add entry/exit trace points, as trace gets lock too, and it might happen quite frequently */
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
if (WaitForSingleObject(*mutex, INFINITE) != WAIT_FAILED) if (WaitForSingleObject(*mutex, INFINITE) != WAIT_FAILED)
#else #else
if ((rc = pthread_mutex_lock(mutex)) == 0) if ((rc = pthread_mutex_lock(mutex)) == 0)
...@@ -334,7 +334,7 @@ int SSL_unlock_mutex(ssl_mutex_type* mutex) ...@@ -334,7 +334,7 @@ int SSL_unlock_mutex(ssl_mutex_type* mutex)
int rc = -1; int rc = -1;
/* don't add entry/exit trace points, as trace gets lock too, and it might happen quite frequently */ /* don't add entry/exit trace points, as trace gets lock too, and it might happen quite frequently */
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
if (ReleaseMutex(*mutex) != 0) if (ReleaseMutex(*mutex) != 0)
#else #else
if ((rc = pthread_mutex_unlock(mutex)) == 0) if ((rc = pthread_mutex_unlock(mutex)) == 0)
...@@ -349,7 +349,7 @@ void SSL_destroy_mutex(ssl_mutex_type* mutex) ...@@ -349,7 +349,7 @@ void SSL_destroy_mutex(ssl_mutex_type* mutex)
int rc = 0; int rc = 0;
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
rc = CloseHandle(*mutex); rc = CloseHandle(*mutex);
#else #else
rc = pthread_mutex_destroy(mutex); rc = pthread_mutex_destroy(mutex);
...@@ -363,7 +363,7 @@ void SSL_destroy_mutex(ssl_mutex_type* mutex) ...@@ -363,7 +363,7 @@ void SSL_destroy_mutex(ssl_mutex_type* mutex)
#if (OPENSSL_VERSION_NUMBER >= 0x010000000) #if (OPENSSL_VERSION_NUMBER >= 0x010000000)
extern void SSLThread_id(CRYPTO_THREADID *id) extern void SSLThread_id(CRYPTO_THREADID *id)
{ {
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
CRYPTO_THREADID_set_numeric(id, (unsigned long)GetCurrentThreadId()); CRYPTO_THREADID_set_numeric(id, (unsigned long)GetCurrentThreadId());
#else #else
CRYPTO_THREADID_set_numeric(id, (unsigned long)pthread_self()); CRYPTO_THREADID_set_numeric(id, (unsigned long)pthread_self());
...@@ -372,7 +372,7 @@ extern void SSLThread_id(CRYPTO_THREADID *id) ...@@ -372,7 +372,7 @@ extern void SSLThread_id(CRYPTO_THREADID *id)
#else #else
extern unsigned long SSLThread_id(void) extern unsigned long SSLThread_id(void)
{ {
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
return (unsigned long)GetCurrentThreadId(); return (unsigned long)GetCurrentThreadId();
#else #else
return (unsigned long)pthread_self(); return (unsigned long)pthread_self();
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#if !defined(SSLSOCKET_H) #if !defined(SSLSOCKET_H)
#define SSLSOCKET_H #define SSLSOCKET_H
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#define ssl_mutex_type HANDLE #define ssl_mutex_type HANDLE
#else #else
#include <pthread.h> #include <pthread.h>
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
int Socket_close_only(int socket); int Socket_close_only(int socket);
int Socket_continueWrites(fd_set* pwset); int Socket_continueWrites(fd_set* pwset);
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#define iov_len len #define iov_len len
#define iov_base buf #define iov_base buf
#endif #endif
...@@ -61,7 +61,7 @@ static fd_set wset; ...@@ -61,7 +61,7 @@ static fd_set wset;
int Socket_setnonblocking(int sock) int Socket_setnonblocking(int sock)
{ {
int rc; int rc;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
u_long flag = 1L; u_long flag = 1L;
FUNC_ENTRY; FUNC_ENTRY;
...@@ -87,12 +87,12 @@ int Socket_setnonblocking(int sock) ...@@ -87,12 +87,12 @@ int Socket_setnonblocking(int sock)
*/ */
int Socket_error(char* aString, int sock) int Socket_error(char* aString, int sock)
{ {
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
int errno; int errno;
#endif #endif
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
errno = WSAGetLastError(); errno = WSAGetLastError();
#endif #endif
if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && errno != EWOULDBLOCK) if (errno != EINTR && errno != EAGAIN && errno != EINPROGRESS && errno != EWOULDBLOCK)
...@@ -110,7 +110,7 @@ int Socket_error(char* aString, int sock) ...@@ -110,7 +110,7 @@ int Socket_error(char* aString, int sock)
*/ */
void Socket_outInitialize() void Socket_outInitialize()
{ {
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
WORD winsockVer = 0x0202; WORD winsockVer = 0x0202;
WSADATA wsd; WSADATA wsd;
...@@ -144,7 +144,7 @@ void Socket_outTerminate() ...@@ -144,7 +144,7 @@ void Socket_outTerminate()
ListFree(s.write_pending); ListFree(s.write_pending);
ListFree(s.clientsds); ListFree(s.clientsds);
SocketBuffer_terminate(); SocketBuffer_terminate();
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
WSACleanup(); WSACleanup();
#endif #endif
FUNC_EXIT; FUNC_EXIT;
...@@ -397,7 +397,7 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes) ...@@ -397,7 +397,7 @@ int Socket_writev(int socket, iobuf* iovecs, int count, unsigned long* bytes)
int rc; int rc;
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
rc = WSASend(socket, iovecs, count, (LPDWORD)bytes, 0, NULL, NULL); rc = WSASend(socket, iovecs, count, (LPDWORD)bytes, 0, NULL, NULL);
if (rc == SOCKET_ERROR) if (rc == SOCKET_ERROR)
{ {
...@@ -517,7 +517,7 @@ int Socket_close_only(int socket) ...@@ -517,7 +517,7 @@ int Socket_close_only(int socket)
int rc; int rc;
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
if (shutdown(socket, SD_BOTH) == SOCKET_ERROR) if (shutdown(socket, SD_BOTH) == SOCKET_ERROR)
Socket_error("shutdown", socket); Socket_error("shutdown", socket);
if ((rc = closesocket(socket)) == SOCKET_ERROR) if ((rc = closesocket(socket)) == SOCKET_ERROR)
...@@ -587,7 +587,7 @@ int Socket_new(char* addr, int port, int* sock) ...@@ -587,7 +587,7 @@ int Socket_new(char* addr, int port, int* sock)
struct sockaddr_in6 address6; struct sockaddr_in6 address6;
#endif #endif
int rc = SOCKET_ERROR; int rc = SOCKET_ERROR;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
short family; short family;
#else #else
sa_family_t family = AF_INET; sa_family_t family = AF_INET;
...@@ -812,7 +812,7 @@ char* Socket_getaddrname(struct sockaddr* sa, int sock) ...@@ -812,7 +812,7 @@ char* Socket_getaddrname(struct sockaddr* sa, int sock)
#define PORTLEN 10 #define PORTLEN 10
static char addr_string[ADDRLEN + PORTLEN]; static char addr_string[ADDRLEN + PORTLEN];
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
int buflen = ADDRLEN*2; int buflen = ADDRLEN*2;
wchar_t buf[ADDRLEN*2]; wchar_t buf[ADDRLEN*2];
if (WSAAddressToString(sa, sizeof(struct sockaddr_in6), NULL, buf, (LPDWORD)&buflen) == SOCKET_ERROR) if (WSAAddressToString(sa, sizeof(struct sockaddr_in6), NULL, buf, (LPDWORD)&buflen) == SOCKET_ERROR)
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include <sys/types.h> #include <sys/types.h>
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#include <winsock2.h> #include <winsock2.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
#define MAXHOSTNAMELEN 256 #define MAXHOSTNAMELEN 256
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "Heap.h" #include "Heap.h"
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#define iov_len len #define iov_len len
#define iov_base buf #define iov_base buf
#endif #endif
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#if !defined(SOCKETBUFFER_H) #if !defined(SOCKETBUFFER_H)
#define SOCKETBUFFER_H #define SOCKETBUFFER_H
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#include "winsock2.h" #include "winsock2.h"
#else #else
#include <sys/socket.h> #include <sys/socket.h>
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include <openssl/ssl.h> #include <openssl/ssl.h>
#endif #endif
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
typedef WSABUF iobuf; typedef WSABUF iobuf;
#else #else
typedef struct iovec iobuf; typedef struct iovec iobuf;
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2012 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#define snprintf _snprintf #define snprintf _snprintf
#endif #endif
...@@ -64,7 +64,7 @@ static int thread_count = 0; ...@@ -64,7 +64,7 @@ static int thread_count = 0;
static threadEntry threads[MAX_THREADS]; static threadEntry threads[MAX_THREADS];
static threadEntry *cur_thread = NULL; static threadEntry *cur_thread = NULL;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
mutex_type stack_mutex; mutex_type stack_mutex;
#else #else
static pthread_mutex_t stack_mutex_store = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t stack_mutex_store = PTHREAD_MUTEX_INITIALIZER;
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#define FUNC_EXIT_MED_RC(x) #define FUNC_EXIT_MED_RC(x)
#define FUNC_EXIT_MAX_RC(x) #define FUNC_EXIT_MAX_RC(x)
#else #else
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#define inline __inline #define inline __inline
#define FUNC_ENTRY StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MINIMUM) #define FUNC_ENTRY StackTrace_entry(__FUNCTION__, __LINE__, TRACE_MINIMUM)
#define FUNC_ENTRY_NOLOG StackTrace_entry(__FUNCTION__, __LINE__, -1) #define FUNC_ENTRY_NOLOG StackTrace_entry(__FUNCTION__, __LINE__, -1)
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
#undef realloc #undef realloc
#undef free #undef free
#if !defined(WIN32) #if !defined(WIN32) && !defined(WIN64)
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
*/ */
thread_type Thread_start(thread_fn fn, void* parameter) thread_type Thread_start(thread_fn fn, void* parameter)
{ {
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
thread_type thread = NULL; thread_type thread = NULL;
#else #else
thread_type thread = 0; thread_type thread = 0;
...@@ -63,7 +63,7 @@ thread_type Thread_start(thread_fn fn, void* parameter) ...@@ -63,7 +63,7 @@ thread_type Thread_start(thread_fn fn, void* parameter)
#endif #endif
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
thread = CreateThread(NULL, 0, fn, parameter, 0, NULL); thread = CreateThread(NULL, 0, fn, parameter, 0, NULL);
#else #else
pthread_attr_init(&attr); pthread_attr_init(&attr);
...@@ -87,7 +87,7 @@ mutex_type Thread_create_mutex() ...@@ -87,7 +87,7 @@ mutex_type Thread_create_mutex()
int rc = 0; int rc = 0;
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
mutex = CreateMutex(NULL, 0, NULL); mutex = CreateMutex(NULL, 0, NULL);
#else #else
mutex = malloc(sizeof(pthread_mutex_t)); mutex = malloc(sizeof(pthread_mutex_t));
...@@ -108,7 +108,7 @@ int Thread_lock_mutex(mutex_type mutex) ...@@ -108,7 +108,7 @@ int Thread_lock_mutex(mutex_type mutex)
int rc = -1; int rc = -1;
/* don't add entry/exit trace points as the stack log uses mutexes - recursion beckons */ /* don't add entry/exit trace points as the stack log uses mutexes - recursion beckons */
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
/* WaitForSingleObject returns WAIT_OBJECT_0 (0), on success */ /* WaitForSingleObject returns WAIT_OBJECT_0 (0), on success */
rc = WaitForSingleObject(mutex, INFINITE); rc = WaitForSingleObject(mutex, INFINITE);
#else #else
...@@ -129,7 +129,7 @@ int Thread_unlock_mutex(mutex_type mutex) ...@@ -129,7 +129,7 @@ int Thread_unlock_mutex(mutex_type mutex)
int rc = -1; int rc = -1;
/* don't add entry/exit trace points as the stack log uses mutexes - recursion beckons */ /* don't add entry/exit trace points as the stack log uses mutexes - recursion beckons */
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
/* if ReleaseMutex fails, the return value is 0 */ /* if ReleaseMutex fails, the return value is 0 */
if (ReleaseMutex(mutex) == 0) if (ReleaseMutex(mutex) == 0)
rc = GetLastError(); rc = GetLastError();
...@@ -152,7 +152,7 @@ void Thread_destroy_mutex(mutex_type mutex) ...@@ -152,7 +152,7 @@ void Thread_destroy_mutex(mutex_type mutex)
int rc = 0; int rc = 0;
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
rc = CloseHandle(mutex); rc = CloseHandle(mutex);
#else #else
rc = pthread_mutex_destroy(mutex); rc = pthread_mutex_destroy(mutex);
...@@ -168,7 +168,7 @@ void Thread_destroy_mutex(mutex_type mutex) ...@@ -168,7 +168,7 @@ void Thread_destroy_mutex(mutex_type mutex)
*/ */
thread_id_type Thread_getid() thread_id_type Thread_getid()
{ {
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
return GetCurrentThreadId(); return GetCurrentThreadId();
#else #else
return pthread_self(); return pthread_self();
...@@ -200,7 +200,7 @@ sem_type Thread_create_sem() ...@@ -200,7 +200,7 @@ sem_type Thread_create_sem()
int rc = 0; int rc = 0;
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
sem = CreateEvent( sem = CreateEvent(
NULL, // default security attributes NULL, // default security attributes
FALSE, // manual-reset event? FALSE, // manual-reset event?
...@@ -249,7 +249,7 @@ int Thread_wait_sem(sem_type sem, int timeout) ...@@ -249,7 +249,7 @@ int Thread_wait_sem(sem_type sem, int timeout)
* so I've used trywait in a loop instead. Ian Craggs 23/7/2010 * so I've used trywait in a loop instead. Ian Craggs 23/7/2010
*/ */
int rc = -1; int rc = -1;
#if !defined(WIN32) #if !defined(WIN32) && !defined(WIN64)
#define USE_TRYWAIT #define USE_TRYWAIT
#if defined(USE_TRYWAIT) #if defined(USE_TRYWAIT)
int i = 0; int i = 0;
...@@ -261,7 +261,7 @@ int Thread_wait_sem(sem_type sem, int timeout) ...@@ -261,7 +261,7 @@ int Thread_wait_sem(sem_type sem, int timeout)
#endif #endif
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
rc = WaitForSingleObject(sem, timeout); rc = WaitForSingleObject(sem, timeout);
#elif defined(USE_TRYWAIT) #elif defined(USE_TRYWAIT)
while (++i < count && (rc = sem_trywait(sem)) != 0) while (++i < count && (rc = sem_trywait(sem)) != 0)
...@@ -293,7 +293,7 @@ int Thread_wait_sem(sem_type sem, int timeout) ...@@ -293,7 +293,7 @@ int Thread_wait_sem(sem_type sem, int timeout)
*/ */
int Thread_check_sem(sem_type sem) int Thread_check_sem(sem_type sem)
{ {
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
return WaitForSingleObject(sem, 0) == WAIT_OBJECT_0; return WaitForSingleObject(sem, 0) == WAIT_OBJECT_0;
#else #else
int semval = -1; int semval = -1;
...@@ -313,7 +313,7 @@ int Thread_post_sem(sem_type sem) ...@@ -313,7 +313,7 @@ int Thread_post_sem(sem_type sem)
int rc = 0; int rc = 0;
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
if (SetEvent(sem) == 0) if (SetEvent(sem) == 0)
rc = GetLastError(); rc = GetLastError();
#else #else
...@@ -335,7 +335,7 @@ int Thread_destroy_sem(sem_type sem) ...@@ -335,7 +335,7 @@ int Thread_destroy_sem(sem_type sem)
int rc = 0; int rc = 0;
FUNC_ENTRY; FUNC_ENTRY;
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
rc = CloseHandle(sem); rc = CloseHandle(sem);
#elif defined(USE_NAMED_SEMAPHORES) #elif defined(USE_NAMED_SEMAPHORES)
int i; int i;
...@@ -359,7 +359,7 @@ int Thread_destroy_sem(sem_type sem) ...@@ -359,7 +359,7 @@ int Thread_destroy_sem(sem_type sem)
} }
#if !defined(WIN32) #if !defined(WIN32) && !defined(WIN64)
/** /**
* Create a new condition variable * Create a new condition variable
* @return the condition variable struct * @return the condition variable struct
......
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2009, 2013 IBM Corp. * Copyright (c) 2009, 2014 IBM Corp.
* *
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#if !defined(THREAD_H) #if !defined(THREAD_H)
#define THREAD_H #define THREAD_H
#if defined(WIN32) #if defined(WIN32) || defined(WIN64)
#include <Windows.h> #include <Windows.h>
#define thread_type HANDLE #define thread_type HANDLE
#define thread_id_type DWORD #define thread_id_type DWORD
......
...@@ -240,7 +240,7 @@ void myassert(char* filename, int lineno, char* description, int value, char* fo ...@@ -240,7 +240,7 @@ void myassert(char* filename, int lineno, char* description, int value, char* fo
va_list args; va_list args;
++failures; ++failures;
printf("Assertion failed, file %s, line %d, description: %s\n", filename, lineno, description); MyLog(LOGA_INFO, "Assertion failed, file %s, line %d, description: %s\n", filename, lineno, description);
va_start(args, format); va_start(args, format);
vprintf(format, args); vprintf(format, args);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment