From 36d6f635415e6d3b517ff7689137c5ab14c16d61 Mon Sep 17 00:00:00 2001
From: armatusmiles <akurotych@gmail.com>
Date: Mon, 14 Jan 2019 18:40:28 +0700
Subject: [PATCH] [+] linux dir, .pri files and C++ definitions

---
 core/core.pri                               |  2 ++
 core/unix/dap_cpu_monitor.h                 |  9 +++++++++
 core/unix/dap_process_manager.h             |  8 ++++++++
 core/unix/dap_process_memory.h              |  8 ++++++++
 core/unix/{ => linux}/dap_network_monitor.c |  0
 core/unix/{ => linux}/dap_network_monitor.h |  8 ++++++++
 core/unix/linux/linux.pri                   |  5 +++++
 core/unix/unix.pri                          | 13 +++++++++++++
 unix.pri                                    |  9 +++++++++
 9 files changed, 62 insertions(+)
 rename core/unix/{ => linux}/dap_network_monitor.c (100%)
 rename core/unix/{ => linux}/dap_network_monitor.h (97%)
 create mode 100644 core/unix/linux/linux.pri
 create mode 100644 core/unix/unix.pri
 create mode 100644 unix.pri

diff --git a/core/core.pri b/core/core.pri
index 018e0e0..62dd630 100644
--- a/core/core.pri
+++ b/core/core.pri
@@ -1,3 +1,5 @@
+include(unix/unix.pri)
+
 HEADERS += $$PWD/dap_common.h \
     $$PWD/dap_config.h \
     $$PWD/dap_math_ops.h \
diff --git a/core/unix/dap_cpu_monitor.h b/core/unix/dap_cpu_monitor.h
index cc63594..ed15e28 100644
--- a/core/unix/dap_cpu_monitor.h
+++ b/core/unix/dap_cpu_monitor.h
@@ -24,6 +24,11 @@
 
 #pragma once
 
+// For C++
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #define MAX_CPU_COUNT 64
 
 #include <stdlib.h>
@@ -58,3 +63,7 @@ void dap_cpu_monitor_deinit(void);
  * @return
  */
 dap_cpu_stats_t dap_cpu_get_stats(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/core/unix/dap_process_manager.h b/core/unix/dap_process_manager.h
index b35bfeb..9ac46bf 100755
--- a/core/unix/dap_process_manager.h
+++ b/core/unix/dap_process_manager.h
@@ -22,6 +22,10 @@
     along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifdef __linux__
 
 #include <stdbool.h>
@@ -44,3 +48,7 @@ extern bool daemonize_process(void);
 extern bool kill_process(pid_t pid);
 
 #endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/core/unix/dap_process_memory.h b/core/unix/dap_process_memory.h
index d07b318..f436768 100644
--- a/core/unix/dap_process_memory.h
+++ b/core/unix/dap_process_memory.h
@@ -22,6 +22,10 @@
     along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdint.h>
 #include <sys/types.h>
 
@@ -44,3 +48,7 @@ dap_process_memory_t get_proc_mem_current(void);
  * @return
  */
 dap_process_memory_t get_proc_mem_by_pid(pid_t pid);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/core/unix/dap_network_monitor.c b/core/unix/linux/dap_network_monitor.c
similarity index 100%
rename from core/unix/dap_network_monitor.c
rename to core/unix/linux/dap_network_monitor.c
diff --git a/core/unix/dap_network_monitor.h b/core/unix/linux/dap_network_monitor.h
similarity index 97%
rename from core/unix/dap_network_monitor.h
rename to core/unix/linux/dap_network_monitor.h
index b81e588..a8b04ca 100644
--- a/core/unix/dap_network_monitor.h
+++ b/core/unix/linux/dap_network_monitor.h
@@ -22,6 +22,10 @@
     along with any DAP based project.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdint.h>
 #include <stdbool.h>
 #include <net/if.h>
@@ -71,3 +75,7 @@ int dap_network_monitor_init(dap_network_monitor_notification_callback_t callbac
  * @brief dap_network_monitor_deinit
  */
 void dap_network_monitor_deinit(void);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/core/unix/linux/linux.pri b/core/unix/linux/linux.pri
new file mode 100644
index 0000000..05fc40b
--- /dev/null
+++ b/core/unix/linux/linux.pri
@@ -0,0 +1,5 @@
+HEADERS += $$PWD/dap_network_monitor.h \
+
+SOURCES += $$PWD/dap_network_monitor.c \
+
+INCLUDEPATH += $$PWD
diff --git a/core/unix/unix.pri b/core/unix/unix.pri
new file mode 100644
index 0000000..e81e162
--- /dev/null
+++ b/core/unix/unix.pri
@@ -0,0 +1,13 @@
+linux-* {
+    include(linux/linux.pri)
+}
+
+HEADERS += $$PWD/dap_cpu_monitor.h \
+           $$PWD/dap_process_manager.h \
+           $$PWD/dap_process_memory.h \
+
+SOURCES += $$PWD/dap_cpu_monitor.c \
+           $$PWD/dap_process_manager.c \
+           $$PWD/dap_process_memory.c \
+
+INCLUDEPATH += $$PWD
diff --git a/unix.pri b/unix.pri
new file mode 100644
index 0000000..4898540
--- /dev/null
+++ b/unix.pri
@@ -0,0 +1,9 @@
+include(linux)
+
+HEADERS += $$PWD/dap_cpu_monitor.h \
+            $$PWD/dap_network_monitor.h \
+
+SOURCES += $$PWD/dap_cpu_monitor.c \
+           $$PWD/dap_network_monitor.c
+
+INCLUDEPATH += $$PWD
-- 
GitLab