Blame lib/time_r.c

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