From e02fa2ec9072132e13afab4441366d3580b5e6f9 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Mon, 15 May 2023 16:22:35 +0100 Subject: gfile: Ensure loff_t is defined on FreeBSD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When `copy_file_range()` support was added, I used the definition of `copy_file_range()` from Linux, which uses `loff_t` to abstract the different `off*_t` types. `loff_t` doesn’t exist on FreeBSD, so this doesn’t compile, and was caught in subsequent asynchronous CI. Define `loff_t` with a fallback value if it’s not defined, which should fix this and other uses of `loff_t` in `gfile.c` (for example, if FreeBSD ever starts declaring `splice()`). Fixes this CI failure: https://gitlab.gnome.org/GNOME/glib/-/jobs/2812302 Signed-off-by: Philip Withnall --- gio/gfile.c | 7 +++++++ meson.build | 4 ++++ 2 files changed, 11 insertions(+) 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 ') + 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 -- cgit v1.2.1