1  /* Deprecated return date and time.  Linux version.
       2     Copyright (C) 1994-2023 Free Software Foundation, Inc.
       3     This file is part of the GNU C Library.
       4  
       5     The GNU C Library is free software; you can redistribute it and/or
       6     modify it under the terms of the GNU Lesser General Public
       7     License as published by the Free Software Foundation; either
       8     version 2.1 of the License, or (at your option) any later version.
       9  
      10     The GNU C Library is distributed in the hope that it will be useful,
      11     but WITHOUT ANY WARRANTY; without even the implied warranty of
      12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13     Lesser General Public License for more details.
      14  
      15     You should have received a copy of the GNU Lesser General Public
      16     License along with the GNU C Library; if not, see
      17     <https://www.gnu.org/licenses/>.  */
      18  
      19  #include <features.h>
      20  #include <sys/timeb.h>
      21  #include <time.h>
      22  #include <errno.h>
      23  
      24  int
      25  __ftime64 (struct __timeb64 *timebuf)
      26  {
      27    struct __timespec64 ts;
      28    __clock_gettime64 (CLOCK_REALTIME, &ts);
      29  
      30    timebuf->time = ts.tv_sec;
      31    timebuf->millitm = ts.tv_nsec / 1000000;
      32    timebuf->timezone = 0;
      33    timebuf->dstflag = 0;
      34    return 0;
      35  }
      36  #if __TIMESIZE != 64
      37  libc_hidden_def (__ftime64)
      38  
      39  int
      40  ftime (struct timeb *timebuf)
      41  {
      42    struct __timeb64 tb64;
      43    __ftime64 (&tb64);
      44    if (! in_time_t_range (tb64.time))
      45      {
      46        __set_errno (EOVERFLOW);
      47        return -1;
      48      }
      49    timebuf->time = tb64.time;
      50    timebuf->millitm = tb64.millitm;
      51    timebuf->timezone = tb64.timezone;
      52    timebuf->dstflag = tb64.dstflag;
      53    return 0;
      54  }
      55  #endif