summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Brown2012-05-08 17:05:42 -0500
committerJeff Brown2012-05-08 17:07:32 -0500
commitbff8f3fa9848e52e3f3fe773796a03a80133992a (patch)
treeaeb980d4dbf1e33b6e0d60eeb9c468ec78c91aa9 /libcutils/sched_policy.c
parent796a85e24511b7926a1fccb7cc695900d3ce0922 (diff)
downloadplatform-system-core-bff8f3fa9848e52e3f3fe773796a03a80133992a.tar.gz
platform-system-core-bff8f3fa9848e52e3f3fe773796a03a80133992a.tar.xz
platform-system-core-bff8f3fa9848e52e3f3fe773796a03a80133992a.zip
Add stubs for host builds.
Bug: 4466013 Change-Id: I5633c841e71a48357bb04cd7ccc02550c17bde22
Diffstat (limited to 'libcutils/sched_policy.c')
-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 20771c0c5..79c6994d9 100644
--- a/libcutils/sched_policy.c
+++ b/libcutils/sched_policy.c
@@ -16,24 +16,31 @@
16** limitations under the License. 16** limitations under the License.
17*/ 17*/
18 18
19#define LOG_TAG "SchedPolicy"
20
19#include <stdio.h> 21#include <stdio.h>
20#include <stdlib.h> 22#include <stdlib.h>
21#include <unistd.h> 23#include <unistd.h>
22#include <string.h> 24#include <string.h>
23#include <errno.h> 25#include <errno.h>
24#include <fcntl.h> 26#include <fcntl.h>
27#include <cutils/sched_policy.h>
28#include <cutils/log.h>
25 29
26#define LOG_TAG "SchedPolicy" 30/* Re-map SP_DEFAULT to the system default policy, and leave other values unchanged.
27#include "cutils/log.h" 31 * Call this any place a SchedPolicy is used as an input parameter.
32 * Returns the possibly re-mapped policy.
33 */
34static inline SchedPolicy _policy(SchedPolicy p)
35{
36 return p == SP_DEFAULT ? SP_SYSTEM_DEFAULT : p;
37}
28 38
29#ifdef HAVE_SCHED_H 39#if defined(HAVE_ANDROID_OS) && defined(HAVE_SCHED_H) && defined(HAVE_PTHREADS)
30#ifdef HAVE_PTHREADS
31 40
32#include <sched.h> 41#include <sched.h>
33#include <pthread.h> 42#include <pthread.h>
34 43
35#include <cutils/sched_policy.h>
36
37#ifndef SCHED_NORMAL 44#ifndef SCHED_NORMAL
38 #define SCHED_NORMAL 0 45 #define SCHED_NORMAL 0
39#endif 46#endif
@@ -274,15 +281,6 @@ int get_sched_policy(int tid, SchedPolicy *policy)
274 return 0; 281 return 0;
275} 282}
276 283
277/* Re-map SP_DEFAULT to the system default policy, and leave other values unchanged.
278 * Call this any place a SchedPolicy is used as an input parameter.
279 * Returns the possibly re-mapped policy.
280 */
281static inline SchedPolicy _policy(SchedPolicy p)
282{
283 return p == SP_DEFAULT ? SP_SYSTEM_DEFAULT : p;
284}
285
286int set_sched_policy(int tid, SchedPolicy policy) 284int set_sched_policy(int tid, SchedPolicy policy)
287{ 285{
288#ifdef HAVE_GETTID 286#ifdef HAVE_GETTID
@@ -356,6 +354,23 @@ int set_sched_policy(int tid, SchedPolicy policy)
356 return 0; 354 return 0;
357} 355}
358 356
357#else
358
359/* Stubs for non-Android targets. */
360
361int set_sched_policy(int tid, SchedPolicy policy)
362{
363 return 0;
364}
365
366int get_sched_policy(int tid, SchedPolicy *policy)
367{
368 *policy = SP_SYSTEM_DEFAULT;
369 return 0;
370}
371
372#endif
373
359const char *get_sched_policy_name(SchedPolicy policy) 374const char *get_sched_policy_name(SchedPolicy policy)
360{ 375{
361 policy = _policy(policy); 376 policy = _policy(policy);
@@ -372,5 +387,3 @@ const char *get_sched_policy_name(SchedPolicy policy)
372 return "error"; 387 return "error";
373} 388}
374 389
375#endif /* HAVE_PTHREADS */
376#endif /* HAVE_SCHED_H */