⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ansistdlib.c

📁 VXWORKS源代码
💻 C
📖 第 1 页 / 共 4 页
字号:
/* ansiStdlib.c - ANSI 'stdlib' documentation *//* Copyright 1992-1995 Wind River Systems, Inc. *//*modification history--------------------01d,11jul97,dgp  doc: SPR 7651 and 7677, specify non-reentrant functions01c,10feb95,jdi  doc tweaks for div_r(), strtod(), strtol().01b,08feb93,jdi  documentation cleanup for 5.1.01a,24oct92,smb  written and documented.*//*DESCRIPTIONThis library includes several standard ANSI routines.  Note that where there is a pair of routines, such as div() and div_r(), only the routinexxx_r() is reentrant.  The xxx() routine is not reentrant.The header stdlib.h declares four types and several functions of generalutility, and defines several macros..SS TypesThe types declared are `size_t', `wchar_t', and:.iP `div_t' 12is the structure type of the value returned by the div()..iP `ldiv_t'is the structure type of the value returned by the ldiv_t()..SS MacrosThe macros defined are NULL and:.iP "`EXIT_FAILURE', `EXIT_SUCCESS'" 12expand to integral constant expressions that may be used as theargument to exit() to return unsuccessful or successful terminationstatus, respectively, to the host environment..iP `RAND_MAX'expands to a positive integer expression whose value is the maximumnumber of bytes on a multibyte character for the extended character setspecified by the current locale, and whose value is never greaterthan MB_LEN_MAX..LPINCLUDE FILES: stdlib.hSEE ALSO: American National Standard X3.159-1989INTERNALThis module is built by appending the following files:    abort.c    abs.c    atexit.c    atof.c    atoi.c    atol.c    bsearch.c    div.c    labs.c    ldiv.c    multibyte.c    qsort.c    rand.c    strtod.c    strtol.c    strtoul.c    system.c*//* abort.c - abort file for stdlib  *//* Copyright 1992-1993 Wind River Systems, Inc. *//*modification history--------------------01d,08feb93,jdi  documentation cleanup for 5.1.01c,20sep92,smb  documentation additions.01b,27jul92,smb  abort now raises an abort signal.01a,19jul92,smb  Phase 1 of ANSI merge.*//*DESCRIPTIONINCLUDE FILES: stdlib.h, signal.hSEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "stdlib.h"#include "signal.h"/******************************************************************************** abort - cause abnormal program termination (ANSI)** This routine causes abnormal program termination, unless the signal* SIGABRT is being caught and the signal handler does not return.  VxWorks* does not flush output streams, close open streams, or remove temporary* files.  abort() returns unsuccessful status termination to the host* environment by calling:* .CS*     raise (SIGABRT);* .CE** INCLUDE FILES: stdlib.h** RETURNS: This routine cannot return to the caller.*/void abort (void)	{	raise (SIGABRT);	exit (EXIT_FAILURE);	}/* abs.c - abs file for stdlib  *//* Copyright 1992-1993 Wind River Systems, Inc. *//*modification history--------------------01c,08feb93,jdi  documentation cleanup for 5.1.01b,20sep92,smb  documentation additions.01a,19jul92,smb  written and documented.*//*DESCRIPTIONINCLUDE FILES: stdlib.hSEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "stdlib.h"/********************************************************************************* abs - compute the absolute value of an integer (ANSI)** This routine computes the absolute value of a specified integer.  If the* result cannot be represented, the behavior is undefined.** INCLUDE FILES: stdlib.h** RETURNS: The absolute value of <i>.*/int abs     (    int i          /* integer for which to return absolute value */    )    {    return (i >= 0 ? i : -i);    }/* atexit.c - atexit file for stdlib  *//* Copyright 1992-1993 Wind River Systems, Inc. *//*modification history--------------------01c,08feb93,jdi  documentation cleanup for 5.1.01b,20sep92,smb  documentation additions.01a,19jul92,smb  written.*//*DESCRIPTIONINCLUDE FILES: stdlib.h, signal.hSEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "stdlib.h"/********************************************************************************* atexit - call a function at program termination (Unimplemented) (ANSI)** This routine is unimplemented.  VxWorks task exit hooks* provide this functionality.** INCLUDE FILES: stdlib.h** RETURNS: ERROR, always.** SEE ALSO: taskHookLib*/int atexit     (    void (*__func)(void)	/* pointer to a function */    )     {    return (ERROR);     }/* atof.c - atof files for stdlib  *//* Copyright 1992-1993 Wind River Systems, Inc. *//*modification history--------------------01c,08feb93,jdi  documentation cleanup for 5.1.01b,20sep92,smb  documentation additions.01a,19jul92,smb  written and documentation.*//*DESCRIPTIONINCLUDE FILES: stdlib.hSEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "stdlib.h"/********************************************************************************* atof - convert a string to a `double' (ANSI)** This routine converts the initial portion of the string <s> * to double-precision representation. ** Its behavior is equivalent to:* .CS*     strtod (s, (char **)NULL);* .CE** INCLUDE FILES: stdlib.h** RETURNS: The converted value in double-precision representation.*/double atof    (    const char * s	/* pointer to string */    )    {    return (strtod (s, (char **) NULL));    }/* atoi.c - atoi files for stdlib  *//* Copyright 1992-1993 Wind River Systems, Inc. *//*modification history--------------------01c,08feb93,jdi  documentation cleanup for 5.1.01b,20sep92,smb  documentation additions.01a,19jul92,smb  written and documented.*//*DESCRIPTIONINCLUDE FILES: stdlib.hSEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "stdlib.h"/******************************************************************************** atoi - convert a string to an `int' (ANSI)** This routine converts the initial portion of the string* <s> to `int' representation.** Its behavior is equivalent to:* .CS*     (int) strtol (s, (char **) NULL, 10);* .CE** INCLUDE FILES: stdlib.h** RETURNS: The converted value represented as an `int'.*/int atoi    (    const char * s		/* pointer to string */    )    {    return (int) strtol (s, (char **) NULL, 10);    }/* atol.c - atol files for stdlib  *//* Copyright 1992-1993 Wind River Systems, Inc. *//*modification history--------------------01c,08feb93,jdi  documentation cleanup for 5.1.01b,20sep92,smb  documentation additions.01a,19jul92,smb  written.*//*DESCRIPTIONINCLUDE FILES: stdlib.hSEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "stdlib.h"/******************************************************************************* atol - convert a string to a `long' (ANSI)** This routine converts the initial portion of the string <s> * to long integer representation.** Its behavior is equivalent to:* .CS*     strtol (s, (char **)NULL, 10);* .CE** INCLUDE FILES: stdlib.h** RETURNS: The converted value represented as a `long'.*/long atol    (    const register char * s		/* pointer to string */    )    {    return strtol (s, (char **) NULL, 10);    }/* bsearch.c	- bsearch routine for the stdlib ANSI library *//* Copyright 1992-1993 Wind River Systems, Inc. *//*modification history--------------------01c,08feb93,jdi  documentation cleanup for 5.1.01b,20sep92,smb  documentation additions.01a,19jul92,smb  written and documented*//*DESCRIPTIONINCLUDE FILE: stdlib.hSEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "stdlib.h"/******************************************************************************** bsearch - perform a binary search (ANSI)** This routine searches an array of <nmemb> objects, the initial element of* which is pointed to by <base0>, for an element that matches the object* pointed to by <key>.  The <size> of each element of the array is specified* by <size>.** The comparison function pointed to by <compar> is called with two arguments* that point to the <key> object and to an array element, in that order.  The* function shall return an integer less than, equal to, or greater than zero if* the <key> object is considered, respectively, to be less than, to match, or* to be greater than the array element.  The array shall consist of all the* elements that compare greater than the <key> object, in that order.** INCLUDE FILES: stdlib.h** RETURNS:* A pointer to a matching element of the array, or a NULL pointer* if no match is found.  If two elements compare as equal, which element * is matched is unspecified.*/void * bsearch    (    FAST const void *	key,		/* element to match */    const void *	base0,		/* initial element in array */    size_t		nmemb,		/* array to search */    FAST size_t		size,		/* size of array element */    FAST int (*compar) (const void *, const void *)  /* comparison function */    )    {    FAST const char *     base = base0;    FAST const void *     p;    FAST int              lim;    FAST int              cmp;    for (lim = nmemb; lim != 0; lim >>= 1) 	{    	p = base + (lim >> 1) * size;    	cmp = (*compar)(key, p);    	if (cmp == 0)    	    return (CHAR_FROM_CONST (p));    	if (cmp > 0) 	    {				/* key > p: move right */    	    base = (CHAR_FROM_CONST (p) + size);    	    lim--;    	    } 		        }    return (NULL);    }/* div.c - div file for stdlib  *//* Copyright 1992-1995 Wind River Systems, Inc. *//*modification history--------------------01f,10feb95,jdi  doc format tweak.01e,08feb93,jdi  documentation cleanup for 5.1.01d,20sep92,smb  documentation additions.01c,24jul92,smb  corrected parameter ordering.01b,24jul92,smb  added reentrant version for div()01a,19jul92,smb  written and documented.*//*DESCRIPTIONINCLUDE FILES: stdlib.hSEE ALSO: American National Standard X3.159-1989NOMANUAL*/#include "vxWorks.h"#include "stdlib.h"/********************************************************************************* div - compute a quotient and remainder (ANSI)** This routine computes the quotient and remainder of <numer>/<denom>.* If the division is inexact, the resulting quotient is the integer of lesser* magnitude that is the nearest to the algebraic quotient.  If the result cannot* be represented, the behavior is undefined; otherwise, `quot' * <denom> + `rem'* equals <numer>.** This routine is not reentrant.  For a reentrant version, see div_r().** INCLUDE FILES: stdlib.h ** RETURNS:* A structure of type `div_t', containing both the quotient and the * remainder. ** INTERNAL* The structure shall contain the following members, in either order:*		int quot; * quotient **		int rem;  * remainder **/div_t div     (    int numer, 		/* numerator */    int denom		/* denominator */    )     {    static div_t divStruct;	/* div_t structure */    div_r (numer, denom, &divStruct);    return (divStruct);    }/********************************************************************************* div_r - compute a quotient and remainder (reentrant)** This routine computes the quotient and remainder of <numer>/<denom>.* The quotient and remainder are stored in the `div_t' structure* pointed to by <divStructPtr>.** This routine is the reentrant version of div().** INCLUDE FILES: stdlib.h ** RETURNS: N/A

⌨️ 快捷键说明

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