pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:1:   /*   || 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"   #include "interpret.h"   #include "svalue.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"   #include "pike_error.h"
pike.git/src/builtin_functions.c:4813: Inside #if defined(HAVE_LOCALTIME) || defined(HAVE_GMTIME)
      push_text("wday");    push_int(tm->tm_wday);    push_text("yday");    push_int(tm->tm_yday);    push_text("isdst");    push_int(tm->tm_isdst);   }   #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.    *!    *! This function works like @[localtime()] but the result is    *! not adjusted for the local time zone.    *!    *! @seealso    *! @[localtime()], @[time()], @[ctime()], @[mktime()]    */   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;       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);    encode_struct_tm(tm);       push_text("timezone");    push_int(0);    f_aggregate_mapping(20);   }   #endif