ARM Technical Support Knowledge Articles

FUNCTION PROTOTYPES FOR REENTRANT FUNCTIONS

Applies to: C51 C Compiler

Answer


Information in this article applies to:


SYMPTOMS

Calls to a reentrant function will not pass parameters on the reentrant stack if the reentrant function is prototyped incorrectly.

CAUSE

Reentrant functions (functions declared with the reentrant keyword) receive parameters from the simulated stack. Functions that call reentrant functions must store arguments on the simulated stack prior to calling the function. To properly pass arguments, the C51 compiler must know whether or not a function is reentrant. Function prototypes for reentrant functions must include the reentrant keyword. For example:

void func (
  long a,
  long b,
  long c);

is a prototype for a function that returns nothing and that requires three arguments. This function (func) is not prototyped as a reentrant function. If the function is indeed reentrant, calls to func will fail to pass parameters on the reentrant stack and func will fail to perform as expected.

RESOLUTION

To correct this problem, be sure that prototypes for reentrant functions include the reentrant keyword. For example:

void func (
  long a,
  long b,
  long c) reentrant;

SEE ALSO

Article last edited on: 2004-06-29 14:14:47

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