Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

elog.h 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #define ELOG(o, msg, ...) do { \
  17. __attribute__((section("elog"))) static const char p_msg[] = msg; \
  18. IF_ELSE(HAS_ARGS(__VA_ARGS__))( \
  19. elog_put(o, p_msg, ELOG_NARG(__VA_ARGS__)/*计算出有多少个参数*/, (msgparam_t[]){ msgparam_cast_apply(__VA_ARGS__) }/*参数数组*/); \
  20. )( \
  21. elog_put(o, p_msg, 0, (msgparam_t[]){}); \
  22. ) \
  23. } while(0)
  24. typedef void (elog_flush_func_t)(elog_entry_t *e, int len, void *ctx);
  25. extern elog_t *elog_init(void *arena, size_t size);
  26. extern int elog_put(elog_t *log, const char *const msg, int n, msgparam_t args[]);
  27. extern elog_entry_t *elog_peek(elog_t *log);
  28. extern void elog_flush(elog_t *log, elog_flush_func_t func, void *ctx);
  29. #ifdef __cplusplus
  30. }
  31. #endif
  32. #endif /* __ELOG_H__ */