summaryrefslogtreecommitdiff
path: root/cpp/include
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/include')
-rw-r--r--cpp/include/Freeze/Application.h10
-rw-r--r--cpp/include/Freeze/Initialize.h10
-rw-r--r--cpp/include/Ice/Config.h61
-rw-r--r--cpp/include/Ice/Const.h34
-rw-r--r--cpp/include/IceSSL/CertificateVerifierOpenSSL.h11
-rw-r--r--cpp/include/IceSSL/Config.h29
-rw-r--r--cpp/include/IceSSL/RSACertificateGen.h11
-rw-r--r--cpp/include/IceSSL/RSAKeyPair.h10
-rw-r--r--cpp/include/IceSSL/RSAKeyPairF.h11
-rw-r--r--cpp/include/IceSSL/RSAPrivateKey.h11
-rw-r--r--cpp/include/IceSSL/RSAPublicKey.h11
-rw-r--r--cpp/include/IceUtil/Cond.h8
-rw-r--r--cpp/include/IceUtil/Config.h108
-rw-r--r--cpp/include/IceUtil/Shared.h97
-rw-r--r--cpp/include/IceXML/StreamI.h8
-rw-r--r--cpp/include/Slice/Parser.h8
-rw-r--r--cpp/include/Slice/Preprocessor.h8
-rw-r--r--cpp/include/XMLTransform/XMLTransform.h8
18 files changed, 184 insertions, 270 deletions
diff --git a/cpp/include/Freeze/Application.h b/cpp/include/Freeze/Application.h
index f87d9fec60e..0db2ee5bfdd 100644
--- a/cpp/include/Freeze/Application.h
+++ b/cpp/include/Freeze/Application.h
@@ -15,16 +15,6 @@
#ifndef FREEZE_APPLICATION_H
#define FREEZE_APPLICATION_H
-#ifdef _WIN32
-# ifdef FREEZE_API_EXPORTS
-# define FREEZE_API __declspec(dllexport)
-# else
-# define FREEZE_API __declspec(dllimport)
-# endif
-#else
-# define FREEZE_API /**/
-#endif
-
#include <Ice/Application.h>
#include <Freeze/Freeze.h>
diff --git a/cpp/include/Freeze/Initialize.h b/cpp/include/Freeze/Initialize.h
index 3b208a70238..8fefce833ce 100644
--- a/cpp/include/Freeze/Initialize.h
+++ b/cpp/include/Freeze/Initialize.h
@@ -18,16 +18,6 @@
#include <Ice/Ice.h>
#include <Freeze/DBF.h>
-#ifdef _WIN32
-# ifdef FREEZE_API_EXPORTS
-# define FREEZE_API __declspec(dllexport)
-# else
-# define FREEZE_API __declspec(dllimport)
-# endif
-#else
-# define FREEZE_API /**/
-#endif
-
namespace Freeze
{
diff --git a/cpp/include/Ice/Config.h b/cpp/include/Ice/Config.h
index a1211c23f8f..804e4ede4a7 100644
--- a/cpp/include/Ice/Config.h
+++ b/cpp/include/Ice/Config.h
@@ -27,6 +27,13 @@
#include <vector>
#include <map>
+#if defined(_WIN32)
+# include <process.h>
+#else
+# include <sys/types.h>
+# include <unistd.h>
+#endif
+
//
// Define the Ice and IceInternal namespace, so that we can use the following
// everywhere in our code:
@@ -42,21 +49,22 @@ namespace IceInternal
{
}
-#if defined(_WIN32)
-
+#ifndef ICE_API
# ifdef ICE_API_EXPORTS
-# define ICE_API __declspec(dllexport)
-# else
-# define ICE_API __declspec(dllimport)
-# endif
+# define ICE_API ICE_DECLSPEC_EXPORT
+# else
+# define ICE_API ICE_DECLSPEC_IMPORT
+# endif
+#endif
+#ifndef ICE_PROTOCOL_API
# ifdef ICE_PROTOCOL_API_EXPORTS
-# define ICE_PROTOCOL_API __declspec(dllexport)
+# define ICE_PROTOCOL_API ICE_DECLSPEC_EXPORT
# else
-# define ICE_PROTOCOL_API __declspec(dllimport)
+# define ICE_PROTOCOL_API ICE_DECLSPEC_IMPORT
# endif
+#endif
-# include <process.h>
namespace Ice
{
@@ -64,50 +72,19 @@ namespace Ice
typedef char Byte;
typedef short Short;
typedef int Int;
-typedef __int64 Long;
+typedef IceUtil::Int64 Long;
typedef float Float;
typedef double Double;
}
// TODO: Should not be inline, this is not performance critical.
+#ifdef _WIN32
inline int getSystemErrno() { return GetLastError(); }
inline int getSocketErrno() { return WSAGetLastError(); }
-
-#elif (defined(__linux__) || defined(__FreeBSD__)) && defined(i386) || defined (__sun)
-
-# include <sys/types.h>
-# include <unistd.h>
-
-# define ICE_API /**/
-# define ICE_PROTOCOL_API /**/
-
-namespace Ice
-{
-
-typedef char Byte;
-typedef short Short;
-typedef int Int;
-
-#ifdef __sparcv9
-typedef long Long
#else
-typedef long long Long;
-#endif
-
-typedef float Float;
-typedef double Double;
-
-}
-
-// TODO: Should not be inline, this is not performance critical.
inline int getSystemErrno() { return errno; }
inline int getSocketErrno() { return errno; }
-
-#else
-
-# error "Unsupported operating system or platform!"
-
#endif
#endif
diff --git a/cpp/include/Ice/Const.h b/cpp/include/Ice/Const.h
deleted file mode 100644
index 044fd3a8741..00000000000
--- a/cpp/include/Ice/Const.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003
-// ZeroC, Inc.
-// Billerica, MA, USA
-//
-// All Rights Reserved.
-//
-// Ice is free software; you can redistribute it and/or modify it under
-// the terms of the GNU General Public License version 2 as published by
-// the Free Software Foundation.
-//
-// **********************************************************************
-
-#ifndef ICE_CONST_H
-#define ICE_CONST_H
-
-//
-// TODO: - switch to C++ compiler macros, since this syntax is compiler
-// dependent
-// - define an ICE_WIDTH macro (or ICE_32 and ICE_64?) to avoid doing
-// the 32 vs 64 bit checks in multiple places.
-
-#if defined(_WIN32)
-# define ICE_INT64_LITERAL(n) n##i64
-#elif defined(__linux__) && defined(i386) || (defined (__sun) && !defined(__sparcv9))
-# define ICE_INT64_LITERAL(n) n##LL
-#elif defined (__sun) && defined(__sparcv9)
-# define ICE_INT64_LITERAL(n) n##L
-#else
-# error "Unsupported operating system or platform!"
-#endif
-
-#endif
diff --git a/cpp/include/IceSSL/CertificateVerifierOpenSSL.h b/cpp/include/IceSSL/CertificateVerifierOpenSSL.h
index f1eec1dadbf..722d1426f19 100644
--- a/cpp/include/IceSSL/CertificateVerifierOpenSSL.h
+++ b/cpp/include/IceSSL/CertificateVerifierOpenSSL.h
@@ -15,19 +15,10 @@
#ifndef ICE_SSL_CERTIFICATE_VERIFIER_OPENSSL_H
#define ICE_SSL_CERTIFICATE_VERIFIER_OPENSSL_H
+#include <IceSSL/Config.h>
#include <IceSSL/CertificateVerifier.h>
#include <openssl/ssl.h>
-#ifdef _WIN32
-# ifdef ICE_SSL_API_EXPORTS
-# define ICE_SSL_API __declspec(dllexport)
-# else
-# define ICE_SSL_API __declspec(dllimport)
-# endif
-#else
-# define ICE_SSL_API /**/
-#endif
-
namespace IceSSL
{
diff --git a/cpp/include/IceSSL/Config.h b/cpp/include/IceSSL/Config.h
new file mode 100644
index 00000000000..2f65d4f0eee
--- /dev/null
+++ b/cpp/include/IceSSL/Config.h
@@ -0,0 +1,29 @@
+// **********************************************************************
+//
+// Copyright (c) 2003
+// ZeroC, Inc.
+// Billerica, MA, USA
+//
+// All Rights Reserved.
+//
+// Ice is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License version 2 as published by
+// the Free Software Foundation.
+//
+// **********************************************************************
+
+
+#ifndef ICE_SSL_CONFIG_H
+#define ICE_SSL_CONFIG_H
+
+#include <IceUtil/Config.h>
+
+#ifndef ICE_SSL_API
+# ifdef ICE_SSL_API_EXPORTS
+# define ICE_SSL_API ICE_DECLSPEC_EXPORT
+# else
+# define ICE_SSL_API ICE_DECLSPEC_IMPORT
+# endif
+#endif
+
+#endif
diff --git a/cpp/include/IceSSL/RSACertificateGen.h b/cpp/include/IceSSL/RSACertificateGen.h
index c65b767b5c7..b5e86fa422e 100644
--- a/cpp/include/IceSSL/RSACertificateGen.h
+++ b/cpp/include/IceSSL/RSACertificateGen.h
@@ -16,16 +16,7 @@
#define ICE_SSL_CERTIFICATE_GEN_H
#include <IceSSL/RSAKeyPairF.h>
-
-#ifdef _WIN32
-# ifdef ICE_SSL_API_EXPORTS
-# define ICE_SSL_API __declspec(dllexport)
-# else
-# define ICE_SSL_API __declspec(dllimport)
-# endif
-#else
-# define ICE_SSL_API /**/
-#endif
+#include <IceSSL/Config.h>
namespace IceSSL
{
diff --git a/cpp/include/IceSSL/RSAKeyPair.h b/cpp/include/IceSSL/RSAKeyPair.h
index 8a18b25e81d..945d0493da7 100644
--- a/cpp/include/IceSSL/RSAKeyPair.h
+++ b/cpp/include/IceSSL/RSAKeyPair.h
@@ -23,18 +23,10 @@
#include <IceSSL/RSACertificateGenF.h>
#include <IceSSL/RSAPrivateKeyF.h>
#include <IceSSL/RSAPublicKeyF.h>
+#include <IceSSL/Config.h>
#include <openssl/ssl.h>
-#ifdef _WIN32
-# ifdef ICE_SSL_API_EXPORTS
-# define ICE_SSL_API __declspec(dllexport)
-# else
-# define ICE_SSL_API __declspec(dllimport)
-# endif
-#else
-# define ICE_SSL_API /**/
-#endif
namespace IceSSL
{
diff --git a/cpp/include/IceSSL/RSAKeyPairF.h b/cpp/include/IceSSL/RSAKeyPairF.h
index 422ab18ec0f..d750be15ae8 100644
--- a/cpp/include/IceSSL/RSAKeyPairF.h
+++ b/cpp/include/IceSSL/RSAKeyPairF.h
@@ -16,16 +16,7 @@
#define ICE_SSL_RSA_KEY_PAIR_F_H
#include <Ice/Handle.h>
-
-#ifdef _WIN32
-# ifdef ICE_SSL_API_EXPORTS
-# define ICE_SSL_API __declspec(dllexport)
-# else
-# define ICE_SSL_API __declspec(dllimport)
-# endif
-#else
-# define ICE_SSL_API /**/
-#endif
+#include <IceSSL/Config.h>
namespace IceSSL
{
diff --git a/cpp/include/IceSSL/RSAPrivateKey.h b/cpp/include/IceSSL/RSAPrivateKey.h
index c87a7394f8a..dc355ce9525 100644
--- a/cpp/include/IceSSL/RSAPrivateKey.h
+++ b/cpp/include/IceSSL/RSAPrivateKey.h
@@ -19,19 +19,12 @@
#include <Ice/BuiltinSequences.h>
+#include <IceSSL/Config.h>
#include <IceSSL/RSAPrivateKeyF.h>
#include <openssl/ssl.h>
-#ifdef _WIN32
-# ifdef ICE_SSL_API_EXPORTS
-# define ICE_SSL_API __declspec(dllexport)
-# else
-# define ICE_SSL_API __declspec(dllimport)
-# endif
-#else
-# define ICE_SSL_API /**/
-#endif
+
namespace IceSSL
{
diff --git a/cpp/include/IceSSL/RSAPublicKey.h b/cpp/include/IceSSL/RSAPublicKey.h
index c5ec47ca46b..dcec37086fc 100644
--- a/cpp/include/IceSSL/RSAPublicKey.h
+++ b/cpp/include/IceSSL/RSAPublicKey.h
@@ -19,20 +19,11 @@
#include <Ice/BuiltinSequences.h>
+#include <IceSSL/Config.h>
#include <IceSSL/RSAPublicKeyF.h>
#include <openssl/ssl.h>
-#ifdef _WIN32
-# ifdef ICE_SSL_API_EXPORTS
-# define ICE_SSL_API __declspec(dllexport)
-# else
-# define ICE_SSL_API __declspec(dllimport)
-# endif
-#else
-# define ICE_SSL_API /**/
-#endif
-
namespace IceSSL
{
diff --git a/cpp/include/IceUtil/Cond.h b/cpp/include/IceUtil/Cond.h
index 37973c059c3..f5b1d62220e 100644
--- a/cpp/include/IceUtil/Cond.h
+++ b/cpp/include/IceUtil/Cond.h
@@ -100,6 +100,10 @@ public:
template <typename Lock> inline void
wait(const Lock& lock) const
{
+ if (!lock.acquired())
+ {
+ throw ThreadLockedException(__FILE__, __LINE__);
+ }
waitImpl(lock._mutex);
}
@@ -113,6 +117,10 @@ public:
template <typename Lock> inline bool
timedWait(const Lock& lock, const Time& timeout) const
{
+ if (!lock.acquired())
+ {
+ throw ThreadLockedException(__FILE__, __LINE__);
+ }
return timedWaitImpl(lock._mutex, timeout);
}
diff --git a/cpp/include/IceUtil/Config.h b/cpp/include/IceUtil/Config.h
index 0e2a07026da..b67de990c41 100644
--- a/cpp/include/IceUtil/Config.h
+++ b/cpp/include/IceUtil/Config.h
@@ -17,13 +17,49 @@
//
-// Endianness: define ICE_UTIL_BIGENDIAN on big endian platforms,
-// nothing on little endian platforms.
+// Endianness
+// Most CPUs support only one endianness, with the notable exceptions
+// of Itanium (IA64) and MIPS.
+//
+#if defined(__i386) || defined(_M_IX86)
+# define ICE_LITTLE_ENDIAN
+#elif defined(__sparc)
+# define ICE_BIG_ENDIAN
+#else
+# error "Unknown architecture"
+#endif
-#if defined(__sparc)
-#define ICE_UTIL_BIGENDIAN
+//
+// 32 or 64 bit mode?
+//
+#if (defined(__sun) && defined(__sparcv9))
+# define ICE_64
+#else
+# define ICE_32
#endif
+//
+// Compiler extensions to export and import symbols: see the documentation
+// for Visual C++ and HP aC++.
+//
+// TODO: more macros to support IBM Visual Age _Export syntax as well.
+//
+#ifdef _MSC_VER
+# define ICE_DECLSPEC_EXPORT __declspec(dllexport)
+# define ICE_DECLSPEC_IMPORT __declspec(dllimport)
+#else
+# define ICE_DECLSPEC_EXPORT /**/
+# define ICE_DECLSPEC_IMPORT /**/
+#endif
+
+//
+// Let's use these extensions with for IceUtil:
+//
+#ifdef ICE_UTIL_API_EXPORTS
+# define ICE_UTIL_API ICE_DECLSPEC_EXPORT
+#else
+# define ICE_UTIL_API ICE_DECLSPEC_IMPORT
+#endif
//
// For STLport. If we compile in debug mode, we want to use the debug
@@ -47,12 +83,6 @@
# error "Only multi-threaded DLL libraries can be used with Ice!"
# endif
-# ifdef ICE_UTIL_API_EXPORTS
-# define ICE_UTIL_API __declspec(dllexport)
-# else
-# define ICE_UTIL_API __declspec(dllimport)
-# endif
-
# include <windows.h>
// '...' : forcing value to bool 'true' or 'false' (performance warning)
@@ -70,14 +100,9 @@
// ...: decorated name length exceeded, name was truncated
# pragma warning( disable : 4503 )
-# define SIZEOF_WCHAR_T 2
-
-#elif (defined(__linux) || defined(__FreeBSD__)) && defined(__i386)
-
-# define ICE_UTIL_API /**/
-# define HAVE_READLINE
-# define SIZEOF_WCHAR_T 4
-
+#elif defined(__sun) && defined(__sparc)
+# include <inttypes.h>
+#else
//
// The ISO C99 standard specifies that in C++ implementations the
// macros for minimum/maximum integer values should only be defined if
@@ -85,20 +110,8 @@
//
# define __STDC_LIMIT_MACROS
# include <stdint.h>
-
-#elif defined(__sun) && defined(__sparc)
-
-# define ICE_UTIL_API /**/
-# define SIZEOF_WCHAR_T 4
-# include <inttypes.h>
-
-#else
-
-# error "unsupported operating system or platform"
-
#endif
-
//
// Some include files we need almost everywhere.
//
@@ -139,32 +152,37 @@ private:
//
// Some definitions for 64-bit integers.
//
-#if defined(_WIN32)
-
+#if defined(_MSC_VER)
typedef __int64 Int64;
const Int64 Int64Min = -9223372036854775808i64;
const Int64 Int64Max = 9223372036854775807i64;
-# define ICE_INT64(x) Int64(x##i64)
+#elif defined(__SUNPRO_CC)
+# if defined(ICE_64)
+typedef long Int64;
+const Int64 Int64Min = -0x7fffffffffffffffL-1L;
+const Int64 Int64Max = 0x7fffffffffffffffL;
+# else
+typedef long long Int64;
+const Int64 Int64Min = -0x7fffffffffffffffLL-1LL;
+const Int64 Int64Max = 0x7fffffffffffffffLL;
+# endif
#else
-
-# if defined(INT64_MIN) && defined(INT64_MAX)
-
+// Assumes ISO C99 types
+//
typedef int64_t Int64;
const Int64 Int64Min = INT64_MIN;
const Int64 Int64Max = INT64_MAX;
-# else
-
-typedef long long Int64;
-const Int64 Int64Min = -0x7fffffffffffffffLL-1LL;
-const Int64 Int64Max = 0x7fffffffffffffffLL;
-
-# endif
-
-#define ICE_INT64(x) Int64(x##LL)
+#endif
+#if defined(_MSC_VER)
+# define ICE_INT64(n) n##i64
+#elif defined(ICE_64)
+# define ICE_INT64(n) n##L
+#else
+# define ICE_INT64(n) n##LL
#endif
}
diff --git a/cpp/include/IceUtil/Shared.h b/cpp/include/IceUtil/Shared.h
index aae20dc017a..7666f999dbd 100644
--- a/cpp/include/IceUtil/Shared.h
+++ b/cpp/include/IceUtil/Shared.h
@@ -17,19 +17,10 @@
#include <IceUtil/Config.h>
-//
-// The inline assembler causes problems with shared libraries.
-//
-#if (defined(__ICC) && !defined(_WIN32)) || defined (__sun)
-# define ICE_USE_MUTEX_SHARED
-#endif
-
-#ifdef ICE_USE_MUTEX_SHARED
-# include <IceUtil/Mutex.h>
-#endif
-
-#if !defined(_WIN32) && !defined(ICE_USE_MUTEX_SHARED)
+#if (defined(__linux) || defined(__FreeBSD__)) && defined(__i386) && !defined(__ICC)
+# define ICE_HAS_ATOMIC_FUNCTIONS
+// __ICC: The inline assembler causes problems with shared libraries.
//
// Linux only. Unfortunately, asm/atomic.h builds non-SMP safe code
// with non-SMP kernels. This means that executables compiled with a
@@ -116,6 +107,11 @@ inline int ice_atomic_exchange_add(int i, ice_atomic_t* v)
return tmp + i;
}
+#elif defined(_WIN32)
+// Nothing to include
+#else
+// Use a simple mutex
+# include <IceUtil/Mutex.h>
#endif
//
@@ -203,13 +199,13 @@ public:
private:
-#ifdef ICE_USE_MUTEX_SHARED
- int _ref;
- Mutex _mutex;
-#elif defined(_WIN32)
+#if defined(_WIN32)
LONG _ref;
-#else
+#elif defined(ICE_HAS_ATOMIC_FUNCTIONS)
ice_atomic_t _ref;
+#else
+ int _ref;
+ Mutex _mutex;
#endif
bool _noDelete;
};
@@ -219,7 +215,7 @@ private:
// all of them should be inlined.
//
-#ifdef ICE_USE_MUTEX_SHARED
+#if defined(_WIN32)
inline
Shared::Shared() :
@@ -236,26 +232,17 @@ Shared::~Shared()
inline void
Shared::__incRef()
{
- _mutex.lock();
- assert(_ref >= 0);
- ++_ref;
- _mutex.unlock();
+ assert(InterlockedExchangeAdd(&_ref, 0) >= 0);
+ InterlockedIncrement(&_ref);
}
inline void
Shared::__decRef()
{
- _mutex.lock();
- bool doDelete = false;
- assert(_ref > 0);
- if(--_ref == 0)
+ assert(InterlockedExchangeAdd(&_ref, 0) > 0);
+ if(InterlockedDecrement(&_ref) == 0 && !_noDelete)
{
- doDelete = !_noDelete;
_noDelete = true;
- }
- _mutex.unlock();
- if(doDelete)
- {
delete this;
}
}
@@ -263,27 +250,22 @@ Shared::__decRef()
inline int
Shared::__getRef() const
{
- _mutex.lock();
- int ref = _ref;
- _mutex.unlock();
- return ref;
+ return InterlockedExchangeAdd(const_cast<LONG*>(&_ref), 0);
}
inline void
Shared::__setNoDelete(bool b)
{
- _mutex.lock();
_noDelete = b;
- _mutex.unlock();
}
-#elif defined(_WIN32)
+#elif defined(ICE_HAS_ATOMIC_FUNCTIONS)
inline
Shared::Shared() :
- _ref(0),
_noDelete(false)
{
+ ice_atomic_set(&_ref, 0);
}
inline
@@ -294,15 +276,15 @@ Shared::~Shared()
inline void
Shared::__incRef()
{
- assert(InterlockedExchangeAdd(&_ref, 0) >= 0);
- InterlockedIncrement(&_ref);
+ assert(ice_atomic_exchange_add(0, &_ref) >= 0);
+ ice_atomic_inc(&_ref);
}
inline void
Shared::__decRef()
{
- assert(InterlockedExchangeAdd(&_ref, 0) > 0);
- if(InterlockedDecrement(&_ref) == 0 && !_noDelete)
+ assert(ice_atomic_exchange_add(0, &_ref) > 0);
+ if(ice_atomic_dec_and_test(&_ref) && !_noDelete)
{
_noDelete = true;
delete this;
@@ -312,7 +294,7 @@ Shared::__decRef()
inline int
Shared::__getRef() const
{
- return InterlockedExchangeAdd(const_cast<LONG*>(&_ref), 0);
+ return ice_atomic_exchange_add(0, const_cast<ice_atomic_t*>(&_ref));
}
inline void
@@ -325,9 +307,9 @@ Shared::__setNoDelete(bool b)
inline
Shared::Shared() :
+ _ref(0),
_noDelete(false)
{
- ice_atomic_set(&_ref, 0);
}
inline
@@ -338,17 +320,26 @@ Shared::~Shared()
inline void
Shared::__incRef()
{
- assert(ice_atomic_exchange_add(0, &_ref) >= 0);
- ice_atomic_inc(&_ref);
+ _mutex.lock();
+ assert(_ref >= 0);
+ ++_ref;
+ _mutex.unlock();
}
inline void
Shared::__decRef()
{
- assert(ice_atomic_exchange_add(0, &_ref) > 0);
- if(ice_atomic_dec_and_test(&_ref) && !_noDelete)
+ _mutex.lock();
+ bool doDelete = false;
+ assert(_ref > 0);
+ if(--_ref == 0)
{
+ doDelete = !_noDelete;
_noDelete = true;
+ }
+ _mutex.unlock();
+ if(doDelete)
+ {
delete this;
}
}
@@ -356,17 +347,21 @@ Shared::__decRef()
inline int
Shared::__getRef() const
{
- return ice_atomic_exchange_add(0, const_cast<ice_atomic_t*>(&_ref));
+ _mutex.lock();
+ int ref = _ref;
+ _mutex.unlock();
+ return ref;
}
inline void
Shared::__setNoDelete(bool b)
{
+ _mutex.lock();
_noDelete = b;
+ _mutex.unlock();
}
#endif
}
-
#endif
diff --git a/cpp/include/IceXML/StreamI.h b/cpp/include/IceXML/StreamI.h
index 7a5a7d7b324..e5144993486 100644
--- a/cpp/include/IceXML/StreamI.h
+++ b/cpp/include/IceXML/StreamI.h
@@ -21,14 +21,12 @@
#include <map>
-#ifdef _WIN32
+#ifndef ICE_XML_API
# ifdef ICE_XML_API_EXPORTS
-# define ICE_XML_API __declspec(dllexport)
+# define ICE_XML_API ICE_DECLSPEC_EXPORT
# else
-# define ICE_XML_API __declspec(dllimport)
+# define ICE_XML_API ICE_DECLSPEC_IMPORT
# endif
-#else
-# define ICE_XML_API /**/
#endif
namespace IceXML
diff --git a/cpp/include/Slice/Parser.h b/cpp/include/Slice/Parser.h
index 858a4efdbc3..ec7bee1a22d 100644
--- a/cpp/include/Slice/Parser.h
+++ b/cpp/include/Slice/Parser.h
@@ -25,14 +25,12 @@
#include <map>
#include <set>
-#ifdef _WIN32
+#ifndef SLICE_API
# ifdef SLICE_API_EXPORTS
-# define SLICE_API __declspec(dllexport)
+# define SLICE_API ICE_DECLSPEC_EXPORT
# else
-# define SLICE_API __declspec(dllimport)
+# define SLICE_API ICE_DECLSPEC_IMPORT
# endif
-#else
-# define SLICE_API /**/
#endif
namespace Slice
diff --git a/cpp/include/Slice/Preprocessor.h b/cpp/include/Slice/Preprocessor.h
index 7d26926189a..273c31f3d49 100644
--- a/cpp/include/Slice/Preprocessor.h
+++ b/cpp/include/Slice/Preprocessor.h
@@ -17,14 +17,12 @@
#include <IceUtil/Config.h>
-#ifdef _WIN32
+#ifndef SLICE_API
# ifdef SLICE_API_EXPORTS
-# define SLICE_API __declspec(dllexport)
+# define SLICE_API ICE_DECLSPEC_EXPORT
# else
-# define SLICE_API __declspec(dllimport)
+# define SLICE_API ICE_DECLSPEC_IMPORT
# endif
-#else
-# define SLICE_API /**/
#endif
namespace Slice
diff --git a/cpp/include/XMLTransform/XMLTransform.h b/cpp/include/XMLTransform/XMLTransform.h
index 4042c1a0496..8c79b291aa2 100644
--- a/cpp/include/XMLTransform/XMLTransform.h
+++ b/cpp/include/XMLTransform/XMLTransform.h
@@ -23,14 +23,12 @@
#include <map>
-#ifdef WIN32
+#ifndef XML_TRANSFORM_API
# ifdef XML_TRANSFORM_API_EXPORTS
-# define XML_TRANSFORM_API __declspec(dllexport)
+# define XML_TRANSFORM_API ICE_DECLSPEC_EXPORT
# else
-# define XML_TRANSFORM_API __declspec(dllimport)
+# define XML_TRANSFORM_API ICE_DECLSPEC_IMPORT
# endif
-#else
-# define XML_TRANSFORM_API /**/
#endif
namespace XMLTransform