1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Some implementation details</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos Reference Manual"
20 HREF="ecos-ref.html"><LINK
22 TITLE="C and math library overview"
23 HREF="c-and-math-library-overview.html"><LINK
25 TITLE="Math library compatibility modes"
26 HREF="math-library-compatibility-modes.html"><LINK
29 HREF="libc-thread-safety.html"></HEAD
40 SUMMARY="Header navigation table"
49 >eCos Reference Manual</TH
57 HREF="math-library-compatibility-modes.html"
65 >Chapter 13. C and math library overview</TD
71 HREF="libc-thread-safety.html"
85 NAME="LIBC-IMPLEMENTATION-DETAILS">Some implementation details</H1
87 >Here are some details about the implementation
88 which might be interesting, although they do not affect the ISO-defined
89 semantics of the library. </P
95 >It is possible to configure
103 to have the standard C library without the kernel. You might want
104 to do this to use less memory. But if you disable the kernel, you
105 will be unable to use memory allocation, thread-safety and certain
106 stdio functions such as input. Other C library functionality is
111 >The opaque type returned by
116 is called clock_t, and is implemented as a 64 bit integer.
117 The value returned by
122 is only correct if the kernel is configured with real-time clock
123 support, as determined by the CYGVAR_KERNEL_COUNTERS_CLOCK
124 configuration option in
133 >The FILE type is not implemented as a structure, but rather
134 as a CYG_ADDRESS. </P
138 >The GNU C compiler will place its own <SPAN
145 instead of some C library functions. This can be turned off with
152 > option. The functions affected
212 >For faster execution speed you should avoid this option
213 and let the compiler use its built-ins. This can be turned off by
241 are located in the infrastructure package, not in the C library
242 package. This is because the compiler calls these functions, and
243 the kernel needs to resolve them even if the C library is not configured. </P
247 >Error codes such as EDOM and ERANGE, as well as
252 , are implemented in the <SPAN
259 error package is separate from the rest of the C and math libraries
268 can use these error handling facilities even if the C library is
278 is invoked, heap memory will normally be coalesced. If the CYGSEM_KERNEL_MEMORY_COALESCE
279 configuration parameter is not set, memory will not be coalesced,
280 which might cause programs to fail. </P
284 >Signals, as implemented by
287 ><signal.h></TT
288 >, are guaranteed to work
289 correctly if raised using the
294 function from a normal working program context. Using signals from
295 within an ISR or DSR context is not expected to work. Also, it is
296 not guaranteed that if CYGSEM_LIBC_SIGNALS_HWEXCEPTIONS
297 is set, that handling a signal using
302 will necessarily catch that form of exception. For example, it
303 may be expected that a divide-by-zero error would be caught by handling
307 >. However it depends on the underlying HAL implementation to implement
308 the required hardware exception. And indeed the hardware itself
309 may not be capable of detecting these exceptions so it may not be
310 possible for the HAL implementer to do this in any case. Despite
311 this lack of guarantees in this respect, the signals implementation
312 is still ISO C compliant since ISO C does not offer any such guarantees
322 function is implemented (unless the CYGPKG_LIBC_ENVIRONMENT configuration
323 option is turned off), but there is no shell or
328 function to set the environment dynamically. The environment is
329 set in a global variable environ, declared as:</P
337 CLASS="PROGRAMLISTING"
338 >extern char **environ; // Standard environment definition</PRE
343 >The environment can be statically initialized at startup time
344 using the CYGDAT_LIBC_DEFAULT_ENVIRONMENT
345 option. If so, remember that the final entry of the array initializer
350 >Here is a minimal <SPAN
357 demonstrates the use of environments (see also the test case in <TT
359 >language/c/libc/current/tests/stdlib/getenv.c</TT
368 CLASS="PROGRAMLISTING"
369 >#include <stdio.h>
370 #include <stdlib.h> // Main header for stdlib functions
372 extern char **environ; // Standard environment definition
375 main( int argc, char *argv[] )
378 char *env[] = { "PATH=/usr/local/bin:/usr/bin",
384 printf("Display the current PATH environment variable\n");
386 environ = (char **)&env;
388 str = getenv("PATH");
391 printf("The current PATH is unset\n");
393 printf("The current PATH is \"%s\"\n", str);
406 SUMMARY="Footer navigation table"
417 HREF="math-library-compatibility-modes.html"
435 HREF="libc-thread-safety.html"
445 >Math library compatibility modes</TD
451 HREF="c-and-math-library-overview.html"