summaryrefslogtreecommitdiff
path: root/entry/include/base_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'entry/include/base_utils.h')
-rw-r--r--entry/include/base_utils.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/entry/include/base_utils.h b/entry/include/base_utils.h
new file mode 100644
index 0000000..311ec78
--- /dev/null
+++ b/entry/include/base_utils.h
@@ -0,0 +1,44 @@
+#pragma once
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+#include <unistd.h>
+#include <inttypes.h>
+#include <arpa/inet.h>
+#include <netinet/ip6.h>
+#include <net/if.h>
+#include <string.h>
+#include <pthread.h>
+#include "MESA/MESA_handle_logger.h"
+
+#ifndef MAX
+#define MAX(a, b) (((a) > (b)) ? (a) : (b))
+#endif
+
+#ifndef MIN
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#endif
+
+#define STRING_MAX 128
+
+#define likely(expr) __builtin_expect((expr), 1)
+#define unlikely(expr) __builtin_expect((expr), 0)
+
+#define ALLOC(type, number) ((type *)calloc(sizeof(type), number))
+#define FREE(p) {free(*p);*p=NULL;}
+
+#define LOG_ERROR(handler, fmt, ...) \
+do { \
+ MESA_handle_runtime_log(handler, RLOG_LV_FATAL, "kni", fmt, ##__VA_ARGS__); } while(0)
+
+#define LOG_INFO(handler, fmt, ...) \
+do { \
+ MESA_handle_runtime_log(handler, RLOG_LV_INFO, "kni", fmt, ##__VA_ARGS__); } while(0)
+
+#define LOG_DEBUG(handler, fmt, ...) \
+do { \
+ MESA_handle_runtime_log(handler, RLOG_LV_DEBUG, "kni", fmt, ##__VA_ARGS__); } while(0)
+
+ \ No newline at end of file