diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/config-win.h | 1 | ||||
-rw-r--r-- | include/my_global.h | 72 | ||||
-rw-r--r-- | include/my_pthread.h | 101 | ||||
-rw-r--r-- | include/my_sys.h | 2 | ||||
-rw-r--r-- | include/mysql.h | 2 | ||||
-rw-r--r-- | include/mysql_h.ic | 19 | ||||
-rw-r--r-- | include/typelib.h | 3 |
7 files changed, 145 insertions, 55 deletions
diff --git a/include/config-win.h b/include/config-win.h index a9977ec955a..34e828e01e8 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -248,7 +248,6 @@ inline double ulonglong2double(ulonglong value) #define tell(A) _telli64(A) #endif -#define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; } #define STACK_DIRECTION -1 diff --git a/include/my_global.h b/include/my_global.h index 19ba37fd58b..b91ff8a9e5b 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -93,6 +93,42 @@ #endif /* + The macros below are used to allow build of Universal/fat binaries of + MySQL and MySQL applications under darwin. +*/ +#ifdef TARGET_FAT_BINARY +# undef SIZEOF_CHARP +# undef SIZEOF_INT +# undef SIZEOF_LONG +# undef SIZEOF_LONG_LONG +# undef SIZEOF_OFF_T +# undef SIZEOF_SHORT + +#if defined(__i386__) +# undef WORDS_BIGENDIAN +# define SIZEOF_CHARP 4 +# define SIZEOF_INT 4 +# define SIZEOF_LONG 4 +# define SIZEOF_LONG_LONG 8 +# define SIZEOF_OFF_T 8 +# define SIZEOF_SHORT 2 + +#elif defined(__ppc__) +# define WORDS_BIGENDIAN +# define SIZEOF_CHARP 4 +# define SIZEOF_INT 4 +# define SIZEOF_LONG 4 +# define SIZEOF_LONG_LONG 8 +# define SIZEOF_OFF_T 8 +# define SIZEOF_SHORT 2 + +#else +# error Building FAT binary for an unknown architecture. +#endif +#endif /* TARGET_FAT_BINARY */ + + +/* The macros below are borrowed from include/linux/compiler.h in the Linux kernel. Use them to indicate the likelyhood of the truthfulness of a condition. This serves two purposes - newer versions of gcc will be @@ -1009,41 +1045,7 @@ typedef char bool; /* Ordinary boolean values 0 1 */ #define MY_HOW_OFTEN_TO_ALARM 2 /* How often we want info on screen */ #define MY_HOW_OFTEN_TO_WRITE 1000 /* How often we want info on screen */ -#ifdef HAVE_TIMESPEC_TS_SEC -#ifndef set_timespec -#define set_timespec(ABSTIME,SEC) \ -{ \ - (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ - (ABSTIME).ts_nsec=0; \ -} -#endif /* !set_timespec */ -#ifndef set_timespec_nsec -#define set_timespec_nsec(ABSTIME,NSEC) \ -{ \ - ulonglong now= my_getsystime() + (NSEC/100); \ - (ABSTIME).ts_sec= (now / ULL(10000000)); \ - (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ -} -#endif /* !set_timespec_nsec */ -#else -#ifndef set_timespec -#define set_timespec(ABSTIME,SEC) \ -{\ - struct timeval tv;\ - gettimeofday(&tv,0);\ - (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ - (ABSTIME).tv_nsec=tv.tv_usec*1000;\ -} -#endif /* !set_timespec */ -#ifndef set_timespec_nsec -#define set_timespec_nsec(ABSTIME,NSEC) \ -{\ - ulonglong now= my_getsystime() + (NSEC/100); \ - (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \ - (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ -} -#endif /* !set_timespec_nsec */ -#endif /* HAVE_TIMESPEC_TS_SEC */ + /* Define-funktions for reading and storing in machine independent format diff --git a/include/my_pthread.h b/include/my_pthread.h index 90e1a758915..52e900b5803 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -30,6 +30,26 @@ extern "C" { #define EXTERNC #endif /* __cplusplus */ +/* + BUG#24507: Race conditions inside current NPTL pthread_exit() implementation. + + If macro NPTL_PTHREAD_EXIT_HACK is defined then a hack described in the bug + report will be implemented inside my_thread_global_init() in my_thr_init.c. + + This amounts to spawning a dummy thread which does nothing but executes + pthread_exit(0). + + This bug is fixed in version 2.5 of glibc library. + + TODO: Remove this code when fixed versions of glibc6 are in common use. + */ + +#if defined(TARGET_OS_LINUX) && defined(HAVE_NPTL) && \ + defined(__GLIBC__) && ( __GLIBC__ < 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ < 5 ) +#define NPTL_PTHREAD_EXIT_BUG 1 +#endif + + #if defined(__WIN__) || defined(OS2) #ifdef OS2 @@ -68,14 +88,6 @@ typedef struct { #endif } pthread_cond_t; - -#ifndef OS2 -struct timespec { /* For pthread_cond_timedwait() */ - time_t tv_sec; - long tv_nsec; -}; -#endif - typedef int pthread_mutexattr_t; #define win_pthread_self my_thread_var->pthread_self #ifdef OS2 @@ -86,6 +98,36 @@ typedef void * (_Optlink *pthread_handler)(void *); typedef void * (__cdecl *pthread_handler)(void *); #endif +/* + Struct and macros to be used in combination with the + windows implementation of pthread_cond_timedwait +*/ + +/* + Declare a union to make sure FILETIME is properly aligned + so it can be used directly as a 64 bit value. The value + stored is in 100ns units. + */ + union ft64 { + FILETIME ft; + __int64 i64; + }; +struct timespec { + union ft64 tv; + /* The max timeout value in millisecond for pthread_cond_timedwait */ + long max_timeout_msec; +}; +#define set_timespec(ABSTIME,SEC) { \ + GetSystemTimeAsFileTime(&((ABSTIME).tv.ft)); \ + (ABSTIME).tv.i64+= (__int64)(SEC)*10000000; \ + (ABSTIME).max_timeout_msec= (long)((SEC)*1000); \ +} +#define set_timespec_nsec(ABSTIME,NSEC) { \ + GetSystemTimeAsFileTime(&((ABSTIME).tv.ft)); \ + (ABSTIME).tv.i64+= (__int64)(NSEC)/100; \ + (ABSTIME).max_timeout_msec= (long)((NSEC)/1000000); \ +} + void win_pthread_init(void); int win_pthread_setspecific(void *A,void *B,uint length); int pthread_create(pthread_t *,pthread_attr_t *,pthread_handler,void *); @@ -163,8 +205,6 @@ extern int pthread_mutex_destroy (pthread_mutex_t *); #define pthread_condattr_init(A) #define pthread_condattr_destroy(A) -/*Irena: compiler does not like this: */ -/*#define my_pthread_getprio(pthread_t thread_id) pthread_dummy(0) */ #define my_pthread_getprio(thread_id) pthread_dummy(0) #elif defined(HAVE_UNIXWARE7_THREADS) @@ -472,6 +512,47 @@ void my_pthread_attr_getstacksize(pthread_attr_t *attrib, size_t *size); int my_pthread_mutex_trylock(pthread_mutex_t *mutex); #endif +/* + The defines set_timespec and set_timespec_nsec should be used + for calculating an absolute time at which + pthread_cond_timedwait should timeout +*/ +#ifdef HAVE_TIMESPEC_TS_SEC +#ifndef set_timespec +#define set_timespec(ABSTIME,SEC) \ +{ \ + (ABSTIME).ts_sec=time(0) + (time_t) (SEC); \ + (ABSTIME).ts_nsec=0; \ +} +#endif /* !set_timespec */ +#ifndef set_timespec_nsec +#define set_timespec_nsec(ABSTIME,NSEC) \ +{ \ + ulonglong now= my_getsystime() + (NSEC/100); \ + (ABSTIME).ts_sec= (now / ULL(10000000)); \ + (ABSTIME).ts_nsec= (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ +} +#endif /* !set_timespec_nsec */ +#else +#ifndef set_timespec +#define set_timespec(ABSTIME,SEC) \ +{\ + struct timeval tv;\ + gettimeofday(&tv,0);\ + (ABSTIME).tv_sec=tv.tv_sec+(time_t) (SEC);\ + (ABSTIME).tv_nsec=tv.tv_usec*1000;\ +} +#endif /* !set_timespec */ +#ifndef set_timespec_nsec +#define set_timespec_nsec(ABSTIME,NSEC) \ +{\ + ulonglong now= my_getsystime() + (NSEC/100); \ + (ABSTIME).tv_sec= (time_t) (now / ULL(10000000)); \ + (ABSTIME).tv_nsec= (long) (now % ULL(10000000) * 100 + ((NSEC) % 100)); \ +} +#endif /* !set_timespec_nsec */ +#endif /* HAVE_TIMESPEC_TS_SEC */ + /* safe_mutex adds checking to mutex for easier debugging */ #if defined(__NETWARE__) && !defined(SAFE_MUTEX_DETECT_DESTROY) diff --git a/include/my_sys.h b/include/my_sys.h index 1f7dda30c54..c7c15e1606d 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -780,6 +780,8 @@ extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append); my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, uint length); +extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, + ...); extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str); extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size); extern void dynstr_free(DYNAMIC_STRING *str); diff --git a/include/mysql.h b/include/mysql.h index fb2e4319b4c..c612bdf175a 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -64,9 +64,9 @@ typedef int my_socket; #endif /* my_socket_defined */ #endif /* _global_h */ +#include "mysql_version.h" #include "mysql_com.h" #include "mysql_time.h" -#include "mysql_version.h" #include "typelib.h" #include "my_list.h" /* for LISTs used in 'MYSQL' and 'MYSQL_STMT' */ diff --git a/include/mysql_h.ic b/include/mysql_h.ic index 0e546acef92..5a9daee6f9f 100644 --- a/include/mysql_h.ic +++ b/include/mysql_h.ic @@ -36,6 +36,8 @@ enum mysql_status; typedef struct st_mysql_rows MYSQL_ROWS; # 24 "my_list.h" typedef struct st_list LIST; +# 35 "my_alloc.h" +typedef struct st_mem_root MEM_ROOT; # 251 "mysql.h" typedef struct st_mysql MYSQL; # 653 "mysql.h" @@ -60,7 +62,7 @@ typedef struct st_mysql_stmt MYSQL_STMT; typedef struct character_set MY_CHARSET_INFO; # 180 "mysql_com.h" typedef struct st_net NET; -# 21 "typelib.h" +# 23 "typelib.h" typedef struct st_typelib TYPELIB; # 170 "mysql_com.h" typedef struct st_vio Vio; @@ -76,8 +78,6 @@ typedef int my_socket; typedef unsigned long long int my_ulonglong; # 144 "mysql.h" typedef struct embedded_query_result EMBEDDED_QUERY_RESULT; -# 35 "my_alloc.h" -typedef struct st_mem_root MEM_ROOT; # 145 "mysql.h" typedef struct st_mysql_data MYSQL_DATA; # 750 "mysql.h" @@ -419,7 +419,7 @@ struct __attribute__((aligned(__alignof__(void *)), aligned(__alignof__(unsigned my_bool report_error; my_bool return_errno; }; -# 21 "typelib.h" +# 23 "typelib.h" struct __attribute__((aligned(__alignof__(unsigned int)), aligned(__alignof__(void *)))) st_typelib { unsigned int count; @@ -575,6 +575,7 @@ enum mysql_enum_shutdown_level SHUTDOWN_WAIT_UPDATES = (unsigned char)((1 << 3)), SHUTDOWN_WAIT_ALL_BUFFERS = ((unsigned char)((1 << 3)) << 1), SHUTDOWN_WAIT_CRITICAL_BUFFERS = (((unsigned char)((1 << 3)) << 1) + 1), + KILL_QUERY = 254, KILL_CONNECTION = 255, }; # 154 "mysql.h" @@ -630,9 +631,11 @@ enum mysql_status extern my_bool check_scramble(char const * reply, char const * message, unsigned char const * hash_stage2); # 416 "mysql_com.h" extern my_bool check_scramble_323(char const *, char const * message, unsigned long int * salt); +# 33 "typelib.h" +extern TYPELIB * copy_typelib(MEM_ROOT * root, TYPELIB * from); # 411 "mysql_com.h" extern void create_random_string(char * to, unsigned int, struct rand_struct * rand_st); -# 28 "typelib.h" +# 30 "typelib.h" extern int find_type(char * x, TYPELIB * typelib, unsigned int); # 425 "mysql_com.h" extern void get_salt_from_password(unsigned char * res, char const * password); @@ -640,7 +643,7 @@ extern void get_salt_from_password(unsigned char * res, char const * password); extern void get_salt_from_password_323(unsigned long int * res, char const * password); # 431 "mysql_com.h" extern char * get_tty_password(char * opt_message); -# 30 "typelib.h" +# 32 "typelib.h" extern char const * get_type(TYPELIB * typelib, unsigned int); # 413 "mysql_com.h" extern void hash_password(unsigned long int * to, char const * password, unsigned int); @@ -668,7 +671,7 @@ extern void make_password_from_salt_323(char * to, unsigned long int const * sal extern void make_scrambled_password(char * to, char const * password); # 414 "mysql_com.h" extern void make_scrambled_password_323(char * to, char const * password); -# 29 "typelib.h" +# 31 "typelib.h" extern void make_type(char * to, unsigned int, TYPELIB * typelib); # 437 "mysql_com.h" extern int modify_defaults_file(char const * file_location, char const * option, char const * option_value, char const * section_name, int); @@ -962,5 +965,5 @@ extern void randominit(struct rand_struct *, unsigned long int, unsigned long in extern void scramble(char * to, char const * message, char const * password); # 415 "mysql_com.h" extern void scramble_323(char * to, char const * message, char const * password); -# 32 "typelib.h" +# 35 "typelib.h" extern TYPELIB sql_protocol_typelib; diff --git a/include/typelib.h b/include/typelib.h index 28554f739d3..75d170e59d3 100644 --- a/include/typelib.h +++ b/include/typelib.h @@ -17,6 +17,8 @@ #ifndef _typelib_h #define _typelib_h +#include "my_alloc.h" + typedef struct st_typelib { /* Different types saved here */ unsigned int count; /* How many types */ const char *name; /* Name of typelib */ @@ -27,6 +29,7 @@ typedef struct st_typelib { /* Different types saved here */ extern int find_type(char *x,TYPELIB *typelib,unsigned int full_name); extern void make_type(char *to,unsigned int nr,TYPELIB *typelib); extern const char *get_type(TYPELIB *typelib,unsigned int nr); +extern TYPELIB *copy_typelib(MEM_ROOT *root, TYPELIB *from); extern TYPELIB sql_protocol_typelib; |