Fix non-Android build targets

am: eca87cb9ca

Change-Id: I4b0305619c91041bf7b844201f23437df06864b9
This commit is contained in:
Suren Baghdasaryan 2019-02-03 20:18:21 -08:00 committed by android-build-merger
commit b5f684bc91
3 changed files with 41 additions and 1 deletions

View file

@ -36,6 +36,8 @@ static inline SchedPolicy _policy(SchedPolicy p) {
return p == SP_DEFAULT ? SP_SYSTEM_DEFAULT : p;
}
#if defined(__ANDROID__)
int set_cpuset_policy(int tid, SchedPolicy policy) {
if (tid == 0) {
tid = GetThreadId();
@ -195,6 +197,21 @@ int get_sched_policy(int tid, SchedPolicy* policy) {
return 0;
}
#else
/* Stubs for non-Android targets. */
int set_sched_policy(int, SchedPolicy) {
return 0;
}
int get_sched_policy(int, SchedPolicy* policy) {
*policy = SP_SYSTEM_DEFAULT;
return 0;
}
#endif
const char* get_sched_policy_name(SchedPolicy policy) {
policy = _policy(policy);
static const char* const kSchedPolicyNames[] = {

View file

@ -18,7 +18,6 @@
#define LOG_TAG "libprocessgroup"
#include <fcntl.h>
#include <sys/prctl.h>
#include <task_profiles.h>
#include <string>
@ -32,6 +31,11 @@
#include <json/reader.h>
#include <json/value.h>
// To avoid issues in sdk_mac build
#if defined(__ANDROID__)
#include <sys/prctl.h>
#endif
using android::base::GetThreadId;
using android::base::StringPrintf;
using android::base::unique_fd;
@ -69,6 +73,9 @@ bool SetClampsAction::ExecuteForTask(int) const {
return false;
}
// To avoid issues in sdk_mac build
#if defined(__ANDROID__)
bool SetTimerSlackAction::IsTimerSlackSupported(int tid) {
auto file = StringPrintf("/proc/%d/timerslack_ns", tid);
@ -97,6 +104,8 @@ bool SetTimerSlackAction::ExecuteForTask(int tid) const {
return true;
}
#endif
bool SetAttributeAction::ExecuteForProcess(uid_t, pid_t pid) const {
return ExecuteForTask(pid);
}

View file

@ -63,6 +63,9 @@ class SetClampsAction : public ProfileAction {
int clamp_;
};
// To avoid issues in sdk_mac build
#if defined(__ANDROID__)
class SetTimerSlackAction : public ProfileAction {
public:
SetTimerSlackAction(unsigned long slack) noexcept : slack_(slack) {}
@ -75,6 +78,17 @@ class SetTimerSlackAction : public ProfileAction {
static bool IsTimerSlackSupported(int tid);
};
#else
class SetTimerSlackAction : public ProfileAction {
public:
SetTimerSlackAction(unsigned long) noexcept {}
virtual bool ExecuteForTask(int) const { return true; }
};
#endif
// Set attribute profile element
class SetAttributeAction : public ProfileAction {
public: