summaryrefslogtreecommitdiffstats
path: root/code/jasmine/misc.h
diff options
context:
space:
mode:
authorZhijiang Hu <hu.zhijiang@zte.com.cn>2017-04-06 23:21:42 -0400
committerZhijiang Hu <hu.zhijiang@zte.com.cn>2017-04-07 03:52:25 -0400
commit7c577e23dde00c759db0cca0898809c3d278b37a (patch)
tree7f8942a599a9b4dbf19f12c8179ded86834cdaa9 /code/jasmine/misc.h
parentd24bd81e5689c5d8531581fb8e3604d6851cc094 (diff)
jasmine(Just A Simple Multicast engINE) Initial mergev1.0.2
Change-Id: I7a543019c8d92314ef549bf72369b7276f39577d Signed-off-by: Zhijiang Hu <hu.zhijiang@zte.com.cn>
Diffstat (limited to 'code/jasmine/misc.h')
-rwxr-xr-xcode/jasmine/misc.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/code/jasmine/misc.h b/code/jasmine/misc.h
new file mode 100755
index 00000000..e60d0b63
--- /dev/null
+++ b/code/jasmine/misc.h
@@ -0,0 +1,39 @@
+/*##############################################################################
+# Copyright (c) 2017 ZTE Coreporation and others.
+# hu.zhijiang@zte.com.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################*/
+
+#ifndef _MCAST_MISC_H
+#define _MCAST_MISC_H
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <error.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/syscall.h>
+#define gettid() syscall(__NR_gettid)
+
+#define level 6
+
+#define crit(x, args...) do { \
+ fprintf(stderr, "\nERROR: "); fprintf(stderr, x, ##args); \
+ error(-1,errno, "\nERROR: [%s:%d:%ld] ", __FILE__, __LINE__, gettid()); \
+} while (0);
+
+#define log(l, f, args...) if (l < level) { \
+ fprintf(stderr, "\n[%s:%d:%ld] ", __FILE__, __LINE__, gettid()); \
+ fprintf(stderr, f, ##args); \
+ fprintf(stderr, "\n"); \
+}
+
+struct sockaddr_in make_addr(char *addr, unsigned short port);
+void * wrapper_malloc(size_t size);
+void set_nonblock(int s);
+size_t read_all(int fd, void *buf, size_t count);
+
+#endif