blob: 8b2efd7449ca9d0b9423dddc17f15d67865e1e8a [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:161// -*- C++ -*-
2//===---------------------------- ctime -----------------------------------===//
3//
Chandler Carruth57b08b02019-01-19 10:56:404// 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 Hinnant3e519522010-05-11 19:42:167//
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 Clowdeb471f2018-07-31 19:25:0020 TIME_UTC // C++17
Louis Dionne6b77ebd2019-10-23 17:40:1521
Howard Hinnant3e519522010-05-11 19:42:1622namespace std
23{
24
25Types:
26
27 clock_t
28 size_t
29 time_t
30 tm
Marshall Clowdeb471f2018-07-31 19:25:0031 timespec // C++17
Louis Dionne6b77ebd2019-10-23 17:40:1532
Howard Hinnant3e519522010-05-11 19:42:1633clock_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 Clowdeb471f2018-07-31 19:25:0043int timespec_get( struct timespec *ts, int base); // C++17
Howard Hinnant3e519522010-05-11 19:42:1644} // std
45
46*/
47
48#include <__config>
49#include <time.h>
50
Howard Hinnant073458b2011-10-17 20:05:1051#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnant3e519522010-05-11 19:42:1652#pragma GCC system_header
Howard Hinnant073458b2011-10-17 20:05:1053#endif
Howard Hinnant3e519522010-05-11 19:42:1654
Louis Dionne5201b962020-09-02 14:36:4855// 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.
Louis Dionne55714672020-09-02 22:11:2662#if defined(__APPLE__)
63# include <sys/cdefs.h>
64# if defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL)
65# define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED
66# endif
Louis Dionne5201b962020-09-02 14:36:4867#endif
68
Howard Hinnant3e519522010-05-11 19:42:1669_LIBCPP_BEGIN_NAMESPACE_STD
70
Louis Dionnea9c91832021-06-02 14:41:3771using ::clock_t _LIBCPP_USING_IF_EXISTS;
72using ::size_t _LIBCPP_USING_IF_EXISTS;
73using ::time_t _LIBCPP_USING_IF_EXISTS;
74using ::tm _LIBCPP_USING_IF_EXISTS;
Dan Albert19fd9032019-11-18 20:16:4575#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
Louis Dionnea9c91832021-06-02 14:41:3776using ::timespec _LIBCPP_USING_IF_EXISTS;
Marshall Clowdeb471f2018-07-31 19:25:0077#endif
Louis Dionnea9c91832021-06-02 14:41:3778using ::clock _LIBCPP_USING_IF_EXISTS;
79using ::difftime _LIBCPP_USING_IF_EXISTS;
80using ::mktime _LIBCPP_USING_IF_EXISTS;
81using ::time _LIBCPP_USING_IF_EXISTS;
Ed Schoutene0cf3b92015-06-24 08:44:3882#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
Louis Dionnea9c91832021-06-02 14:41:3783using ::asctime _LIBCPP_USING_IF_EXISTS;
84using ::ctime _LIBCPP_USING_IF_EXISTS;
85using ::gmtime _LIBCPP_USING_IF_EXISTS;
86using ::localtime _LIBCPP_USING_IF_EXISTS;
Ed Schoutene0cf3b92015-06-24 08:44:3887#endif
Louis Dionnea9c91832021-06-02 14:41:3788using ::strftime _LIBCPP_USING_IF_EXISTS;
Louis Dionne5201b962020-09-02 14:36:4889#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED)
Louis Dionnea9c91832021-06-02 14:41:3790using ::timespec_get _LIBCPP_USING_IF_EXISTS;
Marshall Clowdeb471f2018-07-31 19:25:0091#endif
Howard Hinnant3e519522010-05-11 19:42:1692
93_LIBCPP_END_NAMESPACE_STD
94
Louis Dionne4cd6ca12021-04-20 16:03:3295#endif // _LIBCPP_CTIME