Multiple instances of same function at multiple locations in memory in C

Prawal Source

I want to have same set of instruction executing from different memory location. Using the attribute and linker file, I can specify the address/memory section where the function definition should be located:

void TaskFxn_0(UArg a0, UArg a1) __attribute__((section(".task_0")));

One brute force solution is to have multiple copies of the same function and put them in different memory location:

void TaskFxn_0(UArg a0, UArg a1)  __attribute__((section(".task_0")));
void TaskFxn_1(UArg a0, UArg a1)  __attribute__((section(".task_1")));
void TaskFxn_2(UArg a0, UArg a1)  __attribute__((section(".task_2")));
void TaskFxn_3(UArg a0, UArg a1)  __attribute__((section(".task_3")));
void TaskFxn_4(UArg a0, UArg a1)  __attribute__((section(".task_4")));
void TaskFxn_5(UArg a0, UArg a1)  __attribute__((section(".task_5")));

But in this case I need to have multiple copies of the same function definition and making change to one of them will require me change all of them making the code look ugly.

Is there a better way to do so?

cmultithreadingattributesfunction-pointersmemory-mapping

Answers

comments powered by Disqus