[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
localtime_r on HP-UX
From: |
Bruno Haible |
Subject: |
localtime_r on HP-UX |
Date: |
Fri, 31 Dec 2010 14:03:54 +0100 |
User-agent: |
KMail/1.9.9 |
On HP-UX 11.11, I'm seeing these errors:
g++ -DHAVE_CONFIG_H -I. -DGNULIB_STRICT_CHECKING=1 -I. -I. -I.. -I./..
-I../gllib -I./../gllib -Wall -MT test-time-c++.o -MD -MP -MF $depbase.Tpo -c
-o test-time-c++.o test-time-c++.cc
In file included from test-time-c++.cc:22:
../gllib/time.h:470: error: 'localtime_r' was not declared in this scope
../gllib/time.h:470: error: invalid type in declaration before ';' token
../gllib/time.h:490: error: 'gmtime_r' was not declared in this scope
../gllib/time.h:490: error: invalid type in declaration before ';' token
*** Error exit code 1
The reason is that localtime_r() and gmtime_r() are not declared in the
system's <time.h> unless _REENTRANT is defined.
This fixes it.
2010-12-31 Bruno Haible <address@hidden>
time_r: Add missing declarations on HP-UX 11.
* lib/time.in.h (localtime_r, gmtime_r): Test HAVE_DECL_LOCALTIME_R
instead of HAVE_LOCALTIME_R.
* m4/time_r.m4 (gl_TIME_R): Test whether localtime_r is declared. Set
HAVE_LOCALTIME_R always.
* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize
HAVE_DECL_LOCALTIME_R, not HAVE_LOCALTIME_R.
* modules/time (Makefile.am): Substitute HAVE_DECL_LOCALTIME_R, not
HAVE_LOCALTIME_R.
* doc/posix-functions/gmtime_r.texi: Document the HP-UX 11 problem.
* doc/posix-functions/localtime_r.texi: Likewise.
--- doc/posix-functions/gmtime_r.texi.orig Fri Dec 31 13:57:04 2010
+++ doc/posix-functions/gmtime_r.texi Fri Dec 31 13:35:38 2010
@@ -12,6 +12,10 @@
This function is missing on some platforms:
mingw.
@item
+This function is not declared unless @code{_REENTRANT} is defined,
+on some platforms:
+HP-UX 11.
address@hidden
Some platforms define a function of this name that is incompatible to POSIX:
HP-UX 10.
@end itemize
--- doc/posix-functions/localtime_r.texi.orig Fri Dec 31 13:57:04 2010
+++ doc/posix-functions/localtime_r.texi Fri Dec 31 13:35:38 2010
@@ -12,6 +12,10 @@
This function is missing on some platforms:
mingw.
@item
+This function is not declared unless @code{_REENTRANT} is defined,
+on some platforms:
+HP-UX 11.
address@hidden
Some platforms define a function of this name that is incompatible to POSIX:
HP-UX 10.
@end itemize
--- lib/time.in.h.orig Fri Dec 31 13:57:04 2010
+++ lib/time.in.h Fri Dec 31 13:40:37 2010
@@ -147,7 +147,7 @@
_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# else
-# if ! @HAVE_LOCALTIME_R@
+# if ! @HAVE_DECL_LOCALTIME_R@
_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result)
_GL_ARG_NONNULL ((1, 2)));
@@ -155,7 +155,9 @@
_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# endif
+# if @HAVE_DECL_LOCALTIME_R@
_GL_CXXALIASWARN (localtime_r);
+# endif
# if @REPLACE_LOCALTIME_R@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef gmtime_r
@@ -167,7 +169,7 @@
_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# else
-# if ! @HAVE_LOCALTIME_R@
+# if ! @HAVE_DECL_LOCALTIME_R@
_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result)
_GL_ARG_NONNULL ((1, 2)));
@@ -175,7 +177,9 @@
_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# endif
+# if @HAVE_DECL_LOCALTIME_R@
_GL_CXXALIASWARN (gmtime_r);
+# endif
# endif
/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
--- m4/time_h.m4.orig Fri Dec 31 13:57:05 2010
+++ m4/time_h.m4 Fri Dec 31 13:41:24 2010
@@ -2,7 +2,7 @@
# Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
-# serial 2
+# serial 3
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -95,7 +95,7 @@
GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
dnl Assume proper GNU behavior unless another module says otherwise.
- HAVE_LOCALTIME_R=1; AC_SUBST([HAVE_LOCALTIME_R])
+ HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R])
HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
--- m4/time_r.m4.orig Fri Dec 31 13:57:05 2010
+++ m4/time_r.m4 Fri Dec 31 13:45:39 2010
@@ -15,8 +15,16 @@
AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
AC_REQUIRE([AC_C_RESTRICT])
+ dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
+ dnl not defined.
+ AC_CHECK_DECLS_ONCE([localtime_r])
+ if test $ac_cv_have_decl_localtime_r = no; then
+ HAVE_DECL_LOCALTIME_R=0
+ fi
+
AC_CHECK_FUNCS_ONCE([localtime_r])
if test $ac_cv_func_localtime_r = yes; then
+ HAVE_LOCALTIME_R=1
AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX
signature],
[gl_cv_time_r_posix],
[AC_COMPILE_IFELSE(
--- modules/time.orig Fri Dec 31 13:57:05 2010
+++ modules/time Fri Dec 31 13:41:01 2010
@@ -33,7 +33,7 @@
-e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \
-e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \
-e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \
- -e 's|@''HAVE_LOCALTIME_R''@|$(HAVE_LOCALTIME_R)|g' \
+ -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
-e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
-e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
-e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- localtime_r on HP-UX,
Bruno Haible <=