
abs/labs
7-21
Run-Time-Support Functions
7.4 Description of Run-Time-Support Functions and Macros
This section describes the run-time-support functions and macros. A super-
scripted number is used in the following descriptions to show exponents. For
example, x
y
is the equivalent of x to the power y.
Abort
abort
Syntax
#include <stdlib.h>
void
abort
(void);
Defined in
exit.c in rts.src
Description
The abort function usually terminates a program with an error code. The
TMS320C2x/C2xx/C5x implementation of the abort function calls the exit
function with a value of 0, and is defined as follows:
void abort ()
{
exit(0);
}
This makes the abort function equivalent to the exit function.
Absolute Value
abs/labs
Syntax
#include <stdlib.h>
int
abs
(int j);
long int
labs
(long int k);
Defined in
abs.c in rts.src
Description
The C compiler supports two functions that return the absolute value of an
integer:
-
The abs function returns the absolute value of an integer j.
-
The labs function returns the absolute value of a long integer k.
Since int and long int are functionally equivalent types in TMS320C2x/C2xx/
C5x C, the abs and labs functions are also functionally equivalent. The abs and
labs functions are expanded inline unless the
−
x0 option is used. For more
information, see Section 2.6,
Using Inline Function Expansion
, on page 2-28.
Example
int x = −5;
int y = abs (x);
/* abs returns 5 */
Содержание TMS320C2x
Страница 8: ...viii...
Страница 69: ...2 47 C Compiler Description...
Страница 159: ...6 36...
Страница 226: ...8 6...
Страница 250: ...Index Index 14 Z z shell option 2 2 2 4 2 14 overriding with c option 4 5 overriding with n option 2 13...