Blame lib/time_r.c

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