ctime 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <__assert> // all public C++ headers provide the assertion handler
  39. #include <__config>
  40. // <time.h> is not provided by libc++
  41. #if __has_include(<time.h>)
  42. # include <time.h>
  43. # ifdef _LIBCPP_TIME_H
  44. # error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>"
  45. # endif
  46. #endif
  47. #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
  48. # pragma GCC system_header
  49. #endif
  50. _LIBCPP_BEGIN_NAMESPACE_STD
  51. using ::clock_t _LIBCPP_USING_IF_EXISTS;
  52. using ::size_t _LIBCPP_USING_IF_EXISTS;
  53. using ::time_t _LIBCPP_USING_IF_EXISTS;
  54. using ::tm _LIBCPP_USING_IF_EXISTS;
  55. #if _LIBCPP_STD_VER > 14 && __has_attribute(using_if_exists)
  56. using ::timespec _LIBCPP_USING_IF_EXISTS;
  57. #endif
  58. using ::clock _LIBCPP_USING_IF_EXISTS;
  59. using ::difftime _LIBCPP_USING_IF_EXISTS;
  60. using ::mktime _LIBCPP_USING_IF_EXISTS;
  61. using ::time _LIBCPP_USING_IF_EXISTS;
  62. using ::asctime _LIBCPP_USING_IF_EXISTS;
  63. using ::ctime _LIBCPP_USING_IF_EXISTS;
  64. using ::gmtime _LIBCPP_USING_IF_EXISTS;
  65. using ::localtime _LIBCPP_USING_IF_EXISTS;
  66. using ::strftime _LIBCPP_USING_IF_EXISTS;
  67. #if _LIBCPP_STD_VER > 14 && __has_attribute(using_if_exists)
  68. using ::timespec_get _LIBCPP_USING_IF_EXISTS;
  69. #endif
  70. _LIBCPP_END_NAMESPACE_STD
  71. #endif // _LIBCPP_CTIME