Clearer macro conditions
This commit is contained in:
parent
de6aee3a3a
commit
f29035319c
1 changed files with 13 additions and 14 deletions
|
|
@ -5,27 +5,26 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Fiddle these around according to your need. Delete or check makefile */
|
||||
#ifdef FREELIST_NOALIGN
|
||||
#define ALIGN(x) (x)
|
||||
#else // FREELIST_NOALIGN
|
||||
|
||||
/* Align to nearest multiple of sizeof(void*) */
|
||||
static inline size_t align_up(size_t n) {
|
||||
return (n + sizeof(void *) - 1) & ~(sizeof(void *) - 1);
|
||||
/* Align to nearest multiple of align */
|
||||
static inline size_t align_up_to(size_t n, size_t align) {
|
||||
return (n + align - 1) & ~(align - 1);
|
||||
}
|
||||
|
||||
#define ALIGN(x) (align_up(x))
|
||||
#endif // FREELIST_NOALIGN
|
||||
/* Fiddle these around according to your need. Delete or check makefile */
|
||||
#ifdef FREELIST_ALIGN
|
||||
#define ALIGN(x) (align_up_to(x, sizeof(void *)))
|
||||
#else
|
||||
#define ALIGN(x) (x)
|
||||
#endif
|
||||
|
||||
typedef struct FreeListBlock FreeListBlock;
|
||||
|
||||
typedef struct {
|
||||
uintptr_t start;
|
||||
uintptr_t end;
|
||||
FreeListBlock *free;
|
||||
size_t size;
|
||||
size_t allocated;
|
||||
uintptr_t start;
|
||||
uintptr_t end;
|
||||
size_t size;
|
||||
size_t allocated;
|
||||
} FreeList;
|
||||
|
||||
int fl_init(FreeList *fl, uintptr_t start, uintptr_t end, size_t itemsize);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue