diff options
Diffstat (limited to 'defer.h')
| -rw-r--r-- | defer.h | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -0,0 +1,20 @@ +#ifndef __DEFER_H__ +#define __DEFER_H__ + +#ifndef __unused +#define __unused __attribute__((unused)) +#endif + +#define __cleanup(f) __attribute__((cleanup(f))) + +#define CAT(a, b) CAT_(a, b) +#define CAT_(a, b) a ## b + +#define UNIQ(name) CAT(name, __LINE__) + +#define defer \ + auto void UNIQ(defer_func)(int *); \ + int UNIQ(defer_var) __cleanup(UNIQ(defer_func)); \ + void UNIQ(defer_func)(int *__arg __unused) + +#endif |
