summaryrefslogtreecommitdiff
path: root/server/util
diff options
context:
space:
mode:
Diffstat (limited to 'server/util')
-rw-r--r--server/util/util.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/server/util/util.h b/server/util/util.h
index 9c8679ec..945e20d0 100644
--- a/server/util/util.h
+++ b/server/util/util.h
@@ -162,6 +162,28 @@ errno_t set_debug_file_from_fd(const int fd);
#define OUT_OF_ID_RANGE(id, min, max) \
(id == 0 || (min && (id < min)) || (max && (id > max)))
+#define COPY_MEM(to, from, ptr, size) do { \
+ memcpy(to, from, size); \
+ ptr += size; \
+} while(0)
+
+#define COPY_TYPE(to, from, ptr, type) COPY_MEM(to, from, ptr, sizeof(type))
+
+#define COPY_VALUE(to, value, ptr, type) do { \
+ type CV_MACRO_val = (type) value; \
+ COPY_TYPE(to, &CV_MACRO_val, ptr, type); \
+} while(0)
+
+#define COPY_UINT32(to, from, ptr) COPY_TYPE(to, from, ptr, uint32_t)
+#define COPY_UINT32_VALUE(to, value, ptr) COPY_VALUE(to, value, ptr, uint32_t)
+#define COPY_INT32(to, from, ptr) COPY_TYPE(to, from, ptr, int32_t)
+#define COPY_INT32_VALUE(to, value, ptr) COPY_VALUE(to, value, ptr, int32_t)
+
+#define COPY_UINT32_CHECK(to, from, ptr, size) do { \
+ if ((ptr + sizeof(uint32_t)) > size) return EINVAL; \
+ COPY_UINT32(to, from, ptr); \
+} while(0)
+
#include "util/dlinklist.h"
/* From debug.c */