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
parent 24b683fffc
commit 920784fc73
11 changed files with 26 additions and 0 deletions

View file

@ -15,6 +15,7 @@
#define atomic_fence atomic_thread_fence
/* clang-format off */
#define JEMALLOC_GENERATE_ATOMICS(type, short_type, \
/* unused */ lg_size) \
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, \
desired, success_mo, failure_mo); \
}
/* clang-format on */
/*
* 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, \
/* unused */ lg_size) \
typedef struct { \
@ -161,6 +162,7 @@ atomic_compare_exchange_strong_##short_type(atomic_##short_type##_t *a, \
return false; \
} \
}
/* clang-format on */
#define JEMALLOC_GENERATE_INT_ATOMICS(type, short_type, \
/* 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) \
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)( \
&a->repr, (ATOMIC_INTERLOCKED_REPR(lg_size))val); \
}
/* clang-format on */
#undef ATOMIC_INLINE

View file

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

View file

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

View file

@ -26,6 +26,7 @@
* two-stack tricks reverses orders in the lock-free first stack).
*/
/* clang-format off */
#define mpsc_queue(a_type) \
struct { \
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); \
}
/* clang-format on */
#endif /* JEMALLOC_INTERNAL_MPSC_QUEUE_H */

View file

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

View file

@ -8,6 +8,7 @@
* A simple seqlock implementation.
*/
/* clang-format off */
#define seq_define(type, short_type) \
typedef struct { \
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)); \
return true; \
}
/* clang-format on */
#endif /* JEMALLOC_INTERNAL_SEQ_H */

View file

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

View file

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

View file

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