Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: language lawyering: ftello/fseek/pread edition



On Mon, Mar 23, 2015 at 04:56:11PM +0200, Alan Barrett wrote:
> I think the issue is:  After #define _POSIX_C_SOURCE 200112L and #include
> <stdio.h>, fseeko() and ftello() should be declared, but in some unspecified
> version of NetBSD they are not declared.  Similarly, after #define
> _POSIX_C_SOURCE 200112L and #include <unistd.h>, pread() and pwrite() should
> be declared but they are not.
> 
> I agree that fseeko(), ftello(), pread(), and pwrite(), should be declared
> when _POSIX_C_SOURCE >= 200112L.  I see that NetBSD-current fails to do so.
> The obvious addition of "|| (_POSIX_C_SOURCE - 0) >= 200112L" in appropriate
> places in stdio.h and unistd.h should fix it.

Thanks. So if it survives a build, can I commit the attached patch?
 Thomas
Index: stdio.h
===================================================================
RCS file: /cvsroot/src/include/stdio.h,v
retrieving revision 1.95
diff -u -r1.95 stdio.h
--- stdio.h	5 Mar 2015 03:29:02 -0000	1.95
+++ stdio.h	23 Mar 2015 15:55:09 -0000
@@ -370,8 +370,8 @@
 /*
  * X/Open CAE Specification Issue 5 Version 2
  */
-#if (_XOPEN_SOURCE - 0) >= 500 || defined(_LARGEFILE_SOURCE) || \
-    defined(_NETBSD_SOURCE)
+#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 500 || \
+    defined(_LARGEFILE_SOURCE) || defined(_NETBSD_SOURCE)
 #ifndef	off_t
 typedef	__off_t		off_t;
 #define	off_t		__off_t
@@ -381,7 +381,7 @@
 int	 fseeko(FILE *, off_t, int);
 off_t	 ftello(FILE *);
 __END_DECLS
-#endif /* _XOPEN_SOURCE >= 500 || _LARGEFILE_SOURCE || _NETBSD_SOURCE */
+#endif /* (_POSIX_C_SOURCE - 0) >= 200112L || _XOPEN_SOURCE >= 500 || ... */
 
 /*
  * Functions defined in ISO C99.  Still put under _NETBSD_SOURCE due to
Index: unistd.h
===================================================================
RCS file: /cvsroot/src/include/unistd.h,v
retrieving revision 1.144
diff -u -r1.144 unistd.h
--- unistd.h	22 Feb 2015 00:54:46 -0000	1.144
+++ unistd.h	23 Mar 2015 15:55:09 -0000
@@ -294,10 +294,11 @@
 /*
  * X/Open CAE Specification Issue 5 Version 2
  */
-#if (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE)
+#if (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE - 0) >= 500 || \
+    defined(_NETBSD_SOURCE)
 ssize_t	 pread(int, void *, size_t, off_t);
 ssize_t	 pwrite(int, const void *, size_t, off_t);
-#endif
+#endif /* (_POSIX_C_SOURCE - 0) >= 200112L || ... */
 
 /*
  * X/Open Extended API set 2 (a.k.a. C063)


Home | Main Index | Thread Index | Old Index