2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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.
19 #ifndef CLOCK_REALTIME_COARSE
20 #define CLOCK_REALTIME_COARSE CLOCK_REALTIME
23 #ifndef CLOCK_MONOTONIC_COARSE
24 #define CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC
27 long long common_get_monotonic_time(void)
32 result = clock_gettime(CLOCK_MONOTONIC, &ts);
37 return (((unsigned long long) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000);
40 long long common_get_monotonic_coarse_time(void)
45 result = clock_gettime(CLOCK_MONOTONIC_COARSE, &ts);
50 return (((unsigned long long) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000);
53 long long common_get_epoch_time(void)
55 long long int ret_time = 0;
56 struct timespec time_s;
58 if (0 == clock_gettime(CLOCK_REALTIME, &time_s))
59 ret_time = time_s.tv_sec;
64 long long common_get_epoch_coarse_time(void)
66 long long int ret_time = 0;
67 struct timespec time_s;
69 if (0 == clock_gettime(CLOCK_REALTIME_COARSE, &time_s))
70 ret_time = time_s.tv_sec;
75 int common_get_epoch_timespec(struct timespec *tp)
80 return clock_gettime(CLOCK_REALTIME, tp);
83 int common_get_epoch_coarse_timespec(struct timespec *tp)
88 return clock_gettime(CLOCK_REALTIME_COARSE, tp);