1 /*
2   Copyright (c) DataStax, 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 #ifndef DATASTAX_INTERNAL_GET_TIME_HPP
18 #define DATASTAX_INTERNAL_GET_TIME_HPP
19 
20 #include <uv.h>
21 
22 #define NANOSECONDS_PER_MICROSECOND 1000LL
23 #define NANOSECONDS_PER_MILLISECOND 1000000LL
24 #define NANOSECONDS_PER_SECOND 1000000000LL
25 
26 #define MICROSECONDS_PER_MILLISECOND 1000LL
27 
28 namespace datastax { namespace internal {
29 
30 uint64_t get_time_since_epoch_us();
31 
get_time_since_epoch_ms()32 inline uint64_t get_time_since_epoch_ms() {
33   return get_time_since_epoch_us() / MICROSECONDS_PER_MILLISECOND;
34 }
35 
36 // This is a best effort monotonic clock with an arbitrary start time. If the
37 // system or platform doesn't have a monotonic clock then
38 // `get_time_since_epoch_us()` will be used.
39 uint64_t get_time_monotonic_ns();
40 
41 }} // namespace datastax::internal
42 
43 #endif
44