Commit d80f6121 authored by Jens Gustedt's avatar Jens Gustedt
Browse files

work around a bug in gcc 4.9 that has difficulties to follow complicated

block constructs
parent 9671c2fd
...@@ -215,6 +215,23 @@ P00_BLK_BEFAFT(P00_ROBUST(BEFORE), __VA_ARGS__) \ ...@@ -215,6 +215,23 @@ P00_BLK_BEFAFT(P00_ROBUST(BEFORE), __VA_ARGS__) \
P00_BLK_END P00_BLK_END
#endif #endif
# ifndef P99_SIMPLE_BLOCKS
/**
** @brief A bug avoiding macro to reduce the depth of some code
** produced by P99
**
** This is only useful if your compiler explodes when compiling in
** normal mode. The only compiler that needs this for the moment is
** gcc 4.9.
**
** Predefine this to be @c 1 if you have such a bugger.
**
** @warning Switching this to @c 1 disables exception handling for
** the block constructs. Use with care.
**/
# define P99_SIMPLE_BLOCKS 0
# endif
#ifdef P00_DOXYGEN #ifdef P00_DOXYGEN
/** /**
** @brief A meta-macro to protect a dependent block or statement by ** @brief A meta-macro to protect a dependent block or statement by
...@@ -243,16 +260,25 @@ P00_BLK_END ...@@ -243,16 +260,25 @@ P00_BLK_END
P00_UNWIND_DOCUMENT P00_UNWIND_DOCUMENT
#define P99_GUARDED_BLOCK(T, NAME, INITIAL, BEFORE, AFTER) #define P99_GUARDED_BLOCK(T, NAME, INITIAL, BEFORE, AFTER)
#else #else
# if !P99_SIMPLE_BLOCKS
P00_DOCUMENT_WARN_VLA_ARGUMENT(P99_GUARDED_BLOCK, 0) P00_DOCUMENT_WARN_VLA_ARGUMENT(P99_GUARDED_BLOCK, 0)
P00_DOCUMENT_DECLARATION_ARGUMENT(P99_GUARDED_BLOCK, 1) P00_DOCUMENT_DECLARATION_ARGUMENT(P99_GUARDED_BLOCK, 1)
P00_DOCUMENT_STATEMENT_ARGUMENT(P99_GUARDED_BLOCK, 4) P00_DOCUMENT_STATEMENT_ARGUMENT(P99_GUARDED_BLOCK, 4)
#define P99_GUARDED_BLOCK(T, NAME, INITIAL, BEFORE, AFTER) \ # define P99_GUARDED_BLOCK(T, NAME, INITIAL, BEFORE, AFTER) \
P00_BLK_START \ P00_BLK_START \
P00_BLK_DECL_REC(T, NAME, P00_ROBUST(INITIAL)) \ P00_BLK_DECL_REC(T, NAME, P00_ROBUST(INITIAL)) \
P99_UNWIND_PROTECT if (0) { P99_PROTECT: AFTER; } else \ P99_UNWIND_PROTECT if (0) { P99_PROTECT: AFTER; } else \
P00_BLK_BEFAFT(P00_ROBUST(BEFORE), AFTER) \ P00_BLK_BEFAFT(P00_ROBUST(BEFORE), AFTER) \
/* Ensure that a `break' will still execute AFTER */ \ /* Ensure that a `break' will still execute AFTER */ \
P00_BLK_END P00_BLK_END
# else
# define P99_GUARDED_BLOCK(T, NAME, INITIAL, BEFORE, AFTER) \
P00_BLK_START \
P00_BLK_DECL(T, NAME, P00_ROBUST(INITIAL)) \
P00_BLK_BEFAFT(P00_ROBUST(BEFORE), AFTER) \
/* Ensure that a `break' will still execute AFTER */ \
P00_BLK_END
# endif
#endif #endif
/** /**
......
...@@ -779,7 +779,8 @@ P99_BLOCK_DOCUMENT ...@@ -779,7 +779,8 @@ P99_BLOCK_DOCUMENT
P00_DOCUMENT_PERMITTED_ARGUMENT(P99_MUTUAL_EXCLUDE, 0) P00_DOCUMENT_PERMITTED_ARGUMENT(P99_MUTUAL_EXCLUDE, 0)
#define P99_MUTUAL_EXCLUDE(MUT) P00_MUTUAL_EXCLUDE(MUT, P99_UNIQ(mut)) #define P99_MUTUAL_EXCLUDE(MUT) P00_MUTUAL_EXCLUDE(MUT, P99_UNIQ(mut))
#define P00_MUTUAL_EXCLUDE(MUT, UNIQ) \ # if !P99_SIMPLE_BLOCKS
# define P00_MUTUAL_EXCLUDE(MUT, UNIQ) \
P00_BLK_START \ P00_BLK_START \
P00_BLK_DECL(int, p00_errNo, 0) \ P00_BLK_DECL(int, p00_errNo, 0) \
P99_GUARDED_BLOCK(mtx_t*, \ P99_GUARDED_BLOCK(mtx_t*, \
...@@ -796,8 +797,12 @@ P99_GUARDED_BLOCK(mtx_t*, ...@@ -796,8 +797,12 @@ P99_GUARDED_BLOCK(mtx_t*,
), \ ), \
(void)(UNIQ \ (void)(UNIQ \
&& mtx_unlock(UNIQ))) && mtx_unlock(UNIQ)))
# else
# 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
P99_SETJMP_INLINE(p00_thrd_create) P99_SETJMP_INLINE(p00_thrd_create)
void * p00_thrd_create(void* p00_context); void * p00_thrd_create(void* p00_context);
......
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