Implementation of the thread-safe extension for exceptions4c.
More...
#include <stdio.h>
#include <errno.h>
#include <pthread.h>
#include <exceptions4c-pthreads.h>
|
#define | ASSERT_PTHREAD(message, function, ...) |
| Invokes a function and terminates the program on error.
|
|
#define | ASSERT_THAT(cause, message, assertion) |
| Causes abnormal program termination depending on assertion.
|
|
Implementation of the thread-safe extension for exceptions4c.
- Version
- 0.1.0
- Author
- Guillermo Calvo
- Copyright
- Licensed under Apache 2.0
- See also
- For more information, visit the project on GitHub
◆ ASSERT_PTHREAD
#define ASSERT_PTHREAD |
( |
| message, |
|
|
| function, |
|
|
| ... ) |
Value: do { \
const int error_code = function(__VA_ARGS__); \
if (error_code != 0) { \
print_error(message); \
errno = error_code; \
perror(#function); \
abort(); \
} \
} while (false)
Invokes a function and terminates the program on error.
- Parameters
-
message | The message to print to standard error output. |
function | The function to call. |
... | The arguments to pass to the function. |
◆ ASSERT_THAT
#define ASSERT_THAT |
( |
| cause, |
|
|
| message, |
|
|
| assertion ) |
Value: do { \
if (!(assertion)) { \
print_error(message); \
if (errno != 0) { \
perror(cause); \
} \
abort(); \
} \
} while (false)
Causes abnormal program termination depending on assertion.
- Parameters
-
assertion | The condition that must be true to avoid termination. |
cause | The cause of the problem. |
message | The message to print to standard error output. |
◆ e4c_pthreads_context_supplier()
struct e4c_context * e4c_pthreads_context_supplier |
( |
void | | ) |
|
Supplies a thread-safe exception context.
- Note
- This function MUST be passed to
e4c_set_context_supplier
so each thread will get its own exception context.
- Returns
- The thread-safe exception context.