Threadsafety and reentrancy, Some implementation details, Thread-safety and re-entrancy – Comtrol eCos User Manual
Page 358
Chapter 13. C and math library overview
Type
Behavior
DOMAIN
0.0 returned, errno=EDOM, and a message printed on
stderr
SING
HUGE of appropriate sign is returned, errno=EDOM,
and a message is printed on stderr
OVERFLOW
HUGE of appropriate sign is returned, and
errno=ERANGE
UNDERFLOW
0.0 is returned and errno=ERANGE
TLOSS
0.0 is returned, errno=ERANGE, and a message is
printed on stderr
PLOSS
The current implementation doesn’t return this type
X/Open mode is similar except that the message is not printed on stderr and HUGE_VAL is used in place of HUGE
Thread-safety and re-entrancy
With the appropriate configuration options set below, the math library is fully thread-safe if:
•
Depending on the compatibility mode, the setting of the errno variable from the C library is thread-safe
•
Depending on the compatibility mode, sending error messages to the stderr output stream using the C library
fputs()
function is thread-safe
•
Depending on the compatibility mode, the user-supplied
matherr()
function and anything it depends on are
thread-safe
In addition, with the exception of the
gamma*()
and
lgamma*()
functions, the math library is reentrant (and thus
safe to use from interrupt handlers) if the Math library is always in IEEE mode.
Some implementation details
Here are some details about the implementation which might be interesting, although they do not affect the ISO-
defined semantics of the library.
•
It is possible to configure eCos to have the standard C library without the kernel. You might want to do this to
use less memory. But if you disable the kernel, you will be unable to use memory allocation, thread-safety and
certain stdio functions such as input. Other C library functionality is unaffected.
•
The opaque type returned by
clock()
is called clock_t, and is implemented as a 64 bit integer. The value
returned by
clock()
is only correct if the kernel is configured with real-time clock support, as determined by
the CYGVAR_KERNEL_COUNTERS_CLOCK configuration option in
kernel.h
.
•
The FILE type is not implemented as a structure, but rather as a CYG_ADDRESS.
•
The GNU C compiler will place its own built-in implementations instead of some C library functions. This can
be turned off with the -fno-builtin option. The functions affected by this are
abs()
,
cos()
,
fabs()
,
labs()
,
memcmp()
,
memcpy()
,
sin()
,
sqrt()
,
strcmp()
,
strcpy()
, and
strlen()
.
254