blob: ef81703bc3a9c26acb1a0d6618ce1bc0cf022acb [file] [log] [blame]
Andrew Geisslerc5535c92023-01-27 16:10:19 -06001From 74b3844737b03492756b4f896c938b504b069f14 Mon Sep 17 00:00:00 2001
2From: Jérémie Galarneau <jeremie.galarneau@efficios.com>
3Date: Tue, 17 Jan 2023 16:57:35 -0500
4Subject: [PATCH] compat: off64_t is not defined by musl
Andrew Geissler517393d2023-01-13 08:55:19 -06005
Andrew Geisslerc5535c92023-01-27 16:10:19 -06006This helps compile with latest musl, where off64_t is not defined unless
7_LARGEFILE64_SOURCE is defined. On glibc, _LARGEFILE64_SOURCE is defined
8if _GNU_SOURCE is defined, so the problem is only seen with musl.
Andrew Geissler517393d2023-01-13 08:55:19 -06009
Andrew Geisslerc5535c92023-01-27 16:10:19 -060010Since the project uses AC_SYS_LARGEFILE, which from the autoconf doc:
11"arrange for 64-bit file offsets, known as large-file support."
12
13As such, it is safe to assume off_t is 64-bit wide. This is checked by a
14static_assert to catch any platform where autoconf would let a 32-bit
15off_t slip.
16
17Upstream-Status: Submitted [https://review.lttng.org/c/lttng-tools/+/9268]
18Reported-by: Khem Raj <raj.khem@gmail.com>
19Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
20Change-Id: If2c6007a8c85bc3f3065002af8a7538b882fb4a8
Andrew Geissler517393d2023-01-13 08:55:19 -060021---
Andrew Geissler517393d2023-01-13 08:55:19 -060022
Andrew Geisslerc5535c92023-01-27 16:10:19 -060023--- a/src/common/compat/compat-fcntl.c
24+++ b/src/common/compat/compat-fcntl.c
25@@ -13,7 +13,7 @@
26 #ifdef __linux__
27
28 LTTNG_HIDDEN
29-int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
30+int compat_sync_file_range(int fd, off_t offset, off_t nbytes,
31 unsigned int flags)
32 {
33 #ifdef HAVE_SYNC_FILE_RANGE
Andrew Geissler517393d2023-01-13 08:55:19 -060034--- a/src/common/compat/fcntl.h
35+++ b/src/common/compat/fcntl.h
Andrew Geisslerc5535c92023-01-27 16:10:19 -060036@@ -8,21 +8,21 @@
Andrew Geissler517393d2023-01-13 08:55:19 -060037 #ifndef _COMPAT_FCNTL_H
38 #define _COMPAT_FCNTL_H
Andrew Geisslerc5535c92023-01-27 16:10:19 -060039
40+#include <assert.h>
Andrew Geissler517393d2023-01-13 08:55:19 -060041 #include <fcntl.h>
42 #include <sys/types.h>
43
Andrew Geisslerc5535c92023-01-27 16:10:19 -060044 #include <common/compat/errno.h>
45
46-#if (defined(__CYGWIN__))
47-typedef long long off64_t;
48-#endif
49+static_assert(sizeof(off_t) == sizeof(int64_t),
50+ "Build system is misconfigured, off_t must be 64-bit wide");
51
52 #if (defined(__FreeBSD__) || defined(__sun__))
53 typedef off64_t loff_t;
Andrew Geissler517393d2023-01-13 08:55:19 -060054 #endif
55
56 #ifdef __linux__
Andrew Geisslerc5535c92023-01-27 16:10:19 -060057-extern int compat_sync_file_range(int fd, off64_t offset, off64_t nbytes,
58+extern int compat_sync_file_range(int fd, off_t offset, off_t nbytes,
Andrew Geissler517393d2023-01-13 08:55:19 -060059 unsigned int flags);
60 #define lttng_sync_file_range(fd, offset, nbytes, flags) \
Andrew Geisslerc5535c92023-01-27 16:10:19 -060061 compat_sync_file_range(fd, offset, nbytes, flags)
62@@ -37,8 +37,8 @@ extern int compat_sync_file_range(int fd
63 #define SYNC_FILE_RANGE_WAIT_BEFORE 0
64 #define SYNC_FILE_RANGE_WRITE 0
65
66-static inline int lttng_sync_file_range(int fd, off64_t offset,
67- off64_t nbytes, unsigned int flags)
68+static inline int lttng_sync_file_range(int fd, off_t offset,
69+ off_t nbytes, unsigned int flags)
70 {
71 return -ENOSYS;
72 }