Discussion:
O_NOFOLLOW on NetBSD
(too old to reply)
Bruno Haible
2017-08-14 22:31:06 UTC
Permalink
Raw Message
Gnulib makes use of O_NOFOLLOW in a couple of places. On NetBSD, this definition
(and some others) are only enabled under _NETBSD_SOURCE. See
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/fcntl.h?rev=1.48&content-type=text/x-cvsweb-markup

How about this patch?


2017-08-14 Bruno Haible <***@clisp.org>

extensions: Enable NetBSD specific extensions.
* m4/extensions.m4 (AC_USE_SYSTEM_EXTENSIONS): Define _NETBSD_SOURCE.

diff --git a/m4/extensions.m4 b/m4/extensions.m4
index 0c16bb8..2acbe2e 100644
--- a/m4/extensions.m4
+++ b/m4/extensions.m4
@@ -1,4 +1,4 @@
-# serial 16 -*- Autoconf -*-
+# serial 17 -*- Autoconf -*-
# Enable extensions on systems that normally disable them.

# Copyright (C) 2003, 2006-2017 Free Software Foundation, Inc.
@@ -68,6 +68,10 @@ dnl configure.ac when using autoheader 2.62.
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
+/* Enable NetBSD extensions on NetBSD. */
+#ifndef _NETBSD_SOURCE
+# undef _NETBSD_SOURCE
+#endif
/* Enable OpenBSD extensions on NetBSD. */
#ifndef _OPENBSD_SOURCE
# undef _OPENBSD_SOURCE
Paul Eggert
2017-08-14 23:46:27 UTC
Permalink
Raw Message
Post by Bruno Haible
Gnulib makes use of O_NOFOLLOW in a couple of places. On NetBSD, this definition
(and some others) are only enabled under _NETBSD_SOURCE. See
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/fcntl.h?rev=1.48&content-type=text/x-cvsweb-markup
https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/sys/featuretest.h

says that defining _NETBSD_SOURCE should be helpful only if _ANSI_SOURCE,
_POSIX_SOURCE, _POSIX_C_SOURCE, or _XOPEN_SOURCE is defined. I suppose it
shouldn't hurt to define _NETBSD_SOURCE, to handle these (presumably rare)
configurations.
Bruno Haible
2017-08-15 12:51:58 UTC
Permalink
Raw Message
Post by Paul Eggert
https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/sys/featuretest.h
says that defining _NETBSD_SOURCE should be helpful only if _ANSI_SOURCE,
_POSIX_SOURCE, _POSIX_C_SOURCE, or _XOPEN_SOURCE is defined. I suppose it
shouldn't hurt to define _NETBSD_SOURCE, to handle these (presumably rare)
configurations.
Yes, I agree. Our 'extensions' module does not define any of
_ANSI_SOURCE, _POSIX_SOURCE, _POSIX_C_SOURCE, or _XOPEN_SOURCE on NetBSD
(I checked it with NetBSD 7.0), therefore with the default CFLAGS and CPPFLAGS
this patch is a no-op. But when someone uses -D_XOPEN_SOURCE=500 or something
like that, gnulib would not operate properly without -D_NETBSD_SOURCE:
configure produces wrong findings for REPLACE_FCNTL, REPLACE_FSTATAT,
REPLACE_DUPLOCALE, REPLACE_RENAMEAT, HAVE_COPYSIGN, REPLACE_SYMLINKAT,
REPLACE_LINKAT, REPLACE_FCHOWNAT, REPLACE_UNSETENV, REPLACE_PTSNAME_R,
and so on.


2017-08-15 Bruno Haible <***@clisp.org>

extensions: Enable NetBSD specific extensions.
* m4/extensions.m4 (AC_USE_SYSTEM_EXTENSIONS): Define _NETBSD_SOURCE.

diff --git a/m4/extensions.m4 b/m4/extensions.m4
index 0c16bb8..f854338 100644
--- a/m4/extensions.m4
+++ b/m4/extensions.m4
@@ -1,4 +1,4 @@
-# serial 16 -*- Autoconf -*-
+# serial 17 -*- Autoconf -*-
# Enable extensions on systems that normally disable them.

# Copyright (C) 2003, 2006-2017 Free Software Foundation, Inc.
@@ -68,6 +68,10 @@ dnl configure.ac when using autoheader 2.62.
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
+/* Enable NetBSD extensions on NetBSD. */
+#ifndef _NETBSD_SOURCE
+# undef _NETBSD_SOURCE
+#endif
/* Enable OpenBSD extensions on NetBSD. */
#ifndef _OPENBSD_SOURCE
# undef _OPENBSD_SOURCE
@@ -132,6 +136,7 @@ dnl configure.ac when using autoheader 2.62.
AC_DEFINE([_ALL_SOURCE])
AC_DEFINE([_DARWIN_C_SOURCE])
AC_DEFINE([_GNU_SOURCE])
+ AC_DEFINE([_NETBSD_SOURCE])
AC_DEFINE([_OPENBSD_SOURCE])
AC_DEFINE([_POSIX_PTHREAD_SEMANTICS])
AC_DEFINE([__STDC_WANT_IEC_60559_ATTRIBS_EXT__])

Loading...