On FreeBSD 12.2/arm64, the brk() and sbrk() functions no longer exist [1]. This causes a link error in module get-rusage-data.
This patch fixes it. [1] https://www.freebsd.org/cgi/man.cgi?query=sbrk&sektion=2 2020-12-07 Bruno Haible <br...@clisp.org> get-rusage-data: Fix link error on FreeBSD 12.2/arm64. * modules/get-rusage-data (configure.ac): Test whether sbrk exists. * lib/get-rusage-data.c (get_rusage_data_via_setrlimit): Define trivially of sbrk is not available. * doc/glibc-functions/sbrk.texi: Mention that the function does not exist in FreeBSD 12.2/arm64. * doc/glibc-functions/brk.texi: Likewise. diff --git a/doc/glibc-functions/brk.texi b/doc/glibc-functions/brk.texi index bc046ca..2ca966d 100644 --- a/doc/glibc-functions/brk.texi +++ b/doc/glibc-functions/brk.texi @@ -25,5 +25,5 @@ Portability problems not fixed by Gnulib: @itemize @item This function is missing on some platforms: -AIX 5.1, Cygwin 2.9, mingw, MSVC 14. +FreeBSD 12.2/arm64, AIX 5.1, Cygwin 2.9, mingw, MSVC 14. @end itemize diff --git a/doc/glibc-functions/sbrk.texi b/doc/glibc-functions/sbrk.texi index 8a3d5ab..c09459f 100644 --- a/doc/glibc-functions/sbrk.texi +++ b/doc/glibc-functions/sbrk.texi @@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib: @itemize @item This function is missing on some platforms: -AIX 5.1, mingw, MSVC 14. +FreeBSD 12.2/arm64, AIX 5.1, mingw, MSVC 14. @end itemize diff --git a/lib/get-rusage-data.c b/lib/get-rusage-data.c index 411be94..234442c 100644 --- a/lib/get-rusage-data.c +++ b/lib/get-rusage-data.c @@ -150,7 +150,7 @@ #if !(defined __APPLE__ && defined __MACH__) || defined TEST /* Implement get_rusage_data_via_setrlimit(). */ -# if HAVE_SETRLIMIT && defined RLIMIT_DATA && !defined __HAIKU__ +# if HAVE_SETRLIMIT && defined RLIMIT_DATA && HAVE_SBRK && !defined __HAIKU__ # ifdef _AIX # define errno_expected() (errno == EINVAL || errno == EFAULT) @@ -166,9 +166,9 @@ get_rusage_data_via_setrlimit (void) struct rlimit orig_limit; # ifdef __hpux - /* On HP-UX 11.00, setrlimit() RLIMIT_DATA of does not work: It cannot + /* On HP-UX 11.00, setrlimit() of RLIMIT_DATA does not work: It cannot restore the previous limits. - On HP-UX 11.11, setrlimit() RLIMIT_DATA of does not work: It sometimes + On HP-UX 11.11, setrlimit() of RLIMIT_DATA does not work: It sometimes has no effect on the next sbrk() call. */ { struct utsname buf; diff --git a/modules/get-rusage-data b/modules/get-rusage-data index 6840116..4206ec9 100644 --- a/modules/get-rusage-data +++ b/modules/get-rusage-data @@ -14,7 +14,7 @@ getpagesize vma-iter configure.ac: -AC_CHECK_FUNCS_ONCE([setrlimit]) +AC_CHECK_FUNCS_ONCE([sbrk setrlimit]) gl_FUNC_MMAP_ANON Makefile.am: