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

copyright and whitespace


Signed-off-by: default avatarJens Gustedt <Jens.Gustedt@loria.fr>
parent de5ffdaf
......@@ -3,8 +3,8 @@
/* 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 2012 William Morris */
/* (C) copyright 2013 Pierre-Nicolas Clauss */
/* (C) copyright 2012 William Morris */
/* */
/* 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,6 +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 2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2013 Pierre-Nicolas Clauss */
/* */
/* This file is free software; it is part of the P99 project. */
......@@ -47,37 +48,37 @@ p99_inline uintmax_t p00_arith_abs(uintmax_t p00_a) {
p99_inline intmax_t p99_arith_min(intmax_t p00_a, intmax_t p00_b) {
#if UINTMAX_MAX > INTMAX_MAX
p00_a -= p00_b;
return (p00_a & P00_ARITH_INTMAX_SHIFT(p00_a)) + p00_b;
p00_a -= p00_b;
return (p00_a & P00_ARITH_INTMAX_SHIFT(p00_a)) + p00_b;
#else
return p00_a < p00_b ? p00_a : p00_b;
return p00_a < p00_b ? p00_a : p00_b;
#endif
}
p99_inline intmax_t p99_arith_max(intmax_t p00_a, intmax_t p00_b) {
#if UINTMAX_MAX > INTMAX_MAX
p00_a -= p00_b;
return (p00_a & ~P00_ARITH_INTMAX_SHIFT(p00_a)) + p00_b;
p00_a -= p00_b;
return (p00_a & ~P00_ARITH_INTMAX_SHIFT(p00_a)) + p00_b;
#else
return p00_a < p00_b ? p00_b : p00_a;
return p00_a < p00_b ? p00_b : p00_a;
#endif
}
p99_inline uintmax_t p99_arith_prev_pow2(uintmax_t p00_a) {
/* Any decent compiler will unroll this loop */
for(uintmax_t p00_s = 1; p00_s <= P99_EWIDTH(p00_a) >> 1; p00_s <<= 1) {
p00_a |= p00_a >> p00_s;
}
return p00_a - (p00_a >> 1);
/* Any decent compiler will unroll this loop */
for(uintmax_t p00_s = 1; p00_s <= P99_EWIDTH(p00_a) >> 1; p00_s <<= 1) {
p00_a |= p00_a >> p00_s;
}
return p00_a - (p00_a >> 1);
}
p99_inline uintmax_t p99_arith_next_pow2(uintmax_t p00_a) {
--p00_a;
/* Any decent compiler will unroll this loop */
for(uintmax_t p00_s = 1; p00_s <= P99_EWIDTH(p00_a) >> 1; p00_s <<= 1) {
p00_a |= p00_a >> p00_s;
}
return p00_a + 1;
--p00_a;
/* Any decent compiler will unroll this loop */
for(uintmax_t p00_s = 1; p00_s <= P99_EWIDTH(p00_a) >> 1; p00_s <<= 1) {
p00_a |= p00_a >> p00_s;
}
return p00_a + 1;
}
/**
......@@ -86,18 +87,18 @@ p99_inline uintmax_t p99_arith_next_pow2(uintmax_t p00_a) {
** @todo replace ffs(P99_UINTMAX_WIDTH) by a preprocessor constant
**/
p99_inline uintmax_t p99_arith_log2(uintmax_t p00_a) {
uintmax_t p00_l = 0;
uintmax_t p00_l = 0;
/* Any decent compiler will unroll this loop */
for(int i = ffs(P99_UINTMAX_WIDTH) - 2; i >= 0; --i) {
uintmax_t p00_s = UINTMAX_C(1) << i;
uintmax_t p00_m = ((UINTMAX_C(1) << p00_s) - 1) << p00_s;
uintmax_t p00_t = (p00_a & p00_m) != 0;
/* Any decent compiler will unroll this loop */
for(int i = ffs(P99_UINTMAX_WIDTH) - 2; i >= 0; --i) {
uintmax_t p00_s = UINTMAX_C(1) << i;
uintmax_t p00_m = ((UINTMAX_C(1) << p00_s) - 1) << p00_s;
uintmax_t p00_t = (p00_a & p00_m) != 0;
p00_l |= p00_t * p00_s;
p00_a >>= p00_t * p00_s;
}
return p00_l;
p00_l |= p00_t * p00_s;
p00_a >>= p00_t * p00_s;
}
return p00_l;
}
#endif /* !P99_ARITH_H_ */
......@@ -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 2011-2012 Jens Gustedt, INRIA, France */
/* (C) copyright 2011-2013 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-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......@@ -60,10 +60,10 @@ struct p99_callback_el {
p99_inline
p99_callback_el* p99_callback_el_init(p99_callback_el * p00_obj,
p99_callback_voidptr_func* p00_voidptr_func,
p99_callback_void_func* p00_void_func,
void* p00_arg
) {
p99_callback_voidptr_func* p00_voidptr_func,
p99_callback_void_func* p00_void_func,
void* p00_arg
) {
if (p00_obj) {
if (p00_voidptr_func)
*p00_obj = (p99_callback_el) {
......@@ -91,7 +91,7 @@ P99_GENERIC((&*FUNC), \
(p99_callback_voidptr_func*, (p99_callback_void_func*)0) \
)
#define p99_callback_el_init_(OBJ, FUNC, ARG) \
#define p99_callback_el_init_(OBJ, FUNC, ARG) \
p99_callback_el_init((OBJ), p99_callback_el_init_1(FUNC), p99_callback_el_init_2(FUNC), ARG)
......
......@@ -2,9 +2,9 @@
/* */
/* 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 2012 William Morris */
/* (C) copyright 2010-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2013 Pierre-Nicolas Clauss */
/* (C) copyright 2012 William Morris */
/* */
/* 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 2012-2013 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 */
......
......@@ -29,13 +29,13 @@
#if defined(P99_DECLARE_ATOMIC) || P00_DOXYGEN
# define P99_FIFO(T) P99_PASTE2(p00_fifo_, T)
# define P99_FIFO_DECLARE(T) \
typedef T volatile P99_PASTE2(p00_fifo_base_, T); \
P99_DECLARE_ATOMIC(P99_PASTE2(p00_fifo_base_, T)); \
# define P99_FIFO_DECLARE(T) \
typedef T volatile P99_PASTE2(p00_fifo_base_, T); \
P99_DECLARE_ATOMIC(P99_PASTE2(p00_fifo_base_, T)); \
typedef _Atomic(P99_PASTE2(p00_fifo_base_, T)) P99_PASTE2(p00_fifo_, T)[2]
# define P99_FIFO_INITIALIZER(HEAD, TAIL) { \
[0] = ATOMIC_VAR_INIT(HEAD), \
[1] = ATOMIC_VAR_INIT(TAIL), \
# define P99_FIFO_INITIALIZER(HEAD, TAIL) { \
[0] = ATOMIC_VAR_INIT(HEAD), \
[1] = ATOMIC_VAR_INIT(TAIL), \
}
/**
......@@ -46,38 +46,38 @@ typedef _Atomic(P99_PASTE2(p00_fifo_base_, T)) P99_PASTE2(p00_fifo_, T)[2]
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_FIFO_APPEND, 0)
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_FIFO_APPEND, 1)
#define P99_FIFO_APPEND(L, EL) \
do { \
/* first evaluate the macro arguments such that there can't be */ \
/* name conflicts */ \
register const P99_MACRO_VAR(p00_l, (L)); \
register const P99_MACRO_VAR(p00_el, (EL)); \
register const P99_MACRO_VAR(p00_h, &(*p00_l)[0]); \
register const P99_MACRO_VAR(p00_t, &(*p00_l)[1]); \
p00_el->p99_lifo = 0; \
P99_MACRO_VAR(p00_head, atomic_load(p00_h)); \
for (;;) { \
if (p00_head) { \
/* spin lock the whole fifo */ \
if (atomic_compare_exchange_weak(p00_h, &p00_head, 0)) { \
/* make p00_el the last element */ \
atomic_exchange(p00_t, p00_el)->p99_lifo = p00_el; \
/* unlock the fifo */ \
atomic_store(p00_h, p00_head); \
break; \
} \
} else { \
P99_MACRO_VAR(p00_tail, atomic_load(p00_t)); \
if (!p00_tail \
&& atomic_compare_exchange_weak(p00_t, &p00_tail, p00_el)) { \
#define P99_FIFO_APPEND(L, EL) \
do { \
/* first evaluate the macro arguments such that there can't be */ \
/* name conflicts */ \
register const P99_MACRO_VAR(p00_l, (L)); \
register const P99_MACRO_VAR(p00_el, (EL)); \
register const P99_MACRO_VAR(p00_h, &(*p00_l)[0]); \
register const P99_MACRO_VAR(p00_t, &(*p00_l)[1]); \
p00_el->p99_lifo = 0; \
P99_MACRO_VAR(p00_head, atomic_load(p00_h)); \
for (;;) { \
if (p00_head) { \
/* spin lock the whole fifo */ \
if (atomic_compare_exchange_weak(p00_h, &p00_head, 0)) { \
/* make p00_el the last element */ \
atomic_exchange(p00_t, p00_el)->p99_lifo = p00_el; \
/* unlock the fifo */ \
atomic_store(p00_h, p00_head); \
break; \
} \
} else { \
P99_MACRO_VAR(p00_tail, atomic_load(p00_t)); \
if (!p00_tail \
&& atomic_compare_exchange_weak(p00_t, &p00_tail, p00_el)) { \
/* the fifo was empty, our element is inserted, update the head */ \
atomic_store(p00_h, p00_el); \
break; \
} \
/* we were in the middle of an update of another thread */ \
p00_head = atomic_load(p00_h); \
} \
} \
atomic_store(p00_h, p00_el); \
break; \
} \
/* we were in the middle of an update of another thread */ \
p00_head = atomic_load(p00_h); \
} \
} \
} while (false)
/**
......@@ -121,39 +121,39 @@ do { \
** @see P99_FIFO_APPEND
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_FIFO_POP, 0)
#define P99_FIFO_POP(L) \
p99_extension \
({ \
/* first evaluate the macro argument such that there can't be */ \
/* a name conflict */ \
register const P99_MACRO_VAR(p00_l, (L)); \
register const P99_MACRO_VAR(p00_h, &(*p00_l)[0]); \
register const P99_MACRO_VAR(p00_t, &(*p00_l)[1]); \
P99_MACRO_VAR(p00_head, atomic_load(p00_h)); \
for (;;) { \
if (p00_head) { \
/* spin lock the whole fifo */ \
if (atomic_compare_exchange_weak(p00_h, &p00_head, 0)) { \
if (p00_head->p99_lifo) \
#define P99_FIFO_POP(L) \
p99_extension \
({ \
/* first evaluate the macro argument such that there can't be */ \
/* a name conflict */ \
register const P99_MACRO_VAR(p00_l, (L)); \
register const P99_MACRO_VAR(p00_h, &(*p00_l)[0]); \
register const P99_MACRO_VAR(p00_t, &(*p00_l)[1]); \
P99_MACRO_VAR(p00_head, atomic_load(p00_h)); \
for (;;) { \
if (p00_head) { \
/* spin lock the whole fifo */ \
if (atomic_compare_exchange_weak(p00_h, &p00_head, 0)) { \
if (p00_head->p99_lifo) \
/* there is still another element to come in the fifo, make it \
the head */ \
atomic_store(p00_h, p00_head->p99_lifo); \
else \
/* this was the last element in the fifo, set the tail to 0, \
too */ \
atomic_store(p00_t, 0); \
p00_head->p99_lifo = 0; \
break; \
} \
} else { \
register P99_MACRO_VAR(p00_tail, atomic_load(p00_t)); \
if (!p00_tail) break; \
p00_head = atomic_load(p00_h); \
} \
} \
/* make sure that the result can not be used as an lvalue */ \
register const __typeof__(p00_head = p00_head) p00_r = p00_head; \
p00_r; \
the head */ \
atomic_store(p00_h, p00_head->p99_lifo); \
else \
/* this was the last element in the fifo, set the tail to 0, \
too */ \
atomic_store(p00_t, 0); \
p00_head->p99_lifo = 0; \
break; \
} \
} else { \
register P99_MACRO_VAR(p00_tail, atomic_load(p00_t)); \
if (!p00_tail) break; \
p00_head = atomic_load(p00_h); \
} \
} \
/* make sure that the result can not be used as an lvalue */ \
register const __typeof__(p00_head = p00_head) p00_r = p00_head; \
p00_r; \
})
/**
......@@ -166,31 +166,31 @@ p99_extension \
** @see P00_FIFO_EL
**/
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_FIFO_CLEAR, 0)
#define P99_FIFO_CLEAR(L) \
p99_extension \
({ \
/* first evaluate the macro argument such that there can't be */ \
/* a name conflict */ \
register const P99_MACRO_VAR(p00_l, (L)); \
register const P99_MACRO_VAR(p00_h, &(*p00_l)[0]); \
register const P99_MACRO_VAR(p00_t, &(*p00_l)[1]); \
P99_MACRO_VAR(p00_head, atomic_load(p00_h)); \
for (;;) { \
if (p00_head) { \
/* spin lock the whole fifo */ \
if (atomic_compare_exchange_weak(p00_h, &p00_head, 0)) { \
atomic_store(p00_t, 0); \
break; \
} \
} else { \
register const P99_MACRO_VAR(p00_tail, atomic_load(p00_t)); \
if (!p00_tail) break; \
p00_head = atomic_load(p00_h); \
} \
} \
/* make sure that the result can not be used as an lvalue */ \
register const __typeof__(p00_head = p00_head) p00_r = p00_head; \
p00_r; \
#define P99_FIFO_CLEAR(L) \
p99_extension \
({ \
/* first evaluate the macro argument such that there can't be */ \
/* a name conflict */ \
register const P99_MACRO_VAR(p00_l, (L)); \
register const P99_MACRO_VAR(p00_h, &(*p00_l)[0]); \
register const P99_MACRO_VAR(p00_t, &(*p00_l)[1]); \
P99_MACRO_VAR(p00_head, atomic_load(p00_h)); \
for (;;) { \
if (p00_head) { \
/* spin lock the whole fifo */ \
if (atomic_compare_exchange_weak(p00_h, &p00_head, 0)) { \
atomic_store(p00_t, 0); \
break; \
} \
} else { \
register const P99_MACRO_VAR(p00_tail, atomic_load(p00_t)); \
if (!p00_tail) break; \
p00_head = atomic_load(p00_h); \
} \
} \
/* make sure that the result can not be used as an lvalue */ \
register const __typeof__(p00_head = p00_head) p00_r = p00_head; \
p00_r; \
})
#else
......@@ -202,37 +202,37 @@ p99_extension \
# define P99_FIFO_DECLARE(T) typedef T P99_PASTE2(p00_fifo_, T)[2]
# define P99_FIFO_INITIALIZER(HEAD, TAIL) { [0] = (HEAD), [1] = (TAIL) }
#define P99_FIFO_APPEND(L, EL) \
p99_extension \
({ \
P99_MACRO_VAR(p00_l, (L)); \
P99_MACRO_VAR(p00_el, (EL)); \
p00_el->p99_lifo = (*p00_l)[1]; \
(*p00_l)[1] = p00_el; \
if (!(*p00_l)[0]) (*p00_l)[0] = p00_el; \
#define P99_FIFO_APPEND(L, EL) \
p99_extension \
({ \
P99_MACRO_VAR(p00_l, (L)); \
P99_MACRO_VAR(p00_el, (EL)); \
p00_el->p99_lifo = (*p00_l)[1]; \
(*p00_l)[1] = p00_el; \
if (!(*p00_l)[0]) (*p00_l)[0] = p00_el; \
})
#define P99_FIFO_POP(L) \
p99_extension \
({ \
P99_MACRO_VAR(p00_l, (L)); \
P99_MACRO_VAR(p00_el, (*p00_l)[0]); \
(*p00_l)[0] = p00_el->p99_lifo; \
if (!(*p00_l)[0]) = (*p00_l)[0] = 0; \
if (p00_el) p00_el->p99_lifo = 0; \
/* be sure that the result can not be used as an lvalue */ \
register const __typeof__(p00_el = p00_el) p00_r = p00_el; \
p00_r; \
#define P99_FIFO_POP(L) \
p99_extension \
({ \
P99_MACRO_VAR(p00_l, (L)); \
P99_MACRO_VAR(p00_el, (*p00_l)[0]); \
(*p00_l)[0] = p00_el->p99_lifo; \
if (!(*p00_l)[0]) = (*p00_l)[0] = 0; \
if (p00_el) p00_el->p99_lifo = 0; \
/* be sure that the result can not be used as an lvalue */ \
register const __typeof__(p00_el = p00_el) p00_r = p00_el; \
p00_r; \
})
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_FIFO_CLEAR, 0)
#define P99_FIFO_CLEAR(L) \
({ \
P99_MACRO_VAR(p00_l, (L)); \
register P99_MACRO_VAR(p00_ret, (*p00_l)[0]); \
(*p00_l)[0] = 0; \
(*p00_l)[1] = 0; \
p00_ret; \
#define P99_FIFO_CLEAR(L) \
({ \
P99_MACRO_VAR(p00_l, (L)); \
register P99_MACRO_VAR(p00_ret, (*p00_l)[0]); \
(*p00_l)[0] = 0; \
(*p00_l)[1] = 0; \
p00_ret; \
})
#endif
......
......@@ -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-2012 Jens Gustedt, INRIA, France */
/* (C) copyright 2010-2013 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 */
......@@ -41,8 +41,8 @@ automatically generated, do not change manually.
**/
#define P99_VERSION_ID "$Format:%H$"
#define P00_VERSION_DATE "Thu, 03 Jan 2013 18:48:58 +0100"
#define P00_VERSION_ID "33ac89c0993a36ee079572e19bc4b4c63ff71b46"
#define P00_VERSION_DATE "Sun, 06 Jan 2013 17:30:45 +0100"
#define P00_VERSION_ID "8ddba875e3a104431fc7e9ad7944501c249d6288"
/** @brief The maximal number of arguments the P99 macros can handle.
**
......
......@@ -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-2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......
......@@ -2,6 +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 2013 Jens Gustedt, INRIA, France */
/* (C) copyright 2013 Pierre-Nicolas Clauss */
/* */
/* This file is free software; it is part of the P99 project. */
......@@ -27,26 +28,26 @@
#include "p99_list.h"
#if p99_has_attribute(constructor)
# define P99_AT_LOAD_DECLARE(...) \
# define P99_AT_LOAD_DECLARE(...) \
__attribute__((constructor P99_IF_LE(P99_NARG(__VA_ARGS__), 1)()((P99_SKP(1, __VA_ARGS__))))) \
void P99_CHS(0, __VA_ARGS__)(void)
# define P99_AT_LOAD_DEFINE P99_AT_LOAD_DECLARE
#else
# define P99_AT_LOAD_DECLARE(...) \
void P99_CHS(0, __VA_ARGS__)(void); \
# define P99_AT_LOAD_DECLARE(...) \
void P99_CHS(0, __VA_ARGS__)(void); \
P99_PRAGMA(startup P99_FOR(, P99_NARG(__VA_ARGS__), P00_SER, P00_IDT, __VA_ARGS__)) \
P99_MACRO_END(P99_AT_LOAD_DECLARE)
# define P99_AT_LOAD_DEFINE(...) void P99_CHS(0, __VA_ARGS__)(void)
#endif
#if p99_has_attribute(destructor)
# define P99_AT_UNLOAD_DECLARE(...) \
# define P99_AT_UNLOAD_DECLARE(...) \
__attribute__((destructor P99_IF_LE(P99_NARG(__VA_ARGS__), 1)()((P99_SKP(1, __VA_ARGS__))))) \
void P99_CHS(0, __VA_ARGS__)(void)
# define P99_AT_UNLOAD_DEFINE P99_AT_UNLOAD_DECLARE
#else
# define P99_AT_UNLOAD_DECLARE(...) \
void P99_CHS(0, __VA_ARGS__)(void); \
# define P99_AT_UNLOAD_DECLARE(...) \
void P99_CHS(0, __VA_ARGS__)(void); \
P99_PRAGMA(exit P99_FOR(, P99_NARG(__VA_ARGS__), P00_SER, P00_IDT, __VA_ARGS__)) \
P99_MACRO_END(P99_AT_UNLOAD_DECLARE)
# define P99_AT_UNLOAD_DEFINE(...) void P99_CHS(0, __VA_ARGS__)(void)
......
......@@ -36,15 +36,15 @@
# define P00_INIT_FUNCTION(NR) P99_IF_EMPTY(NR)(P99_PASTE2(p00_init_function_, P99_INIT_NR))(P99_PASTE2(p00_init_function_, NR))
# define P00_INIT_FUNC_VAR_S(_0, _1, I) \
# define P00_INIT_FUNC_VAR_S(_0, _1, I) \
static p99_callback_el const P99_PASTE2(p00_init_function_, I)
P99_FOR(, P99_MAX_NUMBER, P00_SEP, P00_INIT_FUNC_VAR_S, P99_REP(P99_MAX_NUMBER,));
# define P00_INIT_TRIGGER_FUNCTION_1(_0, _1, I) p99_callback_el_call(P99_PASTE2(p00_init_function_, I))
# define P00_INIT_FUNCTION_(NAME, NR) \
void NAME(void); \
# define P00_INIT_FUNCTION_(NAME, NR) \
void NAME(void); \
static p99_callback_el const P00_INIT_FUNCTION(NR) = { .p00_void_func = NAME, }
# ifdef P00_DOXYGEN
......@@ -120,11 +120,11 @@ static p99_callback_el const P00_INIT_FUNCTION(NR) = { .p00_void_func = NAME, }
# define P99_INIT_FUNCTION_DECLARE(...) P99_IF_EQ(P99_NARG(__VA_ARGS__), 2)(P00_INIT_FUNCTION_(__VA_ARGS__))(P00_INIT_FUNCTION_(__VA_ARGS__,))
# endif
# define P00_INIT_VARIABLE(NAME, FUNC, NR) \
static p99_callback_el const P00_INIT_FUNCTION(NR) \
= { \
.p00_voidptr_func = (FUNC), \
.p00_arg = &(NAME), \
# define P00_INIT_VARIABLE(NAME, FUNC, NR) \
static p99_callback_el const P00_INIT_FUNCTION(NR) \
= { \
.p00_voidptr_func = (FUNC), \
.p00_arg = &(NAME), \
}
# ifdef P00_DOXYGEN
......@@ -208,25 +208,25 @@ static p99_callback_el const P00_INIT_FUNCTION(NR) \
** return is mandatory: for the compiler the user @c main is not a @c
** main in the sense of the C standard anymore.
**/
# define P99_MAIN_INTERCEPT(NAME) \
int NAME(int, char*[]); \
P99_WEAK(P99_PASTE2(p00_init_func_, NAME)) \
void P99_PASTE2(p00_init_func_, NAME)(int*, char***); \
P99_WEAK(main) \
int main(int p00_argc, char**p00_argv) { \
# define P99_MAIN_INTERCEPT(NAME) \
int NAME(int, char*[]); \
P99_WEAK(P99_PASTE2(p00_init_func_, NAME)) \
void P99_PASTE2(p00_init_func_, NAME)(int*, char***); \
P99_WEAK(main) \
int main(int p00_argc, char**p00_argv) { \
fprintf(stderr, "%s: intercepting " P99_STRINGIFY(NAME) "\n", __func__); \
P99_PASTE2(p00_init_func_, NAME)(&p00_argc, &p00_argv); \
return NAME(p00_argc, p00_argv); \
} \
P99_WEAK(P99_PASTE2(p00_init_func_, NAME)) \
P99_PASTE2(p00_init_func_, NAME)(&p00_argc, &p00_argv); \
return NAME(p00_argc, p00_argv); \
} \
P99_WEAK(P99_PASTE2(p00_init_func_, NAME)) \
void P99_PASTE2(p00_init_func_, NAME)(int * p00_argc, char***p00_argv)
# define P99_INIT_TRIGGER(NAME, ARGC, ARGV) P99_NOP
# else
# define P99_MAIN_INTERCEPT(NAME) \
P99_WEAK(P99_PASTE2(p00_init_func_, NAME)) \
# define P99_MAIN_INTERCEPT(NAME) \
P99_WEAK(P99_PASTE2(p00_init_func_, NAME)) \
void P99_PASTE2(p00_init_func_, NAME)(int * p00_argc, char***p00_argv)
# define P99_INIT_TRIGGER(NAME, ARGC, ARGV) P99_PASTE2(p00_init_func_, NAME)((ARGC), (ARGV))
......
......@@ -2,7 +2,8 @@
/* */
/* 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 2013 Pierre-Nicolas Clauss */
/* (C) copyright 2012 William Morris */
/* */
/* This file is free software; it is part of the P99 project. */
......@@ -155,12 +156,12 @@ typedef extendedInt p99x_int128;
#ifdef p99x_uintmax
#define P99X__SIGN_PROMOTE(EXPR) \
#define P99X__SIGN_PROMOTE(EXPR) \
((p99x_uintmax)+P99_SIGN_PROMOTE(P99_UE_MAX(EXPR), (p99x_uintmax)+UINTMAX_MAX))
#define P99X__SHIFT(EXPR) \
#define P99X__SHIFT(EXPR) \
((P99_SIGN_PROMOTE(P99_UE_MAX(EXPR), UINTMAX_MAX) > (p99x_uintmax)+UINTMAX_MAX) \
? 64u \
? 64u \
: 0u)
#endif