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 on
25 // platforms we support.
26 #if !FOLLY_HAVE_CLOCK_GETTIME && (defined(__MACH__) || defined(_WIN32))
27 #define CLOCK_REALTIME 0
28 // The Windows implementation supports a few other
29 // clock types as well.
31 # define CLOCK_MONOTONIC 1
32 # define CLOCK_PROCESS_CPUTIME_ID 2
33 # define CLOCK_THREAD_CPUTIME_ID 3
36 typedef uint8_t clockid_t;
37 extern "C" int clock_gettime(clockid_t clk_id, struct timespec* ts);
38 extern "C" int clock_getres(clockid_t clk_id, struct timespec* ts);
42 #define TM_YEAR_BASE (1900)
45 char* asctime_r(const tm* tm, char* buf);
46 char* ctime_r(const time_t* t, char* buf);
47 tm* gmtime_r(const time_t* t, tm* res);
48 tm* localtime_r(const time_t* t, tm* o);
49 int nanosleep(const struct timespec* request, struct timespec* remain);
50 char* strptime(const char* __restrict buf,
51 const char* __restrict fmt,
52 struct tm* __restrict tm);