1 #ifndef _ALLOC_H_ 2 #define _ALLOC_H_ 3 /* 4 * alloc supplies three ingredients to the test framework that are all 5 * related to the support of dynamic memory allocation. 6 * 7 * The first is a set of alloc function wrappers for malloc and its 8 * friends. Using wrappers allows test code and common code to use the 9 * same interface for memory allocation at all stages, even though the 10 * implementations may change with the stage, e.g. pre/post paging. 11 * 12 * The second is a set of implementations for the alloc function 13 * interfaces. These implementations are named early_*, as they can be 14 * used almost immediately by the test framework. 15 * 16 * The third is a very simple physical memory allocator, which the 17 * early_* alloc functions build on. 18 * 19 * Copyright (C) 2014, Red Hat Inc, Andrew Jones <drjones@redhat.com> 20 * 21 * This work is licensed under the terms of the GNU LGPL, version 2. 22 */ 23 #include "libcflat.h" 24 25 struct alloc_ops { 26 void *(*memalign)(size_t alignment, size_t size); 27 void (*free)(void *ptr); 28 }; 29 30 extern struct alloc_ops *alloc_ops; 31 32 void *malloc(size_t size); 33 void *calloc(size_t nmemb, size_t size); 34 void free(void *ptr); 35 void *memalign(size_t alignment, size_t size); 36 37 #endif /* _ALLOC_H_ */ 38