ARM Technical Support Knowledge Articles

INDIRECTLY CALLED REENTRANT FUNCTIONS

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

I have problems passing lots of parameters to indirectly called functions. I tried to use the reentrant attribute but I could not make it work. Can you give me an example?

ANSWER

The example below shows the correct definition for reentrant functions that are called via function pointers. Both the function pointer and the function itself must contain the reentrant attribute. In addition, you must setup the reentrant stack pointer in the startup code (STARTUP.A51).

long* (*indirect_func) (long l, long* lp, int i) reentrant;

long* func (long l, long* lp, int i) reentrant {
  lp += i;              // just for demonstration
  *lp = l;
  return (lp);
}

long xdata larray[100];
long *lp;

void main (void)  {
  indirect_func = func;

  lp = indirect_func (500000L, larray, 5);
  while (1);
}

MORE INFORMATION

SEE ALSO

Article last edited on: 2005-07-18 18:38:21

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential