2 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
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.
30 #if defined(_USE_ECORE_TIME_GET)
34 .type = CLOCK_MONOTONIC,
38 const char *util_basename(const char *name)
41 length = name ? strlen(name) : 0;
45 while (--length > 0 && name[length] != '/');
47 return length <= 0 ? name : name + length + (name[length] == '/');
50 double util_timestamp(void)
52 #if defined(_USE_ECORE_TIME_GET)
56 if (clock_gettime(s_info.type, &ts) == 0) {
57 return ts.tv_sec + ts.tv_nsec / 1000000000.0f;
60 ErrPrint("%d: %s\n", s_info.type, strerror(errno));
61 if (s_info.type == CLOCK_MONOTONIC) {
62 s_info.type = CLOCK_REALTIME;
63 } else if (s_info.type == CLOCK_REALTIME) {
72 if (gettimeofday(&tv, NULL) < 0) {
73 ErrPrint("gettimeofday: %s\n", strerror(errno));
78 return (double)tv.tv_sec + (double)tv.tv_usec / 1000000.0f;