summaryrefslogtreecommitdiff
path: root/include/my_sys.h
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-05-19 19:05:35 +0200
committerSergei Golubchik <sergii@pisem.net>2011-05-19 19:05:35 +0200
commit03b33425e5a3de3fad070aa21e7fc7baf8104c81 (patch)
tree2cc6c9da412eab9a2176ded10bdb1ca7cbb295de /include/my_sys.h
parent8ddcd0cda8e6e90a58e9ea64f0f3773ea0037f0b (diff)
downloadmariadb-git-03b33425e5a3de3fad070aa21e7fc7baf8104c81.tar.gz
many changes to my_getsystime.c:
* my_getsystime() is only an interval timer. Its value can beused for calculating time intervals. * renamed my_getsystime() to my_interval_timer(), to make the semantics clearer and let the compiler catch wrong usages of my_getsystime() (also future ones, that may come in merges). * increased its granularity from 100ns to 1ns, old value was for UUID, but as UUID can no longer use it directly there is no need to downgrade the OS provided value * fixed the UUID code to anchor the my_interval_timer() on the epoch, as required by the UUID standard. That is, this was only needed by UUID, and now I've moved it to UUID code from my_getsystime(). * fixed other wrong usages of my_getsystime() - e.g. in calculating times for pthread_cond_timedwait. It was buggy and could've caused long waits if OS clock would be changed.
Diffstat (limited to 'include/my_sys.h')
-rw-r--r--include/my_sys.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/include/my_sys.h b/include/my_sys.h
index 96754d2e85d..48370ea7c38 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -894,21 +894,18 @@ extern ulong crc32(ulong crc, const uchar *buf, uint len);
extern uint my_set_max_open_files(uint files);
void my_free_open_file_info(void);
-#define HRTIME_RESOLUTION 1000000
+#define HRTIME_RESOLUTION 1000000 /* microseconds */
typedef struct {ulonglong val;} my_hrtime_t;
-typedef struct {ulonglong val;} my_timediff_t;
void my_time_init();
extern my_hrtime_t my_hrtime();
-void my_diff_and_hrtime(my_timediff_t *interval, my_hrtime_t *timestamp);
-extern ulonglong my_getsystime(void);
+extern ulonglong my_interval_timer(void);
-#define my_micro_time() (my_getsystime()/10)
+#define microsecond_interval_timer() (my_interval_timer()/1000)
#define hrtime_to_time(X) ((X).val/1000000)
#define hrtime_from_time(X) ((ulonglong)((X)*1000000ULL))
#define hrtime_to_double(X) ((X).val/(double)HRTIME_RESOLUTION)
#define hrtime_sec_part(X) ((ulong)((X).val%1000000))
#define my_time(X) hrtime_to_time(my_hrtime())
-#define my_micro_and_hrtime(X,Y) my_diff_and_hrtime(X,Y)
extern my_bool my_gethwaddr(uchar *to);
extern int my_getncpus();