Namespace portability symbols better in Singleton.cpp
authorYedidya Feldblum <yfeldblum@fb.com>
Sat, 23 Dec 2017 03:02:54 +0000 (19:02 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Sat, 23 Dec 2017 03:05:45 +0000 (19:05 -0800)
Summary: [Folly] Namespace portability symbols better in `Singleton.cpp`.

Reviewed By: Orvid

Differential Revision: D6631290

fbshipit-source-id: eb802ace6a9bf704e011eb44710922c997a9cd8e

folly/Singleton.cpp

index 7114d53de9df1ca16c630913636a4dc6436e1ddf..81c103a6de64de7a67facbf8cbe57fecdb59fc62 100644 (file)
 #include <folly/ScopeGuard.h>
 
 #if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__)
 #include <folly/ScopeGuard.h>
 
 #if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__)
-static void hs_init_weak(int* argc, char** argv[])
-    __attribute__((__weakref__("hs_init")));
+#define FOLLY_SINGLETON_HAVE_DLSYM 1
 #endif
 
 namespace folly {
 
 #endif
 
 namespace folly {
 
+#if FOLLY_SINGLETON_HAVE_DLSYM
+namespace detail {
+static void singleton_hs_init_weak(int* argc, char** argv[])
+    __attribute__((__weakref__("hs_init")));
+} // namespace detail
+#endif
+
 SingletonVault::Type SingletonVault::defaultVaultType() {
 SingletonVault::Type SingletonVault::defaultVaultType() {
-#if !defined(_WIN32) && !defined(__APPLE__) && !defined(__ANDROID__)
+#if FOLLY_SINGLETON_HAVE_DLSYM
   bool isPython = dlsym(RTLD_DEFAULT, "Py_Main");
   bool isPython = dlsym(RTLD_DEFAULT, "Py_Main");
-  bool isHaskel = &::hs_init_weak || dlsym(RTLD_DEFAULT, "hs_init");
+  bool isHaskel =
+      detail::singleton_hs_init_weak || dlsym(RTLD_DEFAULT, "hs_init");
   bool isJVM = dlsym(RTLD_DEFAULT, "JNI_GetCreatedJavaVMs");
   bool isD = dlsym(RTLD_DEFAULT, "_d_run_main");
 
   bool isJVM = dlsym(RTLD_DEFAULT, "JNI_GetCreatedJavaVMs");
   bool isD = dlsym(RTLD_DEFAULT, "_d_run_main");