diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f10972709..8744ac9cc 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2013-11-25 Corinna Vinschen + + Throughout, keep function definitions and declarations in sync with + newlib in terms of C99 "restrict" keyword. + 2013-11-24 Corinna Vinschen * dtable.cc: Include sys/param.h for MAX definition. diff --git a/winsup/cygwin/dir.cc b/winsup/cygwin/dir.cc index fe0babc99..dc6e2a740 100644 --- a/winsup/cygwin/dir.cc +++ b/winsup/cygwin/dir.cc @@ -177,7 +177,7 @@ readdir (DIR *dir) } extern "C" int -readdir_r (DIR *dir, dirent *de, dirent **ode) +readdir_r (DIR *__restrict dir, dirent *__restrict de, dirent **__restrict ode) { int res = readdir_worker (dir, de); if (!res) diff --git a/winsup/cygwin/glob.cc b/winsup/cygwin/glob.cc index 296cd7fbc..be2a6013b 100644 --- a/winsup/cygwin/glob.cc +++ b/winsup/cygwin/glob.cc @@ -186,7 +186,7 @@ static void qprintf(const char *, Char *); #endif int -glob(const char *pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob) +glob(const char *__restrict pattern, int flags, int (*errfunc)(const char *, int), glob_t *__restrict pglob) { const char *patnext; size_t limit; diff --git a/winsup/cygwin/include/cygwin/stat.h b/winsup/cygwin/include/cygwin/stat.h index ed96fafd9..73f3e9310 100644 --- a/winsup/cygwin/include/cygwin/stat.h +++ b/winsup/cygwin/include/cygwin/stat.h @@ -1,6 +1,6 @@ /* cygwin/stat.h - Copyright 2002, 2007, 2010 Red Hat Inc. + Copyright 2002, 2007, 2010, 2013 Red Hat Inc. Written by Corinna Vinschen This file is part of Cygwin. @@ -56,8 +56,10 @@ struct __stat32 #endif extern int fstat64 (int fd, struct stat *buf); -extern int stat64 (const char *file_name, struct stat *buf); -extern int lstat64 (const char *file_name, struct stat *buf); +extern int stat64 (const char *__restrict file_name, + struct stat *__restrict buf); +extern int lstat64 (const char *__restrict file_name, + struct stat *__restrict buf); #endif diff --git a/winsup/cygwin/include/glob.h b/winsup/cygwin/include/glob.h index 35745196b..4ad200fd5 100644 --- a/winsup/cygwin/include/glob.h +++ b/winsup/cygwin/include/glob.h @@ -103,7 +103,7 @@ __BEGIN_DECLS # define DLLEXPORT __declspec(dllimport) #endif -int DLLEXPORT glob (const char *, int, int (*)(const char *, int), glob_t *); +int DLLEXPORT glob (const char __restrict *, int, int (*)(const char *, int), glob_t *__restrict); void DLLEXPORT globfree (glob_t *); int DLLEXPORT glob_pattern_p (const char *, int); __END_DECLS diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys/dirent.h index 027fa8f73..46c34ab5e 100644 --- a/winsup/cygwin/include/sys/dirent.h +++ b/winsup/cygwin/include/sys/dirent.h @@ -65,7 +65,8 @@ typedef struct __DIR DIR *opendir (const char *); DIR *fdopendir (int); struct dirent *readdir (DIR *); -int readdir_r (DIR *, struct dirent *, struct dirent **); +int readdir_r (DIR * __restrict, struct dirent * __restrict, + struct dirent ** __restrict); void rewinddir (DIR *); int closedir (DIR *); diff --git a/winsup/cygwin/libc/strptime.cc b/winsup/cygwin/libc/strptime.cc index ca059842a..eeaab831c 100644 --- a/winsup/cygwin/libc/strptime.cc +++ b/winsup/cygwin/libc/strptime.cc @@ -763,7 +763,8 @@ literal: } char * -strptime (const char *buf, const char *fmt, struct tm *tm) +strptime (const char *__restrict buf, const char *__restrict fmt, + struct tm *__restrict tm) { era_info_t *era_info = NULL; alt_digits_t *alt_digits = NULL; diff --git a/winsup/cygwin/localtime.cc b/winsup/cygwin/localtime.cc index 19eef6759..a5307101e 100644 --- a/winsup/cygwin/localtime.cc +++ b/winsup/cygwin/localtime.cc @@ -1749,7 +1749,7 @@ localsub(const timezone_t sp, const time_t * const timep, const long offset, ** Re-entrant version of localtime. */ extern "C" struct tm * -localtime_r(const time_t *timep, struct tm *tmp) +localtime_r(const time_t *__restrict timep, struct tm *__restrict tmp) { tzset_guard.init ("tzset_guard")->acquire (); tzset_unlocked(); @@ -1820,7 +1820,7 @@ gmtime(const time_t *const timep) */ extern "C" struct tm * -gmtime_r(const time_t * const timep, struct tm *tmp) +gmtime_r(const time_t *__restrict const timep, struct tm *__restrict tmp) { tmp = gmtsub(NULL, timep, 0L, tmp); diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index f6308b634..b2da91846 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -793,7 +793,7 @@ memset (void *s, int c, size_t n) } extern "C" void * -memcpy(void *dest, const void *src, size_t n) +memcpy(void *__restrict dest, const void *__restrict src, size_t n) { RtlCopyMemory (dest, src, n); return dest; diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 2b1e61442..91d847455 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2989,7 +2989,7 @@ symlink_info::set (char *path) /* readlink system call */ extern "C" ssize_t -readlink (const char *path, char *buf, size_t buflen) +readlink (const char *__restrict path, char *__restrict buf, size_t buflen) { if (buflen < 0) { @@ -3413,7 +3413,7 @@ cygwin_conv_to_full_posix_path (const char *path, char *posix_path) /* The realpath function is required by POSIX:2008. */ extern "C" char * -realpath (const char *path, char *resolved) +realpath (const char *__restrict path, char *__restrict resolved) { /* Make sure the right errno is returned if path is NULL. */ if (!path) diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc index 07020649c..94ce82ce5 100644 --- a/winsup/cygwin/strfuncs.cc +++ b/winsup/cygwin/strfuncs.cc @@ -681,7 +681,7 @@ sys_mbstowcs_alloc (wchar_t **dst_p, int type, const char *src, size_t nms) NUL-terminate the destination string (s1). Return pointer to terminating byte in dst string. */ char * __stdcall -strccpy (char *s1, const char **s2, char c) +strccpy (char *__restrict s1, const char **__restrict s2, char c) { while (**s2 && **s2 != c) *s1++ = *((*s2)++); diff --git a/winsup/cygwin/string.h b/winsup/cygwin/string.h index 9426577a6..0a42f60eb 100644 --- a/winsup/cygwin/string.h +++ b/winsup/cygwin/string.h @@ -1,6 +1,6 @@ /* string.h: Extra string defs - Copyright 2001, 2002, 2003, 2007, 2008, 2011, 2012 Red Hat, Inc. + Copyright 2001, 2002, 2003, 2007, 2008, 2011, 2012, 2013 Red Hat, Inc. This file is part of Cygwin. @@ -89,7 +89,8 @@ char * __stdcall cygwin_strupr (char *); #endif /* __INSIDE_CYGWIN__ */ -char *__stdcall strccpy (char *s1, const char **s2, char c); +char *__stdcall strccpy (char *__restrict s1, const char **__restrict s2, + char c); #ifdef __cplusplus } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 0ad68cf82..ec79e57c1 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1885,7 +1885,7 @@ stat_worker (path_conv &pc, struct stat *buf) } extern "C" int -stat64 (const char *name, struct stat *buf) +stat64 (const char *__restrict name, struct stat *__restrict buf) { syscall_printf ("entering"); path_conv pc (name, PC_SYM_FOLLOW | PC_POSIX | PC_KEEP_HANDLE, @@ -1894,7 +1894,8 @@ stat64 (const char *name, struct stat *buf) } extern "C" int -_stat64_r (struct _reent *ptr, const char *name, struct stat *buf) +_stat64_r (struct _reent *__restrict ptr, const char *__restrict name, + struct stat *buf) { int ret; @@ -1908,7 +1909,7 @@ EXPORT_ALIAS (stat64, stat) EXPORT_ALIAS (_stat64_r, _stat_r) #else extern "C" int -stat (const char *name, struct stat *buf) +stat (const char *__restrict name, struct stat *__restrict buf) { struct stat buf64; int ret = stat64 (name, &buf64); @@ -1918,7 +1919,8 @@ stat (const char *name, struct stat *buf) } extern "C" int -_stat_r (struct _reent *ptr, const char *name, struct stat *buf) +_stat_r (struct _reent *__restrict ptr, const char *__restrict name, + struct stat *__restrict buf) { int ret; @@ -1930,7 +1932,7 @@ _stat_r (struct _reent *ptr, const char *name, struct stat *buf) /* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */ extern "C" int -lstat64 (const char *name, struct stat *buf) +lstat64 (const char *__restrict name, struct stat *__restrict buf) { syscall_printf ("entering"); path_conv pc (name, PC_SYM_NOFOLLOW | PC_POSIX | PC_KEEP_HANDLE, @@ -1943,7 +1945,7 @@ EXPORT_ALIAS (lstat64, lstat) #else /* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */ extern "C" int -lstat (const char *name, struct stat *buf) +lstat (const char *__restrict name, struct stat *__restrict buf) { struct stat buf64; int ret = lstat64 (name, &buf64); @@ -4462,7 +4464,8 @@ fchownat (int dirfd, const char *pathname, uid_t uid, gid_t gid, int flags) } extern "C" int -fstatat (int dirfd, const char *pathname, struct stat *st, int flags) +fstatat (int dirfd, const char *__restrict pathname, struct stat *__restrict st, + int flags) { tmp_pathbuf tp; myfault efault; @@ -4592,7 +4595,8 @@ mknodat (int dirfd, const char *pathname, mode_t mode, dev_t dev) } extern "C" ssize_t -readlinkat (int dirfd, const char *pathname, char *buf, size_t bufsize) +readlinkat (int dirfd, const char *__restrict pathname, char *__restrict buf, + size_t bufsize) { tmp_pathbuf tp; myfault efault; diff --git a/winsup/cygwin/timer.cc b/winsup/cygwin/timer.cc index 93b9cb592..5231499fb 100644 --- a/winsup/cygwin/timer.cc +++ b/winsup/cygwin/timer.cc @@ -1,6 +1,6 @@ /* timer.cc - Copyright 2004, 2005, 2006, 2008, 2010, 2011, 2012 Red Hat, Inc. + Copyright 2004, 2005, 2006, 2008, 2010, 2011, 2012, 2013 Red Hat, Inc. This file is part of Cygwin. @@ -295,7 +295,8 @@ timer_gettime (timer_t timerid, struct itimerspec *ovalue) } extern "C" int -timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) +timer_create (clockid_t clock_id, struct sigevent *__restrict evp, + timer_t *__restrict timerid) { myfault efault; if (efault.faulted (EFAULT)) @@ -318,8 +319,9 @@ timer_create (clockid_t clock_id, struct sigevent *evp, timer_t *timerid) } extern "C" int -timer_settime (timer_t timerid, int flags, const struct itimerspec *value, - struct itimerspec *ovalue) +timer_settime (timer_t timerid, int flags, + const struct itimerspec *__restrict value, + struct itimerspec *__restrict ovalue) { timer_tracker *tt = (timer_tracker *) timerid; myfault efault; @@ -374,7 +376,8 @@ fixup_timers_after_fork () extern "C" int -setitimer (int which, const struct itimerval *value, struct itimerval *ovalue) +setitimer (int which, const struct itimerval *__restrict value, + struct itimerval *__restrict ovalue) { int ret; if (which != ITIMER_REAL) diff --git a/winsup/cygwin/times.cc b/winsup/cygwin/times.cc index c9df29116..55157d389 100644 --- a/winsup/cygwin/times.cc +++ b/winsup/cygwin/times.cc @@ -158,7 +158,7 @@ totimeval (struct timeval *dst, PLARGE_INTEGER src, int sub, int flag) /* FIXME: Make thread safe */ extern "C" int -gettimeofday (struct timeval *tv, void *tzvp) +gettimeofday (struct timeval *__restrict tv, void *__restrict tzvp) { struct timezone *tz = (struct timezone *) tzvp; static bool tzflag;