~vinchen13/mysql-proxy/fix_some_bugs

« back to all changes in this revision

Viewing changes to src/my_rdtsc.h

  • Committer: vin
  • Date: 2012-02-15 02:47:30 UTC
  • Revision ID: vinchen13@gmail.com-20120215024730-6xtv6nhn83ina0sc
origin source code from mysql-proxy-0.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2008, 2009 Sun Microsystems, Inc
 
2
 
 
3
  This program is free software; you can redistribute it and/or modify
 
4
  it under the terms of the GNU General Public License as published by
 
5
  the Free Software Foundation; version 2 of the License.
 
6
 
 
7
  This program is distributed in the hope that it will be useful,
 
8
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
  GNU General Public License for more details.
 
11
 
 
12
  You should have received a copy of the GNU General Public License
 
13
  along with this program; if not, write to the Free Software
 
14
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
15
 
 
16
/*
 
17
  rdtsc3 -- multi-platform timer code
 
18
  pgulutzan@mysql.com, 2005-08-29
 
19
  modified 2008-11-02
 
20
*/
 
21
 
 
22
#ifndef MY_RDTSC_H
 
23
#define MY_RDTSC_H
 
24
 
 
25
#ifdef HAVE_CONFIG_H
 
26
#include "config.h"
 
27
#endif
 
28
 
 
29
#include <glib.h>
 
30
#define C_MODE_START G_BEGIN_DECLS
 
31
#define C_MODE_END G_END_DECLS
 
32
typedef guint64 ulonglong;
 
33
 
 
34
#ifndef HAVE_ULONG
 
35
#ifdef HAVE_ULONG_T
 
36
typedef ulong_t ulong;
 
37
#else /* HAVE_ULONG_T */
 
38
typedef guint32 ulong;
 
39
#endif /* HAVE_ULONG_T */
 
40
#endif /* HAVE_ULONG */
 
41
 
 
42
/**
 
43
  This structure contains the characteristics of all the supported timers.
 
44
  @sa my_timer_init().
 
45
*/
 
46
struct my_timer_info
 
47
{
 
48
  /** Routine used for the cycle timer. */
 
49
  ulonglong cycles_routine;
 
50
  /** Overhead of the cycle timer. */
 
51
  ulonglong cycles_overhead;
 
52
  /** Frequency of the cycle timer. */
 
53
  ulonglong cycles_frequency;
 
54
  /** Resolution of the cycle timer. */
 
55
  ulonglong cycles_resolution;
 
56
  /** Routine used for the nanosecond timer. */
 
57
  ulonglong nanoseconds_routine;
 
58
  /** Overhead of the nanosecond timer. */
 
59
  ulonglong nanoseconds_overhead;
 
60
  /** Frequency of the nanosecond timer. */
 
61
  ulonglong nanoseconds_frequency;
 
62
  /** Resolution of the nanosecond timer. */
 
63
  ulonglong nanoseconds_resolution;
 
64
  /** Routine used for the microsecond timer. */
 
65
  ulonglong microseconds_routine;
 
66
  /** Overhead of the microsecond timer. */
 
67
  ulonglong microseconds_overhead;
 
68
  /** Frequency of the microsecond timer. */
 
69
  ulonglong microseconds_frequency;
 
70
  /** Resolution of the microsecond timer. */
 
71
  ulonglong microseconds_resolution;
 
72
  /** Routine used for the millisecond timer. */
 
73
  ulonglong milliseconds_routine;
 
74
  /** Overhead of the millisecond timer. */
 
75
  ulonglong milliseconds_overhead;
 
76
  /** Frequency of the millisecond timer. */
 
77
  ulonglong milliseconds_frequency;
 
78
  /** Resolution of the millisecond timer. */
 
79
  ulonglong milliseconds_resolution;
 
80
  /** Routine used for the tick timer. */
 
81
  ulonglong ticks_routine;
 
82
  /** Overhead of the tick timer. */
 
83
  ulonglong ticks_overhead;
 
84
  /** Frequency of the tick timer. */
 
85
  ulonglong ticks_frequency;
 
86
  /** Resolution of the tick timer. */
 
87
  ulonglong ticks_resolution;
 
88
};
 
89
 
 
90
typedef struct my_timer_info MY_TIMER_INFO;
 
91
 
 
92
C_MODE_START
 
93
 
 
94
/**
 
95
  A cycle timer.
 
96
  @return the current timer value, in cycles.
 
97
*/
 
98
ulonglong my_timer_cycles(void);
 
99
 
 
100
/**
 
101
  A namoseconds timer.
 
102
  @return the current timer value, in nanoseconds.
 
103
*/
 
104
ulonglong my_timer_nanoseconds(void);
 
105
 
 
106
/**
 
107
  A microseconds timer.
 
108
  @return the current timer value, in microseconds.
 
109
*/
 
110
ulonglong my_timer_microseconds(void);
 
111
 
 
112
/**
 
113
  A millisecond timer.
 
114
  @return the current timer value, in milliseconds.
 
115
*/
 
116
ulonglong my_timer_milliseconds(void);
 
117
 
 
118
/**
 
119
  A ticks timer.
 
120
  @return the current timer value, in ticks.
 
121
*/
 
122
ulonglong my_timer_ticks(void);
 
123
 
 
124
/**
 
125
  Timer initialization function.
 
126
  @param [out] mti the timer characteristics.
 
127
*/
 
128
void my_timer_init(MY_TIMER_INFO *mti);
 
129
 
 
130
C_MODE_END
 
131
 
 
132
#define MY_TIMER_ROUTINE_ASM_X86                  1
 
133
#define MY_TIMER_ROUTINE_ASM_X86_64               2
 
134
#define MY_TIMER_ROUTINE_RDTSCLL                  3
 
135
#define MY_TIMER_ROUTINE_ASM_X86_WIN              4
 
136
#define MY_TIMER_ROUTINE_RDTSC                    5
 
137
#define MY_TIMER_ROUTINE_ASM_IA64                 6
 
138
#define MY_TIMER_ROUTINE_ASM_PPC                  7
 
139
#define MY_TIMER_ROUTINE_SGI_CYCLE                8
 
140
#define MY_TIMER_ROUTINE_GETHRTIME                9
 
141
#define MY_TIMER_ROUTINE_READ_REAL_TIME          10
 
142
#define MY_TIMER_ROUTINE_CLOCK_GETTIME           11
 
143
#define MY_TIMER_ROUTINE_NXGETTIME               12
 
144
#define MY_TIMER_ROUTINE_GETTIMEOFDAY            13
 
145
#define MY_TIMER_ROUTINE_QUERYPERFORMANCECOUNTER 14
 
146
#define MY_TIMER_ROUTINE_GETTICKCOUNT            15
 
147
#define MY_TIMER_ROUTINE_TIME                    16
 
148
#define MY_TIMER_ROUTINE_TIMES                   17
 
149
#define MY_TIMER_ROUTINE_FTIME                   18
 
150
#define MY_TIMER_ROUTINE_ASM_PPC64               19
 
151
#define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC64      20
 
152
#define MY_TIMER_ROUTINE_ASM_SUNPRO_SPARC32      21
 
153
#define MY_TIMER_ROUTINE_ASM_SUNPRO_I386         22
 
154
#define MY_TIMER_ROUTINE_ASM_GCC_SPARC64         23
 
155
#define MY_TIMER_ROUTINE_ASM_GCC_SPARC32         24
 
156
#define MY_TIMER_ROUTINE_MACH_ABSOLUTE_TIME      25
 
157
#define MY_TIMER_ROUTINE_GETSYSTEMTIMEASFILETIME 26
 
158
#define MY_TIMER_ROUTINE_ASM_SUNPRO_X86_64       27
 
159
 
 
160
#endif
 
161