diff options
author | Vladislav Vaintroub <wlad@montyprogram.com> | 2011-03-24 12:30:03 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@montyprogram.com> | 2011-03-24 12:30:03 +0100 |
commit | 8250ceced6aab95347e00e2ff1c02730da0be4fe (patch) | |
tree | a9c92cf8c685457bf79b580ab6109e6331e8c300 | |
parent | a85ccfedcf91f7ad2c578ec60e69d127f199d079 (diff) | |
download | mariadb-git-8250ceced6aab95347e00e2ff1c02730da0be4fe.tar.gz |
Fix compilation on Windows:
- Fixes for type-conversion
(time_t is not interchangeable with my_time_t on Windows as time_t s 64 bit while my_time_t is long)
- BIGENDIAN-> ARCH_BIGENDIAN .
BIGENDIAN constant is defined in winsock2.h (as 0)
- added explicit cast for longlong->double conversion in sql/item.h (fixed many warnings)
Also, HAVE_SNPRINTF is now defined and snprintf is defined to _snprintf in config-win.h
-rw-r--r-- | include/config-win.h | 7 | ||||
-rw-r--r-- | include/my_sys.h | 2 | ||||
-rw-r--r-- | mysys/mf_getdate.c | 2 | ||||
-rw-r--r-- | mysys/my_getsystime.c | 5 | ||||
-rw-r--r-- | sql-common/my_time.c | 4 | ||||
-rw-r--r-- | sql/field.h | 24 | ||||
-rw-r--r-- | sql/item.h | 2 | ||||
-rw-r--r-- | sql/item_timefunc.cc | 2 | ||||
-rw-r--r-- | sql/log_event.cc | 3 |
9 files changed, 27 insertions, 24 deletions
diff --git a/include/config-win.h b/include/config-win.h index da9b1fc00c3..84bc4ece959 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -293,10 +293,9 @@ inline ulonglong double2ulonglong(double d) #define FILE_SHARE_DELETE 0 /* Not implemented on Win 98/ME */ #endif -#ifdef NOT_USED -#define HAVE_SNPRINTF /* Gave link error */ -#define _snprintf snprintf -#endif + +#define HAVE_SNPRINTF +#define snprintf _snprintf #ifdef _MSC_VER #define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */ diff --git a/include/my_sys.h b/include/my_sys.h index f86b7839baf..0d57566d6e4 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -902,7 +902,7 @@ void my_diff_and_hrtime(my_timediff_t *interval, my_hrtime_t *timestamp); extern ulonglong my_getsystime(void); #define my_micro_time() (my_getsystime()/10) -#define hrtime_to_time(X) ((time_t)((X).val/1000000)) +#define hrtime_to_time(X) ((my_time_t)((X).val/1000000)) #define hrtime_from_time(X) ((ulonglong)((X)*1000000ULL)) #define hrtime_to_double(X) ((X).val/1e6) #define hrtime_sec_part(X) ((X).val%1000000) diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c index 9475bebd107..af86322a856 100644 --- a/mysys/mf_getdate.c +++ b/mysys/mf_getdate.c @@ -17,7 +17,7 @@ #include "mysys_priv.h" #include <m_string.h> - +#include <my_time.h> /* get date as string diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c index b467c49c6e6..827c65aef2b 100644 --- a/mysys/my_getsystime.c +++ b/mysys/my_getsystime.c @@ -108,7 +108,10 @@ void my_diff_and_hrtime(my_timediff_t *interval, my_hrtime_t *timestamp) { interval->val= my_getsystime() / 10; #if defined(__WIN__) || defined(HAVE_GETHRTIME) - timestamp->val= my_hrtime(); + { + my_hrtime_t t= my_hrtime(); + timestamp->val= t.val; + } #else timestamp->val= interval->val; #endif diff --git a/sql-common/my_time.c b/sql-common/my_time.c index f05f1fe835b..d9d53107b8b 100644 --- a/sql-common/my_time.c +++ b/sql-common/my_time.c @@ -1245,7 +1245,7 @@ int number_to_time(double nr, MYSQL_TIME *ltime, int *was_cut) ltime->hour = tmp/100/100; ltime->minute= tmp/100%100; ltime->second= tmp%100; - ltime->second_part= (nr-tmp)*1e6; + ltime->second_part= (ulong)((nr-tmp)*1e6); if (ltime->minute < 60 && ltime->second < 60) return 0; @@ -1363,7 +1363,7 @@ MYSQL_TIME *unpack_time(longlong packed, MYSQL_TIME *my_time) get_one(my_time->hour, 24ULL); get_one(my_time->day, 32ULL); get_one(my_time->month, 13ULL); - my_time->year= packed; + my_time->year= (uint)packed; my_time->time_type= MYSQL_TIMESTAMP_DATETIME; return my_time; } diff --git a/sql/field.h b/sql/field.h index f40a4e2fb3c..8eacfcd404f 100644 --- a/sql/field.h +++ b/sql/field.h @@ -22,10 +22,10 @@ #pragma interface /* gcc class implementation */ #endif -#ifdef WORDS_BIGENDIAN -#define BIGENDIAN 1 +#ifdef WORDS_ARCH_BIGENDIAN +#define ARCH_BIGENDIAN 1 #else -#define BIGENDIAN 0 +#define ARCH_BIGENDIAN 0 #endif #define NOT_FIXED_DEC 31 @@ -548,12 +548,12 @@ protected: bool low_byte_first_from, bool low_byte_first_to) { int32 val; - if (BIGENDIAN && low_byte_first_from) + if (ARCH_BIGENDIAN && low_byte_first_from) val = sint4korr(from); else longget(val, from); - if (BIGENDIAN && low_byte_first_to) + if (ARCH_BIGENDIAN && low_byte_first_to) int4store(to, val); else longstore(to, val); @@ -566,12 +566,12 @@ protected: bool low_byte_first_from, bool low_byte_first_to) { int64 val; - if (BIGENDIAN && low_byte_first_from) + if (ARCH_BIGENDIAN && low_byte_first_from) val = sint8korr(from); else longlongget(val, from); - if (BIGENDIAN && low_byte_first_to) + if (ARCH_BIGENDIAN && low_byte_first_to) int8store(to, val); else longlongstore(to, val); @@ -883,12 +883,12 @@ public: uint max_length, bool low_byte_first) { int16 val; - if (BIGENDIAN && table->s->db_low_byte_first) + if (ARCH_BIGENDIAN && table->s->db_low_byte_first) val = sint2korr(from); else shortget(val, from); - if (BIGENDIAN && low_byte_first) + if (ARCH_BIGENDIAN && low_byte_first) int2store(to, val); else shortstore(to, val); @@ -899,12 +899,12 @@ public: uint param_data, bool low_byte_first) { int16 val; - if (BIGENDIAN && low_byte_first) + if (ARCH_BIGENDIAN && low_byte_first) val = sint2korr(from); else shortget(val, from); - if (BIGENDIAN && table->s->db_low_byte_first) + if (ARCH_BIGENDIAN && table->s->db_low_byte_first) int2store(to, val); else shortstore(to, val); @@ -1200,7 +1200,7 @@ public: virtual long get_timestamp(ulong *sec_part) const; virtual void store_TIME(my_time_t timestamp, ulong sec_part) { - if (BIGENDIAN && table && table->s->db_low_byte_first) + if (ARCH_BIGENDIAN && table && table->s->db_low_byte_first) int4store(ptr,timestamp); else longstore(ptr,(uint32) timestamp); diff --git a/sql/item.h b/sql/item.h index d45df4ebe53..866b3fcb4fc 100644 --- a/sql/item.h +++ b/sql/item.h @@ -1786,7 +1786,7 @@ public: Item_datetime() :Item_int(0) { unsigned_flag=0; } int save_in_field(Field *field, bool no_conversions); longlong val_int(); - double val_real() { return val_int(); } + double val_real() { return (double)val_int(); } void set(longlong packed); }; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 6ca15873199..4f9022cb579 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -86,7 +86,7 @@ static bool sec_to_time(double seconds, MYSQL_TIME *ltime) ltime->hour= (uint) (seconds/3600); ltime->minute= sec/60; ltime->second= sec % 60; - ltime->second_part= (ulong)((seconds - trunc(seconds))*1e6); + ltime->second_part= (ulong)((seconds - floor(seconds))*1e6); return 0; diff --git a/sql/log_event.cc b/sql/log_event.cc index 4abf56f70f3..8a0c8f93af3 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2063,10 +2063,11 @@ void Log_event::print_base64(IO_CACHE* file, void Log_event::print_timestamp(IO_CACHE* file, time_t* ts) { struct tm *res; + time_t my_when= when; DBUG_ENTER("Log_event::print_timestamp"); if (!ts) { - ts = &when; + ts = &my_when; } res=localtime(ts); |