-/* Make sure ssize_t is defined (a signed type the same size as size_t) */
-/* HAVE_SSIZE_T should be defined for compiliers that already have it */
-#ifdef __MINGW32__
- #if defined(_SSIZE_T_) && !defined(HAVE_SSIZE_T)
- #define HAVE_SSIZE_T
- #endif
-#endif
-#if defined(__PALMOS__) && !defined(HAVE_SSIZE_T)
- #define HAVE_SSIZE_T
-#endif
-#if wxCHECK_WATCOM_VERSION(1,4)
- #define HAVE_SSIZE_T
-#endif
-#ifndef HAVE_SSIZE_T
- #if SIZEOF_SIZE_T == 4
- typedef wxInt32 ssize_t;
- #elif SIZEOF_SIZE_T == 8
- typedef wxInt64 ssize_t;
- #else
- #error "error defining ssize_t, size_t is not 4 or 8 bytes"
- #endif
+/* Make sure ssize_t is defined (a signed type the same size as size_t). */
+/* (HAVE_SSIZE_T is not already defined by configure) */
+#ifndef HAVE_SSIZE_T
+#ifdef __MINGW32__
+ #if defined(_SSIZE_T_) || defined(_SSIZE_T_DEFINED)
+ #define HAVE_SSIZE_T
+ #endif
+#elif wxCHECK_WATCOM_VERSION(1,4)
+ #define HAVE_SSIZE_T
+#endif
+#endif /* !HAVE_SSIZE_T */
+
+/* If we really don't have ssize_t, provide our own version. */
+#ifdef HAVE_SSIZE_T
+ #ifdef __UNIX__
+ #include <sys/types.h>
+ #endif
+#else /* !HAVE_SSIZE_T */
+ #if SIZEOF_SIZE_T == 4
+ typedef wxInt32 ssize_t;
+ #elif SIZEOF_SIZE_T == 8
+ typedef wxInt64 ssize_t;
+ #else
+ #error "error defining ssize_t, size_t is not 4 or 8 bytes"
+ #endif
+
+ /* prevent ssize_t redefinitions in other libraries */
+ #define HAVE_SSIZE_T
+#endif
+
+/*
+ We can't rely on Windows _W64 being defined as windows.h may not be
+ included so define our own equivalent: this should be used with types
+ like WXLPARAM or WXWPARAM which are 64 bit under Win64 to avoid warnings
+ each time we cast it to a pointer or a handle (which results in hundreds
+ of warnings as Win32 API often passes pointers in them)
+ */
+#if wxCHECK_VISUALC_VERSION(7)
+ #define wxW64 __w64
+#else
+ #define wxW64
+#endif
+
+/*
+ Define signed and unsigned integral types big enough to contain all of long,
+ size_t and void *.
+ */
+#if SIZEOF_LONG >= SIZEOF_VOID_P
+ /*
+ Normal case when long is the largest integral type.
+ */
+ typedef long wxIntPtr;
+ typedef unsigned long wxUIntPtr;
+#elif SIZEOF_SIZE_T >= SIZEOF_VOID_P
+ /*
+ Win64 case: size_t is the only integral type big enough for "void *".
+
+ Notice that we must use __w64 to avoid warnings about casting pointers
+ to wxIntPtr (which we do often as this is what it is defined for) in 32
+ bit build with MSVC.
+ */
+ typedef wxW64 ssize_t wxIntPtr;
+ typedef size_t wxUIntPtr;
+#else
+ /*
+ This should never happen for the current architectures but if you're
+ using one where it does, please contact wx-dev@lists.wxwidgets.org.
+ */
+ #error "Pointers can't be stored inside integer types."
+#endif
+
+#ifdef __cplusplus
+/* And also define a couple of simple functions to cast pointer to/from it. */
+inline wxUIntPtr wxPtrToUInt(const void *p)
+{
+ /*
+ VC++ 7.1 gives warnings about casts such as below even when they're
+ explicit with /Wp64 option, suppress them as we really know what we're
+ doing here. Same thing with icc with -Wall.
+ */
+#ifdef __VISUALC__
+ #if __VISUALC__ >= 1200
+ #pragma warning(push)
+ #endif
+ /* pointer truncation from '' to '' */
+ #pragma warning(disable: 4311)
+#elif defined(__INTELC__)
+ #pragma warning(push)
+ /* conversion from pointer to same-sized integral type */
+ #pragma warning(disable: 1684)
+#endif
+
+ return wx_reinterpret_cast(wxUIntPtr, p);
+
+#if (defined(__VISUALC__) && __VISUALC__ >= 1200) || defined(__INTELC__)
+ #pragma warning(pop)
+#endif
+}
+
+inline void *wxUIntToPtr(wxUIntPtr p)
+{
+#ifdef __VISUALC__
+ #if __VISUALC__ >= 1200
+ #pragma warning(push)
+ #endif
+ /* conversion to type of greater size */
+ #pragma warning(disable: 4312)
+#elif defined(__INTELC__)
+ #pragma warning(push)
+ /* invalid type conversion: "wxUIntPtr={unsigned long}" to "void *" */
+ #pragma warning(disable: 171)
+#endif
+
+ return wx_reinterpret_cast(void *, p);
+
+#if (defined(__VISUALC__) && __VISUALC__ >= 1200) || defined(__INTELC__)
+ #pragma warning(pop)