Patch - Add restrict to unistd.h

Joel Sherrill joel.sherrill@oarcorp.com
Fri Nov 22 21:03:00 GMT 2013


Hi

Another patch in the add restrict series from Google
Code-In students.

FWIW readlinkat() is what was wrapped in a CYGWIN
ifdef which made me wonder why and send the other
email.

OK to commit?

2013-11-22  Chirayu Desai  <chirayudesai1@gmail.com>

        * libc/include/sys/unistd.h (readlink): Add restrict keyword.
        (readlinkat): Ditto.
        (swab): Ditto.
        * libc/sys/rdos/readlink.c (readlink): Ditto.
        * libc/string/swab.c (swab): Ditto.


-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill@OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985
-------------- next part --------------
Index: libc/include/sys/unistd.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/unistd.h,v
retrieving revision 1.84
diff -u -r1.84 unistd.h
--- libc/include/sys/unistd.h	18 Nov 2013 10:04:56 -0000	1.84
+++ libc/include/sys/unistd.h	22 Nov 2013 20:58:01 -0000
@@ -175,7 +175,7 @@
 void	_EXFUN(setusershell, (void));
 #endif
 unsigned _EXFUN(sleep, (unsigned int __seconds ));
-void    _EXFUN(swab, (const void *, void *, ssize_t));
+void    _EXFUN(swab, (const void *__restrict, void *__restrict, ssize_t));
 long    _EXFUN(sysconf, (int __name ));
 pid_t   _EXFUN(tcgetpgrp, (int __fildes ));
 int     _EXFUN(tcsetpgrp, (int __fildes, pid_t __pgrp_id ));
@@ -244,9 +244,11 @@
 void    _EXFUN(sync, (void));
 #endif
 
-ssize_t _EXFUN(readlink, (const char *__path, char *__buf, size_t __buflen));
+ssize_t _EXFUN(readlink, (const char *__restrict __path,
+                          char *__restrict __buf, size_t __buflen));
 #if defined(__CYGWIN__)
-ssize_t	_EXFUN(readlinkat, (int __dirfd1, const char *__path, char *__buf, size_t __buflen));
+ssize_t        _EXFUN(readlinkat, (int __dirfd1, const char *__restrict __path,
+                            char *__restrict __buf, size_t __buflen));
 #endif
 int     _EXFUN(symlink, (const char *__name1, const char *__name2));
 #if defined(__CYGWIN__)
Index: libc/sys/rdos/readlink.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/rdos/readlink.c,v
retrieving revision 1.2
diff -u -r1.2 readlink.c
--- libc/sys/rdos/readlink.c	21 Nov 2013 19:27:17 -0000	1.2
+++ libc/sys/rdos/readlink.c	22 Nov 2013 20:58:01 -0000
@@ -4,7 +4,7 @@
 #include <errno.h>
 #include <sys/types.h>
 
-int readlink(const char *path, char *buf, size_t bufsize)
+int readlink(const char *__restrict path, char *__restrict buf, size_t bufsize)
 {
   errno = ENOSYS;
   return -1;


More information about the Newlib mailing list