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

whitespace and copyright update

parent dd41b304
......@@ -754,14 +754,14 @@ P00_DOCUMENT_TYPE_ARGUMENT(P99_ATOMIC_INHERIT, 0)
p99_inline
P99_CONST_FUNCTION uintptr_t p00_exchange_ignore(void* p00_x, ...) { P99_UNUSED(p00_x); return 0; }
#define P00_EXCHANGE(X) \
P99_GENERIC_SIZE \
(sizeof(X), \
p00_exchange_ignore, \
(1, p00_atomic_exchange_1), \
(2, p00_atomic_exchange_2), \
(4, p00_atomic_exchange_4) \
P99_IF_EQ_2(ATOMIC_INT64_LOCK_FREE)(,(8, p00_atomic_exchange_8))() \
#define P00_EXCHANGE(X) \
P99_GENERIC_SIZE \
(sizeof(X), \
p00_exchange_ignore, \
(1, p00_atomic_exchange_1), \
(2, p00_atomic_exchange_2), \
(4, p00_atomic_exchange_4) \
P99_IF_EQ_2(ATOMIC_INT64_LOCK_FREE)(,(8, p00_atomic_exchange_8))() \
P99_IF_EQ_2(ATOMIC_INT128_LOCK_FREE)(,(16, p00_atomic_exchange_16))() \
)
......@@ -1013,26 +1013,26 @@ p99_extension \
**/
#define atomic_exchange_explicit(OBJP, DESIRED, ORD)
#else
#define atomic_exchange_explicit(OBJP, DESIRED, ORD) \
p99_extension \
({ \
P99_MACRO_PVAR(p00_objp, (OBJP), volatile); \
typedef __typeof__(P00_AT(p00_objp)) p00_base_t; \
typedef __typeof__(P00_AX(p00_objp)) p00_ubase_t; \
register p00_base_t const p00_des = (DESIRED); \
register p00_ubase_t p00_ret = P99_INIT; \
if (!atomic_is_lock_free(p00_objp)) { \
P99_SPIN_EXCLUDE(&p00_objp->p00_lock) { \
p00_ret.p00_t = P00_AT(p00_objp); \
P00_AT(p00_objp) = p00_des; \
} \
} else { \
P99_IF_EMPTY(P99_ATOMIC_LOCK_FREE_TYPES) \
() \
(register p00_ubase_t const p00_desm = { .p00_t = p00_des }; \
#define atomic_exchange_explicit(OBJP, DESIRED, ORD) \
p99_extension \
({ \
P99_MACRO_PVAR(p00_objp, (OBJP), volatile); \
typedef __typeof__(P00_AT(p00_objp)) p00_base_t; \
typedef __typeof__(P00_AX(p00_objp)) p00_ubase_t; \
register p00_base_t const p00_des = (DESIRED); \
register p00_ubase_t p00_ret = P99_INIT; \
if (!atomic_is_lock_free(p00_objp)) { \
P99_SPIN_EXCLUDE(&p00_objp->p00_lock) { \
p00_ret.p00_t = P00_AT(p00_objp); \
P00_AT(p00_objp) = p00_des; \
} \
} else { \
P99_IF_EMPTY(P99_ATOMIC_LOCK_FREE_TYPES) \
() \
(register p00_ubase_t const p00_desm = { .p00_t = p00_des }; \
p00_ret.p00_m = p00_atomic_exchange_n(&P00_AM(p00_objp), p00_desm.p00_m, (ORD))); \
} \
p00_ret.p00_t; \
} \
p00_ret.p00_t; \
})
#endif
......@@ -1047,7 +1047,7 @@ p99_extension
** @see atomic_int
** @see atomic_exchange_explicit
**/
#define atomic_exchange(OBJP, DESIRED) \
#define atomic_exchange(OBJP, DESIRED) \
atomic_exchange_explicit((OBJP), (DESIRED), memory_order_seq_cst)
......@@ -1062,21 +1062,21 @@ atomic_exchange_explicit((OBJP), (DESIRED), memory_order_seq_cst)
**
** @see atomic_int
**/
#define atomic_load_explicit(OBJP, ORD) \
p99_extension \
({ \
P99_MACRO_PVAR(p00_objp, (OBJP), volatile); \
typedef __typeof__(P00_AX(p00_objp)) p00_ubase_t; \
register p00_ubase_t p00_ret = P99_INIT; \
if (!atomic_is_lock_free(p00_objp)) { \
P99_SPIN_EXCLUDE(&p00_objp->p00_lock) \
p00_ret.p00_t = P00_AT(p00_objp); \
} else { \
P99_IF_EMPTY(P99_ATOMIC_LOCK_FREE_TYPES) \
(P00_AT(p00_objp)) \
(p00_ret.p00_m = p00_atomic_load_n(&P00_AM(p00_objp), (ORD))); \
} \
p00_ret.p00_t = p00_ret.p00_t; \
#define atomic_load_explicit(OBJP, ORD) \
p99_extension \
({ \
P99_MACRO_PVAR(p00_objp, (OBJP), volatile); \
typedef __typeof__(P00_AX(p00_objp)) p00_ubase_t; \
register p00_ubase_t p00_ret = P99_INIT; \
if (!atomic_is_lock_free(p00_objp)) { \
P99_SPIN_EXCLUDE(&p00_objp->p00_lock) \
p00_ret.p00_t = P00_AT(p00_objp); \
} else { \
P99_IF_EMPTY(P99_ATOMIC_LOCK_FREE_TYPES) \
(P00_AT(p00_objp)) \
(p00_ret.p00_m = p00_atomic_load_n(&P00_AM(p00_objp), (ORD))); \
} \
p00_ret.p00_t = p00_ret.p00_t; \
})
/**
......@@ -1109,13 +1109,13 @@ p99_extension
#define atomic_compare_exchange_weak_explicit(OBJP, EXPECTED, DESIRED, SUCC, FAIL) \
p00_atomic_compare_exchange(true, OBJP, EXPECTED, DESIRED, SUCC, FAIL,)
#define atomic_compare_exchange_weak(OBJP, EXPECTED, DESIRED) \
#define atomic_compare_exchange_weak(OBJP, EXPECTED, DESIRED) \
atomic_compare_exchange_weak_explicit(OBJP, EXPECTED, DESIRED, memory_order_seq_cst, memory_order_seq_cst)
#define atomic_compare_exchange_strong_explicit(OBJP, EXPECTED, DESIRED, SUCC, FAIL) \
p00_atomic_compare_exchange(false, OBJP, EXPECTED, DESIRED, SUCC, FAIL,)
#define atomic_compare_exchange_strong(OBJP, EXPECTED, DESIRED) \
#define atomic_compare_exchange_strong(OBJP, EXPECTED, DESIRED) \
atomic_compare_exchange_strong_explicit(OBJP, EXPECTED, DESIRED, memory_order_seq_cst, memory_order_seq_cst)
#define p00_atomic_compare_exchange(WEAK, OBJP, EXPECTED, DESIRED, SUCC, FAIL, ...) \
......@@ -1160,21 +1160,21 @@ p99_extension
**/
#define atomic_store_explicit(OBJP, DES, ORD)
#else
#define atomic_store_explicit(OBJP, DES, ORD) \
p99_extension \
({ \
P99_MACRO_PVAR(p00_objp, (OBJP), volatile); \
P99_MACRO_VAR(p00_desp, (DES)); \
typedef __typeof__(P00_AX(p00_objp)) p00_ubase_t; \
register p00_ubase_t const p00_des = { .p00_t = (p00_desp) }; \
if (!atomic_is_lock_free(p00_objp)) { \
P99_SPIN_EXCLUDE(&p00_objp->p00_lock) \
P00_AT(p00_objp) = p00_des.p00_t; \
} else { \
P99_IF_EMPTY(P99_ATOMIC_LOCK_FREE_TYPES) \
(P00_AT(p00_objp)) \
(p00_atomic_store_n(&P00_AM(p00_objp), p00_des.p00_m, (ORD))); \
} \
#define atomic_store_explicit(OBJP, DES, ORD) \
p99_extension \
({ \
P99_MACRO_PVAR(p00_objp, (OBJP), volatile); \
P99_MACRO_VAR(p00_desp, (DES)); \
typedef __typeof__(P00_AX(p00_objp)) p00_ubase_t; \
register p00_ubase_t const p00_des = { .p00_t = (p00_desp) }; \
if (!atomic_is_lock_free(p00_objp)) { \
P99_SPIN_EXCLUDE(&p00_objp->p00_lock) \
P00_AT(p00_objp) = p00_des.p00_t; \
} else { \
P99_IF_EMPTY(P99_ATOMIC_LOCK_FREE_TYPES) \
(P00_AT(p00_objp)) \
(p00_atomic_store_n(&P00_AM(p00_objp), p00_des.p00_m, (ORD))); \
} \
})
#endif
......@@ -1184,27 +1184,27 @@ p99_extension
#define atomic_store(OBJP, DES) atomic_store_explicit(OBJP, DES, memory_order_seq_cst)
#define P00_FETCH_OP(OBJP, OPERAND, BUILTIN, OPERATOR, ORD) \
p99_extension \
({ \
P99_MACRO_PVAR(p00_objp, (OBJP), volatile); \
P99_MACRO_VAR(p00_op, OPERAND); \
((!atomic_is_lock_free(p00_objp)) \
? ({ \
register __typeof__(P00_AT(p00_objp)) p00_ret = P99_INIT; \
P99_SPIN_EXCLUDE(&p00_objp->p00_lock) { \
p00_ret = P00_AT(p00_objp); \
P00_AT(p00_objp) OPERATOR p00_op; \
} \
p00_ret; \
}) \
: (P99_IF_EMPTY(P99_ATOMIC_LOCK_FREE_TYPES) \
(P00_AT(p00_objp)) \
(P00_ATOMIC_TERN(p00_objp, \
BUILTIN(&P00_AO(p00_objp), \
P00_ATOMIC_TERN(p00_objp, p00_op, 0), \
(ORD)), \
P00_AT(p00_objp))))); \
#define P00_FETCH_OP(OBJP, OPERAND, BUILTIN, OPERATOR, ORD) \
p99_extension \
({ \
P99_MACRO_PVAR(p00_objp, (OBJP), volatile); \
P99_MACRO_VAR(p00_op, OPERAND); \
((!atomic_is_lock_free(p00_objp)) \
? ({ \
register __typeof__(P00_AT(p00_objp)) p00_ret = P99_INIT; \
P99_SPIN_EXCLUDE(&p00_objp->p00_lock) { \
p00_ret = P00_AT(p00_objp); \
P00_AT(p00_objp) OPERATOR p00_op; \
} \
p00_ret; \
}) \
: (P99_IF_EMPTY(P99_ATOMIC_LOCK_FREE_TYPES) \
(P00_AT(p00_objp)) \
(P00_ATOMIC_TERN(p00_objp, \
BUILTIN(&P00_AO(p00_objp), \
P00_ATOMIC_TERN(p00_objp, p00_op, 0), \
(ORD)), \
P00_AT(p00_objp))))); \
})
/**
......@@ -1224,7 +1224,7 @@ p99_extension \
** @see atomic_fetch_add for a simpler version without @a ORD parameter
** @see atomic_int
**/
#define atomic_fetch_add_explicit(OBJP, OPERAND, ORD) \
#define atomic_fetch_add_explicit(OBJP, OPERAND, ORD) \
P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_add, +=, (ORD))
#define atomic_fetch_add(OBJP, OPERAND) atomic_fetch_add_explicit((OBJP), (OPERAND), memory_order_seq_cst)
......@@ -1246,7 +1246,7 @@ P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_add, +=, (ORD))
** @see atomic_fetch_sub for a simpler version without @a ORD parameter
** @see atomic_int
**/
#define atomic_fetch_sub_explicit(OBJP, OPERAND, ORD) \
#define atomic_fetch_sub_explicit(OBJP, OPERAND, ORD) \
P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_sub, -=, ORD)
#define atomic_fetch_sub(OBJP, OPERAND) atomic_fetch_sub_explicit((OBJP), (OPERAND), memory_order_seq_cst)
......@@ -1292,7 +1292,7 @@ P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_or, |=, (ORD))
** @see atomic_fetch_and for a simpler version without @a ORD parameter
** @see atomic_int
**/
#define atomic_fetch_and_explicit(OBJP, OPERAND, ORD) \
#define atomic_fetch_and_explicit(OBJP, OPERAND, ORD) \
P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_and, &=, (ORD))
#define atomic_fetch_and(OBJP, OPERAND) atomic_fetch_and_explicit((OBJP), (OPERAND), memory_order_seq_cst)
......@@ -1316,7 +1316,7 @@ P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_and, &=, (ORD))
** @see atomic_int
** @see _Atomic
**/
#define atomic_fetch_xor_explicit(OBJP, OPERAND, ORD) \
#define atomic_fetch_xor_explicit(OBJP, OPERAND, ORD) \
P00_FETCH_OP((OBJP), (OPERAND), p00_atomic_fetch_xor, ^=, (ORD))
#define atomic_fetch_xor(OBJP, OPERAND) atomic_fetch_xor_explicit((OBJP), (OPERAND), memory_order_seq_cst)
......
......@@ -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-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2010-2014 Jens Gustedt, INRIA, France */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......
......@@ -3,7 +3,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 2011 Emmanuel Jeanvoine, INRIA, France */
/* (C) copyright 2010-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2010-2014 Jens Gustedt, INRIA, France */
/* */
/* This file is free software; it is part of the P99 project. */
/* You can redistribute it and/or modify it under the terms of the QPL as */
......
......@@ -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 2012-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2012-2014 Jens Gustedt, INRIA, France */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......
......@@ -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 2012 Jens Gustedt, INRIA, France */
/* (C) copyright 2012, 2014 Jens Gustedt, INRIA, France */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......
......@@ -3,7 +3,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 2013 Bobby */
/* (C) copyright 2010-2014 Jens Gustedt, INRIA, France */
/* (C) copyright 2010-2015 Jens Gustedt, INRIA, France */
/* (C) copyright 2013 Pierre-Nicolas Clauss */
/* (C) copyright 2012 William Morris */
/* */
......
......@@ -2,7 +2,7 @@
/* */
/* Except for parts copied from previous work and as explicitly stated below, */
/* the author and copyright holder for this work is */
/* (C) copyright 2012-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2012-2014 Jens Gustedt, INRIA, France */
/* */
/* This file is free software; it is part of the P99 project. */
/* You can redistribute it and/or modify it under the terms of the QPL as */
......@@ -395,9 +395,9 @@ errno_t p00_constraint_call(errno_t p00_cond, char const* p00_file, char const*
if (p00_cond) {
if (p00_file) P00_JMP_BUF_FILE = p00_file;
if (p00_context) P00_JMP_BUF_CONTEXT = p00_context;
/* Ensure that all dependent data for this error has been */ \
/* synchronized. */ \
atomic_thread_fence(memory_order_seq_cst); \
/* Ensure that all dependent data for this error has been */ \
/* synchronized. */ \
atomic_thread_fence(memory_order_seq_cst); \
p99_constraint_handler(p00_info, 0, p00_cond);
}
return p00_cond;
......
......@@ -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-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2010-2014 Jens Gustedt, INRIA, France */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......@@ -1234,7 +1234,7 @@ P99_FOR(, P99_NARG(__VA_ARGS__), P00_SEP, P00_MAC_ARGS_REAL1, __VA_ARGS__)
__typeof__(EXP) __VA_ARGS__ P99_PASTE2(p00_macro_var_, NAME) = (EXP), \
NAME = P99_PASTE2(p00_macro_var_, NAME)
#define P00_MACRO_PVAR(NAME, EXP, ...) \
#define P00_MACRO_PVAR(NAME, EXP, ...) \
__typeof__(*(EXP)) __VA_ARGS__* P99_PASTE2(p00_macro_var_, NAME) = (EXP), \
* NAME = P99_PASTE2(p00_macro_var_, NAME)
......
......@@ -2,7 +2,7 @@
/* */
/* Except for parts copied from previous work and as explicitly stated below, */
/* the author and copyright holder for this work is */
/* (C) copyright 2012 Jens Gustedt, INRIA, France */
/* (C) copyright 2012, 2014 Jens Gustedt, INRIA, France */
/* */
/* This file is free software; it is part of the P99 project. */
/* You can redistribute it and/or modify it under the terms of the QPL as */
......
......@@ -2,7 +2,7 @@
/* */
/* Except for parts copied from previous work and as explicitly stated below, */
/* the author and copyright holder for this work is */
/* (C) copyright 2012-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2012-2014 Jens Gustedt, INRIA, France */
/* */
/* This file is free software; it is part of the P99 project. */
/* You can redistribute it and/or modify it under the terms of the QPL as */
......@@ -267,7 +267,7 @@ void p99_futex_wait(p99_futex volatile* p00_cntp) {
switch (p00_ret) {
default: assert(!p00_ret);
case 0: return;
// Allow for different val or spurious wake ups
// Allow for different val or spurious wake ups
case EWOULDBLOCK: ;
case EINTR: ;
}
......
......@@ -2,7 +2,7 @@
/* */
/* Except for parts copied from previous work and as explicitly stated below, */
/* the author and copyright holder for this work is */
/* (C) copyright 2010-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2010-2013, 2015 Jens Gustedt, INRIA, France */
/* */
/* This file is free software; it is part of the P99 project. */
/* You can redistribute it and/or modify it under the terms of the QPL as */
......
......@@ -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 2012-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2012-2014 Jens Gustedt, INRIA, France */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......
......@@ -504,11 +504,11 @@ void p00_getopt_help_count_(bool p00_set,
struct p00_getopt const*p00_help,
int p00_ns[4]) {
register struct p00_getopt const*const p00_p
= (p00_set
? p00_pc
: (((p00_c != p99_getopt_enum_p00h) && (p00_c != p99_getopt_enum_p00HELP))
? 0
: p00_help));
= (p00_set
? p00_pc
: (((p00_c != p99_getopt_enum_p00h) && (p00_c != p99_getopt_enum_p00HELP))
? 0
: p00_help));
if (p00_p) {
if (p00_p->p00_a) p00_ns[0] = P99_GEN_MAX(p00_ns[0], strlen(p00_p->p00_a));
if (p00_p->p00_t) p00_ns[1] = P99_GEN_MAX(p00_ns[1], strlen(p00_p->p00_t));
......@@ -533,11 +533,11 @@ void p00_getopt_help_count_(bool p00_set,
p99_inline
void p00_getopt_help_(bool p00_set, enum p99_getopt_enum p00_c, struct p00_getopt const*p00_pc, struct p00_getopt const*p00_help, int const p00_ns[4]) {
register struct p00_getopt const*const p00_p
= (p00_set
? p00_pc
: (((p00_c != p99_getopt_enum_p00h) && (p00_c != p99_getopt_enum_p00HELP))
? 0
: p00_help));
= (p00_set
? p00_pc
: (((p00_c != p99_getopt_enum_p00h) && (p00_c != p99_getopt_enum_p00HELP))
? 0
: p00_help));
if (p00_p) {
char const*const p00_d = p00_p->p00_d ? p00_p->p00_d : "(not documented)";
char const*const p00_t = p00_p->p00_t ? p00_p->p00_t : "";
......@@ -791,8 +791,8 @@ void p99_getopt_initialize(int * p00_argc, char***p00_argv) {
/* The cases for the one-character options are hidden
here. */
P00_GETOPT_INITIALIZE(P00_GETOPT_CHARS)
/* If the initial string was "--" this announces a long
option. */
/* If the initial string was "--" this announces a long
option. */
case '-': {
/* First split up the option string into option and
argument, if possible. */
......
......@@ -3,7 +3,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 2013 Bobby */
/* (C) copyright 2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2013-2014 Jens Gustedt, INRIA, France */
/* */
/* This file is free software; it is part of the P99 project. */
/* You can redistribute it and/or modify it under the terms of the QPL as */
......
......@@ -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-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2010-2014 Jens Gustedt, INRIA, France */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......
......@@ -2,7 +2,7 @@
/* */
/* Except for parts copied from previous work and as explicitly stated below, */
/* the author and copyright holder for this work is */
/* (C) copyright 2012-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2012-2014 Jens Gustedt, INRIA, France */
/* */
/* This file is free software; it is part of the P99 project. */
/* You can redistribute it and/or modify it under the terms of the QPL as */
......
......@@ -2,7 +2,7 @@
/* */
/* Except for parts copied from previous work and as explicitly stated below, */
/* the author and copyright holder for this work is */
/* (C) copyright 2012-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2012-2014 Jens Gustedt, INRIA, France */
/* */
/* This file is free software; it is part of the P99 project. */
/* You can redistribute it and/or modify it under the terms of the QPL as */
......
......@@ -2,7 +2,7 @@
/* */
/* Except for parts copied from previous work and as explicitly stated below, */
/* the author and copyright holder for this work is */
/* (C) copyright 2012 Jens Gustedt, INRIA, France */
/* (C) copyright 2014 Jens Gustedt, INRIA, France */
/* */
/* This file is free software; it is part of the P99 project. */
/* You can redistribute it and/or modify it under the terms of the QPL as */
......@@ -73,10 +73,10 @@ struct p99_rwl {
/**
** @brief Initialize an ::p99_rwl object.
**/
# define P99_RWL_INITIALIZER \
{ \
.p00_f = P99_FUTEX_INITIALIZER, \
.p00_w = ATOMIC_VAR_INIT(0), \
# define P99_RWL_INITIALIZER \
{ \
.p00_f = P99_FUTEX_INITIALIZER, \
.p00_w = ATOMIC_VAR_INIT(0), \
}
/**
......@@ -130,8 +130,8 @@ int p99_rwl_rdlock(p99_rwl volatile* p00_r) {
/* Return EAGAIN if we couldn't increment because there were too
many waiters. */
return (p00_res <= P00_RWL_EXCL-1)
? 0
: EAGAIN;
? 0
: EAGAIN;
}
/**
......@@ -210,61 +210,61 @@ p99_inline bool p99_rwl_haswaiters(p99_rwl volatile* p00_r) {
**
** @see p99_rwl
**/
# define P99_RDLOCK(RWLOCK) \
P00_BLK_START \
P00_BLK_DECL(int, p00_errNo, 0) \
P99_GUARDED_BLOCK(p99_rwl*, \
P99_FILEID(rwlock), \
&(RWLOCK), \
(void)(P99_UNLIKELY(p00_errNo = p99_rwl_rdlock(P99_FILEID(rwlock))) \
&& (fprintf(stderr, \
__FILE__ ":" \
P99_STRINGIFY(__LINE__) ": read lock error for " \
P99_STRINGIFY(RWLOCK) ", %s", \
strerror(p00_errNo)), 1) \
&& (P99_FILEID(rwlock) = 0, 1) \
&& (P99_UNWIND(-1), 1) \
), \
(void)(P99_FILEID(rwlock) \
# define P99_RDLOCK(RWLOCK) \
P00_BLK_START \
P00_BLK_DECL(int, p00_errNo, 0) \
P99_GUARDED_BLOCK(p99_rwl*, \
P99_FILEID(rwlock), \
&(RWLOCK), \
(void)(P99_UNLIKELY(p00_errNo = p99_rwl_rdlock(P99_FILEID(rwlock))) \
&& (fprintf(stderr, \
__FILE__ ":" \
P99_STRINGIFY(__LINE__) ": read lock error for " \
P99_STRINGIFY(RWLOCK) ", %s", \
strerror(p00_errNo)), 1) \
&& (P99_FILEID(rwlock) = 0, 1) \
&& (P99_UNWIND(-1), 1) \
), \
(void)(P99_FILEID(rwlock) \
&& p99_rwl_unlock(P99_FILEID(rwlock))))
/**
** @brief protect the depending statement or block by an exclusive lock
**
** @see p99_rwl
** @see p99_rwl
**/
# define P99_WRLOCK(RWLOCK) \
P00_BLK_START \
P00_BLK_DECL(int, p00_errNo, 0) \
P99_GUARDED_BLOCK(p99_rwl*, \
P99_FILEID(rwlock), \
&(RWLOCK), \
(void)(P99_UNLIKELY(p00_errNo = p99_rwl_wrlock(P99_FILEID(rwlock))) \
&& (fprintf(stderr, \
__FILE__ ":" \
P99_STRINGIFY(__LINE__) ": write lock error for " \
P99_STRINGIFY(RWLOCK) ", %s", \
strerror(p00_errNo)), 1) \
&& (P99_FILEID(rwlock) = 0, 1) \
&& (P99_UNWIND(-1), 1) \
), \
(void)(P99_FILEID(rwlock) \
# define P99_WRLOCK(RWLOCK) \
P00_BLK_START \
P00_BLK_DECL(int, p00_errNo, 0) \
P99_GUARDED_BLOCK(p99_rwl*, \
P99_FILEID(rwlock), \
&(RWLOCK), \
(void)(P99_UNLIKELY(p00_errNo = p99_rwl_wrlock(P99_FILEID(rwlock))) \
&& (fprintf(stderr, \
__FILE__ ":" \
P99_STRINGIFY(__LINE__) ": write lock error for " \
P99_STRINGIFY(RWLOCK) ", %s", \
strerror(p00_errNo)), 1) \
&& (P99_FILEID(rwlock) = 0, 1) \
&& (P99_UNWIND(-1), 1) \
), \
(void)(P99_FILEID(rwlock) \
&& p99_rwl_unlock(P99_FILEID(rwlock))))
# else
# define P99_RDLOCK(RWLOCK) \
P99_GUARDED_BLOCK(p99_rwl*, \
P99_FILEID(rwlock), \
&(RWLOCK), \
p99_rwl_rdlock(P99_FILEID(rwlock)), \
# define P99_RDLOCK(RWLOCK) \
P99_GUARDED_BLOCK(p99_rwl*, \
P99_FILEID(rwlock), \
&(RWLOCK), \
p99_rwl_rdlock(P99_FILEID(rwlock)), \
p99_rwl_unlock(P99_FILEID(rwlock)))
# define P99_WRLOCK(RWLOCK) \
P99_GUARDED_BLOCK(p99_rwl*, \
P99_FILEID(rwlock), \
&(RWLOCK), \
p99_rwl_wrlock(P99_FILEID(rwlock)), \
# define P99_WRLOCK(RWLOCK) \
P99_GUARDED_BLOCK(p99_rwl*, \
P99_FILEID(rwlock), \
&(RWLOCK), \
p99_rwl_wrlock(P99_FILEID(rwlock)), \
p99_rwl_unlock(P99_FILEID(rwlock)))
# endif
......
......@@ -319,9 +319,9 @@ P99_GUARDED_BLOCK(mtx_t*,
(void)(UNIQ \
&& mtx_unlock(UNIQ)))
# else
# define P00_MUTUAL_EXCLUDE(MUT, UNIQ) \
P00_BLK_START \
P00_BLK_DECL(mtx_t*, UNIQ, &(MUT)) \
# define P00_MUTUAL_EXCLUDE(MUT, UNIQ) \
P00_BLK_START \
P00_BLK_DECL(mtx_t*, UNIQ, &(MUT)) \
P00_BLK_BEFAFT(mtx_lock(UNIQ), mtx_unlock(UNIQ))
# endif
......
/* This may look like nonsense, but it really is -*- mode: C -*- */
/* */
/* Except for parts copied from previous work and as explicitly stated below, */
/* the authors and copyright holder for this work is as follows: */