From c7fa4a5be885c13689c021bce364041a47ccd890 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 24 Apr 2024 17:56:19 +0300 Subject: Release version 8.0.15+16 Add support for building with MinGW GCC. --- libmysqlclient/mysql/mysys | 1 - libmysqlclient/mysql/mysys/array.cc | 1 + libmysqlclient/mysql/mysys/base64.cc | 1 + libmysqlclient/mysql/mysys/charset-def.cc | 1 + libmysqlclient/mysql/mysys/charset.cc | 1 + libmysqlclient/mysql/mysys/checksum.cc | 1 + libmysqlclient/mysql/mysys/errors.cc | 1 + libmysqlclient/mysql/mysys/kqueue_timers.cc | 1 + libmysqlclient/mysql/mysys/lf_alloc-pin.cc | 1 + libmysqlclient/mysql/mysys/lf_dynarray.cc | 1 + libmysqlclient/mysql/mysys/lf_hash.cc | 1 + libmysqlclient/mysql/mysys/list.cc | 1 + libmysqlclient/mysql/mysys/mf_arr_appstr.cc | 1 + libmysqlclient/mysql/mysys/mf_cache.cc | 1 + libmysqlclient/mysql/mysys/mf_dirname.cc | 1 + libmysqlclient/mysql/mysys/mf_fn_ext.cc | 1 + libmysqlclient/mysql/mysys/mf_format.cc | 1 + libmysqlclient/mysql/mysys/mf_getdate.cc | 1 + libmysqlclient/mysql/mysys/mf_iocache.cc | 1 + libmysqlclient/mysql/mysys/mf_iocache2.cc | 1 + libmysqlclient/mysql/mysys/mf_keycache.cc | 1 + libmysqlclient/mysql/mysys/mf_keycaches.cc | 1 + libmysqlclient/mysql/mysys/mf_loadpath.cc | 1 + libmysqlclient/mysql/mysys/mf_pack.cc | 1 + libmysqlclient/mysql/mysys/mf_path.cc | 1 + libmysqlclient/mysql/mysys/mf_qsort2.cc | 1 + libmysqlclient/mysql/mysys/mf_same.cc | 1 + libmysqlclient/mysql/mysys/mf_tempdir.cc | 1 + libmysqlclient/mysql/mysys/mf_tempfile.cc | 1 + libmysqlclient/mysql/mysys/mf_unixpath.cc | 1 + libmysqlclient/mysql/mysys/mf_wcomp.cc | 1 + libmysqlclient/mysql/mysys/mulalloc.cc | 1 + libmysqlclient/mysql/mysys/my_access.cc | 1 + libmysqlclient/mysql/mysys/my_alloc.cc | 1 + libmysqlclient/mysql/mysys/my_bit.cc | 1 + libmysqlclient/mysql/mysys/my_bitmap.cc | 1 + libmysqlclient/mysql/mysys/my_chmod.cc | 1 + libmysqlclient/mysql/mysys/my_chsize.cc | 1 + libmysqlclient/mysql/mysys/my_compare.cc | 1 + libmysqlclient/mysql/mysys/my_compress.cc | 1 + libmysqlclient/mysql/mysys/my_conio.cc | 1 + libmysqlclient/mysql/mysys/my_copy.cc | 1 + libmysqlclient/mysql/mysys/my_create.cc | 1 + libmysqlclient/mysql/mysys/my_delete.cc | 1 + libmysqlclient/mysql/mysys/my_div.cc | 1 + libmysqlclient/mysql/mysys/my_error.cc | 1 + libmysqlclient/mysql/mysys/my_fallocator.cc | 1 + libmysqlclient/mysql/mysys/my_file.cc | 1 + libmysqlclient/mysql/mysys/my_fopen.cc | 1 + libmysqlclient/mysql/mysys/my_fstream.cc | 1 + libmysqlclient/mysql/mysys/my_gethwaddr.cc | 1 + libmysqlclient/mysql/mysys/my_getsystime.cc | 1 + libmysqlclient/mysql/mysys/my_getwd.cc | 1 + libmysqlclient/mysql/mysys/my_handler_errors.h | 1 + libmysqlclient/mysql/mysys/my_init.cc | 1 + libmysqlclient/mysql/mysys/my_largepage.cc | 1 + libmysqlclient/mysql/mysys/my_lib.cc | 1 + libmysqlclient/mysql/mysys/my_malloc.cc | 1 + libmysqlclient/mysql/mysys/my_mess.cc | 1 + libmysqlclient/mysql/mysys/my_mkdir.cc | 1 + libmysqlclient/mysql/mysys/my_mmap.cc | 1 + libmysqlclient/mysql/mysys/my_murmur3.cc | 1 + libmysqlclient/mysql/mysys/my_once.cc | 1 + libmysqlclient/mysql/mysys/my_open.cc | 1 + libmysqlclient/mysql/mysys/my_pread.cc | 1 + libmysqlclient/mysql/mysys/my_rdtsc.cc | 1 + libmysqlclient/mysql/mysys/my_read.cc | 1 + libmysqlclient/mysql/mysys/my_rename.cc | 1 + libmysqlclient/mysql/mysys/my_seek.cc | 1 + libmysqlclient/mysql/mysys/my_static.cc | 1 + libmysqlclient/mysql/mysys/my_static.h | 1 + libmysqlclient/mysql/mysys/my_string.cc | 1 + libmysqlclient/mysql/mysys/my_symlink.cc | 1 + libmysqlclient/mysql/mysys/my_symlink2.cc | 1 + libmysqlclient/mysql/mysys/my_sync.cc | 1 + libmysqlclient/mysql/mysys/my_syslog.cc | 1 + libmysqlclient/mysql/mysys/my_thr_init.cc | 385 ++++++++++++ libmysqlclient/mysql/mysys/my_thr_init.cc.orig | 1 + libmysqlclient/mysql/mysys/my_thread.cc | 1 + libmysqlclient/mysql/mysys/my_time.cc | 1 + libmysqlclient/mysql/mysys/my_timespec.cc | 1 + libmysqlclient/mysql/mysys/my_user.cc | 1 + libmysqlclient/mysql/mysys/my_windac.cc | 1 + libmysqlclient/mysql/mysys/my_winerr.cc | 1 + libmysqlclient/mysql/mysys/my_winfile.cc | 1 + libmysqlclient/mysql/mysys/my_write.cc | 1 + libmysqlclient/mysql/mysys/mysys_priv.h | 1 + libmysqlclient/mysql/mysys/pack.cc | 1 + libmysqlclient/mysql/mysys/posix_timers.cc | 1 + libmysqlclient/mysql/mysys/print_version.cc | 1 + libmysqlclient/mysql/mysys/psi_noop.cc | 1 + libmysqlclient/mysql/mysys/ptr_cmp.cc | 1 + libmysqlclient/mysql/mysys/sql_chars.cc | 1 + libmysqlclient/mysql/mysys/stacktrace.cc | 784 +++++++++++++++++++++++++ libmysqlclient/mysql/mysys/stacktrace.cc.orig | 1 + libmysqlclient/mysql/mysys/thr_cond.cc | 1 + libmysqlclient/mysql/mysys/thr_lock.cc | 1 + libmysqlclient/mysql/mysys/thr_mutex.cc | 1 + libmysqlclient/mysql/mysys/thr_rwlock.cc | 1 + libmysqlclient/mysql/mysys/tree.cc | 1 + libmysqlclient/mysql/mysys/typelib.cc | 1 + libmysqlclient/mysql/mysys/win_timers.cc | 1 + 102 files changed, 1268 insertions(+), 1 deletion(-) delete mode 120000 libmysqlclient/mysql/mysys create mode 120000 libmysqlclient/mysql/mysys/array.cc create mode 120000 libmysqlclient/mysql/mysys/base64.cc create mode 120000 libmysqlclient/mysql/mysys/charset-def.cc create mode 120000 libmysqlclient/mysql/mysys/charset.cc create mode 120000 libmysqlclient/mysql/mysys/checksum.cc create mode 120000 libmysqlclient/mysql/mysys/errors.cc create mode 120000 libmysqlclient/mysql/mysys/kqueue_timers.cc create mode 120000 libmysqlclient/mysql/mysys/lf_alloc-pin.cc create mode 120000 libmysqlclient/mysql/mysys/lf_dynarray.cc create mode 120000 libmysqlclient/mysql/mysys/lf_hash.cc create mode 120000 libmysqlclient/mysql/mysys/list.cc create mode 120000 libmysqlclient/mysql/mysys/mf_arr_appstr.cc create mode 120000 libmysqlclient/mysql/mysys/mf_cache.cc create mode 120000 libmysqlclient/mysql/mysys/mf_dirname.cc create mode 120000 libmysqlclient/mysql/mysys/mf_fn_ext.cc create mode 120000 libmysqlclient/mysql/mysys/mf_format.cc create mode 120000 libmysqlclient/mysql/mysys/mf_getdate.cc create mode 120000 libmysqlclient/mysql/mysys/mf_iocache.cc create mode 120000 libmysqlclient/mysql/mysys/mf_iocache2.cc create mode 120000 libmysqlclient/mysql/mysys/mf_keycache.cc create mode 120000 libmysqlclient/mysql/mysys/mf_keycaches.cc create mode 120000 libmysqlclient/mysql/mysys/mf_loadpath.cc create mode 120000 libmysqlclient/mysql/mysys/mf_pack.cc create mode 120000 libmysqlclient/mysql/mysys/mf_path.cc create mode 120000 libmysqlclient/mysql/mysys/mf_qsort2.cc create mode 120000 libmysqlclient/mysql/mysys/mf_same.cc create mode 120000 libmysqlclient/mysql/mysys/mf_tempdir.cc create mode 120000 libmysqlclient/mysql/mysys/mf_tempfile.cc create mode 120000 libmysqlclient/mysql/mysys/mf_unixpath.cc create mode 120000 libmysqlclient/mysql/mysys/mf_wcomp.cc create mode 120000 libmysqlclient/mysql/mysys/mulalloc.cc create mode 120000 libmysqlclient/mysql/mysys/my_access.cc create mode 120000 libmysqlclient/mysql/mysys/my_alloc.cc create mode 120000 libmysqlclient/mysql/mysys/my_bit.cc create mode 120000 libmysqlclient/mysql/mysys/my_bitmap.cc create mode 120000 libmysqlclient/mysql/mysys/my_chmod.cc create mode 120000 libmysqlclient/mysql/mysys/my_chsize.cc create mode 120000 libmysqlclient/mysql/mysys/my_compare.cc create mode 120000 libmysqlclient/mysql/mysys/my_compress.cc create mode 120000 libmysqlclient/mysql/mysys/my_conio.cc create mode 120000 libmysqlclient/mysql/mysys/my_copy.cc create mode 120000 libmysqlclient/mysql/mysys/my_create.cc create mode 120000 libmysqlclient/mysql/mysys/my_delete.cc create mode 120000 libmysqlclient/mysql/mysys/my_div.cc create mode 120000 libmysqlclient/mysql/mysys/my_error.cc create mode 120000 libmysqlclient/mysql/mysys/my_fallocator.cc create mode 120000 libmysqlclient/mysql/mysys/my_file.cc create mode 120000 libmysqlclient/mysql/mysys/my_fopen.cc create mode 120000 libmysqlclient/mysql/mysys/my_fstream.cc create mode 120000 libmysqlclient/mysql/mysys/my_gethwaddr.cc create mode 120000 libmysqlclient/mysql/mysys/my_getsystime.cc create mode 120000 libmysqlclient/mysql/mysys/my_getwd.cc create mode 120000 libmysqlclient/mysql/mysys/my_handler_errors.h create mode 120000 libmysqlclient/mysql/mysys/my_init.cc create mode 120000 libmysqlclient/mysql/mysys/my_largepage.cc create mode 120000 libmysqlclient/mysql/mysys/my_lib.cc create mode 120000 libmysqlclient/mysql/mysys/my_malloc.cc create mode 120000 libmysqlclient/mysql/mysys/my_mess.cc create mode 120000 libmysqlclient/mysql/mysys/my_mkdir.cc create mode 120000 libmysqlclient/mysql/mysys/my_mmap.cc create mode 120000 libmysqlclient/mysql/mysys/my_murmur3.cc create mode 120000 libmysqlclient/mysql/mysys/my_once.cc create mode 120000 libmysqlclient/mysql/mysys/my_open.cc create mode 120000 libmysqlclient/mysql/mysys/my_pread.cc create mode 120000 libmysqlclient/mysql/mysys/my_rdtsc.cc create mode 120000 libmysqlclient/mysql/mysys/my_read.cc create mode 120000 libmysqlclient/mysql/mysys/my_rename.cc create mode 120000 libmysqlclient/mysql/mysys/my_seek.cc create mode 120000 libmysqlclient/mysql/mysys/my_static.cc create mode 120000 libmysqlclient/mysql/mysys/my_static.h create mode 120000 libmysqlclient/mysql/mysys/my_string.cc create mode 120000 libmysqlclient/mysql/mysys/my_symlink.cc create mode 120000 libmysqlclient/mysql/mysys/my_symlink2.cc create mode 120000 libmysqlclient/mysql/mysys/my_sync.cc create mode 120000 libmysqlclient/mysql/mysys/my_syslog.cc create mode 100644 libmysqlclient/mysql/mysys/my_thr_init.cc create mode 120000 libmysqlclient/mysql/mysys/my_thr_init.cc.orig create mode 120000 libmysqlclient/mysql/mysys/my_thread.cc create mode 120000 libmysqlclient/mysql/mysys/my_time.cc create mode 120000 libmysqlclient/mysql/mysys/my_timespec.cc create mode 120000 libmysqlclient/mysql/mysys/my_user.cc create mode 120000 libmysqlclient/mysql/mysys/my_windac.cc create mode 120000 libmysqlclient/mysql/mysys/my_winerr.cc create mode 120000 libmysqlclient/mysql/mysys/my_winfile.cc create mode 120000 libmysqlclient/mysql/mysys/my_write.cc create mode 120000 libmysqlclient/mysql/mysys/mysys_priv.h create mode 120000 libmysqlclient/mysql/mysys/pack.cc create mode 120000 libmysqlclient/mysql/mysys/posix_timers.cc create mode 120000 libmysqlclient/mysql/mysys/print_version.cc create mode 120000 libmysqlclient/mysql/mysys/psi_noop.cc create mode 120000 libmysqlclient/mysql/mysys/ptr_cmp.cc create mode 120000 libmysqlclient/mysql/mysys/sql_chars.cc create mode 100644 libmysqlclient/mysql/mysys/stacktrace.cc create mode 120000 libmysqlclient/mysql/mysys/stacktrace.cc.orig create mode 120000 libmysqlclient/mysql/mysys/thr_cond.cc create mode 120000 libmysqlclient/mysql/mysys/thr_lock.cc create mode 120000 libmysqlclient/mysql/mysys/thr_mutex.cc create mode 120000 libmysqlclient/mysql/mysys/thr_rwlock.cc create mode 120000 libmysqlclient/mysql/mysys/tree.cc create mode 120000 libmysqlclient/mysql/mysys/typelib.cc create mode 120000 libmysqlclient/mysql/mysys/win_timers.cc (limited to 'libmysqlclient/mysql/mysys') diff --git a/libmysqlclient/mysql/mysys b/libmysqlclient/mysql/mysys deleted file mode 120000 index 0708a61..0000000 --- a/libmysqlclient/mysql/mysys +++ /dev/null @@ -1 +0,0 @@ -../../upstream/mysys \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/array.cc b/libmysqlclient/mysql/mysys/array.cc new file mode 120000 index 0000000..66dae1a --- /dev/null +++ b/libmysqlclient/mysql/mysys/array.cc @@ -0,0 +1 @@ +../../../upstream/mysys/array.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/base64.cc b/libmysqlclient/mysql/mysys/base64.cc new file mode 120000 index 0000000..7739086 --- /dev/null +++ b/libmysqlclient/mysql/mysys/base64.cc @@ -0,0 +1 @@ +../../../upstream/mysys/base64.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/charset-def.cc b/libmysqlclient/mysql/mysys/charset-def.cc new file mode 120000 index 0000000..2453db1 --- /dev/null +++ b/libmysqlclient/mysql/mysys/charset-def.cc @@ -0,0 +1 @@ +../../../upstream/mysys/charset-def.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/charset.cc b/libmysqlclient/mysql/mysys/charset.cc new file mode 120000 index 0000000..30b6c18 --- /dev/null +++ b/libmysqlclient/mysql/mysys/charset.cc @@ -0,0 +1 @@ +../../../upstream/mysys/charset.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/checksum.cc b/libmysqlclient/mysql/mysys/checksum.cc new file mode 120000 index 0000000..fc46b72 --- /dev/null +++ b/libmysqlclient/mysql/mysys/checksum.cc @@ -0,0 +1 @@ +../../../upstream/mysys/checksum.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/errors.cc b/libmysqlclient/mysql/mysys/errors.cc new file mode 120000 index 0000000..e3cdef4 --- /dev/null +++ b/libmysqlclient/mysql/mysys/errors.cc @@ -0,0 +1 @@ +../../../upstream/mysys/errors.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/kqueue_timers.cc b/libmysqlclient/mysql/mysys/kqueue_timers.cc new file mode 120000 index 0000000..0555fd5 --- /dev/null +++ b/libmysqlclient/mysql/mysys/kqueue_timers.cc @@ -0,0 +1 @@ +../../../upstream/mysys/kqueue_timers.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/lf_alloc-pin.cc b/libmysqlclient/mysql/mysys/lf_alloc-pin.cc new file mode 120000 index 0000000..942e564 --- /dev/null +++ b/libmysqlclient/mysql/mysys/lf_alloc-pin.cc @@ -0,0 +1 @@ +../../../upstream/mysys/lf_alloc-pin.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/lf_dynarray.cc b/libmysqlclient/mysql/mysys/lf_dynarray.cc new file mode 120000 index 0000000..f8e6648 --- /dev/null +++ b/libmysqlclient/mysql/mysys/lf_dynarray.cc @@ -0,0 +1 @@ +../../../upstream/mysys/lf_dynarray.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/lf_hash.cc b/libmysqlclient/mysql/mysys/lf_hash.cc new file mode 120000 index 0000000..f85fe22 --- /dev/null +++ b/libmysqlclient/mysql/mysys/lf_hash.cc @@ -0,0 +1 @@ +../../../upstream/mysys/lf_hash.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/list.cc b/libmysqlclient/mysql/mysys/list.cc new file mode 120000 index 0000000..e20e210 --- /dev/null +++ b/libmysqlclient/mysql/mysys/list.cc @@ -0,0 +1 @@ +../../../upstream/mysys/list.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_arr_appstr.cc b/libmysqlclient/mysql/mysys/mf_arr_appstr.cc new file mode 120000 index 0000000..7e9305c --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_arr_appstr.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_arr_appstr.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_cache.cc b/libmysqlclient/mysql/mysys/mf_cache.cc new file mode 120000 index 0000000..e652859 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_cache.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_cache.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_dirname.cc b/libmysqlclient/mysql/mysys/mf_dirname.cc new file mode 120000 index 0000000..4cf0ca1 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_dirname.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_dirname.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_fn_ext.cc b/libmysqlclient/mysql/mysys/mf_fn_ext.cc new file mode 120000 index 0000000..586cca6 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_fn_ext.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_fn_ext.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_format.cc b/libmysqlclient/mysql/mysys/mf_format.cc new file mode 120000 index 0000000..6319f27 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_format.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_format.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_getdate.cc b/libmysqlclient/mysql/mysys/mf_getdate.cc new file mode 120000 index 0000000..f888517 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_getdate.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_getdate.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_iocache.cc b/libmysqlclient/mysql/mysys/mf_iocache.cc new file mode 120000 index 0000000..e646b51 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_iocache.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_iocache.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_iocache2.cc b/libmysqlclient/mysql/mysys/mf_iocache2.cc new file mode 120000 index 0000000..d6d484c --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_iocache2.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_iocache2.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_keycache.cc b/libmysqlclient/mysql/mysys/mf_keycache.cc new file mode 120000 index 0000000..d34b375 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_keycache.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_keycache.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_keycaches.cc b/libmysqlclient/mysql/mysys/mf_keycaches.cc new file mode 120000 index 0000000..9253369 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_keycaches.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_keycaches.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_loadpath.cc b/libmysqlclient/mysql/mysys/mf_loadpath.cc new file mode 120000 index 0000000..65ecde0 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_loadpath.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_loadpath.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_pack.cc b/libmysqlclient/mysql/mysys/mf_pack.cc new file mode 120000 index 0000000..a4914b4 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_pack.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_pack.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_path.cc b/libmysqlclient/mysql/mysys/mf_path.cc new file mode 120000 index 0000000..82cef95 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_path.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_path.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_qsort2.cc b/libmysqlclient/mysql/mysys/mf_qsort2.cc new file mode 120000 index 0000000..4ecab6c --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_qsort2.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_qsort2.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_same.cc b/libmysqlclient/mysql/mysys/mf_same.cc new file mode 120000 index 0000000..075cb12 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_same.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_same.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_tempdir.cc b/libmysqlclient/mysql/mysys/mf_tempdir.cc new file mode 120000 index 0000000..2a3b0e7 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_tempdir.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_tempdir.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_tempfile.cc b/libmysqlclient/mysql/mysys/mf_tempfile.cc new file mode 120000 index 0000000..482324e --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_tempfile.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_tempfile.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_unixpath.cc b/libmysqlclient/mysql/mysys/mf_unixpath.cc new file mode 120000 index 0000000..f35a903 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_unixpath.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_unixpath.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mf_wcomp.cc b/libmysqlclient/mysql/mysys/mf_wcomp.cc new file mode 120000 index 0000000..02c2d72 --- /dev/null +++ b/libmysqlclient/mysql/mysys/mf_wcomp.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mf_wcomp.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mulalloc.cc b/libmysqlclient/mysql/mysys/mulalloc.cc new file mode 120000 index 0000000..5afce3e --- /dev/null +++ b/libmysqlclient/mysql/mysys/mulalloc.cc @@ -0,0 +1 @@ +../../../upstream/mysys/mulalloc.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_access.cc b/libmysqlclient/mysql/mysys/my_access.cc new file mode 120000 index 0000000..3c85276 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_access.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_access.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_alloc.cc b/libmysqlclient/mysql/mysys/my_alloc.cc new file mode 120000 index 0000000..84e36f2 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_alloc.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_alloc.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_bit.cc b/libmysqlclient/mysql/mysys/my_bit.cc new file mode 120000 index 0000000..050f0bd --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_bit.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_bit.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_bitmap.cc b/libmysqlclient/mysql/mysys/my_bitmap.cc new file mode 120000 index 0000000..8b532bb --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_bitmap.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_bitmap.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_chmod.cc b/libmysqlclient/mysql/mysys/my_chmod.cc new file mode 120000 index 0000000..471133f --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_chmod.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_chmod.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_chsize.cc b/libmysqlclient/mysql/mysys/my_chsize.cc new file mode 120000 index 0000000..fbe7745 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_chsize.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_chsize.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_compare.cc b/libmysqlclient/mysql/mysys/my_compare.cc new file mode 120000 index 0000000..19cc566 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_compare.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_compare.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_compress.cc b/libmysqlclient/mysql/mysys/my_compress.cc new file mode 120000 index 0000000..4ff176e --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_compress.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_compress.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_conio.cc b/libmysqlclient/mysql/mysys/my_conio.cc new file mode 120000 index 0000000..844aa26 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_conio.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_conio.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_copy.cc b/libmysqlclient/mysql/mysys/my_copy.cc new file mode 120000 index 0000000..bc44370 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_copy.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_copy.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_create.cc b/libmysqlclient/mysql/mysys/my_create.cc new file mode 120000 index 0000000..b45c076 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_create.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_create.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_delete.cc b/libmysqlclient/mysql/mysys/my_delete.cc new file mode 120000 index 0000000..1bf38e6 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_delete.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_delete.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_div.cc b/libmysqlclient/mysql/mysys/my_div.cc new file mode 120000 index 0000000..2dbc3e8 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_div.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_div.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_error.cc b/libmysqlclient/mysql/mysys/my_error.cc new file mode 120000 index 0000000..9ebc574 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_error.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_error.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_fallocator.cc b/libmysqlclient/mysql/mysys/my_fallocator.cc new file mode 120000 index 0000000..a86827f --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_fallocator.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_fallocator.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_file.cc b/libmysqlclient/mysql/mysys/my_file.cc new file mode 120000 index 0000000..bbaff4a --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_file.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_file.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_fopen.cc b/libmysqlclient/mysql/mysys/my_fopen.cc new file mode 120000 index 0000000..229ba82 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_fopen.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_fopen.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_fstream.cc b/libmysqlclient/mysql/mysys/my_fstream.cc new file mode 120000 index 0000000..b269697 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_fstream.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_fstream.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_gethwaddr.cc b/libmysqlclient/mysql/mysys/my_gethwaddr.cc new file mode 120000 index 0000000..55763d9 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_gethwaddr.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_gethwaddr.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_getsystime.cc b/libmysqlclient/mysql/mysys/my_getsystime.cc new file mode 120000 index 0000000..048ed3f --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_getsystime.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_getsystime.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_getwd.cc b/libmysqlclient/mysql/mysys/my_getwd.cc new file mode 120000 index 0000000..b4e01f0 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_getwd.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_getwd.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_handler_errors.h b/libmysqlclient/mysql/mysys/my_handler_errors.h new file mode 120000 index 0000000..23b1037 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_handler_errors.h @@ -0,0 +1 @@ +../../../upstream/mysys/my_handler_errors.h \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_init.cc b/libmysqlclient/mysql/mysys/my_init.cc new file mode 120000 index 0000000..98ef919 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_init.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_init.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_largepage.cc b/libmysqlclient/mysql/mysys/my_largepage.cc new file mode 120000 index 0000000..e20955e --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_largepage.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_largepage.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_lib.cc b/libmysqlclient/mysql/mysys/my_lib.cc new file mode 120000 index 0000000..f03f8c1 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_lib.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_lib.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_malloc.cc b/libmysqlclient/mysql/mysys/my_malloc.cc new file mode 120000 index 0000000..92bb2fa --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_malloc.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_malloc.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_mess.cc b/libmysqlclient/mysql/mysys/my_mess.cc new file mode 120000 index 0000000..84d0430 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_mess.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_mess.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_mkdir.cc b/libmysqlclient/mysql/mysys/my_mkdir.cc new file mode 120000 index 0000000..a180e57 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_mkdir.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_mkdir.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_mmap.cc b/libmysqlclient/mysql/mysys/my_mmap.cc new file mode 120000 index 0000000..4d6c5ae --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_mmap.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_mmap.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_murmur3.cc b/libmysqlclient/mysql/mysys/my_murmur3.cc new file mode 120000 index 0000000..519fe48 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_murmur3.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_murmur3.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_once.cc b/libmysqlclient/mysql/mysys/my_once.cc new file mode 120000 index 0000000..558eb69 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_once.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_once.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_open.cc b/libmysqlclient/mysql/mysys/my_open.cc new file mode 120000 index 0000000..df074ad --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_open.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_open.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_pread.cc b/libmysqlclient/mysql/mysys/my_pread.cc new file mode 120000 index 0000000..970c3e2 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_pread.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_pread.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_rdtsc.cc b/libmysqlclient/mysql/mysys/my_rdtsc.cc new file mode 120000 index 0000000..bfbef95 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_rdtsc.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_rdtsc.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_read.cc b/libmysqlclient/mysql/mysys/my_read.cc new file mode 120000 index 0000000..fd332b5 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_read.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_read.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_rename.cc b/libmysqlclient/mysql/mysys/my_rename.cc new file mode 120000 index 0000000..087c283 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_rename.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_rename.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_seek.cc b/libmysqlclient/mysql/mysys/my_seek.cc new file mode 120000 index 0000000..b5787d4 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_seek.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_seek.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_static.cc b/libmysqlclient/mysql/mysys/my_static.cc new file mode 120000 index 0000000..da2bc5d --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_static.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_static.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_static.h b/libmysqlclient/mysql/mysys/my_static.h new file mode 120000 index 0000000..8aff1d8 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_static.h @@ -0,0 +1 @@ +../../../upstream/mysys/my_static.h \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_string.cc b/libmysqlclient/mysql/mysys/my_string.cc new file mode 120000 index 0000000..465a4bd --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_string.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_string.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_symlink.cc b/libmysqlclient/mysql/mysys/my_symlink.cc new file mode 120000 index 0000000..cf6bd73 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_symlink.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_symlink.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_symlink2.cc b/libmysqlclient/mysql/mysys/my_symlink2.cc new file mode 120000 index 0000000..1094124 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_symlink2.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_symlink2.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_sync.cc b/libmysqlclient/mysql/mysys/my_sync.cc new file mode 120000 index 0000000..4246f2e --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_sync.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_sync.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_syslog.cc b/libmysqlclient/mysql/mysys/my_syslog.cc new file mode 120000 index 0000000..149f3de --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_syslog.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_syslog.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_thr_init.cc b/libmysqlclient/mysql/mysys/my_thr_init.cc new file mode 100644 index 0000000..ba10464 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_thr_init.cc @@ -0,0 +1,385 @@ +/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + Without limiting anything contained in the foregoing, this file, + which is part of C Driver for MySQL (Connector/C), is also subject to the + Universal FOSS Exception, version 1.0, a copy of which can be found at + http://oss.oracle.com/licenses/universal-foss-exception. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License, version 2.0, for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + @file mysys/my_thr_init.cc + Functions to handle initialization and allocation of all mysys & debug + thread variables. +*/ + +#include +#include +#ifdef _WIN32 +#include +#endif +#include + +#include "my_dbug.h" +#include "my_inttypes.h" +#include "my_loglevel.h" +#include "my_macros.h" +#include "my_psi_config.h" +#include "my_sys.h" +#include "my_systime.h" +#include "my_thread.h" +#include "my_thread_local.h" +#include "mysql/psi/mysql_cond.h" +#include "mysql/psi/mysql_mutex.h" +#include "mysql/psi/mysql_thread.h" +#include "mysql/psi/psi_thread.h" +#include "mysys/mysys_priv.h" +#include "mysys_err.h" +#include "thr_mutex.h" + +static bool my_thread_global_init_done = false; +#ifndef DBUG_OFF +static uint THR_thread_count = 0; +static uint my_thread_end_wait_time = 5; +static my_thread_id thread_id = 0; +struct st_my_thread_var; +static thread_local st_my_thread_var *THR_mysys = nullptr; +#endif +static thread_local int THR_myerrno = 0; +#ifdef _WIN32 +static thread_local int THR_winerrno = 0; +#endif + +mysql_mutex_t THR_LOCK_myisam_mmap; +mysql_mutex_t THR_LOCK_myisam; +mysql_mutex_t THR_LOCK_heap; +mysql_mutex_t THR_LOCK_malloc; +mysql_mutex_t THR_LOCK_open; +mysql_mutex_t THR_LOCK_lock; +mysql_mutex_t THR_LOCK_net; +mysql_mutex_t THR_LOCK_charset; +#ifndef DBUG_OFF +mysql_mutex_t THR_LOCK_threads; +mysql_cond_t THR_COND_threads; +#endif + +#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP +native_mutexattr_t my_fast_mutexattr; +#endif +#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP +native_mutexattr_t my_errorcheck_mutexattr; +#endif +#ifdef _WIN32 +static void install_sigabrt_handler(); +#endif + +#ifndef DBUG_OFF +struct st_my_thread_var { + my_thread_id id; + struct CODE_STATE *dbug; +}; + +static struct st_my_thread_var *mysys_thread_var() { return THR_mysys; } + +static int set_mysys_thread_var(struct st_my_thread_var *mysys_var) { + THR_mysys = mysys_var; + return 0; +} +#endif + +/** + Re-initialize components initialized early with @c my_thread_global_init. + Some mutexes were initialized before the instrumentation. + Destroy + create them again, now that the instrumentation + is in place. + This is safe, since this function() is called before creating new threads, + so the mutexes are not in use. +*/ + +void my_thread_global_reinit() { + DBUG_ASSERT(my_thread_global_init_done); + +#ifdef HAVE_PSI_INTERFACE + my_init_mysys_psi_keys(); +#endif + + mysql_mutex_destroy(&THR_LOCK_heap); + mysql_mutex_init(key_THR_LOCK_heap, &THR_LOCK_heap, MY_MUTEX_INIT_FAST); + + mysql_mutex_destroy(&THR_LOCK_net); + mysql_mutex_init(key_THR_LOCK_net, &THR_LOCK_net, MY_MUTEX_INIT_FAST); + + mysql_mutex_destroy(&THR_LOCK_myisam); + mysql_mutex_init(key_THR_LOCK_myisam, &THR_LOCK_myisam, MY_MUTEX_INIT_SLOW); + + mysql_mutex_destroy(&THR_LOCK_malloc); + mysql_mutex_init(key_THR_LOCK_malloc, &THR_LOCK_malloc, MY_MUTEX_INIT_FAST); + + mysql_mutex_destroy(&THR_LOCK_open); + mysql_mutex_init(key_THR_LOCK_open, &THR_LOCK_open, MY_MUTEX_INIT_FAST); + + mysql_mutex_destroy(&THR_LOCK_charset); + mysql_mutex_init(key_THR_LOCK_charset, &THR_LOCK_charset, MY_MUTEX_INIT_FAST); + +#ifndef DBUG_OFF + mysql_mutex_destroy(&THR_LOCK_threads); + mysql_mutex_init(key_THR_LOCK_threads, &THR_LOCK_threads, MY_MUTEX_INIT_FAST); + + mysql_cond_destroy(&THR_COND_threads); + mysql_cond_init(key_THR_COND_threads, &THR_COND_threads); +#endif +} + +/** + initialize thread environment + + @retval false ok + @retval true error +*/ + +bool my_thread_global_init() { + if (my_thread_global_init_done) return false; + my_thread_global_init_done = true; + +#if defined(SAFE_MUTEX) + safe_mutex_global_init(); /* Must be called early */ +#endif + +#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP + /* + Set mutex type to "fast" a.k.a "adaptive" + + In this case the thread may steal the mutex from some other thread + that is waiting for the same mutex. This will save us some + context switches but may cause a thread to 'starve forever' while + waiting for the mutex (not likely if the code within the mutex is + short). + */ + pthread_mutexattr_init(&my_fast_mutexattr); + pthread_mutexattr_settype(&my_fast_mutexattr, PTHREAD_MUTEX_ADAPTIVE_NP); +#endif + +#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP + /* + Set mutex type to "errorcheck" + */ + pthread_mutexattr_init(&my_errorcheck_mutexattr); + pthread_mutexattr_settype(&my_errorcheck_mutexattr, PTHREAD_MUTEX_ERRORCHECK); +#endif + + mysql_mutex_init(key_THR_LOCK_malloc, &THR_LOCK_malloc, MY_MUTEX_INIT_FAST); + mysql_mutex_init(key_THR_LOCK_open, &THR_LOCK_open, MY_MUTEX_INIT_FAST); + mysql_mutex_init(key_THR_LOCK_charset, &THR_LOCK_charset, MY_MUTEX_INIT_FAST); + mysql_mutex_init(key_THR_LOCK_lock, &THR_LOCK_lock, MY_MUTEX_INIT_FAST); + mysql_mutex_init(key_THR_LOCK_myisam, &THR_LOCK_myisam, MY_MUTEX_INIT_SLOW); + mysql_mutex_init(key_THR_LOCK_myisam_mmap, &THR_LOCK_myisam_mmap, + MY_MUTEX_INIT_FAST); + mysql_mutex_init(key_THR_LOCK_heap, &THR_LOCK_heap, MY_MUTEX_INIT_FAST); + mysql_mutex_init(key_THR_LOCK_net, &THR_LOCK_net, MY_MUTEX_INIT_FAST); +#ifndef DBUG_OFF + mysql_mutex_init(key_THR_LOCK_threads, &THR_LOCK_threads, MY_MUTEX_INIT_FAST); + mysql_cond_init(key_THR_COND_threads, &THR_COND_threads); +#endif + + return false; +} + +void my_thread_global_end() { +#ifndef DBUG_OFF + struct timespec abstime; + bool all_threads_killed = true; + + set_timespec(&abstime, my_thread_end_wait_time); + mysql_mutex_lock(&THR_LOCK_threads); + while (THR_thread_count > 0) { + int error = + mysql_cond_timedwait(&THR_COND_threads, &THR_LOCK_threads, &abstime); + if (is_timeout(error)) { +#ifndef _WIN32 + /* + We shouldn't give an error here, because if we don't have + pthread_kill(), programs like mysqld can't ensure that all threads + are killed when we enter here. + */ + if (THR_thread_count) /* purecov: begin inspected */ + my_message_local(ERROR_LEVEL, EE_FAILED_TO_KILL_ALL_THREADS, + THR_thread_count); + /* purecov: end */ +#endif + all_threads_killed = false; + break; + } + } + mysql_mutex_unlock(&THR_LOCK_threads); +#endif + +#ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP + pthread_mutexattr_destroy(&my_fast_mutexattr); +#endif +#ifdef PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP + pthread_mutexattr_destroy(&my_errorcheck_mutexattr); +#endif + mysql_mutex_destroy(&THR_LOCK_malloc); + mysql_mutex_destroy(&THR_LOCK_open); + mysql_mutex_destroy(&THR_LOCK_lock); + mysql_mutex_destroy(&THR_LOCK_myisam); + mysql_mutex_destroy(&THR_LOCK_myisam_mmap); + mysql_mutex_destroy(&THR_LOCK_heap); + mysql_mutex_destroy(&THR_LOCK_net); + mysql_mutex_destroy(&THR_LOCK_charset); +#ifndef DBUG_OFF + if (all_threads_killed) { + mysql_mutex_destroy(&THR_LOCK_threads); + mysql_cond_destroy(&THR_COND_threads); + } +#endif + + my_thread_global_init_done = false; +} + +/** + Allocate thread specific memory for the thread, used by mysys and dbug + + @note This function may called multiple times for a thread, for example + if one uses my_init() followed by mysql_server_init(). + + @retval false ok + @retval true Fatal error; mysys/dbug functions can't be used +*/ + +extern "C" bool my_thread_init() { +#ifndef DBUG_OFF + struct st_my_thread_var *tmp; +#endif + + if (!my_thread_global_init_done) + return true; /* cannot proceed with unintialized library */ + +#ifdef _WIN32 + install_sigabrt_handler(); +#endif + +#ifndef DBUG_OFF + if (mysys_thread_var()) return false; + + if (!(tmp = (struct st_my_thread_var *)calloc(1, sizeof(*tmp)))) return true; + + mysql_mutex_lock(&THR_LOCK_threads); + tmp->id = ++thread_id; + ++THR_thread_count; + mysql_mutex_unlock(&THR_LOCK_threads); + set_mysys_thread_var(tmp); +#endif + + return false; +} + +/** + Deallocate memory used by the thread for book-keeping + + @note This may be called multiple times for a thread. + This happens for example when one calls 'mysql_server_init()' + mysql_server_end() and then ends with a mysql_end(). +*/ + +extern "C" void my_thread_end() { +#ifndef DBUG_OFF + struct st_my_thread_var *tmp = mysys_thread_var(); +#endif + +#ifdef HAVE_PSI_THREAD_INTERFACE + /* + Remove the instrumentation for this thread. + This must be done before trashing st_my_thread_var, + because the LF_HASH depends on it. + */ + PSI_THREAD_CALL(delete_current_thread)(); +#endif + +#if !defined(DBUG_OFF) + if (tmp) { + /* tmp->dbug is allocated inside DBUG library */ + if (tmp->dbug) { + DBUG_POP(); + free(tmp->dbug); + tmp->dbug = NULL; + } + free(tmp); + + /* + Decrement counter for number of running threads. We are using this + in my_thread_global_end() to wait until all threads have called + my_thread_end and thus freed all memory they have allocated in + my_thread_init() and DBUG_xxxx + */ + mysql_mutex_lock(&THR_LOCK_threads); + DBUG_ASSERT(THR_thread_count != 0); + if (--THR_thread_count == 0) mysql_cond_signal(&THR_COND_threads); + mysql_mutex_unlock(&THR_LOCK_threads); + } + set_mysys_thread_var(NULL); +#endif +} + +int my_errno() { return THR_myerrno; } + +void set_my_errno(int my_errno) { THR_myerrno = my_errno; } + +#ifdef _WIN32 +int thr_winerr() { return THR_winerrno; } + +void set_thr_winerr(int winerr) { THR_winerrno = winerr; } +#endif + +#ifndef DBUG_OFF +my_thread_id my_thread_var_id() { return mysys_thread_var()->id; } + +void set_my_thread_var_id(my_thread_id id) { mysys_thread_var()->id = id; } + +CODE_STATE **my_thread_var_dbug() { + struct st_my_thread_var *tmp = THR_mysys; + return tmp ? &tmp->dbug : NULL; +} +#endif /* DBUG_OFF */ + +#ifdef _WIN32 +/* + In Visual Studio 2005 and later, default SIGABRT handler will overwrite + any unhandled exception filter set by the application and will try to + call JIT debugger. This is not what we want, this we calling __debugbreak + to stop in debugger, if process is being debugged or to generate + EXCEPTION_BREAKPOINT and then handle_segfault will do its magic. +*/ + +static void my_sigabrt_handler(int sig) { __debugbreak(); } + +static void install_sigabrt_handler() { + /*abort() should not override our exception filter*/ + + // Requires msvcrt90 or later but forcing this in a library is + // probably not a good idea. + // +#ifndef __MINGW32__ + _set_abort_behavior(0, _CALL_REPORTFAULT); +#endif + signal(SIGABRT, my_sigabrt_handler); +} +#endif diff --git a/libmysqlclient/mysql/mysys/my_thr_init.cc.orig b/libmysqlclient/mysql/mysys/my_thr_init.cc.orig new file mode 120000 index 0000000..cf23bc8 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_thr_init.cc.orig @@ -0,0 +1 @@ +../../../upstream/mysys/my_thr_init.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_thread.cc b/libmysqlclient/mysql/mysys/my_thread.cc new file mode 120000 index 0000000..9e79b5a --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_thread.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_thread.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_time.cc b/libmysqlclient/mysql/mysys/my_time.cc new file mode 120000 index 0000000..429ec3f --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_time.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_time.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_timespec.cc b/libmysqlclient/mysql/mysys/my_timespec.cc new file mode 120000 index 0000000..ddf2c33 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_timespec.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_timespec.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_user.cc b/libmysqlclient/mysql/mysys/my_user.cc new file mode 120000 index 0000000..c43c366 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_user.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_user.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_windac.cc b/libmysqlclient/mysql/mysys/my_windac.cc new file mode 120000 index 0000000..7520971 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_windac.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_windac.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_winerr.cc b/libmysqlclient/mysql/mysys/my_winerr.cc new file mode 120000 index 0000000..a5ef48e --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_winerr.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_winerr.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_winfile.cc b/libmysqlclient/mysql/mysys/my_winfile.cc new file mode 120000 index 0000000..bc4f86f --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_winfile.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_winfile.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/my_write.cc b/libmysqlclient/mysql/mysys/my_write.cc new file mode 120000 index 0000000..b867c30 --- /dev/null +++ b/libmysqlclient/mysql/mysys/my_write.cc @@ -0,0 +1 @@ +../../../upstream/mysys/my_write.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/mysys_priv.h b/libmysqlclient/mysql/mysys/mysys_priv.h new file mode 120000 index 0000000..5cd0b9a --- /dev/null +++ b/libmysqlclient/mysql/mysys/mysys_priv.h @@ -0,0 +1 @@ +../../../upstream/mysys/mysys_priv.h \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/pack.cc b/libmysqlclient/mysql/mysys/pack.cc new file mode 120000 index 0000000..23feed3 --- /dev/null +++ b/libmysqlclient/mysql/mysys/pack.cc @@ -0,0 +1 @@ +../../../upstream/mysys/pack.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/posix_timers.cc b/libmysqlclient/mysql/mysys/posix_timers.cc new file mode 120000 index 0000000..9b56f9f --- /dev/null +++ b/libmysqlclient/mysql/mysys/posix_timers.cc @@ -0,0 +1 @@ +../../../upstream/mysys/posix_timers.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/print_version.cc b/libmysqlclient/mysql/mysys/print_version.cc new file mode 120000 index 0000000..1339d65 --- /dev/null +++ b/libmysqlclient/mysql/mysys/print_version.cc @@ -0,0 +1 @@ +../../../upstream/mysys/print_version.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/psi_noop.cc b/libmysqlclient/mysql/mysys/psi_noop.cc new file mode 120000 index 0000000..766cc41 --- /dev/null +++ b/libmysqlclient/mysql/mysys/psi_noop.cc @@ -0,0 +1 @@ +../../../upstream/mysys/psi_noop.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/ptr_cmp.cc b/libmysqlclient/mysql/mysys/ptr_cmp.cc new file mode 120000 index 0000000..a972834 --- /dev/null +++ b/libmysqlclient/mysql/mysys/ptr_cmp.cc @@ -0,0 +1 @@ +../../../upstream/mysys/ptr_cmp.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/sql_chars.cc b/libmysqlclient/mysql/mysys/sql_chars.cc new file mode 120000 index 0000000..33ae259 --- /dev/null +++ b/libmysqlclient/mysql/mysys/sql_chars.cc @@ -0,0 +1 @@ +../../../upstream/mysys/sql_chars.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/stacktrace.cc b/libmysqlclient/mysql/mysys/stacktrace.cc new file mode 100644 index 0000000..9f7e443 --- /dev/null +++ b/libmysqlclient/mysql/mysys/stacktrace.cc @@ -0,0 +1,784 @@ +/* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2.0, + as published by the Free Software Foundation. + + This program is also distributed with certain software (including + but not limited to OpenSSL) that is licensed under separate terms, + as designated in a particular file or component or in included license + documentation. The authors of MySQL hereby grant you an additional + permission to link the program and your derivative works with the + separately licensed software that they have included with MySQL. + + Without limiting anything contained in the foregoing, this file, + which is part of C Driver for MySQL (Connector/C), is also subject to the + Universal FOSS Exception, version 1.0, a copy of which can be found at + http://oss.oracle.com/licenses/universal-foss-exception. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License, version 2.0, for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + +/** + @file mysys/stacktrace.cc +*/ + +#include "my_config.h" + +#include +#include +#include +#include +#include +#include +#include +#ifdef __linux__ +#include +#endif +#include + +#include "my_inttypes.h" +#include "my_macros.h" +#include "my_stacktrace.h" + +#ifndef _WIN32 +#include + +#include "my_thread.h" +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_STACKTRACE + +#ifdef __linux__ +#include /* isprint */ +#endif + +#ifdef HAVE_EXECINFO_H +#include +#endif + +#ifdef __linux__ +/* __bss_start doesn't seem to work on FreeBSD and doesn't exist on OSX/Solaris. + */ +#define PTR_SANE(p) \ + ((p) && (char *)(p) >= heap_start && (char *)(p) <= heap_end) +static char *heap_start; +extern char *__bss_start; +#else +#define PTR_SANE(p) (p) +#endif /* __linux */ + +void my_init_stacktrace() { +#ifdef __linux__ + heap_start = (char *)&__bss_start; +#endif /* __linux__ */ +} + +#ifdef __linux__ + +static void print_buffer(char *buffer, size_t count) { + const char s[] = " "; + for (; count && *buffer; --count) { + my_write_stderr(isprint(*buffer) ? buffer : s, 1); + ++buffer; + } +} + +/** + Access the pages of this process through /proc/self/task//mem + in order to safely print the contents of a memory address range. + + @param addr The address at the start of the memory region. + @param max_len The length of the memory region. + + @return Zero on success. +*/ +static int safe_print_str(const char *addr, int max_len) { + int fd; + pid_t tid; + off_t offset; + ssize_t nbytes = 0; + size_t total, count; + char buf[256]; + + tid = (pid_t)syscall(SYS_gettid); + + sprintf(buf, "/proc/self/task/%d/mem", tid); + + if ((fd = open(buf, O_RDONLY)) < 0) return -1; + + static_assert(sizeof(off_t) >= sizeof(intptr), + "off_t needs to be able to hold a pointer."); + + total = max_len; + offset = (intptr)addr; + + /* Read up to the maximum number of bytes. */ + while (total) { + count = MY_MIN(sizeof(buf), total); + + if ((nbytes = pread(fd, buf, count, offset)) < 0) { + /* Just in case... */ + if (errno == EINTR) + continue; + else + break; + } + + /* Advance offset into memory. */ + total -= nbytes; + offset += nbytes; + addr += nbytes; + + /* Output the printable characters. */ + print_buffer(buf, nbytes); + + /* Break if less than requested... */ + if ((count - nbytes)) break; + } + + /* Output a new line if something was printed. */ + if (total != (size_t)max_len) my_safe_printf_stderr("%s", "\n"); + + if (nbytes == -1) my_safe_printf_stderr("Can't read from address %p\n", addr); + + close(fd); + + return 0; +} + +#endif /* __linux __ */ + +void my_safe_puts_stderr(const char *val, size_t max_len) { +#ifdef __linux__ + if (!safe_print_str(val, max_len)) return; + + /* Only needed by the linux version of PTR_SANE */ + char *heap_end = (char *)sbrk(0); +#endif + + if (!PTR_SANE(val)) { + my_safe_printf_stderr("%s", "is an invalid pointer\n"); + return; + } + + for (; max_len && PTR_SANE(val) && *val; --max_len) + my_write_stderr((val++), 1); + my_safe_printf_stderr("%s", "\n"); +} + +#if defined(HAVE_PRINTSTACK) + +/* Use Solaris' symbolic stack trace routine. */ +#include + +void my_print_stacktrace(uchar *stack_bottom MY_ATTRIBUTE((unused)), + ulong thread_stack MY_ATTRIBUTE((unused))) { + if (printstack(fileno(stderr)) == -1) + my_safe_printf_stderr( + "%s", "Error when traversing the stack, stack appears corrupt.\n"); + else + my_safe_printf_stderr( + "Please read " + "http://dev.mysql.com/doc/refman/%u.%u/en/resolve-stack-dump.html\n" + "and follow instructions on how to resolve the stack trace.\n" + "Resolved stack trace is much more helpful in diagnosing the\n" + "problem, so please do resolve it\n", + MYSQL_VERSION_MAJOR, MYSQL_VERSION_MINOR); +} + +#elif defined(HAVE_BACKTRACE) + +#ifdef HAVE_ABI_CXA_DEMANGLE + +#include + +static char *my_demangle(const char *mangled_name, int *status) { + return abi::__cxa_demangle(mangled_name, NULL, NULL, status); +} + +static bool my_demangle_symbol(char *line) { + char *demangled = NULL; +#ifdef __APPLE__ // OS X formatting of stacktraces is different from Linux + char *begin = strstr(line, "_Z"); + char *end = begin ? strchr(begin, ' ') : NULL; + + if (begin && end) { + begin[-1] = '\0'; + *end = '\0'; + int status; + demangled = my_demangle(begin, &status); + if (!demangled || status) { + demangled = NULL; + begin[-1] = '_'; + *end = ' '; + } + } + if (demangled) my_safe_printf_stderr("%s %s %s\n", line, demangled, end + 1); +#else // !__APPLE__ + char *begin = strchr(line, '('); + char *end = begin ? strchr(begin, '+') : NULL; + + if (begin && end) { + *begin++ = *end++ = '\0'; + int status; + demangled = my_demangle(begin, &status); + if (!demangled || status) { + demangled = NULL; + begin[-1] = '('; + end[-1] = '+'; + } + } + if (demangled) my_safe_printf_stderr("%s(%s+%s\n", line, demangled, end); +#endif // !__APPLE__ + bool ret = (demangled == NULL); + free(demangled); + return (ret); +} + +static void my_demangle_symbols(char **addrs, int n) { + for (int i = 0; i < n; i++) { + if (my_demangle_symbol(addrs[i])) // demangling failed + my_safe_printf_stderr("%s\n", addrs[i]); + } +} + +#endif /* HAVE_ABI_CXA_DEMANGLE */ + +void my_print_stacktrace(uchar *stack_bottom, ulong thread_stack) { + void *addrs[128]; + char **strings = NULL; + int n = backtrace(addrs, array_elements(addrs)); + my_safe_printf_stderr("stack_bottom = %p thread_stack 0x%lx\n", stack_bottom, + thread_stack); +#ifdef HAVE_ABI_CXA_DEMANGLE + if ((strings = backtrace_symbols(addrs, n))) { + my_demangle_symbols(strings, n); + free(strings); + } +#endif + if (!strings) { + backtrace_symbols_fd(addrs, n, fileno(stderr)); + } +} + +#endif /* HAVE_PRINTSTACK || HAVE_BACKTRACE */ +#endif /* HAVE_STACKTRACE */ + +/* Produce a core for the thread */ +void my_write_core(int sig) { + signal(sig, SIG_DFL); + pthread_kill(my_thread_self(), sig); +#if defined(P_MYID) + /* On Solaris, the above kill is not enough */ + sigsend(P_PID, P_MYID, sig); +#endif +} + +#else /* _WIN32*/ + +#include +#include +#if _MSC_VER +#pragma comment(lib, "dbghelp") +#endif + +static EXCEPTION_POINTERS *exception_ptrs; + +#define MODULE64_SIZE_WINXP 576 +#define STACKWALK_MAX_FRAMES 64 + +void my_init_stacktrace() {} + +void my_set_exception_pointers(EXCEPTION_POINTERS *ep) { exception_ptrs = ep; } + +/* + Appends directory to symbol path. +*/ +static void add_to_symbol_path(char *path, size_t path_buffer_size, char *dir, + size_t dir_buffer_size) { + strcat_s(dir, dir_buffer_size, ";"); + if (!strstr(path, dir)) { + strcat_s(path, path_buffer_size, dir); + } +} + +/* + Get symbol path - semicolon-separated list of directories to search for debug + symbols. We expect PDB in the same directory as corresponding exe or dll, + so the path is build from directories of the loaded modules. If environment + variable _NT_SYMBOL_PATH is set, it's value appended to the symbol search path +*/ +static void get_symbol_path(char *path, size_t size) { + HANDLE hSnap; + char *envvar; + char *p; +#ifndef DBUG_OFF + static char pdb_debug_dir[MAX_PATH + 7]; +#endif + + path[0] = '\0'; + +#ifndef DBUG_OFF + /* + Add "debug" subdirectory of the application directory, sometimes PDB will + placed here by installation. + */ + GetModuleFileName(NULL, pdb_debug_dir, MAX_PATH); + p = strrchr(pdb_debug_dir, '\\'); + if (p) { + *p = 0; + strcat_s(pdb_debug_dir, sizeof(pdb_debug_dir), "\\debug;"); + add_to_symbol_path(path, size, pdb_debug_dir, sizeof(pdb_debug_dir)); + } +#endif + + /* + Enumerate all modules, and add their directories to the path. + Avoid duplicate entries. + */ + hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, GetCurrentProcessId()); + if (hSnap != INVALID_HANDLE_VALUE) { + BOOL ret; + MODULEENTRY32 mod; + mod.dwSize = sizeof(MODULEENTRY32); + for (ret = Module32First(hSnap, &mod); ret; + ret = Module32Next(hSnap, &mod)) { + char *module_dir = mod.szExePath; + p = strrchr(module_dir, '\\'); + if (!p) { + /* + Path separator was not found. Not known to happen, if ever happens, + will indicate current directory. + */ + module_dir[0] = '.'; + module_dir[1] = '\0'; + } else { + *p = '\0'; + } + add_to_symbol_path(path, size, module_dir, sizeof(mod.szExePath)); + } + CloseHandle(hSnap); + } + + /* Add _NT_SYMBOL_PATH, if present. */ + envvar = getenv("_NT_SYMBOL_PATH"); + if (envvar) { + strcat_s(path, size, envvar); + } +} + +#define MAX_SYMBOL_PATH 32768 + +/* Platform SDK in VS2003 does not have definition for SYMOPT_NO_PROMPTS*/ +#ifndef SYMOPT_NO_PROMPTS +#define SYMOPT_NO_PROMPTS 0 +#endif + +void my_print_stacktrace(uchar *unused1, ulong unused2) { + HANDLE hProcess = GetCurrentProcess(); + HANDLE hThread = GetCurrentThread(); + static IMAGEHLP_MODULE64 module = {sizeof(module)}; + static IMAGEHLP_SYMBOL64_PACKAGE package; + DWORD64 addr; + DWORD machine; + int i; + CONTEXT context; + STACKFRAME64 frame = {0}; + static char symbol_path[MAX_SYMBOL_PATH]; + + if (!exception_ptrs) return; + + /* Copy context, as stackwalking on original will unwind the stack */ + context = *(exception_ptrs->ContextRecord); + /*Initialize symbols.*/ + SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_NO_PROMPTS | SYMOPT_DEFERRED_LOADS | + SYMOPT_DEBUG); + get_symbol_path(symbol_path, sizeof(symbol_path)); + SymInitialize(hProcess, symbol_path, true); + + /*Prepare stackframe for the first StackWalk64 call*/ + frame.AddrFrame.Mode = frame.AddrPC.Mode = frame.AddrStack.Mode = + AddrModeFlat; +#if (defined _M_X64) + machine = IMAGE_FILE_MACHINE_AMD64; + frame.AddrFrame.Offset = context.Rbp; + frame.AddrPC.Offset = context.Rip; + frame.AddrStack.Offset = context.Rsp; +#else + /*There is currently no need to support IA64*/ +#pragma error("unsupported architecture") +#endif + + package.sym.SizeOfStruct = sizeof(package.sym); + package.sym.MaxNameLength = sizeof(package.name); + + /*Walk the stack, output useful information*/ + for (i = 0; i < STACKWALK_MAX_FRAMES; i++) { + DWORD64 function_offset = 0; + DWORD line_offset = 0; + IMAGEHLP_LINE64 line = {sizeof(line)}; + BOOL have_module = false; + BOOL have_symbol = false; + BOOL have_source = false; + + if (!StackWalk64(machine, hProcess, hThread, &frame, &context, 0, 0, 0, 0)) + break; + addr = frame.AddrPC.Offset; + + have_module = SymGetModuleInfo64(hProcess, addr, &module); + have_symbol = + SymGetSymFromAddr64(hProcess, addr, &function_offset, &(package.sym)); + have_source = SymGetLineFromAddr64(hProcess, addr, &line_offset, &line); + + my_safe_printf_stderr("%p ", addr); + if (have_module) { + char *base_image_name = strrchr(module.ImageName, '\\'); + if (base_image_name) + base_image_name++; + else + base_image_name = module.ImageName; + my_safe_printf_stderr("%s!", base_image_name); + } + if (have_symbol) + my_safe_printf_stderr("%s()", package.sym.Name); + + else if (have_module) + my_safe_printf_stderr("%s", "???"); + + if (have_source) { + char *base_file_name = strrchr(line.FileName, '\\'); + if (base_file_name) + base_file_name++; + else + base_file_name = line.FileName; + my_safe_printf_stderr("[%s:%u]", base_file_name, line.LineNumber); + } + my_safe_printf_stderr("%s", "\n"); + } +} + +/* + Write dump. The dump is created in current directory, + file name is constructed from executable name plus + ".dmp" extension +*/ +void my_write_core(int unused) { + char path[MAX_PATH]; + // See comment below for clarification about size of dump_fname + char dump_fname[MAX_PATH + 1 + 10 + 4 + 1] = "core.dmp"; + + if (!exception_ptrs) return; + + if (GetModuleFileName(NULL, path, sizeof(path))) { + char module_name[MAX_PATH]; + _splitpath(path, NULL, NULL, module_name, NULL); + // max length of a value being placed to dump_fname is + // MAX_PATH + 1 byte for '.' + up to 10 bytes for string + // representation of DWORD value + 4 bytes for .dmp suffix + + // 1 byte for termitated \0. Such size of output buffer guarantees + // that there is enough space to place a result of string formatting + // performed by snprintf(). + snprintf(dump_fname, sizeof(dump_fname), "%s.%u.dmp", module_name, + GetCurrentProcessId()); + } + my_create_minidump(dump_fname, 0, 0); +} + +/** Create a minidump. + @param name path of minidump file. + @param process HANDLE to process. (0 for own process). + @param pid Process id. +*/ + +void my_create_minidump(const char *name, HANDLE process, DWORD pid) { + char path[MAX_PATH]; + MINIDUMP_EXCEPTION_INFORMATION info; + PMINIDUMP_EXCEPTION_INFORMATION info_ptr = NULL; + HANDLE hFile; + + if (process == 0) { + /* Does not need to CloseHandle() for the below. */ + process = GetCurrentProcess(); + pid = GetCurrentProcessId(); + info.ExceptionPointers = exception_ptrs; + info.ClientPointers = false; + info.ThreadId = GetCurrentThreadId(); + info_ptr = &info; + } + + hFile = CreateFile(name, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, 0); + if (hFile) { + MINIDUMP_TYPE mdt = + (MINIDUMP_TYPE)(MiniDumpNormal | MiniDumpWithThreadInfo | + MiniDumpWithProcessThreadData); + /* Create minidump, use info only if same process. */ + if (MiniDumpWriteDump(process, pid, hFile, mdt, info_ptr, 0, 0)) { + my_safe_printf_stderr("Minidump written to %s\n", + _fullpath(path, name, sizeof(path)) ? path : name); + } else { + my_safe_printf_stderr("MiniDumpWriteDump() failed, last error %d\n", + GetLastError()); + } + CloseHandle(hFile); + } else { + my_safe_printf_stderr("CreateFile(%s) failed, last error %d\n", name, + GetLastError()); + } +} + +void my_safe_puts_stderr(const char *val, size_t len) { +#ifndef __MINGW32__ + __try { +#endif + my_write_stderr(val, len); + my_safe_printf_stderr("%s", "\n"); +#ifndef __MINGW32__ + } __except (EXCEPTION_EXECUTE_HANDLER) { + my_safe_printf_stderr("%s", "is an invalid string pointer\n"); + } +#endif +} +#endif /* _WIN32 */ + +#ifdef _WIN32 +size_t my_write_stderr(const void *buf, size_t count) { + DWORD bytes_written; + SetFilePointer(GetStdHandle(STD_ERROR_HANDLE), 0, NULL, FILE_END); + WriteFile(GetStdHandle(STD_ERROR_HANDLE), buf, (DWORD)count, &bytes_written, + NULL); + return bytes_written; +} +#else +size_t my_write_stderr(const void *buf, size_t count) { + return (size_t)write(STDERR_FILENO, buf, count); +} +#endif + +static const char digits[] = "0123456789abcdef"; + +char *my_safe_utoa(int base, ulonglong val, char *buf) { + *buf-- = 0; + do { + *buf-- = digits[val % base]; + } while ((val /= base) != 0); + return buf + 1; +} + +char *my_safe_itoa(int base, longlong val, char *buf) { + char *orig_buf = buf; + const bool is_neg = (val < 0); + *buf-- = 0; + + if (is_neg) val = -val; + if (is_neg && base == 16) { + int ix; + val -= 1; + for (ix = 0; ix < 16; ++ix) buf[-ix] = '0'; + } + + do { + *buf-- = digits[val % base]; + } while ((val /= base) != 0); + + if (is_neg && base == 10) *buf-- = '-'; + + if (is_neg && base == 16) { + int ix; + buf = orig_buf - 1; + for (ix = 0; ix < 16; ++ix, --buf) { + switch (*buf) { + case '0': + *buf = 'f'; + break; + case '1': + *buf = 'e'; + break; + case '2': + *buf = 'd'; + break; + case '3': + *buf = 'c'; + break; + case '4': + *buf = 'b'; + break; + case '5': + *buf = 'a'; + break; + case '6': + *buf = '9'; + break; + case '7': + *buf = '8'; + break; + case '8': + *buf = '7'; + break; + case '9': + *buf = '6'; + break; + case 'a': + *buf = '5'; + break; + case 'b': + *buf = '4'; + break; + case 'c': + *buf = '3'; + break; + case 'd': + *buf = '2'; + break; + case 'e': + *buf = '1'; + break; + case 'f': + *buf = '0'; + break; + } + } + } + return buf + 1; +} + +static const char *check_longlong(const char *fmt, bool *have_longlong) { + *have_longlong = false; + if (*fmt == 'l') { + fmt++; + if (*fmt != 'l') + *have_longlong = (sizeof(long) == sizeof(longlong)); + else { + fmt++; + *have_longlong = true; + } + } + return fmt; +} + +static size_t my_safe_vsnprintf(char *to, size_t size, const char *format, + va_list ap) { + char *start = to; + char *end = start + size - 1; + for (; *format; ++format) { + bool have_longlong = false; + if (*format != '%') { + if (to == end) /* end of buffer */ + break; + *to++ = *format; /* copy ordinary char */ + continue; + } + ++format; /* skip '%' */ + + format = check_longlong(format, &have_longlong); + + switch (*format) { + case 'd': + case 'i': + case 'u': + case 'x': + case 'p': { + longlong ival = 0; + ulonglong uval = 0; + if (*format == 'p') + have_longlong = (sizeof(void *) == sizeof(longlong)); + if (have_longlong) { + if (*format == 'u') + uval = va_arg(ap, ulonglong); + else + ival = va_arg(ap, longlong); + } else { + if (*format == 'u') + uval = va_arg(ap, unsigned int); + else + ival = va_arg(ap, int); + } + + { + char buff[22]; + const int base = (*format == 'x' || *format == 'p') ? 16 : 10; + char *val_as_str = + (*format == 'u') + ? my_safe_utoa(base, uval, &buff[sizeof(buff) - 1]) + : my_safe_itoa(base, ival, &buff[sizeof(buff) - 1]); + + /* + Strip off "ffffffff" if we have 'x' format without 'll' + Similarly for 'p' format on 32bit systems. + */ + if (base == 16 && !have_longlong && ival < 0) val_as_str += 8; + + while (*val_as_str && to < end) *to++ = *val_as_str++; + continue; + } + } + case 's': { + const char *val = va_arg(ap, char *); + if (!val) val = "(null)"; + while (*val && to < end) *to++ = *val++; + continue; + } + } + } + *to = 0; + return to - start; +} + +size_t my_safe_snprintf(char *to, size_t n, const char *fmt, ...) { + size_t result; + va_list args; + va_start(args, fmt); + result = my_safe_vsnprintf(to, n, fmt, args); + va_end(args); + return result; +} + +size_t my_safe_printf_stderr(const char *fmt, ...) { + char to[512]; + size_t result; + va_list args; + va_start(args, fmt); + result = my_safe_vsnprintf(to, sizeof(to), fmt, args); + va_end(args); + my_write_stderr(to, result); + return result; +} + +void my_safe_print_system_time() { + char hrs_buf[3] = "00"; + char mins_buf[3] = "00"; + char secs_buf[3] = "00"; + int base = 10; +#ifdef _WIN32 + SYSTEMTIME utc_time; + long hrs, mins, secs; + GetSystemTime(&utc_time); + hrs = utc_time.wHour; + mins = utc_time.wMinute; + secs = utc_time.wSecond; +#else + /* Using time() instead of my_time() to avoid looping */ + const time_t curr_time = time(NULL); + /* Calculate time of day */ + const long tmins = curr_time / 60; + const long thrs = tmins / 60; + const long hrs = thrs % 24; + const long mins = tmins % 60; + const long secs = curr_time % 60; +#endif + + my_safe_itoa(base, hrs, &hrs_buf[2]); + my_safe_itoa(base, mins, &mins_buf[2]); + my_safe_itoa(base, secs, &secs_buf[2]); + + my_safe_printf_stderr("---------- %s:%s:%s UTC - ", hrs_buf, mins_buf, + secs_buf); +} diff --git a/libmysqlclient/mysql/mysys/stacktrace.cc.orig b/libmysqlclient/mysql/mysys/stacktrace.cc.orig new file mode 120000 index 0000000..ca3963b --- /dev/null +++ b/libmysqlclient/mysql/mysys/stacktrace.cc.orig @@ -0,0 +1 @@ +../../../upstream/mysys/stacktrace.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/thr_cond.cc b/libmysqlclient/mysql/mysys/thr_cond.cc new file mode 120000 index 0000000..366c4bb --- /dev/null +++ b/libmysqlclient/mysql/mysys/thr_cond.cc @@ -0,0 +1 @@ +../../../upstream/mysys/thr_cond.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/thr_lock.cc b/libmysqlclient/mysql/mysys/thr_lock.cc new file mode 120000 index 0000000..607d646 --- /dev/null +++ b/libmysqlclient/mysql/mysys/thr_lock.cc @@ -0,0 +1 @@ +../../../upstream/mysys/thr_lock.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/thr_mutex.cc b/libmysqlclient/mysql/mysys/thr_mutex.cc new file mode 120000 index 0000000..85bbc0f --- /dev/null +++ b/libmysqlclient/mysql/mysys/thr_mutex.cc @@ -0,0 +1 @@ +../../../upstream/mysys/thr_mutex.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/thr_rwlock.cc b/libmysqlclient/mysql/mysys/thr_rwlock.cc new file mode 120000 index 0000000..f04a455 --- /dev/null +++ b/libmysqlclient/mysql/mysys/thr_rwlock.cc @@ -0,0 +1 @@ +../../../upstream/mysys/thr_rwlock.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/tree.cc b/libmysqlclient/mysql/mysys/tree.cc new file mode 120000 index 0000000..c34b980 --- /dev/null +++ b/libmysqlclient/mysql/mysys/tree.cc @@ -0,0 +1 @@ +../../../upstream/mysys/tree.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/typelib.cc b/libmysqlclient/mysql/mysys/typelib.cc new file mode 120000 index 0000000..c72b6af --- /dev/null +++ b/libmysqlclient/mysql/mysys/typelib.cc @@ -0,0 +1 @@ +../../../upstream/mysys/typelib.cc \ No newline at end of file diff --git a/libmysqlclient/mysql/mysys/win_timers.cc b/libmysqlclient/mysql/mysys/win_timers.cc new file mode 120000 index 0000000..2c61b10 --- /dev/null +++ b/libmysqlclient/mysql/mysys/win_timers.cc @@ -0,0 +1 @@ +../../../upstream/mysys/win_timers.cc \ No newline at end of file -- cgit v1.1