# HG changeset patch
# User edouard
# Date 1260190513 -3600
# Node ID a6a9b59636d81c4f018dc86787ae9109ffbc6e3d
# Parent  11638e373a6556a9ec6256dee5c705da0daed564
Propagated new runtime changes to win32 target

diff -r 11638e373a65 -r a6a9b59636d8 targets/Win32/plc_Win32_main.c
--- a/targets/Win32/plc_Win32_main.c	Mon Dec 07 10:08:12 2009 +0100
+++ b/targets/Win32/plc_Win32_main.c	Mon Dec 07 13:55:13 2009 +0100
@@ -147,7 +147,14 @@
 int TryEnterDebugSection(void)
 {
 	//printf("TryEnterDebugSection\n");
-	return WaitForSingleObject(debug_sem, 0) == WAIT_OBJECT_0;
+    if(WaitForSingleObject(debug_sem, 0) == WAIT_OBJECT_0){
+        /* Only enter if debug active */
+        if(__DEBUG){
+            return 1;
+        }
+    ReleaseSemaphore(debug_sem, 1, NULL);
+    return 0;
+    }
 }
 
 void LeaveDebugSection(void)
@@ -171,7 +178,6 @@
 
 /* from plc_debugger.c */
 int WaitDebugData(unsigned long *tick)
-unsigned long WaitDebugData()
 {
     *tick = __debug_tick;
     /* Wait signal from PLC thread */
@@ -188,11 +194,12 @@
     ReleaseSemaphore(debug_wait_sem, 1, NULL);
 }
 
-void suspendDebug()
-{
-	__DEBUG = 0;
+void suspendDebug(int disable)
+{
     /* Prevent PLC to enter debug code */
 	WaitForSingleObject(debug_sem, INFINITE);
+    /*__DEBUG is protected by this mutex */
+    __DEBUG = !disable;
 }
 
 void resumeDebug()