port: namespace align.h with BT_ prefix
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 19 Oct 2020 16:37:53 +0000 (12:37 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 19 Feb 2021 18:57:19 +0000 (13:57 -0500)
ALIGN is defined in FreeBSD system includes with an incompatible
signature, namespace our internal version.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I2d7e24ebb1756b0e115118fa3f2e6ebc8595fea5

src/common/align.h
src/common/mmap-align.h
src/ctfser/ctfser.h
src/plugins/ctf/common/bfcr/bfcr.c
src/plugins/ctf/common/metadata/objstack.c

index d27b5b5368cc8b4079cdb7be1a46fb8a3c0d8898..c76393f0618b7e08f7a50b4ff42987bd6f91b4db 100644 (file)
 #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.
  *
        })
 
 /**
- * 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)));      \
index c42cdeb34da234b02490db1f0cf25c6fe877893f..1e0215311af9e2c2fceaba6d63cd1ba67f77eeff 100644 (file)
@@ -49,7 +49,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
@@ -73,7 +73,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) {
index ac71eac87a67e95040febff7f61cf71e08e5450c..09def17ee783967e1dc53897f478ba540e9337d7 100644 (file)
@@ -180,7 +180,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))) {
index a95079e154d5dbf15bb3e7db27a8b6eab222e6e3..a21e87cb8138bcb1c0a944a548f7e2be45354d36 100644 (file)
@@ -984,7 +984,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);
 }
 
index 5919fa13f481088c25760ba4986f245d7c3449b7..ebf5b5c935a92d06af5bc31e214d6ea73c76567c 100644 (file)
@@ -130,7 +130,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,
This page took 0.027538 seconds and 4 git commands to generate.