From 328342cd737582216dc7b8b7d558b2a1bf8ea5e8 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 19 Oct 2020 12:37:53 -0400 Subject: [PATCH] port: namespace align.h with BT_ prefix MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ALIGN is defined in FreeBSD system includes with an incompatible signature, namespace our internal version. Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau Change-Id: Ib5b24a7194a0ddbe6eab9aa4f789c612886594f5 --- src/common/align.h | 30 +++++++++++----------- src/common/mmap-align.h | 4 +-- src/ctfser/ctfser.h | 2 +- src/plugins/ctf/common/bfcr/bfcr.c | 2 +- src/plugins/ctf/common/metadata/objstack.c | 2 +- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/common/align.h b/src/common/align.h index 21664986..a9c88de8 100644 --- a/src/common/align.h +++ b/src/common/align.h @@ -10,24 +10,24 @@ #include "compat/compiler.h" #include "compat/limits.h" -#define ALIGN(x, a) __ALIGN_MASK(x, (typeof(x))(a) - 1) -#define __ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) -#define PTR_ALIGN(p, a) ((typeof(p)) ALIGN((unsigned long) (p), a)) -#define ALIGN_FLOOR(x, a) __ALIGN_FLOOR_MASK(x, (typeof(x)) (a) - 1) -#define __ALIGN_FLOOR_MASK(x, mask) ((x) & ~(mask)) -#define PTR_ALIGN_FLOOR(p, a) \ - ((typeof(p)) ALIGN_FLOOR((unsigned long) (p), a)) -#define IS_ALIGNED(x, a) (((x) & ((typeof(x)) (a) - 1)) == 0) +#define BT_ALIGN(x, a) __BT_ALIGN_MASK(x, (typeof(x))(a) - 1) +#define __BT_ALIGN_MASK(x, mask) (((x) + (mask)) & ~(mask)) +#define BT_PTR_ALIGN(p, a) ((typeof(p)) BT_ALIGN((unsigned long) (p), a)) +#define BT_ALIGN_FLOOR(x, a) __BT_ALIGN_FLOOR_MASK(x, (typeof(x)) (a) - 1) +#define __BT_ALIGN_FLOOR_MASK(x, mask) ((x) & ~(mask)) +#define BT_PTR_ALIGN_FLOOR(p, a) \ + ((typeof(p)) BT_ALIGN_FLOOR((unsigned long) (p), a)) +#define BT_IS_ALIGNED(x, a) (((x) & ((typeof(x)) (a) - 1)) == 0) /* * Align pointer on natural object alignment. */ -#define object_align(obj) PTR_ALIGN(obj, __alignof__(*(obj))) -#define object_align_floor(obj) PTR_ALIGN_FLOOR(obj, __alignof__(*(obj))) +#define bt_object_align(obj) BT_PTR_ALIGN(obj, __alignof__(*(obj))) +#define bt_object_align_floor(obj) BT_PTR_ALIGN_FLOOR(obj, __alignof__(*(obj))) /** - * offset_align - Calculate the offset needed to align an object on its natural - * alignment towards higher addresses. + * bt_offset_align - Calculate the offset needed to align an object on its + * natural alignment towards higher addresses. * @align_drift: object offset from an "alignment"-aligned address. * @alignment: natural object alignment. Must be non-zero, power of 2. * @@ -42,14 +42,14 @@ }) /** - * offset_align_floor - Calculate the offset needed to align an object - * on its natural alignment towards lower addresses. + * bt_offset_align_floor - Calculate the offset needed to align an object + * on its natural alignment towards lower addresses. * @align_drift: object offset from an "alignment"-aligned address. * @alignment: natural object alignment. Must be non-zero, power of 2. * * Returns the offset that must be substracted to align towards lower addresses. */ -#define offset_align_floor(align_drift, alignment) \ +#define bt_offset_align_floor(align_drift, alignment) \ ({ \ MAYBE_BUILD_BUG_ON((alignment) == 0 \ || ((alignment) & ((alignment) - 1))); \ diff --git a/src/common/mmap-align.h b/src/common/mmap-align.h index 05ade732..7a5ed990 100644 --- a/src/common/mmap-align.h +++ b/src/common/mmap-align.h @@ -33,7 +33,7 @@ struct mmap_align { static inline off_t get_page_aligned_offset(off_t offset, int log_level) { - return ALIGN_FLOOR(offset, bt_mmap_get_offset_align_size(log_level)); + return BT_ALIGN_FLOOR(offset, bt_mmap_get_offset_align_size(log_level)); } static inline @@ -57,7 +57,7 @@ struct mmap_align *mmap_align(size_t length, int prot, * require a 2 pages page_aligned_length if the range crosses a page * boundary. */ - mma->page_aligned_length = ALIGN(length + offset - page_aligned_offset, page_size); + mma->page_aligned_length = BT_ALIGN(length + offset - page_aligned_offset, page_size); mma->page_aligned_addr = bt_mmap(NULL, mma->page_aligned_length, prot, flags, fd, page_aligned_offset, log_level); if (mma->page_aligned_addr == MAP_FAILED) { diff --git a/src/ctfser/ctfser.h b/src/ctfser/ctfser.h index caffaec8..b9e710d9 100644 --- a/src/ctfser/ctfser.h +++ b/src/ctfser/ctfser.h @@ -164,7 +164,7 @@ int bt_ctfser_align_offset_in_current_packet(struct bt_ctfser *ctfser, uint64_t align_size_bits; BT_ASSERT_DBG(alignment_bits > 0); - align_size_bits = ALIGN(ctfser->offset_in_cur_packet_bits, + align_size_bits = BT_ALIGN(ctfser->offset_in_cur_packet_bits, alignment_bits) - ctfser->offset_in_cur_packet_bits; if (G_UNLIKELY(!_bt_ctfser_has_space_left(ctfser, align_size_bits))) { diff --git a/src/plugins/ctf/common/bfcr/bfcr.c b/src/plugins/ctf/common/bfcr/bfcr.c index 9eb76dcb..e3c85179 100644 --- a/src/plugins/ctf/common/bfcr/bfcr.c +++ b/src/plugins/ctf/common/bfcr/bfcr.c @@ -968,7 +968,7 @@ size_t bits_to_skip_to_align_to(struct bt_bfcr *bfcr, size_t align) { size_t aligned_packet_at; - aligned_packet_at = ALIGN(packet_at(bfcr), align); + aligned_packet_at = BT_ALIGN(packet_at(bfcr), align); return aligned_packet_at - packet_at(bfcr); } diff --git a/src/plugins/ctf/common/metadata/objstack.c b/src/plugins/ctf/common/metadata/objstack.c index 2f05b4de..a730589d 100644 --- a/src/plugins/ctf/common/metadata/objstack.c +++ b/src/plugins/ctf/common/metadata/objstack.c @@ -112,7 +112,7 @@ void *objstack_alloc(struct objstack *objstack, size_t len) struct objstack_node *last_node; void *p; - len = ALIGN(len, OBJSTACK_ALIGN); + len = BT_ALIGN(len, OBJSTACK_ALIGN); /* Get last node */ last_node = bt_list_entry(objstack->head.prev, -- 2.34.1