Paul Eggert wrote: > While you're at it, probably worth documenting that the function is not > thread-safe.
Done through the second of the attached patches. Thanks for the suggestion.
>From 96a905cda7e941862ffcbf12e720824612c446c7 Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Sat, 13 Sep 2025 01:46:42 +0200 Subject: [PATCH 1/2] pagealign_alloc: Tweak the benchmark. * tests/bench-pagealign_alloc.c (show_stats): Reformat. (main): Fix usage message. --- ChangeLog | 6 ++++++ tests/bench-pagealign_alloc.c | 12 ++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 209e6b08eb..9b45e80a86 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2025-09-12 Bruno Haible <[email protected]> + + pagealign_alloc: Tweak the benchmark. + * tests/bench-pagealign_alloc.c (show_stats): Reformat. + (main): Fix usage message. + 2025-09-12 Bruno Haible <[email protected]> vma-iter: Improve on OpenBSD. diff --git a/tests/bench-pagealign_alloc.c b/tests/bench-pagealign_alloc.c index bdba5bfecf..3366fd100d 100644 --- a/tests/bench-pagealign_alloc.c +++ b/tests/bench-pagealign_alloc.c @@ -67,11 +67,15 @@ show_stats (intptr_t initial_as, intptr_t initial_data, int count) intptr_t requested = count * size_of_some_pages (); intptr_t as_increase = get_rusage_as () - initial_as; intptr_t data_increase = get_rusage_data () - initial_data; - printf ("count = %5d: requested: %6ld pages, allocated AS: %6ld pages (%.2f%%), allocated DATA: %6ld pages (%.2f%%)\n", + printf ("count = %5d: requested: %6ld pages, " + "allocated AS: %6ld pages (%.2f%%), " + "allocated DATA: %6ld pages (%.2f%%)\n", count, (long int) (requested / pagesize), - (long int) (as_increase / pagesize), 100 * (double) as_increase / (double) requested, - (long int) (data_increase / pagesize), 100 * (double) data_increase / (double) requested); + (long int) (as_increase / pagesize), + 100 * (double) as_increase / (double) requested, + (long int) (data_increase / pagesize), + 100 * (double) data_increase / (double) requested); } } @@ -99,7 +103,7 @@ main (int argc, char *argv[]) if (argc != 2) { fprintf (stderr, "Usage: %s TESTS\n", argv[0]); - fprintf (stderr, "Example: %s abcdef\n", argv[0]); + fprintf (stderr, "Example: %s {a|b|c|d|e|f}\n", argv[0]); exit (1); } -- 2.50.1
>From 978871e5386f09ba15615e46aee37ae2ee3e4707 Mon Sep 17 00:00:00 2001 From: Bruno Haible <[email protected]> Date: Sat, 13 Sep 2025 01:44:53 +0200 Subject: [PATCH 2/2] pagealign_alloc: Improve documentation. Suggested by Paul Eggert. * lib/pagealign_alloc.h: Document that this module is not multithread- safe. --- ChangeLog | 7 +++++++ lib/pagealign_alloc.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9b45e80a86..90adaefe81 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2025-09-12 Bruno Haible <[email protected]> + + pagealign_alloc: Improve documentation. + Suggested by Paul Eggert. + * lib/pagealign_alloc.h: Document that this module is not multithread- + safe. + 2025-09-12 Bruno Haible <[email protected]> pagealign_alloc: Tweak the benchmark. diff --git a/lib/pagealign_alloc.h b/lib/pagealign_alloc.h index e04d895b48..f07673839e 100644 --- a/lib/pagealign_alloc.h +++ b/lib/pagealign_alloc.h @@ -32,6 +32,9 @@ extern "C" { #endif +/* Note: The functions declared in this file are NOT multithread-safe. */ + + /* Free a memory block. PTR must be a non-NULL pointer returned by pagealign_alloc or pagealign_xalloc. */ -- 2.50.1
