-/* We need these to be playing with various stuff. */
-#ifdef TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else /* not TIME_WITH_SYS_TIME_H */
-#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
-#else /* not HAVE_SYS_TIME_H */
-# include <time.h>
-#endif /* HAVE_SYS_TIME_H */
-#endif /* TIME_WITH_SYS_TIME_H */
+/* Testing for __sun is not enough because it's also defined on SunOS. */
+#ifdef __sun
+# ifdef __SVR4
+# define solaris
+# endif
+#endif
+
+#if defined(__INTERIX) && !defined(_ALL_SOURCE)
+# define _ALL_SOURCE
+#endif
+
+/* The "namespace tweaks" below attempt to set a friendly "compilation
+ environment" under popular operating systems. Default compilation
+ environment often means that some functions that are "extensions"
+ are not declared -- `strptime' is one example.
+
+ But non-default environments can expose bugs in the system header
+ files, crippling compilation in _very_ non-obvious ways. Because
+ of that, we define them only on well-tested architectures where we
+ know they will work. */
+
+#undef NAMESPACE_TWEAKS
+
+#ifdef solaris
+# define NAMESPACE_TWEAKS
+#endif
+
+#if defined(__linux__) || defined(__GLIBC__)
+# define NAMESPACE_TWEAKS
+#endif
+
+#ifdef NAMESPACE_TWEAKS
+
+/* Request the "Unix 98 compilation environment". */
+#define _XOPEN_SOURCE 500
+
+#endif /* NAMESPACE_TWEAKS */