Message ID | 20231219115423.222134-3-ammarfaizi2@gnuweeb.org (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Makefile and t/no-mmap-inval updates | expand |
On Tue, Dec 19, 2023 at 6:54 PM Ammar Faizi wrote: > Address the limitations of valloc(). This function, which is primarily > used for allocating page-aligned memory, is not only absent in some > systems but is also marked as obsolete according to the `man 3 valloc`. > > Replace valloc() with t_posix_memalign() to fix the following build > error: > > no-mmap-inval.c:28:56: warning: call to undeclared function 'valloc'; ISO C99 and \ > later do not support implicit function declarations [-Wimplicit-function-declaration] > p.cq_off.user_addr = (unsigned long long) (uintptr_t) valloc(8192); > ^ > 1 warning generated. > > ld.lld: error: undefined symbol: valloc > >>> referenced by no-mmap-inval.c:28 > >>> /tmp/no-mmap-inval-ea16a2.o:(main) > >>> did you mean: calloc > >>> defined in: /system/lib64/libc.so > clang-15: error: linker command failed with exit code 1 (use -v to see invocation) > make[1]: *** [Makefile:239: no-mmap-inval.t] Error 1 > > Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> Reviewed-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org> -- Viro
diff --git a/test/no-mmap-inval.c b/test/no-mmap-inval.c index 9571fee0035ac5ce..244d4eb645115a44 100644 --- a/test/no-mmap-inval.c +++ b/test/no-mmap-inval.c @@ -20,12 +20,14 @@ int main(int argc, char *argv[]) .flags = IORING_SETUP_NO_MMAP, }; struct io_uring ring; + void *addr; int ret; if (argc > 1) return T_EXIT_SKIP; - p.cq_off.user_addr = (unsigned long long) (uintptr_t) valloc(8192); + t_posix_memalign(&addr, sysconf(_SC_PAGESIZE), 8192); + p.cq_off.user_addr = (unsigned long long) (uintptr_t) addr; ret = io_uring_queue_init_params(2, &ring, &p); if (ret == -EINVAL) {