From d90f751e2a857949f6eca74876dc0921bffa01d9 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 23 Jun 2007 19:47:10 +0000 Subject: [PATCH] * 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 . --- ChangeLog | 7 ++++ lib/time_.h | 99 ++++++++++++++++++++++++++--------------------------- 2 files changed, 55 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index fa6defb9ae..d2b371259c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2007-06-23 Paul Eggert + + * 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 + . + 2007-06-23 Bruno Haible * gnulib-tool (func_emit_lib_Makefile_am, func_emit_tests_Makefile_am): diff --git a/lib/time_.h b/lib/time_.h index efc3d3b8d6..4d5cab8daf 100644 --- 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 eventually includes itself + recursively; if that is happening, just include the system + 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 +# define _GL_TIME_H -/* The include_next requires a split double-inclusion guard. */ -# @INCLUDE_NEXT@ @NEXT_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 (e.g., FreeBSD circa 1997). */ -# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ -# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ -# include -# else -# undef timespec -# define timespec rpl_timespec +# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@ +# if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@ +# include +# 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 . */ -# 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 and . */ -# 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 . */ -# 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 - -# ifdef __cplusplus +# 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 } -# endif +# endif -# endif /* _GL_TIME_H */ -# endif /* _GL_TIME_H */ #endif -- 2.30.2