Add some more OpenSSL 1.1 APIs for folly/portability/
[folly.git] / folly / portability / Stdlib.h
index c3bf734075e0401c2454da7215b2da3c5645a8b2..1124273b607215902155775d8197ba5e29886c5a 100644 (file)
 
 #include <cstdlib>
 
+#if defined(__APPLE__)
+#if __has_include(<crt_externs.h>)
+#include <crt_externs.h>
+#endif
+#endif
+
 extern "C" {
 #ifdef _WIN32
 // These are technically supposed to be defined linux/limits.h and
@@ -35,6 +41,14 @@ char* realpath(const char* path, char* resolved_path);
 int setenv(const char* name, const char* value, int overwrite);
 int unsetenv(const char* name);
 #elif defined(__APPLE__)
-extern char** environ;
+// environ doesn't work well with dylibs, so use _NSGetEnviron instead.
+#if !__has_include(<crt_externs.h>)
+char*** _NSGetEnviron(void);
+#endif
+#define environ (*_NSGetEnviron())
+#endif
+
+#if !__linux__ && !FOLLY_MOBILE
+int clearenv();
 #endif
 }