Commit de4c1bfb authored by Martin Uecker's avatar Martin Uecker

types.h more self-sustaining

parent 1ce3ed79
......@@ -10,11 +10,21 @@
#ifndef __TYPES_H
#define __TYPES_H
#include <stddef.h>
#include <stdnoreturn.h>
#ifndef __cplusplus
extern noreturn void error(const char* str, ...);
#else
extern __attribute__((noreturn)) void error(const char* str, ...);
#endif
#define TYPE_CHECK(T, x) (1 ? (x) : (T)0)
#define CONTAINER_OF(x, T, member) \
((T*)((char*)TYPE_CHECK(__typeof__(&((T*)0)->member), x) - offsetof(T, member)))
#define CAST_CONST(T, x) ((T)TYPE_CHECK(const T, x))
#define CAST_MAYBE(T, x) ({ \
__typeof__(x) __tmp = (x); \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment