VxWorks Reference Manual : Libraries
ansiStdlib - ANSI stdlib documentation
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)
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.
The types declared are size_t, wchar_t, and:.SS
- 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( ).
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.
stdlib.h
ansiStdlib, American National Standard X3.159-1989
abort( ) - cause abnormal program termination (ANSI)
void abort (void)
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);
stdlib.h
This routine cannot return to the caller.
abs( ) - compute the absolute value of an integer (ANSI)
int abs ( int i /* integer for which to return absolute value */ )
This routine computes the absolute value of a specified integer. If the result cannot be represented, the behavior is undefined.
stdlib.h
The absolute value of i.
atexit( ) - call a function at program termination (Unimplemented) (ANSI)
int atexit ( void (* __func)(void) /* pointer to a function */ )
This routine is unimplemented. VxWorks task exit hooks provide this functionality.
stdlib.h
ERROR, always.
atof( ) - convert a string to a double (ANSI)
double atof ( const char * s /* pointer to string */ )
This routine converts the initial portion of the string s to double-precision representation.
Its behavior is equivalent to:
strtod (s, (char **)NULL);
stdlib.h
The converted value in double-precision representation.
atoi( ) - convert a string to an int (ANSI)
int atoi ( const char * s /* pointer to string */ )
This routine converts the initial portion of the string s to int representation.
Its behavior is equivalent to:
(int) strtol (s, (char **) NULL, 10);
stdlib.h
The converted value represented as an int.
atol( ) - convert a string to a long (ANSI)
long atol ( const register char * s /* pointer to string */ )
This routine converts the initial portion of the string s to long integer representation.
Its behavior is equivalent to:
strtol (s, (char **)NULL, 10);
stdlib.h
The converted value represented as a long.
bsearch( ) - perform a binary search (ANSI)
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 */ )
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.
stdlib.h
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.
div( ) - compute a quotient and remainder (ANSI)
div_t div ( int numer, /* numerator */ int denom /* denominator */ )
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( ).
stdlib.h
A structure of type div_t, containing both the quotient and the remainder.
div_r( ) - compute a quotient and remainder (reentrant)
void div_r ( int numer, /* numerator */ int denom, /* denominator */ div_t * divStructPtr /* div_t structure */ )
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( ).
stdlib.h
N/A
labs( ) - compute the absolute value of a long (ANSI)
long labs ( long i /* long for which to return absolute value */ )
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.
stdlib.h
The absolute value of i.
ldiv( ) - compute the quotient and remainder of the division (ANSI)
ldiv_t ldiv ( long numer, /* numerator */ long denom /* denominator */ )
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( ).
stdlib.h
A structure of type ldiv_t, containing both the quotient and the remainder.
ldiv_r( ) - compute a quotient and remainder (reentrant)
void ldiv_r ( long numer, /* numerator */ long denom, /* denominator */ ldiv_t * divStructPtr /* ldiv_t structure */ )
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( ).
stdlib.h
N/A
mblen( ) - calculate the length of a multibyte character (Unimplemented) (ANSI)
int mblen ( const char * s, size_t n )
This multibyte character function is unimplemented in VxWorks.
stdlib.h
OK, or ERROR if the parameters are invalid.
mbtowc( ) - convert a multibyte character to a wide character (Unimplemented) (ANSI)
int mbtowc ( wchar_t * pwc, const char * s, size_t n )
This multibyte character function is unimplemented in VxWorks.
stdlib.h
OK, or ERROR if the parameters are invalid.
wctomb( ) - convert a wide character to a multibyte character (Unimplemented) (ANSI)
int wctomb ( char * s, wchar_t wchar )
This multibyte character function is unimplemented in VxWorks.
stdlib.h
OK, or ERROR if the parameters are invalid.
mbstowcs( ) - convert a series of multibyte char's to wide char's (Unimplemented) (ANSI)
size_t mbstowcs ( wchar_t * pwcs, const char * s, size_t n )
This multibyte character function is unimplemented in VxWorks.
stdlib.h
OK, or ERROR if the parameters are invalid.
wcstombs( ) - convert a series of wide char's to multibyte char's (Unimplemented) (ANSI)
size_t wcstombs ( char * s, const wchar_t * pwcs, size_t n )
This multibyte character function is unimplemented in VxWorks.
stdlib.h
OK, or ERROR if the parameters are invalid.
qsort( ) - sort an array of objects (ANSI)
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 */ )
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.
stdlib.h
N/A
rand( ) - generate a pseudo-random integer between 0 and RAND_MAX (ANSI)
int rand (void)
This routine generates a pseudo-random integer between 0 and RAND_MAX. The seed value for rand( ) can be reset with srand( ).
stdlib.h
A pseudo-random integer.
ansiStdlib, srand( )
srand( ) - reset the value of the seed used to generate random numbers (ANSI)
void * srand ( uint_t seed /* random number seed */ )
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.
stdlib.h
N/A
ansiStdlib, rand( )
strtod( ) - convert the initial portion of a string to a double (ANSI)
double strtod ( const char * s, /* string to convert */ char * * endptr /* ptr to final string */ )
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.
stdlib.h
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.
strtol( ) - convert a string to a long integer (ANSI)
long strtol ( const char * nptr, /* string to convert */ char * * endptr, /* ptr to final string */ int base /* radix */ )
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.
stdlib.h
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.
strtoul( ) - convert a string to an unsigned long integer (ANSI)
ulong_t strtoul ( const char * nptr, /* string to convert */ char * * endptr, /* ptr to final string */ int base /* radix */ )
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.
stdlib.h
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.
system( ) - pass a string to a command processor (Unimplemented) (ANSI)
int system ( const char * string /* pointer to string */ )
This function is not applicable to VxWorks.
stdlib.h
OK, always.