mirror of
https://github.com/ipxe/ipxe
synced 2025-12-22 21:11:03 +03:00
[linux] Make malloc and linux_umalloc valgrindable
Make the allocators used by malloc and linux_umalloc valgrindable. Include valgrind headers in the codebase to avoid a build dependency on valgrind. Signed-off-by: Piotr Jaroszyński <p.jaroszynski@gmail.com> Modified-by: Michael Brown <mcb30@ipxe.org> Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
committed by
Michael Brown
parent
3c1bdfd5d9
commit
b604e8a388
@@ -19,6 +19,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <ipxe/tables.h>
|
||||
#include <valgrind/memcheck.h>
|
||||
|
||||
extern size_t freemem;
|
||||
|
||||
@@ -39,7 +40,10 @@ extern void mdumpfree ( void );
|
||||
* @c align must be a power of two. @c size may not be zero.
|
||||
*/
|
||||
static inline void * __malloc malloc_dma ( size_t size, size_t phys_align ) {
|
||||
return alloc_memblock ( size, phys_align );
|
||||
void * ptr = alloc_memblock ( size, phys_align );
|
||||
if ( ptr && size )
|
||||
VALGRIND_MALLOCLIKE_BLOCK ( ptr, size, 0, 0 );
|
||||
return ptr;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,6 +59,7 @@ static inline void * __malloc malloc_dma ( size_t size, size_t phys_align ) {
|
||||
*/
|
||||
static inline void free_dma ( void *ptr, size_t size ) {
|
||||
free_memblock ( ptr, size );
|
||||
VALGRIND_FREELIKE_BLOCK ( ptr, 0 );
|
||||
}
|
||||
|
||||
/** A cache discarder */
|
||||
|
||||
Reference in New Issue
Block a user