From 98f4bfaf728390a3ee9f2e69d3d7a07608d6c38a Mon Sep 17 00:00:00 2001 From: Elizabeth Smith Date: Tue, 6 May 2014 11:21:11 -0700 Subject: [PATCH] Adding some msvc specific defines Summary: msvc puts ssize_t in a stupidly odd place and names it weirdly too this also takes care of snprintf missing (the semantics are slightly off in the msvc version regarding the return value, but usage in folly is limited and does NOT do the double snprintf call madness so this is safe) funcsig and pretty function give you roughtly the same thing in compiler specific implementations strerror_s is msvc's thread save strerror @override-unit-failures Test Plan: fbmake runtests Reviewed By: delong.j@fb.com FB internal diff: D1291542 --- folly/Portability.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/folly/Portability.h b/folly/Portability.h index a29862c3..4d623eb4 100644 --- a/folly/Portability.h +++ b/folly/Portability.h @@ -188,4 +188,24 @@ struct MaxAlign { char c; } __attribute__((aligned)); #endif #endif // __cplusplus +// MSVC specific defines +// mainly for posix compat +#ifdef _MSC_VER + +// this definition is in a really silly place with a silly name +// and ifdefing it every time we want it is painful +#include +typedef SSIZE_T ssize_t; + +// sprintf semantics are not exactly identical +// but current usage is not a problem +# define snprintf _snprintf + +// semantics here are identical +# define strerror_r(errno,buf,len) strerror_s(buf,len,errno) + +// compiler specific to compiler specific +# define __PRETTY_FUNCTION__ __FUNCSIG__ +#endif + #endif // FOLLY_PORTABILITY_H_ -- 2.34.1