zipline: refactor environment variables (#377101)
[NixPkgs.git] / pkgs / by-name / li / libeatmydata / LFS64.patch
blob2a8ab5e088933c3e38eca8cc1ed4181ab435cb9c
1 From 59f04ad8730034a205a1a792662d4b5dc2006b7c Mon Sep 17 00:00:00 2001
2 From: Alyssa Ross <hi@alyssa.is>
3 Date: Mon, 13 May 2024 09:53:23 +0200
4 Subject: [PATCH] Fix sync_file_range() with musl 1.2.4
6 musl 1.2.4 has removed the transitional LFS off64_t type.
7 sync_file_range is declared with off_t in musl, which is always 64
8 bits.
10 This assumes that the same is true of any other libc which doesn't
11 provide off64_t. If it's not, gcc will produce an error due to the
12 conflicting types of sync_file_range(), so it will be caught and can
13 be fixed.
14 ---
15 configure.ac | 2 ++
16 libeatmydata/libeatmydata.c | 11 +++++++++--
17 2 files changed, 11 insertions(+), 2 deletions(-)
19 diff --git a/configure.ac b/configure.ac
20 index 4d101ba..f3c4a69 100644
21 --- a/configure.ac
22 +++ b/configure.ac
23 @@ -37,6 +37,8 @@ AC_CHECK_HEADERS_ONCE(pthread.h)
24 AC_CHECK_SIZEOF(mode_t)
25 AC_CHECK_SIZEOF(int)
27 +AC_CHECK_TYPES([off64_t])
29 AC_CHECK_TYPE(pthread_barrier_t,,,[
30 #ifdef HAVE_PTHREAD_H
31 #include <pthread.h>
32 diff --git a/libeatmydata/libeatmydata.c b/libeatmydata/libeatmydata.c
33 index 134afcd..0015f1f 100644
34 --- a/libeatmydata/libeatmydata.c
35 +++ b/libeatmydata/libeatmydata.c
36 @@ -35,6 +35,12 @@
37 #define CHECK_FILE "/tmp/eatmydata"
40 +#ifdef HAVE_OFF64_T
41 +typedef off64_t sync_file_range_off;
42 +#else
43 +typedef off_t sync_file_range_off;
44 +#endif
46 typedef int (*libc_open_t)(const char*, int, ...);
47 #ifdef HAVE_OPEN64
48 typedef int (*libc_open64_t)(const char*, int, ...);
49 @@ -44,7 +50,7 @@ typedef int (*libc_sync_t)(void);
50 typedef int (*libc_fdatasync_t)(int);
51 typedef int (*libc_msync_t)(void*, size_t, int);
52 #ifdef HAVE_SYNC_FILE_RANGE
53 -typedef int (*libc_sync_file_range_t)(int, off64_t, off64_t, unsigned int);
54 +typedef int (*libc_sync_file_range_t)(int, sync_file_range_off, sync_file_range_off, unsigned int);
55 #endif
56 #ifdef HAVE_SYNCFS
57 typedef int (*libc_syncfs_t)(int);
58 @@ -259,7 +265,8 @@ int LIBEATMYDATA_API msync(void *addr, size_t length, int flags)
61 #ifdef HAVE_SYNC_FILE_RANGE
62 -int LIBEATMYDATA_API sync_file_range(int fd, off64_t offset, off64_t nbytes,
63 +int LIBEATMYDATA_API sync_file_range(int fd, sync_file_range_off offset,
64 + sync_file_range_off nbytes,
65 unsigned int flags)
67 if (eatmydata_is_hungry()) {
68 --
69 2.45.1