diff options
author | tjung | 2012-11-10 19:19:08 +0000 |
---|---|---|
committer | tjung | 2012-11-10 19:19:08 +0000 |
commit | c5a68eb233a00cf9c3fd9c9664d23871bd93578a (patch) | |
tree | 4e97300139fbf878f2196585798928f8fd3d51b2 | |
parent | 3328f159d86a59532f8d6a4aea0e88f6883d66b4 (diff) | |
download | org.eclipse.etrice-c5a68eb233a00cf9c3fd9c9664d23871bd93578a.tar.gz org.eclipse.etrice-c5a68eb233a00cf9c3fd9c9664d23871bd93578a.tar.xz org.eclipse.etrice-c5a68eb233a00cf9c3fd9c9664d23871bd93578a.zip |
[runtime.c] Threading for MinGW added
3 files changed, 72 insertions, 0 deletions
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h b/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h index 4ae1d6ea8..ad519ffa5 100644 --- a/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h +++ b/runtime/org.eclipse.etrice.runtime.c/src/common/platform/etPlatform.h @@ -13,11 +13,33 @@ #ifndef __ETPLATFORM_H__
#define __ETPLATFORM_H__
+#include "etDatatypes.h"
+
/*
* etPlatform.h defines a generic interface for platform specific implementations
*
* */
+/* platform specific functions */
+
+/******************thread********************/
+void etThread_construct(etThread* self, etThreadname name,void (*func)(void *),etStacksize stacksize, etPriority prio);
+void etThread_destruct(etThread* self);
+
+/*****************mutex**********************/
+void etMutex_construct(etMutex* self);
+void etMutex_destruct(etMutex* self);
+void etMutex_enter(etMutex* self);
+void etMutex_leave(etMutex* self);
+
+/********************semaphore****************/
+void etSema_contruct(etSema* self);
+void etSema_destruct(etSema* self);
+void etSema_wakeup(etSema* self);
+void etSema_waitForWakeup(etSema* self);
+
+/*********************************************/
+
/*
* Platform startup and shutdown -> generated code for SubSystemClass uses these interfaces
* */
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 );
+}
+/*********************************************/
|