Blame gnu/time_r.c

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