diff options
| author | 2022-04-30 00:50:20 +0000 | |
|---|---|---|
| committer | 2022-06-11 02:08:30 +0000 | |
| commit | f55d6882c852bc3a87ed34657d024c2dfc8b4eb2 (patch) | |
| tree | f222fa80ce9d75e74614da8221be7310ea93218c /libs | |
| parent | 1519b984526ba70e1560d95a91134ec82068512d (diff) | |
libbinder: compile some Linux code conditionally
Binder.cpp and Parcel.cpp contain some Linux-specific code
that deals with scheduling and task priorities. This disables
those headers and methods on non-Linux OSes.
Bug: 224644083
Test: m
Change-Id: I5edf60a16ccb2d1abbc669f80b397238622112fe
Diffstat (limited to 'libs')
| -rw-r--r-- | libs/binder/Binder.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libs/binder/Binder.cpp b/libs/binder/Binder.cpp index 6a12e65fc0..e2db1a389c 100644 --- a/libs/binder/Binder.cpp +++ b/libs/binder/Binder.cpp @@ -32,9 +32,12 @@ #include <utils/misc.h> #include <inttypes.h> -#include <linux/sched.h> #include <stdio.h> +#ifdef __linux__ +#include <linux/sched.h> +#endif + #include "RpcState.h" namespace android { @@ -234,11 +237,13 @@ class BBinder::Extras { public: // unlocked objects - bool mRequestingSid = false; - bool mInheritRt = false; sp<IBinder> mExtension; +#ifdef __linux__ int mPolicy = SCHED_NORMAL; int mPriority = 0; +#endif + bool mRequestingSid = false; + bool mInheritRt = false; // for below objects Mutex mLock; @@ -407,6 +412,7 @@ sp<IBinder> BBinder::getExtension() { return e->mExtension; } +#ifdef __linux__ void BBinder::setMinSchedulerPolicy(int policy, int priority) { LOG_ALWAYS_FATAL_IF(mParceled, "setMinSchedulerPolicy() should not be called after a binder object " @@ -451,6 +457,7 @@ int BBinder::getMinSchedulerPriority() { if (e == nullptr) return 0; return e->mPriority; } +#endif // __linux__ bool BBinder::isInheritRt() { Extras* e = mExtras.load(std::memory_order_acquire); @@ -478,7 +485,12 @@ void BBinder::setInheritRt(bool inheritRt) { } pid_t BBinder::getDebugPid() { +#ifdef __linux__ return getpid(); +#else + // TODO: handle other OSes + return 0; +#endif // __linux__ } void BBinder::setExtension(const sp<IBinder>& extension) { |