From 29e5a66b8800dfb2ff3d28e859d443c0f8c033d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 May 2007 19:58:06 +0300 Subject: Added casts to avoid compiler warnings and fixed a wrong type. mysys/array.c: Added casts to avoid compiler warnings. mysys/hash.c: Added casts to avoid compiler warnings. sql/sql_plugin.cc: Fixed wrong type. --- mysys/array.c | 18 +++++++++--------- mysys/hash.c | 8 +++++--- 2 files changed, 14 insertions(+), 12 deletions(-) (limited to 'mysys') diff --git a/mysys/array.c b/mysys/array.c index d9c17d817cc..8a539f18a20 100644 --- a/mysys/array.c +++ b/mysys/array.c @@ -63,7 +63,7 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, array->size_of_element=element_size; if ((array->buffer= init_buffer)) DBUG_RETURN(FALSE); - if (!(array->buffer=(char*) my_malloc_ci(element_size*init_alloc,MYF(MY_WME)))) + if (!(array->buffer=(uchar*) my_malloc_ci(element_size*init_alloc,MYF(MY_WME)))) { array->max_element=0; DBUG_RETURN(TRUE); @@ -132,7 +132,7 @@ uchar *alloc_dynamic(DYNAMIC_ARRAY *array) if (array->elements == array->max_element) { char *new_ptr; - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) { /* In this senerio, the buffer is statically preallocated, @@ -152,7 +152,7 @@ uchar *alloc_dynamic(DYNAMIC_ARRAY *array) array->size_of_element, MYF(MY_WME | MY_ALLOW_ZERO_PTR)))) return 0; - array->buffer=new_ptr; + array->buffer= (uchar*) new_ptr; array->max_element+=array->alloc_increment; } return array->buffer+(array->elements++ * array->size_of_element); @@ -206,7 +206,7 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, uchar* element, uint idx) char *new_ptr; size=(idx+array->alloc_increment)/array->alloc_increment; size*= array->alloc_increment; - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) { /* In this senerio, the buffer is statically preallocated, @@ -224,7 +224,7 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, uchar* element, uint idx) array->size_of_element, MYF(MY_WME | MY_ALLOW_ZERO_PTR)))) return TRUE; - array->buffer=new_ptr; + array->buffer= (uchar*) new_ptr; array->max_element=size; } bzero((uchar*) (array->buffer+array->elements*array->size_of_element), @@ -273,7 +273,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array) /* Just mark as empty if we are using a static buffer */ - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) array->elements= 0; else if (array->buffer) @@ -295,7 +295,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array) void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx) { - char *ptr=array->buffer+array->size_of_element*idx; + char *ptr= (char*) array->buffer+array->size_of_element*idx; array->elements--; memmove(ptr,ptr+array->size_of_element, (array->elements-idx)*array->size_of_element); @@ -318,12 +318,12 @@ void freeze_size(DYNAMIC_ARRAY *array) /* Do nothing if we are using a static buffer */ - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) return; if (array->buffer && array->max_element != elements) { - array->buffer=(char*) my_realloc(array->buffer, + array->buffer=(uchar*) my_realloc(array->buffer, elements*array->size_of_element, MYF(MY_WME)); array->max_element=elements; diff --git a/mysys/hash.c b/mysys/hash.c index 698c2299f4d..d8c914d13dd 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -308,7 +308,8 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key, my_bool my_hash_insert(HASH *info,const uchar *record) { int flag; - uint halfbuff,hash_nr,first_index,idx; + size_t idx; + uint halfbuff,hash_nr,first_index; uchar *ptr_to_rec,*ptr_to_rec2; HASH_LINK *data,*empty,*gpos,*gpos2,*pos; @@ -535,7 +536,8 @@ exit: my_bool hash_update(HASH *hash, uchar *record, uchar *old_key, size_t old_key_length) { - uint idx,new_index,new_pos_index,blength,records,empty; + uint new_index,new_pos_index,blength,records,empty; + size_t idx; HASH_LINK org_link,*data,*previous,*pos; DBUG_ENTER("hash_update"); @@ -546,7 +548,7 @@ my_bool hash_update(HASH *hash, uchar *record, uchar *old_key, if ((found= hash_first(hash, new_key, idx, &state))) do { - if (found != record) + if (found != (char*) record) DBUG_RETURN(1); /* Duplicate entry */ } while ((found= hash_next(hash, new_key, idx, &state))); -- cgit v1.2.1 From 44c169f2cdcce8be7177f963597b81e1b4e1eef1 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 08:22:38 +0300 Subject: Added casts and fixed wrong type. client/mysqltest.c: Added casts to avoid compiler warnings. mysys/my_quick.c: Added cast to avoid compiler warning. sql/sql_map.cc: Added casts to avoid compiler warnings. strings/ctype-ucs2.c: Fixed wrong type. --- mysys/my_quick.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mysys') diff --git a/mysys/my_quick.c b/mysys/my_quick.c index af8ef05bd5f..c19fe08572d 100644 --- a/mysys/my_quick.c +++ b/mysys/my_quick.c @@ -50,7 +50,7 @@ size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count) #ifndef DBUG_OFF writtenbytes = #endif - write(Filedes,Buffer,Count)) != Count) + (size_t) write(Filedes,Buffer,Count)) != Count) { #ifndef DBUG_OFF if ((writtenbytes == 0 || writtenbytes == (size_t) -1) && errno == EINTR) -- cgit v1.2.1 From 72a9b472beef06c2c45b21488184f7bad9457ef8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 19:46:48 +0300 Subject: Disabled compiler warnings mainly for Win 64. mysys/my_conio.c: To avoid a warning from compiler. sql/ha_partition.cc: result is type bool, so calculation should be forced to that also. support-files/compiler_warnings.supp: Added new disabled warnings for Win 64. --- mysys/my_conio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'mysys') diff --git a/mysys/my_conio.c b/mysys/my_conio.c index d03f63a11a9..1ea1f7a820a 100644 --- a/mysys/my_conio.c +++ b/mysys/my_conio.c @@ -125,6 +125,7 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen) { ULONG state; char *result; + DWORD plen_res; CONSOLE_SCREEN_BUFFER_INFO csbi; pthread_auto_mutex_decl(my_conio_cs); @@ -171,7 +172,8 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen) do { clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y); - if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, plen, NULL)) + if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, &plen_res, + NULL)) { result= NULL; clen>>= 1; @@ -183,7 +185,7 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen) } } while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY); - + *plen= plen_res; if (result != NULL) { -- cgit v1.2.1 From 9ac571dc0cc09143373368f75ad91a4c3d93661e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 29 May 2007 21:07:48 +0300 Subject: Added casts to remove compiler warnings on windows Give warnings also for safe_mutex errors found by test system Added some warnings from different machines in pushbuild mysql-test/lib/mtr_report.pl: Give warnings also for safe_mutex errors Added some warnings from different machines in pushbuild mysys/my_compress.c: Added casts to remove compiler warnings on windows sql/sql_class.cc: Added cast to remove compiler warnings on windows --- mysys/my_compress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'mysys') diff --git a/mysys/my_compress.c b/mysys/my_compress.c index 3966be8b6bb..d495a1c1c6d 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -68,7 +68,7 @@ uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen) return 0; /* Not enough memory */ tmp_complen= *complen; - res= compress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet, *len); + res= compress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet, (uLong) *len); *complen= tmp_complen; if (res != Z_OK) @@ -120,7 +120,7 @@ my_bool my_uncompress(uchar *packet, size_t len, size_t *complen) tmp_complen= *complen; error= uncompress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet, - len); + (uLong) len); *complen= tmp_complen; if (error != Z_OK) { /* Probably wrong packet */ -- cgit v1.2.1 From 08dd5dcf168bbc1e1bf6e8bab784fdde58068daa Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Jul 2007 01:58:12 +0300 Subject: Added support for 'internal temporary tables' in HEAP tables. Now we don't take any mutexes when creating or dropping internal HEAP tables during SELECT. Change buffer sizes to size_t to make keycache 64 bit safe on platforms where sizeof(ulong) != sizeof(size_t) BitKeeper/etc/ignore: added support-files/mysqld_multi.server include/heap.h: Added 'internal_table' to HP_CREATE_INFO include/keycache.h: Change buffer sizes to size_t to make keycache 64 bit safe include/my_base.h: Added HA_OPEN_INTERNAL_TABLE to mark temporary tables that should be deleted on close mysys/mf_keycache.c: Change buffer sizes to size_t to make keycache 64 bit safe sql/sql_select.cc: Added HA_OPEN_INTERNAL_TABLE to mark temporary tables that should be deleted on close Removed not anymore needed call to delete_table() storage/heap/ha_heap.cc: Added support for internal temporary tables that should be deleted on close. Internal tables now use dedicated open and close calls to avoid taking mutexes. If heap_open() failes, now delete the newly created table. (This fixes a possible memory leak) Remove never executed info() in create() storage/heap/ha_heap.h: Added slots needed to handle internal temporary tables storage/heap/heapdef.h: Protect against C++ inclusion storage/heap/hp_close.c: Don't call list_delete() for internal temporary tables (They are not in the list) storage/heap/hp_create.c: Added HP_SHARE ** element to heap_create() to store the SHARE of the newly created table. For internal temporary tables: Don't take any mutex and don't put them into the open table list. storage/heap/hp_open.c: Split heap_open() into sub functions to be able to create internal temporary tables without putting them in the heap_share_list. Add faster open() functions for when we already know the 'share'. storage/heap/hp_test1.c: Update call to heap_create() Initialize all keyinfo members. storage/heap/hp_test2.c: Update call to heap_create() --- mysys/mf_keycache.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'mysys') diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 1fef8aac170..c81da9a469a 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -366,10 +366,11 @@ static inline uint next_power(uint value) */ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, - ulong use_mem, uint division_limit, + size_t use_mem, uint division_limit, uint age_threshold) { - uint blocks, hash_links, length; + ulong blocks, hash_links; + size_t length; int error; DBUG_ENTER("init_key_cache"); DBUG_ASSERT(key_cache_block_size >= 512); @@ -405,8 +406,8 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, DBUG_PRINT("info", ("key_cache_block_size: %u", key_cache_block_size)); - blocks= (uint) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) + - sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); + blocks= (ulong) (use_mem / (sizeof(BLOCK_LINK) + 2 * sizeof(HASH_LINK) + + sizeof(HASH_LINK*) * 5/4 + key_cache_block_size)); /* It doesn't make sense to have too few blocks (less than 8) */ if (blocks >= 8) { @@ -424,18 +425,18 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, ALIGN_SIZE(hash_links * sizeof(HASH_LINK)) + ALIGN_SIZE(sizeof(HASH_LINK*) * keycache->hash_entries))) + - ((ulong) blocks * keycache->key_cache_block_size) > use_mem) + ((size_t) blocks * keycache->key_cache_block_size) > use_mem) blocks--; /* Allocate memory for cache page buffers */ if ((keycache->block_mem= - my_large_malloc((ulong) blocks * keycache->key_cache_block_size, + my_large_malloc((size_t) blocks * keycache->key_cache_block_size, MYF(MY_WME)))) { /* Allocate memory for blocks, hash_links and hash entries; For each block 2 hash links are allocated */ - if ((keycache->block_root= (BLOCK_LINK*) my_malloc((uint) length, + if ((keycache->block_root= (BLOCK_LINK*) my_malloc(length, MYF(0)))) break; my_large_free(keycache->block_mem, MYF(0)); @@ -448,7 +449,7 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, } blocks= blocks / 4*3; } - keycache->blocks_unused= (ulong) blocks; + keycache->blocks_unused= blocks; keycache->disk_blocks= (int) blocks; keycache->hash_links= hash_links; keycache->hash_root= (HASH_LINK**) ((char*) keycache->block_root + @@ -556,7 +557,7 @@ err: */ int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, - ulong use_mem, uint division_limit, + size_t use_mem, uint division_limit, uint age_threshold) { int blocks; -- cgit v1.2.1 From b59217ebbbb9c2869ab914805729b3ca57c976fa Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 30 Jul 2007 11:33:50 +0300 Subject: Slow query log to file now displays queries with microsecond precission --long-query-time is now given in seconds with microseconds as decimals --min_examined_row_limit added for slow query log long_query_time user variable is now double with 6 decimals Added functions to get time in microseconds Added faster time() functions for system that has gethrtime() (Solaris) We now do less time() calls. Added field->in_read_set() and field->in_write_set() for easier field manipulation by handlers set_var.cc and my_getopt() can now handle DOUBLE variables. All time() calls changed to my_time() my_time() now does retry's if time() call fails. Added debug function for stopping in mysql_admin_table() when tables are locked Some trivial function and struct variable renames to avoid merge errors. Fixed compiler warnings Initialization of some time variables on windows moved to my_init() include/my_getopt.h: Added support for double arguments include/my_sys.h: Fixed wrong type to packfrm() Added new my_time functions include/mysql/plugin.h: Added support for DOUBLE libmysql/CMakeLists.txt: Added new time functions libmysql/Makefile.shared: Added new time functions mysql-test/r/variables.result: Testing of long_query_time mysql-test/t/variables.test: Testing of long_query_time mysys/charset.c: Fixed compiler warnings mysys/default_modify.c: Fixed compiler warnings mysys/hash.c: Fixed compiler warnings mysys/mf_getdate.c: Use my_time() mysys/mf_iocache2.c: Fixed compiler warnings mysys/mf_pack.c: Fixed compiler warnings mysys/mf_path.c: Fixed compiler warnings mysys/my_append.c: Fixed compiler warnings mysys/my_compress.c: Fixed compiler warnings mysys/my_copy.c: Fixed compiler warnings mysys/my_gethwaddr.c: Fixed compiler warnings mysys/my_getopt.c: Added support for double arguments mysys/my_getsystime.c: Added functions to get time in microseconds. Added faster time() functions for system that has gethrtime() (Solaris) Moved windows initialization code to my_init() mysys/my_init.c: Added initializing of variables needed for windows time functions mysys/my_static.c: Added variables needed for windows time functions mysys/my_static.h: Added variables needed for windows time functions mysys/my_thr_init.c: Added THR_LOCK_time, used for faster my_time() mysys/mysys_priv.h: Added THR_LOCK_time, used for faster my_time() mysys/thr_alarm.c: time() -> my_time() sql/event_data_objects.cc: end_time() -> set_current_time() sql/event_queue.cc: end_time() -> set_current_time() sql/event_scheduler.cc: Fixed compiler warnings sql/field.h: Added field->in_read_set() and field->in_write_set() for easier field manipulation by handlers sql/item.h: Added decimal to Item_float(double) sql/item_cmpfunc.h: Added decimal to Item_float(double) sql/item_timefunc.cc: time() -> my_time() sql/item_xmlfunc.cc: Fixed compiler warning sql/lock.cc: lock_time() -> set_time_after_lock() sql/log.cc: Timing in slow query log to file is now done in microseconds Changed some while() loops to for() loops. Fixed indentation time() -> my_time() sql/log.h: Slow query logging is now done based on microseconds sql/log_event.cc: time() -> my_time() Fixed arguments to new Item_float() sql/mysql_priv.h: Fixed compiler warnings Added opt_log_slow_slave_statements sql/mysqld.cc: Added --log_slow_slave_statements and --min_examined_row_limit --long-query-time now takes a double argument with microsecond resolution Don't write shutdown message when using --help Removed not needed \n Thread create time and connect time is now done in microseconds time() -> my_time() Avoid some time() calls sql/net_serv.cc: Fixed compiler warnings sql/parse_file.cc: time() -> my_time() sql/set_var.cc: Added support for DOUBLE variables Added support for variables that are given in seconds with microsecond resolution sql/set_var.h: Added support for variables that are given in seconds with microsecond resolution sql/slave.cc: Allow logging of slave queries to slow query log if 'opt_log_slow_slave_statements' is given time() -> my_time() sql/sql_cache.h: Fixed compiler warning() sql/sql_class.cc: Initialize new THD variables sql/sql_class.h: long_query_time is now in microseconds Added min_examined_row_limit Reordered some THD elements for higher efficency Added timers in microseconds (connect_utime, thr_create_utime, start_utime and utime_after_lock) Start of query is now recorded both in seconds and in microseconds. Following renames was made for more clarity and avoid merge problems from earlier versions: connect_time -> connect_utime thr_create_time -> thr_create_utime end_time() -> set_current_time() lock_time() -> set_time_after_lock() Added THD::start_utime, which is start of query in microseconds from some arbitary time Added function THD::current_utime() Removed safe_time() as retry's are handled in my_time() sql/sql_connect.cc: User resources are now using microsecond resolution sql/sql_insert.cc: end_time() -> set_current_time() sql-common/client.c: time() -> my_time() sql/sql_parse.cc: Testing if we should print to slow_query_log() is now done with microsecond precission. If min_examined_row_limit is given, only log queries to slow query log that has examined more rows than this. sql/sql_select.cc: Simplify code now that Item_float() takes decimals as argument sql/sql_show.cc: time() -> my_time() Added support for SYS_DOUBLE sql/sql_table.cc: Added debug function for stopping in mysql_admin_table() when tables are locked sql/structs.h: intime -> reset_utime --- mysys/charset.c | 8 +-- mysys/default_modify.c | 2 +- mysys/hash.c | 20 +++--- mysys/mf_getdate.c | 2 +- mysys/mf_iocache2.c | 14 ++-- mysys/mf_pack.c | 4 +- mysys/mf_path.c | 2 +- mysys/my_append.c | 15 ++-- mysys/my_compress.c | 13 ++-- mysys/my_copy.c | 6 +- mysys/my_gethwaddr.c | 2 +- mysys/my_getopt.c | 43 +++++++++++- mysys/my_getsystime.c | 186 ++++++++++++++++++++++++++++++++++++++++++++----- mysys/my_init.c | 22 ++++++ mysys/my_static.c | 5 ++ mysys/my_static.h | 2 + mysys/my_thr_init.c | 4 +- mysys/mysys_priv.h | 2 +- mysys/thr_alarm.c | 12 ++-- 19 files changed, 298 insertions(+), 66 deletions(-) (limited to 'mysys') diff --git a/mysys/charset.c b/mysys/charset.c index 1c81e480404..cc1a238f281 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -323,14 +323,14 @@ static int charset_initialized=0; static my_bool my_read_charset_file(const char *filename, myf myflags) { - char *buf; + uchar *buf; int fd; uint len, tmp_len; MY_STAT stat_info; if (!my_stat(filename, &stat_info, MYF(myflags)) || ((len= (uint)stat_info.st_size) > MY_MAX_ALLOWED_BUF) || - !(buf= (char *)my_malloc(len,myflags))) + !(buf= (uchar*) my_malloc(len,myflags))) return TRUE; if ((fd=my_open(filename,O_RDONLY,myflags)) < 0) @@ -340,7 +340,7 @@ static my_bool my_read_charset_file(const char *filename, myf myflags) if (tmp_len != len) goto error; - if (my_parse_charset_xml(buf,len,add_collation)) + if (my_parse_charset_xml((char*) buf,len,add_collation)) { #ifdef NOT_YET printf("ERROR at line %d pos %d '%s'\n", @@ -350,7 +350,7 @@ static my_bool my_read_charset_file(const char *filename, myf myflags) #endif } - my_free(buf, myflags); + my_free(buf, myflags); return FALSE; error: diff --git a/mysys/default_modify.c b/mysys/default_modify.c index b2a43f511b9..78f6105b071 100644 --- a/mysys/default_modify.c +++ b/mysys/default_modify.c @@ -218,7 +218,7 @@ int modify_defaults_file(const char *file_location, const char *option, if (my_chsize(fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0, MYF(MY_WME)) || my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) || - my_fwrite(cnf_file, file_buffer, (size_t) (dst_ptr - file_buffer), + my_fwrite(cnf_file, (uchar*) file_buffer, (size_t) (dst_ptr - file_buffer), MYF(MY_NABP))) goto err; } diff --git a/mysys/hash.c b/mysys/hash.c index 47ddc5aa97d..4532b06b533 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -137,7 +137,7 @@ void my_hash_reset(HASH *hash) DBUG_VOID_RETURN; } - /* some helper functions */ +/* some helper functions */ /* This function is char* instead of uchar* as HPUX11 compiler can't @@ -149,9 +149,9 @@ hash_key(const HASH *hash, const uchar *record, size_t *length, my_bool first) { if (hash->get_key) - return (*hash->get_key)(record,length,first); + return (char*) (*hash->get_key)(record,length,first); *length=hash->key_length; - return (uchar*) record+hash->key_offset; + return (char*) record+hash->key_offset; } /* Calculate pos according to keys */ @@ -313,12 +313,14 @@ my_bool my_hash_insert(HASH *info,const uchar *record) uchar *ptr_to_rec,*ptr_to_rec2; HASH_LINK *data,*empty,*gpos,*gpos2,*pos; - LINT_INIT(gpos); LINT_INIT(gpos2); - LINT_INIT(ptr_to_rec); LINT_INIT(ptr_to_rec2); + LINT_INIT(gpos); + LINT_INIT(gpos2); + LINT_INIT(ptr_to_rec); + LINT_INIT(ptr_to_rec2); if (HASH_UNIQUE & info->flags) { - char *key= (char*) hash_key(info, record, &idx, 1); + uchar *key= (uchar*) hash_key(info, record, &idx, 1); if (hash_search(info, key, idx)) return(TRUE); /* Duplicate entry */ } @@ -544,14 +546,16 @@ my_bool hash_update(HASH *hash, uchar *record, uchar *old_key, if (HASH_UNIQUE & hash->flags) { HASH_SEARCH_STATE state; - char *found, *new_key= hash_key(hash, record, &idx, 1); + uchar *found, *new_key= (uchar*) hash_key(hash, record, &idx, 1); if ((found= hash_first(hash, new_key, idx, &state))) + { do { - if (found != (char*) record) + if (found != record) DBUG_RETURN(1); /* Duplicate entry */ } while ((found= hash_next(hash, new_key, idx, &state))); + } } data=dynamic_element(&hash->array,0,HASH_LINK*); diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c index 2f08027a477..3a8e1be6a0b 100644 --- a/mysys/mf_getdate.c +++ b/mysys/mf_getdate.c @@ -42,7 +42,7 @@ void get_date(register char * to, int flag, time_t date) struct tm tm_tmp; #endif - skr=date ? (time_t) date : time((time_t*) 0); + skr=date ? (time_t) date : my_time(0); #if defined(HAVE_LOCALTIME_R) && defined(_REENTRANT) if (flag & GETDATE_GMT) localtime_r(&skr,&tm_tmp); diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index 8a5b91661c4..87ea995f518 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -246,7 +246,7 @@ size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length) for (;;) { - char *pos,*end; + uchar *pos, *end; if (length > max_length) length=max_length; for (pos=info->read_pos,end=pos+length ; pos < end ;) @@ -323,7 +323,7 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) length= (size_t) (fmt - start); out_length+=length; - if (my_b_write(info, start, length)) + if (my_b_write(info, (const uchar*) start, length)) goto err; if (*fmt == '\0') /* End of format */ @@ -378,14 +378,14 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) size_t length2 = strlen(par); /* TODO: implement minimum width and precision */ out_length+= length2; - if (my_b_write(info, par, length2)) + if (my_b_write(info, (uchar*) par, length2)) goto err; } else if (*fmt == 'b') /* Sized buffer parameter, only precision makes sense */ { char *par = va_arg(args, char *); out_length+= precision; - if (my_b_write(info, par, precision)) + if (my_b_write(info, (uchar*) par, precision)) goto err; } else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */ @@ -400,7 +400,7 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) else length2= (size_t) (int10_to_str((long) (uint) iarg,buff,10)- buff); out_length+= length2; - if (my_b_write(info, buff, length2)) + if (my_b_write(info, (uchar*) buff, length2)) goto err; } else if ((*fmt == 'l' && fmt[1] == 'd') || fmt[1] == 'u') @@ -416,13 +416,13 @@ size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) else length2= (size_t) (int10_to_str(iarg,buff,10)- buff); out_length+= length2; - if (my_b_write(info, buff, length2)) + if (my_b_write(info, (uchar*) buff, length2)) goto err; } else { /* %% or unknown code */ - if (my_b_write(info, backtrack, fmt-backtrack)) + if (my_b_write(info, (uchar*) backtrack, (size_t) (fmt-backtrack))) goto err; out_length+= fmt-backtrack; } diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index 99c0c959d94..a31b9595c85 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -56,7 +56,7 @@ void pack_dirname(char * to, const char *from) (buff_length == d_length && !bcmp(buff,start,d_length))) && *start != FN_LIBCHAR && *start) { /* Put current dir before */ - bchange(to,d_length,buff,buff_length,strlen(to)+1); + bchange((uchar*) to, d_length, (uchar*) buff, buff_length, strlen(to)+1); } } @@ -328,7 +328,7 @@ size_t unpack_dirname(char * to, const char *from) if (buff+h_length < suffix) bmove(buff+h_length,suffix,length); else - bmove_upp(buff+h_length+length,suffix+length,length); + bmove_upp((uchar*) buff+h_length+length, (uchar*) suffix+length, length); bmove(buff,tilde_expansion,h_length); } } diff --git a/mysys/mf_path.c b/mysys/mf_path.c index 7baded9d715..73e73cb7f76 100644 --- a/mysys/mf_path.c +++ b/mysys/mf_path.c @@ -46,7 +46,7 @@ char * my_path(char * to, const char *progname, if (!test_if_hard_path(to)) { if (!my_getwd(curr_dir,FN_REFLEN,MYF(0))) - bchange(to,0,curr_dir, (uint) strlen(curr_dir), (uint) strlen(to)+1); + bchange((uchar*) to, 0, (uchar*) curr_dir, strlen(curr_dir), strlen(to)+1); } } else diff --git a/mysys/my_append.c b/mysys/my_append.c index ddd3c91e832..35881a959d5 100644 --- a/mysys/my_append.c +++ b/mysys/my_append.c @@ -27,21 +27,22 @@ struct utimbuf { }; #endif - /* Append a file to another */ - -int my_append(const char *from, const char *to, myf MyFlags) +/* + Append a file to another + NOTES + Don't set MY_FNABP or MY_NABP bits on when calling this function +*/ - /* Dont set MY_FNABP or MY_NABP bits on - when calling this funktion */ +int my_append(const char *from, const char *to, myf MyFlags) { uint Count; File from_file,to_file; - char buff[IO_SIZE]; + uchar buff[IO_SIZE]; DBUG_ENTER("my_append"); DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags)); - from_file=to_file= -1; + from_file= to_file= -1; if ((from_file=my_open(from,O_RDONLY,MyFlags)) >= 0) { diff --git a/mysys/my_compress.c b/mysys/my_compress.c index d495a1c1c6d..bc9f8317487 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -154,17 +154,20 @@ my_bool my_uncompress(uchar *packet, size_t len, size_t *complen) SYNOPSIS packfrm() - data Data reference to frm file data + data Data reference to frm file data. len Length of frm file data out:pack_data Reference to the pointer to the packed frm data out:pack_len Length of packed frm file data + NOTES + data is replaced with compressed content + RETURN VALUES 0 Success >0 Failure */ -int packfrm(const uchar *data, size_t len, +int packfrm(uchar *data, size_t len, uchar **pack_data, size_t *pack_len) { int error; @@ -178,8 +181,8 @@ int packfrm(const uchar *data, size_t len, if (my_compress((uchar*)data, &org_len, &comp_len)) goto err; - DBUG_PRINT("info", ("org_len: %lu comp_len: %lu", org_len, comp_len)); - DBUG_DUMP("compressed", (char*)data, org_len); + DBUG_PRINT("info", ("org_len: %lu comp_len: %lu", (ulong) org_len, (ulong) comp_len)); + DBUG_DUMP("compressed", data, org_len); error= 2; blob_len= BLOB_HEADER + org_len; @@ -235,7 +238,7 @@ int unpackfrm(uchar **unpack_data, size_t *unpack_len, complen= uint4korr(pack_data+8); DBUG_PRINT("blob",("ver: %lu complen: %lu orglen: %lu", - ver, complen, orglen)); + ver, (ulong) complen, (ulong) orglen)); DBUG_DUMP("blob->data", pack_data + BLOB_HEADER, complen); if (ver != 1) diff --git a/mysys/my_copy.c b/mysys/my_copy.c index 3f8b0695a25..cd741b1eb52 100644 --- a/mysys/my_copy.c +++ b/mysys/my_copy.c @@ -54,7 +54,7 @@ int my_copy(const char *from, const char *to, myf MyFlags) my_bool new_file_stat= 0; /* 1 if we could stat "to" */ int create_flag; File from_file,to_file; - char buff[IO_SIZE]; + uchar buff[IO_SIZE]; MY_STAT stat_buff,new_stat_buff; DBUG_ENTER("my_copy"); DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags)); @@ -80,10 +80,12 @@ int my_copy(const char *from, const char *to, myf MyFlags) MyFlags)) < 0) goto err; - while ((Count=my_read(from_file,buff,IO_SIZE,MyFlags)) != 0) + while ((Count=my_read(from_file, buff, sizeof(buff), MyFlags)) != 0) + { if (Count == (uint) -1 || my_write(to_file,buff,Count,MYF(MyFlags | MY_NABP))) goto err; + } if (my_close(from_file,MyFlags) | my_close(to_file,MyFlags)) DBUG_RETURN(-1); /* Error on close */ diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c index 01abc02058b..845b5aa4152 100644 --- a/mysys/my_gethwaddr.c +++ b/mysys/my_gethwaddr.c @@ -19,7 +19,7 @@ #include "mysys_priv.h" #include -#ifndef MAIN +#if !defined(__FreeBSD__) || defined(__linux__) static my_bool memcpy_and_test(uchar *to, uchar *from, uint len) { uint i, res=1; diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 32a5452e451..3a5b130e067 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -32,6 +32,7 @@ my_bool getopt_compare_strings(const char *s, static longlong getopt_ll(char *arg, const struct my_option *optp, int *err); static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err); +static double getopt_double(char *arg, const struct my_option *optp, int *err); static void init_variables(const struct my_option *options); static int setval(const struct my_option *opts, uchar* *value, char *argument, my_bool set_maximum_value); @@ -611,6 +612,9 @@ static int setval(const struct my_option *opts, uchar* *value, char *argument, case GET_ULL: *((ulonglong*) result_pos)= getopt_ull(argument, opts, &err); break; + case GET_DOUBLE: + *((double*) result_pos)= getopt_double(argument, opts, &err); + break; case GET_STR: *((char**) result_pos)= argument; break; @@ -720,7 +724,7 @@ my_bool getopt_compare_strings(register const char *s, register const char *t, be k|K for kilo, m|M for mega or g|G for giga. */ -static longlong eval_num_suffix (char *argument, int *error, char *option_name) +static longlong eval_num_suffix(char *argument, int *error, char *option_name) { char *endchar; longlong num; @@ -801,6 +805,37 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp) } +/* + Get double value withing ranges + + Evaluates and returns the value that user gave as an argument to a variable. + + RETURN + decimal value of arg + + In case of an error, prints an error message and sets *err to + EXIT_ARGUMENT_INVALID. Otherwise err is not touched +*/ + +static double getopt_double(char *arg, const struct my_option *optp, int *err) +{ + double num; + int error; + char *end= arg + 1000; /* Big enough as *arg is \0 terminated */ + num= my_strtod(arg, &end, &error); + if (end[0] != 0 || error) + { + fprintf(stderr, + "%s: ERROR: Invalid decimal value for option '%s'\n", + my_progname, optp->name); + *err= EXIT_ARGUMENT_INVALID; + return 0.0; + } + if (optp->max_value && num > (double) optp->max_value) + num= (double) optp->max_value; + return max(num, (double) optp->min_value); +} + /* Init one value to it's default values @@ -838,6 +873,9 @@ static void init_one_value(const struct my_option *option, uchar* *variable, case GET_SET: *((ulonglong*) variable)= (ulonglong) value; break; + case GET_DOUBLE: + *((double*) variable)= (double) value; + break; case GET_STR: /* Do not clear variable value if it has no default value. @@ -1052,6 +1090,9 @@ void my_print_variables(const struct my_option *options) longlong2str(*((ulonglong*) value), buff, 10); printf("%s\n", buff); break; + case GET_DOUBLE: + printf("%g\n", *(double*) value); + break; default: printf("(Disabled)\n"); break; diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c index 2fd7eed7778..17ba1232d7a 100644 --- a/mysys/my_getsystime.c +++ b/mysys/my_getsystime.c @@ -29,28 +29,17 @@ ulonglong my_getsystime() clock_gettime(CLOCK_REALTIME, &tp); return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100; #elif defined(__WIN__) -#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10) - static __int64 offset=0, freq; LARGE_INTEGER t_cnt; - if (!offset) + struct timeval tv; + if (query_performance_frequency) { - /* strictly speaking there should be a mutex to protect - initialization section. But my_getsystime() is called from - UUID() code, and UUID() calls are serialized with a mutex anyway - */ - LARGE_INTEGER li; - FILETIME ft; - GetSystemTimeAsFileTime(&ft); - li.LowPart=ft.dwLowDateTime; - li.HighPart=ft.dwHighDateTime; - offset=li.QuadPart-OFFSET_TO_EPOC; - QueryPerformanceFrequency(&li); - freq=li.QuadPart; QueryPerformanceCounter(&t_cnt); - offset-=t_cnt.QuadPart/freq*10000000+t_cnt.QuadPart%freq*10000000/freq; + return (t_cnt.QuadPart / query_performance_frequency * 10000000+ + t_cnt.QuadPart % query_performance_frequency * 10000000/ + query_performance_frequency+query_performance_offset); } - QueryPerformanceCounter(&t_cnt); - return t_cnt.QuadPart/freq*10000000+t_cnt.QuadPart%freq*10000000/freq+offset; + gettimeofday(&tv,NULL); + return (ulonglong)tv.tv_sec*10000000+(ulonglong)tv.tv_usec*10; #elif defined(__NETWARE__) NXTime_t tm; NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm); @@ -62,3 +51,164 @@ ulonglong my_getsystime() return (ulonglong)tv.tv_sec*10000000+(ulonglong)tv.tv_usec*10; #endif } + + +/* + Return current time + + SYNOPSIS + my_time() + flags If MY_WME is set, write error if time call fails + +*/ + +#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */ + +time_t my_time(myf flags __attribute__((unused))) +{ +#ifdef HAVE_GETHRTIME + static hrtime_t prev_gethrtime= 0; + static time_t cur_time= 0; + + hrtime_t cur_gethrtime; + pthread_mutex_lock(&THR_LOCK_time); + cur_gethrtime= gethrtime(); + if ((prev_gethrtime - cur_gethrtime) > DELTA_FOR_SECONDS) + { + cur_time= time(0); + prev_gethrtime= cur_gethrtime; + } + pthread_mutex_unlock(&THR_LOCK_time); + return cur_time; +#else + time_t t; + /* The following loop is here beacuse time() may fail on some systems */ + while ((t= time(0)) == (time_t) -1) + { + if (flags & MY_WME) + fprintf(stderr, "%s: Warning: time() call failed\n", my_progname); + } + return t; +#endif +} + + +/* + Return time in micro seconds + + SYNOPSIS + my_micro_time() + + NOTES + This function is to be used to measure performance in micro seconds. + As it's not defined whats the start time for the clock, this function + us only useful to measure time between two moments. + + For windows platforms we need the frequency value of the CUP. This is + initalized in my_init.c through QueryPerformanceFrequency(). + + If Windows platform doesn't support QueryPerformanceFrequency() we will + obtain the time via GetClockCount, which only supports milliseconds. + + RETURN + Value in microseconds from some undefined point in time +*/ + +ulonglong my_micro_time() +{ + ulonglong newtime; +#if defined(__WIN__) + if (query_performance_frequency) + { + QueryPerformanceCounter(&newtime); + newtime/= (query_performance_frequency * 1000000); + } + else + newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */ +#elif defined(HAVE_GETHRTIME) + return gethrtime()/1000; +#else + struct timeval t; + /* The following loop is here because gettimeofday may fail on some systems */ + while (gettimeofday(&t, NULL) != 0) + {} + newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec; +#endif /* defined(__WIN__) */ + return newtime; +} + + +/* + Return time in seconds and timer in microseconds + + SYNOPSIS + my_micro_time_and_time() + time_arg Will be set to seconds since epoch (00:00:00 UTC, January 1, + 1970) + + NOTES + This function is to be useful when we need both the time and microtime. + For example in MySQL this is used to get the query time start of a query and + to measure the time of a query (for the slow query log) + + IMPLEMENTATION + Same as my_micro_time() + + RETURN + Value in microseconds from some undefined point in time +*/ + +ulonglong my_micro_time_and_time(time_t *time_arg) +{ + ulonglong newtime; +#if defined(__WIN__) + if (query_performance_frequency) + { + QueryPerformanceCounter((LARGE_INTEGER *) &newtime); + newtime/= (query_performance_frequency * 1000000); + } + else + newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */ + (void) time(time_arg); +#else + struct timeval t; + /* The following loop is here because gettimeofday may fail on some systems */ + while (gettimeofday(&t, NULL) != 0) + {} + *time_arg= t.tv_sec; + newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec; +#endif /* defined(__WIN__) */ + return newtime; +} + + +/* + Returns current time + + SYNOPSIS + my_time_possible_from_micro() + microtime Value from very recent my_micro_time() + + NOTES + This function returns the current time. The microtime argument is only used + if my_micro_time() uses a function that can safely be converted to the current + time. + + RETURN + current time +*/ + +time_t my_time_possible_from_micro(ulonglong microtime __attribute__((unused))) +{ +#if defined(__WIN__) + time_t t; + while ((t= time(0)) == (time_t) -1) + {} + return t; +#elif defined(HAVE_GETHRTIME) + return my_time(0); /* Cached time */ +#else + return (time_t) (microtime / 1000000); +#endif /* defined(__WIN__) */ +} + diff --git a/mysys/my_init.c b/mysys/my_init.c index c1337205eb4..8281d7ced99 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -371,6 +371,28 @@ static void my_win_init(void) /* chiude la chiave */ RegCloseKey(hSoftMysql) ; + + /* The following is used by time functions */ +#define OFFSET_TO_EPOC ((__int64) 134774 * 24 * 60 * 60 * 1000 * 1000 * 10) +#define MS 10000000 + { + FILETIME ft; + LARGE_INTEGER li, t_cnt; + DBUG_ASSERT(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency)); + if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency)) + query_performance_frequency= 0; + else + { + GetSystemTimeAsFileTime(&ft); + li.LowPart= ft.dwLowDateTime; + li.HighPart= ft.dwHighDateTime; + query_performance_offset= li.QuadPart-OFFSET_TO_EPOC; + QueryPerformanceCounter(&t_cnt); + query_performance_offset-= (t_cnt.QuadPart / query_performance_frequency * MS + + t_cnt.QuadPart % query_performance_frequency * MS / + query_performance_frequency); + } + } DBUG_VOID_RETURN ; } diff --git a/mysys/my_static.c b/mysys/my_static.c index 472cf3b5084..92c959c4c6c 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -93,6 +93,11 @@ int (*error_handler_hook)(uint error,const char *str,myf MyFlags)= int (*fatal_error_handler_hook)(uint error,const char *str,myf MyFlags)= my_message_no_curses; +#ifdef __WIN__ +/* from my_getsystime.c */ +ulonglong query_performance_frequency, query_performance_offset; +#endif + /* How to disable options */ my_bool NEAR my_disable_locking=0; my_bool NEAR my_disable_async_io=0; diff --git a/mysys/my_static.h b/mysys/my_static.h index 66e6ea1c280..0eca196c1c9 100644 --- a/mysys/my_static.h +++ b/mysys/my_static.h @@ -66,6 +66,8 @@ extern struct st_irem *sf_malloc_root; extern struct st_my_file_info my_file_info_default[MY_NFILE]; +extern ulonglong query_performance_frequency, query_performance_offset; + #if defined(THREAD) && !defined(__WIN__) extern sigset_t my_signals; /* signals blocked by mf_brkhant */ #endif diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index cc33ac3f21c..8b935c895c8 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -30,7 +30,7 @@ pthread_key(struct st_my_thread_var, THR_KEY_mysys); #endif /* USE_TLS */ pthread_mutex_t THR_LOCK_malloc,THR_LOCK_open, THR_LOCK_lock,THR_LOCK_isam,THR_LOCK_myisam,THR_LOCK_heap, - THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads; + THR_LOCK_net, THR_LOCK_charset, THR_LOCK_threads, THR_LOCK_time; pthread_cond_t THR_COND_threads; uint THR_thread_count= 0; uint my_thread_end_wait_time= 5; @@ -146,6 +146,7 @@ my_bool my_thread_global_init(void) pthread_mutex_init(&THR_LOCK_net,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_charset,MY_MUTEX_INIT_FAST); pthread_mutex_init(&THR_LOCK_threads,MY_MUTEX_INIT_FAST); + pthread_mutex_init(&THR_LOCK_time,MY_MUTEX_INIT_FAST); pthread_cond_init(&THR_COND_threads, NULL); #if defined( __WIN__) || defined(OS2) win_pthread_init(); @@ -202,6 +203,7 @@ void my_thread_global_end(void) pthread_mutex_destroy(&THR_LOCK_myisam); pthread_mutex_destroy(&THR_LOCK_heap); pthread_mutex_destroy(&THR_LOCK_net); + pthread_mutex_destroy(&THR_LOCK_time); pthread_mutex_destroy(&THR_LOCK_charset); if (all_threads_killed) { diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h index 709cfed969a..6e0959ae08c 100644 --- a/mysys/mysys_priv.h +++ b/mysys/mysys_priv.h @@ -28,7 +28,7 @@ #include extern pthread_mutex_t THR_LOCK_malloc, THR_LOCK_open, THR_LOCK_keycache; extern pthread_mutex_t THR_LOCK_lock, THR_LOCK_isam, THR_LOCK_net; -extern pthread_mutex_t THR_LOCK_charset; +extern pthread_mutex_t THR_LOCK_charset, THR_LOCK_time; #else #include #endif diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 81093be3678..2934e724724 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -157,7 +157,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data) DBUG_ENTER("thr_alarm"); DBUG_PRINT("enter",("thread: %s sec: %d",my_thread_name(),sec)); - now=(ulong) time((time_t*) 0); + now=(ulong) my_time(0); pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask); pthread_mutex_lock(&LOCK_alarm); /* Lock from threads & alarms */ if (alarm_aborted > 0) @@ -351,7 +351,7 @@ static sig_handler process_alarm_part2(int sig __attribute__((unused))) } else { - ulong now=(ulong) time((time_t*) 0); + ulong now=(ulong) my_time(0); ulong next=now+10-(now%10); while ((alarm_data=(ALARM*) queue_top(&alarm_queue))->expire_time <= now) { @@ -480,7 +480,7 @@ void thr_alarm_info(ALARM_INFO *info) info->max_used_alarms= max_used_alarms; if ((info->active_alarms= alarm_queue.elements)) { - ulong now=(ulong) time((time_t*) 0); + ulong now=(ulong) my_time(0); long time_diff; ALARM *alarm_data= (ALARM*) queue_top(&alarm_queue); time_diff= (long) (alarm_data->expire_time - now); @@ -528,7 +528,7 @@ static void *alarm_handler(void *arg __attribute__((unused))) { if (alarm_queue.elements) { - ulong sleep_time,now=time((time_t*) 0); + ulong sleep_time,now= my_time(0); if (alarm_aborted) sleep_time=now+1; else @@ -685,7 +685,7 @@ static void *test_thread(void *arg) for (i=1 ; i <= 10 ; i++) { wait_time=param ? 11-i : i; - start_time=time((time_t*) 0); + start_time= my_time(0); if (thr_alarm(&got_alarm,wait_time,0)) { printf("Thread: %s Alarms aborted\n",my_thread_name()); @@ -747,7 +747,7 @@ static void *test_thread(void *arg) } } printf("Thread: %s Slept for %d (%d) sec\n",my_thread_name(), - (int) (time((time_t*) 0)-start_time), wait_time); fflush(stdout); + (int) (my_time(0)-start_time), wait_time); fflush(stdout); thr_end_alarm(&got_alarm); fflush(stdout); } -- cgit v1.2.1 From a250e2b453475694451b0553622a9a6ab330e1a6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 31 Jul 2007 19:35:13 +0200 Subject: Fix a bad BitKeeper dependency structure for the "CMakeLists.txt" files. They had been introduced in 5.1 and were only later backported to 5.0; as a consequence, the files in the 5.1 tree do not depend on the 5.0 ones, and changes in 5.0 do not propagate into the 5.1 files. To fix this, the (previous) files in 5.1 now are deleted ("bk rm"), and the previously deleted files depending on 5.0 are now moved to the respective source directories ("bk mv"). The current 5.1 contents is restored in these files. If you need the previous history of the 5.1 files ("bk revtool"), access those in "BitKeeper/deleted". Contrary to the original plan, I did not introduce the name "CMakeLists.historic" - mostly in order not to clutter the source tree. This fixes bug#29982. BitKeeper/deleted/.del-CMakeLists.txt~2eb9019b: Delete: client/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~5b8836e4: Delete: CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~93f0d646: Delete: dbug/CMakeLists.txt dbug/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~9 -> dbug/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~57492bba: Delete: extra/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~8c35983c: Delete: extra/yassl/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~c3563d5f: Delete: extra/yassl/taocrypt/CMakeLists.txt extra/yassl/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~11 -> extra/yassl/CMakeLists.txt extra/yassl/taocrypt/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~12 -> extra/yassl/taocrypt/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~99a50df6: Delete: libmysql/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~86a68ea1: Delete: mysys/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~9e206e11: Delete: regex/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~95969b72: Delete: server-tools/instance-manager/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~fdec1f01: Delete: sql/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~1960eb07: Delete: storage/innobase/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~96726c3b: Delete: storage/myisam/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~bb293bb4: Delete: storage/heap/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~5fa65a12: Delete: strings/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~fb3a3a47: Delete: storage/myisammrg/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~fc201a06: Delete: tests/CMakeLists.txt tests/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~5 -> tests/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~2a609d33: Delete: vio/CMakeLists.txt vio/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~6 -> vio/CMakeLists.txt BitKeeper/deleted/.del-CMakeLists.txt~ef945345: Delete: zlib/CMakeLists.txt zlib/CMakeLists.txt: Rename: BitKeeper/deleted/.del-CMakeLists.txt~8 -> zlib/CMakeLists.txt CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". client/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". extra/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". libmysql/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". mysys/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". regex/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". server-tools/instance-manager/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". sql/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". storage/heap/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". storage/innobase/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". storage/myisam/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". storage/myisammrg/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". strings/CMakeLists.txt: Restore the current 5.1 contents into the 5.0-dependent file. For the previous 5.1 history of this file, see the one in "BitKeeper/deleted". --- mysys/CMakeLists.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 mysys/CMakeLists.txt (limited to 'mysys') diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt old mode 100644 new mode 100755 -- cgit v1.2.1 From 0c9a3e597d329c5475d4fec0a6f95ac87d65ca19 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 1 Aug 2007 22:59:05 +0300 Subject: Fixes Bug#30127: --debug-info no longer prints memory usage in mysql Fixed compiler warnings, errors and link errors Fixed new bug on Solaris with gethrtime() Added --debug-check option to all mysql clients to print errors and memory leaks Added --debug-info to all clients. This now works as --debug-check but also prints memory and cpu usage BUILD/compile-solaris-sparc-debug: Remove old cpu options client/client_priv.h: Added OPT_DBUG_CHECK client/mysql.cc: --debug-info now prints memory usage Added --debug-check client/mysql_upgrade.c: --debug-info now prints memory usage Added --debug-check client/mysqladmin.cc: --debug-info now prints memory usage Added --debug-check client/mysqlbinlog.cc: --debug-info now prints memory usage Added --debug-check client/mysqlcheck.c: --debug-info now prints memory usage Added --debug-check client/mysqldump.c: --debug-info now prints memory usage Added --debug-check client/mysqlimport.c: --debug-info now prints memory usage Added --debug-check client/mysqlshow.c: --debug-info now prints memory usage Added --debug-check client/mysqlslap.c: --debug-info now prints memory usage Added --debug-check client/mysqltest.c: --debug-info now prints memory usage Added --debug-check include/my_sys.h: Added extra option to TERMINATE to not print statistics libmysql/libmysql.c: Fixed compiler warning mysql-test/mysql-test-run.pl: --debug-info -> --debug-check to not print memory usage mysys/my_getsystime.c: Moved fast time calculation to my_micro_time_and_time() Fixed bug in previous push related to HAVE_GETHRTIME mysys/my_init.c: Print not freed memory in my_end() if MY_CHECK_ERROR is given mysys/my_static.c: Cleanup mysys/safemalloc.c: Added extra option to TERMINATE to not print statistics sql/item_xmlfunc.cc: Fixed compiler warning sql/sql_test.cc: Fixed TERMINATE() call unittest/mysys/base64-t.c: Fixed link error unittest/mysys/bitmap-t.c: Fixed link error unittest/mysys/my_atomic-t.c: Fixed link error --- mysys/my_getsystime.c | 68 ++++++++++++++++++++++++++++++--------------------- mysys/my_init.c | 11 ++++++--- mysys/my_static.c | 2 -- mysys/safemalloc.c | 18 ++++++++------ 4 files changed, 58 insertions(+), 41 deletions(-) (limited to 'mysys') diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c index 17ba1232d7a..43bb6c08af9 100644 --- a/mysys/my_getsystime.c +++ b/mysys/my_getsystime.c @@ -17,11 +17,13 @@ /* thus to get the current time we should use the system function with the highest possible resolution */ +#include "mysys_priv.h" +#include "my_static.h" + #ifdef __NETWARE__ #include #endif -#include "mysys_priv.h" ulonglong my_getsystime() { #ifdef HAVE_CLOCK_GETTIME @@ -30,7 +32,6 @@ ulonglong my_getsystime() return (ulonglong)tp.tv_sec*10000000+(ulonglong)tp.tv_nsec/100; #elif defined(__WIN__) LARGE_INTEGER t_cnt; - struct timeval tv; if (query_performance_frequency) { QueryPerformanceCounter(&t_cnt); @@ -38,8 +39,7 @@ ulonglong my_getsystime() t_cnt.QuadPart % query_performance_frequency * 10000000/ query_performance_frequency+query_performance_offset); } - gettimeofday(&tv,NULL); - return (ulonglong)tv.tv_sec*10000000+(ulonglong)tv.tv_usec*10; + return 0; #elif defined(__NETWARE__) NXTime_t tm; NXGetTime(NX_SINCE_1970, NX_NSECONDS, &tm); @@ -62,26 +62,13 @@ ulonglong my_getsystime() */ -#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */ - time_t my_time(myf flags __attribute__((unused))) { + time_t t; #ifdef HAVE_GETHRTIME - static hrtime_t prev_gethrtime= 0; - static time_t cur_time= 0; - - hrtime_t cur_gethrtime; - pthread_mutex_lock(&THR_LOCK_time); - cur_gethrtime= gethrtime(); - if ((prev_gethrtime - cur_gethrtime) > DELTA_FOR_SECONDS) - { - cur_time= time(0); - prev_gethrtime= cur_gethrtime; - } - pthread_mutex_unlock(&THR_LOCK_time); - return cur_time; + (void) my_micro_time_and_time(&t); + return t; #else - time_t t; /* The following loop is here beacuse time() may fail on some systems */ while ((t= time(0)) == (time_t) -1) { @@ -120,11 +107,12 @@ ulonglong my_micro_time() #if defined(__WIN__) if (query_performance_frequency) { - QueryPerformanceCounter(&newtime); + QueryPerformanceCounter((LARGE_INTEGER*) &newtime); newtime/= (query_performance_frequency * 1000000); } else - newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */ + newtime= (GetTickCount() * 1000); /* GetTickCount only returns milliseconds */ + return newtime; #elif defined(HAVE_GETHRTIME) return gethrtime()/1000; #else @@ -133,13 +121,13 @@ ulonglong my_micro_time() while (gettimeofday(&t, NULL) != 0) {} newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec; -#endif /* defined(__WIN__) */ return newtime; +#endif /* defined(__WIN__) */ } /* - Return time in seconds and timer in microseconds + Return time in seconds and timer in microseconds (not different start!) SYNOPSIS my_micro_time_and_time() @@ -152,24 +140,48 @@ ulonglong my_micro_time() to measure the time of a query (for the slow query log) IMPLEMENTATION - Same as my_micro_time() + Value of time is as in time() call. + Value of microtime is same as my_micro_time(), which may be totally unrealated + to time() RETURN Value in microseconds from some undefined point in time */ +#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */ + ulonglong my_micro_time_and_time(time_t *time_arg) { ulonglong newtime; #if defined(__WIN__) if (query_performance_frequency) { - QueryPerformanceCounter((LARGE_INTEGER *) &newtime); + QueryPerformanceCounter((LARGE_INTEGER*) &newtime); newtime/= (query_performance_frequency * 1000000); } else - newtime= (GetTickCount() * 1000; /* GetTickCount only returns milliseconds */ + newtime= (GetTickCount() * 1000); /* GetTickCount only returns milliseconds */ (void) time(time_arg); + return newtime; +#elif defined(HAVE_GETHRTIME) + /* + Solaris has a very slow time() call. We optimize this by using the very fast + gethrtime() call and only calling time() every 1/2 second + */ + static hrtime_t prev_gethrtime= 0; + static time_t cur_time= 0; + hrtime_t cur_gethrtime; + + pthread_mutex_lock(&THR_LOCK_time); + cur_gethrtime= gethrtime(); + if ((cur_gethrtime - prev_gethrtime) > DELTA_FOR_SECONDS) + { + cur_time= time(0); + prev_gethrtime= cur_gethrtime; + } + *time_arg= cur_time; + pthread_mutex_unlock(&THR_LOCK_time); + return cur_gethrtime/1000; #else struct timeval t; /* The following loop is here because gettimeofday may fail on some systems */ @@ -177,8 +189,8 @@ ulonglong my_micro_time_and_time(time_t *time_arg) {} *time_arg= t.tv_sec; newtime= (ulonglong)t.tv_sec * 1000000 + t.tv_usec; -#endif /* defined(__WIN__) */ return newtime; +#endif /* defined(__WIN__) */ } diff --git a/mysys/my_init.c b/mysys/my_init.c index 8281d7ced99..127e94c958b 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -130,8 +130,9 @@ void my_end(int infoflag) */ FILE *info_file= DBUG_FILE; my_bool print_info= (info_file != stderr); - /* We do not use DBUG_ENTER here, as after cleanup DBUG is no longer - operational, so we cannot use DBUG_RETURN. + /* + We do not use DBUG_ENTER here, as after cleanup DBUG is no longer + operational, so we cannot use DBUG_RETURN. */ DBUG_PRINT("info",("Shutting down")); if (!info_file) @@ -185,7 +186,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC); #endif #if defined(SAFEMALLOC) - TERMINATE(stderr); /* Give statistic on screen */ + TERMINATE(stderr, 1); /* Give statistic on screen */ #elif defined(__WIN__) && defined(_MSC_VER) _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR ); @@ -197,6 +198,10 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", _CrtDumpMemoryLeaks(); #endif } + else if (infoflag & MY_CHECK_ERROR) + { + TERMINATE(stderr, 0); /* Print memory leaks on screen */ + } if (!(infoflag & MY_DONT_FREE_DBUG)) { diff --git a/mysys/my_static.c b/mysys/my_static.c index 92c959c4c6c..b8bff0e9810 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -18,11 +18,9 @@ a shared library */ -#if !defined(stdin) #include "mysys_priv.h" #include "my_static.h" #include "my_alarm.h" -#endif my_bool timed_mutexes= 0; diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index 30c501c54ee..7a2f448b2dc 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -51,7 +51,7 @@ (equivalent to realloc()) FREE( pPtr ) Free memory allocated by NEW (equivalent to free()) - TERMINATE(file) End system, report errors and stats on file + TERMINATE(file,flag) End system, report errors and stats on file I personally use two more functions, but have not included them here: char *STRSAVE( sPtr ) Save a copy of the string in dynamic memory char *RENEW( pPtr, uSize ) @@ -352,12 +352,15 @@ static int check_ptr(const char *where, uchar *ptr, const char *filename, /* - TERMINATE(FILE *file) - Report on all the memory pieces that have not been - free'ed as well as the statistics. + Report on all the memory pieces that have not been free'ed + + SYNOPSIS + TERMINATE() + file Write output to this file + flag If <> 0, also write statistics */ -void TERMINATE(FILE *file) +void TERMINATE(FILE *file, uint flag) { struct st_irem *irem; DBUG_ENTER("TERMINATE"); @@ -373,8 +376,7 @@ void TERMINATE(FILE *file) { if (file) { - fprintf(file, "Warning: Not freed memory segments: %u\n", - sf_malloc_count); + fprintf(file, "Warning: Not freed memory segments: %u\n", sf_malloc_count); (void) fflush(file); } DBUG_PRINT("safe",("sf_malloc_count: %u", sf_malloc_count)); @@ -414,7 +416,7 @@ void TERMINATE(FILE *file) } } /* Report the memory usage statistics */ - if (file) + if (file && flag) { fprintf(file, "Maximum memory usage: %ld bytes (%ldk)\n", sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L); -- cgit v1.2.1 From f9ea427508fa5451bd22c0d6366a855a4d88800d Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 07:49:29 +0300 Subject: Set --debug-check if one uses DBUG_PUSH in all clients Fixed bug in query cache that made it impossible to run mysqld with --debug Fixed memory leaks in mysqldump and mysqltest Memory leaks associated with wrong usage of mysqltest is not fixed. To find these, run mysql-test-run --debug mysqltest client/mysql_upgrade.c: Set --debug-check if one uses DBUG_PUSH client/mysqlcheck.c: Set --debug-check if one uses DBUG_PUSH client/mysqldump.c: Set --debug-check if one uses DBUG_PUSH Fixed several memory leaks client/mysqlimport.c: Set --debug-check if one uses DBUG_PUSH client/mysqlshow.c: Set --debug-check if one uses DBUG_PUSH client/mysqlslap.c: Set --debug-check if one uses DBUG_PUSH client/mysqltest.c: Set --debug-check if one uses DBUG_PUSH Fixed some memory leaks Removed MY_CHECK_ERROR argument to my_end() as mysqltest.test otherwise shows MANY memory leaks dbug/dbug.c: Fixed compiler warning Force flush of out_file on end Removed some wrong dbug_flush(0) commands that could cause crashes mysys/my_init.c: Don't write memory usage if MY_GIVE_INFO is not given sql/sql_cache.cc: Fixed bug in query cache that made it impossible to run mysqld with --debug --- mysys/my_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mysys') diff --git a/mysys/my_init.c b/mysys/my_init.c index 127e94c958b..257edb351b4 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -134,14 +134,14 @@ void my_end(int infoflag) We do not use DBUG_ENTER here, as after cleanup DBUG is no longer operational, so we cannot use DBUG_RETURN. */ - DBUG_PRINT("info",("Shutting down")); + DBUG_PRINT("info",("Shutting down: infoflag: %d print_info: %d", + infoflag, print_info)); if (!info_file) { info_file= stderr; print_info= 0; } - DBUG_PRINT("info",("Shutting down: print_info: %d", print_info)); if ((infoflag & MY_CHECK_ERROR) || print_info) { /* Test if some file is left open */ @@ -186,7 +186,7 @@ Voluntary context switches %ld, Involuntary context switches %ld\n", fprintf(info_file,"\nRun time: %.1f\n",(double) clock()/CLOCKS_PER_SEC); #endif #if defined(SAFEMALLOC) - TERMINATE(stderr, 1); /* Give statistic on screen */ + TERMINATE(stderr, (infoflag & MY_GIVE_INFO) != 0); #elif defined(__WIN__) && defined(_MSC_VER) _CrtSetReportMode( _CRT_WARN, _CRTDBG_MODE_FILE ); _CrtSetReportFile( _CRT_WARN, _CRTDBG_FILE_STDERR ); -- cgit v1.2.1 From def8d6b36399708c7e1dd28d13178b303ed14d14 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 2 Aug 2007 12:49:27 +0200 Subject: CMakeLists.txt (several), make_win_bin_dist: Aligned client library build and use with the Unix version when it comes to what source to include directly in the builds, and what libraries to link with (bug#30118). Also reviewed, corrected and made more clear when static or dynamic Thread Local Storage is to be used. Some code duplication was removed, and some redundant library usage were removed, reducing the risk of incorrect TLS usage. client/CMakeLists.txt: - Removed code duplication by moving build of "mysqlclient" to the "libmysql" directory - Link clients with the new "mysqlclient_notls", to protect for the case the clients use more than the client API, and access thread data directly. - Synced explicit target addition of sources with Unix. dbug/CMakeLists.txt: No need to set CXX flags, no C++ code libmysql/CMakeLists.txt: - Aligned more with Unix version when it comes to included source files - Build both DLL and static library in this directory - Produce separe static TLS version of the static client library, for use when building clients in this build that might access TLS storage directly. mysys/CMakeLists.txt: We only have to build the static TLS version, as no clients are linking directly with the "mysys" library. scripts/make_win_bin_dist: Ajusted paths to new "mysqlclient.lib" location in source tree sql/CMakeLists.txt: Removed duplicate "ha_blackhole.cc" in file listing Removed explicit link to "dbug.lib" not needed Link with the static TLS "mysqlclient_notls" tests/CMakeLists.txt: Removed explicit link to "dbug", "mysys", "yassl", "taocrypt" and "zlib" not needed. Added explicit source addition "../mysys/my_memmem.c". No need for setting CXX flags, no C++ code. Use the static TLS "mysqlclient_notls" for linkage. zlib/CMakeLists.txt: No need for a dynamic TLS version of this library, no access to thread storage is done from it. Also no need to define MYSQL_CLIENT, not used, or __WIN32__ that is handled by the library header without this define. --- mysys/CMakeLists.txt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'mysys') diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 608d7cb1ce9..4c11b57d736 100755 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -16,17 +16,13 @@ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -# Need to set USE_TLS, since mysys is linked into libmysql.dll and -# libmysqld.dll, and __declspec(thread) approach to thread local storage does -# not work properly in DLLs. -# Currently, USE_TLS crashes in Debug builds, so until that is fixed Debug -# .dlls cannot be loaded at runtime. -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DUSE_TLS") -SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DUSE_TLS") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DUSE_TLS") -SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DUSE_TLS") +# Only the server link with this library, the client libraries and the client +# executables all link with recompiles of source found in the "mysys" directory. +# So we only need to create one version of this library, with the "static" +# Thread Local Storage model. INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys ) + ADD_LIBRARY(mysys array.c charset-def.c charset.c checksum.c default.c default_modify.c errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c -- cgit v1.2.1 From c28ca5e2e2c2917536fd2e0b857d67aad114004d Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 11:06:53 +0200 Subject: Re-apply fixes originally made by Kent, they got lost because of a merge conflict with the CMakeLists.txt dependency fix (numer 29982 in our bugs DB). These changes are for bug#30118. client/CMakeLists.txt: Manual merge from 5.0 (bug#30118) libmysql/CMakeLists.txt: Manual merge from 5.0 (bug#30118) mysys/CMakeLists.txt: Manual merge from 5.0 (bug#30118) sql/CMakeLists.txt: Added missing '${MYSQLD_EXE_SUFFIX}' to "mysqld" targets new in 5.1 zlib/CMakeLists.txt: Manual merge from 5.0 (bug#30118) --- mysys/CMakeLists.txt | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'mysys') diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 1ae625c4c03..08279eda00c 100755 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -13,18 +13,23 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") -# Need to set USE_TLS, since mysys is linked into libmysql.dll and -# libmysqld.dll, and __declspec(thread) approach to thread local storage does -# not work properly in DLLs. -# Currently, USE_TLS crashes in Debug builds, so until that is fixed Debug -# .dlls cannot be loaded at runtime. -SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DUSE_TLS") -SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DUSE_TLS") +# Only the server link with this library, the client libraries and the client +# executables all link with recompiles of source found in the "mysys" directory. +# So we only need to create one version of this library, with the "static" +# Thread Local Storage model. +# +# Exception is the embedded server that needs this library compiled with +# dynamic TLS, i.e. define USE_TLS + +IF(EMBEDDED_ONLY) + ADD_DEFINITIONS(-DUSE_TLS) + ADD_DEFINITIONS(-DEMBEDDED_LIBRARY) +ENDIF(EMBEDDED_ONLY) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include) + ADD_LIBRARY(mysys array.c charset-def.c charset.c checksum.c default.c default_modify.c errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c -- cgit v1.2.1 From 29bd01e6c11c0d9df7f556f157b1b00e06306f60 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 3 Aug 2007 21:51:37 +0200 Subject: CMakeLists.txt, README, configure.js Several adjustments to make client libraries pass the link test on both win32 and winx64, Visual Studio 2003 and 2005 (bug#30118) win/README: - Removed references to PARTITION engine, 5.1 only win/configure.js: - Removed references to PARTITION engine, 5.1 only extra/CMakeLists.txt: Use the special 'debug' list element to mark that "dbug" library is only to be linked against if build type "Debug". myisam/CMakeLists.txt: Use the special 'debug' list element to mark that "dbug" library is only to be linked against if build type "Debug". scripts/CMakeLists.txt: Use the special 'debug' list element to mark that "dbug" library is only to be linked against if build type "Debug". server-tools/instance-manager/CMakeLists.txt: Use the special 'debug' list element to mark that "dbug" library is only to be linked against if build type "Debug". sql/CMakeLists.txt: Use the special 'debug' list element to mark that "dbug" library is only to be linked against if build type "Debug". mysys/CMakeLists.txt: Restored include path to "mysys" itself dbug/CMakeLists.txt: Changed to optionally be included to give a file list only extra/yassl/CMakeLists.txt: Changed to optionally be included to give a file list only extra/yassl/taocrypt/CMakeLists.txt: Changed to optionally be included to give a file list only zlib/CMakeLists.txt: Changed to optionally be included to give a file list only libmysql/CMakeLists.txt: For compatibility with Visual Studio 2005, list all files that are to be part of the library build, i.e. libraries can't be built from other libraries. Set SOURCE_SUBLIBS and include the file listings from "zlib", "dbug", "taocrypt" and "yassl" --- mysys/CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'mysys') diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 4c11b57d736..8aaf0b5f00f 100755 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -13,7 +13,6 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # Only the server link with this library, the client libraries and the client @@ -21,7 +20,7 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX") # So we only need to create one version of this library, with the "static" # Thread Local Storage model. -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys ) +INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys) ADD_LIBRARY(mysys array.c charset-def.c charset.c checksum.c default.c default_modify.c errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c -- cgit v1.2.1