summaryrefslogtreecommitdiff
path: root/os
diff options
context:
space:
mode:
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>2021-04-26 00:10:40 +0900
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>2021-04-26 00:15:07 +0900
commite9d2a04d1278ce02140a8b8da4d5aede7a6ad39d (patch)
tree1481fd25e4ae16e670851622fe1c1954ae3af138 /os
parent14691a4df98b85621b07dd2bdc0f0a960acbb8ba (diff)
downloadfio-e9d2a04d1278ce02140a8b8da4d5aede7a6ad39d.tar.gz
fio-e9d2a04d1278ce02140a8b8da4d5aede7a6ad39d.tar.bz2
gettime: Fix compilation on non-Linux with pthread_getaffinity_np()
874d55e50c("os/os-linux: add pthread CPU affinity helper") and a few commits after that broke compilation on non-Linux platforms which support pthread_getaffinity_np(). Define fio_get_thread_affinity() on non-Linux platforms, and make gettime test FIO_HAVE_GET_THREAD_AFFINITY which may or may not depend on pthread. FIO_HAVE_GET_THREAD_AFFINITY is currently not defined on Windows. Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Diffstat (limited to 'os')
-rw-r--r--os/os-aix.h6
-rw-r--r--os/os-android.h6
-rw-r--r--os/os-dragonfly.h6
-rw-r--r--os/os-freebsd.h6
-rw-r--r--os/os-hpux.h7
-rw-r--r--os/os-linux.h3
-rw-r--r--os/os-mac.h6
-rw-r--r--os/os-netbsd.h6
-rw-r--r--os/os-openbsd.h6
-rw-r--r--os/os-solaris.h6
10 files changed, 58 insertions, 0 deletions
diff --git a/os/os-aix.h b/os/os-aix.h
index 1aab96e0..db99eef4 100644
--- a/os/os-aix.h
+++ b/os/os-aix.h
@@ -18,6 +18,12 @@
#define FIO_USE_GENERIC_SWAP
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask) \
+ pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
static inline int blockdev_invalidate_cache(struct fio_file *f)
{
return ENOTSUP;
diff --git a/os/os-android.h b/os/os-android.h
index 3c050776..3f1aa9d3 100644
--- a/os/os-android.h
+++ b/os/os-android.h
@@ -58,6 +58,12 @@
#define MAP_HUGETLB 0x40000 /* arch specific */
#endif
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask) \
+ pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
#ifndef CONFIG_NO_SHM
/*
* Bionic doesn't support SysV shared memeory, so implement it using ashmem
diff --git a/os/os-dragonfly.h b/os/os-dragonfly.h
index 44bfcd5d..6e465894 100644
--- a/os/os-dragonfly.h
+++ b/os/os-dragonfly.h
@@ -92,6 +92,12 @@ typedef cpumask_t os_cpu_mask_t;
/* No CPU_COUNT(), but use the default function defined in os/os.h */
#define fio_cpu_count(mask) CPU_COUNT((mask))
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask) \
+ pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
static inline int fio_cpuset_init(os_cpu_mask_t *mask)
{
CPUMASK_ASSZERO(*mask);
diff --git a/os/os-freebsd.h b/os/os-freebsd.h
index b3addf98..1b24fa02 100644
--- a/os/os-freebsd.h
+++ b/os/os-freebsd.h
@@ -37,6 +37,12 @@ typedef cpuset_t os_cpu_mask_t;
#define fio_cpu_isset(mask, cpu) (CPU_ISSET((cpu), (mask)) != 0)
#define fio_cpu_count(mask) CPU_COUNT((mask))
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask) \
+ pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
static inline int fio_cpuset_init(os_cpu_mask_t *mask)
{
CPU_ZERO(mask);
diff --git a/os/os-hpux.h b/os/os-hpux.h
index c1dafe42..a80cb2bc 100644
--- a/os/os-hpux.h
+++ b/os/os-hpux.h
@@ -38,6 +38,13 @@
#define FIO_USE_GENERIC_SWAP
#define FIO_OS_HAVE_AIOCB_TYPEDEF
+
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask) \
+ pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
typedef struct aiocb64 os_aiocb_t;
static inline int blockdev_invalidate_cache(struct fio_file *f)
diff --git a/os/os-linux.h b/os/os-linux.h
index ea8d7922..f7137abe 100644
--- a/os/os-linux.h
+++ b/os/os-linux.h
@@ -74,8 +74,11 @@ typedef cpu_set_t os_cpu_mask_t;
sched_getaffinity((pid), (ptr))
#endif
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
#define fio_get_thread_affinity(mask) \
pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
#define fio_cpu_clear(mask, cpu) (void) CPU_CLR((cpu), (mask))
#define fio_cpu_set(mask, cpu) (void) CPU_SET((cpu), (mask))
diff --git a/os/os-mac.h b/os/os-mac.h
index 683aab32..ec2cc1e5 100644
--- a/os/os-mac.h
+++ b/os/os-mac.h
@@ -27,6 +27,12 @@
#define fio_swap32(x) OSSwapInt32(x)
#define fio_swap64(x) OSSwapInt64(x)
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask) \
+ pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
#ifndef CONFIG_CLOCKID_T
typedef unsigned int clockid_t;
#endif
diff --git a/os/os-netbsd.h b/os/os-netbsd.h
index abc1d3cb..624c7fa5 100644
--- a/os/os-netbsd.h
+++ b/os/os-netbsd.h
@@ -35,6 +35,12 @@
#define fio_swap32(x) bswap32(x)
#define fio_swap64(x) bswap64(x)
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask) \
+ pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
{
struct disklabel dl;
diff --git a/os/os-openbsd.h b/os/os-openbsd.h
index 994bf078..f1bad671 100644
--- a/os/os-openbsd.h
+++ b/os/os-openbsd.h
@@ -35,6 +35,12 @@
#define fio_swap32(x) swap32(x)
#define fio_swap64(x) swap64(x)
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask) \
+ pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes)
{
struct disklabel dl;
diff --git a/os/os-solaris.h b/os/os-solaris.h
index f1966f44..ea1f081c 100644
--- a/os/os-solaris.h
+++ b/os/os-solaris.h
@@ -46,6 +46,12 @@ struct solaris_rand_seed {
#define os_ctime_r(x, y, z) ctime_r((x), (y), (z))
#define FIO_OS_HAS_CTIME_R
+#ifdef CONFIG_PTHREAD_GETAFFINITY
+#define FIO_HAVE_GET_THREAD_AFFINITY
+#define fio_get_thread_affinity(mask) \
+ pthread_getaffinity_np(pthread_self(), sizeof(mask), &(mask))
+#endif
+
typedef psetid_t os_cpu_mask_t;
static inline int chardev_size(struct fio_file *f, unsigned long long *bytes)