Remove some globals from system_properties
pa_size should be static to prop_area, so make it so.
__system_property_area__ was reused for various purposes, but
realistically is a deprecated symbol and this finally separates us
from it.
Bug: 36001741
Test: boot bullhead, system property unit tests
Change-Id: I39663cc3b613093fa4c728b21d8ba58754f8e105
diff --git a/libc/system_properties/contexts_pre_split.h b/libc/system_properties/contexts_pre_split.h
index 7e83a37..bbc8529 100644
--- a/libc/system_properties/contexts_pre_split.h
+++ b/libc/system_properties/contexts_pre_split.h
@@ -29,12 +29,10 @@
#ifndef SYSTEM_PROPERTIES_CONTEXTS_PRE_SPLIT_H
#define SYSTEM_PROPERTIES_CONTEXTS_PRE_SPLIT_H
-#include <sys/mman.h>
-
#include "contexts.h"
#include "prop_area.h"
#include "prop_info.h"
-#include "system_property_globals.h"
+#include "property_filename.h"
class ContextsPreSplit : public Contexts {
public:
@@ -43,16 +41,20 @@
// We'll never initialize this legacy option as writable, so don't even check the arg.
virtual bool Initialize(bool) override {
- __system_property_area__ = prop_area::map_prop_area(property_filename);
- return __system_property_area__ != nullptr;
+ pre_split_prop_area_ = prop_area::map_prop_area(property_filename);
+ return pre_split_prop_area_ != nullptr;
}
virtual prop_area* GetPropAreaForName(const char*) override {
- return __system_property_area__;
+ return pre_split_prop_area_;
+ }
+
+ virtual prop_area* GetSerialPropArea() override {
+ return pre_split_prop_area_;
}
virtual void ForEach(void (*propfn)(const prop_info* pi, void* cookie), void* cookie) override {
- __system_property_area__->foreach (propfn, cookie);
+ pre_split_prop_area_->foreach (propfn, cookie);
}
// This is a no-op for pre-split properties as there is only one property file and it is
@@ -61,11 +63,11 @@
}
virtual void FreeAndUnmap() override {
- if (__system_property_area__ != nullptr) {
- munmap(__system_property_area__, pa_size);
- __system_property_area__ = nullptr;
- }
+ prop_area::unmap_prop_area(&pre_split_prop_area_);
}
+
+ private:
+ prop_area* pre_split_prop_area_ = nullptr;
};
#endif