Blame lib/time_r.c

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