#include <string.h>
#include "build_id.h"
+#include "macros.h"
#ifndef NT_GNU_BUILD_ID
#define NT_GNU_BUILD_ID 3
#define ElfW(type) Elf_##type
#endif
-#define ALIGN(val, align) (((val) + (align) - 1) & ~((align) - 1))
-
struct build_id_note {
ElfW(Nhdr) nhdr;
}
size_t offset = sizeof(ElfW(Nhdr)) +
- ALIGN(note->nhdr.n_namesz, 4) +
- ALIGN(note->nhdr.n_descsz, 4);
+ ALIGN_POT(note->nhdr.n_namesz, 4) +
+ ALIGN_POT(note->nhdr.n_descsz, 4);
note = (struct build_id_note *)((char *)note + offset);
len -= offset;
}
#define MIN3( A, B, C ) ((A) < (B) ? MIN2(A, C) : MIN2(B, C))
#define MAX3( A, B, C ) ((A) > (B) ? MAX2(A, C) : MAX2(B, C))
+/** Align a value to a power of two */
+#define ALIGN_POT(x, pot_align) (((x) + (pot_align) - 1) & ~((pot_align) - 1))
+
/**
* Macro for declaring an explicit conversion operator. Defaults to an
* implicit conversion if C++11 is not supported.
* other buffers.
*/
-#define ALIGN_POT(x, y) (((x) + (y) - 1) & ~((y) - 1))
-
#define MIN_LINEAR_BUFSIZE 2048
#define SUBALLOC_ALIGNMENT sizeof(uintptr_t)
#define LMAGIC 0x87b9c7d3
#include <stdbool.h>
#include <string.h>
-#define ALIGN(value, align) (((value) + (align) - 1) & ~((align) - 1))
-
#define SLAB_MAGIC_ALLOCATED 0xcafe4321
#define SLAB_MAGIC_FREE 0x7ee01234
unsigned num_items)
{
mtx_init(&parent->mutex, mtx_plain);
- parent->element_size = ALIGN(sizeof(struct slab_element_header) + item_size,
- sizeof(intptr_t));
+ parent->element_size = ALIGN_POT(sizeof(struct slab_element_header) + item_size,
+ sizeof(intptr_t));
parent->num_elements = num_items;
}