ctime_r.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /* Return in BUF representation of time T in form of asctime
  2. Copyright (C) 1996-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
  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. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <http://www.gnu.org/licenses/>. */
  16. #include <time.h>
  17. /* Return a string as returned by asctime which is the representation
  18. of *T in that form. Reentrant version. */
  19. char *
  20. __ctime64_r (const __time64_t *t, char *buf)
  21. {
  22. struct tm tm;
  23. return __asctime_r (__localtime64_r (t, &tm), buf);
  24. }
  25. /* Provide a 32-bit variant if needed. */
  26. #if __TIMESIZE != 64
  27. libc_hidden_def (__ctime64_r)
  28. char *
  29. ctime_r (const time_t *t, char *buf)
  30. {
  31. __time64_t t64 = *t;
  32. return __ctime64_r (&t64, buf);
  33. }
  34. #endif