+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
_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 *));
_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 */
# 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));
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));
/* 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 */
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>
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
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)
{
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>
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
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)
{
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>
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;
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))
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>
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;
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);
/* 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);
}
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>
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);
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;
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>
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;
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);
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>
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);
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;
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>
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
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)
{