Benoit
Benoit

Reputation: 39064

Is there a way to use the same file for both a RTP and a kernel module in vxWorks?

We have a vxWorks application that we would like to deploy either as a kernel module, or as a Real-Time process.

Is there a way to do this from the same source file, or do we have to create one file for the kernel module and another for the RTP?

Upvotes: 0

Views: 1455

Answers (1)

Benoit
Benoit

Reputation: 39064

The easiest solution would be to have a single file that can be compiled either as a kernel module, or as a Real-Time Process. It probably should look something like this:


void MyModule_Init()
{
   // Initialize the module
   ...
}
...
#ifdef __RTP__
int main(...)
{
   // RTP Main just invokes the Module's initialization
   MyModule_Init();
}
#endif

The __RTP__ macro is defined if the build is for a RTP environment
The _WRS_KERNEL macro is defined if the build is for a kernel environment.

With those two macros, you can have code compiling for both environment.

Upvotes: 2

Related Questions