Remove some warnings about uninitilized fields with CLANG.

This commit is contained in:
Patrick Pelissier committed 2017-12-16 18:24:17 +01:00
1 parent e2e902552e
commit 1efd7e84a7
2 files changed
+18 -3

No files matched your search

+4 -1
View File
@@ -3353,9 +3353,12 @@ cannot use return / goto to go outside the flow).
This macro needs either GCC (for nested function) or CLANG (for blocks) to This macro needs either GCC (for nested function) or CLANG (for blocks) to
work. work.
NOTE: Even if nested functions are used for GCC, it doesn't generate NOTE1: Even if nested functions are used for GCC, it doesn't generate
a trampoline and the stack doesn't need to be executable. a trampoline and the stack doesn't need to be executable.
NOTE2: For CLANG, you need to add -fblocks to CFLAGS and -lBlocksRuntime to LIB (See CLANG manual).
NOTE3: It will generate warnings about shadow variables. There is no way to avoid this.
### M-ALGO ### M-ALGO
+14 -2
View File
@@ -68,6 +68,18 @@ typedef struct {
#endif #endif
} worker_order_t; } worker_order_t;
/* Define the macros needed to initialize an order.
* * MACRO to be used to send an empty order to stop the thread
* * MACRO to complete the not-used fields
*/
#if WORKER_CLANG_BLOCK
# define WORKER_EMPTY_ORDER { NULL, NULL, NULL, NULL }
# define WORKER_EXTRA_ORDER , NULL
#else
# define WORKER_EMPTY_ORDER { NULL, NULL, NULL }
# define WORKER_EXTRA_ORDER
#endif
/* This type defines a worker */ /* This type defines a worker */
typedef struct { typedef struct {
m_thread_t id; m_thread_t id;
@@ -171,7 +183,7 @@ static inline void
worker_clear(worker_t g) worker_clear(worker_t g)
{ {
for(unsigned int i = 0; i < g->numWorker_g; i++) { for(unsigned int i = 0; i < g->numWorker_g; i++) {
worker_order_t w = { NULL, NULL, NULL}; worker_order_t w = WORKER_EMPTY_ORDER;
worker_queue_push (g->queue_g, w); worker_queue_push (g->queue_g, w);
} }
@@ -197,7 +209,7 @@ worker_start(worker_block_t block)
static inline void static inline void
worker_spawn(worker_t g, worker_block_t block, void (*func)(void *data), void *data) worker_spawn(worker_t g, worker_block_t block, void (*func)(void *data), void *data)
{ {
const worker_order_t w = { block, data, func }; const worker_order_t w = { block, data, func WORKER_EXTRA_ORDER };
if (M_UNLIKELY (!worker_queue_full_p(g->queue_g)) if (M_UNLIKELY (!worker_queue_full_p(g->queue_g))
&& worker_queue_push (g->queue_g, w) == true) { && worker_queue_push (g->queue_g, w) == true) {
//printf ("Sending data to thread: %p (block: %d / %d)\n", data, block->num_spawn, block->num_terminated_spawn); //printf ("Sending data to thread: %p (block: %d / %d)\n", data, block->num_spawn, block->num_terminated_spawn);