123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- #ifndef TEMPLATE_T
- #error Please define TEMPLATE_T as an element type to use in this template.
- #undef TEMPLATE_OK
- #endif
- #ifdef TEMPLATE_NEEDS_U
- #ifndef TEMPLATE_U
- #error Please define TEMPLATE_U as an element type to use in this template.
- #undef TEMPLATE_OK
- #endif
- #endif
- #ifdef TEMPLATE_NEEDS_V
- #ifndef TEMPLATE_V
- #error Please define TEMPLATE_V as an element type to use in this template.
- #undef TEMPLATE_OK
- #endif
- #endif
- #ifdef TEMPLATE_NEEDS_W
- #ifndef TEMPLATE_W
- #error Please define TEMPLATE_W as an element type to use this template.
- #undef TEMPLATE_OK
- #endif
- #endif
- #ifndef TEMPLATE_NAME
- #error Please define TEMPLATE_NAME to be the name of the main templated type.
- #undef TEMPLATE_OK
- #endif
- #ifndef TEMPLATE_PREFIX
- #define TEMPLATE_PREFIX TEMPLATE_NAME
- #endif
- #ifndef TEMPLATE_ALLOC
- #define TEMPLATE_ALLOC(SIZE) calloc(SIZE, 1)
- #endif
- #ifndef TEMPLATE_FREE
- #define TEMPLATE_FREE(MEM) free(MEM)
- #endif
- #include <stdlib.h>
-
- #define TSTR_HELPER(S) #S
- #define TSTR(S) TSTR_HELPER(S)
- #define TJOIN_HELPER(A, B) A##B
- #define TJOIN(A,B) TJOIN_HELPER(A,B)
- #define TSTRUCT(NAME) TJOIN(NAME, _struct)
- #define TFUNC(NAME, FUNC) TJOIN(NAME, FUNC)
- #define TEMPLATE_STRUCT TSTRUCT(TEMPLATE_NAME)
- #define TEMPLATE_FUNC(FUNC) TFUNC(TEMPLATE_PREFIX, FUNC)
- #ifndef FALSE
- #define FALSE 0
- #endif
- #ifndef TRUE
- #define TRUE (!FALSE)
- #endif
- #if defined(TEMPLATE_NAME) && defined(TEMPLATE_T)
- #define TEMPLATE_OK 1
- #else
- #undef TEMPLATE_OK
- #endif
|