blob: 3aa619daa3581f97a4ae7c584c5172182d29fb08 [file] [log] [blame]
Howard Hinnantc51e1022010-05-11 19:42:16 +00001// -*- C++ -*-
2//===---------------------------- ctime -----------------------------------===//
3//
Chandler Carruthd2012102019-01-19 10:56:40 +00004// 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 Hinnantc51e1022010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_CTIME
11#define _LIBCPP_CTIME
12
13/*
14 ctime synopsis
15
16Macros:
17
18 NULL
19 CLOCKS_PER_SEC
Marshall Clow8e632a92018-07-31 19:25:00 +000020 TIME_UTC // C++17
Louis Dionnefd77e4f2019-10-23 10:40:15 -070021
Howard Hinnantc51e1022010-05-11 19:42:16 +000022namespace std
23{
24
25Types:
26
27 clock_t
28 size_t
29 time_t
30 tm
Marshall Clow8e632a92018-07-31 19:25:00 +000031 timespec // C++17
Louis Dionnefd77e4f2019-10-23 10:40:15 -070032
Howard Hinnantc51e1022010-05-11 19:42:16 +000033clock_t clock();
34double difftime(time_t time1, time_t time0);
35time_t mktime(tm* timeptr);
36time_t time(time_t* timer);
37char* asctime(const tm* timeptr);
38char* ctime(const time_t* timer);
39tm* gmtime(const time_t* timer);
40tm* localtime(const time_t* timer);
41size_t strftime(char* restrict s, size_t maxsize, const char* restrict format,
42 const tm* restrict timeptr);
Marshall Clow8e632a92018-07-31 19:25:00 +000043int timespec_get( struct timespec *ts, int base); // C++17
Howard Hinnantc51e1022010-05-11 19:42:16 +000044} // std
45
46*/
47
48#include <__config>
49#include <time.h>
50
Howard Hinnantaaaa52b2011-10-17 20:05:10 +000051#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantc51e1022010-05-11 19:42:16 +000052#pragma GCC system_header
Howard Hinnantaaaa52b2011-10-17 20:05:10 +000053#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +000054
Louis Dionne74e83072020-09-02 10:36:48 -040055// FIXME:
56// Apple SDKs don't define ::timespec_get unconditionally in C++ mode. This
57// should be fixed in future SDKs, but for the time being we need to avoid
58// trying to use that declaration when the SDK doesn't provide it. Note that
59// we're detecting this here instead of in <__config> because we can't include
60// system headers from <__config>, since it leads to circular module dependencies.
61// This is also meant to be a very temporary workaround until the SDKs are fixed.
62#include <sys/cdefs.h>
63#if defined(__APPLE__) && defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL)
64# define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED
65#endif
66
Howard Hinnantc51e1022010-05-11 19:42:16 +000067_LIBCPP_BEGIN_NAMESPACE_STD
68
69using ::clock_t;
70using ::size_t;
71using ::time_t;
72using ::tm;
Dan Albert1d3cfad2019-11-18 12:16:45 -080073#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
Marshall Clow8e632a92018-07-31 19:25:00 +000074using ::timespec;
75#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +000076using ::clock;
77using ::difftime;
78using ::mktime;
79using ::time;
Ed Schouten137c8632015-06-24 08:44:38 +000080#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Howard Hinnantc51e1022010-05-11 19:42:16 +000081using ::asctime;
82using ::ctime;
83using ::gmtime;
84using ::localtime;
Ed Schouten137c8632015-06-24 08:44:38 +000085#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +000086using ::strftime;
Louis Dionne74e83072020-09-02 10:36:48 -040087#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED)
Marshall Clow8e632a92018-07-31 19:25:00 +000088using ::timespec_get;
89#endif
Howard Hinnantc51e1022010-05-11 19:42:16 +000090
91_LIBCPP_END_NAMESPACE_STD
92
93#endif // _LIBCPP_CTIME