eCos Reference Manual
Prev |  | Next

# Chapter 8. C and math library overview

eCos provides compatibility with the ISO 9899:1990 specification for the standard C library, which is essentially the same as the better-known ANSI C3.159-1989 specification (C-89).

There are three aspects of this compatibility supplied by eCos. First there is a C library which implements the functions defined by the ISO standard, except for the mathematical functions. This is provided by the eCos C library packages.

Then eCos provides a math library, which implements the mathematical functions from the ISO C library. This distinction between C and math libraries is frequently drawn — most standard C library implementations provide separate linkable files for the two, and the math library contains all the functions from the `math.h` header file.

There is a third element to the ISO C library, which is the environment in which applications run when they use the standard C library. This environment is set up by the C library startup procedure (the Section called C library startup) and it provides (among other things) a `main()` entry point function, an `exit()` function that does the cleanup required by the standard (including handlers registered using the `atexit()` function), and an environment that can be read with `getenv()`.

The description in this manual focuses on the eCos-specific aspects of the C library (mostly related to eCos's configurability) as well as mentioning the omissions from the standard in this release. We do not attempt to define the semantics of each function, since that information can be found in the ISO, ANSI, POSIX and IEEE standards, and the many good books that have been written about the standard C library, that cover usage of these functions in a more general and useful way.

# Included non-ISO functions

The following functions from the POSIX specification are included for convenience:

extern char **environ variable (for setting up the environment for use with `getenv()`)

`_exit()`

`strtok_r()`

`rand_r()`

`asctime_r()`

`ctime_r()`

`localtime_r()`

`gmtime_r()`

eCos provides the following additional implementation-specific functions within the standard C library to adjust the date and time settings:

    void cyg_libc_time_setdst(
      cyg_libc_time_dst state
    );

This function sets the state of Daylight Savings Time. The values for state are:

    CYG_LIBC_TIME_DSTNA   unknown
    CYG_LIBC_TIME_DSTOFF  off
    CYG_LIBC_TIME_DSTON   on

    void cyg_libc_time_setzoneoffsets(
      time_t stdoffset, time_t dstoffset
    );

This function sets the offsets from UTC used when Daylight Savings Time is enabled or disabled. The offsets are in time_t’s, which are seconds in the current inplementation.

    Cyg_libc_time_dst cyg_libc_time_getzoneoffsets(
      time_t *stdoffset, time_t *dstoffset
    );

This function retrieves the current setting for Daylight Savings Time along with the offsets used for both STD and DST. The offsets are both in time_t’s, which are seconds in the current implementation.

    cyg_bool cyg_libc_time_settime(
      time_t utctime
    );

This function sets the current time for the system The time is specified as a time_t in UTC. It returns non-zero on error.

Prev | Home | Next
The ISO Standard C and Math Libraries | Up | Math library compatibility modes