proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
Time.h
Go to the documentation of this file.
1
/*
2
* Copyright 2016-present Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
#pragma once
18
19
#include <stdint.h>
20
#include <time.h>
21
22
#include <
folly/portability/Config.h
>
23
24
// OSX is a pain. The XCode 8 SDK always declares clock_gettime
25
// even if the target OS version doesn't support it, so you get
26
// an error at runtime because it can't resolve the symbol. We
27
// solve that by pretending we have it here in the header and
28
// then enable our implementation on the source side so that
29
// gets linked in instead.
30
#if __MACH__ && \
31
(MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_12 || \
32
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_10_0)
33
34
#ifdef FOLLY_HAVE_CLOCK_GETTIME
35
#undef FOLLY_HAVE_CLOCK_GETTIME
36
#endif
37
38
#define FOLLY_HAVE_CLOCK_GETTIME 1
39
#define FOLLY_FORCE_CLOCK_GETTIME_DEFINITION 1
40
41
#endif
42
43
// These aren't generic implementations, so we can only declare them on
44
// platforms we support.
45
#if !FOLLY_HAVE_CLOCK_GETTIME && (defined(__MACH__) || defined(_WIN32))
46
#define CLOCK_REALTIME 0
47
#define CLOCK_MONOTONIC 1
48
#define CLOCK_PROCESS_CPUTIME_ID 2
49
#define CLOCK_THREAD_CPUTIME_ID 3
50
51
typedef
uint8_t
clockid_t;
52
extern
"C"
int
clock_gettime
(clockid_t clk_id,
struct
timespec* ts);
53
extern
"C"
int
clock_getres(clockid_t clk_id,
struct
timespec* ts);
54
#endif
55
56
#ifdef _WIN32
57
#define TM_YEAR_BASE (1900)
58
59
extern
"C"
{
60
char
* asctime_r(
const
tm* tm,
char
* buf);
61
char
* ctime_r(
const
time_t*
t
,
char
* buf);
62
tm* gmtime_r(
const
time_t*
t
, tm* res);
63
tm* localtime_r(
const
time_t*
t
, tm* o);
64
int
nanosleep(
const
struct
timespec* request,
struct
timespec* remain);
65
char
* strptime(
66
const
char
* __restrict buf,
67
const
char
* __restrict fmt,
68
struct
tm* __restrict tm);
69
}
70
#endif
folly::chrono::clock_gettime
int(* clock_gettime)(clockid_t, timespec *ts)
Definition:
ClockGettimeWrappers.cpp:48
Config.h
uint8_t
uint8_t
Definition:
ConstexprMathBenchmark.cpp:178
folly::pushmi::detail::t
requires Tuple && t
Definition:
extension_operators.h:48
proxygen
folly
folly
portability
Time.h
Generated by
1.8.11