CUBRID Engine  latest
tsc_timer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 /*
20  * tsc_timer.h - Time Stamp Counter(TSC) timer definitions
21  */
22 
23 #ifndef _TSC_TIMER_H_
24 #define _TSC_TIMER_H_
25 
26 #ident "$Id$"
27 
28 #include "porting.h"
29 #include "cycle.h"
30 
31 #define TSC_ADD_TIMEVAL(total, diff) \
32 do { \
33  (total).tv_usec += (diff).tv_usec; \
34  (total).tv_sec += (diff).tv_sec; \
35  (total).tv_sec += (total).tv_usec / 1000000; \
36  (total).tv_usec %= 1000000; \
37 } while (0)
38 
39 typedef UINT64 TSC_UINT64;
40 typedef struct timeval TSCTIMEVAL;
41 
42 typedef union tsc_ticks TSC_TICKS;
43 union tsc_ticks
44 {
45  ticks tc; /* ticks from cycle.h */
46  struct timeval tv; /* microseconds */
47 };
48 
49 /* todo: inline functions */
50 
51 extern void tsc_init (void);
52 extern void tsc_getticks (TSC_TICKS * tck);
53 extern void tsc_elapsed_time_usec (TSCTIMEVAL * tv, TSC_TICKS end_tick, TSC_TICKS start_tick);
54 extern UINT64 tsc_elapsed_utime (TSC_TICKS end_tick, TSC_TICKS start_tick);
55 extern void tsc_start_time_usec (TSC_TICKS * tck);
56 extern void tsc_end_time_usec (TSCTIMEVAL * tv, TSC_TICKS start_tick);
57 
58 extern TSC_UINT64 get_clock_freq (void);
59 #endif /* _TSC_TIMER_H_ */
UINT64 tsc_elapsed_utime(TSC_TICKS end_tick, TSC_TICKS start_tick)
Definition: tsc_timer.c:135
struct timeval TSCTIMEVAL
Definition: tsc_timer.h:40
void tsc_getticks(TSC_TICKS *tck)
Definition: tsc_timer.c:81
UINT64 TSC_UINT64
Definition: tsc_timer.h:39
TSC_UINT64 get_clock_freq(void)
void tsc_end_time_usec(TSCTIMEVAL *tv, TSC_TICKS start_tick)
Definition: tsc_timer.c:162
struct timeval tv
Definition: tsc_timer.h:46
void tsc_elapsed_time_usec(TSCTIMEVAL *tv, TSC_TICKS end_tick, TSC_TICKS start_tick)
Definition: tsc_timer.c:101
void tsc_init(void)
Definition: tsc_timer.c:67
void tsc_start_time_usec(TSC_TICKS *tck)
Definition: tsc_timer.c:150
ticks tc
Definition: tsc_timer.h:45