You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
1.9 KiB

  1. From 2759b7c8dda77641fe271102a26ad7a02419ad62 Mon Sep 17 00:00:00 2001
  2. From: Rosen Penev <rosenp@gmail.com>
  3. Date: Sun, 16 Sep 2018 11:07:14 -0700
  4. Subject: [PATCH] Add Musl support
  5. The *48_r functions are glibc extensions that also happen to be supported
  6. by uclibc as well. Adapted from the Android solution.
  7. __USE_FILE_OFFSET64 is glibc specific so use LARGEFILE_SOURCE.
  8. Signed-off-by: Rosen Penev <rosenp@gmail.com>
  9. ---
  10. os/os-linux.h | 17 +++++++++++++++++
  11. oslib/libmtd_common.h | 2 +-
  12. 2 files changed, 18 insertions(+), 1 deletion(-)
  13. diff --git a/os/os-linux.h b/os/os-linux.h
  14. index 6b63d123..e06aadae 100644
  15. --- a/os/os-linux.h
  16. +++ b/os/os-linux.h
  17. @@ -60,7 +60,11 @@
  18. typedef cpu_set_t os_cpu_mask_t;
  19. +#if defined(__GLIBC__) || defined(__UCLIBC__)
  20. typedef struct drand48_data os_random_state_t;
  21. +#else
  22. +typedef struct { unsigned short r[3]; } os_random_state_t;
  23. +#endif
  24. #ifdef CONFIG_3ARG_AFFINITY
  25. #define fio_setaffinity(pid, cpumask) \
  26. @@ -172,14 +176,27 @@ static inline unsigned long long os_phys_mem(void)
  27. static inline void os_random_seed(unsigned long seed, os_random_state_t *rs)
  28. {
  29. +#if defined(__GLIBC__) || defined (__UCLIBC__)
  30. srand48_r(seed, rs);
  31. +#else
  32. + rs->r[0] = seed & 0xffff;
  33. + seed >>= 16;
  34. + rs->r[1] = seed & 0xffff;
  35. + seed >>= 16;
  36. + rs->r[2] = seed & 0xffff;
  37. + seed48(rs->r);
  38. +#endif
  39. }
  40. static inline long os_random_long(os_random_state_t *rs)
  41. {
  42. long val;
  43. +#if defined(__GLIBC__) || (__UCLIBC__)
  44. lrand48_r(rs, &val);
  45. +#else
  46. + val = nrand48(rs->r);
  47. +#endif
  48. return val;
  49. }
  50. diff --git a/oslib/libmtd_common.h b/oslib/libmtd_common.h
  51. index 4ed9f0ba..c5cfd217 100644
  52. --- a/oslib/libmtd_common.h
  53. +++ b/oslib/libmtd_common.h
  54. @@ -69,7 +69,7 @@ extern "C" {
  55. #endif
  56. /* define a print format specifier for off_t */
  57. -#ifdef __USE_FILE_OFFSET64
  58. +#ifdef _LARGEFILE_SOURCE
  59. #define PRIxoff_t PRIx64
  60. #define PRIdoff_t PRId64
  61. #else
  62. --
  63. 2.19.1