diff options
Diffstat (limited to 'innobase/ut')
-rw-r--r-- | innobase/ut/ut0mem.c | 1 | ||||
-rw-r--r-- | innobase/ut/ut0ut.c | 77 |
2 files changed, 64 insertions, 14 deletions
diff --git a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c index 79351ff120f..a1320e8b5bc 100644 --- a/innobase/ut/ut0mem.c +++ b/innobase/ut/ut0mem.c @@ -121,6 +121,7 @@ ut_malloc( { return(ut_malloc_low(n, TRUE)); } + /************************************************************************** Frees a memory block allocated with ut_malloc. */ diff --git a/innobase/ut/ut0ut.c b/innobase/ut/ut0ut.c index 964d5bca567..7ee32b9a8e2 100644 --- a/innobase/ut/ut0ut.c +++ b/innobase/ut/ut0ut.c @@ -17,6 +17,24 @@ Created 5/11/1994 Heikki Tuuri ibool ut_always_false = FALSE; /************************************************************ +Gets the high 32 bits in a ulint. That is makes a shift >> 32, +but since there seem to be compiler bugs in both gcc and Visual C++, +we do this by a special conversion. */ + +ulint +ut_get_high32( +/*==========*/ + /* out: a >> 32 */ + ulint a) /* in: ulint */ +{ + if (sizeof(ulint) == 4) { + return(0); + } + + return(a >> 32); +} + +/************************************************************ The following function returns a clock time in milliseconds. */ ulint @@ -58,11 +76,11 @@ ut_print_timestamp( FILE* file) /* in: file where to print */ { #ifdef __WIN__ - SYSTEMTIME cal_tm; + SYSTEMTIME cal_tm; - GetLocalTime(&cal_tm); + GetLocalTime(&cal_tm); - fprintf(file,"%02d%02d%02d %2d:%02d:%02d", + fprintf(file,"%02d%02d%02d %2d:%02d:%02d", (int)cal_tm.wYear % 100, (int)cal_tm.wMonth, (int)cal_tm.wDay, @@ -70,23 +88,21 @@ ut_print_timestamp( (int)cal_tm.wMinute, (int)cal_tm.wSecond); #else + struct tm cal_tm; + struct tm* cal_tm_ptr; + time_t tm; - struct tm cal_tm; - struct tm* cal_tm_ptr; - time_t tm; - - time(&tm); + time(&tm); #ifdef HAVE_LOCALTIME_R - localtime_r(&tm, &cal_tm); - cal_tm_ptr = &cal_tm; + localtime_r(&tm, &cal_tm); + cal_tm_ptr = &cal_tm; #else - cal_tm_ptr = localtime(&tm); + cal_tm_ptr = localtime(&tm); #endif - - fprintf(file,"%02d%02d%02d %2d:%02d:%02d", + fprintf(file,"%02d%02d%02d %2d:%02d:%02d", cal_tm_ptr->tm_year % 100, - cal_tm_ptr->tm_mon+1, + cal_tm_ptr->tm_mon + 1, cal_tm_ptr->tm_mday, cal_tm_ptr->tm_hour, cal_tm_ptr->tm_min, @@ -94,6 +110,39 @@ ut_print_timestamp( #endif } +/************************************************************** +Returns current year, month, day. */ + +void +ut_get_year_month_day( +/*==================*/ + ulint* year, /* out: current year */ + ulint* month, /* out: month */ + ulint* day) /* out: day */ +{ +#ifdef __WIN__ + SYSTEMTIME cal_tm; + + GetLocalTime(&cal_tm); + + *year = (ulint)cal_tm.wYear; + *month = (ulint)cal_tm.wMonth; + *day = (ulint)cal_tm.wDay; +#else + struct tm cal_tm; + struct tm* cal_tm_ptr; + time_t tm; + + time(&tm); + + cal_tm_ptr = localtime(&tm); + + *year = (ulint)cal_tm_ptr->tm_year; + *month = (ulint)cal_tm_ptr->tm_mon + 1; + *day = (ulint)cal_tm_ptr->tm_mday; +#endif +} + /***************************************************************** Runs an idle loop on CPU. The argument gives the desired delay in microseconds on 100 MHz Pentium + Visual C++. */ |