diff options
Diffstat (limited to 'include/my_sys.h')
-rw-r--r-- | include/my_sys.h | 80 |
1 files changed, 43 insertions, 37 deletions
diff --git a/include/my_sys.h b/include/my_sys.h index c1d81108a84..3fc36bdd75b 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -17,8 +17,6 @@ #ifndef _my_sys_h #define _my_sys_h -#include "my_global.h" /* C_MODE_START, C_MODE_END */ - #include <m_string.h> C_MODE_START @@ -62,18 +60,19 @@ typedef struct my_aio_result { /* General bitmaps for my_func's */ #define MY_FFNF 1U /* Fatal if file not found */ -#define MY_FNABP 2U /* Fatal if not all bytes read/writen */ -#define MY_NABP 4U /* Error if not all bytes read/writen */ +#define MY_FNABP 2U /* Fatal if not all bytes read/written */ +#define MY_NABP 4U /* Error if not all bytes read/written */ #define MY_FAE 8U /* Fatal if any error */ #define MY_WME 16U /* Write message on error */ #define MY_WAIT_IF_FULL 32U /* Wait and try again if disk full error */ #define MY_IGNORE_BADFD 32U /* my_sync(): ignore 'bad descriptor' errors */ #define MY_ENCRYPT 64U /* Encrypt IO_CACHE temporary files */ +#define MY_TEMPORARY 64U /* create_temp_file(): delete file at once */ #define MY_NOSYMLINKS 512U /* my_open(): don't follow symlinks */ #define MY_FULL_IO 512U /* my_read(): loop until I/O is complete */ #define MY_DONT_CHECK_FILESIZE 128U /* Option to init_io_cache() */ #define MY_LINK_WARNING 32U /* my_redel() gives warning if links */ -#define MY_COPYTIME 64U /* my_redel() copys time */ +#define MY_COPYTIME 64U /* my_redel() copies time */ #define MY_DELETE_OLD 256U /* my_create_with_symlink() */ #define MY_RESOLVE_LINK 128U /* my_realpath(); Only resolve links */ #define MY_HOLD_ORIGINAL_MODES 128U /* my_copy() holds to file modes */ @@ -98,7 +97,7 @@ typedef struct my_aio_result { #define MY_SYNC_FILESIZE 65536U /* my_sync(): safe sync when file is extended */ #define MY_THREAD_SPECIFIC 0x10000U /* my_malloc(): thread specific */ #define MY_THREAD_MOVE 0x20000U /* realloc(); Memory can move */ -/* Tree that should delete things automaticly */ +/* Tree that should delete things automatically */ #define MY_TREE_WITH_DELETE 0x40000U #define MY_CHECK_ERROR 1U /* Params to my_end; Check open-close */ @@ -108,7 +107,7 @@ typedef struct my_aio_result { #define ME_BELL 4U /* Ring bell then printing message */ #define ME_WAITTANG 0 /* Wait for a user action */ #define ME_NOREFRESH 64U /* Write the error message to error log */ -#define ME_NOINPUT 0 /* Dont use the input libary */ +#define ME_NOINPUT 0 /* Don't use the input library */ #define ME_JUST_INFO 1024U /**< not error but just info */ #define ME_JUST_WARNING 2048U /**< not error but just warning */ #define ME_FATALERROR 4096U /* Fatal statement error */ @@ -154,9 +153,12 @@ typedef struct my_aio_result { /* Extra length needed for filename if one calls my_create_backup_name */ #define MY_BACKUP_NAME_EXTRA_LENGTH 17 +char *guess_malloc_library(); + /* If we have our own safemalloc (for debugging) */ #if defined(SAFEMALLOC) void sf_report_leaked_memory(my_thread_id id); +int sf_sanity(); extern my_thread_id (*sf_malloc_dbug_id)(void); #define SAFEMALLOC_REPORT_MEMORY(X) sf_report_leaked_memory(X) #else @@ -259,10 +261,11 @@ extern ulonglong my_collation_statistics_get_use_count(uint id); extern const char *my_collation_get_tailoring(uint id); /* statistics */ -extern ulong my_file_opened,my_stream_opened, my_tmp_file_created; +extern ulong my_stream_opened, my_tmp_file_created; extern ulong my_file_total_opened; extern ulong my_sync_count; extern uint mysys_usage_id; +extern int32 my_file_opened; extern my_bool my_init_done, my_thr_key_mysys_exists; extern my_bool my_assert_on_error; extern myf my_global_flags; /* Set to MY_WME for more error messages */ @@ -270,7 +273,7 @@ extern myf my_global_flags; /* Set to MY_WME for more error messages extern void (*my_sigtstp_cleanup)(void), /* Executed before jump to shell */ (*my_sigtstp_restart)(void); - /* Executed when comming from shell */ + /* Executed when coming from shell */ extern MYSQL_PLUGIN_IMPORT int my_umask; /* Default creation mask */ extern int my_umask_dir, my_recived_signals, /* Signals we have got */ @@ -310,7 +313,7 @@ enum flush_type FLUSH_KEEP_LAZY }; -typedef struct st_record_cache /* Used when cacheing records */ +typedef struct st_record_cache /* Used when caching records */ { File file; int rc_seek,error,inited; @@ -390,7 +393,7 @@ typedef struct st_io_cache_share #endif } IO_CACHE_SHARE; -typedef struct st_io_cache /* Used when cacheing files */ +typedef struct st_io_cache /* Used when caching files */ { /* Offset in file corresponding to the first byte of uchar* buffer. */ my_off_t pos_in_file; @@ -550,12 +553,13 @@ static inline int my_b_get(IO_CACHE *info) return _my_b_get(info); } -/* my_b_write_byte dosn't have any err-check */ -static inline void my_b_write_byte(IO_CACHE *info, uchar chr) +static inline my_bool my_b_write_byte(IO_CACHE *info, uchar chr) { if (info->write_pos >= info->write_end) - my_b_flush_io_cache(info, 1); + if (my_b_flush_io_cache(info, 1)) + return 1; *info->write_pos++= chr; + return 0; } /** @@ -571,21 +575,21 @@ static inline void my_b_write_byte(IO_CACHE *info, uchar chr) static inline size_t my_b_fill(IO_CACHE *info) { info->read_pos= info->read_end; - return _my_b_read(info,0,0) ? 0 : info->read_end - info->read_pos; + return _my_b_read(info,0,0) ? 0 : (size_t) (info->read_end - info->read_pos); } static inline my_off_t my_b_tell(const IO_CACHE *info) { if (info->type == WRITE_CACHE) { - return info->pos_in_file + (info->write_pos - info->request_pos); + return info->pos_in_file + (my_off_t)(info->write_pos - info->request_pos); } - return info->pos_in_file + (info->read_pos - info->request_pos); + return info->pos_in_file + (my_off_t) (info->read_pos - info->request_pos); } static inline my_off_t my_b_write_tell(const IO_CACHE *info) { - return info->pos_in_file + (info->write_pos - info->write_buffer); + return info->pos_in_file + (my_off_t) (info->write_pos - info->write_buffer); } static inline uchar* my_b_get_buffer_start(const IO_CACHE *info) @@ -595,7 +599,7 @@ static inline uchar* my_b_get_buffer_start(const IO_CACHE *info) static inline size_t my_b_get_bytes_in_buffer(const IO_CACHE *info) { - return info->read_end - info->request_pos; + return (size_t) (info->read_end - info->request_pos); } static inline my_off_t my_b_get_pos_in_file(const IO_CACHE *info) @@ -606,9 +610,9 @@ static inline my_off_t my_b_get_pos_in_file(const IO_CACHE *info) static inline size_t my_b_bytes_in_cache(const IO_CACHE *info) { if (info->type == WRITE_CACHE) { - return info->write_end - info->write_pos; + return (size_t) (info->write_end - info->write_pos); } - return info->read_end - info->read_pos; + return (size_t) (info->read_end - info->read_pos); } int my_b_copy_to_file (IO_CACHE *cache, FILE *file, size_t count); @@ -734,12 +738,6 @@ void my_create_backup_name(char *to, const char *from, extern int my_copystat(const char *from, const char *to, int MyFlags); extern char * my_filename(File fd); -#ifdef EXTRA_DEBUG -void my_print_open_files(void); -#else -#define my_print_open_files() -#endif - extern my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist); extern char *my_tmpdir(MY_TMPDIR *tmpdir); extern void free_tmpdir(MY_TMPDIR *tmpdir); @@ -826,9 +824,9 @@ extern int end_io_cache(IO_CACHE *info); extern void my_b_seek(IO_CACHE *info,my_off_t pos); extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length); extern my_off_t my_b_filelength(IO_CACHE *info); -extern size_t my_b_write_backtick_quote(IO_CACHE *info, const char *str, - size_t len); -extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...); +extern my_bool my_b_write_backtick_quote(IO_CACHE *info, const char *str, + size_t len); +extern my_bool my_b_printf(IO_CACHE *info, const char* fmt, ...); extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, const char *prefix, size_t cache_size, @@ -894,8 +892,9 @@ extern void my_free_lock(void *ptr); #define alloc_root_inited(A) ((A)->min_malloc != 0) #define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8) #define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0) -extern void init_alloc_root(MEM_ROOT *mem_root, size_t block_size, - size_t pre_alloc_size, myf my_flags); +extern void init_alloc_root(MEM_ROOT *mem_root, const char *name, + size_t block_size, size_t pre_alloc_size, + myf my_flags); extern void *alloc_root(MEM_ROOT *mem_root, size_t Size); extern void *multi_alloc_root(MEM_ROOT *mem_root, ...); extern void free_root(MEM_ROOT *root, myf MyFLAGS); @@ -922,7 +921,7 @@ extern int unpackfrm(uchar **, size_t *, const uchar *); extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem, size_t count); -#ifndef DBUG_OFF +#ifdef DBUG_ASSERT_EXISTS extern void my_debug_put_break_here(void); #else #define my_debug_put_break_here() do {} while(0) @@ -940,6 +939,13 @@ extern int my_getncpus(void); typedef struct {ulonglong val;} my_hrtime_t; void my_time_init(void); extern my_hrtime_t my_hrtime(void); + +#ifdef _WIN32 +extern my_hrtime_t my_hrtime_coarse(); +#else +#define my_hrtime_coarse() my_hrtime() +#endif + extern ulonglong my_interval_timer(void); extern ulonglong my_getcputime(void); @@ -948,7 +954,7 @@ extern ulonglong my_getcputime(void); #define hrtime_from_time(X) ((ulonglong)((X)*HRTIME_RESOLUTION)) #define hrtime_to_double(X) ((X).val/(double)HRTIME_RESOLUTION) #define hrtime_sec_part(X) ((ulong)((X).val % HRTIME_RESOLUTION)) -#define my_time(X) hrtime_to_time(my_hrtime()) +#define my_time(X) hrtime_to_time(my_hrtime_coarse()) #if STACK_DIRECTION < 0 #define available_stack_size(CUR,END) (long) ((char*)(CUR) - (char*)(END)) @@ -1047,9 +1053,9 @@ extern size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info, char *to, size_t to_length, const char *from, size_t length); -extern void thd_increment_bytes_sent(void *thd, ulong length); -extern void thd_increment_bytes_received(void *thd, ulong length); -extern void thd_increment_net_big_packet_count(void *thd, ulong length); +extern void thd_increment_bytes_sent(void *thd, size_t length); +extern void thd_increment_bytes_received(void *thd, size_t length); +extern void thd_increment_net_big_packet_count(void *thd, size_t length); #ifdef __WIN__ extern my_bool have_tcpip; /* Is set if tcpip is used */ |