mirror of
https://github.com/ipxe/ipxe
synced 2025-12-25 00:17:57 +03:00
[malloc] Add cache discard mechanism
Add a facility allowing cached data to be discarded in order to satisfy memory allocations that would otherwise fail. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -18,6 +18,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
||||
*
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <ipxe/tables.h>
|
||||
|
||||
extern size_t freemem;
|
||||
|
||||
@@ -56,4 +57,20 @@ static inline void free_dma ( void *ptr, size_t size ) {
|
||||
free_memblock ( ptr, size );
|
||||
}
|
||||
|
||||
/** A cache discarder */
|
||||
struct cache_discarder {
|
||||
/**
|
||||
* Discard some cached data
|
||||
*
|
||||
* @ret discarded Number of cached items discarded
|
||||
*/
|
||||
unsigned int ( * discard ) ( void );
|
||||
};
|
||||
|
||||
/** Cache discarder table */
|
||||
#define CACHE_DISCARDERS __table ( struct cache_discarder, "cache_discarders" )
|
||||
|
||||
/** Declare a cache discarder */
|
||||
#define __cache_discarder __table_entry ( CACHE_DISCARDERS, 01 )
|
||||
|
||||
#endif /* _IPXE_MALLOC_H */
|
||||
|
||||
Reference in New Issue
Block a user