Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

elog.h 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef __ELOG_H__
  2. #define __ELOG_H__
  3. #include <stddef.h>
  4. #include "elog-cpp.h"
  5. #include "elog-internal.h"
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9. typedef struct {
  10. ptrdiff_t buflen;
  11. ptrdiff_t offset;
  12. char buffer[0];
  13. } __attribute__((__packed__)) elog_t;
  14. #define _msgparam_cast_apply(x) ((long) (x)),
  15. #define msgparam_cast_apply(...) EVAL(MAP(_msgparam_cast_apply, __VA_ARGS__))
  16. /*计算出有多少个参数, 参数数组*/
  17. #define ELOG(o, msg, ...) do { \
  18. __attribute__((section("elog"))) static const char p_msg[] = msg; \
  19. IF_ELSE(HAS_ARGS(__VA_ARGS__))( \
  20. elog_put(o, p_msg, ELOG_NARG(__VA_ARGS__), (msgparam_t[]){ msgparam_cast_apply(__VA_ARGS__) }); \
  21. )( \
  22. elog_put(o, p_msg, 0, NULL); \
  23. ) \
  24. } while(0)
  25. typedef void (elog_flush_func_t)(elog_entry_t *e, int len, void *ctx);
  26. extern elog_t *elog_init(void *arena, size_t size);
  27. extern int elog_put(elog_t *log, const char *const msg, int n, msgparam_t args[]);
  28. extern elog_entry_t *elog_peek(elog_t *log);
  29. extern void elog_flush(elog_t *log, elog_flush_func_t func, void *ctx);
  30. #ifdef __cplusplus
  31. }
  32. #endif
  33. #endif /* __ELOG_H__ */