2006-07-02
2006-07-02 00:00:06 by Martin Stjernholm <mast@lysator.liu.se>
-
1bf4198e11f8d62effdc8b0115fcca22000731d4
(14 lines)
(+12/-2)
[
Show
| Annotate
]
Branch: 7.9
Use thread safe variant of gmtime(3) if available.
Rev: src/builtin_functions.c:1.618
Rev: src/configure.in:1.967
2:
|| This file is part of Pike. For copyright information see COPYRIGHT.
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING
|| for more information.
- || $Id: builtin_functions.c,v 1.617 2006/03/25 12:43:27 grubba Exp $
+ || $Id: builtin_functions.c,v 1.618 2006/07/02 00:00:06 mast Exp $
*/
#include "global.h"
4820:
}
#endif
- #ifdef HAVE_GMTIME
+ #if defined (HAVE_GMTIME) || defined (HAVE_GMTIME_R) || defined (HAVE_GMTIME_S)
/*! @decl mapping(string:int) gmtime(int timestamp)
*!
*! Convert seconds since 00:00:00 UTC, Jan 1, 1970 into components.
4833: Inside #if defined(HAVE_GMTIME)
*/
PMOD_EXPORT void f_gmtime(INT32 args)
{
+ #if defined (HAVE_GMTIME_R) || defined (HAVE_GMTIME_S)
+ struct tm tm_s;
+ #endif
struct tm *tm;
INT_TYPE tt;
time_t t;
4840: Inside #if defined(HAVE_GMTIME)
get_all_args("gmtime", args, "%i", &tt);
t = tt;
+ #ifdef HAVE_GMTIME_R
+ tm = gmtime_r (&t, &tm_s);
+ #elif defined (HAVE_GMTIME_S)
+ if (!gmtime_s (&tm_s, &t)) tm = &tm_s;
+ #else
tm = gmtime(&t);
-
+ #endif
if (!tm) Pike_error ("gmtime() on this system cannot handle "
"the timestamp %ld.\n", (long) t);
pop_n_elems(args);