util/macros: Import ALIGN_POT from ralloc.c
v2 (Jason Ekstrand): - Rename y to pot_align (Brian) - Also use ALIGN_POT in build_id.c and slab.c (Brian) Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Reviewed-by: Iago Toral Quiroga <itoral@igalia.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "build_id.h"
|
||||
#include "macros.h"
|
||||
|
||||
#ifndef NT_GNU_BUILD_ID
|
||||
#define NT_GNU_BUILD_ID 3
|
||||
@@ -37,8 +38,6 @@
|
||||
#define ElfW(type) Elf_##type
|
||||
#endif
|
||||
|
||||
#define ALIGN(val, align) (((val) + (align) - 1) & ~((align) - 1))
|
||||
|
||||
struct build_id_note {
|
||||
ElfW(Nhdr) nhdr;
|
||||
|
||||
@@ -90,8 +89,8 @@ build_id_find_nhdr_callback(struct dl_phdr_info *info, size_t size, void *data_)
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
@@ -285,6 +285,9 @@ do { \
|
||||
#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.
|
||||
|
@@ -553,8 +553,6 @@ ralloc_vasprintf_rewrite_tail(char **str, size_t *start, const char *fmt,
|
||||
* 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
|
||||
|
@@ -28,8 +28,6 @@
|
||||
#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
|
||||
|
||||
@@ -109,8 +107,8 @@ slab_create_parent(struct slab_parent_pool *parent,
|
||||
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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user