Technical Details
Floating point support
Many of the functions are provided in two variants, distinguished by a 'f' (or
no) or 'd' suffix. These indicate the routine is expected to provide a float
(32bit FP) or double (64bit FP) argument. Except where mentioned, floating
point arguments are passed in ARM registers.
'long long' support
A number of 'long long' support functions are also provided. These provide
additional support to that provided by the C99Low library explicitly for
C99-specification support.
A 'long long' is a 64bit value which can be signed or unsigned. It is
represented by two 32bit little-endian words, with the low word stored first.
When passed to functions, a 'long long' can be effectively represented as a
structure thus:
typedef __value_in_regs struct longlong_s {long lo;
unsigned long hi;
} longlong_t;
In this form, values are passed to functions as if there were two registers
containing the lo and hi values.
'intmax_t' support
The 'intmax_t' type is provided in an identical manner to that of the 'long
long' support. Parameters passed to functions and returned by this type are
passed in two registers containing the low and high values.
Calling conventions
All functions within the library use APCS-R or APCS-32 (dependent on linkage)
calling conventions.
Functions
The entry numbers are those of the entries within the C99 library chunk.
Number classification
| Entry | Function | Description |
| 0 | int __fpclassifyf(float); | float version |
| 1 | int __fpclassifyd(double); | double version |
Returns a classification of the floating point argument passed, as specified below:
| Value | Meaning |
| 0 | Value is zero |
| 1 | Value is a sub-normal FP value |
| 2 | Value is a normal FP value |
| 3 | Value is an infinity FP value |
| 4 | Value is Not-A-Number (NAN) FP value |
Note: FP values are passed in FP registers.
| Entry | Function | Description |
| 2 | int __signbitf(float); | float version |
| 3 | int __signbitd(double); | double version |
Returns the value of the sign bit for the floating point argument passed. 1 if the sign bit is set, 0 if the sign bit is clear.
Note: FP values are passed in FP registers.
| Entry | Function | Description |
| 4 | double copysign(double x, double y); | double version |
| 5 | float copysignf(float x, float y); | float version |
Returns a floating point value whose sign matches that of y, and whose magnitude is that of x. Effectively, copies the sign of y into x and returns it.
Note: FP values are passed in FP registers.
| Entry | Function | Description |
| 6 | double nan(const char *tag); | double version |
| 7 | float nanf(const char *tag); | float version |
Returns a Not-A-Number (NAN) FP value. The value of tag is implementation defined. Current implementations ignore the value of tag.
| Entry | Function | Description |
| 8 | double nextafter(double x, double y); | double version |
| 9 | float nextafterf(float x, float y); | float version |
Returns the next representable value in the specified format after x in the direction of y.
| Entry | Function | Description |
| 10 | double fdim(double x, double y); | double version |
| 11 | float fdimf(float x, float y); | float version |
Determines the positive difference between the arguments:
- if x > y, returns x-y
- if x <= y, returns +0
A range error may occur. Returns the positive difference value.
| Entry | Function | Description |
| 12 | double fmax(double x, double y); | double version |
| 13 | float fmaxf(float x, float y); | float version |
Returns the higher of the two arguments.
| Entry | Function | Description |
| 14 | double fmin(double x, double y); | double version |
| 15 | float fminf(float x, float y); | float version |
Returns the lower of the two arguments.
| Entry | Function | Description |
| 16 | float fabsf(float x); | Returns the absolute value of the argument. |
| Entry | Function | Description |
| 17 | double hypot(double x, double y); | double version |
| 18 | float hypotf(float x, float y); | float version |
Returns the square root of the sum of the squares of x and y, without undue overflow or underflow. A range error may occur.
Floating Point Environment operations
| Entry | Function | Description |
| 19 | int feclearexcept(int exceptions); | Clears floating point exceptions. Returns the bit mask of the exceptions which could not be cleared. |
The exceptions bit mask is:
| Bit | Exception |
| 0 | Invalid operation |
| 1 | Division by zero |
| 2 | Overflow |
| 3 | Underflow |
| 4 | Inexact |
| Entry | Function | Description |
| 20 | int fegetexceptflag(unsigned int *flagsp, int exceptions); | Reads the representation of the FP status flags indicated by the exceptions arguments. Returns zero if successful, non-zero if failed. |
| Entry | Function | Description |
| 21 | int feraiseexcept(int exceptions); | Attempts to raise the floating point exceptions specified within the exceptions flags. Returns zero if successful, non-zero if failed. |
| Entry | Function | Description |
| 22 | int fesetexceptflag(unsigned int *flagsp, int exceptions); | Attempts to set the status flags indicated by the exceptions argument to those stored in the value pointed to by flagsp. This function can be used together with fegetexceptflag() to preserve and restore floating point status flags. Returns zero if successful, or non-zero if failed. |
| Entry | Function | Description |
| 23 | int fetestexcept(int exceptions); | Determines which of the exceptions specified in the argument are currently set. Returns the exceptions which are currently set, from those specified within the argument. |
| Entry | Function | Description |
| 24 | int fegetround(void); | Reads the current rounding direction. Returns 0 indicating 'round to nearest'. The current implementation of the ARM FP system cannot change its rounding direction at runtime. |
| Entry | Function | Description |
| 25 | int fesetround(int direction); | Changes the rounding direction. Returns 0 indicating success if the direction specified was 0, or 1 indicating a failure otherwise. |
| Entry | Function | Description |
| 26 | int fegetenv(const fenv_t *envp); | Reads the current floating point environment into the structure specified. The structure must be 6 words long. Returns 0 if successful, or 1 if failed. |
| Entry | Function | Description |
| 27 | int feholdexcept(const fenv_t *envp); | Reads the current floating point environment into the structure specified, clears any pending exceptions and disables all floating point exceptions. Returns 0 if successful, or 1 if failed. |
| Entry | Function | Description |
| 28 | int fesetenv(const fenv_t *envp); | Attempts to set the floating point environment to that stored in the argument. No exceptions are raised. Returns 0 if successful, or 1 if failed. |
| Entry | Function | Description |
| 29 | int feupdateenv(const fenv_t *envp); | Attempts to set the floating point environment to that stored in the argument. Exceptions are then raised. Returns 0 if successful, or 1 if failed. |
Extended string operations
| Entry | Function | Description |
| 30 | int _snprintf(char *output, size_t max, const char *format, ...); | Integer-only form of sprintf, limited to max output bytes. Consult the C specification for details of the format parameters. Returns the number of bytes which have been written to the output buffer, or would have been written if the buffer had been long enough. |
| Entry | Function | Description |
| 31 | int snprintf(char *output, size_t max, const char *format, ...); | Form of sprintf, limited to max output bytes. Consult the C specification for details of the format parameters. Returns the number of bytes which have been written to the output buffer, or would have been written if the buffer had been long enough. |
| Entry | Function | Description |
| 32 | int vsnprintf(char *output, size_t max, const char *format, va_list ap); | Variadic arguments form of snprintf. Consult the C specification for details of the format parameters. Returns the number of bytes which have been written to the output buffer, or would have been written if the buffer had been long enough. |
| Entry | Function | Description |
| 33 | int vfscanf(FILE *f, const char *format, va_list); | Variadic form of fscanf. Consult the C specification for details of the format parameters. Returns the number of arguments processed, or EOF if failed before any conversion. |
| Entry | Function | Description |
| 34 | int vscanf(const char *format, va_list); | Variadic form of scanf. Consult the C specification for details of the format parameters. Returns the number of arguments processed, or EOF if failed before any conversion. |
| Entry | Function | Description |
| 35 | int vsscanf(const char *string, const char *format, va_list); | Variadic form of sscanf. Consult the C specification for details of the format parameters. Returns the number of arguments processed, or EOF if failed before any conversion. |
Rounding and remainder functions
| Entry | Function | Description |
| 36 | float ceilf(float x); | Returns the smallest integer not less than x. |
| Entry | Function | Description |
| 37 | float floorf(float x); | Returns the largest integer not greater than x. |
| Entry | Function | Description |
| 38 | double nearbyint(double x); | double version |
| 39 | float nearbyintf(float x); | float version |
Rounds its argument to an integer value, using the current rounding direction. Does not raise the inexact exception.
| Entry | Function | Description |
| 40 | double rint(double x); | double version |
| 41 | float rintf(float x); | float version |
| 42 | long int lrint(double x); | double version, returning a long int |
| 43 | long int lrintf(float x); | float version, returning a long int |
Rounds its argument to an integer value, using the current rounding direction. Raises "inexact" if the result differs from the argument.
| Entry | Function | Description |
| 44 | double round(double x); | double version |
| 45 | float roundf(float x); | float version |
| 46 | long int lround(double x); | double version, returning a long int |
| 47 | long int lroundf(float x); | float version, returning a long int |
Rounds its argument to the nearest integer value, rounding halfway cases away from zero.
| Entry | Function | Description |
| 48 | double trunc(double x); | double version |
| 49 | float truncf(float x); | float version |
Rounds its argument to the integer value, nearest to but no larger in magnitude than the argument.
| Entry | Function | Description |
| 50 | double remainder(double x, double y); | double version |
| 51 | float remainderf(float x, float y); | float version |
Computes the remainder x REM y required by IEEE 754.
Long Long operations
| Entry | Function | Description |
| 52 | long long llabs(long long j); | Returns the absolute value of j. |
| Entry | Function | Description |
| 53 | lldiv_t lldiv(long long j, long long k); | Computes numer / denom and numer % denom in a single operation. Returns a structure of type lldiv_t, comprising both the quotient and the remainder. |
typedef struct lldiv_t { long long quot;
long long rem;
} lldiv_t;
String conversion functions
| Entry | Function | Description |
| 54 | long long atoll(const char *s); | Returns the value of the string in s. This is equivalent to strtoll(s, (char **)NULL, 10); with the exception that errno is unaffected by the conversion. |
| Entry | Function | Description |
| 55 | long long strtoll(const char *s, char **e, int b); | Returns the value of the string in s, given in base b, storing the end of the conversion in pointer at e. e may be NULL if no end pointer is required. b may be 0 to indicate that the number is decimal, octal, or hexadecimal based on the prefix - '0x' indicates hexadecimal, '0' indicates octal, and all other values are decimal. Leading spaces, as determined by isspace(), are skipped. If b is 16, the string may be prefixed by '0x' and this will be skipped. The base may be any value from 2 to 36. If the value cannot be converted because it is too large, it will return LLONG_MAX or LLONG_MIN, depending on whether the overflowing value was positive or negative, and errno will be set to ERANGE. |
| Entry | Function | Description |
| 56 | unsigned long long strtoull(const char *s, char **e, int b); | Returns the value of the string in s as an unsigned value, given in base b, storing the end of the conversion in pointer at e. This function is identical to strtoll, except that underflow cannot be reported, and an overflow is indicated by ULLONG_MAX. |
| Entry | Function | Description |
| 57 | long long imaxabs(long long i); | Returns the absolute value of a 64bit value. Equivalent to llabs. |
| Entry | Function | Description |
| 58 | intmax_t imaxdiv(long long j, long long k); | Divides an intmax_t value by a second intmax_t value. Equivalent to lldiv. |
| Entry | Function | Description |
| 59 | intmax_t strtoimax(const char *s, char **e, int b); | Equivalent to strtoll. |
| 60 | intmax_t strtouimax(const char *s, char **e, int b); | Equivalent to strtoull. |
Core library support functions
| Entry | Function | Description |
| 61 | void __assert2(const char *message, const char *func, const char *file, int line); | Displays an error to stderr in response to an assertion, and then calls abort(). Never returns. |
| Entry | Function | Description |
| 62 | void _Exit(int status); | Terminates the program immediately, without calling the 'atexit' functions. This may mean under a C++ environment that destructors are not invoked. File descriptors opened by the standard stream functions will be closed. |
Extended floating point functions
The following entries are provided. Their behaviour is as specified by C99 for the functions of those names, with the 'f' suffix indicating the float variant.
| Entry | Function | Description |
| 63 | acosf | |
| 64 | asinf | |
| 65 | atanf | |
| 66 | atan2f | |
| 67 | cosf | |
| 68 | sinf | |
| 69 | tanf | |
| 70 | acosh | |
| 71 | acoshf | |
| 72 | asinh | |
| 73 | asinhf | |
| 74 | atanh | |
| 75 | atanhf | |
| 76 | expf | |
| 77 | exp2 | |
| 78 | exp2f | |
| 79 | expm1 | |
| 80 | expm1f | |
| 81 | frexpf | |
| 82 | ilogb | |
| 83 | ilogbf | |
| 84 | ldexpf | |
| 85 | logf | |
| 86 | log10f | |
| 87 | log1p | |
| 88 | log1pf | |
| 89 | log2 | |
| 90 | log2f | |
| 91 | logb | |
| 92 | logbf | |
| 93 | modff | |
| 94 | fmodf | |
| 95 | scalbn | |
| 96 | scalbnf | |
| 97 | scalbln | |
| 98 | scalblnf | |
| 99 | cbrt | |
| 100 | cbrtf | |
| 101 | powf | |
| 102 | sqrtf | |
| 103 | erf | |
| 104 | erff | |
| 105 | erfc | |
| 106 | erfcf | |
| 107 | lgamma | |
| 108 | lgammaf | |
| 109 | tgamma | |
| 110 | tgammaf | |
| 111 | nexttoward | |
| 112 | nexttowardf | |
| 113 | fmaf | |