src: only define ssize_t on windows if undefined
authorTimothy J Fontaine <tjfontaine@gmail.com>
Tue, 28 Jan 2014 22:11:32 +0000 (14:11 -0800)
committerTimothy J Fontaine <tjfontaine@gmail.com>
Tue, 28 Jan 2014 23:07:40 +0000 (15:07 -0800)
This matches how libuv handles the definition of ssize_t, by
typedef'ing intptr_t to ssize_t.

However, in the future we will use portable types from stddef.h

src/node.h

index 677a24f..7a08dc9 100644 (file)
 #include "v8.h"  // NOLINT(build/include_order)
 #include "node_version.h"  // NODE_MODULE_VERSION
 
-#ifdef _WIN32
-# include <BaseTsd.h>
-typedef SSIZE_T ssize_t;
-typedef SIZE_T size_t;
-#else  // !_WIN32
-# include <sys/types.h>  // size_t, ssize_t
-#endif  // _WIN32
-
 // Forward-declare these functions now to stop MSVS from becoming
 // terminally confused when it's done in node_internals.h
 namespace node {
@@ -192,6 +184,17 @@ void DisplayExceptionLine(v8::Handle<v8::Message> message);
 NODE_EXTERN v8::Local<v8::Value> Encode(const void *buf, size_t len,
                                         enum encoding encoding = BINARY);
 
+#ifdef _WIN32
+// TODO(tjfontaine) consider changing the usage of ssize_t to ptrdiff_t
+#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
+typedef intptr_t ssize_t;
+# define _SSIZE_T_
+# define _SSIZE_T_DEFINED
+#endif
+#else  // !_WIN32
+# include <sys/types.h>  // size_t, ssize_t
+#endif  // _WIN32
+
 // Returns -1 if the handle was not valid for decoding
 NODE_EXTERN ssize_t DecodeBytes(v8::Handle<v8::Value>,
                                 enum encoding encoding = BINARY);