No prototype for readdir_r

Joel Sherrill joel.sherrill@oarcorp.com
Wed Nov 20 18:36:00 GMT 2013


Hi

A simple patch to add readir_r() prototypes to
all dirent.h files and __restrict to readdir_r.c

OK to commit or did I miss something?

Thanks.

2013-11-20  Joel Sherrill <joel.sherrill@oarcorp.com>

	* newlib/libc/posix/readdir_r.c: Add restrict keyword.
	* newlib/libc/machine/spu/sys/dirent.h,
	newlib/libc/sys/decstation/sys/dirent.h,
	newlib/libc/sys/linux/sys/dirent.h, newlib/libc/sys/rtems/sys/dirent.h,
	newlib/libc/sys/sparc64/sys/dirent.h, newlib/libc/sys/sun4/sys/dirent.h,
	newlib/libc/sys/sysvi386/sys/dirent.h: Add readdir_r() prototype.


On 11/18/2013 6:15 AM, Corinna Vinschen wrote:
> On Nov 15 13:45, Joel Sherrill wrote:
>> On 11/15/2013 1:41 PM, Craig Howland wrote:
>>> On 11/15/2013 01:49 PM, Joel Sherrill wrote:
>>>> Hi
>>>>
>>>> I noticed that readdir_r() does not have a prototype.
>>>> It should be in dirent.h. I am happy to add it to
>>>> the RTEMS dirent.h but there are other versions of
>>>> this file and
>>>>
>>>> ./libc/include/sys/dirent.h
>>>> ./libc/include/dirent.h
>>>> ./libc/machine/spu/sys/dirent.h
>>>> ./libc/sys/rtems/sys/dirent.h
>>>> ./libc/sys/decstation/sys/dirent.h
>>>> ./libc/sys/sun4/sys/dirent.h
>>>> ./libc/sys/linux/bits/dirent.h
>>>> ./libc/sys/linux/sys/dirent.h
>>>> ./libc/sys/sparc64/sys/dirent.h
>>>> ./libc/sys/sysvi386/sys/dirent.h
>>>>
>>>> I can drop the prototype in those at the same time.
>>>>
>>>> And ... Linux man page shows these guards. What should
>>>> they be on newlib?
>>>>
>>>>      _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _BSD_SOURCE ||
>>>>      _SVID_SOURCE || _POSIX_SOURCE
>>>>
>>>       It probably is not worth bothering with a guard.
>>>       dirent.h is not in the C standard, so there is no gate needed based on 
>>> it.  (Someone could say that with your sample gate that it would be skipped with 
>>> STRICT_ANSI, but from that point of view, dirent.h should not even be included.)
>>>       POSIX says is was added in issue 2, which is so ancient that it seems 
>>> unreasonable to add something now to avoid it for someone trying to use issue 
>>> 1.  (I think that the guard would probably be _POSIX_C_SOURCE >= 199209 to be 
>>> for issue 2, assuming that sys/cdefs.h has been included before the check.)  I 
>>> don't know why GLIBC's test is for 1, instead of 2.
>>
>> So you would lean to just adding it to every dirent.h
>> without a guard? If so, that's really easy. :)
> 
> I agree with Craig.  In theory there's no good reason to omit
> prototypes which are standard for a long time anyway.
> 
> 
> Corinna
> 



-- 
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 --------------
? newlib/libc/libc.info
? newlib/libm/libm.info
Index: newlib/libc/machine/spu/sys/dirent.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/spu/sys/dirent.h,v
retrieving revision 1.2
diff -u -r1.2 dirent.h
--- newlib/libc/machine/spu/sys/dirent.h	16 Jun 2008 18:54:17 -0000	1.2
+++ newlib/libc/machine/spu/sys/dirent.h	20 Nov 2013 18:31:01 -0000
@@ -54,6 +54,8 @@
 DIR *opendir(const char *);
 int closedir(DIR *);
 struct dirent *readdir (DIR *);
+int readdir_r (DIR *__restrict, struct dirent *__restrict,
+              struct dirent **__restrict);
 void rewinddir(DIR *);
 void seekdir(DIR *dir, off_t offset);
 off_t telldir(DIR *dir);
Index: newlib/libc/posix/readdir_r.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/posix/readdir_r.c,v
retrieving revision 1.5
diff -u -r1.5 readdir_r.c
--- newlib/libc/posix/readdir_r.c	19 Nov 2013 11:48:02 -0000	1.5
+++ newlib/libc/posix/readdir_r.c	20 Nov 2013 18:31:01 -0000
@@ -51,9 +51,9 @@
  */
 int
 _DEFUN(readdir_r, (dirp, dp, dpp),
-	register DIR *dirp _AND
-	struct dirent *dp _AND
-	struct dirent **dpp) {
+	register DIR *__restrict dirp _AND
+	struct dirent *__restrict dp _AND
+	struct dirent **__restrict dpp) {
 
 struct dirent *tmpdp;
  
Index: newlib/libc/sys/decstation/sys/dirent.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/decstation/sys/dirent.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 dirent.h
--- newlib/libc/sys/decstation/sys/dirent.h	17 Feb 2000 19:39:49 -0000	1.1.1.1
+++ newlib/libc/sys/decstation/sys/dirent.h	20 Nov 2013 18:31:01 -0000
@@ -25,6 +25,8 @@
 
 DIR *opendir (const char *);
 struct dirent *readdir (DIR *);
+int readdir_r (DIR *__restrict, struct dirent *__restrict,
+               struct dirent **__restrict);
 void rewinddir (DIR *);
 int closedir (DIR *);
 
Index: newlib/libc/sys/linux/sys/dirent.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/linux/sys/dirent.h,v
retrieving revision 1.7
diff -u -r1.7 dirent.h
--- newlib/libc/sys/linux/sys/dirent.h	6 Jul 2010 15:23:27 -0000	1.7
+++ newlib/libc/sys/linux/sys/dirent.h	20 Nov 2013 18:31:02 -0000
@@ -36,6 +36,8 @@
 
 DIR *opendir(const char *);
 struct dirent *readdir(DIR *);
+int readdir_r(DIR *__restrict, struct dirent *__restrict,
+              struct dirent **__restrict);
 void rewinddir(DIR *);
 int closedir(DIR *);
 
Index: newlib/libc/sys/rtems/sys/dirent.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/rtems/sys/dirent.h,v
retrieving revision 1.4
diff -u -r1.4 dirent.h
--- newlib/libc/sys/rtems/sys/dirent.h	26 Jul 2011 04:04:45 -0000	1.4
+++ newlib/libc/sys/rtems/sys/dirent.h	20 Nov 2013 18:31:02 -0000
@@ -26,6 +26,8 @@
 
 DIR *opendir(const char *);
 struct dirent *readdir(DIR *);
+int readdir_r(DIR *__restrict, struct dirent *__restrict,
+              struct dirent **__restrict);
 void rewinddir(DIR *);
 int closedir(DIR *);
 void seekdir(DIR *dir, long loc);
Index: newlib/libc/sys/sparc64/sys/dirent.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sparc64/sys/dirent.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 dirent.h
--- newlib/libc/sys/sparc64/sys/dirent.h	17 Feb 2000 19:39:50 -0000	1.1.1.1
+++ newlib/libc/sys/sparc64/sys/dirent.h	20 Nov 2013 18:31:02 -0000
@@ -21,6 +21,8 @@
 
 DIR *opendir (const char *);
 struct dirent *readdir (DIR *);
+int readdir_r (DIR *__restrict, struct dirent *__restrict,
+               struct dirent **__restrict);
 void rewinddir (DIR *);
 int closedir (DIR *);
 
Index: newlib/libc/sys/sun4/sys/dirent.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sun4/sys/dirent.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 dirent.h
--- newlib/libc/sys/sun4/sys/dirent.h	17 Feb 2000 19:39:50 -0000	1.1.1.1
+++ newlib/libc/sys/sun4/sys/dirent.h	20 Nov 2013 18:31:02 -0000
@@ -23,6 +23,8 @@
 
 DIR *opendir (const char *);
 struct dirent *readdir (DIR *);
+int readdir_r (DIR *__restrict, struct dirent *__restrict,
+              struct dirent **__restrict);
 void rewinddir (DIR *);
 int closedir (DIR *);
 
Index: newlib/libc/sys/sysvi386/sys/dirent.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/sys/sysvi386/sys/dirent.h,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 dirent.h
--- newlib/libc/sys/sysvi386/sys/dirent.h	17 Feb 2000 19:39:51 -0000	1.1.1.1
+++ newlib/libc/sys/sysvi386/sys/dirent.h	20 Nov 2013 18:31:02 -0000
@@ -20,6 +20,8 @@
 
 DIR *opendir (const char *);
 struct dirent *readdir (DIR *);
+int readdir_r (DIR *__restrict, struct dirent *__restrict,
+               struct dirent **__restrict);
 void rewinddir (DIR *);
 int closedir (DIR *);
 


More information about the Newlib mailing list