xref: /freebsd/contrib/llvm-project/libcxx/include/ctime (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
10b57cec5SDimitry Andric// -*- C++ -*-
2*349cc55cSDimitry Andric//===----------------------------------------------------------------------===//
30b57cec5SDimitry Andric//
40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information.
60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
70b57cec5SDimitry Andric//
80b57cec5SDimitry Andric//===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric
100b57cec5SDimitry Andric#ifndef _LIBCPP_CTIME
110b57cec5SDimitry Andric#define _LIBCPP_CTIME
120b57cec5SDimitry Andric
130b57cec5SDimitry Andric/*
140b57cec5SDimitry Andric    ctime synopsis
150b57cec5SDimitry Andric
160b57cec5SDimitry AndricMacros:
170b57cec5SDimitry Andric
180b57cec5SDimitry Andric    NULL
190b57cec5SDimitry Andric    CLOCKS_PER_SEC
200b57cec5SDimitry Andric    TIME_UTC // C++17
210b57cec5SDimitry Andric
220b57cec5SDimitry Andricnamespace std
230b57cec5SDimitry Andric{
240b57cec5SDimitry Andric
250b57cec5SDimitry AndricTypes:
260b57cec5SDimitry Andric
270b57cec5SDimitry Andric    clock_t
280b57cec5SDimitry Andric    size_t
290b57cec5SDimitry Andric    time_t
300b57cec5SDimitry Andric    tm
310b57cec5SDimitry Andric    timespec // C++17
320b57cec5SDimitry Andric
330b57cec5SDimitry Andricclock_t clock();
340b57cec5SDimitry Andricdouble difftime(time_t time1, time_t time0);
350b57cec5SDimitry Andrictime_t mktime(tm* timeptr);
360b57cec5SDimitry Andrictime_t time(time_t* timer);
370b57cec5SDimitry Andricchar* asctime(const tm* timeptr);
380b57cec5SDimitry Andricchar* ctime(const time_t* timer);
390b57cec5SDimitry Andrictm*    gmtime(const time_t* timer);
400b57cec5SDimitry Andrictm* localtime(const time_t* timer);
410b57cec5SDimitry Andricsize_t strftime(char* restrict s, size_t maxsize, const char* restrict format,
420b57cec5SDimitry Andric                const tm* restrict timeptr);
430b57cec5SDimitry Andricint timespec_get( struct timespec *ts, int base); // C++17
440b57cec5SDimitry Andric}  // std
450b57cec5SDimitry Andric
460b57cec5SDimitry Andric*/
470b57cec5SDimitry Andric
480b57cec5SDimitry Andric#include <__config>
490b57cec5SDimitry Andric#include <time.h>
500b57cec5SDimitry Andric
510b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
520b57cec5SDimitry Andric#pragma GCC system_header
530b57cec5SDimitry Andric#endif
540b57cec5SDimitry Andric
55e8d8bef9SDimitry Andric// FIXME:
56e8d8bef9SDimitry Andric// Apple SDKs don't define ::timespec_get unconditionally in C++ mode. This
57e8d8bef9SDimitry Andric// should be fixed in future SDKs, but for the time being we need to avoid
58e8d8bef9SDimitry Andric// trying to use that declaration when the SDK doesn't provide it. Note that
59e8d8bef9SDimitry Andric// we're detecting this here instead of in <__config> because we can't include
60e8d8bef9SDimitry Andric// system headers from <__config>, since it leads to circular module dependencies.
61e8d8bef9SDimitry Andric// This is also meant to be a very temporary workaround until the SDKs are fixed.
626e75b2fbSDimitry Andric#if defined(__APPLE__) && !__has_attribute(using_if_exists)
63e8d8bef9SDimitry Andric#   include <sys/cdefs.h>
64e8d8bef9SDimitry Andric#   if defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL)
65e8d8bef9SDimitry Andric#       define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED
66e8d8bef9SDimitry Andric#   endif
67e8d8bef9SDimitry Andric#endif
68e8d8bef9SDimitry Andric
690b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD
700b57cec5SDimitry Andric
71fe6060f1SDimitry Andricusing ::clock_t _LIBCPP_USING_IF_EXISTS;
72fe6060f1SDimitry Andricusing ::size_t _LIBCPP_USING_IF_EXISTS;
73fe6060f1SDimitry Andricusing ::time_t _LIBCPP_USING_IF_EXISTS;
74fe6060f1SDimitry Andricusing ::tm _LIBCPP_USING_IF_EXISTS;
75480093f4SDimitry Andric#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
76fe6060f1SDimitry Andricusing ::timespec _LIBCPP_USING_IF_EXISTS;
770b57cec5SDimitry Andric#endif
78fe6060f1SDimitry Andricusing ::clock _LIBCPP_USING_IF_EXISTS;
79fe6060f1SDimitry Andricusing ::difftime _LIBCPP_USING_IF_EXISTS;
80fe6060f1SDimitry Andricusing ::mktime _LIBCPP_USING_IF_EXISTS;
81fe6060f1SDimitry Andricusing ::time _LIBCPP_USING_IF_EXISTS;
82fe6060f1SDimitry Andricusing ::asctime _LIBCPP_USING_IF_EXISTS;
83fe6060f1SDimitry Andricusing ::ctime _LIBCPP_USING_IF_EXISTS;
84fe6060f1SDimitry Andricusing ::gmtime _LIBCPP_USING_IF_EXISTS;
85fe6060f1SDimitry Andricusing ::localtime _LIBCPP_USING_IF_EXISTS;
86fe6060f1SDimitry Andricusing ::strftime _LIBCPP_USING_IF_EXISTS;
87e8d8bef9SDimitry Andric#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED)
88fe6060f1SDimitry Andricusing ::timespec_get _LIBCPP_USING_IF_EXISTS;
890b57cec5SDimitry Andric#endif
900b57cec5SDimitry Andric
910b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD
920b57cec5SDimitry Andric
930b57cec5SDimitry Andric#endif // _LIBCPP_CTIME
94