summaryrefslogtreecommitdiffstats
path: root/libcutils
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2012-05-08 15:05:42 -0700
committerJeff Brown <jeffbrown@google.com>2012-05-08 15:07:32 -0700
commitbff8f3fa9848e52e3f3fe773796a03a80133992a (patch)
treeaeb980d4dbf1e33b6e0d60eeb9c468ec78c91aa9 /libcutils
parent796a85e24511b7926a1fccb7cc695900d3ce0922 (diff)
downloadsystem_core-bff8f3fa9848e52e3f3fe773796a03a80133992a.zip
system_core-bff8f3fa9848e52e3f3fe773796a03a80133992a.tar.gz
system_core-bff8f3fa9848e52e3f3fe773796a03a80133992a.tar.bz2
Add stubs for host builds.
Bug: 4466013 Change-Id: I5633c841e71a48357bb04cd7ccc02550c17bde22
Diffstat (limited to 'libcutils')
-rw-r--r--libcutils/sched_policy.c47
1 files changed, 30 insertions, 17 deletions
diff --git a/libcutils/sched_policy.c b/libcutils/sched_policy.c
index 20771c0..79c6994 100644
--- a/libcutils/sched_policy.c
+++ b/libcutils/sched_policy.c
@@ -16,24 +16,31 @@
** limitations under the License.
*/
+#define LOG_TAG "SchedPolicy"
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
+#include <cutils/sched_policy.h>
+#include <cutils/log.h>
-#define LOG_TAG "SchedPolicy"
-#include "cutils/log.h"
+/* Re-map SP_DEFAULT to the system default policy, and leave other values unchanged.
+ * Call this any place a SchedPolicy is used as an input parameter.
+ * Returns the possibly re-mapped policy.
+ */
+static inline SchedPolicy _policy(SchedPolicy p)
+{
+ return p == SP_DEFAULT ? SP_SYSTEM_DEFAULT : p;
+}
-#ifdef HAVE_SCHED_H
-#ifdef HAVE_PTHREADS
+#if defined(HAVE_ANDROID_OS) && defined(HAVE_SCHED_H) && defined(HAVE_PTHREADS)
#include <sched.h>
#include <pthread.h>
-#include <cutils/sched_policy.h>
-
#ifndef SCHED_NORMAL
#define SCHED_NORMAL 0
#endif
@@ -274,15 +281,6 @@ int get_sched_policy(int tid, SchedPolicy *policy)
return 0;
}
-/* Re-map SP_DEFAULT to the system default policy, and leave other values unchanged.
- * Call this any place a SchedPolicy is used as an input parameter.
- * Returns the possibly re-mapped policy.
- */
-static inline SchedPolicy _policy(SchedPolicy p)
-{
- return p == SP_DEFAULT ? SP_SYSTEM_DEFAULT : p;
-}
-
int set_sched_policy(int tid, SchedPolicy policy)
{
#ifdef HAVE_GETTID
@@ -356,6 +354,23 @@ int set_sched_policy(int tid, SchedPolicy policy)
return 0;
}
+#else
+
+/* Stubs for non-Android targets. */
+
+int set_sched_policy(int tid, SchedPolicy policy)
+{
+ return 0;
+}
+
+int get_sched_policy(int tid, SchedPolicy *policy)
+{
+ *policy = SP_SYSTEM_DEFAULT;
+ return 0;
+}
+
+#endif
+
const char *get_sched_policy_name(SchedPolicy policy)
{
policy = _policy(policy);
@@ -372,5 +387,3 @@ const char *get_sched_policy_name(SchedPolicy policy)
return "error";
}
-#endif /* HAVE_PTHREADS */
-#endif /* HAVE_SCHED_H */