From 2759b7c8dda77641fe271102a26ad7a02419ad62 Mon Sep 17 00:00:00 2001
|
|
From: Rosen Penev <rosenp@gmail.com>
|
|
Date: Sun, 16 Sep 2018 11:07:14 -0700
|
|
Subject: [PATCH] Add Musl support
|
|
|
|
The *48_r functions are glibc extensions that also happen to be supported
|
|
by uclibc as well. Adapted from the Android solution.
|
|
|
|
__USE_FILE_OFFSET64 is glibc specific so use LARGEFILE_SOURCE.
|
|
|
|
Signed-off-by: Rosen Penev <rosenp@gmail.com>
|
|
---
|
|
os/os-linux.h | 17 +++++++++++++++++
|
|
oslib/libmtd_common.h | 2 +-
|
|
2 files changed, 18 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/os/os-linux.h b/os/os-linux.h
|
|
index 6b63d123..e06aadae 100644
|
|
--- a/os/os-linux.h
|
|
+++ b/os/os-linux.h
|
|
@@ -60,7 +60,11 @@
|
|
|
|
typedef cpu_set_t os_cpu_mask_t;
|
|
|
|
+#if defined(__GLIBC__) || defined(__UCLIBC__)
|
|
typedef struct drand48_data os_random_state_t;
|
|
+#else
|
|
+typedef struct { unsigned short r[3]; } os_random_state_t;
|
|
+#endif
|
|
|
|
#ifdef CONFIG_3ARG_AFFINITY
|
|
#define fio_setaffinity(pid, cpumask) \
|
|
@@ -172,14 +176,27 @@ static inline unsigned long long os_phys_mem(void)
|
|
|
|
static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
|
|
{
|
|
+#if defined(__GLIBC__) || defined (__UCLIBC__)
|
|
srand48_r(seed, rs);
|
|
+#else
|
|
+ rs->r[0] = seed & 0xffff;
|
|
+ seed >>= 16;
|
|
+ rs->r[1] = seed & 0xffff;
|
|
+ seed >>= 16;
|
|
+ rs->r[2] = seed & 0xffff;
|
|
+ seed48(rs->r);
|
|
+#endif
|
|
}
|
|
|
|
static inline long os_random_long(os_random_state_t *rs)
|
|
{
|
|
long val;
|
|
|
|
+#if defined(__GLIBC__) || (__UCLIBC__)
|
|
lrand48_r(rs, &val);
|
|
+#else
|
|
+ val = nrand48(rs->r);
|
|
+#endif
|
|
return val;
|
|
}
|
|
|
|
diff --git a/oslib/libmtd_common.h b/oslib/libmtd_common.h
|
|
index 4ed9f0ba..c5cfd217 100644
|
|
--- a/oslib/libmtd_common.h
|
|
+++ b/oslib/libmtd_common.h
|
|
@@ -69,7 +69,7 @@ extern "C" {
|
|
#endif
|
|
|
|
/* define a print format specifier for off_t */
|
|
-#ifdef __USE_FILE_OFFSET64
|
|
+#ifdef _LARGEFILE_SOURCE
|
|
#define PRIxoff_t PRIx64
|
|
#define PRIdoff_t PRId64
|
|
#else
|
|
--
|
|
2.19.1
|
|
|