Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 | [diff] [blame] | 1 | // -*- C++ -*- |
Louis Dionne | eb8650a | 2021-11-17 21:25:01 | [diff] [blame] | 2 | //===----------------------------------------------------------------------===// |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 | [diff] [blame] | 3 | // |
Chandler Carruth | 57b08b0 | 2019-01-19 10:56:40 | [diff] [blame] | 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 |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef _LIBCPP_CTIME |
| 11 | #define _LIBCPP_CTIME |
| 12 | |
| 13 | /* |
| 14 | ctime synopsis |
| 15 | |
| 16 | Macros: |
| 17 | |
| 18 | NULL |
| 19 | CLOCKS_PER_SEC |
Marshall Clow | deb471f | 2018-07-31 19:25:00 | [diff] [blame] | 20 | TIME_UTC // C++17 |
Louis Dionne | 6b77ebd | 2019-10-23 17:40:15 | [diff] [blame] | 21 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 | [diff] [blame] | 22 | namespace std |
| 23 | { |
| 24 | |
| 25 | Types: |
| 26 | |
| 27 | clock_t |
| 28 | size_t |
| 29 | time_t |
| 30 | tm |
Marshall Clow | deb471f | 2018-07-31 19:25:00 | [diff] [blame] | 31 | timespec // C++17 |
Louis Dionne | 6b77ebd | 2019-10-23 17:40:15 | [diff] [blame] | 32 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 | [diff] [blame] | 33 | clock_t clock(); |
| 34 | double difftime(time_t time1, time_t time0); |
| 35 | time_t mktime(tm* timeptr); |
| 36 | time_t time(time_t* timer); |
| 37 | char* asctime(const tm* timeptr); |
| 38 | char* ctime(const time_t* timer); |
| 39 | tm* gmtime(const time_t* timer); |
| 40 | tm* localtime(const time_t* timer); |
| 41 | size_t strftime(char* restrict s, size_t maxsize, const char* restrict format, |
| 42 | const tm* restrict timeptr); |
Marshall Clow | deb471f | 2018-07-31 19:25:00 | [diff] [blame] | 43 | int timespec_get( struct timespec *ts, int base); // C++17 |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 | [diff] [blame] | 44 | } // std |
| 45 | |
| 46 | */ |
| 47 | |
Nikolas Klauser | b9a2658 | 2024-12-21 12:01:48 | [diff] [blame] | 48 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
| 49 | # include <__cxx03/ctime> |
| 50 | #else |
Nikolas Klauser | c166a9c | 2024-12-10 15:02:12 | [diff] [blame] | 51 | # include <__config> |
| 52 | # include <__cstddef/size_t.h> |
Louis Dionne | 647ddc0 | 2022-11-22 18:42:33 | [diff] [blame] | 53 | |
| 54 | // <time.h> is not provided by libc++ |
Nikolas Klauser | c166a9c | 2024-12-10 15:02:12 | [diff] [blame] | 55 | # if __has_include(<time.h>) |
| 56 | # include <time.h> |
| 57 | # ifdef _LIBCPP_TIME_H |
| 58 | # error "If libc++ starts defining <time.h>, the __has_include check should move to libc++'s <time.h>" |
| 59 | # endif |
Louis Dionne | 647ddc0 | 2022-11-22 18:42:33 | [diff] [blame] | 60 | # endif |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 | [diff] [blame] | 61 | |
Nikolas Klauser | c166a9c | 2024-12-10 15:02:12 | [diff] [blame] | 62 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
| 63 | # pragma GCC system_header |
| 64 | # endif |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 | [diff] [blame] | 65 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 | [diff] [blame] | 66 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 67 | |
Louis Dionne | a9c9183 | 2021-06-02 14:41:37 | [diff] [blame] | 68 | using ::clock_t _LIBCPP_USING_IF_EXISTS; |
Louis Dionne | a9c9183 | 2021-06-02 14:41:37 | [diff] [blame] | 69 | using ::time_t _LIBCPP_USING_IF_EXISTS; |
| 70 | using ::tm _LIBCPP_USING_IF_EXISTS; |
Nikolas Klauser | c166a9c | 2024-12-10 15:02:12 | [diff] [blame] | 71 | # if _LIBCPP_STD_VER >= 17 |
Louis Dionne | a9c9183 | 2021-06-02 14:41:37 | [diff] [blame] | 72 | using ::timespec _LIBCPP_USING_IF_EXISTS; |
Nikolas Klauser | c166a9c | 2024-12-10 15:02:12 | [diff] [blame] | 73 | # endif |
Louis Dionne | a9c9183 | 2021-06-02 14:41:37 | [diff] [blame] | 74 | using ::clock _LIBCPP_USING_IF_EXISTS; |
| 75 | using ::difftime _LIBCPP_USING_IF_EXISTS; |
| 76 | using ::mktime _LIBCPP_USING_IF_EXISTS; |
| 77 | using ::time _LIBCPP_USING_IF_EXISTS; |
Louis Dionne | a9c9183 | 2021-06-02 14:41:37 | [diff] [blame] | 78 | using ::asctime _LIBCPP_USING_IF_EXISTS; |
| 79 | using ::ctime _LIBCPP_USING_IF_EXISTS; |
| 80 | using ::gmtime _LIBCPP_USING_IF_EXISTS; |
| 81 | using ::localtime _LIBCPP_USING_IF_EXISTS; |
Louis Dionne | a9c9183 | 2021-06-02 14:41:37 | [diff] [blame] | 82 | using ::strftime _LIBCPP_USING_IF_EXISTS; |
Nikolas Klauser | c166a9c | 2024-12-10 15:02:12 | [diff] [blame] | 83 | # if _LIBCPP_STD_VER >= 17 |
Louis Dionne | a9c9183 | 2021-06-02 14:41:37 | [diff] [blame] | 84 | using ::timespec_get _LIBCPP_USING_IF_EXISTS; |
Nikolas Klauser | c166a9c | 2024-12-10 15:02:12 | [diff] [blame] | 85 | # endif |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 | [diff] [blame] | 86 | |
| 87 | _LIBCPP_END_NAMESPACE_STD |
| 88 | |
Nikolas Klauser | b9a2658 | 2024-12-21 12:01:48 | [diff] [blame] | 89 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
Nikolas Klauser | c166a9c | 2024-12-10 15:02:12 | [diff] [blame] | 90 | |
Louis Dionne | 4cd6ca1 | 2021-04-20 16:03:32 | [diff] [blame] | 91 | #endif // _LIBCPP_CTIME |