~mdcallag/+junk/5.1-map

« back to all changes in this revision

Viewing changes to storage/innobase/ut/ut0ut.c

  • Committer: msvensson at pilot
  • Date: 2007-04-24 09:11:45 UTC
  • mfrom: (2469.1.106)
  • Revision ID: sp1r-msvensson@pilot.blaudden-20070424091145-10463
Merge pilot.blaudden:/home/msvensson/mysql/my51-m-mysql_upgrade
into  pilot.blaudden:/home/msvensson/mysql/mysql-5.1-maint

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
ibool   ut_always_false = FALSE;
22
22
 
 
23
#ifdef __WIN__
 
24
/*********************************************************************
 
25
NOTE: The Windows epoch starts from 1601/01/01 whereas the Unix
 
26
epoch starts from 1970/1/1. For selection of constant see:
 
27
http://support.microsoft.com/kb/167296/ */
 
28
#define WIN_TO_UNIX_DELTA_USEC  ((ib_longlong) 11644473600000000ULL)
 
29
 
 
30
 
 
31
/*********************************************************************
 
32
This is the Windows version of gettimeofday(2).*/
 
33
static
 
34
int
 
35
ut_gettimeofday(
 
36
/*============*/
 
37
                        /* out: 0 if all OK else -1 */
 
38
        struct timeval* tv,     /* out: Values are relative to Unix epoch */
 
39
        void*           tz)     /* in: not used */
 
40
{
 
41
        FILETIME        ft;
 
42
        ib_longlong     tm;
 
43
 
 
44
        if (!tv) {
 
45
                errno = EINVAL;
 
46
                return(-1);
 
47
        }
 
48
 
 
49
        GetSystemTimeAsFileTime(&ft);
 
50
 
 
51
        tm = (ib_longlong) ft.dwHighDateTime << 32;
 
52
        tm |= ft.dwLowDateTime;
 
53
 
 
54
        ut_a(tm >= 0);  /* If tm wraps over to negative, the quotient / 10
 
55
                        does not work */
 
56
 
 
57
        tm /= 10;       /* Convert from 100 nsec periods to usec */
 
58
 
 
59
        /* If we don't convert to the Unix epoch the value for
 
60
        struct timeval::tv_sec will overflow.*/
 
61
        tm -= WIN_TO_UNIX_DELTA_USEC;
 
62
 
 
63
        tv->tv_sec  = (long) (tm / 1000000L);
 
64
        tv->tv_usec = (long) (tm % 1000000L);
 
65
 
 
66
        return(0);
 
67
}
 
68
#else
 
69
#define ut_gettimeofday         gettimeofday
 
70
#endif
 
71
 
23
72
#ifndef UNIV_HOTBACKUP
24
73
/*********************************************************************
25
74
Display an SQL identifier.
85
134
        ulint*  sec,    /* out: seconds since the Epoch */
86
135
        ulint*  ms)     /* out: microseconds since the Epoch+*sec */
87
136
{
88
 
#ifdef __WIN__
89
 
        SYSTEMTIME st;
90
 
        GetLocalTime(&st);
91
 
        *sec = (ulint) st.wSecond;
92
 
        *ms  = (ulint) st.wMilliseconds;
93
 
#else
94
137
        struct timeval  tv;
95
 
        gettimeofday(&tv,NULL);
 
138
 
 
139
        ut_gettimeofday(&tv, NULL);
96
140
        *sec = (ulint) tv.tv_sec;
97
141
        *ms  = (ulint) tv.tv_usec;
98
 
#endif
99
142
}
100
143
 
101
144
/**************************************************************