ctime 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // -*- C++ -*-
  2. //===----------------------------------------------------------------------===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef _LIBCPP_CTIME
  10. #define _LIBCPP_CTIME
  11. /*
  12. ctime synopsis
  13. Macros:
  14. NULL
  15. CLOCKS_PER_SEC
  16. TIME_UTC // C++17
  17. namespace std
  18. {
  19. Types:
  20. clock_t
  21. size_t
  22. time_t
  23. tm
  24. timespec // C++17
  25. clock_t clock();
  26. double difftime(time_t time1, time_t time0);
  27. time_t mktime(tm* timeptr);
  28. time_t time(time_t* timer);
  29. char* asctime(const tm* timeptr);
  30. char* ctime(const time_t* timer);
  31. tm* gmtime(const time_t* timer);
  32. tm* localtime(const time_t* timer);
  33. size_t strftime(char* restrict s, size_t maxsize, const char* restrict format,
  34. const tm* restrict timeptr);
  35. int timespec_get( struct timespec *ts, int base); // C++17
  36. } // std
  37. */
  38. #include <__config>
  39. // <time.h> is not provided by libc++
  40. #if __has_include(<time.h>)
  41. # include <time.h>
  42. # ifdef _LIBCPP_TIME_H
  43. # error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>"
  44. # endif
  45. #endif
  46. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  47. # pragma GCC system_header
  48. #endif
  49. _LIBCPP_BEGIN_NAMESPACE_STD
  50. using ::clock_t _LIBCPP_USING_IF_EXISTS;
  51. using ::size_t _LIBCPP_USING_IF_EXISTS;
  52. using ::time_t _LIBCPP_USING_IF_EXISTS;
  53. using ::tm _LIBCPP_USING_IF_EXISTS;
  54. #if _LIBCPP_STD_VER >= 17 && __has_attribute(using_if_exists)
  55. using ::timespec _LIBCPP_USING_IF_EXISTS;
  56. #endif
  57. using ::clock _LIBCPP_USING_IF_EXISTS;
  58. using ::difftime _LIBCPP_USING_IF_EXISTS;
  59. using ::mktime _LIBCPP_USING_IF_EXISTS;
  60. using ::time _LIBCPP_USING_IF_EXISTS;
  61. using ::asctime _LIBCPP_USING_IF_EXISTS;
  62. using ::ctime _LIBCPP_USING_IF_EXISTS;
  63. using ::gmtime _LIBCPP_USING_IF_EXISTS;
  64. using ::localtime _LIBCPP_USING_IF_EXISTS;
  65. using ::strftime _LIBCPP_USING_IF_EXISTS;
  66. #if _LIBCPP_STD_VER >= 17 && __has_attribute(using_if_exists)
  67. using ::timespec_get _LIBCPP_USING_IF_EXISTS;
  68. #endif
  69. _LIBCPP_END_NAMESPACE_STD
  70. #endif // _LIBCPP_CTIME