build: prepend "NFD_" to various macro names to avoid conflicts

Change-Id: Icc370968e3d38fef80ece35a2aed56450f54b653
diff --git a/daemon/common/global.cpp b/daemon/common/global.cpp
index a0fd88f..c54f043 100644
--- a/daemon/common/global.cpp
+++ b/daemon/common/global.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019,  Regents of the University of California,
+ * Copyright (c) 2014-2021,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -50,7 +50,7 @@
   return *g_scheduler;
 }
 
-#ifdef WITH_TESTS
+#ifdef NFD_WITH_TESTS
 void
 resetGlobalIoService()
 {
diff --git a/daemon/common/global.hpp b/daemon/common/global.hpp
index 1e1fce8..ccc5160 100644
--- a/daemon/common/global.hpp
+++ b/daemon/common/global.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019  Regents of the University of California,
+ * Copyright (c) 2014-2021  Regents of the University of California,
  *                          Arizona Board of Regents,
  *                          Colorado State University,
  *                          University Pierre & Marie Curie, Sorbonne University,
@@ -61,7 +61,7 @@
 void
 runOnRibIoService(const std::function<void()>& f);
 
-#ifdef WITH_TESTS
+#ifdef NFD_WITH_TESTS
 /** \brief Destroy the global io_service instance.
  *
  *  It will be recreated at the next invocation of getGlobalIoService().
diff --git a/daemon/common/privilege-helper.cpp b/daemon/common/privilege-helper.cpp
index 293eb6f..eb8e608 100644
--- a/daemon/common/privilege-helper.cpp
+++ b/daemon/common/privilege-helper.cpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2020,  Regents of the University of California,
+ * Copyright (c) 2014-2021,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -33,18 +33,18 @@
 
 NFD_LOG_INIT(PrivilegeHelper);
 
-#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
+#ifdef NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
 uid_t PrivilegeHelper::s_normalUid = ::geteuid();
 gid_t PrivilegeHelper::s_normalGid = ::getegid();
 
 uid_t PrivilegeHelper::s_privilegedUid = ::geteuid();
 gid_t PrivilegeHelper::s_privilegedGid = ::getegid();
-#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
+#endif // NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
 
 void
 PrivilegeHelper::initialize(const std::string& userName, const std::string& groupName)
 {
-#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
+#ifdef NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
   static const size_t MAX_GROUP_BUFFER_SIZE = 16384; // 16 KiB
   static const size_t MAX_PASSWD_BUFFER_SIZE = 16384;
 
@@ -111,13 +111,13 @@
   if (!userName.empty() || !groupName.empty()) {
     throw Error("Dropping and raising privileges is not supported on this platform");
   }
-#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
+#endif // NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
 }
 
 void
 PrivilegeHelper::drop()
 {
-#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
+#ifdef NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
   if (::geteuid() == s_normalUid && ::getegid() == s_normalGid)
     return;
 
@@ -132,13 +132,13 @@
   NFD_LOG_INFO("dropped to effective uid=" << ::geteuid() << " gid=" << ::getegid());
 #else
   NFD_LOG_WARN("Dropping privileges is not supported on this platform");
-#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
+#endif // NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
 }
 
 void
 PrivilegeHelper::raise()
 {
-#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
+#ifdef NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
   if (::geteuid() == s_privilegedUid && ::getegid() == s_privilegedGid)
     return;
 
@@ -153,7 +153,7 @@
   NFD_LOG_INFO("elevated to effective uid=" << ::geteuid() << " gid=" << ::getegid());
 #else
   NFD_LOG_WARN("Elevating privileges is not supported on this platform");
-#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
+#endif // NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
 }
 
 } // namespace nfd
diff --git a/daemon/common/privilege-helper.hpp b/daemon/common/privilege-helper.hpp
index 52daf84..f0eb3bd 100644
--- a/daemon/common/privilege-helper.hpp
+++ b/daemon/common/privilege-helper.hpp
@@ -1,6 +1,6 @@
 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
 /*
- * Copyright (c) 2014-2019,  Regents of the University of California,
+ * Copyright (c) 2014-2021,  Regents of the University of California,
  *                           Arizona Board of Regents,
  *                           Colorado State University,
  *                           University Pierre & Marie Curie, Sorbonne University,
@@ -71,7 +71,7 @@
   {
     raise();
     try {
-      f();
+      std::forward<F>(f)();
     }
     catch (...) {
       drop();
@@ -80,18 +80,18 @@
     drop();
   }
 
-PUBLIC_WITH_TESTS_ELSE_PRIVATE:
+NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
   static void
   raise();
 
-PUBLIC_WITH_TESTS_ELSE_PRIVATE:
-#ifdef HAVE_PRIVILEGE_DROP_AND_ELEVATE
+NFD_PUBLIC_WITH_TESTS_ELSE_PRIVATE:
+#ifdef NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
   static uid_t s_normalUid;
   static gid_t s_normalGid;
 
   static uid_t s_privilegedUid;
   static gid_t s_privilegedGid;
-#endif // HAVE_PRIVILEGE_DROP_AND_ELEVATE
+#endif // NFD_HAVE_PRIVILEGE_DROP_AND_ELEVATE
 };
 
 } // namespace nfd