Commit dd83ab95 authored by (no author)'s avatar (no author) Committed by Jens Gustedt
Browse files

whitespace

parent fe262517
......@@ -1167,36 +1167,36 @@ p99_extension
**
** @see atomic_int
**/
#define atomic_compare_exchange_weak(OBJP, EXPECTED, DESIRED) \
p99_extension \
({ \
P99_MACRO_PVAR(p00_objp, (OBJP)); \
typedef __typeof__(P00_AT(p00_objp)) p00_base_t; \
typedef __typeof__(P00_AX(p00_objp)) p00_ubase_t; \
/* Both, *EXPECTED and DESIRED must be assignment compatible with the base type */ \
register p00_base_t* const p00_exp = (EXPECTED); \
register p00_ubase_t const p00_des = { .p00_t = (DESIRED) }; \
register _Bool p00_ret = false; \
if (!atomic_is_lock_free(p00_objp)) { \
P99_SPIN_EXCLUDE(&p00_objp->p00_lock) { \
p00_ret = !memcmp(P00_CVT(p00_exp), P00_CVT(&P00_AT(p00_objp)), sizeof *p00_exp); \
if (p00_ret) P00_AT(p00_objp) = p00_des.p00_t; \
else *p00_exp = P00_AT(p00_objp); \
} \
} \
P99_IF_EMPTY(P99_ATOMIC_LOCK_FREE_TYPES) \
(else p00_ret = false;) \
(else { \
register p00_ubase_t p00_expm = { .p00_t = *p00_exp, }; \
register p00_ubase_t const p00_valm \
= { .p00_m = P00_ATOMIC_TERN \
(p00_objp, \
__sync_val_compare_and_swap(&P00_AM(p00_objp), p00_expm.p00_m, p00_des.p00_m), \
0) }; \
p00_ret = (p00_expm.p00_m == p00_valm.p00_m); \
if (!p00_ret) *p00_exp = p00_valm.p00_t; \
}) \
p00_ret; \
#define atomic_compare_exchange_weak(OBJP, EXPECTED, DESIRED) \
p99_extension \
({ \
P99_MACRO_PVAR(p00_objp, (OBJP)); \
typedef __typeof__(P00_AT(p00_objp)) p00_base_t; \
typedef __typeof__(P00_AX(p00_objp)) p00_ubase_t; \
/* Both, *EXPECTED and DESIRED must be assignment compatible with the base type */ \
register p00_base_t* const p00_exp = (EXPECTED); \
register p00_ubase_t const p00_des = { .p00_t = (DESIRED) }; \
register _Bool p00_ret = false; \
if (!atomic_is_lock_free(p00_objp)) { \
P99_SPIN_EXCLUDE(&p00_objp->p00_lock) { \
p00_ret = !memcmp(P00_CVT(p00_exp), P00_CVT(&P00_AT(p00_objp)), sizeof *p00_exp); \
if (p00_ret) P00_AT(p00_objp) = p00_des.p00_t; \
else *p00_exp = P00_AT(p00_objp); \
} \
} \
P99_IF_EMPTY(P99_ATOMIC_LOCK_FREE_TYPES) \
(else p00_ret = false;) \
(else { \
register p00_ubase_t p00_expm = { .p00_t = *p00_exp, }; \
register p00_ubase_t const p00_valm \
= { .p00_m = P00_ATOMIC_TERN \
(p00_objp, \
__sync_val_compare_and_swap(&P00_AM(p00_objp), p00_expm.p00_m, p00_des.p00_m), \
0) }; \
p00_ret = (p00_expm.p00_m == p00_valm.p00_m); \
if (!p00_ret) *p00_exp = p00_valm.p00_t; \
}) \
p00_ret; \
})
#ifdef P00_DOXYGEN
......
......@@ -598,7 +598,7 @@ static char const*const p00_getopt_synopsis = { LINE }
** @param CALLBACK must be assignment compatible to a pointer to
** ::p99_callback_void_func.
**/
#define P99_GETOPT_CALLBACK(CALLBACK) \
#define P99_GETOPT_CALLBACK(CALLBACK) \
static p99_callback_void_func*const p00_getopt_callback = (CALLBACK)
......
......@@ -54,15 +54,15 @@ P00_DOCUMENT_PERMITTED_ARGUMENT(P99_LIFO_TOP, 0)
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_LIFO_PUSH, 0)
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_LIFO_PUSH, 1)
#define P99_LIFO_PUSH(L, EL) \
p99_extension \
({ \
register const P99_MACRO_VAR(p00_l, (L)); \
register P99_TP_TYPE(p00_l)*const p00_rr = (EL); \
#define P99_LIFO_PUSH(L, EL) \
p99_extension \
({ \
register const P99_MACRO_VAR(p00_l, (L)); \
register P99_TP_TYPE(p00_l)*const p00_rr = (EL); \
P99_TP_TYPE_STATE(p00_l) p00_state = P99_TP_STATE_INITIALIZER(p00_l, p00_rr); \
do { \
p00_rr->p99_lifo = P99_TP_STATE_GET(&p00_state); \
} while (!P99_TP_STATE_COMMIT(&p00_state)); \
do { \
p00_rr->p99_lifo = P99_TP_STATE_GET(&p00_state); \
} while (!P99_TP_STATE_COMMIT(&p00_state)); \
})
/**
......@@ -106,20 +106,20 @@ p99_extension \
** @see P99_LIFO_PUSH
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_LIFO_POP, 0)
#define P99_LIFO_POP(L) \
p99_extension \
({ \
register const P99_MACRO_VAR(p00_l, (L)); \
P99_TP_TYPE_STATE(p00_l) p00_state = P99_TP_STATE_INITIALIZER(p00_l, 0); \
/* be sure that the result can not be used as an lvalue */ \
register P99_TP_TYPE(p00_l)* p00_r = P99_TP_STATE_GET(&p00_state); \
for (; p00_r; p00_r = P99_TP_STATE_GET(&p00_state)) { \
P99_TP_STATE_SET(&p00_state, p00_r->p99_lifo); \
if (P99_TP_STATE_COMMIT(&p00_state)) \
break; \
} \
if (p00_r) p00_r->p99_lifo = 0; \
p00_r; \
#define P99_LIFO_POP(L) \
p99_extension \
({ \
register const P99_MACRO_VAR(p00_l, (L)); \
P99_TP_TYPE_STATE(p00_l) p00_state = P99_TP_STATE_INITIALIZER(p00_l, 0); \
/* be sure that the result can not be used as an lvalue */ \
register P99_TP_TYPE(p00_l)* p00_r = P99_TP_STATE_GET(&p00_state); \
for (; p00_r; p00_r = P99_TP_STATE_GET(&p00_state)) { \
P99_TP_STATE_SET(&p00_state, p00_r->p99_lifo); \
if (P99_TP_STATE_COMMIT(&p00_state)) \
break; \
} \
if (p00_r) p00_r->p99_lifo = 0; \
p00_r; \
})
#define P00_LIFO_REVERT(L) \
......@@ -147,18 +147,18 @@ p99_extension \
** @see P99_LIFO_TOP
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_LIFO_CLEAR, 0)
#define P99_LIFO_CLEAR(L) \
p99_extension \
({ \
register const P99_MACRO_VAR(p00_l, (L)); \
P99_TP_TYPE_STATE(p00_l) p00_state = P99_TP_STATE_INITIALIZER(p00_l, 0); \
/* be sure that the result can not be used as an lvalue */ \
register P99_TP_TYPE(p00_l)* p00_r = P99_TP_STATE_GET(&p00_state); \
for (; p00_r; p00_r = P99_TP_STATE_GET(&p00_state)) { \
if (P99_TP_STATE_COMMIT(&p00_state)) \
break; \
} \
p00_r; \
#define P99_LIFO_CLEAR(L) \
p99_extension \
({ \
register const P99_MACRO_VAR(p00_l, (L)); \
P99_TP_TYPE_STATE(p00_l) p00_state = P99_TP_STATE_INITIALIZER(p00_l, 0); \
/* be sure that the result can not be used as an lvalue */ \
register P99_TP_TYPE(p00_l)* p00_r = P99_TP_STATE_GET(&p00_state); \
for (; p00_r; p00_r = P99_TP_STATE_GET(&p00_state)) { \
if (P99_TP_STATE_COMMIT(&p00_state)) \
break; \
} \
p00_r; \
})
#else
......
......@@ -2,7 +2,7 @@
/* */
/* Except for parts copied from previous work and as explicitly stated below, */
/* the authors and copyright holders for this work are as follows: */
/* (C) copyright 2010-2012 Jens Gustedt, INRIA, France */
/* (C) copyright 2010-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......
......@@ -61,7 +61,7 @@ struct p00_tp_state {
p99_inline
p00_tp_state p00_tp_p2i(void * p00_val, uintptr_t p00_tag) {
return (p00_tp_state){ .p00_tag = p00_tag, .p00_val = p00_val, };
return (p00_tp_state) { .p00_tag = p00_tag, .p00_val = p00_val, };
}
p99_inline
......@@ -140,7 +140,7 @@ p99_tp_state p99_tp_state_initializer(p99_tp* p00_tp, void* p00_p) {
uintptr_t p00_tic = atomic_fetch_add(&p00_tp->p00_tic, UINTPTR_C(1));
return (p99_tp_state) {
.p00_val = p00_tp_get(p00_tp),
.p00_next = p00_tp_p2i(p00_p, p00_tic),
.p00_next = p00_tp_p2i(p00_p, p00_tic),
.p00_tp = p00_tp,
};
}
......@@ -176,18 +176,18 @@ bool p99_tp_state_commit(p99_tp_state* p00_state) {
# define P99_TP(T) P99_PASTE2(p00_tp_, T)
# define P99_TP_STATE(T) P99_PASTE2(p00_tp_state_, T)
# define P99_TP_DECLARE(T) \
typedef union P99_TP(T) P99_TP(T); \
typedef union P99_TP_STATE(T) P99_TP_STATE(T); \
_Alignas(sizeof(p00_tp_state)) union P99_TP(T) { \
p99_tp p00_tp; \
T p00_dum; /* we only need this for its type */ \
P99_TP_STATE(T)* p00_mud; /* we only need this for its type */ \
}; \
_Alignas(sizeof(p00_tp_state)) union P99_TP_STATE(T) { \
p99_tp_state p00_st; \
T p00_dum; /* we only need this for its type */ \
P99_TP(T)* p00_mud; /* we only need this for its type */ \
# define P99_TP_DECLARE(T) \
typedef union P99_TP(T) P99_TP(T); \
typedef union P99_TP_STATE(T) P99_TP_STATE(T); \
_Alignas(sizeof(p00_tp_state)) union P99_TP(T) { \
p99_tp p00_tp; \
T p00_dum; /* we only need this for its type */ \
P99_TP_STATE(T)* p00_mud; /* we only need this for its type */ \
}; \
_Alignas(sizeof(p00_tp_state)) union P99_TP_STATE(T) { \
p99_tp_state p00_st; \
T p00_dum; /* we only need this for its type */ \
P99_TP(T)* p00_mud; /* we only need this for its type */ \
}
# define P99_TP_TYPE(TP) __typeof__(*(TP)->p00_dum)
......@@ -201,45 +201,45 @@ _Alignas(sizeof(p00_tp_state)) union P99_TP_STATE(T) { \
** @brief Load the value of @a TP into the state variable and
** prepare it to commit value @a P later.
**/
#define P99_TP_STATE_INITIALIZER(TP, P) \
p99_extension ({ \
P99_MACRO_VAR(p00_tp, (TP)); \
/* ensure that P is assignment compatible to the */ \
/* base type, and that the return can't be used as lvalue */ \
register P99_TP_TYPE(p00_tp)* const p00_p = (P); \
register P99_TP_TYPE_STATE(p00_tp) const p00_r = { \
.p00_st = p99_tp_state_initializer(&p00_tp->p00_tp, p00_p), \
}; \
p00_r; \
#define P99_TP_STATE_INITIALIZER(TP, P) \
p99_extension ({ \
P99_MACRO_VAR(p00_tp, (TP)); \
/* ensure that P is assignment compatible to the */ \
/* base type, and that the return can't be used as lvalue */ \
register P99_TP_TYPE(p00_tp)* const p00_p = (P); \
register P99_TP_TYPE_STATE(p00_tp) const p00_r = { \
.p00_st = p99_tp_state_initializer(&p00_tp->p00_tp, p00_p), \
}; \
p00_r; \
})
#define P99_TP_GET(TP) \
p99_extension ({ \
P99_MACRO_VAR(p00_tp, (TP)); \
/* ensure that pointer that is returned is converted to the */ \
/* base type, and that the return can't be used as lvalue */ \
register P99_TP_TYPE(p00_tp)* const p00_r \
= p99_tp_get(&p00_tp->p00_tp); \
p00_r; \
#define P99_TP_GET(TP) \
p99_extension ({ \
P99_MACRO_VAR(p00_tp, (TP)); \
/* ensure that pointer that is returned is converted to the */ \
/* base type, and that the return can't be used as lvalue */ \
register P99_TP_TYPE(p00_tp)* const p00_r \
= p99_tp_get(&p00_tp->p00_tp); \
p00_r; \
})
#define P99_TP_STATE_GET(TPS) \
p99_extension ({ \
P99_MACRO_VAR(p00_tps, (TPS)); \
/* ensure that pointer that is returned is converted to the */ \
/* base type, and that the return can't be used as lvalue */ \
register P99_TP_STATE_TYPE(p00_tps)* const p00_r \
= p99_tp_state_get(&p00_tps->p00_st); \
p00_r; \
#define P99_TP_STATE_GET(TPS) \
p99_extension ({ \
P99_MACRO_VAR(p00_tps, (TPS)); \
/* ensure that pointer that is returned is converted to the */ \
/* base type, and that the return can't be used as lvalue */ \
register P99_TP_STATE_TYPE(p00_tps)* const p00_r \
= p99_tp_state_get(&p00_tps->p00_st); \
p00_r; \
})
#define P99_TP_STATE_SET(TPS, P) \
p99_extension ({ \
P99_MACRO_VAR(p00_tps, (TPS)); \
/* ensure that P is assignment compatible to the */ \
/* base type, and that the return can't be used as lvalue */ \
register P99_TP_STATE_TYPE(p00_tps)* p00_p = (P); \
p99_tp_state_set(&p00_tps->p00_st, p00_p); \
#define P99_TP_STATE_SET(TPS, P) \
p99_extension ({ \
P99_MACRO_VAR(p00_tps, (TPS)); \
/* ensure that P is assignment compatible to the */ \
/* base type, and that the return can't be used as lvalue */ \
register P99_TP_STATE_TYPE(p00_tps)* p00_p = (P); \
p99_tp_state_set(&p00_tps->p00_st, p00_p); \
})
#define P99_TP_STATE_COMMIT(TPS) p99_tp_state_commit(&(TPS)->p00_st)
......
......@@ -242,7 +242,7 @@ typedef struct p99_tss p99_tss;
p99_inline
p99_tss* p99_tss_init(p99_tss* p00_el, tss_dtor_t p00_f) {
if (p00_el) {
*p00_el = (p99_tss){ .p99_dtor = p00_f, };
*p00_el = (p99_tss) { .p99_dtor = p00_f, };
atomic_flag_clear(&p00_el->p00_flg);
}
return p00_el;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment