targets/Win32/plc_Win32_main.c
changeset 1475 de4ee16f7c6c
parent 1466 805826ba48c5
child 1573 6dbc61e3dd65
--- a/targets/Win32/plc_Win32_main.c	Sat Dec 06 19:31:51 2014 +0000
+++ b/targets/Win32/plc_Win32_main.c	Wed Oct 21 15:00:32 2015 +0100
@@ -76,8 +76,6 @@
     BOOL tmp;
     setlocale(LC_NUMERIC, "C");
 
-    InitializeCriticalSection(&Atomic64CS);
-
     debug_sem = CreateSemaphore(
                             NULL,           // default security attributes
                             1,  			// initial count
@@ -136,7 +134,7 @@
     }
     if( __init(argc,argv) == 0 )
     {
-        PLC_SetTimer(Ttick,Ttick);
+        PLC_SetTimer(common_ticktime__,common_ticktime__);
         PLC_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PlcLoop, NULL, 0, &thread_id);
     }
     else{
@@ -170,7 +168,6 @@
     CloseHandle(PLC_timer);
     WaitForSingleObject(PLC_thread, INFINITE);
     __cleanup();
-    DeleteCriticalSection(&Atomic64CS);
     CloseHandle(debug_wait_sem);
     CloseHandle(debug_sem);
     CloseHandle(python_wait_sem);
@@ -244,6 +241,14 @@
 	WaitForSingleObject(python_sem, INFINITE);
 }
 
+void InitRetain(void)
+{
+}
+
+void CleanupRetain(void)
+{
+}
+
 int CheckRetainBuffer(void)
 {
 	return 1;
@@ -271,3 +276,16 @@
 {
 }
 
+static void __attribute__((constructor))
+beremiz_dll_init(void)
+{
+    InitializeCriticalSection(&Atomic64CS);
+
+}
+
+static void __attribute__((destructor))
+beremiz_dll_destroy(void)
+{
+    DeleteCriticalSection(&Atomic64CS);
+}
+