c-and-math-library-overview.html

来自「有关ecos2。0介绍了实时嵌入式的结构以及线程调度的实现和内存的管理等」· HTML 代码 · 共 449 行

HTML
449
字号
<!-- Copyright (C) 2003 Red Hat, Inc.                                --><!-- This material may be distributed only subject to the terms      --><!-- and conditions set forth in the Open Publication License, v1.0  --><!-- or later (the latest version is presently available at          --><!-- http://www.opencontent.org/openpub/).                           --><!-- Distribution of the work or derivative of the work in any       --><!-- standard (paper) book form is prohibited unless prior           --><!-- permission is obtained from the copyright holder.               --><HTML><HEAD><TITLE>C and math library overview</TITLE><meta name="MSSmartTagsPreventParsing" content="TRUE"><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+"><LINKREL="HOME"TITLE="eCos Reference Manual"HREF="ecos-ref.html"><LINKREL="UP"TITLE="The ISO Standard C and Math Libraries"HREF="libc.html"><LINKREL="PREVIOUS"TITLE="The ISO Standard C and Math Libraries"HREF="libc.html"><LINKREL="NEXT"TITLE="Math library compatibility modes"HREF="math-library-compatibility-modes.html"></HEAD><BODYCLASS="CHAPTER"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLESUMMARY="Header navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">eCos Reference Manual</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="libc.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom"></TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="math-library-compatibility-modes.html"ACCESSKEY="N">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="CHAPTER"><H1><ANAME="C-AND-MATH-LIBRARY-OVERVIEW">Chapter 13. C and math library overview</H1><DIVCLASS="TOC"><DL><DT><B>Table of Contents</B></DT><DT><AHREF="c-and-math-library-overview.html#INCLUDE-NON-ISO-FUNCTIONS">Included non-ISO functions</A></DT><DT><AHREF="math-library-compatibility-modes.html">Math library compatibility modes</A></DT><DT><AHREF="libc-implementation-details.html">Some implementation details</A></DT><DT><AHREF="libc-thread-safety.html">Thread safety</A></DT><DT><AHREF="c-library-startup.html">C library startup</A></DT></DL></DIV><ANAME="ISO-C-AND-MATH-LIBRARIES"></A><P><SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN> 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).</P><P>There are three aspects of this compatibility supplied by <SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN>.First there is a <ICLASS="FIRSTTERM">C library</I> whichimplements the functions defined by the ISO standard, except for themathematical functions. This is provided by the eCos C librarypackages. </P><P>Then <SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN> provides a mathlibrary, which implements the mathematical functions from the ISOC library. This distinction between C and math libraries is frequentlydrawn &#8212; most standard C library implementations provideseparate linkable files for the two, and the math library containsall the functions from the <TTCLASS="FILENAME">math.h</TT> headerfile.</P><P>There is a third element to the ISO C library, which is theenvironment in which applications run when they use the standardC library. This environment is set up by the C library startup procedure(<AHREF="c-library-startup.html">the Section called <I>C library startup</I></A>)and it provides (among other things) a <TTCLASS="FUNCTION">main()</TT> entrypoint function, an <TTCLASS="FUNCTION">exit()</TT> function thatdoes the cleanup required by the standard (including handlers registeredusing the <TTCLASS="FUNCTION">atexit()</TT> function), and an environmentthat can be read with <TTCLASS="FUNCTION">getenv()</TT>. </P><P>The description in this manual focuses on the <SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN>-specificaspects of the C library (mostly related to <SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN>'sconfigurability) as well as mentioning the omissions from the standardin this release. We do not attempt to define the semantics of eachfunction, since that information can be found in the ISO, ANSI,POSIX and IEEE standards, and the many good books that have beenwritten about the standard C library, that cover usage of thesefunctions in a more general and useful way.</P><DIVCLASS="SECT1"><H1CLASS="SECT1"><ANAME="INCLUDE-NON-ISO-FUNCTIONS">Included non-ISO functions</H1><P>The following functions from the POSIX specificationare included for convenience: </P><P>	<TTCLASS="LITERAL">extern char **</TT><SPANCLASS="emphasis"><ICLASS="EMPHASIS">environ</I></SPAN> variable(for setting up the environment for use with <TTCLASS="FUNCTION">getenv()</TT>)</P><P>	<TTCLASS="FUNCTION">_exit()</TT> </P><P>	<TTCLASS="FUNCTION">strtok_r()</TT> </P><P>	<TTCLASS="FUNCTION">rand_r()</TT> </P><P>	<TTCLASS="FUNCTION">asctime_r()</TT> </P><P>	<TTCLASS="FUNCTION">ctime_r()</TT> </P><P>	<TTCLASS="FUNCTION">localtime_r()</TT> </P><P>	<TTCLASS="FUNCTION">gmtime_r()</TT> </P><P><SPANCLASS="emphasis"><ICLASS="EMPHASIS">eCos</I></SPAN> provides the following additionalimplementation-specific functions within the standard C libraryto adjust the date and time settings:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void <TTCLASS="FUNCTION">cyg_libc_time_setdst</TT>(   cyg_libc_time_dst state);</PRE></TD></TR></TABLE><P>This function sets the state of Daylight Savings Time. Thevalues for state are:</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">CYG_LIBC_TIME_DSTNA   unknownCYG_LIBC_TIME_DSTOFF  offCYG_LIBC_TIME_DSTON   on</PRE></TD></TR></TABLE><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING">void <TTCLASS="FUNCTION">cyg_libc_time_setzoneoffsets</TT>(   time_t stdoffset, time_t dstoffset);</PRE></TD></TR></TABLE><P>This function sets the offsets from UTC used when DaylightSavings Time is enabled or disabled. The offsets are in time_t&#8217;s,which are seconds in the current inplementation.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"><TTCLASS="FUNCTION">Cyg_libc_time_dst cyg_libc_time_getzoneoffsets</TT>(   time_t *stdoffset, time_t *dstoffset);</PRE></TD></TR></TABLE><P>This function retrieves the current setting for Daylight SavingsTime along with the offsets used for both STD and DST. The offsetsare both in time_t&#8217;s, which are seconds in thecurrent implementation.</P><TABLEBORDER="5"BGCOLOR="#E0E0F0"WIDTH="70%"><TR><TD><PRECLASS="PROGRAMLISTING"><TTCLASS="FUNCTION">cyg_bool cyg_libc_time_settime</TT>(   time_t utctime);</PRE></TD></TR></TABLE><P>This function sets the current time for the system The timeis specified as a <SPANCLASS="TYPE">time_t</SPAN> in UTC.It returns non-zero on error.</P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLESUMMARY="Footer navigation table"WIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="libc.html"ACCESSKEY="P">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="ecos-ref.html"ACCESSKEY="H">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="math-library-compatibility-modes.html"ACCESSKEY="N">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">The ISO Standard C and Math Libraries</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="libc.html"ACCESSKEY="U">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Math library compatibility modes</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?