summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--src/arch/android/Makefile24
-rw-r--r--src/arch/bionic/Makefile25
-rw-r--r--src/cyclictest/cyclictest.c47
-rw-r--r--src/include/bionic.h42
-rw-r--r--src/include/rt-sched.h4
6 files changed, 81 insertions, 64 deletions
diff --git a/Makefile b/Makefile
index 703333f..86a5c4b 100644
--- a/Makefile
+++ b/Makefile
@@ -69,8 +69,7 @@ ifdef HAVE_PARSE_CPUSTRING_ALL
endif
endif
-# Include any arch specific makefiles here.
-include src/arch/bionic/Makefile
+include src/arch/android/Makefile
VPATH = src/cyclictest:
VPATH += src/signaltest:
diff --git a/src/arch/android/Makefile b/src/arch/android/Makefile
new file mode 100644
index 0000000..2c4b4b7
--- /dev/null
+++ b/src/arch/android/Makefile
@@ -0,0 +1,24 @@
+
+# Android use Bionic for libc, and this does not have
+# - pthread barriers
+# - pthread_[gs]etaffinity
+#
+# This is all handled by bionic.h based on flags we set here.
+
+# Typically see something like "aarch64-linux-android". However, in some
+# buildsystems, it will be a variation of -androidabe.
+ost=$(findstring android, $(ostype))
+ifeq (android,$(ost))
+ USE_BIONIC := 1
+ CFLAGS += -DPTHREAD_BIONIC
+
+ LDFLAGS += -pie
+# -lrt and -lpthread is in standard bionic library, no standalone library
+ LIBS := $(filter-out -lrt,$(LIBS))
+ LIBS := $(filter-out -lpthread,$(LIBS))
+
+# Currently, only these binaries will compile and link properly for android
+# - cyclictest
+# - hackbench
+ sources := cyclictest.c hackbench.c
+endif
diff --git a/src/arch/bionic/Makefile b/src/arch/bionic/Makefile
deleted file mode 100644
index 410d2c9..0000000
--- a/src/arch/bionic/Makefile
+++ /dev/null
@@ -1,25 +0,0 @@
-
-# Bionic (android) does not have:
-# - pthread barriers
-# - pthread_[gs]etaffinity
-#
-# Typically see something like "aarch64-linux-android"
-ifeq (android,$(ostype))
- USE_BIONIC := 1
- CFLAGS += -DNO_PTHREAD_BARRIER
- CFLAGS += -DNO_PTHREAD_SETAFFINITY
-
- LDFLAGS += -pie
-# -lrt and -lpthread is in standard bionic library, no standalone library
- LIBS := $(filter-out -lrt,$(LIBS))
- LIBS := $(filter-out -lpthread,$(LIBS))
-
-# BIONIC does not support PI, barriers and has different files in
-# include/. This means that currently, only these binaries will compile
-# and link properly:
-# - cyclictest
-# - hackbench
-# - hwlatdetect
- sources := cyclictest.c hackbench.c hwlatdetect.c
-endif
-
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c
index a208165..f5a67dc 100644
--- a/src/cyclictest/cyclictest.c
+++ b/src/cyclictest/cyclictest.c
@@ -40,6 +40,8 @@
#include "rt-utils.h"
+#include <bionic.h>
+
#define DEFAULT_INTERVAL 1000
#define DEFAULT_DISTANCE 500
@@ -83,20 +85,11 @@ int sched_setaffinity (__pid_t __pid, size_t __cpusetsize,
#define CPU_SET(cpu, cpusetp)
#define CPU_ZERO(cpusetp)
-#endif
-
-#ifdef NO_PTHREAD_SETAFFINITY
-static inline int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize,
- const cpu_set_t *cpuset)
-{
- return sched_setaffinity(0, cpusetsize, cpuset);
-}
-
#else
extern int clock_nanosleep(clockid_t __clock_id, int __flags,
__const struct timespec *__req,
struct timespec *__rem);
-#endif
+#endif /* __UCLIBC__ */
#define USEC_PER_SEC 1000000
#define NSEC_PER_SEC 1000000000
@@ -226,14 +219,12 @@ static pthread_mutex_t break_thread_id_lock = PTHREAD_MUTEX_INITIALIZER;
static pid_t break_thread_id = 0;
static uint64_t break_thread_value = 0;
-#ifndef NO_PTHREAD_BARRIER
static int aligned = 0;
static int secaligned = 0;
static int offset = 0;
static pthread_barrier_t align_barr;
static pthread_barrier_t globalt_barr;
static struct timespec globalt;
-#endif
/* Backup of kernel variables that we modify */
static struct kvars {
@@ -845,7 +836,6 @@ static void *timerthread(void *param)
par->cpu, par->prio);
/* Get current time */
-#ifndef NO_PTHREAD_BARRIER
if (aligned || secaligned) {
pthread_barrier_wait(&globalt_barr);
if (par->tnum == 0) {
@@ -870,7 +860,6 @@ static void *timerthread(void *param)
tsnorm(&now);
}
} else
-#endif
clock_gettime(par->clock, &now);
next = now;
@@ -1088,9 +1077,7 @@ static void display_help(int error)
"-a [NUM] --affinity run thread #N on processor #N, if possible\n"
" with NUM pin all threads to the processor NUM\n"
#endif
-#ifndef NO_PTHREAD_BARRIER
"-A USEC --aligned=USEC align thread wakeups to a specific offset\n"
-#endif
"-b USEC --breaktrace=USEC send break trace command when latency > USEC\n"
"-B --preemptirqs both preempt and irqsoff tracing (used with -b)\n"
"-c CLOCK --clock=CLOCK select clock\n"
@@ -1131,9 +1118,7 @@ static void display_help(int error)
"-R --resolution check clock resolution, calling clock_gettime() many\n"
" times. list of clock_gettime() values will be\n"
" reported with -X\n"
-#ifndef NO_PTHREAD_BARRIER
" --secaligned [USEC] align thread wakeups to the next full second,\n"
-#endif
" and apply the optional offset\n"
"-s --system use sys_nanosleep and sys_setitimer\n"
"-S --smp Standard SMP testing: options -a -t -n and\n"
@@ -1281,15 +1266,13 @@ enum option_values {
OPT_AFFINITY=1, OPT_NOTRACE, OPT_BREAKTRACE, OPT_PREEMPTIRQ, OPT_CLOCK,
OPT_CONTEXT, OPT_DISTANCE, OPT_DURATION, OPT_LATENCY, OPT_EVENT,
OPT_FTRACE, OPT_FIFO, OPT_HISTOGRAM, OPT_HISTOFALL, OPT_HISTFILE,
- OPT_INTERVAL, OPT_IRQSOFF, OPT_LOOPS, OPT_MLOCKALL, OPT_REFRESH, OPT_NANOSLEEP,
- OPT_NSECS, OPT_OSCOPE, OPT_TRACEOPT, OPT_PRIORITY, OPT_PREEMPTOFF, OPT_QUIET,
- OPT_PRIOSPREAD, OPT_RELATIVE, OPT_RESOLUTION, OPT_SYSTEM, OPT_SMP, OPT_THREADS,
- OPT_TRACER, OPT_TRIGGER, OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE,
- OPT_WAKEUP, OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP, OPT_NUMOPTS,
-#ifndef NO_PTHREAD_BARRIER
- OPT_ALIGNED, OPT_SECALIGNED,
-#endif
- OPT_LAPTOP,
+ OPT_INTERVAL, OPT_IRQSOFF, OPT_LOOPS, OPT_MLOCKALL, OPT_REFRESH,
+ OPT_NANOSLEEP, OPT_NSECS, OPT_OSCOPE, OPT_TRACEOPT, OPT_PRIORITY,
+ OPT_PREEMPTOFF, OPT_QUIET, OPT_PRIOSPREAD, OPT_RELATIVE, OPT_RESOLUTION,
+ OPT_SYSTEM, OPT_SMP, OPT_THREADS, OPT_TRACER, OPT_TRIGGER,
+ OPT_TRIGGER_NODES, OPT_UNBUFFERED, OPT_NUMA, OPT_VERBOSE, OPT_WAKEUP,
+ OPT_WAKEUPRT, OPT_DBGCYCLIC, OPT_POLICY, OPT_HELP, OPT_NUMOPTS,
+ OPT_ALIGNED, OPT_SECALIGNED, OPT_LAPTOP,
};
/* Process commandline options */
@@ -1307,9 +1290,7 @@ static void process_options (int argc, char *argv[], int max_cpus)
static struct option long_options[] = {
{"affinity", optional_argument, NULL, OPT_AFFINITY},
{"notrace", no_argument, NULL, OPT_NOTRACE },
-#ifndef NO_PTHREAD_BARRIER
{"aligned", optional_argument, NULL, OPT_ALIGNED },
-#endif
{"breaktrace", required_argument, NULL, OPT_BREAKTRACE },
{"preemptirqs", no_argument, NULL, OPT_PREEMPTIRQ },
{"clock", required_argument, NULL, OPT_CLOCK },
@@ -1339,9 +1320,7 @@ static void process_options (int argc, char *argv[], int max_cpus)
{"priospread", no_argument, NULL, OPT_PRIOSPREAD },
{"relative", no_argument, NULL, OPT_RELATIVE },
{"resolution", no_argument, NULL, OPT_RESOLUTION },
-#ifndef NO_PTHREAD_BARRIER
{"secaligned", optional_argument, NULL, OPT_SECALIGNED },
-#endif
{"system", no_argument, NULL, OPT_SYSTEM },
{"smp", no_argument, NULL, OPT_SMP },
{"spike", required_argument, NULL, OPT_TRIGGER },
@@ -1378,7 +1357,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
setaffinity = AFFINITY_USEALL;
}
break;
-#ifndef NO_PTHREAD_BARRIER
case 'A':
case OPT_ALIGNED:
aligned=1;
@@ -1389,7 +1367,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
else
offset = 0;
break;
-#endif
case 'b':
case OPT_BREAKTRACE:
tracelimit = atoi(optarg); break;
@@ -1490,7 +1467,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
case OPT_RESOLUTION:
check_clock_resolution = 1; break;
case 's':
-#ifndef NO_PTHREAD_BARRIER
case OPT_SECALIGNED:
secaligned = 1;
if (optarg != NULL)
@@ -1500,7 +1476,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
else
offset = 0;
break;
-#endif
case OPT_SYSTEM:
use_system = MODE_SYS_OFFSET; break;
case 'S':
@@ -1644,7 +1619,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
if (num_threads < 1)
error = 1;
-#ifndef NO_PTHREAD_BARRIER
if (aligned && secaligned)
error = 1;
@@ -1652,7 +1626,6 @@ static void process_options (int argc, char *argv[], int max_cpus)
pthread_barrier_init(&globalt_barr, NULL, num_threads);
pthread_barrier_init(&align_barr, NULL, num_threads);
}
-#endif
if (error) {
if (affinity_mask)
rt_bitmask_free(affinity_mask);
diff --git a/src/include/bionic.h b/src/include/bionic.h
new file mode 100644
index 0000000..54f9c54
--- /dev/null
+++ b/src/include/bionic.h
@@ -0,0 +1,42 @@
+#ifndef BIONIC_H
+#define BIONIC_H
+
+#ifdef PTHREAD_BIONIC
+#warning Program is being compiled with PTHREAD_BIONIC, some options may behave erratically.
+
+/*
+ * We do not have pthread_barrier_t available, but since we are not
+ * going to use them for anything useful, just typedef them to int
+ */
+typedef int pthread_barrier_t;
+typedef int pthread_barrierattr_t;
+
+#ifndef PTHREAD_BARRIER_SERIAL_THREAD
+#define PTHREAD_BARRIER_SERIAL_THREAD 0
+#endif
+
+static inline int pthread_barrier_wait(pthread_barrier_t *barrier)
+{
+ return PTHREAD_BARRIER_SERIAL_THREAD;
+}
+
+static inline int pthread_barrier_destroy(pthread_barrier_t *barrier)
+{
+ return 0;
+}
+static inline int pthread_barrier_init(pthread_barrier_t * barrier,
+ const pthread_barrierattr_t * attr,
+ unsigned count)
+{
+ return 0;
+}
+
+static inline int pthread_setaffinity_np(pthread_t thread, size_t cpusetsize,
+ const cpu_set_t *cpuset)
+{
+ return sched_setaffinity(0, cpusetsize, cpuset);
+}
+
+#endif /* PTHREAD_BIONIC */
+
+#endif /* BIONIC_H */
diff --git a/src/include/rt-sched.h b/src/include/rt-sched.h
index b46b1b1..679c4bd 100644
--- a/src/include/rt-sched.h
+++ b/src/include/rt-sched.h
@@ -43,9 +43,13 @@
#endif
#ifdef __arm__
+#ifndef __NR_sched_setattr
#define __NR_sched_setattr 380
+#endif
+#ifndef __NR_sched_getattr
#define __NR_sched_getattr 381
#endif
+#endif
#ifdef __tilegx__
#define __NR_sched_setattr 274