#include <errno.h>
#include <unistd.h>
+#include <sys/endian.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/statvfs.h>
#define FIO_HAVE_GETTID
#define FIO_HAVE_CPU_AFFINITY
#define FIO_HAVE_IOPRIO
+#define FIO_HAVE_SHM_ATTACH_REMOVED
#define OS_MAP_ANON MAP_ANON
/*
* Define USCHED_GET_CPUMASK as the macro didn't exist until release 4.5.
- * usched_set(2) returns EINVAL if the kernel doesn't support it, though
- * fio_getaffinity() returns void.
+ * usched_set(2) returns EINVAL if the kernel doesn't support it.
*
* Also note usched_set(2) works only for the current thread regardless of
* the command type. It doesn't work against another thread regardless of
#define USCHED_GET_CPUMASK 5
#endif
+/* No CPU_COUNT(), but use the default function defined in os/os.h */
+#define fio_cpu_count(mask) CPU_COUNT((mask))
+
static inline int fio_cpuset_init(os_cpu_mask_t *mask)
{
CPUMASK_ASSZERO(*mask);
return 0;
}
-static inline int fio_cpu_count(os_cpu_mask_t *mask)
-{
- int i, n = 0;
-
- for (i = 0; i < FIO_MAX_CPUS; i++)
- if (CPUMASK_TESTBIT(*mask, i))
- n++;
-
- return n;
-}
-
static inline int fio_setaffinity(int pid, os_cpu_mask_t mask)
{
int i, firstcall = 1;
return 0;
}
-static inline void fio_getaffinity(int pid, os_cpu_mask_t *mask)
+static inline int fio_getaffinity(int pid, os_cpu_mask_t *mask)
{
/* 0 for the current thread, see BUGS in usched_set(2) */
pid = 0;
- usched_set(pid, USCHED_GET_CPUMASK, mask, sizeof(*mask));
+ if (usched_set(pid, USCHED_GET_CPUMASK, mask, sizeof(*mask)))
+ return -1;
+
+ return 0;
}
/* fio code is Linux based, so rename macros to Linux style */
static inline int blockdev_invalidate_cache(struct fio_file *f)
{
- return EINVAL;
+ return ENOTSUP;
}
static inline unsigned long long os_phys_mem(void)
#define FIO_MADV_FREE MADV_FREE
#endif
+static inline int shm_attach_to_open_removed(void)
+{
+ int x;
+ size_t len = sizeof(x);
+
+ if (sysctlbyname("kern.ipc.shm_allow_removed", &x, &len, NULL, 0) < 0)
+ return 0;
+
+ return x > 0 ? 1 : 0;
+}
+
#endif