VxWorks Reference Manual : Libraries

ansiStdlib

NAME

ansiStdlib - ANSI stdlib documentation

ROUTINES

abort( ) - cause abnormal program termination (ANSI)
abs( ) - compute the absolute value of an integer (ANSI)
atexit( ) - call a function at program termination (Unimplemented) (ANSI)
atof( ) - convert a string to a double (ANSI)
atoi( ) - convert a string to an int (ANSI)
atol( ) - convert a string to a long (ANSI)
bsearch( ) - perform a binary search (ANSI)
div( ) - compute a quotient and remainder (ANSI)
div_r( ) - compute a quotient and remainder (reentrant)
labs( ) - compute the absolute value of a long (ANSI)
ldiv( ) - compute the quotient and remainder of the division (ANSI)
ldiv_r( ) - compute a quotient and remainder (reentrant)
mblen( ) - calculate the length of a multibyte character (Unimplemented) (ANSI)
mbtowc( ) - convert a multibyte character to a wide character (Unimplemented) (ANSI)
wctomb( ) - convert a wide character to a multibyte character (Unimplemented) (ANSI)
mbstowcs( ) - convert a series of multibyte char's to wide char's (Unimplemented) (ANSI)
wcstombs( ) - convert a series of wide char's to multibyte char's (Unimplemented) (ANSI)
qsort( ) - sort an array of objects (ANSI)
rand( ) - generate a pseudo-random integer between 0 and RAND_MAX (ANSI)
srand( ) - reset the value of the seed used to generate random numbers (ANSI)
strtod( ) - convert the initial portion of a string to a double (ANSI)
strtol( ) - convert a string to a long integer (ANSI)
strtoul( ) - convert a string to an unsigned long integer (ANSI)
system( ) - pass a string to a command processor (Unimplemented) (ANSI)

DESCRIPTION

This library includes several standard ANSI routines. Note that where there is a pair of routines, such as div( ) and div_r( ), only the routine xxx_r( ) is reentrant. The xxx( ) routine is not reentrant.

The header stdlib.h declares four types and several functions of general utility, and defines several macros.

Types

The types declared are size_t, wchar_t, and:
div_t
is the structure type of the value returned by the div( ).

ldiv_t
is the structure type of the value returned by the ldiv_t( ).

.SS
 Macros The macros defined are NULL and:
EXIT_FAILURE, EXIT_SUCCESS
expand to integral constant expressions that may be used as the argument to exit( ) to return unsuccessful or successful termination status, respectively, to the host environment.

RAND_MAX
expands to a positive integer expression whose value is the maximum number of bytes on a multibyte character for the extended character set specified by the current locale, and whose value is never greater than MB_LEN_MAX.

INCLUDE FILES

stdlib.h

SEE ALSO

ansiStdlib, American National Standard X3.159-1989


Libraries : Routines

abort( )

NAME

abort( ) - cause abnormal program termination (ANSI)

SYNOPSIS


void abort (void)

DESCRIPTION

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:

    raise (SIGABRT);

INCLUDE FILES

stdlib.h

RETURNS

This routine cannot return to the caller.

SEE ALSO

ansiStdlib


Libraries : Routines

abs( )

NAME

abs( ) - compute the absolute value of an integer (ANSI)

SYNOPSIS

int abs
    (
    int i /* integer for which to return absolute value */
    )

DESCRIPTION

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.

SEE ALSO

ansiStdlib


Libraries : Routines

atexit( )

NAME

atexit( ) - call a function at program termination (Unimplemented) (ANSI)

SYNOPSIS

int atexit
    (
    void (* __func)(void) /* pointer to a function */
    )

DESCRIPTION

This routine is unimplemented. VxWorks task exit hooks provide this functionality.

INCLUDE FILES

stdlib.h

RETURNS

ERROR, always.

SEE ALSO

ansiStdlib, taskHookLib


Libraries : Routines

atof( )

NAME

atof( ) - convert a string to a double (ANSI)

SYNOPSIS

double atof
    (
    const char * s /* pointer to string */
    )

DESCRIPTION

This routine converts the initial portion of the string s to double-precision representation.

Its behavior is equivalent to:

    strtod (s, (char **)NULL);

INCLUDE FILES

stdlib.h

RETURNS

The converted value in double-precision representation.

SEE ALSO

ansiStdlib


Libraries : Routines

atoi( )

NAME

atoi( ) - convert a string to an int (ANSI)

SYNOPSIS

int atoi
    (
    const char * s /* pointer to string */
    )

DESCRIPTION

This routine converts the initial portion of the string s to int representation.

Its behavior is equivalent to:

    (int) strtol (s, (char **) NULL, 10);

INCLUDE FILES

stdlib.h

RETURNS

The converted value represented as an int.

SEE ALSO

ansiStdlib


Libraries : Routines

atol( )

NAME

atol( ) - convert a string to a long (ANSI)

SYNOPSIS

long atol
    (
    const register char * s /* pointer to string */
    )

DESCRIPTION

This routine converts the initial portion of the string s to long integer representation.

Its behavior is equivalent to:

    strtol (s, (char **)NULL, 10);

INCLUDE FILES

stdlib.h

RETURNS

The converted value represented as a long.

SEE ALSO

ansiStdlib


Libraries : Routines

bsearch( )

NAME

bsearch( ) - perform a binary search (ANSI)

SYNOPSIS

void * bsearch
    (
    const void *                 key,   /* element to match */
    const void *                 base0, /* initial element in array */
    size_t                       nmemb, /* array to search */
    size_t                       size,  /* size of array element */
    int (* compar) (const void * ,
    const void *                 )      /* comparison function */
    )

DESCRIPTION

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.

SEE ALSO

ansiStdlib


Libraries : Routines

div( )

NAME

div( ) - compute a quotient and remainder (ANSI)

SYNOPSIS

div_t div
    (
    int numer, /* numerator */
    int denom  /* denominator */
    )

DESCRIPTION

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.

SEE ALSO

ansiStdlib


Libraries : Routines

div_r( )

NAME

div_r( ) - compute a quotient and remainder (reentrant)

SYNOPSIS

void div_r
    (
    int     numer,       /* numerator */
    int     denom,       /* denominator */
    div_t * divStructPtr /* div_t structure */
    )

DESCRIPTION

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

SEE ALSO

ansiStdlib


Libraries : Routines

labs( )

NAME

labs( ) - compute the absolute value of a long (ANSI)

SYNOPSIS

long labs
    (
    long i /* long for which to return absolute value */
    )

DESCRIPTION

This routine computes the absolute value of a specified long. If the result cannot be represented, the behavior is undefined. This routine is equivalent to abs( ), except that the argument and return value are all of type long.

INCLUDE FILES

stdlib.h

RETURNS

The absolute value of i.

SEE ALSO

ansiStdlib


Libraries : Routines

ldiv( )

NAME

ldiv( ) - compute the quotient and remainder of the division (ANSI)

SYNOPSIS

ldiv_t ldiv
    (
    long numer, /* numerator */
    long denom  /* denominator */
    )

DESCRIPTION

This routine computes the quotient and remainder of numer/denom. This routine is similar to div( ), except that the arguments and the elements of the returned structure are all of type long.

This routine is not reentrant. For a reentrant version, see ldiv_r( ).

INCLUDE FILES

stdlib.h

RETURNS

A structure of type ldiv_t, containing both the quotient and the remainder.

SEE ALSO

ansiStdlib


Libraries : Routines

ldiv_r( )

NAME

ldiv_r( ) - compute a quotient and remainder (reentrant)

SYNOPSIS

void ldiv_r
    (
    long     numer,       /* numerator */
    long     denom,       /* denominator */
    ldiv_t * divStructPtr /* ldiv_t structure */
    )

DESCRIPTION

This routine computes the quotient and remainder of numer/denom. The quotient and remainder are stored in the ldiv_t structure divStructPtr.

This routine is the reentrant version of ldiv( ).

INCLUDE FILES

stdlib.h

RETURNS

N/A

SEE ALSO

ansiStdlib


Libraries : Routines

mblen( )

NAME

mblen( ) - calculate the length of a multibyte character (Unimplemented) (ANSI)

SYNOPSIS

int mblen
    (
    const char * s,
    size_t       n
    )

DESCRIPTION

This multibyte character function is unimplemented in VxWorks.

INCLUDE FILES

stdlib.h

RETURNS

OK, or ERROR if the parameters are invalid.

SEE ALSO

ansiStdlib


Libraries : Routines

mbtowc( )

NAME

mbtowc( ) - convert a multibyte character to a wide character (Unimplemented) (ANSI)

SYNOPSIS

int mbtowc
    (
    wchar_t *    pwc,
    const char * s,
    size_t       n
    )

DESCRIPTION

This multibyte character function is unimplemented in VxWorks.

INCLUDE FILES

stdlib.h

RETURNS

OK, or ERROR if the parameters are invalid.

SEE ALSO

ansiStdlib


Libraries : Routines

wctomb( )

NAME

wctomb( ) - convert a wide character to a multibyte character (Unimplemented) (ANSI)

SYNOPSIS

int wctomb
    (
    char *  s,
    wchar_t wchar
    )

DESCRIPTION

This multibyte character function is unimplemented in VxWorks.

INCLUDE FILES

stdlib.h

RETURNS

OK, or ERROR if the parameters are invalid.

SEE ALSO

ansiStdlib


Libraries : Routines

mbstowcs( )

NAME

mbstowcs( ) - convert a series of multibyte char's to wide char's (Unimplemented) (ANSI)

SYNOPSIS

size_t mbstowcs
    (
    wchar_t *    pwcs,
    const char * s,
    size_t       n
    )

DESCRIPTION

This multibyte character function is unimplemented in VxWorks.

INCLUDE FILES

stdlib.h

RETURNS

OK, or ERROR if the parameters are invalid.

SEE ALSO

ansiStdlib


Libraries : Routines

wcstombs( )

NAME

wcstombs( ) - convert a series of wide char's to multibyte char's (Unimplemented) (ANSI)

SYNOPSIS

size_t wcstombs
    (
    char *          s,
    const wchar_t * pwcs,
    size_t          n
    )

DESCRIPTION

This multibyte character function is unimplemented in VxWorks.

INCLUDE FILES

stdlib.h

RETURNS

OK, or ERROR if the parameters are invalid.

SEE ALSO

ansiStdlib


Libraries : Routines

qsort( )

NAME

qsort( ) - sort an array of objects (ANSI)

SYNOPSIS

void qsort
    (
    void *                       bot,   /* initial element in array */
    size_t                       nmemb, /* no. of objects in array */
    size_t                       size,  /* size of array element */
    int (* compar) (const void * ,
    const void *                 )      /* comparison function */
    )

DESCRIPTION

This routine sorts an array of nmemb objects, the initial element of which is pointed to by bot. The size of each object is specified by size.

The contents of the array are sorted into ascending order according to a comparison function pointed to by compar, which is called with two arguments that point to the objects being compared. The function shall return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

If two elements compare as equal, their order in the sorted array is unspecified.

INCLUDE FILES

stdlib.h

RETURNS

N/A

SEE ALSO

ansiStdlib


Libraries : Routines

rand( )

NAME

rand( ) - generate a pseudo-random integer between 0 and RAND_MAX (ANSI)

SYNOPSIS


int rand (void)

DESCRIPTION

This routine generates a pseudo-random integer between 0 and RAND_MAX. The seed value for rand( ) can be reset with srand( ).

INCLUDE FILES

stdlib.h

RETURNS

A pseudo-random integer.

SEE ALSO

ansiStdlib, srand( )


Libraries : Routines

srand( )

NAME

srand( ) - reset the value of the seed used to generate random numbers (ANSI)

SYNOPSIS

void * srand
    (
    uint_t seed /* random number seed */
    )

DESCRIPTION

This routine resets the seed value used by rand( ). If srand( ) is then called with the same seed value, the sequence of pseudo-random numbers is repeated. If rand( ) is called before any calls to srand( ) have been made, the same sequence shall be generated as when srand( ) is first called with the seed value of 1.

INCLUDE FILES

stdlib.h

RETURNS

N/A

SEE ALSO

ansiStdlib, rand( )


Libraries : Routines

strtod( )

NAME

strtod( ) - convert the initial portion of a string to a double (ANSI)

SYNOPSIS

double strtod
    (
    const char * s,     /* string to convert */
    char * *     endptr /* ptr to final string */
    )

DESCRIPTION

This routine converts the initial portion of a specified string s to a double. First, it decomposes the input string into three parts: an initial, possibly empty, sequence of white-space characters (as specified by the isspace( ) function); a subject sequence resembling a floating-point constant; and a final string of one or more unrecognized characters, including the terminating null character of the input string. Then, it attempts to convert the subject sequence to a floating-point number, and returns the result.

The expected form of the subject sequence is an optional plus or minus decimal-point character, then an optional exponent part but no floating suffix. The subject sequence is defined as the longest initial subsequence of the input string, starting with the first non-white-space character, that is of the expected form. The subject sequence contains no characters if the input string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign, a digit, or a decimal-point character.

If the subject sequence has the expected form, the sequence of characters starting with the first digit or the decimal-point character (whichever occurs first) is interpreted as a floating constant, except that the decimal-point character is used in place of a period, and that if neither an exponent part nor a decimal-point character appears, a decimal point is assumed to follow the last digit in the string. If the subject sequence begins with a minus sign, the value resulting form the conversion is negated. A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null pointer.

In other than the "C" locale, additional implementation-defined subject sequence forms may be accepted. VxWorks supports only the "C" locale.

If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of s is stored in the object pointed to by endptr, provided that endptr is not a null pointer.

INCLUDE FILES

stdlib.h

RETURNS

The converted value, if any. If no conversion could be performed, it returns zero. If the correct value is outside the range of representable values, it returns plus or minus HUGE_VAL (according to the sign of the value), and stores the value of the macro ERANGE in errno. If the correct value would cause underflow, it returns zero and stores the value of the macro ERANGE in errno.

SEE ALSO

ansiStdlib


Libraries : Routines

strtol( )

NAME

strtol( ) - convert a string to a long integer (ANSI)

SYNOPSIS

long strtol
    (
    const char * nptr,   /* string to convert */
    char * *     endptr, /* ptr to final string */
    int          base    /* radix */
    )

DESCRIPTION

This routine converts the initial portion of a string nptr to long int representation. First, it decomposes the input string into three parts: an initial, possibly empty, sequence of white-space characters (as specified by isspace( )); a subject sequence resembling an integer represented in some radix determined by the value of base; and a final string of one or more unrecognized characters, including the terminating NULL character of the input string. Then, it attempts to convert the subject sequence to an integer number, and returns the result.

If the value of base is zero, the expected form of the subject sequence is that of an integer constant, optionally preceded by a plus or minus sign, but not including an integer suffix. If the value of base is between 2 and 36, the expected form of the subject sequence is a sequence of letters and digits representing an integer with the radix specified by base optionally preceded by a plus or minus sign, but not including an integer suffix. The letters from a (or A) through to z (or Z) are ascribed the values 10 to 35; only letters whose ascribed values are less than base are premitted. If the value of base is 16, the characters 0x or 0X may optionally precede the sequence of letters and digits, following the sign if present.

The subject sequence is defined as the longest initial subsequence of the input string, starting with the first non-white-space character, that is of the expected form. The subject sequence contains no characters if the input string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign or a permissible letter or digit.

If the subject sequence has the expected form and the value of base is zero, the sequence of characters starting with the first digit is interpreted as an integer constant. If the subject sequence has the expected form and the value of base is between 2 and 36, it is used as the base for conversion, ascribing to each latter its value as given above. If the subject sequence begins with a minus sign, the value resulting from the conversion is negated. A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a NULL pointer.

In other than the "C" locale, additional implementation-defined subject sequence forms may be accepted. VxWorks supports only the "C" locale; it assumes that the upper- and lower-case alphabets and digits are each contiguous.

If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of nptr is stored in the object pointed to by endptr, provided that endptr is not a NULL pointer.

INCLUDE FILES

stdlib.h

RETURNS

The converted value, if any. If no conversion could be performed, it returns zero. If the correct value is outside the range of representable values, it returns LONG_MAX or LONG_MIN (according to the sign of the value), and stores the value of the macro ERANGE in errno.

SEE ALSO

ansiStdlib


Libraries : Routines

strtoul( )

NAME

strtoul( ) - convert a string to an unsigned long integer (ANSI)

SYNOPSIS

ulong_t strtoul
    (
    const char * nptr,   /* string to convert */
    char * *     endptr, /* ptr to final string */
    int          base    /* radix */
    )

DESCRIPTION

This routine converts the initial portion of a string nptr to unsigned long int representation. First, it decomposes the input string into three parts: an initial, possibly empty, sequence of white-space characters (as specified by isspace( )); a subject sequence resembling an unsigned integer represented in some radix determined by the value base; and a final string of one or more unrecognized characters, including the terminating null character of the input string. Then, it attempts to convert the subject sequence to an unsigned integer, and returns the result.

If the value of base is zero, the expected form of the subject sequence is that of an integer constant, optionally preceded by a plus or minus sign, but not including an integer suffix. If the value of base is between 2 and 36, the expected form of the subject sequence is a sequence of letters and digits representing an integer with the radix specified by letters from a (or A) through z (or Z) which are ascribed the values 10 to 35; only letters whose ascribed values are less than base are premitted. If the value of base is 16, the characters 0x or 0X may optionally precede the sequence of letters and digits, following the sign if present.

The subject sequence is defined as the longest initial subsequence of the input string, starting with the first non-white-space character, that is of the expected form. The subject sequence contains no characters if the input string is empty or consists entirely of white space, or if the first non-white-space character is other than a sign or a permissible letter or digit.

If the subject sequence has the expected form and the value of base is zero, the sequence of characters starting with the first digit is interpreted as an integer constant. If the subject sequence has the expected form and the value of base is between 2 and 36, it is used as the base for conversion, ascribing to each letter its value as given above. If the subject sequence begins with a minus sign, the value resulting from the conversion is negated. A pointer to the final string is stored in the object pointed to by endptr, provided that endptr is not a null pointer.

In other than the "C" locale, additional implementation-defined subject sequence forms may be accepted. VxWorks supports only the "C" locale; it assumes that the upper- and lower-case alphabets and digits are each contiguous.

If the subject sequence is empty or does not have the expected form, no conversion is performed; the value of nptr is stored in the object pointed to by endptr, provided that endptr is not a null pointer.

INCLUDE FILES

stdlib.h

RETURNS

The converted value, if any. If no conversion could be performed it returns zero. If the correct value is outside the range of representable values, it returns ULONG_MAX, and stores the value of the macro ERANGE in errno.

SEE ALSO

ansiStdlib


Libraries : Routines

system( )

NAME

system( ) - pass a string to a command processor (Unimplemented) (ANSI)

SYNOPSIS

int system
    (
    const char * string /* pointer to string */
    )

DESCRIPTION

This function is not applicable to VxWorks.

INCLUDE FILES

stdlib.h

RETURNS

OK, always.

SEE ALSO

ansiStdlib