Datasheet
The C and C++ Libraries
4-52 Copyright © 1999-2001 ARM Limited. All rights reserved. ARM DUI 0067D
4.7.1 _sys_exit()
The library exit function. All exits from the library eventually call
_sys_exit()
.
Syntax
void _sys_exit(int return_code)
Implementation
This function must not return. You can intercept applicationexit at a higher level by
either:
• Implementing the C library function
exit()
as part of your application. You lose
atexit()
processing and library shutdown if you do this.
• Implementing the function
__rt_exit(int n)
as part of your application. You lose
library shutdown if you do this, but
atexit()
processing is still performed when
exit()
is called or
main()
returns.
Caution
This function is called if a stack overflow occurs. If you reimplement this function and
include a stack check as part of the code, the overflow causes an immediate return to
_sys_exit()
causing a worse stack overflow. It is not recommended that this function
performs stack checking.
Returns
The return code is advisory. An implementation might attempt to pass it to the execution
environment.
4.7.2 errno
The C library
errno
variable is defined in the implicit static data area of the library. This
area is identified by
__user_libspace()
. It occupies part of initial stack space used by
the functions that established the runtime stack. The definition of
errno
is:
(*(volatile int *) __rt_errno_addr())
You can define
__rt_errno_addr()
if you want to place
errno
at a user-defined location
instead of the default location identified by
__user_libspace()
.