[Select]

Programmer


Index

 

C99 support functions

The C99 support library (C99) provides a number of functions required by the C99 compiler and usable by other clients. The library has no data requirements. The library has a SharedCLibrary library chunk ID of 5.

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.

Functions

All functions within the library use APCS-R or APCS-32 (dependent on linkage) calling conventions.

Number classification

Entry number 0: int __fpclassifyf(float);

Entry number 1: int __fpclassifyd(double);
Returns a classification of the floating point argument passed, as specified below :

  1. = Value is zero
  2. = Value is a sub-normal FP value
  3. = Value is a normal FP value
  4. = Value is an infinity FP value
  5. = Value is Not-A-Number (NAN) FP value

Note: FP values are passed in FP registers.

Entry number 2: int __signbitf(float);

Entry number 3: int __signbitd(double);
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 number 4: double copysign(double x, double y);

Entry number 5: floats copysignf(float x, float y);
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 number 6: double nan(const char *tag);

Entry number 7: float nanf(const char *tag);
Returns a Not-A-Number (NAN) FP value. The value of tagp is implementation defined. Current implementations ignore the value of tagp.

Extra floating point functions

Entry number 8: double nextafter(double x, double y);

Entry number 9: float nextafterf(float x, float y);
Returns the next representable value in the specified format after x in the direction of y.

Entry number 10: double fdim(double x, double y);

Entry number 11: float fdimf(float x, float y);
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 number 12: double fmax(double x, double y);

Entry number 13: float fmaxf(float x, float y);

Returns the higher of the two arguments.

Entry number 14: double fmin(double x, double y);

Entry number 15: float fminf(float x, float y);
Returns the lower of the two arguments.

Entry number 16: float fabsf(float x);
Returns the absolute value of the argument.

Entry number 17: double hypot(double x, double y);

Entry number 18: float hypotf(float x, float y);
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 number 19: int feclearexcept(int exceptions);
Clears floating point exceptions.
Returns the bit mask of the exceptions which could not be cleared.
Exceptions bit mask :

      bit 0 = Invalid operation
      bit 1 = Division by zero
      bit 2 = Overflow
      bit 3 = Underflow
      bit 4 = Inexact

Entry number 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 number 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 number 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 number 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 number 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 number 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 number 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 number 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 number 28: int fesetenv(const fenv_t *envp);
Attempts to set the floating point enviroment to that stored in the argument. No exceptions are raised.
Returns 0 if successful, or 1 if failed.

Entry number 29: int feupdateenv(const fent_t *envp);
Attempts to set the floating point enviroment to that stored in the argument. Exceptions are then raised.
Returns 0 if successful, or 1 if failed.

Extended string operations

Entry number 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 number 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 number 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 number 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 number 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 number 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.

Limitations

Entry number 36: float ceilf(float x);
Returns the smallest integer not less than x.

Entry number 37: float floorf(float x);
Returns the largest integer not less than x.

Entry number 38: double nearbyint(double x);

Entry number 39: float nearbyintf(float x);
Rounds its argument to an integer value, using the current rounding direction. Does not raise the inexact exception.

Entry number 40: double rint(double x);

Entry number 41: float rintf(float x);

Entry number 42: long int lrint(double x);

Entry number 43: long int lrintf(float x);
Rounds its argument to an integer value, using the current rounding direction. Raises "inexact" if the result differs from the argument.

Entry number 44: double round(double x);

Entry number 45: float roundf(float x);

Entry number 46: long int lround(double x);

Entry number 47: long int lroundf(float x);
Rounds its argument to the nearest integer value, rounding halfway cases away from zero.

Entry number 48: double trunc(double x);

Entry number 49: float truncf(float x);
Rounds its argument to the integer value, nearest to but no larger in magnitude than the argument.

Entry number 50: double remainder(double x);

Entry number 51: float remainderf(float x);
Computes the remainder x REM y required by IEEE 754

Long Long operations

Entry number 52: long long llabs(long long j);
Returns the absolute value of j.

Entry number 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 quot;
        long long rem;
      } lldiv_t;
String conversion functions

Entry number 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 number 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 number 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 number 57: long long imaxabs(long long i);
Returns the absolute value of a 64bit value.
Equivalent to llabs.

Entry number 58: intmax_t imaxdiv(long long j, long long k);
Divides an intmax_t value by a second intmax_t value.
Equivilent to lldiv.

Entry number 59: imax_t strtoimax((const char *s, char **e, int b);

Entry number 60: imax_t strtouimax((const char *s, char **e, int b);
These functions are equivalent to strtoll and strtoull respectively.

Core library support functions

Entry number 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 number 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

Entry number 63: acosf

Entry number 64: asinf

Entry number 65: atanf

Entry number 66: atan2f

Entry number 67: cosf

Entry number 68: sinf

Entry number 69: tanf

Entry number 70: acosh

Entry number 71: acoshf

Entry number 72: asinh

Entry number 73: asinhf

Entry number 74: atanh

Entry number 75: atanhf

Entry number 76: expf

Entry number 77: exp2

Entry number 78: exp2f

Entry number 79: expm1

Entry number 80: expm1f

Entry number 81: frexpf

Entry number 82: ilogb

Entry number 83: ilogbf

Entry number 84: ldexpf

Entry number 85: logf

Entry number 86: log10f

Entry number 87: log1p

Entry number 88: log1pf

Entry number 89: log2

Entry number 90: log2f

Entry number 91: logb

Entry number 92: logbf

Entry number 93: modff

Entry number 94: fmodf

Entry number 95: scalbn

Entry number 96: scalbnf

Entry number 97: scalbln

Entry number 98: scalblnf

Entry number 99: cbrt

Entry number 100: cbrtf

Entry number 101: powf

Entry number 102: sqrtf

Entry number 103: erf

Entry number 104: erff

Entry number 105: erfc

Entry number 106: erfcf

Entry number 107: lgamma

Entry number 108: lgammaf

Entry number 109: tgamma

Entry number 100: tgammaf

Entry number 101: nexttoward

Entry number 102: nexttowardf

Entry number 103: fmaf


This documentation is copyright 3QD Developments Ltd 2013 and may not be reproduced or published in any form without the copyright holders permission. RISC OS is subject to continuous development and improvement as such all information is reproduced by 3QD Developments Ltd in good faith and is believed to be correct at the time of publication E&OE. 3QD Developments Ltd cannot accept any liability for any loss or damage arising from the use of any information provided as part of the RISC OS Documentation.

HTML document version 1.03 3rd November 2015