forked from lei.chen/myxce
use nix build & meson & zlog
This commit is contained in:
parent
0123623742
commit
346768a144
60 changed files with 13739 additions and 0 deletions
94
src/include/utils.h
Normal file
94
src/include/utils.h
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#if !defined(_UTILS_H_)
|
||||
|
||||
#define _UTILS_H_
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <capnp_c.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "controller.capnp.h"
|
||||
#include "xce/errnox.h"
|
||||
#include "xce/types.h"
|
||||
|
||||
#define xce_use(x) (void)(x)
|
||||
|
||||
#define float_near_zero (0.000001)
|
||||
|
||||
#define float_equal(a, b) (fabs((a) - (b)) < float_near_zero)
|
||||
|
||||
#define STR(x) _STR(x)
|
||||
#define _STR(x) #x
|
||||
|
||||
#define MK_VERSION(ver, commit) ver commit
|
||||
|
||||
#ifndef FREEUP
|
||||
#define FREEUP(p) \
|
||||
if ((p) != NULL) { \
|
||||
free(p); \
|
||||
(p) = NULL; \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define N_EL_ARRAY(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
#define PTR_STEP(p, delta) \
|
||||
((void*)(((char*)p) + (delta)))
|
||||
|
||||
#define N_EL_ARRAY(arr) (sizeof(arr) / sizeof(arr[0]))
|
||||
#define PTR_STEP(p, delta) \
|
||||
((void*)(((char*)p) + (delta)))
|
||||
|
||||
/* move the owner ship of pointer from src to dst */
|
||||
#define MOVE_PTR(dst, src) \
|
||||
do { \
|
||||
(dst) = (src); \
|
||||
(src) = NULL; \
|
||||
} while (0)
|
||||
|
||||
#define NULLSTR(p) (((p) == NULL) || (strlen(p) == 0))
|
||||
|
||||
#define SET_ERROR(code) \
|
||||
do { \
|
||||
set_error((char*)__FILE__, \
|
||||
(char*)__func__, \
|
||||
__LINE__, \
|
||||
(code)); \
|
||||
} while (0)
|
||||
|
||||
#define PERROR(s) xce_perror(s)
|
||||
|
||||
typedef struct {
|
||||
char* file;
|
||||
char* func;
|
||||
int line;
|
||||
int code;
|
||||
} ectx_t;
|
||||
|
||||
#define TRACE(...)
|
||||
#define WARN(...)
|
||||
|
||||
extern capn_text chars_to_text(const char*);
|
||||
extern int parse_argv(char*, char***);
|
||||
extern void free_argv(char**, int);
|
||||
extern void freeup_kvs(int, xce_kv_t*);
|
||||
extern int mylog_init(char*, char*, char*, int, int);
|
||||
extern void mylog_fini(void);
|
||||
extern int mylog_setlevel(char*);
|
||||
extern void set_error(char*, char*, int, int);
|
||||
extern ectx_t* get_ectx(void);
|
||||
extern int xce_vprintf(const char*, va_list);
|
||||
extern int xce_strerror_r(int, char*, size_t);
|
||||
extern void xce_perror(const char*);
|
||||
extern char* frame_symbol(int);
|
||||
extern int copy_int_list(int**, int*, int);
|
||||
extern int copy_strlist(xce_strlist_t*, xce_strlist_t);
|
||||
extern void free_timewindow_config(xce_timewindow_config_t*);
|
||||
extern xce_timewindow_config_t* dup_timewindow_config(xce_timewindow_config_t*);
|
||||
extern void free_resource_thresholds(xce_res_threshold_t**, int);
|
||||
extern xce_res_threshold_t** dup_resource_thresholds(xce_res_threshold_t**, int);
|
||||
extern void free_resval_with_idx_list(xce_val_with_idx_t***, int);
|
||||
extern void free_strlist(xce_strlist_t*);
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue