Update for perl script; added return type handling.
This commit is contained in:
parent
f68e6b9dd3
commit
f4484e35b5
2 changed files with 33 additions and 1 deletions
|
@ -1,4 +1,9 @@
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <lladd/common.h>
|
||||||
|
#ifndef __COMPENSATIONS_H
|
||||||
|
#define __COMPENSATIONS_H
|
||||||
|
|
||||||
|
BEGIN_C_DECLS
|
||||||
|
|
||||||
/** Rants about cpp:
|
/** Rants about cpp:
|
||||||
|
|
||||||
|
@ -9,7 +14,7 @@ foo() {
|
||||||
|
|
||||||
// stuff
|
// stuff
|
||||||
|
|
||||||
compensate(l) {
|
compensate_(l) {
|
||||||
lock(l);
|
lock(l);
|
||||||
// blah blah
|
// blah blah
|
||||||
} with {
|
} with {
|
||||||
|
@ -94,6 +99,7 @@ void lock_c_line_1231(lock * l) {
|
||||||
Also, begin_action(NULL, NULL) is supported, and is useful for
|
Also, begin_action(NULL, NULL) is supported, and is useful for
|
||||||
checking the return value of a called function.
|
checking the return value of a called function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void compensations_init();
|
void compensations_init();
|
||||||
void compensations_deinit();
|
void compensations_deinit();
|
||||||
int compensation_error();
|
int compensation_error();
|
||||||
|
@ -119,3 +125,28 @@ void compensation_set_error(int code);
|
||||||
if(compensation_error()) return; \
|
if(compensation_error()) return; \
|
||||||
} while(0)
|
} while(0)
|
||||||
|
|
||||||
|
#define begin_action_ret(func, var, ret) \
|
||||||
|
if(compensation_error()) return (ret); \
|
||||||
|
do{ \
|
||||||
|
void (*_func_)(void*); \
|
||||||
|
pthread_cleanup_push(_func_=(void(*)(void*))(func), (void*)(var));\
|
||||||
|
do
|
||||||
|
|
||||||
|
#define end_action_ret(ret) \
|
||||||
|
while(0); \
|
||||||
|
pthread_cleanup_pop(_func_ && compensation_error()); \
|
||||||
|
if(compensation_error()) return (ret); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#define compensate_ret(ret) \
|
||||||
|
while(0); \
|
||||||
|
pthread_cleanup_pop((int)_func_); \
|
||||||
|
if(compensation_error()) return (ret); \
|
||||||
|
} while(0)
|
||||||
|
|
||||||
|
#define compensated_function
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
END_C_DECLS
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <lladd/compensations.h>
|
#include <lladd/compensations.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
pthread_key_t error_key;
|
pthread_key_t error_key;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue