Merge "init: remove last init.cpp global"
diff --git a/init/builtins.cpp b/init/builtins.cpp
index f188ef9..fca9809 100644
--- a/init/builtins.cpp
+++ b/init/builtins.cpp
@@ -89,6 +89,8 @@
namespace android {
namespace init {
+std::vector<std::string> late_import_paths;
+
static constexpr std::chrono::nanoseconds kCommandRetryTimeout = 5s;
static Result<void> reboot_into_recovery(const std::vector<std::string>& options) {
diff --git a/init/builtins.h b/init/builtins.h
index 5db0d1c..7bbf6aa 100644
--- a/init/builtins.h
+++ b/init/builtins.h
@@ -40,6 +40,8 @@
const Map& map() const override;
};
+extern std::vector<std::string> late_import_paths;
+
} // namespace init
} // namespace android
diff --git a/init/devices.cpp b/init/devices.cpp
index 5e760d0..e8e6cd7 100644
--- a/init/devices.cpp
+++ b/init/devices.cpp
@@ -39,10 +39,6 @@
#include "selabel.h"
#include "util.h"
-#ifdef _INIT_INIT_H
-#error "Do not include init.h in files used by ueventd; it will expose init's globals"
-#endif
-
using namespace std::chrono_literals;
using android::base::Basename;
diff --git a/init/init.cpp b/init/init.cpp
index 2b94825..b6911e5 100644
--- a/init/init.cpp
+++ b/init/init.cpp
@@ -28,9 +28,11 @@
#include <sys/types.h>
#include <unistd.h>
+#include <functional>
#include <map>
#include <memory>
#include <optional>
+#include <vector>
#include <android-base/chrono_utils.h>
#include <android-base/file.h>
@@ -54,6 +56,7 @@
#include "action_parser.h"
#include "boringssl_self_test.h"
+#include "builtins.h"
#include "epoll.h"
#include "first_stage_init.h"
#include "first_stage_mount.h"
@@ -100,8 +103,6 @@
static bool do_shutdown = false;
static bool load_debug_prop = false;
-std::vector<std::string> late_import_paths;
-
static std::vector<Subcontext>* subcontexts;
void DumpState() {
diff --git a/init/init.h b/init/init.h
index 6ada6ab..cfc28f1 100644
--- a/init/init.h
+++ b/init/init.h
@@ -14,14 +14,11 @@
* limitations under the License.
*/
-#ifndef _INIT_INIT_H
-#define _INIT_INIT_H
+#pragma once
#include <sys/types.h>
-#include <functional>
#include <string>
-#include <vector>
#include "action.h"
#include "action_manager.h"
@@ -31,11 +28,6 @@
namespace android {
namespace init {
-// Note: These globals are *only* valid in init, so they should not be used in ueventd
-// or any files that may be included in ueventd, such as devices.cpp and util.cpp.
-// TODO: Have an Init class and remove all globals.
-extern std::vector<std::string> late_import_paths;
-
Parser CreateParser(ActionManager& action_manager, ServiceList& service_list);
Parser CreateServiceOnlyParser(ServiceList& service_list);
@@ -53,5 +45,3 @@
} // namespace init
} // namespace android
-
-#endif /* _INIT_INIT_H */
diff --git a/init/util.cpp b/init/util.cpp
index 14acaa2..2b34242 100644
--- a/init/util.cpp
+++ b/init/util.cpp
@@ -46,10 +46,6 @@
#include "host_init_stubs.h"
#endif
-#ifdef _INIT_INIT_H
-#error "Do not include init.h in files used by ueventd; it will expose init's globals"
-#endif
-
using android::base::boot_clock;
using namespace std::literals::string_literals;