Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rentz-Reichert2019-06-28 12:30:42 +0000
committerHenrik Rentz-Reichert2019-06-28 17:56:33 +0000
commita877df88488833e5f057ad56fafaef78171c0c5a (patch)
tree502cb2bc20057f29c3901887f5713f6d8d801893
parent934759368615c62e0133b4b7b214438567f53859 (diff)
downloadorg.eclipse.etrice-a877df88488833e5f057ad56fafaef78171c0c5a.tar.gz
org.eclipse.etrice-a877df88488833e5f057ad56fafaef78171c0c5a.tar.xz
org.eclipse.etrice-a877df88488833e5f057ad56fafaef78171c0c5a.zip
Bug 539945 - Provide C++ option for the C code generator
* runtime.c headers with extern "C" for C++ * generator with switch for C++ file extensions *.cpp/*.hpp * introduced explicit casts where C++ compiler requires them Change-Id: I0aba20a9fde24e1355427bc53b758cee223b9e60
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend6
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend56
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeGen.xtend12
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend2
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorOptions.java18
-rw-r--r--plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorOptionsHelper.java5
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorConfigTab.java42
-rw-r--r--plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorLaunchConfigurationDelegate.java15
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory.c1
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FixedSize.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FreeList.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/base/etQueue.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.h5
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etBufferSender.h11
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etConsoleLogger.h11
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.h5
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etLogger.h10
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/etStdDatatypes.h12
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/etStdMacros.h33
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.h11
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etLock.h11
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etMutex.h11
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etPlatformLifecycle.h3
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSema.h10
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSocket.h23
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTcpSockets.h11
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etThread.h10
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTime.h12
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTimer.h9
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h13
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h4
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h12
-rw-r--r--runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSocket.c6
46 files changed, 312 insertions, 137 deletions
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
index 347375f60..f199c8b25 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/ActorClassGen.xtend
@@ -153,7 +153,7 @@ class ActorClassGen extends GenericActorClassGenerator {
«IF hasVarData»
struct «ac.name» {
«IF hasConstData»
- const «ac.name»_const* const constData;
+ const «ac.name»_const* ET_CONST_MEMBER constData;
«ENDIF»
/* data send ports */
@@ -377,9 +377,9 @@ class ActorClassGen extends GenericActorClassGenerator {
ET_MSC_LOGGER_SYNC_ENTRY("«ac.name»", "_receiveMessage")
«IF !isEmptyStateGraph»
«IF handleEvents»
- «langExt.operationScope(ac.name, false)»receiveEvent(self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));
+ «langExt.operationScope(ac.name, false)»receiveEvent((«ac.name»*) self, (etPort*)ifitem, msg->evtID, (void*)(((char*)msg)+MEM_CEIL(sizeof(etMessage))));
«ELSE»
- «langExt.operationScope(ac.name, false)»receiveEventInternal(self);
+ «langExt.operationScope(ac.name, false)»receiveEventInternal((«ac.name»*) self);
«ENDIF»
«ENDIF»
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
index 79502585c..d36852cc5 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/CExtensions.xtend
@@ -37,15 +37,15 @@ import org.eclipse.etrice.core.room.ExternalType
import org.eclipse.etrice.core.room.Message
import org.eclipse.etrice.core.room.MessageData
import org.eclipse.etrice.core.room.PrimitiveType
+import org.eclipse.etrice.core.room.RefableType
import org.eclipse.etrice.core.room.RoomClass
import org.eclipse.etrice.core.room.RoomModel
+import org.eclipse.etrice.core.room.VarDecl
import org.eclipse.etrice.core.room.util.RoomHelpers
import org.eclipse.etrice.generator.c.Main
import org.eclipse.etrice.generator.c.setup.GeneratorOptionsHelper
import org.eclipse.etrice.generator.generic.ILanguageExtension
import org.eclipse.xtext.util.Pair
-import org.eclipse.etrice.core.room.VarDecl
-import org.eclipse.etrice.core.room.RefableType
@Singleton
class CExtensions implements ILanguageExtension {
@@ -96,42 +96,60 @@ class CExtensions implements ILanguageExtension {
/* TODO: move specific code elsewhere */
// used
def String getCHeaderFileName(RoomClass rc) {
- return rc.name+".h";
+ return rc.name+headerExtension;
}
// used
def String getCSourceFileName(RoomClass rc) {
- return rc.name+".c";
+ return rc.name + sourceExtension;
}
// used
def String getCUtilsFileName(RoomClass rc) {
- return rc.name+"_Utils.h";
+ return rc.name+"_Utils" + headerExtension;
}
def String getInstSourceFileName(RoomClass rc) {
- return rc.name+"_Inst.h";
+ return rc.name+"_Inst" + headerExtension;
}
def String getDispSourceFileName(RoomClass rc) {
- return rc.name+"_Disp.h";
+ return rc.name+"_Disp" + headerExtension;
}
// used
def String getCHeaderFileName(NodeRef nr, SubSystemInstance ssi) {
- return nr.name+"_"+ssi.name+".h";
+ return nr.name+"_"+ssi.name + headerExtension;
}
def String getCSourceFileName(NodeRef nr, SubSystemInstance ssi) {
- return nr.name+"_"+ssi.name+".c";
+ return nr.name+"_"+ssi.name + sourceExtension;
}
def String getInstSourceFileName(NodeRef nr, SubSystemInstance ssi) {
- return nr.name+"_"+ssi.name+"_Inst.h";
+ return nr.name+"_"+ssi.name+"_Inst" + headerExtension;
}
def String getDispSourceFileName(NodeRef nr, SubSystemInstance ssi) {
- return nr.name+"_"+ssi.name+"_Disp.h";
+ return nr.name+"_"+ssi.name+"_Disp" + headerExtension;
+ }
+
+ def String headerExtension() {
+ if (Main.settings.isCppFileExtensions) {
+ ".hpp";
+ }
+ else {
+ ".h";
+ }
+ }
+
+ def String sourceExtension() {
+ if (Main.settings.isCppFileExtensions) {
+ ".cpp";
+ }
+ else {
+ ".c";
+ }
}
def getIncludeGuardString(String filename){
@@ -161,6 +179,22 @@ class CExtensions implements ILanguageExtension {
'''
}
+ def generateCppExternCBegin() {
+ '''
+ #ifdef __cplusplus
+ extern „C“ {
+ #endif // __cplusplus
+ '''
+ }
+
+ def generateCppExternCEnd() {
+ '''
+ #ifdef __cplusplus
+ }
+ #endif // __cplusplus
+ '''
+ }
+
override boolean usesInheritance() {
return false
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeGen.xtend
index 185b0eb8a..7e7cf3e24 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeGen.xtend
@@ -380,7 +380,7 @@ class NodeGen {
/* forward declaration of variable actor structs */
«FOR ai : ssi.allContainedInstances»
- static «ai.actorClass.name» «ai.path.getPathName()»;
+ ET_FOWARD_DECLARATION_OF_INST_VAR «ai.actorClass.name» «ai.path.getPathName()»;
«ENDFOR»
/* forward declaration of variable port structs */
@@ -390,7 +390,7 @@ class NodeGen {
«ELSE»
«FOR pi:ai.orderedIfItemInstances»
«IF pi.portClassAttributesSize > 0»
- static «pi.protocol.getPortClassName(pi.conjugated)»_var «pi.path.pathName»_var«IF pi.replicated»[«pi.peers.size»]«ENDIF»={
+ ET_FOWARD_DECLARATION_OF_INST_VAR «pi.protocol.getPortClassName(pi.conjugated)»_var «pi.path.pathName»_var«IF pi.replicated»[«pi.peers.size»]«ENDIF»={
«FOR Integer i:1.. if(pi.peers.size==0)1 else pi.peers.size SEPARATOR ', '»
«attrInitGenAddon.generateAttributeInit(pi, pi.interfaceItem.portClass.attributes)»
«ENDFOR»};
@@ -467,7 +467,7 @@ class NodeGen {
«genPeerPortArrays(root, ai)»
«ENDIF»
«IF haveReplSubItems»
- static const etReplSubPort «replSubPortsArray»[«offset»] = {
+ ET_INITIALIZATION_OF_INST_VAR const etReplSubPort «replSubPortsArray»[«offset»] = {
/* Replicated Sub Ports: {varData, msgService, peerAddress, localId, index} */
«FOR pi : replEventItems.filter(e|!e.peers.empty) SEPARATOR ","»
«genReplSubPortInitializers(root, ai, pi)»
@@ -475,7 +475,7 @@ class NodeGen {
};
«ENDIF»
«IF haveConstData»
- static «const» «ai.actorClass.name»_const «instName»_const = {
+ ET_INITIALIZATION_OF_INST_VAR «const» «ai.actorClass.name»_const «instName»_const = {
«IF Main::settings.generateMSCInstrumentation»
«sep»"«ai.path»"
@@ -507,7 +507,7 @@ class NodeGen {
«ENDFOR»
};
«ENDIF»
- static «ai.actorClass.name» «instName» = {
+ ET_INITIALIZATION_OF_INST_VAR «ai.actorClass.name» «instName» = {
«IF haveConstData»
&«instName»_const,
@@ -682,7 +682,7 @@ class NodeGen {
static void MsgDispatcher_«thread.name»_poll(void){
ET_MSC_LOGGER_SYNC_ENTRY("MsgDispatcher_«thread.name»", "execute")
«FOR ai : executedInstances»
- «ai.actorClass.name»_execute((void*)&«ai.path.pathName»);
+ «ai.actorClass.name»_execute((«ai.actorClass.name»*)&«ai.path.pathName»);
«ENDFOR»
ET_MSC_LOGGER_SYNC_EXIT
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend
index 18e90df79..da14d915f 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/NodeRunnerGen.xtend
@@ -43,7 +43,7 @@ class NodeRunnerGen {
if (ssi!==null) {
val clsname = nr.name+"_"+ssi.name
val path = ssi.subSystemClass.getPath
- val file = clsname + "_Runner.c"
+ val file = clsname + "_Runner" + sourceExtension
fileIO.generateFile("generating Node runner file", path + file, root.generateSourceFile(ssi, first))
first = false
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
index 901ccf7cc..6af88d94e 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/gen/StateMachineGen.xtend
@@ -76,7 +76,7 @@ class StateMachineGen extends GenericStateMachineGenerator {
'''
«IF Main::settings.generateMSCInstrumentation»
/* state names */
- static char* stateStrings[] = {"<no state>","<top>",«FOR state : states SEPARATOR ","»"«state.genStatePathName»"
+ static const char* stateStrings[] = {"<no state>","<top>",«FOR state : states SEPARATOR ","»"«state.genStatePathName»"
«ENDFOR»};
«ENDIF»
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorOptions.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorOptions.java
index 14f436d44..d33a3f414 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorOptions.java
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorOptions.java
@@ -15,8 +15,26 @@
package org.eclipse.etrice.generator.c.setup;
+import java.util.List;
+
import org.eclipse.etrice.generator.base.AbstractGeneratorOptions;
+import org.eclipse.etrice.generator.base.args.BooleanOption;
+import org.eclipse.etrice.generator.base.args.Option;
public class GeneratorOptions extends AbstractGeneratorOptions {
+
+ public static final BooleanOption CPP_FILE_EXTENSIONS = new BooleanOption(
+ GROUP_ETRICE,
+ "cppfileextensions",
+ "cppFileExtensions",
+ "if specified the file extensions for C source and header files will be *.cpp and *.hpp resp.'",
+ false);
+
+ @Override
+ public void configure(List<Option<?>> options) {
+ super.configure(options);
+
+ options.add(CPP_FILE_EXTENSIONS);
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorOptionsHelper.java b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorOptionsHelper.java
index 36c5d9029..df00a4e24 100644
--- a/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorOptionsHelper.java
+++ b/plugins/org.eclipse.etrice.generator.c/src/org/eclipse/etrice/generator/c/setup/GeneratorOptionsHelper.java
@@ -16,7 +16,12 @@
package org.eclipse.etrice.generator.c.setup;
import org.eclipse.etrice.generator.base.AbstractGeneratorOptionsHelper;
+import org.eclipse.etrice.generator.base.args.Arguments;
public class GeneratorOptionsHelper extends AbstractGeneratorOptionsHelper {
+
+ public boolean isCppFileExtensions(Arguments args) {
+ return args.get(GeneratorOptions.CPP_FILE_EXTENSIONS);
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorConfigTab.java b/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorConfigTab.java
index 097aab067..d5dbefd72 100644
--- a/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorConfigTab.java
+++ b/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorConfigTab.java
@@ -14,14 +14,56 @@
package org.eclipse.etrice.generator.launch.c;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.etrice.generator.launch.GeneratorConfigTab;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
/**
* @author Henrik Rentz-Reichert
*
*/
public class CGeneratorConfigTab extends GeneratorConfigTab {
+
+ public static final String GEN_CPP_FILE_EXTENSIONS = "cppFileExtensions";
+
+ private Button generateCppFileExtensions;
+ @Override
+ protected void addFurtherControls(Composite mainComposite) {
+ super.addFurtherControls(mainComposite);
+
+
+ createSeparator(mainComposite, 2);
+
+ generateCppFileExtensions = createCheckButton(mainComposite, "generate with C++ file extensions");
+ generateCppFileExtensions.setToolTipText("this options generates C source and header files with *.cpp and *.hpp extensions");
+ generateCppFileExtensions.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1));
+ generateCppFileExtensions.addSelectionListener(new UpdateConfig());
+ }
+
+ @Override
+ public void initializeFrom(ILaunchConfiguration configuration) {
+ super.initializeFrom(configuration);
+
+ try {
+ generateCppFileExtensions.setSelection(configuration.getAttribute(GEN_CPP_FILE_EXTENSIONS, false));
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ super.performApply(configuration);
+
+ configuration.setAttribute(GEN_CPP_FILE_EXTENSIONS, generateCppFileExtensions.getSelection());
+ }
+
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName()
*/
diff --git a/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorLaunchConfigurationDelegate.java b/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorLaunchConfigurationDelegate.java
index d096cf8aa..f192937e8 100644
--- a/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.etrice.generator.launch.c/src/org/eclipse/etrice/generator/launch/c/CGeneratorLaunchConfigurationDelegate.java
@@ -14,8 +14,12 @@
package org.eclipse.etrice.generator.launch.c;
-import org.eclipse.etrice.generator.c.Main;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.etrice.generator.base.io.ILineOutput;
+import org.eclipse.etrice.generator.c.Main;
+import org.eclipse.etrice.generator.c.setup.GeneratorOptions;
import org.eclipse.etrice.generator.launch.GeneratorLaunchConfigurationDelegate;
/**
@@ -32,6 +36,15 @@ public class CGeneratorLaunchConfigurationDelegate extends GeneratorLaunchConfig
Main.setOutput(out);
Main.run(args);
}
+
+ @Override
+ protected void addArguments(ILaunchConfiguration configuration, IProject project, StringBuffer argString) throws CoreException {
+ super.addArguments(configuration, project, argString);
+
+ if (configuration.getAttribute(CGeneratorConfigTab.GEN_CPP_FILE_EXTENSIONS, false)) {
+ argString.append(" -"+GeneratorOptions.CPP_FILE_EXTENSIONS.getName());
+ }
+ }
/* (non-Javadoc)
* @see org.eclipse.etrice.generator.launch.GeneratorLaunchConfigurationDelegate#getConsoleName()
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory.c b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory.c
index f0bba33c4..92dd54062 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory.c
@@ -14,6 +14,7 @@
#include "base/etMemory.h"
#include "debugging/etMSCLogger.h"
+#include "runtime/etRuntime.h"
#define DO_LOCK \
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory.h b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory.h
index 42b365204..28b36cc9f 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory.h
@@ -18,6 +18,8 @@
#include "etDatatypes.h"
#include "osal/etLock.h"
+ET_EXTERN_C_BEGIN
+
/**
* this macro computes the memory aligned value for a given size. It uses the ALIGNMENT
* defined in etDatatypes.h
@@ -104,4 +106,6 @@ void etMemory_setUserLock(etMemory* mem, etLock* lock);
*/
void etMemory_destroy(etMemory* mem);
+ET_EXTERN_C_END
+
#endif /* _ETMEMORY_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FixedSize.h b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FixedSize.h
index 6dcf77d04..1adabe504 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FixedSize.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FixedSize.h
@@ -26,6 +26,8 @@
#include "base/etMemory.h"
#include "base/etQueue.h"
+ET_EXTERN_C_BEGIN
+
/**
* initializes the heap with a simple block management
*
@@ -46,4 +48,6 @@ etMemory* etMemory_FixedSize_init(void* heap, etUInt32 size, etUInt16 blockSize)
*/
etUInt32 etMemory_FixedSize_getFreeHeapMem(etMemory* mem);
+ET_EXTERN_C_END
+
#endif /* _ETMEMORY_FIXED_SIZE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FreeList.h b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FreeList.h
index 812e78af2..68fd21c2b 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FreeList.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_FreeList.h
@@ -25,6 +25,8 @@
#include "base/etMemory.h"
#include "osal/etLock.h"
+ET_EXTERN_C_BEGIN
+
typedef etUInt16 roundUpSize(etUInt16 size);
/**
@@ -96,4 +98,6 @@ etUInt16 etMemory_FreeList_freeSlots(etMemory* mem);
*/
etUInt16 etMemory_FreeList_MgmtDataPerObject();
+ET_EXTERN_C_END
+
#endif /* _ETMEMORY_FREE_LIST_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.h b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.h
index cc9f85ead..fe811bc6d 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etMemory_VariableSize.h
@@ -27,6 +27,8 @@
#include "base/etQueue.h"
#include "osal/etLock.h"
+ET_EXTERN_C_BEGIN
+
/**
* initializes the heap with a simple block management
*
@@ -44,5 +46,6 @@ etMemory* etMemory_VariableSize_init(void* heap, etUInt32 size);
*/
etUInt8 etMemory_VariableSize_freeHeapMem(etMemory* mem);
+ET_EXTERN_C_END
#endif /* _ETMEMORY_VARIABLE_SIZE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etQueue.h b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etQueue.h
index 3b8873783..89109c64a 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/base/etQueue.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/base/etQueue.h
@@ -18,6 +18,8 @@
#include <stddef.h>
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
+
typedef struct etQueueObj {
struct etQueueObj* next;
} etQueueObj;
@@ -46,6 +48,6 @@ etInt16 etQueue_getHighWaterMark(etQueue* self);
etInt16 etQueue_getSize(etQueue* self);
-
+ET_EXTERN_C_END
#endif /* _ETQUEUE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.h b/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.h
index 4f45581ca..04edffe12 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/container/etStaticDeque.h
@@ -16,6 +16,9 @@
#define SRC_COMMON_CONTAINERS_ETSTATICDEQUE_H_
#include <stdint.h>
+#include "etDatatypes.h"
+
+ET_EXTERN_C_BEGIN
/**
* etStaticDeque (static double ended queue) is a data structure for storing objects of equal size in order.
@@ -103,4 +106,6 @@ void* etStaticDeque_front(const etStaticDeque* self);
*/
void* etStaticDeque_back(const etStaticDeque* self);
+ET_EXTERN_C_END
+
#endif /* SRC_COMMON_CONTAINERS_ETSTATICDEQUE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etBufferSender.h b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etBufferSender.h
index 92c17c8ee..d1cea4396 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etBufferSender.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etBufferSender.h
@@ -19,9 +19,6 @@
*
* \author: hrentzreichert
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETBUFFERSENDER_H_
#define _ETBUFFERSENDER_H_
@@ -29,6 +26,8 @@ extern "C" {
#include <stddef.h>
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
+
struct etBufferSender;
typedef void* etBufferSender_getBuffer(struct etBufferSender* self, size_t size);
@@ -40,8 +39,6 @@ typedef struct etBufferSender {
}
etBufferSender;
-#endif /* _ETBUFFERSENDER_H_ */
+ET_EXTERN_C_END
-#ifdef __cplusplus
-}
-#endif
+#endif /* _ETBUFFERSENDER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etConsoleLogger.h b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etConsoleLogger.h
index 1875e5f87..fc286ffc8 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etConsoleLogger.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etConsoleLogger.h
@@ -19,9 +19,6 @@
*
* \author: hrentzreichert
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETCONSOLELOGGER_H_
#define _ETCONSOLELOGGER_H_
@@ -29,6 +26,8 @@ extern "C" {
#include <debugging/etBufferSender.h>
#include "etLogger.h"
+ET_EXTERN_C_BEGIN
+
extern etLogger theConsoleLogger;
/**
@@ -37,8 +36,6 @@ extern etLogger theConsoleLogger;
*/
void etConsoleLogger_init();
-#endif /* _ETCONSOLELOGGER_H_ */
+ET_EXTERN_C_END
-#ifdef __cplusplus
-}
-#endif
+#endif /* _ETCONSOLELOGGER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.h b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.h
index fc56abc07..2e0577f4f 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etDataLogger.h
@@ -26,6 +26,9 @@
#define ETDATALOGGER_H_
#include "etRuntimeConfig.h"
+#include "etDatatypes.h"
+
+ET_EXTERN_C_BEGIN
/**
* opens a file for data logging
@@ -127,4 +130,6 @@ void etDataLogger_newRow();
#define ET_DATA_LOGGER_NEW_ROW
#endif
+ET_EXTERN_C_END
+
#endif /* ETDATALOGGER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etLogger.h b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etLogger.h
index 2967bbda9..95b60b631 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etLogger.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etLogger.h
@@ -19,9 +19,6 @@
*
* \author: tschuetz
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETLOGGER_H_
#define _ETLOGGER_H_
@@ -29,6 +26,8 @@ extern "C" {
#include <stdio.h>
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
+
/**
* open a log file
*
@@ -183,9 +182,6 @@ void etLogger_log(etLogger* self, LogSeverity severity, const char* msg);
*/
void etLogger_logF(etLogger* self, LogSeverity severity, const char* format, ... );
+ET_EXTERN_C_END
#endif /* _ETLOGGER_H_ */
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.h b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.h
index 1753b61c0..b4b98913c 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/debugging/etMSCLogger.h
@@ -25,6 +25,9 @@
#define _ETMSCLOGGER_H_
#include "etRuntimeConfig.h"
+#include "etDatatypes.h"
+
+ET_EXTERN_C_BEGIN
/**
* opens a log file for the MSC. Only one at a time can be open.
@@ -191,5 +194,6 @@ void etMSCLogger_setState(const char* objectName, const char* stateName);
#define ET_MSC_LOGGER_CHANGE_STATE(objectName, stateName)
#endif
+ET_EXTERN_C_END
#endif /* _ETMSCLOGGER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/etStdDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/common/etStdDatatypes.h
index 57384965e..6f5c9e63c 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/etStdDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/etStdDatatypes.h
@@ -15,9 +15,6 @@
/*
* Generic version for most platforms based on std.
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETSTDDATATYPES_H_
#define _ETSTDDATATYPES_H_
@@ -26,6 +23,8 @@ extern "C" {
#error etStdDatatypes must not be included before etDatatypes (include etDatatypes instead).
#endif
+#include "etStdMacros.h"
+
/*
Define switches for additional data types:
#define ET_INT64
@@ -38,6 +37,8 @@ extern "C" {
#include <inttypes.h>
#include <stdbool.h>
+ET_EXTERN_C_BEGIN
+
/* --- Data types for room.basic.types */
/* bool already defined */
@@ -123,9 +124,6 @@ typedef etInt16 etAddressId;
*/
/*-----------------------------------------------------------*/
+ET_EXTERN_C_END
#endif /* _ETSTDDATATYPES_H_ */
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/etStdMacros.h b/runtime/org.eclipse.etrice.runtime.c/src/common/etStdMacros.h
new file mode 100644
index 000000000..e4de4be6b
--- /dev/null
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/etStdMacros.h
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2019 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * CONTRIBUTORS:
+ * Henrik Rentz-Reichert (initial contribution)
+ *
+ *******************************************************************************/
+
+
+#ifndef _ETSTDMACROS_H_
+#define _ETSTDMACROS_H_
+
+#ifdef __cplusplus
+#define ET_EXTERN_C_BEGIN extern "C" {
+#define ET_EXTERN_C_END }
+#define ET_CONST_MEMBER
+#define ET_INITIALIZATION_OF_INST_VAR
+#define ET_FOWARD_DECLARATION_OF_INST_VAR extern
+#else
+#define ET_EXTERN_C_BEGIN
+#define ET_EXTERN_C_END
+#define ET_CONST_MEMBER const
+#define ET_INITIALIZATION_OF_INST_VAR static
+#define ET_FOWARD_DECLARATION_OF_INST_VAR static
+#endif
+
+#endif /* _ETSTDMACROS_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.h b/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.h
index de5b812e0..e666b00b0 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/etUnit/etUnit.h
@@ -21,9 +21,6 @@
*
* \author Thomas Schuetz
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETUNIT_H_
#define _ETUNIT_H_
@@ -31,6 +28,8 @@ extern "C" {
#include "etDatatypes.h"
#include <string.h>
+ET_EXTERN_C_BEGIN
+
// compile time evaluated
#define ETUNIT_FILENAME (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__))
@@ -422,9 +421,7 @@ void expectOrder(etInt16 id, const char* msg, etInt16 identifier, const char* fi
*/
void expectOrderEnd(etInt16 id, const char* msg, etInt16 identifier, const char* file, int line);
-#endif /* _ETUNIT_H_ */
+ET_EXTERN_C_END
-#ifdef __cplusplus
-}
-#endif
+#endif /* _ETUNIT_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h b/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h
index db8d0e7e0..115d65355 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/helpers/etTimeHelpers.h
@@ -25,6 +25,8 @@
#include "osal/etTime.h"
+ET_EXTERN_C_BEGIN
+
/**
* normalizes the time value to ensure that part is always 0 <= nSec < 1E9
*
@@ -96,4 +98,6 @@ etBool etTimeHelpers_isGreater(etTime* t1, etTime* t2);
*/
etBool etTimeHelpers_isGreaterOrEqual(etTime* t1, etTime* t2);
+ET_EXTERN_C_END
+
#endif /* _ETTIMEHELPERS_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h
index be3978ea3..cc3bbdb9a 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessage.h
@@ -25,6 +25,8 @@
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
+
/**
* the message structure
*/
@@ -41,4 +43,6 @@ typedef struct etMessage {
*/
void etMessage_init(etMessage* self);
+ET_EXTERN_C_END
+
#endif /* _ETMESSAGE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
index b320cca59..eb3727034 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageQueue.h
@@ -26,6 +26,8 @@
#include "messaging/etMessage.h"
#include <stddef.h>
+ET_EXTERN_C_BEGIN
+
/**
* a data structure for the queue statistics
*/
@@ -131,5 +133,6 @@ etInt16 etMessageQueue_getLowWaterMark(etMessageQueue* self);
*/
void etMessageQueue_resetLowWaterMark(etMessageQueue* self);
+ET_EXTERN_C_END
#endif /* _RMESSAGEQUEUE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h
index 9f80de5f9..631f57663 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageReceiver.h
@@ -25,6 +25,8 @@
#include "messaging/etMessage.h"
+ET_EXTERN_C_BEGIN
+
/**
* method prototype that receives a message
*
@@ -48,4 +50,6 @@ typedef etBool (*etDispatcherReceiveMessage)(const etMessage* msg);
*/
typedef void (*etDispatcherExecute)(void);
+ET_EXTERN_C_END
+
#endif /* _ETMESSAGERECEIVER_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
index 653eaf53e..1d52a5f3c 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etMessageService.h
@@ -33,6 +33,8 @@
#include "osal/etSema.h"
#include "osal/etTimer.h"
+ET_EXTERN_C_BEGIN
+
/** the address of the message service */
#define MESSAGESERVICE_ADDRESS 1
/** the base address for other receivers */
@@ -221,4 +223,6 @@ etInt16 etMessageService_getMessagePoolLowWaterMark(etMessageService* self);
void etMessageService_registerHighPrioFunc(etMessageService* self, etHighPrioFunc* func);
void etMessageService_unregisterHighPrioFunc(etMessageService* self, etHighPrioFunc* func);
+ET_EXTERN_C_END
+
#endif /* RMESSAGESERVICE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h
index 260e15608..398079be9 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/messaging/etSystemProtocol.h
@@ -11,6 +11,8 @@
#include "etDatatypes.h"
#include "modelbase/etPort.h"
+ET_EXTERN_C_BEGIN
+
/* message IDs */
enum etSystemProtocol_msg_ids {
etSystemProtocol_MSG_MIN = 0,
@@ -46,6 +48,7 @@ etInt32 etSystemProtocolConjReplPort_getReplication(const etSystemProtocolConjRe
/* get message string for message id */
const char* etSystemProtocol_getMessageString(int msg_id);
+ET_EXTERN_C_END
#endif /* _ETSYSTEMPROTOCOL_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h
index da5de60bb..ed9bc7e38 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etActor.h
@@ -24,6 +24,8 @@
#include "etDatatypes.h"
#include "modelbase/etPort.h"
+ET_EXTERN_C_BEGIN
+
/** transition chain ID indicating that no chain fired */
#define NOT_CAUGHT 0
@@ -45,4 +47,6 @@
*/
etBool handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data);
+ET_EXTERN_C_END
+
#endif /* _ETACTOR_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h
index 58a2e81c0..6c4846677 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/modelbase/etPort.h
@@ -28,6 +28,8 @@
#include "messaging/etMessageService.h"
#include "etRuntimeConfig.h"
+ET_EXTERN_C_BEGIN
+
/**
* the data structure of a port that holds the constant data
*/
@@ -77,6 +79,6 @@ typedef etPort InterfaceItemBase;
*/
void etPort_sendMessage(const etPort* self, etInt16 evtId, int size, void* data);
-
+ET_EXTERN_C_END
#endif /* _ETPORT_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etLock.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etLock.h
index 8e018131a..7c01bc555 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etLock.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etLock.h
@@ -20,13 +20,12 @@
*
* \author Henrik Rentz-Reichert
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETLOCK_H_
#define _ETLOCK_H_
+ET_EXTERN_C_BEGIN
+
typedef void etLock_lock(void* lockData);
typedef void etLock_unlock(void* lockData);
@@ -37,8 +36,6 @@ typedef struct etLock {
}
etLock;
-#endif /* _ETLOCK_H_ */
+ET_EXTERN_C_END
-#ifdef __cplusplus
-}
-#endif
+#endif /* _ETLOCK_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etMutex.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etMutex.h
index 4768cf8e6..9c3583280 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etMutex.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etMutex.h
@@ -20,15 +20,14 @@
*
* \author Thomas Schuetz, Thomas Jung
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETMUTEX_H_
#define _ETMUTEX_H_
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
+
/**
* etMutex holds the object data for a mutex (for self pointer)
*/
@@ -60,8 +59,6 @@ void etMutex_enter(etMutex* self);
*/
void etMutex_leave(etMutex* self);
-#endif /* _ETMUTEX_H_ */
+ET_EXTERN_C_END
-#ifdef __cplusplus
-}
-#endif
+#endif /* _ETMUTEX_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etPlatformLifecycle.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etPlatformLifecycle.h
index 298b05c0b..3897b0316 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etPlatformLifecycle.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etPlatformLifecycle.h
@@ -27,6 +27,7 @@
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
/**
* Platform specific code, called at the start of the system startup of the main function
@@ -48,4 +49,6 @@ void etUserPostRun(void);
*/
void etUserExit(void);
+ET_EXTERN_C_END
+
#endif /* _ETPLATFORMLIFECYCLE_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSema.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSema.h
index 6819e5d2b..1794a9737 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSema.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSema.h
@@ -11,9 +11,6 @@
* Thomas Schuetz (initial contribution)
*
*******************************************************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETSEMA_H_
#define _ETSEMA_H_
@@ -28,6 +25,8 @@ extern "C" {
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
+
/**
* etSema holds the object data for a semaphore (for self pointer)
*/
@@ -60,9 +59,6 @@ void etSema_wakeupFromISR(etSema* self);
*/
void etSema_waitForWakeup(etSema* self);
+ET_EXTERN_C_END
#endif /* _ETSEMA_H_ */
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSocket.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSocket.h
index de729de9a..3252912f4 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSocket.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etSocket.h
@@ -1,12 +1,24 @@
-#ifdef __cplusplus
-extern "C" {
-#endif
+/*******************************************************************************
+ * Copyright (c) 2017 protos software gmbh (http://www.protos.de).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
+ * https://www.eclipse.org/legal/epl-2.0/
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * CONTRIBUTORS:
+ * Jan Belle (initial contribution)
+ *
+ *******************************************************************************/
#ifndef _ETSOCKET_H_
#define _ETSOCKET_H_
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
+
/*
* Data structure representing an etSocket
* etSocket is used to establish a tcp connection
@@ -91,9 +103,6 @@ int etServerSocket_destruct(etServerSocket* self);
*/
int etServerSocket_accept(etServerSocket* self, etSocket* socket);
+ET_EXTERN_C_END
#endif /* _ETSOCKET_H_ */
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTcpSockets.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTcpSockets.h
index 02458a406..3bd72dede 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTcpSockets.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTcpSockets.h
@@ -19,15 +19,14 @@
*
* \author Henrik Rentz-Reichert
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETTCPSOCKETS_H_
#define _ETTCPSOCKETS_H_
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
+
/** the maximum number of connections per server */
#define MAX_CONNECTIONS 32
@@ -177,8 +176,6 @@ etSocketError etWriteSocket(etSocketConnectionData* self, int size, const int8*
*/
etSocketError etCloseSocket(etSocketConnectionData* self);
-#endif /* _ETTCPSOCKETS_H_ */
+ET_EXTERN_C_END
-#ifdef __cplusplus
-}
-#endif
+#endif /* _ETTCPSOCKETS_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etThread.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etThread.h
index 94cede364..d164c0127 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etThread.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etThread.h
@@ -20,15 +20,14 @@
* \author Thomas Schuetz, Thomas Jung
*
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETTHREAD_H_
#define _ETTHREAD_H_
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
+
/*
* typedefs for etThread
*/
@@ -101,9 +100,6 @@ etOSThreadData etThread_self(void);
*/
etOSThreadId etThread_self_id(void);
+ET_EXTERN_C_END
#endif /* _ETTHREAD_H_ */
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTime.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTime.h
index 677c4df65..cc3785952 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTime.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTime.h
@@ -20,15 +20,13 @@
* \author Thomas Schuetz
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#ifndef _ETTIME_H_
#define _ETTIME_H_
#include "etDatatypes.h"
+ET_EXTERN_C_BEGIN
+
/**
* time definition composed by the number of seconds and the number of nano seconds
* negative values have only negative sec, nSec is always positive
@@ -54,8 +52,6 @@ typedef etInt32 etTimeDiff;
*/
void getTimeFromTarget(etTime *t);
-#endif /* _ETTIME_H_ */
+ET_EXTERN_C_END
-#ifdef __cplusplus
-}
-#endif
+#endif /* _ETTIME_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTimer.h b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTimer.h
index 3d38f76c0..253b40bb8 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTimer.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/osal/etTimer.h
@@ -19,9 +19,6 @@
*
* \author Thomas Jung
*/
-#ifdef __cplusplus
-extern "C" {
-#endif
#ifndef _ETTIMER_H_
#define _ETTIMER_H_
@@ -29,6 +26,7 @@ extern "C" {
#include "etDatatypes.h"
#include "etTime.h"
+ET_EXTERN_C_BEGIN
/**
* the prototype for the time callback function
@@ -74,9 +72,6 @@ void etTimer_stop(etTimer* self);
*/
void etTimer_destruct(etTimer* self);
+ET_EXTERN_C_END
#endif /* __ETTIMER_H__ */
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h
index 90533e78b..f7706c020 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etRuntime.h
@@ -12,15 +12,12 @@
*
*******************************************************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#ifndef _ETRUNTIME_H_
#define _ETRUNTIME_H_
#include "messaging/etMessageService.h"
#include "base/etMemory.h"
+#include "osal/etSema.h"
/**
* \file etRuntime.h
@@ -30,7 +27,7 @@ extern "C" {
* \author Thomas Schuetz
*/
-#include "osal/etSema.h"
+ET_EXTERN_C_BEGIN
/**
* returns the number of message services in this process
@@ -135,8 +132,6 @@ void etRuntime_resetAllMemoryManagementStatistics();
*/
etSema* etRuntime_getTerminateSemaphore();
-#endif /* _ETRUNTIME_H_ */
+ET_EXTERN_C_END
-#ifdef __cplusplus
-}
-#endif
+#endif /* _ETRUNTIME_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.h b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.h
index e80edc41c..144d00ee7 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/common/runtime/etThreadList.h
@@ -26,6 +26,8 @@
#include "osal/etThread.h"
+ET_EXTERN_C_BEGIN
+
typedef struct etThreadController{
etThread* threadList; /**< list of all thread data (as array) **/
int32 size; /**< size of the list **/
@@ -36,4 +38,6 @@ void etThreadController_startAll(etThreadController* self);
void etThreadController_stopAll(etThreadController* self);
void etThreadController_getCurrentThreadId(void);
+ET_EXTERN_C_END
+
#endif /* _etThreadController_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
index aefbb96b0..c35952a98 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_POSIX_GENERIC_GCC/etDatatypes.h
@@ -36,6 +36,8 @@
#include <pthread.h>
#include <semaphore.h>
+ET_EXTERN_C_BEGIN
+
/*--- Data types for room.basic.types */
/*-----------------------------------------------------------*/
@@ -61,4 +63,6 @@ typedef timer_t etOSTimerId;
/*-----------------------------------------------------------*/
+ET_EXTERN_C_END
+
#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h
index b969c8f4b..6a3a63bdd 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etDatatypes.h
@@ -12,10 +12,6 @@
*
*******************************************************************************/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
#ifndef _ETDATATYPES_H_
#define _ETDATATYPES_H_
@@ -36,6 +32,8 @@ extern "C" {
#define WINVER 0x0500
#include <windows.h>
+ET_EXTERN_C_BEGIN
+
/*--- Data types for room.basic.types */
/*-----------------------------------------------------------*/
@@ -57,8 +55,6 @@ typedef SOCKET etOSSocketData;
/*-----------------------------------------------------------*/
-#endif /* _DATATYPES_H_ */
+ET_EXTERN_C_END
-#ifdef __cplusplus
-}
-#endif
+#endif /* _DATATYPES_H_ */
diff --git a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSocket.c b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSocket.c
index b6492af2f..f3118a5ad 100644
--- a/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSocket.c
+++ b/runtime/org.eclipse.etrice.runtime.c/src/platforms/MT_WIN_MinGW/etSocket.c
@@ -49,7 +49,7 @@ int etSocket_destruct(etSocket* self) {
}
int etSocket_recv(etSocket* self, uint8* buffer, size_t length) {
- int result = recv(self->socket, buffer, length, 0);
+ int result = recv(self->socket, (char*) buffer, length, 0);
if(result < 0) {
printf("Error: socket could not receive data\n");
printLastError();
@@ -58,7 +58,7 @@ int etSocket_recv(etSocket* self, uint8* buffer, size_t length) {
}
int etSocket_send(etSocket* self, uint8* buffer, size_t length) {
- int result = send(self->socket, buffer, length, 0);
+ int result = send(self->socket, (const char*) buffer, length, 0);
if(result < 0) {
printf("Error: socket could not send data\n");
printLastError();
@@ -162,6 +162,6 @@ void printLastError() {
NULL, WSAGetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPWSTR)&s, 0, NULL);
- printf("%S\n", s);
+ wprintf(L"%S\n", s);
LocalFree(s);
}

Back to the top