tst-malloc-aux.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Wrappers for malloc-like functions to allow testing the implementation
  2. without optimization.
  3. Copyright (C) 2024-2026 Free Software Foundation, Inc.
  4. This file is part of the GNU C Library.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public License as
  7. published by the Free Software Foundation; either version 2.1 of the
  8. License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; see the file COPYING.LIB. If
  15. not, see <https://www.gnu.org/licenses/>. */
  16. #ifndef TST_MALLOC_AUX_H
  17. #define TST_MALLOC_AUX_H
  18. #include <stddef.h>
  19. #include <stdlib.h>
  20. #include <malloc.h>
  21. static __typeof (aligned_alloc) * volatile aligned_alloc_indirect
  22. = aligned_alloc;
  23. static __typeof (calloc) * volatile calloc_indirect = calloc;
  24. static __typeof (malloc) * volatile malloc_indirect = malloc;
  25. static __typeof (memalign) * volatile memalign_indirect = memalign;
  26. static __typeof (posix_memalign) * volatile posix_memalign_indirect
  27. = posix_memalign;
  28. static __typeof (pvalloc) * volatile pvalloc_indirect = pvalloc;
  29. static __typeof (realloc) * volatile realloc_indirect = realloc;
  30. static __typeof (valloc) * volatile valloc_indirect = valloc;
  31. static __typeof (reallocarray) * volatile reallocarray_indirect = reallocarray;
  32. #undef aligned_alloc
  33. #undef calloc
  34. #undef malloc
  35. #undef memalign
  36. #undef posix_memalign
  37. #undef pvalloc
  38. #undef realloc
  39. #undef valloc
  40. #undef reallocarray
  41. #define aligned_alloc aligned_alloc_indirect
  42. #define calloc calloc_indirect
  43. #define malloc malloc_indirect
  44. #define memalign memalign_indirect
  45. #define posix_memalign posix_memalign_indirect
  46. #define pvalloc pvalloc_indirect
  47. #define realloc realloc_indirect
  48. #define valloc valloc_indirect
  49. #define reallocarray reallocarray_indirect
  50. #endif /* TST_MALLOC_AUX_H */