add a 'lumiera_err' typedef
This commit is contained in:
parent
9826fd180d
commit
93e126f5ab
2 changed files with 11 additions and 10 deletions
|
|
@ -46,12 +46,12 @@ lumiera_error_tls_init (void)
|
|||
}
|
||||
|
||||
|
||||
const char*
|
||||
lumiera_error_set (const char * nerr)
|
||||
lumiera_err
|
||||
lumiera_error_set (lumiera_err nerr)
|
||||
{
|
||||
pthread_once (&lumiera_error_initialized, lumiera_error_tls_init);
|
||||
|
||||
const char* err = pthread_getspecific (lumiera_error_tls);
|
||||
lumiera_err err = pthread_getspecific (lumiera_error_tls);
|
||||
if (!err)
|
||||
pthread_setspecific (lumiera_error_tls, nerr);
|
||||
|
||||
|
|
@ -59,12 +59,12 @@ lumiera_error_set (const char * nerr)
|
|||
}
|
||||
|
||||
|
||||
const char*
|
||||
lumiera_err
|
||||
lumiera_error ()
|
||||
{
|
||||
pthread_once (&lumiera_error_initialized, lumiera_error_tls_init);
|
||||
|
||||
const char* err = pthread_getspecific (lumiera_error_tls);
|
||||
lumiera_err err = pthread_getspecific (lumiera_error_tls);
|
||||
if (err)
|
||||
pthread_setspecific (lumiera_error_tls, NULL);
|
||||
return err;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ extern "C" {
|
|||
* C Error handling in Lumiera, header.
|
||||
*/
|
||||
|
||||
typedef const char* lumiera_err;
|
||||
|
||||
/**
|
||||
* Abort unconditionally with a 'Fatal Error!' message.
|
||||
|
|
@ -49,7 +50,7 @@ extern "C" {
|
|||
* @param err name of the error without the 'LUMIERA_ERROR_' prefix (example: NO_MEMORY)
|
||||
*/
|
||||
#define LUMIERA_ERROR_DECLARE(err) \
|
||||
extern const char* LUMIERA_ERROR_##err
|
||||
extern lumiera_err LUMIERA_ERROR_##err
|
||||
|
||||
/**
|
||||
* Definition and initialization of an error constant.
|
||||
|
|
@ -58,7 +59,7 @@ extern const char* LUMIERA_ERROR_##err
|
|||
* @param msg message describing the error in plain english (example: "memory allocation failed")
|
||||
*/
|
||||
#define LUMIERA_ERROR_DEFINE(err, msg) \
|
||||
const char* LUMIERA_ERROR_##err = "LUMIERA_ERROR_" #err ":" msg
|
||||
lumiera_err LUMIERA_ERROR_##err = "LUMIERA_ERROR_" #err ":" msg
|
||||
|
||||
/**
|
||||
* Helper macro to raise an error for the current thread.
|
||||
|
|
@ -77,8 +78,8 @@ lumiera_error_set(LUMIERA_ERROR_##err))
|
|||
* @return old state, that is NULL for success, when the state was cleared and a pointer to a pending
|
||||
* error when the error state was already set
|
||||
*/
|
||||
const char*
|
||||
lumiera_error_set (const char * err);
|
||||
lumiera_err
|
||||
lumiera_error_set (lumiera_err err);
|
||||
|
||||
/**
|
||||
* Get and clear current error state.
|
||||
|
|
@ -86,7 +87,7 @@ lumiera_error_set (const char * err);
|
|||
* variable.
|
||||
* @return pointer to any pending error of this thread, NULL if no error is pending
|
||||
*/
|
||||
const char*
|
||||
lumiera_err
|
||||
lumiera_error ();
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue