commit: 86d4a937823afbae13e16705a490df30e3f79ba5
parent 125ed15d0a173242a77bebcc0fb322ac20f8248d
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 1 Aug 2025 09:13:15 +0200
add no-op fallback on posix_fadvise()
Diffstat:
11 files changed, 24 insertions(+), 0 deletions(-)
diff --git a/cmd/cat.c b/cmd/cat.c
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: MPL-2.0
#define _POSIX_C_SOURCE 200809L
+#include "../config.h"
#include "../libutils/fs.h"
#include "../libutils/getopt_nolong.h"
diff --git a/cmd/cksum.c b/cmd/cksum.c
@@ -3,6 +3,8 @@
// SPDX-License-Identifier: MPL-2.0
#define _POSIX_C_SOURCE 200809L
+#include "../config.h"
+
#include <errno.h>
#include <fcntl.h> // open, O_*
#include <inttypes.h> // uint32_t
diff --git a/cmd/cmp.c b/cmd/cmp.c
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: MPL-2.0
#define _POSIX_C_SOURCE 200809L
+#include "../config.h"
#include "../libutils/getopt_nolong.h"
#include <assert.h>
diff --git a/cmd/head.c b/cmd/head.c
@@ -4,6 +4,7 @@
#define _POSIX_C_SOURCE 200809L
+#include "../config.h"
#include "../libutils/fs.h" // auto_fd_copy
#include "../libutils/getopt_nolong.h"
#include "../libutils/truncation.h" // apply_size_suffix
diff --git a/cmd/mv.c b/cmd/mv.c
@@ -11,6 +11,7 @@
#define _NETBSD_SOURCE
#endif
+#include "../config.h"
#include "../libutils/consent.h"
#include "../libutils/fs.h"
#include "../libutils/getopt_nolong.h"
diff --git a/cmd/sha1sum.c b/cmd/sha1sum.c
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: MPL-2.0
#define _POSIX_C_SOURCE 200809L
+#include "../config.h"
#include "../lib/sha1.h" // sha1_*
#include "../lib/strconv.h" // bytes2hex
#include "../libutils/getopt_nolong.h"
diff --git a/cmd/sha256sum.c b/cmd/sha256sum.c
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: MPL-2.0
#define _POSIX_C_SOURCE 200809L
+#include "../config.h"
#include "../lib/sha256.h" // sha256_*
#include "../lib/strconv.h" // bytes2hex
#include "../libutils/getopt_nolong.h"
diff --git a/cmd/sha512sum.c b/cmd/sha512sum.c
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: MPL-2.0
#define _POSIX_C_SOURCE 200809L
+#include "../config.h"
#include "../lib/sha512.h" // sha512_*
#include "../lib/strconv.h" // bytes2hex
#include "../libutils/getopt_nolong.h"
diff --git a/cmd/split.c b/cmd/split.c
@@ -4,6 +4,7 @@
#define _POSIX_C_SOURCE 200809L
+#include "../config.h"
#include "../libutils/fs.h" // auto_file_copy
#include "../libutils/getopt_nolong.h"
#include "../libutils/truncation.h" // apply_size_suffix
diff --git a/configure b/configure
@@ -271,6 +271,9 @@ if ! check_conftest configure.d/o_path.c; then
target_filter="${target_filter} -e cmd/ln."
fi
+# OpenBSD lacks posix_fadvise
+check_conftest configure.d/posix_fadvise.c || cpp_define 'posix_fadvise(fd, off, len, adv) 0'
+
rm -f configure.d/*.bin
echo
diff --git a/configure.d/posix_fadvise.c b/configure.d/posix_fadvise.c
@@ -0,0 +1,11 @@
+#define _POSIX_C_SOURCE 200809L
+#include <fcntl.h>
+
+int
+main(void)
+{
+ int fd = 1;
+ off_t offset = 0;
+ off_t len = 0;
+ return posix_fadvise(fd, offset, len, POSIX_FADV_SEQUENTIAL);
+}