original files of m241
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
# Makefile - makefile for target/src/libc/ctype
|
||||
#
|
||||
# modification history
|
||||
# --------------------
|
||||
# 01j,06jan11,jph remove include mapping file not needed
|
||||
# 01i,08nov10,jph add mapping file
|
||||
# 01h,26oct10,jph remove version
|
||||
# 01g,08oct09,kkz Adding version number
|
||||
# 01f,31aug07,pee WIND101680. Renamed rand to stdrand. Limitation of the tools.# File to be restored to original name when tools allow dups.
|
||||
# 01e,15sep05,mcm Fix for SPR#101756
|
||||
# 01d,04feb04,pch remove PPC32 hack, no longer needed
|
||||
# 01c,31jan03,pch Add PPC32 support
|
||||
# 01b,12oct01,tam added repackaging support
|
||||
# 01a,18jun96,yp created from 01d of MakeSkel
|
||||
#
|
||||
# DESCRIPTION
|
||||
# This file contains the makefile rules for building the vx library
|
||||
#
|
||||
#*/
|
||||
|
||||
TGT_DIR=$(WIND_BASE)/target
|
||||
|
||||
LIB_BASE_NAME = c_wr
|
||||
|
||||
DOC_FILES= ansiStdlib.c
|
||||
|
||||
## ansiStdlib.c includes 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 stdrand.c strtod.c strtol.c
|
||||
# strtoul.c system.c
|
||||
|
||||
OBJS= abort.o abs.o atexit.o atof.o atoi.o atol.o bsearch.o div.o labs.o \
|
||||
ldiv.o multibyte.o qsort.o stdrand.o strtol.o strtoul.o system.o strtod.o
|
||||
|
||||
include $(TGT_DIR)/h/make/rules.library
|
||||
|
||||
DOC_BOOK = Standard_C_and_C++_Libraries
|
||||
DOC_CHAPTER = VxWorks_Native_C_Libraries
|
||||
DOC_DIR=$(DOCS_ROOT)/$(DOC_CCPLUS_LIB)
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h, signal.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,47 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h, signal.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#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));
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
/* bsearch.c - bsearch routine for the stdlib ANSI library */
|
||||
|
||||
/* Copyright 1992-1993,2009 Wind River Systems, Inc. */
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01d,18may09,fan updated for LP64 data model
|
||||
01c,08feb93,jdi documentation cleanup for 5.1.
|
||||
01b,20sep92,smb documentation additions.
|
||||
01a,19jul92,smb written and documented
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILE: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#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 size_t 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);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/* div.c - div file for stdlib */
|
||||
|
||||
/* Copyright 1992-2001 Wind River Systems, Inc. */
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01g,25sep01,gls fixed div_r to check for negative numerator (SPR #30636)
|
||||
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.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#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>.
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
void div_r
|
||||
(
|
||||
int numer, /* numerator */
|
||||
int denom, /* denominator */
|
||||
div_t * divStructPtr /* div_t structure */
|
||||
)
|
||||
{
|
||||
/* calculate quotient */
|
||||
divStructPtr->quot = numer / denom;
|
||||
|
||||
/* calculate remainder */
|
||||
divStructPtr->rem = numer - (denom * divStructPtr->quot);
|
||||
|
||||
/* check for negative numerator */
|
||||
if ((numer < 0) && (divStructPtr->rem > 0))
|
||||
{
|
||||
divStructPtr->quot++;
|
||||
divStructPtr->rem -= denom;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/* labs.c - labs 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILE: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#include "vxWorks.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* labs - compute the absolute value of a `long' (ANSI)
|
||||
*
|
||||
* 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>.
|
||||
*/
|
||||
|
||||
long labs
|
||||
(
|
||||
long i /* long for which to return absolute value */
|
||||
)
|
||||
{
|
||||
return (i >= 0 ? i : -i);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/* ldiv.c - ldiv file for stdlib */
|
||||
|
||||
/* Copyright 1992-2001 Wind River Systems, Inc. */
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01f,25sep01,gls fixed ldiv_r to check for negative numerator (SPR #30636)
|
||||
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 of ldiv()
|
||||
01a,19jul92,smb written.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#include "vxWorks.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ldiv - compute the quotient and remainder of the division (ANSI)
|
||||
*
|
||||
* 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'.
|
||||
*
|
||||
* INCLUDE FILES: stdlib.h
|
||||
*
|
||||
* RETURNS:
|
||||
* A structure of type `ldiv_t', containing both the quotient and the
|
||||
* remainder.
|
||||
*/
|
||||
|
||||
ldiv_t ldiv
|
||||
(
|
||||
long numer, /* numerator */
|
||||
long denom /* denominator */
|
||||
)
|
||||
{
|
||||
static ldiv_t divStruct;
|
||||
|
||||
ldiv_r (numer, denom, &divStruct);
|
||||
return (divStruct);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ldiv_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 `ldiv_t' structure
|
||||
* `divStructPtr'.
|
||||
*
|
||||
* This routine is the reentrant version of ldiv().
|
||||
*
|
||||
* INCLUDE FILES: stdlib.h
|
||||
*
|
||||
* RETURNS: N/A
|
||||
*/
|
||||
|
||||
void ldiv_r
|
||||
(
|
||||
long numer, /* numerator */
|
||||
long denom, /* denominator */
|
||||
ldiv_t * divStructPtr /* ldiv_t structure */
|
||||
)
|
||||
{
|
||||
/* calculate quotient */
|
||||
divStructPtr->quot = numer / denom;
|
||||
|
||||
/* calculate remainder */
|
||||
divStructPtr->rem = numer - (denom * divStructPtr->quot);
|
||||
|
||||
/* check for negative numerator */
|
||||
if ((numer < 0) && (divStructPtr->rem > 0))
|
||||
{
|
||||
divStructPtr->quot++;
|
||||
divStructPtr->rem -= denom;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,146 @@
|
||||
/* multibyte.c - multibyte file for stdlib */
|
||||
|
||||
/* Copyright 1992-1993,2009 Wind River Systems, Inc. */
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01d,07jan04,mcm Fix for SPR 92583
|
||||
01c,08feb93,jdi documentation cleanup for 5.1.
|
||||
01b,20sep92,smb documentation additions.
|
||||
01a,19jul92,smb written and documented.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
These ignore the current fixed ("C") locale and
|
||||
always indicate that no multibyte characters are supported.
|
||||
|
||||
INCLUDE FILES: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#include "vxWorks.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* mblen - calculate the length of a multibyte character (Unimplemented) (ANSI)
|
||||
*
|
||||
* This multibyte character function is unimplemented in VxWorks.
|
||||
*
|
||||
* INCLUDE FILES: stdlib.h
|
||||
*
|
||||
* RETURNS: OK, or ERROR if the parameters are invalid.
|
||||
*/
|
||||
|
||||
int mblen
|
||||
(
|
||||
const char * s,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
if ((strcmp (s,NULL) == 0) && (n == 0) && (*s == EOS))
|
||||
return (ERROR);
|
||||
|
||||
return (OK);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* mbtowc - convert a multibyte character to a wide character (Unimplemented) (ANSI)
|
||||
*
|
||||
* This multibyte character function is unimplemented in VxWorks.
|
||||
*
|
||||
* INCLUDE FILES: stdlib.h
|
||||
*
|
||||
* RETURNS: OK, or ERROR if the parameters are invalid.
|
||||
*/
|
||||
|
||||
int mbtowc
|
||||
(
|
||||
wchar_t * pwc,
|
||||
const char * s,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
if ((strcmp (s,NULL) == 0) && (n == 0) && (*s == EOS))
|
||||
return (ERROR);
|
||||
|
||||
return (OK);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* wctomb - convert a wide character to a multibyte character (Unimplemented) (ANSI)
|
||||
*
|
||||
* This multibyte character function is unimplemented in VxWorks.
|
||||
*
|
||||
* INCLUDE FILES: stdlib.h
|
||||
*
|
||||
* RETURNS: OK, or ERROR if the parameters are invalid.
|
||||
*/
|
||||
|
||||
int wctomb
|
||||
(
|
||||
char * s,
|
||||
wchar_t wchar
|
||||
)
|
||||
{
|
||||
if (strcmp (s,NULL) == 0)
|
||||
return (ERROR);
|
||||
|
||||
return (OK);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* mbstowcs - convert a series of multibyte char's to wide char's (Unimplemented) (ANSI)
|
||||
*
|
||||
* This multibyte character function is unimplemented in VxWorks.
|
||||
*
|
||||
* INCLUDE FILES: stdlib.h
|
||||
*
|
||||
* RETURNS: OK, or ERROR if the parameters are invalid.
|
||||
*/
|
||||
|
||||
size_t mbstowcs
|
||||
(
|
||||
wchar_t * pwcs,
|
||||
const char * s,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
if ((strcmp (s,NULL) == 0) && (n == 0) && (*s == EOS))
|
||||
return ((size_t)ERROR);
|
||||
|
||||
return (OK);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* wcstombs - convert a series of wide char's to multibyte char's (Unimplemented) (ANSI)
|
||||
*
|
||||
* This multibyte character function is unimplemented in VxWorks.
|
||||
*
|
||||
* INCLUDE FILES: stdlib.h
|
||||
*
|
||||
* RETURNS: OK, or ERROR if the parameters are invalid.
|
||||
*/
|
||||
|
||||
size_t wcstombs
|
||||
(
|
||||
char * s,
|
||||
const wchar_t * pwcs,
|
||||
size_t n
|
||||
)
|
||||
{
|
||||
if (pwcs == NULL || n == 0 || *pwcs == (wchar_t)EOS)
|
||||
return ((size_t)ERROR);
|
||||
|
||||
return (OK);
|
||||
}
|
||||
@@ -0,0 +1,407 @@
|
||||
/* qsort.c - qsort file for stdlib */
|
||||
|
||||
/* Copyright 1992-1993,2009 Wind River Systems, Inc. */
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01e,18may09,fan updated for LP64 data model
|
||||
01d,01jul93,jmm fixed parameter order of quick_sort and insertion_sort (spr 2202)
|
||||
01c,08feb93,jdi documentation cleanup for 5.1.
|
||||
01b,20sep92,smb documentation additions.
|
||||
01a,19jul92,smb written and documented.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
* Copyright (c) 1980, 1983, 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
INCLUDE FILES: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#include "vxWorks.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
/*
|
||||
* MTHRESH is the smallest partition for which we compare for a median
|
||||
* value instead of using the middle value.
|
||||
*/
|
||||
#define MTHRESH 6
|
||||
|
||||
/*
|
||||
* THRESH is the minimum number of entries in a partition for continued
|
||||
* partitioning.
|
||||
*/
|
||||
#define THRESH 4
|
||||
|
||||
static void insertion_sort(), quick_sort();
|
||||
|
||||
|
||||
/*
|
||||
* Swap two areas of size number of bytes. Although qsort(3) permits random
|
||||
* blocks of memory to be sorted, sorting pointers is almost certainly the
|
||||
* common case (and, were it not, could easily be made so). Regardless, it
|
||||
* isn't worth optimizing; the SWAP's get sped up by the cache, and pointer
|
||||
* arithmetic gets lost in the time required for comparison function calls.
|
||||
*/
|
||||
#define SWAP(a, b) \
|
||||
{ \
|
||||
cnt = size; \
|
||||
do \
|
||||
{ \
|
||||
ch = *a; \
|
||||
*a++ = *b; \
|
||||
*b++ = ch; \
|
||||
} while (--cnt); \
|
||||
}
|
||||
|
||||
/*
|
||||
* Knuth, Vol. 3, page 116, Algorithm Q, step b, argues that a single pass
|
||||
* of straight insertion sort after partitioning is complete is better than
|
||||
* sorting each small partition as it is created. This isn't correct in this
|
||||
* implementation because comparisons require at least one (and often two)
|
||||
* function calls and are likely to be the dominating expense of the sort.
|
||||
* Doing a final insertion sort does more comparisons than are necessary
|
||||
* because it compares the "edges" and medians of the partitions which are
|
||||
* known to be already sorted.
|
||||
*
|
||||
* This is also the reasoning behind selecting a small THRESH value (see
|
||||
* Knuth, page 122, equation 26), since the quicksort algorithm does less
|
||||
* comparisons than the insertion sort.
|
||||
*/
|
||||
#define SORT(bot, n) \
|
||||
{ \
|
||||
if (n > 1) \
|
||||
{ \
|
||||
if (n == 2) \
|
||||
{ \
|
||||
t1 = bot + size; \
|
||||
if (compar (t1, bot) < 0) \
|
||||
SWAP (t1, bot); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
insertion_sort(bot, n, size, compar); \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
||||
static void quick_sort
|
||||
(
|
||||
FAST char * bot,
|
||||
size_t nmemb,
|
||||
FAST size_t size,
|
||||
int (*compar)()
|
||||
);
|
||||
|
||||
static void insertion_sort
|
||||
(
|
||||
char * bot,
|
||||
size_t nmemb,
|
||||
FAST size_t size,
|
||||
int (*compar)()
|
||||
);
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* qsort - sort an array of objects (ANSI)
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
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 */
|
||||
)
|
||||
{
|
||||
/* static void insertion_sort(), quick_sort(); */
|
||||
|
||||
if (nmemb <= 1)
|
||||
return;
|
||||
|
||||
if (nmemb >= THRESH)
|
||||
quick_sort (bot, nmemb, size, compar);
|
||||
else
|
||||
insertion_sort (bot, nmemb, size, compar);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* quick_sort - sort an array of objects.
|
||||
*
|
||||
* RETURNS: no value.
|
||||
* NOMANUAL
|
||||
*/
|
||||
|
||||
static void quick_sort
|
||||
(
|
||||
FAST char * bot,
|
||||
size_t nmemb,
|
||||
FAST size_t size,
|
||||
int (*compar)()
|
||||
)
|
||||
{
|
||||
FAST size_t cnt;
|
||||
FAST uint_t ch;
|
||||
FAST char * top;
|
||||
FAST char * mid;
|
||||
FAST char * t1;
|
||||
FAST char * t2;
|
||||
FAST long n1;
|
||||
FAST long n2;
|
||||
char * bsv;
|
||||
|
||||
/* bot and nmemb must already be set. */
|
||||
|
||||
partition:
|
||||
|
||||
/* find mid and top elements */
|
||||
mid = bot + size * (nmemb >> 1);
|
||||
top = bot + (nmemb - 1) * size;
|
||||
|
||||
/*
|
||||
* Find the median of the first, last and middle element (see Knuth,
|
||||
* Vol. 3, page 123, Eq. 28). This test order gets the equalities
|
||||
* right.
|
||||
*/
|
||||
if (nmemb >= MTHRESH)
|
||||
{
|
||||
n1 = compar (bot, mid);
|
||||
n2 = compar (mid, top);
|
||||
|
||||
if ((n1 < 0) && (n2 > 0))
|
||||
t1 = compar (bot, top) < 0 ? top : bot;
|
||||
else
|
||||
if ((n1 > 0) && (n2 < 0))
|
||||
t1 = compar (bot, top) > 0 ? top : bot;
|
||||
else
|
||||
t1 = mid;
|
||||
|
||||
/* if mid element not selected, swap selection there */
|
||||
if (t1 != mid)
|
||||
{
|
||||
SWAP (t1, mid);
|
||||
mid -= size;
|
||||
}
|
||||
}
|
||||
|
||||
/* Standard quicksort, Knuth, Vol. 3, page 116, Algorithm Q. */
|
||||
#define didswap n1
|
||||
#define newbot t1
|
||||
#define replace t2
|
||||
|
||||
didswap = 0;
|
||||
bsv = bot;
|
||||
|
||||
FOREVER
|
||||
{
|
||||
while ((bot < mid) && (compar (bot, mid) <= 0))
|
||||
{
|
||||
bot += size;
|
||||
}
|
||||
|
||||
while (top > mid)
|
||||
{
|
||||
if (compar (mid, top) <= 0)
|
||||
{
|
||||
top -= size;
|
||||
continue;
|
||||
}
|
||||
newbot = bot + size; /* value of bot after swap */
|
||||
|
||||
if (bot == mid) /* top <-> mid, mid == top */
|
||||
replace = mid = top;
|
||||
else
|
||||
{ /* bot <-> top */
|
||||
replace = top;
|
||||
top -= size;
|
||||
}
|
||||
goto swap;
|
||||
}
|
||||
|
||||
if (bot == mid)
|
||||
break;
|
||||
|
||||
/* bot <-> mid, mid == bot */
|
||||
replace = mid;
|
||||
newbot = mid = bot; /* value of bot after swap */
|
||||
top -= size;
|
||||
|
||||
swap: SWAP(bot, replace);
|
||||
|
||||
bot = newbot;
|
||||
didswap = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Quicksort behaves badly in the presence of data which is already
|
||||
* sorted (see Knuth, Vol. 3, page 119) going from O N lg N to O N^2.
|
||||
* To avoid this worst case behavior, if a re-partitioning occurs
|
||||
* without swapping any elements, it is not further partitioned and
|
||||
* is insert sorted. This wins big with almost sorted data sets and
|
||||
* only loses if the data set is very strangely partitioned. A fix
|
||||
* for those data sets would be to return prematurely if the insertion
|
||||
* sort routine is forced to make an excessive number of swaps, and
|
||||
* continue the partitioning.
|
||||
*/
|
||||
if (!didswap)
|
||||
{
|
||||
insertion_sort (bsv, nmemb, size, compar);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Re-partition or sort as necessary. Note that the mid element
|
||||
* itself is correctly positioned and can be ignored.
|
||||
*/
|
||||
#define nlower n1
|
||||
#define nupper n2
|
||||
|
||||
bot = bsv;
|
||||
nlower = (mid - bot) / size; /* size of lower partition */
|
||||
mid += size;
|
||||
nupper = nmemb - nlower - 1; /* size of upper partition */
|
||||
|
||||
/*
|
||||
* If must call recursively, do it on the smaller partition; this
|
||||
* bounds the stack to lg N entries.
|
||||
*/
|
||||
if (nlower > nupper)
|
||||
{
|
||||
if (nupper >= THRESH)
|
||||
quick_sort (mid, (size_t)nupper, size, compar);
|
||||
else
|
||||
{
|
||||
SORT (mid, (size_t)nupper);
|
||||
if (nlower < THRESH)
|
||||
{
|
||||
SORT (bot, (size_t)nlower);
|
||||
return;
|
||||
}
|
||||
}
|
||||
nmemb = nlower;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nlower >= THRESH)
|
||||
quick_sort (bot, (size_t)nlower, size, compar);
|
||||
else
|
||||
{
|
||||
SORT (bot, (size_t)nlower);
|
||||
if (nupper < THRESH)
|
||||
{
|
||||
SORT (mid, (size_t)nupper);
|
||||
return;
|
||||
}
|
||||
}
|
||||
bot = mid;
|
||||
nmemb = nupper;
|
||||
}
|
||||
goto partition;
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* insertion_sort - internal routine
|
||||
*
|
||||
* RETURNS: no value.
|
||||
* NOMANUAL
|
||||
*/
|
||||
|
||||
static void insertion_sort
|
||||
(
|
||||
char * bot,
|
||||
size_t nmemb,
|
||||
FAST size_t size,
|
||||
int (*compar)()
|
||||
)
|
||||
{
|
||||
FAST size_t cnt;
|
||||
FAST uint_t ch;
|
||||
FAST char * s1;
|
||||
FAST char * s2;
|
||||
FAST char * t1;
|
||||
FAST char * t2;
|
||||
FAST char * top;
|
||||
|
||||
/*
|
||||
* A simple insertion sort (see Knuth, Vol. 3, page 81, Algorithm
|
||||
* S). Insertion sort has the same worst case as most simple sorts
|
||||
* (O N^2). It gets used here because it is (O N) in the case of
|
||||
* sorted data.
|
||||
*/
|
||||
top = bot + nmemb * size;
|
||||
|
||||
for (t1 = bot + size; t1 < top;)
|
||||
{
|
||||
for (t2 = t1; ((t2 -= size) >= bot) && (compar (t1, t2) < 0);)
|
||||
;
|
||||
if (t1 != (t2 += size))
|
||||
{
|
||||
/* Bubble bytes up through each element. */
|
||||
for (cnt = size; cnt--; ++t1)
|
||||
{
|
||||
ch = *t1;
|
||||
for (s1 = s2 = t1; (s2 -= size) >= t2; s1 = s2)
|
||||
{
|
||||
*s1 = *s2;
|
||||
}
|
||||
*s1 = ch;
|
||||
}
|
||||
}
|
||||
else
|
||||
t1 += size;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/* rand.c - rand, srand functions 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#include "vxWorks.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
ulong_t _Randseed = 1;
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* rand - generate a pseudo-random integer between 0 and RAND_MAX (ANSI)
|
||||
*
|
||||
* 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: srand()
|
||||
*/
|
||||
|
||||
int rand (void)
|
||||
{
|
||||
_Randseed = _Randseed * 1103515245 + 12345;
|
||||
return (uint_t) (_Randseed/65536) % (RAND_MAX + 1);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
*
|
||||
* srand - reset the value of the seed used to generate random numbers (ANSI)
|
||||
*
|
||||
* 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: rand()
|
||||
*/
|
||||
|
||||
void * srand
|
||||
(
|
||||
uint_t seed /* random number seed */
|
||||
)
|
||||
{
|
||||
_Randseed = seed;
|
||||
return (void *)0;
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
/* strtod.c function for stdlib */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992-1995, 2008-2009 Wind River Systems, Inc.
|
||||
*
|
||||
* The right to copy, distribute or otherwise make use of this software
|
||||
* may be licensed only pursuant to the terms of an applicable Wind River
|
||||
* license agreement. No license to Wind River intellectual property rights
|
||||
* is granted herein. All rights not licensed by Wind River are reserved
|
||||
* by Wind River.
|
||||
*/
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01h,05jun09,fan updated for LP64 data model
|
||||
01g,10sep08,mcm Fix for WIND00030598 - strtod does not stop when it sees "."
|
||||
Replaced with source from Wind River Compiler library.
|
||||
01f,26feb08,scm GNU corrections...
|
||||
01e,11feb95,jdi doc fix.
|
||||
01d,16aug93,dvs fixed value of endptr for strings that start with d, D, e, or E
|
||||
(SPR #2229)
|
||||
01c,08feb93,jdi documentation cleanup for 5.1.
|
||||
01b,20sep92,smb documentation additions.
|
||||
01a,19jul92,smb written and documented
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h, math.h, assert.h, errno.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#include <vxWorks.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <float.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define LARGE_EXP (INT_MAX/100)
|
||||
|
||||
#define F0 1.25
|
||||
#define F1 F0*F0
|
||||
#define F2 F1*F1
|
||||
#define F3 F2*F2
|
||||
#define F4 F3*F3
|
||||
#define F5 F4*F4
|
||||
#define F6 F5*F5
|
||||
#define F7 F6*F6
|
||||
#define F8 F7*F7
|
||||
#define F9 F8*F8
|
||||
#define F10 F9*F9
|
||||
#define F11 F10*F10
|
||||
#define F12 F11*F11
|
||||
#define F13 F12*F12
|
||||
#define F14 F13*F13
|
||||
|
||||
static const double f125[] = {
|
||||
F0, F1, F2, F3, F4, F5, F6, F7, F8,
|
||||
F9, 1.0
|
||||
};
|
||||
|
||||
#define F125MAX (&f125[sizeof(f125)/sizeof(double) - 1])
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* strtod - convert the initial portion of a string to a double (ANSI)
|
||||
*
|
||||
* 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'.
|
||||
*
|
||||
*/
|
||||
|
||||
double strtod
|
||||
(
|
||||
const char * nptr, /* string to convert */
|
||||
char ** endptr /* ptr to final string */
|
||||
)
|
||||
{
|
||||
int c, neg, ndigits, iexp, iexp1, legal;
|
||||
double val, adj_exp;
|
||||
const double *fp;
|
||||
|
||||
if (endptr) *endptr = (char *)nptr;
|
||||
while(isspace(c = *nptr++)) ;
|
||||
neg = 0;
|
||||
switch(c)
|
||||
{
|
||||
case '-':
|
||||
neg = 1;
|
||||
/* fall through */
|
||||
case '+':
|
||||
c = *nptr++;
|
||||
break;
|
||||
}
|
||||
legal = 0;
|
||||
ndigits = 0;
|
||||
iexp = 0;
|
||||
val = 0.0;
|
||||
while(isdigit(c))
|
||||
{ /* collect everything before . */
|
||||
if (ndigits > DBL_DIG+2)
|
||||
{
|
||||
iexp++;
|
||||
}
|
||||
else if (c != '0' || ndigits != 0)
|
||||
{
|
||||
val = val*10 + (c-'0');
|
||||
ndigits++;
|
||||
}
|
||||
legal = 1;
|
||||
c = *nptr++;
|
||||
}
|
||||
if (c == '.')
|
||||
{
|
||||
c = *nptr++;
|
||||
while(isdigit(c))
|
||||
{ /* collect everything after . */
|
||||
if (ndigits <= DBL_DIG+2)
|
||||
{
|
||||
if (c != '0' || ndigits != 0)
|
||||
{
|
||||
val = val*10 + (c-'0');
|
||||
ndigits++;
|
||||
}
|
||||
iexp--;
|
||||
}
|
||||
legal = 1;
|
||||
c = *nptr++;
|
||||
}
|
||||
}
|
||||
if (legal && endptr) *endptr = (char *)nptr - 1;
|
||||
legal = 0;
|
||||
if (neg) val = -val;
|
||||
iexp1 = 0;
|
||||
neg = 0;
|
||||
if (c == 'e' || c == 'E')
|
||||
{
|
||||
switch(c = *nptr++)
|
||||
{
|
||||
case '-':
|
||||
neg = 1;
|
||||
/* fall through */
|
||||
case '+':
|
||||
c = *nptr++;
|
||||
break;
|
||||
}
|
||||
while(isdigit(c))
|
||||
{ /* collect exponent */
|
||||
if (iexp1 < LARGE_EXP)
|
||||
{
|
||||
iexp1 = iexp1*10 + c - '0';
|
||||
}
|
||||
legal = 1;
|
||||
c = *nptr++;
|
||||
}
|
||||
if (neg) iexp1 = -iexp1;
|
||||
iexp += iexp1;
|
||||
}
|
||||
if (legal && endptr) *endptr = (char *)nptr - 1;
|
||||
|
||||
/* We now have result = val * 10**iexp. Change that to
|
||||
val1 * 2**iexp1 => val * 1.25**iexp * 2**(iexp*3) */
|
||||
|
||||
adj_exp = 1.;
|
||||
iexp1 = iexp;
|
||||
if (iexp1 < 0) iexp1 = -iexp1;
|
||||
fp = f125;
|
||||
while(iexp1)
|
||||
{ /* compensate mantissa */
|
||||
if (iexp1 & 1) adj_exp *= *fp;
|
||||
iexp1 >>= 1;
|
||||
if (fp < F125MAX) fp++;
|
||||
}
|
||||
if (iexp >= 0) val *= adj_exp;
|
||||
else val /= adj_exp;
|
||||
iexp *= 3;
|
||||
return ldexp(val,iexp);
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
/* strtol.c - strtol file for stdlib */
|
||||
|
||||
/* Copyright 1992-1995, 2013 Wind River Systems, Inc. */
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01g,08oct13,dee eliminate compiler warnings
|
||||
01f,11feb95,jdi doc fix.
|
||||
01e,13oct93,caf ansi fix: added cast when assigning from a const.
|
||||
01d,08feb93,jdi documentation cleanup for 5.1.
|
||||
01c,21sep92,smb tweaks for mg
|
||||
01b,20sep92,smb documentation additions.
|
||||
01a,10jul92,smb written and documented.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
|
||||
INCLUDE FILES: stdlib.h, limits.h, ctype.h, errno.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#include "vxWorks.h"
|
||||
#include "stdlib.h"
|
||||
#include "limits.h"
|
||||
#include "ctype.h"
|
||||
#include "errno.h"
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* strtol - convert a string to a long integer (ANSI)
|
||||
*
|
||||
* 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'.
|
||||
*/
|
||||
|
||||
long strtol
|
||||
(
|
||||
const char * nptr, /* string to convert */
|
||||
char ** endptr, /* ptr to final string */
|
||||
FAST int base /* radix */
|
||||
)
|
||||
{
|
||||
FAST const char *s = nptr;
|
||||
FAST ulong_t acc;
|
||||
FAST int c;
|
||||
FAST ulong_t cutoff;
|
||||
FAST int neg = 0;
|
||||
FAST int any;
|
||||
FAST int cutlim;
|
||||
|
||||
/*
|
||||
* Skip white space and pick up leading +/- sign if any.
|
||||
* If base is 0, allow 0x for hex and 0 for octal, else
|
||||
* assume decimal; if base is already 16, allow 0x.
|
||||
*/
|
||||
do
|
||||
{
|
||||
c = *s++;
|
||||
} while (isspace (c));
|
||||
|
||||
if (c == '-')
|
||||
{
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
}
|
||||
else if (c == '+')
|
||||
c = *s++;
|
||||
|
||||
if (((base == 0) || (base == 16)) &&
|
||||
(c == '0') &&
|
||||
((*s == 'x') || (*s == 'X')))
|
||||
{
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
|
||||
if (base == 0)
|
||||
base = (c == '0' ? 8 : 10);
|
||||
|
||||
/*
|
||||
* Compute the cutoff value between legal numbers and illegal
|
||||
* numbers. That is the largest legal value, divided by the
|
||||
* base. An input number that is greater than this value, if
|
||||
* followed by a legal input character, is too big. One that
|
||||
* is equal to this value may be valid or not; the limit
|
||||
* between valid and invalid numbers is then based on the last
|
||||
* digit. For instance, if the range for longs is
|
||||
* [-2147483648..2147483647] and the input base is 10,
|
||||
* cutoff will be set to 214748364 and cutlim to either
|
||||
* 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
|
||||
* a value > 214748364, or equal but the next digit is > 7 (or 8),
|
||||
* the number is too big, and we will return a range error.
|
||||
*
|
||||
* Set any if any `digits' consumed; make it negative to indicate
|
||||
* overflow.
|
||||
*/
|
||||
|
||||
cutoff = (neg ? -(ulong_t) LONG_MIN : LONG_MAX);
|
||||
cutlim = cutoff % (ulong_t) base;
|
||||
cutoff /= (ulong_t) base;
|
||||
|
||||
for (acc = 0, any = 0;; c = *s++)
|
||||
{
|
||||
if (isdigit (c))
|
||||
c -= '0';
|
||||
else if (isalpha (c))
|
||||
c -= (isupper(c) ? 'A' - 10 : 'a' - 10);
|
||||
else
|
||||
break;
|
||||
|
||||
if (c >= base)
|
||||
break;
|
||||
|
||||
if ((any < 0) || (acc > cutoff) || ((acc == cutoff) && (c > cutlim)))
|
||||
any = -1;
|
||||
else
|
||||
{
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
|
||||
if (any < 0)
|
||||
{
|
||||
acc = (neg ? LONG_MIN : LONG_MAX);
|
||||
errno = ERANGE;
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
|
||||
if (endptr != 0)
|
||||
*endptr = (any ? (char *) (s - 1) : (char *) nptr);
|
||||
|
||||
return (acc);
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
/* strtoul.c - strtoul file for stdlib */
|
||||
|
||||
/* Copyright 1992-1993, 2013 Wind River Systems, Inc. */
|
||||
|
||||
/*
|
||||
modification history
|
||||
--------------------
|
||||
01e,08oct13,dee eliminate compiler warnings
|
||||
01d,08feb93,jdi documentation cleanup for 5.1.
|
||||
01c,21sep92,smb tweaks for mg
|
||||
01b,20sep92,smb documentation additions.
|
||||
01a,10jul92,smb documented.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
* Copyright (c) 1990 Regents of the University of California.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
|
||||
INCLUDE FILES: stdlib.h, limits.h, ctype.h, errno.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#include "vxWorks.h"
|
||||
#include "limits.h"
|
||||
#include "ctype.h"
|
||||
#include "errno.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* strtoul - convert a string to an unsigned long integer (ANSI)
|
||||
*
|
||||
* 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>.
|
||||
*/
|
||||
|
||||
ulong_t strtoul
|
||||
(
|
||||
const char * nptr, /* string to convert */
|
||||
char ** endptr, /* ptr to final string */
|
||||
FAST int base /* radix */
|
||||
)
|
||||
{
|
||||
FAST const char *s = nptr;
|
||||
FAST ulong_t acc;
|
||||
FAST int c;
|
||||
FAST ulong_t cutoff;
|
||||
FAST int neg = 0;
|
||||
FAST int any;
|
||||
FAST int cutlim;
|
||||
|
||||
/*
|
||||
* See strtol for comments as to the logic used.
|
||||
*/
|
||||
do
|
||||
{
|
||||
c = *s++;
|
||||
} while (isspace (c));
|
||||
|
||||
if (c == '-')
|
||||
{
|
||||
neg = 1;
|
||||
c = *s++;
|
||||
}
|
||||
else if (c == '+')
|
||||
c = *s++;
|
||||
|
||||
if (((base == 0) || (base == 16)) &&
|
||||
(c == '0') &&
|
||||
((*s == 'x') || (*s == 'X')))
|
||||
{
|
||||
c = s[1];
|
||||
s += 2;
|
||||
base = 16;
|
||||
}
|
||||
|
||||
if (base == 0)
|
||||
base = (c == '0' ? 8 : 10);
|
||||
|
||||
cutoff = (ulong_t)ULONG_MAX / (ulong_t)base;
|
||||
cutlim = (ulong_t)ULONG_MAX % (ulong_t)base;
|
||||
|
||||
for (acc = 0, any = 0;; c = *s++)
|
||||
{
|
||||
if (isdigit (c))
|
||||
c -= '0';
|
||||
else if (isalpha (c))
|
||||
c -= (isupper (c) ? 'A' - 10 : 'a' - 10);
|
||||
else
|
||||
break;
|
||||
|
||||
if (c >= base)
|
||||
break;
|
||||
|
||||
if ((any < 0) || (acc > cutoff) || ((acc == cutoff) && (c > cutlim)))
|
||||
any = -1;
|
||||
else
|
||||
{
|
||||
any = 1;
|
||||
acc *= base;
|
||||
acc += c;
|
||||
}
|
||||
}
|
||||
|
||||
if (any < 0)
|
||||
{
|
||||
acc = ULONG_MAX;
|
||||
errno = ERANGE;
|
||||
}
|
||||
else if (neg)
|
||||
acc = -acc;
|
||||
|
||||
if (endptr != 0)
|
||||
*endptr = (any ? CHAR_FROM_CONST (s - 1) : CHAR_FROM_CONST (nptr));
|
||||
|
||||
return (acc);
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/* system.c - system 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,25mar92,smb written.
|
||||
*/
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
|
||||
INCLUDE FILES: stdlib.h
|
||||
|
||||
SEE ALSO: American National Standard X3.159-1989
|
||||
|
||||
NOMANUAL
|
||||
*/
|
||||
|
||||
#include "vxWorks.h"
|
||||
#include "stdlib.h"
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* system - pass a string to a command processor (Unimplemented) (ANSI)
|
||||
*
|
||||
* This function is not applicable to VxWorks.
|
||||
*
|
||||
* INCLUDE FILES: stdlib.h
|
||||
*
|
||||
* RETURNS: OK, always.
|
||||
*/
|
||||
int system
|
||||
(
|
||||
const char * string /* pointer to string */
|
||||
)
|
||||
{
|
||||
return (OK);
|
||||
}
|
||||
Reference in New Issue
Block a user