diff options
author | Thomas White <taw@physics.org> | 2011-01-11 17:34:50 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2012-02-22 15:27:10 +0100 |
commit | 3dc2ba04ab33be723d2ea8dfe1638a127519a0ae (patch) | |
tree | 200aaefb204543a0b3840c24b38bcbc21a16e18e /src/utils.h | |
parent | 5ed6541407ce99c4036d0e768546fe554f9fa5c2 (diff) |
Prefix STATUS() and ERROR() messages with a unique thread number, where appropriate
Diffstat (limited to 'src/utils.h')
-rw-r--r-- | src/utils.h | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/utils.h b/src/utils.h index 29e2aeda..30ab27c8 100644 --- a/src/utils.h +++ b/src/utils.h @@ -20,6 +20,10 @@ #include <complex.h> #include <string.h> #include <stdlib.h> +#include <pthread.h> + + +#include "thread-pool.h" /* -------------------------- Fundamental constants ------------------------ */ @@ -216,8 +220,27 @@ extern ReflItemList *intersection_items(ReflItemList *i1, ReflItemList *i2); /* ------------------------------ Message macros ---------------------------- */ -#define ERROR(...) fprintf(stderr, __VA_ARGS__) -#define STATUS(...) fprintf(stderr, __VA_ARGS__) +extern pthread_mutex_t stderr_lock; + +#define ERROR(...) { \ + int val = get_status_label(); \ + pthread_mutex_lock(&stderr_lock); \ + if ( val >= 0 ) { \ + fprintf(stderr, "%3i: ", val); \ + } \ + fprintf(stderr, __VA_ARGS__); \ + pthread_mutex_unlock(&stderr_lock); \ + } + +#define STATUS(...) { \ + int val = get_status_label(); \ + pthread_mutex_lock(&stderr_lock); \ + if ( val >= 0 ) { \ + fprintf(stderr, "%3i: ", val); \ + } \ + fprintf(stderr, __VA_ARGS__); \ + pthread_mutex_unlock(&stderr_lock); \ + } /* ------------------------------ File handling ----------------------------- */ |