# HG changeset patch
# User laurent
# Date 1251891527 -7200
# Node ID 2932b0dd437c7915548c5e8e1f4e4fde65239541
# Parent  49cd52914a6f3fb010ebdc698bb42f38cc4e27da
Applying patch from Iztok for old gcc versions

diff -r 49cd52914a6f -r 2932b0dd437c targets/Linux/plc_Linux_main.c
--- a/targets/Linux/plc_Linux_main.c	Tue Sep 01 10:45:07 2009 +0200
+++ b/targets/Linux/plc_Linux_main.c	Wed Sep 02 13:38:47 2009 +0200
@@ -124,6 +124,7 @@
     pthread_mutex_destroy(&debug_wait_mutex);
     pthread_mutex_unlock(&python_wait_mutex);
     pthread_mutex_destroy(&python_wait_mutex);
+    return 0;
 }
 
 extern int __tick;
diff -r 49cd52914a6f -r 2932b0dd437c targets/plc_common_main.c
--- a/targets/plc_common_main.c	Tue Sep 01 10:45:07 2009 +0200
+++ b/targets/plc_common_main.c	Wed Sep 02 13:38:47 2009 +0200
@@ -58,12 +58,12 @@
  **/
 int __init(int argc,char **argv)
 {
-    int res;
+    int res = 0;
     setlocale(LC_NUMERIC, "C");
     config_init__();
     __init_debug();
     %(init_calls)s
-    return 0;
+    return res;
 }
 /*
  * Calls plugin cleanup proc.
diff -r 49cd52914a6f -r 2932b0dd437c targets/plc_debug.c
--- a/targets/plc_debug.c	Tue Sep 01 10:45:07 2009 +0200
+++ b/targets/plc_debug.c	Wed Sep 02 13:38:47 2009 +0200
@@ -67,6 +67,8 @@
 
 extern int TryEnterDebugSection(void);
 extern void LeaveDebugSection(void);
+extern long AtomicCompareExchange(long*, long, long);
+extern void InitiateDebugTransfer(void);
 
 extern int __tick;
 void __publish_debug()
@@ -152,13 +154,15 @@
 
 void* IterDebugData(int* idx, const char **type_name)
 {
+	struct_plcvar* my_var;
+	USINT size;
     if(subscription_cursor < latest_subscription){
         char* old_cursor = buffer_cursor;
         *idx = *subscription_cursor;
-        struct_plcvar* my_var = &variable_table[*(subscription_cursor++)];
+        my_var = &variable_table[*(subscription_cursor++)];
         *type_name = __get_type_enum_name(my_var->type);
         /* get variable size*/
-        USINT size = __get_type_enum_size(my_var->type);
+        size = __get_type_enum_size(my_var->type);
         /* compute next cursor position*/
         buffer_cursor = buffer_cursor + size;
         if(old_cursor < debug_buffer + BUFFER_SIZE)