Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tools/compat Clarify the NetBSD-specific and Linux-specific ...
details: https://anonhg.NetBSD.org/src/rev/fdeac246b5ce
branches: trunk
changeset: 328834:fdeac246b5ce
user: apb <apb%NetBSD.org@localhost>
date: Sat Apr 19 19:01:08 2014 +0000
description:
Clarify the NetBSD-specific and Linux-specific code at the top of
compat_defs.h:
* Explain why _NETBSD_SOURCE should not be defined on NetBSD.
* Move NetBSD-specific block to the top of the file.
* Improve comment about Linux <feature.h>.
* Move #undef _POSIX_SOURCE and #undef _POSIX_C_SOURCE to the
Linux-specific block instead of a place that would affect all
non-NetBSD platforms. This makes the code match the comment.
This will need to be re-visited if other platforms also need
#undef _POSIX_SOURCE or #undef _POSIX_C_SOURCE. At present, I suspect
that they are needed only for Linux.
diffstat:
tools/compat/compat_defs.h | 34 ++++++++++++++++++----------------
1 files changed, 18 insertions(+), 16 deletions(-)
diffs (54 lines):
diff -r 4b2d1636e494 -r fdeac246b5ce tools/compat/compat_defs.h
--- a/tools/compat/compat_defs.h Sat Apr 19 16:43:08 2014 +0000
+++ b/tools/compat/compat_defs.h Sat Apr 19 19:01:08 2014 +0000
@@ -1,32 +1,34 @@
-/* $NetBSD: compat_defs.h,v 1.95 2014/01/09 16:08:46 apb Exp $ */
+/* $NetBSD: compat_defs.h,v 1.96 2014/04/19 19:01:08 apb Exp $ */
#ifndef __NETBSD_COMPAT_DEFS_H__
#define __NETBSD_COMPAT_DEFS_H__
-
-/* Work around some complete brain damage. */
/*
- * Linux: <features.h> turns on _POSIX_SOURCE by default, even though the
- * program (not the OS) should do that. Preload <features.h> to keep any
- * of this crap from being pulled in, and undefine _POSIX_SOURCE.
+ * On NetBSD, ensure that _NETBSD_SOURCE does not get defined, so that
+ * accidental attempts to use NetBSD-specific features instead of more
+ * portable features is likely to be noticed when the tools are built
+ * on NetBSD. Define enough other feature test macros to expose the
+ * features we need.
*/
-
-#if defined(__linux__) && HAVE_FEATURES_H
-#include <features.h>
-#define __USE_ISOC99 1
-#endif
-
-/* So _NETBSD_SOURCE doesn't end up defined. Define enough to pull in standard
- defs. Other platforms may need similiar defines. */
#ifdef __NetBSD__
#define _ISOC99_SOURCE
#define _POSIX_SOURCE 1
#define _POSIX_C_SOURCE 200112L
#define _XOPEN_SOURCE 600
-#else
+#endif /* __NetBSD__ */
+
+/*
+ * Linux: <features.h> turns on _POSIX_SOURCE by default, even though the
+ * program (not the OS) should do that. Preload <features.h> and
+ * then override some of the feature test macros.
+ */
+
+#if defined(__linux__) && HAVE_FEATURES_H
+#include <features.h>
#undef _POSIX_SOURCE
#undef _POSIX_C_SOURCE
-#endif
+#define __USE_ISOC99 1
+#endif /* __linux__ && HAVE_FEATURES_H */
/* System headers needed for (re)definitions below. */
Home |
Main Index |
Thread Index |
Old Index