Преглед изворни кода

make sure plugin code doesn't have its own instances of global variables but uses the ones from the main program

ambrop7 пре 13 година
родитељ
комит
e1cda2fad8
5 измењених фајлова са 13 додато и 1 уклоњено
  1. 1 1
      CMakeLists.txt
  2. 4 0
      base/BLog.c
  3. 2 0
      base/DebugObject.c
  4. 4 0
      system/BNetwork.c
  5. 2 0
      system/BTime.c

+ 1 - 1
CMakeLists.txt

@@ -269,7 +269,7 @@ function(badvpn_add_library LIB_NAME LINK_BADVPN_LIBS LINK_SYS_LIBS LIB_SOURCES)
     add_library("${LIB_NAME}-plugin" STATIC ${LIB_SOURCES})
     target_link_libraries("${LIB_NAME}-plugin" ${BADVPN_LIBS_PLUGIN} ${LINK_SYS_LIBS})
     set_target_properties("${LIB_NAME}-plugin" PROPERTIES POSITION_INDEPENDENT_CODE YES)
-    set_target_properties("${LIB_NAME}-plugin" PROPERTIES COMPILE_FLAGS "-fvisibility=hidden")
+    set_target_properties("${LIB_NAME}-plugin" PROPERTIES COMPILE_FLAGS "-fvisibility=hidden -DBADVPN_PLUGIN")
 endfunction()
 
 # internal libraries

+ 4 - 0
base/BLog.c

@@ -32,6 +32,8 @@
 
 #include "BLog.h"
 
+#ifndef BADVPN_PLUGIN
+
 struct _BLog_channel blog_channel_list[] = {
 #include <generated/blog_channels_list.h>
 };
@@ -42,6 +44,8 @@ struct _BLog_global blog_global = {
     #endif
 };
 
+#endif
+
 // keep in sync with level numbers in BLog.h!
 static char *level_names[] = { NULL, "ERROR", "WARNING", "NOTICE", "INFO", "DEBUG" };
 

+ 2 - 0
base/DebugObject.c

@@ -29,9 +29,11 @@
 
 #include "DebugObject.h"
 
+#ifndef BADVPN_PLUGIN
 #ifndef NDEBUG
 DebugCounter debugobject_counter = DEBUGCOUNTER_STATIC;
 #ifdef BADVPN_THREADWORK_USE_PTHREAD
 pthread_mutex_t debugobject_mutex = PTHREAD_MUTEX_INITIALIZER;
 #endif
 #endif
+#endif

+ 4 - 0
system/BNetwork.c

@@ -43,7 +43,11 @@
 
 #include <generated/blog_channel_BNetwork.h>
 
+extern int bnetwork_initialized;
+
+#ifndef BADVPN_PLUGIN
 int bnetwork_initialized = 0;
+#endif
 
 int BNetwork_GlobalInit (void)
 {

+ 2 - 0
system/BTime.c

@@ -29,8 +29,10 @@
 
 #include <system/BTime.h>
 
+#ifndef BADVPN_PLUGIN
 struct _BTime_global btime_global = {
     #ifndef NDEBUG
     0
     #endif
 };
+#endif