Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortjung2012-11-10 19:19:08 +0000
committertjung2012-11-10 19:19:08 +0000
commitc5a68eb233a00cf9c3fd9c9664d23871bd93578a (patch)
tree4e97300139fbf878f2196585798928f8fd3d51b2 /runtime/org.eclipse.etrice.runtime.c/src/platforms
parent3328f159d86a59532f8d6a4aea0e88f6883d66b4 (diff)
downloadorg.eclipse.etrice-c5a68eb233a00cf9c3fd9c9664d23871bd93578a.tar.gz
org.eclipse.etrice-c5a68eb233a00cf9c3fd9c9664d23871bd93578a.tar.xz
org.eclipse.etrice-c5a68eb233a00cf9c3fd9c9664d23871bd93578a.zip
[runtime.c] Threading for MinGW added
Diffstat (limited to 'runtime/org.eclipse.etrice.runtime.c/src/platforms')
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h15
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c35
2 files changed, 50 insertions, 0 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h
index 6b45744d4..09fd1478c 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etDatatypes.h
@@ -19,7 +19,10 @@
*
* */
+#include <windows.h>
#include <stdio.h>
+#include <process.h>
+
/* unsigned integer datatypes */
typedef unsigned char uint8;
@@ -76,4 +79,16 @@ typedef FILE* etFileHandle;
typedef int8 etAddressId;
+/*
+ * typedefs for threading
+ */
+
+typedef CRITICAL_SECTION etMutex;
+typedef HANDLE etThread;
+typedef HANDLE etSema;
+
+typedef int32 etStacksize;
+typedef int32 etPriority;
+typedef charPtr etThreadname;
+
#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c
index 5a4115f8c..c79c2ac1a 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/generic/etPlatform.c
@@ -10,6 +10,7 @@
*
*******************************************************************************/
+#include <etDatatypes.h>
/* implemenatation for eTrice interfaces*/
@@ -24,3 +25,37 @@ void etUserExit(void){ }
/* platform specific functions */
+/******************thread********************/
+void etThread_construct(etThread* self, etThreadname name,void (*func)(void *),etStacksize stacksize, etPriority prio){
+ *self = (HANDLE)_beginthread( func, stacksize, NULL );
+ SetThreadPriority(*self,THREAD_PRIORITY_NORMAL);
+}
+
+void etThread_destruct(etThread* self){}
+
+/*****************mutex**********************/
+void etMutex_construct(etMutex* self){
+ InitializeCriticalSection( self );
+}
+void etMutex_destruct(etMutex* self){}
+void etMutex_enter(etMutex* self){
+ EnterCriticalSection( self );
+}
+void etMutex_leave(etMutex* self){
+ LeaveCriticalSection( self );
+}
+
+/********************semaphore****************/
+void etSema_contruct(etSema* self){
+ *self = CreateEvent( NULL, FALSE, FALSE, NULL );
+}
+void etSema_destruct(etSema* self){}
+
+void etSema_wakeup(etSema* self){
+ SetEvent(self);
+}
+
+void etSema_waitForWakeup(etSema* self){
+ WaitForSingleObject( self, INFINITE );
+}
+/*********************************************/

Back to the top