2013-11-18 Sahil Patnayakuni <sahilp@oarcorp.com>

* libc/include/stdlib.h, libc/stdlib/mbstowcs.c,
	libc/stdlib/mbstowcs_r.c, libc/stdlib/mbtowc.c,
	libc/stdlib/mbtowc_r.c, libc/stdlib/strtod.c,
	libc/stdlib/strtol.c, libc/stdlib/strtold.c,
	libc/stdlib/strtoll.c, libc/stdlib/strtoll_r.c,
	libc/stdlib/strtoul.c, libc/stdlib/strtoull.c,
	libc/stdlib/strtoull_r.c, libc/stdlib/wcstombs.c,
	libc/stdlib/wcstombs_r.c: Add restrict keyword.
This commit is contained in:
Joel Sherrill 2013-11-18 17:26:52 +00:00
parent 7c62befe16
commit 8ab08406da
16 changed files with 79 additions and 68 deletions

View File

@ -1,3 +1,14 @@
2013-11-18 Sahil Patnayakuni <sahilp@oarcorp.com>
* libc/include/stdlib.h, libc/stdlib/mbstowcs.c,
libc/stdlib/mbstowcs_r.c, libc/stdlib/mbtowc.c,
libc/stdlib/mbtowc_r.c, libc/stdlib/strtod.c,
libc/stdlib/strtol.c, libc/stdlib/strtold.c,
libc/stdlib/strtoll.c, libc/stdlib/strtoll_r.c,
libc/stdlib/strtoul.c, libc/stdlib/strtoull.c,
libc/stdlib/strtoull_r.c, libc/stdlib/wcstombs.c,
libc/stdlib/wcstombs_r.c: Add restrict keyword.
2013-11-18 Marcus Shawcroft <marcus.shawcroft@arm.com>
* libc/include/sys/unistd.h (ftruncate, truncate): Define

View File

@ -94,14 +94,14 @@ ldiv_t _EXFUN(ldiv,(long __numer, long __denom));
_PTR _EXFUN_NOTHROW(malloc,(size_t __size));
int _EXFUN(mblen,(const char *, size_t));
int _EXFUN(_mblen_r,(struct _reent *, const char *, size_t, _mbstate_t *));
int _EXFUN(mbtowc,(wchar_t *, const char *, size_t));
int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *));
int _EXFUN(mbtowc,(wchar_t *__restrict, const char *__restrict, size_t));
int _EXFUN(_mbtowc_r,(struct _reent *, wchar_t *__restrict, const char *__restrict, size_t, _mbstate_t *));
int _EXFUN(wctomb,(char *, wchar_t));
int _EXFUN(_wctomb_r,(struct _reent *, char *, wchar_t, _mbstate_t *));
size_t _EXFUN(mbstowcs,(wchar_t *, const char *, size_t));
size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *, const char *, size_t, _mbstate_t *));
size_t _EXFUN(wcstombs,(char *, const wchar_t *, size_t));
size_t _EXFUN(_wcstombs_r,(struct _reent *, char *, const wchar_t *, size_t, _mbstate_t *));
size_t _EXFUN(mbstowcs,(wchar_t *__restrict, const char *__restrict, size_t));
size_t _EXFUN(_mbstowcs_r,(struct _reent *, wchar_t *__restrict, const char *__restrict, size_t, _mbstate_t *));
size_t _EXFUN(wcstombs,(char *__restrict, const wchar_t *__restrict, size_t));
size_t _EXFUN(_wcstombs_r,(struct _reent *, char *__restrict, const wchar_t *__restrict, size_t, _mbstate_t *));
#ifndef __STRICT_ANSI__
#ifndef _REENT_ONLY
char * _EXFUN(mkdtemp,(char *));
@ -125,10 +125,10 @@ _PTR _EXFUN_NOTHROW(realloc,(_PTR __r, size_t __size));
_PTR _EXFUN(reallocf,(_PTR __r, size_t __size));
#endif
_VOID _EXFUN(srand,(unsigned __seed));
double _EXFUN(strtod,(const char *__n, char **__end_PTR));
double _EXFUN(_strtod_r,(struct _reent *,const char *__n, char **__end_PTR));
double _EXFUN(strtod,(const char *__restrict __n, char **__restrict __end_PTR));
double _EXFUN(_strtod_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR));
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
float _EXFUN(strtof,(const char *__n, char **__end_PTR));
float _EXFUN(strtof,(const char *__restrict __n, char **__restrict __end_PTR));
#endif
#ifndef __STRICT_ANSI__
/* the following strtodf interface is deprecated...use strtof instead */
@ -136,10 +136,10 @@ float _EXFUN(strtof,(const char *__n, char **__end_PTR));
# define strtodf strtof
# endif
#endif
long _EXFUN(strtol,(const char *__n, char **__end_PTR, int __base));
long _EXFUN(_strtol_r,(struct _reent *,const char *__n, char **__end_PTR, int __base));
unsigned long _EXFUN(strtoul,(const char *__n, char **__end_PTR, int __base));
unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__n, char **__end_PTR, int __base));
long _EXFUN(strtol,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
long _EXFUN(_strtol_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR, int __base));
unsigned long _EXFUN(strtoul,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
unsigned long _EXFUN(_strtoul_r,(struct _reent *,const char *__restrict __n, char **__restrict __end_PTR, int __base));
int _EXFUN(system,(const char *__string));
@ -192,16 +192,16 @@ long long _EXFUN(llabs,(long long));
lldiv_t _EXFUN(lldiv,(long long __numer, long long __denom));
#endif /* ! __STRICT_ANSI__ */
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
long long _EXFUN(strtoll,(const char *__n, char **__end_PTR, int __base));
long long _EXFUN(strtoll,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif
#ifndef __STRICT_ANSI__
long long _EXFUN(_strtoll_r,(struct _reent *, const char *__n, char **__end_PTR, int __base));
long long _EXFUN(_strtoll_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif /* ! __STRICT_ANSI__ */
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
unsigned long long _EXFUN(strtoull,(const char *__n, char **__end_PTR, int __base));
unsigned long long _EXFUN(strtoull,(const char *__restrict __n, char **__restrict __end_PTR, int __base));
#endif
#ifndef __STRICT_ANSI__
unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__n, char **__end_PTR, int __base));
unsigned long long _EXFUN(_strtoull_r,(struct _reent *, const char *__restrict __n, char **__restrict __end_PTR, int __base));
#ifndef __CYGWIN__
_VOID _EXFUN(cfree,(_PTR));
@ -230,7 +230,7 @@ _VOID _EXFUN(__eprintf,(const char *, const char *, unsigned int, const char *))
/* On platforms where long double equals double. */
#ifdef _LDBL_EQ_DBL
#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L) || (__cplusplus >= 201103L)
extern long double strtold (const char *, char **);
extern long double strtold (const char *__restrict, char **__restrict);
#endif
extern long double wcstold (const wchar_t *, wchar_t **);
#endif /* _LDBL_EQ_DBL */

View File

@ -7,7 +7,7 @@ INDEX
ANSI_SYNOPSIS
#include <stdlib.h>
int mbstowcs(wchar_t *<[pwc]>, const char *<[s]>, size_t <[n]>);
int mbstowcs(wchar_t *restrict <[pwc]>, const char *restrict <[s]>, size_t <[n]>);
TRAD_SYNOPSIS
#include <stdlib.h>
@ -55,8 +55,8 @@ effects vary with the locale.
size_t
_DEFUN (mbstowcs, (pwcs, s, n),
wchar_t *pwcs _AND
const char *s _AND
wchar_t *__restrict pwcs _AND
const char *__restrict s _AND
size_t n)
{
#ifdef _MB_CAPABLE

View File

@ -5,8 +5,8 @@
size_t
_DEFUN (_mbstowcs_r, (reent, pwcs, s, n, state),
struct _reent *r _AND
wchar_t *pwcs _AND
const char *s _AND
wchar_t *__restrict pwcs _AND
const char *__restrict s _AND
size_t n _AND
mbstate_t *state)
{

View File

@ -7,7 +7,7 @@ INDEX
ANSI_SYNOPSIS
#include <stdlib.h>
int mbtowc(wchar_t *<[pwc]>, const char *<[s]>, size_t <[n]>);
int mbtowc(wchar_t *restrict <[pwc]>, const char *restrict <[s]>, size_t <[n]>);
TRAD_SYNOPSIS
#include <stdlib.h>
@ -58,8 +58,8 @@ effects vary with the locale.
int
_DEFUN (mbtowc, (pwc, s, n),
wchar_t *pwc _AND
const char *s _AND
wchar_t *__restrict pwc _AND
const char *__restrict s _AND
size_t n)
{
#ifdef _MB_CAPABLE

View File

@ -19,8 +19,8 @@ int (*__mbtowc) (struct _reent *, wchar_t *, const char *, size_t,
int
_DEFUN (_mbtowc_r, (r, pwc, s, n, state),
struct _reent *r _AND
wchar_t *pwc _AND
const char *s _AND
wchar_t *__restrict pwc _AND
const char *__restrict s _AND
size_t n _AND
mbstate_t *state)
{

View File

@ -11,11 +11,11 @@ INDEX
ANSI_SYNOPSIS
#include <stdlib.h>
double strtod(const char *<[str]>, char **<[tail]>);
float strtof(const char *<[str]>, char **<[tail]>);
double strtod(const char *restrict <[str]>, char **restrict <[tail]>);
float strtof(const char *restrict <[str]>, char **restrict <[tail]>);
double _strtod_r(void *<[reent]>,
const char *<[str]>, char **<[tail]>);
const char *restrict <[str]>, char **restrict <[tail]>);
TRAD_SYNOPSIS
#include <stdlib.h>
@ -236,8 +236,8 @@ _DEFUN (match, (sp, t),
double
_DEFUN (_strtod_r, (ptr, s00, se),
struct _reent *ptr _AND
_CONST char *s00 _AND
char **se)
_CONST char *__restrict s00 _AND
char **__restrict se)
{
#ifdef Avoid_Underflow
int scale;
@ -1255,15 +1255,15 @@ _DEFUN (_strtod_r, (ptr, s00, se),
double
_DEFUN (strtod, (s00, se),
_CONST char *s00 _AND char **se)
_CONST char *__restrict s00 _AND char **__restrict se)
{
return _strtod_r (_REENT, s00, se);
}
float
_DEFUN (strtof, (s00, se),
_CONST char *s00 _AND
char **se)
_CONST char *__restrict s00 _AND
char **__restrict se)
{
double retval = _strtod_r (_REENT, s00, se);
if (isnan (retval))

View File

@ -9,10 +9,10 @@ INDEX
ANSI_SYNOPSIS
#include <stdlib.h>
long strtol(const char *<[s]>, char **<[ptr]>,int <[base]>);
long strtol(const char *restrict <[s]>, char **restrict <[ptr]>,int <[base]>);
long _strtol_r(void *<[reent]>,
const char *<[s]>, char **<[ptr]>,int <[base]>);
const char *restrict <[s]>, char **restrict <[ptr]>,int <[base]>);
TRAD_SYNOPSIS
#include <stdlib.h>
@ -133,8 +133,8 @@ No supporting OS subroutines are required.
long
_DEFUN (_strtol_r, (rptr, nptr, endptr, base),
struct _reent *rptr _AND
_CONST char *nptr _AND
char **endptr _AND
_CONST char *__restrict nptr _AND
char **__restrict endptr _AND
int base)
{
register const unsigned char *s = (const unsigned char *)nptr;
@ -216,8 +216,8 @@ _DEFUN (_strtol_r, (rptr, nptr, endptr, base),
long
_DEFUN (strtol, (s, ptr, base),
_CONST char *s _AND
char **ptr _AND
_CONST char *__restrict s _AND
char **__restrict ptr _AND
int base)
{
return _strtol_r (_REENT, s, ptr, base);

View File

@ -34,7 +34,7 @@ POSSIBILITY OF SUCH DAMAGE.
/* On platforms where long double is as wide as double. */
#ifdef _LDBL_EQ_DBL
long double
strtold (const char *s00, char **se)
strtold (const char *__restrict s00, char **__restrict se)
{
return strtod(s00, se);
}

View File

@ -9,10 +9,10 @@ INDEX
ANSI_SYNOPSIS
#include <stdlib.h>
long long strtoll(const char *<[s]>, char **<[ptr]>,int <[base]>);
long long strtoll(const char *restrict <[s]>, char **restrict <[ptr]>,int <[base]>);
long long _strtoll_r(void *<[reent]>,
const char *<[s]>, char **<[ptr]>,int <[base]>);
const char *restrict <[s]>, char **restrict <[ptr]>,int <[base]>);
TRAD_SYNOPSIS
#include <stdlib.h>
@ -128,8 +128,8 @@ No supporting OS subroutines are required.
long long
_DEFUN (strtoll, (s, ptr, base),
_CONST char *s _AND
char **ptr _AND
_CONST char *__restrict s _AND
char **__restrict ptr _AND
int base)
{
return _strtoll_r (_REENT, s, ptr, base);

View File

@ -58,8 +58,8 @@
long long
_DEFUN (_strtoll_r, (rptr, nptr, endptr, base),
struct _reent *rptr _AND
_CONST char *nptr _AND
char **endptr _AND
_CONST char *__restrict nptr _AND
char **__restrict endptr _AND
int base)
{
register const unsigned char *s = (const unsigned char *)nptr;

View File

@ -9,11 +9,11 @@ INDEX
ANSI_SYNOPSIS
#include <stdlib.h>
unsigned long strtoul(const char *<[s]>, char **<[ptr]>,
unsigned long strtoul(const char *restrict <[s]>, char **restrict <[ptr]>,
int <[base]>);
unsigned long _strtoul_r(void *<[reent]>, const char *<[s]>,
char **<[ptr]>, int <[base]>);
unsigned long _strtoul_r(void *<[reent]>, const char *restrict <[s]>,
char **restrict <[ptr]>, int <[base]>);
TRAD_SYNOPSIS
#include <stdlib.h>
@ -134,8 +134,8 @@ PORTABILITY
unsigned long
_DEFUN (_strtoul_r, (rptr, nptr, endptr, base),
struct _reent *rptr _AND
_CONST char *nptr _AND
char **endptr _AND
_CONST char *__restrict nptr _AND
char **__restrict endptr _AND
int base)
{
register const unsigned char *s = (const unsigned char *)nptr;
@ -196,8 +196,8 @@ _DEFUN (_strtoul_r, (rptr, nptr, endptr, base),
unsigned long
_DEFUN (strtoul, (s, ptr, base),
_CONST char *s _AND
char **ptr _AND
_CONST char *__restrict s _AND
char **__restrict ptr _AND
int base)
{
return _strtoul_r (_REENT, s, ptr, base);

View File

@ -9,11 +9,11 @@ INDEX
ANSI_SYNOPSIS
#include <stdlib.h>
unsigned long long strtoull(const char *<[s]>, char **<[ptr]>,
unsigned long long strtoull(const char *restrict <[s]>, char **restrict <[ptr]>,
int <[base]>);
unsigned long long _strtoull_r(void *<[reent]>, const char *<[s]>,
char **<[ptr]>, int <[base]>);
unsigned long long _strtoull_r(void *<[reent]>, const char *restrict <[s]>,
char **restrict <[ptr]>, int <[base]>);
TRAD_SYNOPSIS
#include <stdlib.h>
@ -129,8 +129,8 @@ PORTABILITY
unsigned long long
_DEFUN (strtoull, (s, ptr, base),
_CONST char *s _AND
char **ptr _AND
_CONST char *__restrict s _AND
char **__restrict ptr _AND
int base)
{
return _strtoull_r (_REENT, s, ptr, base);

View File

@ -59,8 +59,8 @@
unsigned long long
_DEFUN (_strtoull_r, (rptr, nptr, endptr, base),
struct _reent *rptr _AND
_CONST char *nptr _AND
char **endptr _AND
_CONST char *__restrict nptr _AND
char **__restrict endptr _AND
int base)
{
register const unsigned char *s = (const unsigned char *)nptr;

View File

@ -7,7 +7,7 @@ INDEX
ANSI_SYNOPSIS
#include <stdlib.h>
size_t wcstombs(char *<[s]>, const wchar_t *<[pwc]>, size_t <[n]>);
size_t wcstombs(char *restrict <[s]>, const wchar_t *restrict <[pwc]>, size_t <[n]>);
TRAD_SYNOPSIS
#include <stdlib.h>
@ -56,8 +56,8 @@ effects vary with the locale.
size_t
_DEFUN (wcstombs, (s, pwcs, n),
char *s _AND
const wchar_t *pwcs _AND
char *__restrict s _AND
const wchar_t *__restrict pwcs _AND
size_t n)
{
#ifdef _MB_CAPABLE

View File

@ -5,8 +5,8 @@
size_t
_DEFUN (_wcstombs_r, (reent, s, pwcs, n, state),
struct _reent *r _AND
char *s _AND
const wchar_t *pwcs _AND
char *__restrict s _AND
const wchar_t *__restrict pwcs _AND
size_t n _AND
mbstate_t *state)
{