123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #ifndef TPL_H
- #define TPL_H
- #include <stddef.h> /* size_t */
- #include <stdarg.h> /* va_list */
- #ifdef __INTEL_COMPILER
- #include <tbb/tbbmalloc_proxy.h>
- #endif
- #ifdef _MSC_VER
- typedef unsigned int uint32_t;
- #else
- #include <inttypes.h> /* uint32_t */
- #endif
- #if defined __cplusplus
- extern "C" {
- #endif
- #ifdef _WIN32
- #ifdef TPL_EXPORTS
- #define TPL_API __declspec(dllexport)
- #else
- #ifdef TPL_NOLIB
- #define TPL_API
- #else
- #define TPL_API __declspec(dllimport)
- #endif
- #endif
- #else
- #define TPL_API
- #endif
- #define TPL_FILE (1 << 0)
- #define TPL_MEM (1 << 1)
- #define TPL_PREALLOCD (1 << 2)
- #define TPL_EXCESS_OK (1 << 3)
- #define TPL_FD (1 << 4)
- #define TPL_UFREE (1 << 5)
- #define TPL_DATAPEEK (1 << 6)
- #define TPL_FXLENS (1 << 7)
- #define TPL_GETSIZE (1 << 8)
- #define TPL_GATHER_BLOCKING 1
- #define TPL_GATHER_NONBLOCKING 2
- #define TPL_GATHER_MEM 3
- typedef int (tpl_print_fcn)(const char *fmt, ...);
- typedef void *(tpl_malloc_fcn)(size_t sz);
- typedef void *(tpl_realloc_fcn)(void *ptr, size_t sz);
- typedef void (tpl_free_fcn)(void *ptr);
- typedef void (tpl_fatal_fcn)(const char *fmt, ...);
- typedef struct tpl_hook_t {
- tpl_print_fcn *oops;
- tpl_malloc_fcn *malloc;
- tpl_realloc_fcn *realloc;
- tpl_free_fcn *free;
- tpl_fatal_fcn *fatal;
- size_t gather_max;
- } tpl_hook_t;
- typedef struct tpl_node {
- int type;
- void *addr;
- void *data;
- int num;
- size_t ser_osz;
- struct tpl_node *children;
- struct tpl_node *next,*prev;
- struct tpl_node *parent;
- } tpl_node;
- typedef struct tpl_bin {
- void *addr;
- uint32_t sz;
- } tpl_bin;
- typedef struct tpl_gather_t {
- char *img;
- int len;
- } tpl_gather_t;
- typedef int (tpl_gather_cb)(void *img, size_t sz, void *data);
- TPL_API tpl_node *tpl_map(char *fmt,...);
- TPL_API void tpl_free(tpl_node *r);
- TPL_API int tpl_pack(tpl_node *r, int i);
- TPL_API int tpl_unpack(tpl_node *r, int i);
- TPL_API int tpl_dump(tpl_node *r, int mode, ...);
- TPL_API int tpl_load(tpl_node *r, int mode, ...);
- TPL_API int tpl_Alen(tpl_node *r, int i);
- TPL_API char* tpl_peek(int mode, ...);
- TPL_API int tpl_gather( int mode, ...);
- TPL_API int tpl_jot(int mode, ...);
- TPL_API tpl_node *tpl_map_va(char *fmt, va_list ap);
- #if defined __cplusplus
- }
- #endif
- #endif
|