Blame gl/time_r.c

Packit 549fdc
/* Reentrant time functions like localtime_r.
Packit 549fdc
Packit 549fdc
   Copyright (C) 2003, 2006-2007, 2010-2016 Free Software Foundation, Inc.
Packit 549fdc
Packit 549fdc
   This program is free software; you can redistribute it and/or modify
Packit 549fdc
   it under the terms of the GNU Lesser General Public License as published by
Packit 549fdc
   the Free Software Foundation; either version 2.1, or (at your option)
Packit 549fdc
   any later version.
Packit 549fdc
Packit 549fdc
   This program is distributed in the hope that it will be useful,
Packit 549fdc
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 549fdc
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 549fdc
   GNU Lesser General Public License for more details.
Packit 549fdc
Packit 549fdc
   You should have received a copy of the GNU Lesser General Public License along
Packit 549fdc
   with this program; if not, see <http://www.gnu.org/licenses/>.  */
Packit 549fdc
Packit 549fdc
/* Written by Paul Eggert.  */
Packit 549fdc
Packit 549fdc
#include <config.h>
Packit 549fdc
Packit 549fdc
#include <time.h>
Packit 549fdc
Packit 549fdc
static struct tm *
Packit 549fdc
copy_tm_result (struct tm *dest, struct tm const *src)
Packit 549fdc
{
Packit 549fdc
  if (! src)
Packit 549fdc
    return 0;
Packit 549fdc
  *dest = *src;
Packit 549fdc
  return dest;
Packit 549fdc
}
Packit 549fdc
Packit 549fdc
Packit 549fdc
struct tm *
Packit 549fdc
gmtime_r (time_t const * restrict t, struct tm * restrict tp)
Packit 549fdc
{
Packit 549fdc
  return copy_tm_result (tp, gmtime (t));
Packit 549fdc
}
Packit 549fdc
Packit 549fdc
struct tm *
Packit 549fdc
localtime_r (time_t const * restrict t, struct tm * restrict tp)
Packit 549fdc
{
Packit 549fdc
  return copy_tm_result (tp, localtime (t));
Packit 549fdc
}