logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/
commit: 865d3b6a2cd9159e4f4ad30c67125851309f8205
parent 7bc999d45c85a71ce760362f6c5e8a052efcc7d8
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu, 26 Dec 2024 02:02:39 +0100

configure*: test linking as well, makes sure no lib is missing

Diffstat:

Mconfigure2+-
Mconfigure.d/copy_file_range.c13++++++++-----
Mconfigure.d/reallocarray.c10+++++-----
Mconfigure.d/sendfile_linux.c14+++++++++-----
Mconfigure.d/syncfs.c5++---
5 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/configure b/configure @@ -110,7 +110,7 @@ check_conftest() { printf 'Checking if conftest %s compiles ...' "$conftest" - ${CC} ${CFLAGS} ${CFLAGS_CHECK} -c -o "${conftest}.bin" "${conftest}" 2>&1 + ${CC} ${CFLAGS} ${CFLAGS_CHECK} -o "${conftest}.bin" "${conftest}" ${LDFLAGS} ${LDSTATIC} 2>&1 is_ok } diff --git a/configure.d/copy_file_range.c b/configure.d/copy_file_range.c @@ -10,11 +10,14 @@ #include <sys/types.h> #include <unistd.h> -ssize_t test(int in, int out); - -ssize_t -test(int in, int out) +int +main(void) { + int fd_in = 0; + int fd_out = 1; off_t in_pos = 0, out_pos = 0; - return copy_file_range(in, &in_pos, out, &out_pos, SIZE_MAX, 0); + + ssize_t ret = copy_file_range(fd_in, &in_pos, fd_out, &out_pos, SIZE_MAX, 0); + + return ret > 0; } diff --git a/configure.d/reallocarray.c b/configure.d/reallocarray.c @@ -8,11 +8,11 @@ #include <stdlib.h> // reallocarray -void test(void); - -void -test(void) +int +main(void) { char *arr = NULL; - (void)reallocarray(&arr, 69, sizeof(*arr)); + arr = reallocarray(&arr, 69, sizeof(*arr)); + + return arr != NULL; } diff --git a/configure.d/sendfile_linux.c b/configure.d/sendfile_linux.c @@ -7,11 +7,15 @@ #include <sys/sendfile.h> -ssize_t test(int in, int out, size_t len); - -ssize_t -test(int in, int out, size_t len) +int +main(void) { + int fd_in = 0; + int fd_out = 1; off_t *offset = NULL; - return sendfile(out, in, offset, len); + size_t len = 42; + + ssize_t ret = sendfile(fd_out, fd_in, offset, len); + + return ret > 0; } diff --git a/configure.d/syncfs.c b/configure.d/syncfs.c @@ -8,10 +8,9 @@ #include <unistd.h> // syncfs -int test(int fd); - int -test(int fd) +main(void) { + int fd = 0; return syncfs(fd); }