Record whether cached certificate was used
[folly.git] / folly / portability / Time.h
1 /*
2  * Copyright 2016 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 // These aren't generic implementations, so we can only declare them on
25 // platforms we support.
26 #if !FOLLY_HAVE_CLOCK_GETTIME && (defined(__MACH__) || defined(_WIN32))
27 #define CLOCK_REALTIME 0
28 #define CLOCK_MONOTONIC 1
29 #define CLOCK_PROCESS_CPUTIME_ID 2
30 #define CLOCK_THREAD_CPUTIME_ID 3
31
32 typedef uint8_t clockid_t;
33 extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts);
34 extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts);
35 #endif
36
37 #ifdef _WIN32
38 #define TM_YEAR_BASE (1900)
39
40 extern "C" {
41 char* asctime_r(const tm* tm, char* buf);
42 char* ctime_r(const time_t* t, char* buf);
43 tm* gmtime_r(const time_t* t, tm* res);
44 tm* localtime_r(const time_t* t, tm* o);
45 int nanosleep(const struct timespec* request, struct timespec* remain);
46 char* strptime(const char* __restrict buf,
47                const char* __restrict fmt,
48                struct tm* __restrict tm);
49 }
50 #endif