changeset 9011:0589063a61f3

* lib/time_.h: Port to Solaris 8 with Sun Studio 11, using a method that I hope also handles the double-include problem noted by Bruno Haible in <http://lists.gnu.org/archive/html/bug-gnulib/2007-05/msg00186.html>.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 23 Jun 2007 19:47:10 +0000
parents 03602a916a9a
children 9df95c094ca7
files ChangeLog lib/time_.h
diffstat 2 files changed, 54 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-06-23  Paul Eggert  <eggert@cs.ucla.edu>
+
+	* lib/time_.h: Port to Solaris 8 with Sun Studio 11, using a
+	method that I hope also handles the double-include problem noted
+	by Bruno Haible in
+	<http://lists.gnu.org/archive/html/bug-gnulib/2007-05/msg00186.html>.
+
 2007-06-23  Bruno Haible  <bruno@clisp.org>
 
 	* gnulib-tool (func_emit_lib_Makefile_am, func_emit_tests_Makefile_am):
--- a/lib/time_.h
+++ b/lib/time_.h
@@ -18,100 +18,97 @@
 
 /* Don't get in the way of glibc when it includes time.h merely to
    declare a few standard symbols, rather than to declare all the
-   symbols.  */
-#if defined __need_time_t || defined __need_clock_t || defined __need_timespec
+   symbols.  Also, Solaris 8 <time.h> eventually includes itself
+   recursively; if that is happening, just include the system <time.h>
+   without adding our own declarations.  */
+#if (defined __need_time_t || defined __need_clock_t \
+     || defined __need_timespec \
+     || defined _GL_TIME_H)
 
 # @INCLUDE_NEXT@ @NEXT_TIME_H@
 
 #else
-/* Normal invocation convention.  */
 
-# if ! defined _GL_TIME_H
-
-/* The include_next requires a split double-inclusion guard.  */
-#  @INCLUDE_NEXT@ @NEXT_TIME_H@
+# define _GL_TIME_H
 
-#  if ! defined _GL_TIME_H
-#   define _GL_TIME_H
+# @INCLUDE_NEXT@ @NEXT_TIME_H@
 
-#   ifdef __cplusplus
+# ifdef __cplusplus
 extern "C" {
-#   endif
+# endif
 
 /* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
    Or they define it with the wrong member names or define it in <sys/time.h>
    (e.g., FreeBSD circa 1997).  */
-#   if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
-#    if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
-#     include <sys/time.h>
-#    else
-#     undef timespec
-#     define timespec rpl_timespec
+# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
+#  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+#   include <sys/time.h>
+#  else
+#   undef timespec
+#   define timespec rpl_timespec
 struct timespec
 {
   time_t tv_sec;
   long int tv_nsec;
 };
-#    endif
-#   endif
+#  endif
+# endif
 
 /* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
    return -1 and store the remaining time into RMTP.  See
    <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
-#   if @REPLACE_NANOSLEEP@
-#    define nanosleep rpl_nanosleep
+# if @REPLACE_NANOSLEEP@
+#  define nanosleep rpl_nanosleep
 int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
-#   endif
+# endif
 
 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
    <http://www.opengroup.org/susv3xsh/localtime_r.html> and
    <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
-#   if @REPLACE_LOCALTIME_R@
-#    undef localtime_r
-#    define localtime_r rpl_localtime_r
-#    undef gmtime_r
-#    define gmtime_r rpl_gmtime_r
+# if @REPLACE_LOCALTIME_R@
+#  undef localtime_r
+#  define localtime_r rpl_localtime_r
+#  undef gmtime_r
+#  define gmtime_r rpl_gmtime_r
 struct tm *localtime_r (time_t const *restrict __timer,
 			struct tm *restrict __result);
 struct tm *gmtime_r (time_t const *restrict __timer,
 		     struct tm *restrict __result);
-#   endif
+# endif
 
 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
    the resulting broken-down time into TM.  See
    <http://www.opengroup.org/susv3xsh/strptime.html>.  */
-#   if @REPLACE_STRPTIME@
-#    undef strptime
-#    define strptime rpl_strptime
+# if @REPLACE_STRPTIME@
+#  undef strptime
+#  define strptime rpl_strptime
 char *strptime (char const *restrict __buf, char const *restrict __format,
 		struct tm *restrict __tm);
-#   endif
+# endif
 
 /* Convert TM to a time_t value, assuming UTC.  */
-#   if @REPLACE_TIMEGM@
-#    undef timegm
-#    define timegm rpl_timegm
+# if @REPLACE_TIMEGM@
+#  undef timegm
+#  define timegm rpl_timegm
 time_t timegm (struct tm *__tm);
-#   endif
+# endif
 
 /* Encourage applications to avoid unsafe functions that can overrun
    buffers when given outlandish struct tm values.  Portable
    applications should use strftime (or even sprintf) instead.  */
-#   if GNULIB_PORTCHECK
-#    undef asctime
-#    define asctime eschew_asctime
-#    undef asctime_r
-#    define asctime_r eschew_asctime_r
-#    undef ctime
-#    define ctime eschew_ctime
-#    undef ctime_r
-#    define ctime_r eschew_ctime_r
-#   endif
+# if GNULIB_PORTCHECK
+#  undef asctime
+#  define asctime eschew_asctime
+#  undef asctime_r
+#  define asctime_r eschew_asctime_r
+#  undef ctime
+#  define ctime eschew_ctime
+#  undef ctime_r
+#  define ctime_r eschew_ctime_r
+# endif
 
-#   ifdef __cplusplus
+# ifdef __cplusplus
 }
-#   endif
+# endif
 
-#  endif /* _GL_TIME_H */
-# endif /* _GL_TIME_H */
 #endif