2 * Copyright 2016 Facebook, Inc.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <folly/portability/Config.h>
24 // These aren't generic implementations, so we can only declare them
25 // on platforms we support. Apple started defining clock_gettime in
26 // iOS 10 / OSX 12 and is gated via __CLOCK_AVAILABILITY.
27 #if !FOLLY_HAVE_CLOCK_GETTIME && \
28 (defined(_WIN32) || (defined(__MACH__) && !defined(__CLOCK_AVAILABILITY)))
29 #define CLOCK_REALTIME 0
30 // The Windows implementation supports a few other
31 // clock types as well.
33 # define CLOCK_MONOTONIC 1
34 # define CLOCK_PROCESS_CPUTIME_ID 2
35 # define CLOCK_THREAD_CPUTIME_ID 3
38 typedef uint8_t clockid_t;
39 extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts);
40 extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts);
44 #define TM_YEAR_BASE (1900)
47 char* asctime_r(const tm* tm, char* buf);
48 char* ctime_r(const time_t* t, char* buf);
49 tm* gmtime_r(const time_t* t, tm* res);
50 tm* localtime_r(const time_t* t, tm* o);
51 int nanosleep(const struct timespec* request, struct timespec* remain);
52 char* strptime(const char* __restrict buf,
53 const char* __restrict fmt,
54 struct tm* __restrict tm);