summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gmail.com>2023-05-15 16:48:32 +0000
committerEmmanuele Bassi <ebassi@gmail.com>2023-05-15 16:48:32 +0000
commit03aa8513f8591892fd5cc09b4fa068ba1bfc2667 (patch)
treef04a4fe443c63f2122a9daa95aa4aeb45dfd753f
parentfde068300efe442822fbbd56dc8ecc1caf4b83a7 (diff)
parente02fa2ec9072132e13afab4441366d3580b5e6f9 (diff)
downloadglib-03aa8513f8591892fd5cc09b4fa068ba1bfc2667.tar.gz
Merge branch 'wip/pwithnall/bsd-copy-file-range' into 'main'
gfile: Ensure loff_t is defined on FreeBSD See merge request GNOME/glib!3431
-rw-r--r--gio/gfile.c7
-rw-r--r--meson.build4
2 files changed, 11 insertions, 0 deletions
diff --git a/gio/gfile.c b/gio/gfile.c
index 31da0b05e..a78737773 100644
--- a/gio/gfile.c
+++ b/gio/gfile.c
@@ -77,6 +77,13 @@
#include "gioerror.h"
#include "glibintl.h"
+/* Linux defines loff_t as a way to simplify the offset types for calls like
+ * splice() and copy_file_range(). BSD has copy_file_range() but doesn’t define
+ * loff_t. Abstract that. */
+#ifndef HAVE_LOFF_T
+typedef off_t loff_t;
+#endif
+
/**
* SECTION:gfile
diff --git a/meson.build b/meson.build
index 44284fc10..1d3754abb 100644
--- a/meson.build
+++ b/meson.build
@@ -828,6 +828,10 @@ if cc.has_header_symbol('dlfcn.h', 'RTLD_NEXT', args: '-D_GNU_SOURCE')
glib_conf.set('HAVE_RTLD_NEXT', 1)
endif
+if cc.has_type('loff_t', prefix: '#include <sys/types.h>')
+ glib_conf.set('HAVE_LOFF_T', 1)
+endif
+
# Check whether to use statfs or statvfs
# Some systems have both statfs and statvfs, pick the most "native" for these
if have_func_statfs and have_func_statvfs