Turn clang-format off for codes with multi-line commands in macros

This commit is contained in:
guangli-dai
2025-05-22 22:59:00 -07:00
committed by Qi Wang
parent 4531411abe
commit edaab8b3ad
11 changed files with 26 additions and 0 deletions

View File

@@ -15,6 +15,7 @@
#define atomic_fence atomic_thread_fence #define atomic_fence atomic_thread_fence
/* clang-format off */
#define JEMALLOC_GENERATE_ATOMICS(type, short_type, \ #define JEMALLOC_GENERATE_ATOMICS(type, short_type, \
/* unused */ lg_size) \ /* unused */ lg_size) \
typedef _Atomic(type) atomic_##short_type##_t; \ typedef _Atomic(type) atomic_##short_type##_t; \
@@ -59,6 +60,7 @@ atomic_compare_exchange_strong_##short_type(atomic_##short_type##_t *a, \
return atomic_compare_exchange_strong_explicit(a, expected, \ return atomic_compare_exchange_strong_explicit(a, expected, \
desired, success_mo, failure_mo); \ desired, success_mo, failure_mo); \
} }
/* clang-format on */
/* /*
* Integral types have some special operations available that non-integral ones * Integral types have some special operations available that non-integral ones

View File

@@ -87,6 +87,7 @@ atomic_post_sc_store_fence() {
} }
/* clang-format off */
#define JEMALLOC_GENERATE_ATOMICS(type, short_type, \ #define JEMALLOC_GENERATE_ATOMICS(type, short_type, \
/* unused */ lg_size) \ /* unused */ lg_size) \
typedef struct { \ typedef struct { \
@@ -161,6 +162,7 @@ atomic_compare_exchange_strong_##short_type(atomic_##short_type##_t *a, \
return false; \ return false; \
} \ } \
} }
/* clang-format on */
#define JEMALLOC_GENERATE_INT_ATOMICS(type, short_type, \ #define JEMALLOC_GENERATE_INT_ATOMICS(type, short_type, \
/* unused */ lg_size) \ /* unused */ lg_size) \

View File

@@ -118,6 +118,7 @@ atomic_compare_exchange_strong_##short_type(atomic_##short_type##_t *a, \
} }
/* clang-format off */
#define JEMALLOC_GENERATE_INT_ATOMICS(type, short_type, lg_size) \ #define JEMALLOC_GENERATE_INT_ATOMICS(type, short_type, lg_size) \
JEMALLOC_GENERATE_ATOMICS(type, short_type, lg_size) \ JEMALLOC_GENERATE_ATOMICS(type, short_type, lg_size) \
\ \
@@ -158,6 +159,7 @@ atomic_fetch_xor_##short_type(atomic_##short_type##_t *a, \
return (type)ATOMIC_INTERLOCKED_NAME(_InterlockedXor, lg_size)( \ return (type)ATOMIC_INTERLOCKED_NAME(_InterlockedXor, lg_size)( \
&a->repr, (ATOMIC_INTERLOCKED_REPR(lg_size))val); \ &a->repr, (ATOMIC_INTERLOCKED_REPR(lg_size))val); \
} }
/* clang-format on */
#undef ATOMIC_INLINE #undef ATOMIC_INLINE

View File

@@ -35,6 +35,7 @@ ffs_u(unsigned x) {
return JEMALLOC_INTERNAL_FFS(x) - 1; return JEMALLOC_INTERNAL_FFS(x) - 1;
} }
/* clang-format off */
#define DO_FLS_SLOW(x, suffix) do { \ #define DO_FLS_SLOW(x, suffix) do { \
util_assume(x != 0); \ util_assume(x != 0); \
x |= (x >> 1); \ x |= (x >> 1); \
@@ -58,6 +59,7 @@ ffs_u(unsigned x) {
} \ } \
return ffs_##suffix(x) - 1; \ return ffs_##suffix(x) - 1; \
} while(0) } while(0)
/* clang-format on */
static inline unsigned static inline unsigned
fls_llu_slow(unsigned long long x) { fls_llu_slow(unsigned long long x) {
@@ -118,6 +120,7 @@ fls_u(unsigned x) {
#define DO_BSR64(bit, x) bit = 0; unreachable() #define DO_BSR64(bit, x) bit = 0; unreachable()
#endif #endif
/* clang-format off */
#define DO_FLS(x) do { \ #define DO_FLS(x) do { \
if (x == 0) { \ if (x == 0) { \
return 8 * sizeof(x); \ return 8 * sizeof(x); \
@@ -144,6 +147,7 @@ fls_u(unsigned x) {
} \ } \
unreachable(); \ unreachable(); \
} while (0) } while (0)
/* clang-format on */
static inline unsigned static inline unsigned
fls_llu(unsigned long long x) { fls_llu(unsigned long long x) {
@@ -184,6 +188,7 @@ fls_u(unsigned x) {
# error "Haven't implemented popcount for 16-byte ints." # error "Haven't implemented popcount for 16-byte ints."
#endif #endif
/* clang-format off */
#define DO_POPCOUNT(x, type) do { \ #define DO_POPCOUNT(x, type) do { \
/* \ /* \
* Algorithm from an old AMD optimization reference manual. \ * Algorithm from an old AMD optimization reference manual. \
@@ -227,6 +232,7 @@ fls_u(unsigned x) {
x >>= ((sizeof(x) - 1) * 8); \ x >>= ((sizeof(x) - 1) * 8); \
return (unsigned)x; \ return (unsigned)x; \
} while(0) } while(0)
/* clang-format on */
static inline unsigned static inline unsigned
popcount_u_slow(unsigned bitmap) { popcount_u_slow(unsigned bitmap) {

View File

@@ -69,6 +69,7 @@ struct hpa_shard_opts_s {
uint64_t peak_demand_window_ms; uint64_t peak_demand_window_ms;
}; };
/* clang-format off */
#define HPA_SHARD_OPTS_DEFAULT { \ #define HPA_SHARD_OPTS_DEFAULT { \
/* slab_max_alloc */ \ /* slab_max_alloc */ \
64 * 1024, \ 64 * 1024, \
@@ -95,5 +96,6 @@ struct hpa_shard_opts_s {
/* peak_demand_window_ms */ \ /* peak_demand_window_ms */ \
0 \ 0 \
} }
/* clang-format on */
#endif /* JEMALLOC_INTERNAL_HPA_OPTS_H */ #endif /* JEMALLOC_INTERNAL_HPA_OPTS_H */

View File

@@ -26,6 +26,7 @@
* two-stack tricks reverses orders in the lock-free first stack). * two-stack tricks reverses orders in the lock-free first stack).
*/ */
/* clang-format off */
#define mpsc_queue(a_type) \ #define mpsc_queue(a_type) \
struct { \ struct { \
atomic_p_t tail; \ atomic_p_t tail; \
@@ -131,5 +132,6 @@ a_prefix##pop_batch(a_queue_type *queue, a_list_type *dst) { \
} \ } \
ql_concat(dst, &reversed, a_link); \ ql_concat(dst, &reversed, a_link); \
} }
/* clang-format on */
#endif /* JEMALLOC_INTERNAL_MPSC_QUEUE_H */ #endif /* JEMALLOC_INTERNAL_MPSC_QUEUE_H */

View File

@@ -38,6 +38,7 @@
*/ */
#define RB_MAX_DEPTH (sizeof(void *) << 4) #define RB_MAX_DEPTH (sizeof(void *) << 4)
/* clang-format off */
#ifdef RB_COMPACT #ifdef RB_COMPACT
/* Node structure. */ /* Node structure. */
#define rb_node(a_type) \ #define rb_node(a_type) \
@@ -1871,5 +1872,6 @@ a_prefix##reverse_iter_filtered(a_rbt_type *rbtree, a_type *start, \
return ret; \ return ret; \
} \ } \
) /* end rb_summarized_only */ ) /* end rb_summarized_only */
/* clang-format on */
#endif /* JEMALLOC_INTERNAL_RB_H */ #endif /* JEMALLOC_INTERNAL_RB_H */

View File

@@ -8,6 +8,7 @@
* A simple seqlock implementation. * A simple seqlock implementation.
*/ */
/* clang-format off */
#define seq_define(type, short_type) \ #define seq_define(type, short_type) \
typedef struct { \ typedef struct { \
atomic_zu_t seq; \ atomic_zu_t seq; \
@@ -52,5 +53,6 @@ seq_try_load_##short_type(type *dst, seq_##short_type##_t *src) { \
memcpy(dst, buf, sizeof(type)); \ memcpy(dst, buf, sizeof(type)); \
return true; \ return true; \
} }
/* clang-format on */
#endif /* JEMALLOC_INTERNAL_SEQ_H */ #endif /* JEMALLOC_INTERNAL_SEQ_H */

View File

@@ -32,6 +32,7 @@ TSD_DATA_FAST
TSD_DATA_SLOWER TSD_DATA_SLOWER
#undef O #undef O
/* clang-format off */
/* tsd_foop_get(tsd) returns a pointer to the thread-local instance of foo. */ /* tsd_foop_get(tsd) returns a pointer to the thread-local instance of foo. */
#define O(n, t, nt) \ #define O(n, t, nt) \
JEMALLOC_ALWAYS_INLINE t * \ JEMALLOC_ALWAYS_INLINE t * \
@@ -48,6 +49,7 @@ tsd_##n##p_get(tsd_t *tsd) { \
state == tsd_state_minimal_initialized); \ state == tsd_state_minimal_initialized); \
return tsd_##n##p_get_unsafe(tsd); \ return tsd_##n##p_get_unsafe(tsd); \
} }
/* clang-format on */
TSD_DATA_SLOW TSD_DATA_SLOW
TSD_DATA_FAST TSD_DATA_FAST
TSD_DATA_SLOWER TSD_DATA_SLOWER

View File

@@ -15,6 +15,7 @@
* and val3 for desired. * and val3 for desired.
*/ */
/* clang-format off */
#define DO_TESTS(t, ta, val1, val2, val3) do { \ #define DO_TESTS(t, ta, val1, val2, val3) do { \
t val; \ t val; \
t expected; \ t expected; \
@@ -174,6 +175,7 @@ typedef struct { \
DO_INTEGER_TESTS(t, ta, test.val1, test.val2); \ DO_INTEGER_TESTS(t, ta, test.val1, test.val2); \
} \ } \
} while (0) } while (0)
/* clang-format on */
TEST_STRUCT(uint64_t, u64); TEST_STRUCT(uint64_t, u64);
TEST_BEGIN(test_atomic_u64) { TEST_BEGIN(test_atomic_u64) {

View File

@@ -226,6 +226,7 @@ expand_byte_to_mask(unsigned byte) {
return result; return result;
} }
/* clang-format off */
#define TEST_POPCOUNT(t, suf, pri_hex) do { \ #define TEST_POPCOUNT(t, suf, pri_hex) do { \
t bmul = (t)0x0101010101010101ULL; \ t bmul = (t)0x0101010101010101ULL; \
for (unsigned i = 0; i < (1 << sizeof(t)); i++) { \ for (unsigned i = 0; i < (1 << sizeof(t)); i++) { \
@@ -245,6 +246,7 @@ expand_byte_to_mask(unsigned byte) {
} \ } \
} \ } \
} while (0) } while (0)
/* clang-format on */
TEST_BEGIN(test_popcount_u) { TEST_BEGIN(test_popcount_u) {
TEST_POPCOUNT(unsigned, u, "x"); TEST_POPCOUNT(unsigned, u, "x");