mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-06-04 10:18:22 +00:00
Upstream system_properties
This commit is contained in:
parent
30286f0ea5
commit
e395c9442f
@ -14,8 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ERRNO_RESTORER_H
|
#pragma once
|
||||||
#define ERRNO_RESTORER_H
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
@ -37,7 +36,5 @@ class ErrnoRestorer {
|
|||||||
private:
|
private:
|
||||||
int saved_errno_;
|
int saved_errno_;
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer);
|
BIONIC_DISALLOW_COPY_AND_ASSIGN(ErrnoRestorer);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ERRNO_RESTORER_H
|
|
||||||
|
@ -25,8 +25,8 @@
|
|||||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#ifndef _BIONIC_LOCK_H
|
|
||||||
#define _BIONIC_LOCK_H
|
#pragma once
|
||||||
|
|
||||||
#include <stdatomic.h>
|
#include <stdatomic.h>
|
||||||
#include "private/bionic_futex.h"
|
#include "private/bionic_futex.h"
|
||||||
@ -70,25 +70,24 @@ class Lock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void unlock() {
|
void unlock() {
|
||||||
|
bool shared = process_shared; /* cache to local variable */
|
||||||
if (atomic_exchange_explicit(&state, Unlocked, memory_order_release) == LockedWithWaiter) {
|
if (atomic_exchange_explicit(&state, Unlocked, memory_order_release) == LockedWithWaiter) {
|
||||||
__futex_wake_ex(&state, process_shared, 1);
|
__futex_wake_ex(&state, shared, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class LockGuard {
|
class LockGuard {
|
||||||
public:
|
public:
|
||||||
LockGuard(Lock& lock) : lock_(lock) {
|
explicit LockGuard(Lock& lock) : lock_(lock) {
|
||||||
lock_.lock();
|
lock_.lock();
|
||||||
}
|
}
|
||||||
~LockGuard() {
|
~LockGuard() {
|
||||||
lock_.unlock();
|
lock_.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(LockGuard);
|
BIONIC_DISALLOW_COPY_AND_ASSIGN(LockGuard);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Lock& lock_;
|
Lock& lock_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _BIONIC_LOCK_H
|
|
||||||
|
@ -14,31 +14,17 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _BIONIC_MACROS_H_
|
#pragma once
|
||||||
#define _BIONIC_MACROS_H_
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
// Frameworks OpenGL code currently leaks this header and allows
|
#define BIONIC_DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
||||||
// collisions with other declarations, e.g., from libnativehelper.
|
TypeName(const TypeName&) = delete; \
|
||||||
// TODO: Remove once cleaned up. b/18334516
|
|
||||||
#if !defined(DISALLOW_COPY_AND_ASSIGN)
|
|
||||||
// DISALLOW_COPY_AND_ASSIGN disallows the copy and operator= functions.
|
|
||||||
// It goes in the private: declarations in a class.
|
|
||||||
#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
|
|
||||||
TypeName(const TypeName&) = delete; \
|
|
||||||
void operator=(const TypeName&) = delete
|
void operator=(const TypeName&) = delete
|
||||||
#endif // !defined(DISALLOW_COPY_AND_ASSIGN)
|
|
||||||
|
|
||||||
// A macro to disallow all the implicit constructors, namely the
|
#define BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
||||||
// default constructor, copy constructor and operator= functions.
|
TypeName() = delete; \
|
||||||
//
|
BIONIC_DISALLOW_COPY_AND_ASSIGN(TypeName)
|
||||||
// This should be used in the private: declarations for a class
|
|
||||||
// that wants to prevent anyone from instantiating it. This is
|
|
||||||
// especially useful for classes containing only static methods.
|
|
||||||
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \
|
|
||||||
TypeName() = delete; \
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(TypeName)
|
|
||||||
|
|
||||||
#define BIONIC_ROUND_UP_POWER_OF_2(value) \
|
#define BIONIC_ROUND_UP_POWER_OF_2(value) \
|
||||||
((sizeof(value) == 8) \
|
((sizeof(value) == 8) \
|
||||||
@ -101,5 +87,3 @@ char (&ArraySizeHelper(T (&array)[N]))[N]; // NOLINT(readability/casting)
|
|||||||
#else
|
#else
|
||||||
#define __BIONIC_FALLTHROUGH
|
#define __BIONIC_FALLTHROUGH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // _BIONIC_MACROS_H_
|
|
||||||
|
@ -42,7 +42,7 @@ class ContextNode {
|
|||||||
Unmap();
|
Unmap();
|
||||||
}
|
}
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(ContextNode);
|
BIONIC_DISALLOW_COPY_AND_ASSIGN(ContextNode);
|
||||||
|
|
||||||
bool Open(bool access_rw, bool* fsetxattr_failed);
|
bool Open(bool access_rw, bool* fsetxattr_failed);
|
||||||
bool CheckAccessAndOpen();
|
bool CheckAccessAndOpen();
|
||||||
|
@ -86,7 +86,7 @@ struct prop_bt {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_COPY_AND_ASSIGN(prop_bt);
|
BIONIC_DISALLOW_COPY_AND_ASSIGN(prop_bt);
|
||||||
};
|
};
|
||||||
|
|
||||||
class prop_area {
|
class prop_area {
|
||||||
@ -138,10 +138,10 @@ class prop_area {
|
|||||||
|
|
||||||
prop_bt* root_node();
|
prop_bt* root_node();
|
||||||
|
|
||||||
prop_bt* find_prop_bt(prop_bt* const bt, const char* name, uint32_t namelen, bool alloc_if_needed);
|
|
||||||
|
|
||||||
/* resetprop: Traverse through the trie and find the node */
|
/* resetprop: Traverse through the trie and find the node */
|
||||||
prop_bt *find_prop_bt(prop_bt *const trie, const char *name, bool alloc_if_needed);
|
prop_bt *find_prop_bt(prop_bt *const bt, const char* name, bool alloc_if_needed);
|
||||||
|
|
||||||
|
prop_bt* find_prop_bt(prop_bt* const bt, const char* name, uint32_t namelen, bool alloc_if_needed);
|
||||||
|
|
||||||
const prop_info* find_property(prop_bt* const trie, const char* name, uint32_t namelen,
|
const prop_info* find_property(prop_bt* const trie, const char* name, uint32_t namelen,
|
||||||
const char* value, uint32_t valuelen, bool alloc_if_needed);
|
const char* value, uint32_t valuelen, bool alloc_if_needed);
|
||||||
@ -163,5 +163,5 @@ class prop_area {
|
|||||||
uint32_t reserved_[28];
|
uint32_t reserved_[28];
|
||||||
char data_[0];
|
char data_[0];
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(prop_area);
|
BIONIC_DISALLOW_COPY_AND_ASSIGN(prop_area);
|
||||||
};
|
};
|
||||||
|
@ -84,7 +84,7 @@ struct prop_info {
|
|||||||
prop_info(const char* name, uint32_t namelen, uint32_t long_offset);
|
prop_info(const char* name, uint32_t namelen, uint32_t long_offset);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_IMPLICIT_CONSTRUCTORS(prop_info);
|
BIONIC_DISALLOW_IMPLICIT_CONSTRUCTORS(prop_info);
|
||||||
};
|
};
|
||||||
|
|
||||||
static_assert(sizeof(prop_info) == 96, "sizeof struct prop_info must be 96 bytes");
|
static_assert(sizeof(prop_info) == 96, "sizeof struct prop_info must be 96 bytes");
|
||||||
|
@ -52,7 +52,7 @@ class SystemProperties {
|
|||||||
explicit SystemProperties(bool initialized) : initialized_(initialized) {
|
explicit SystemProperties(bool initialized) : initialized_(initialized) {
|
||||||
}
|
}
|
||||||
|
|
||||||
DISALLOW_COPY_AND_ASSIGN(SystemProperties);
|
BIONIC_DISALLOW_COPY_AND_ASSIGN(SystemProperties);
|
||||||
|
|
||||||
bool Init(const char* filename);
|
bool Init(const char* filename);
|
||||||
bool AreaInit(const char* filename, bool* fsetxattr_failed);
|
bool AreaInit(const char* filename, bool* fsetxattr_failed);
|
||||||
|
@ -320,7 +320,6 @@ prop_bt *prop_area::find_prop_bt(prop_bt *const trie, const char *name, bool all
|
|||||||
const prop_info* prop_area::find_property(prop_bt* const trie, const char* name, uint32_t namelen,
|
const prop_info* prop_area::find_property(prop_bt* const trie, const char* name, uint32_t namelen,
|
||||||
const char* value, uint32_t valuelen,
|
const char* value, uint32_t valuelen,
|
||||||
bool alloc_if_needed) {
|
bool alloc_if_needed) {
|
||||||
const char* remaining_name = name;
|
|
||||||
prop_bt* current = find_prop_bt(trie, name, alloc_if_needed);
|
prop_bt* current = find_prop_bt(trie, name, alloc_if_needed);
|
||||||
if (!current)
|
if (!current)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user