]> Savannah Git Hosting - gnulib.git/commit
malloc etc. tests: use volatile more consistently
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Nov 2024 17:38:03 +0000 (09:38 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Nov 2024 17:40:29 +0000 (09:40 -0800)
commit41be6842b56b2e83fb84be025a62c2dd1521af83
tree48b20adde7e002acd4068be0548b5e02ca941c08
parenta1da46a05cc65842021511bd6d68560b0240eec7
malloc etc. tests: use volatile more consistently

Typically it’s ineffective to use ‘void *volatile p’
when testing malloc and similar functions, as the compiler
can optimize the call to malloc before assigning the result
to the volatile pointer variable.  Instead, be more systematic
about calling malloc through a volatile function pointer
so that the compiler cannot infer that it is a malloc call.
This fix can’t be done for alloca-like functions which may not
have a function address, so continue to trust to luck there.
* tests/test-aligned-malloc.c (aligned4_malloc, aligned4_free)
(aligned8_malloc, aligned8_free, aligned16_malloc)
(aligned16_free, aligned32_malloc, aligned32_free):
* tests/test-aligned_alloc.c (aligned_alloc):
* tests/test-calloc-gnu.c (calloc):
* tests/test-free.c (free):
* tests/test-malloc-gnu.c (malloc):
* tests/test-reallocarray.c (reallocarray):
Test indirectly, by calling through a volatile pointer.
* tests/test-aligned-malloc.c, tests/test-aligned_alloc.c:
* tests/test-calloc-gnu.c, tests/test-calloc-posix.c:
* tests/test-free.c, tests/test-malloc-gnu.c:
* tests/test-malloc-posix.c, tests/test-realloc-posix.c:
* tests/test-reallocarray.c:
(main) Don’t bother making data pointers olatile, as it’s ineffective.
* tests/test-calloc-gnu.c (identity):
* tests/test-free.c (get_errno, get_errno_func):
Remove; all uses removed.
ChangeLog
tests/test-aligned-malloc.c
tests/test-aligned_alloc.c
tests/test-calloc-gnu.c
tests/test-calloc-posix.c
tests/test-free.c
tests/test-malloc-gnu.c
tests/test-malloc-posix.c
tests/test-realloc-posix.c
tests/test-reallocarray.c