2010-05-12 03:42:16 +08:00
|
|
|
// -*- C++ -*-
|
|
|
|
//===---------------------------- ctime -----------------------------------===//
|
|
|
|
//
|
2019-01-19 18:56:40 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2010-05-12 03:42:16 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_CTIME
|
|
|
|
#define _LIBCPP_CTIME
|
|
|
|
|
|
|
|
/*
|
|
|
|
ctime synopsis
|
|
|
|
|
|
|
|
Macros:
|
|
|
|
|
|
|
|
NULL
|
|
|
|
CLOCKS_PER_SEC
|
2018-08-01 03:25:00 +08:00
|
|
|
TIME_UTC // C++17
|
2019-10-24 01:40:15 +08:00
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
|
|
|
|
Types:
|
|
|
|
|
|
|
|
clock_t
|
|
|
|
size_t
|
|
|
|
time_t
|
|
|
|
tm
|
2018-08-01 03:25:00 +08:00
|
|
|
timespec // C++17
|
2019-10-24 01:40:15 +08:00
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
clock_t clock();
|
|
|
|
double difftime(time_t time1, time_t time0);
|
|
|
|
time_t mktime(tm* timeptr);
|
|
|
|
time_t time(time_t* timer);
|
|
|
|
char* asctime(const tm* timeptr);
|
|
|
|
char* ctime(const time_t* timer);
|
|
|
|
tm* gmtime(const time_t* timer);
|
|
|
|
tm* localtime(const time_t* timer);
|
|
|
|
size_t strftime(char* restrict s, size_t maxsize, const char* restrict format,
|
|
|
|
const tm* restrict timeptr);
|
2018-08-01 03:25:00 +08:00
|
|
|
int timespec_get( struct timespec *ts, int base); // C++17
|
2010-05-12 03:42:16 +08:00
|
|
|
} // std
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <__config>
|
|
|
|
#include <time.h>
|
|
|
|
|
2011-10-18 04:05:10 +08:00
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
2010-05-12 03:42:16 +08:00
|
|
|
#pragma GCC system_header
|
2011-10-18 04:05:10 +08:00
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
|
2020-09-02 22:36:48 +08:00
|
|
|
// FIXME:
|
|
|
|
// Apple SDKs don't define ::timespec_get unconditionally in C++ mode. This
|
|
|
|
// should be fixed in future SDKs, but for the time being we need to avoid
|
|
|
|
// trying to use that declaration when the SDK doesn't provide it. Note that
|
|
|
|
// we're detecting this here instead of in <__config> because we can't include
|
|
|
|
// system headers from <__config>, since it leads to circular module dependencies.
|
|
|
|
// This is also meant to be a very temporary workaround until the SDKs are fixed.
|
2020-09-03 06:11:26 +08:00
|
|
|
#if defined(__APPLE__)
|
|
|
|
# include <sys/cdefs.h>
|
|
|
|
# if defined(_LIBCPP_HAS_TIMESPEC_GET) && (__DARWIN_C_LEVEL < __DARWIN_C_FULL)
|
|
|
|
# define _LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED
|
|
|
|
# endif
|
2020-09-02 22:36:48 +08:00
|
|
|
#endif
|
|
|
|
|
2010-05-12 03:42:16 +08:00
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
|
|
|
|
using ::clock_t;
|
|
|
|
using ::size_t;
|
|
|
|
using ::time_t;
|
|
|
|
using ::tm;
|
Fix _LIBCPP_HAS_ definitions for Android.
Summary:
Android added quick_exit()/at_quick_exit() in API level 21,
aligned_alloc() in API level 28, and timespec_get() in API level 29,
but has the other C11 features at all API levels (since they're basically
just coming from clang directly).
_LIBCPP_HAS_QUICK_EXIT and _LIBCPP_HAS_TIMESPEC_GET already existed,
so we can reuse them. (And use _LIBCPP_HAS_TIMESPEC_GET in a few more
places where _LIBCPP_HAS_C11_FEATURES has been used as a proxy. This
isn't correct for Android.)
_LIBCPP_HAS_ALIGNED_ALLOC is added, to cover aligned_alloc() (obviously).
Add a missing std:: before aligned_alloc in a cstdlib test, and remove a
couple of !defined(_WIN32)s now that we're explicitly testing
TEST_HAS_ALIGNED_ALLOC rather than TEST_HAS_C11_FEATURES.
Reviewers: danalbert, EricWF, mclow.lists
Reviewed By: danalbert
Subscribers: srhines, christof, libcxx-commits
Tags: #libc
Differential Revision: https://reviews.llvm.org/D69929
2019-11-19 04:16:45 +08:00
|
|
|
#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET)
|
2018-08-01 03:25:00 +08:00
|
|
|
using ::timespec;
|
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
using ::clock;
|
|
|
|
using ::difftime;
|
|
|
|
using ::mktime;
|
|
|
|
using ::time;
|
2015-06-24 16:44:38 +08:00
|
|
|
#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
|
2010-05-12 03:42:16 +08:00
|
|
|
using ::asctime;
|
|
|
|
using ::ctime;
|
|
|
|
using ::gmtime;
|
|
|
|
using ::localtime;
|
2015-06-24 16:44:38 +08:00
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
using ::strftime;
|
2020-09-02 22:36:48 +08:00
|
|
|
#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_TIMESPEC_GET) && !defined(_LIBCPP_HAS_TIMESPEC_GET_NOT_ACTUALLY_PROVIDED)
|
2018-08-01 03:25:00 +08:00
|
|
|
using ::timespec_get;
|
|
|
|
#endif
|
2010-05-12 03:42:16 +08:00
|
|
|
|
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
|
2021-04-21 00:03:32 +08:00
|
|
|
#endif // _LIBCPP_CTIME
|