summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2022-04-21 19:56:41 +0100
committerSimon McVittie <smcv@collabora.com>2022-04-21 19:56:41 +0100
commit238f7bfc494e16a0864f88ae891da6e7b3d82e5b (patch)
treef0b85783954d4c3ff1c6ce2a319c1d09aa389914
parent4d5b1fcf0257f508f4b5e48b099f259b7bb9c908 (diff)
downloadlibglnx-238f7bfc494e16a0864f88ae891da6e7b3d82e5b.tar.gz
fdio: Skip glnx_try_fallocate() if _GNU_SOURCE is not defined
fallocate() is only visible in fcntl.h if _GNU_SOURCE is defined. Most users of libglnx will want to do that anyway, but it seems nicer to avoid "implicit declaration of function ‘fallocate’" warnings from simply including <libglnx.h> into naive code. Signed-off-by: Simon McVittie <smcv@collabora.com>
-rw-r--r--glnx-fdio.h2
-rw-r--r--tests/use-as-subproject/meson.build1
2 files changed, 2 insertions, 1 deletions
diff --git a/glnx-fdio.h b/glnx-fdio.h
index b6ba0ea..af53479 100644
--- a/glnx-fdio.h
+++ b/glnx-fdio.h
@@ -209,6 +209,7 @@ int glnx_renameat2_noreplace (int olddirfd, const char *oldpath,
int glnx_renameat2_exchange (int olddirfd, const char *oldpath,
int newdirfd, const char *newpath);
+#ifdef _GNU_SOURCE
/**
* glnx_try_fallocate:
* @fd: File descriptor
@@ -240,6 +241,7 @@ glnx_try_fallocate (int fd,
return TRUE;
}
+#endif
/**
* glnx_fstat:
diff --git a/tests/use-as-subproject/meson.build b/tests/use-as-subproject/meson.build
index 65ba37b..2d08160 100644
--- a/tests/use-as-subproject/meson.build
+++ b/tests/use-as-subproject/meson.build
@@ -7,7 +7,6 @@ project(
version : '0',
meson_version : '>=0.49.0',
)
-add_project_arguments('-D_GNU_SOURCE', language : 'c')
configure_file(
copy : true,