In the merge 9e6e43551f
we made Atomic_counter a more generic wrapper of std::atomic
so that dict_index_t would support the implicit assignment operator.
It is better to revert the changes to Atomic_counter and
instead introduce Atomic_relaxed as a generic wrapper to std::atomic.
Unlike Atomic_counter, we will not define operator++, operator+=
or similar, because we want to make the operations more explicit
in the users of Atomic_wrapper, because unlike loads and stores,
atomic read-modify-write operations always incur some overhead.
Moved gcc specific code to gcc_builtins.h.
Moved intptr into the black magic code block.
Moved definition of atomic operations for "long" out of black magic code block.
Removed gcc transparent union hack that was supposed to suppress gcc warnings.
If there're warnings still it is to be fixed differently and the fix should
be platform independent.
Clean-up nolock.h: it doesn't serve any purpose anymore. Appropriate code moved
to x86-gcc.h and my_atomic.h.
If gcc sync bultins were detected, we want to make use of them independently of
__GNUC__ definition. E.g. XLC simulates those, but doesn't define __GNUC__.
HS/Spider: According to AIX manual alloca() returns char*, which cannot be
casted to any type with static_cast. Use explicit cast instead.
MDL: Removed namemangling pragma, which didn't let MariaDB build with XLC.
WSREP: _int64 seem to be conflicting name with XLC, replaced with _integer64.
CONNECT: RTLD_NOLOAD is GNU extention. Removed rather meaningless check if
library is loaded. Multiple dlopen()'s of the same library are permitted,
and it never gets closed anyway. Except for error, which was a bug: it may
close library, which can still be referenced by other subsystems.
InnoDB: __ppc_get_timebase() is GNU extention. Only use it when __GLIBC__ is
defined.
Based on contribution by flynn1973.
Replaced InnoDB atomic operations with server atomic operations.
Moved INNODB_RW_LOCKS_USE_ATOMICS - it is always defined (code won't compile
otherwise).
NOTE: InnoDB uses thread identifiers as a target for atomic operations.
Thread identifiers should be considered opaque: any attempt to use a
thread ID other than in pthreads calls is nonportable and can lead to
unspecified results.
Creating a CONNECT object on client connect and pass this to the working thread which creates the THD.
Split LOCK_thread_count to different mutexes
Added LOCK_thread_start to syncronize threads
Moved most usage of LOCK_thread_count to dedicated functions
Use next_thread_id() instead of thread_id++
Other things:
- Thread id now starts from 1 instead of 2
- Added cast for thread_id as thread id is now of type my_thread_id
- Made THD->host const (To ensure it's not changed)
- Removed some DBUG_PRINT() about entering/exiting mutex as these was already logged by mutex code
- Fixed that aborted_connects and connection_errors_internal are counted in all cases
- Don't take locks for current_linfo when we set it (not needed as it was 0 before)
Added API for atomic operations with explicit memory barrier. Only gcc
atomic builtins are currently supported. If they're unavailable, fall
back to atomic operations with implicit full memory barrier.
Remove wrappers around inline -- static inline is used without
wrappers throughout the source code. We rely on the compiler or
linker to eliminate unused static functions.
Bug#52261: 64 bit atomic operations do not work on Solaris i386
gcc in debug compilation
One of the various problems was that the source operand to
CMPXCHG8b was marked as a input/output operand, causing GCC
to use the EBX register as the destination register for the
CMPXCHG8b instruction. This could lead to crashes as the EBX
register is also implicitly used by the instruction, causing
the value to be potentially garbaged and a protection fault
once the value is used to access a position in memory.
Another problem was the lack of proper clobbers for the atomic
operations and, also, a discrepancy between the implementations
for the Compare and Set operation. The specific problems are
described and fixed by Kristian Nielsen patches:
Patch: 1
Fix bugs in my_atomic_cas*(val,cmp,new) that *cmp is accessed
after CAS succeds.
In the gcc builtin implementation, problem was that *cmp was
read again after atomic CAS to check if old *val == *cmp;
this fails if CAS is successful and another thread modifies
*cmp in-between.
In the x86-gcc implementation, problem was that *cmp was set
also in the case of successful CAS; this means there is a
window where it can clobber a value written by another thread
after successful CAS.
Patch 2:
Add a GCC asm "memory" clobber to primitives that imply a
memory barrier.
This signifies to GCC that any potentially aliased memory
must be flushed before the operation, and re-read after the
operation, so that read or modification in other threads of
such memory values will work as intended.
In effect, it makes these primitives work as memory barriers
for the compiler as well as the CPU. This is better and more
correct than adding "volatile" to variables.
include/atomic/gcc_builtins.h:
Do not read from *cmp after the operation as it might be
already gone if the operation was successful.
include/atomic/nolock.h:
Prefer system provided atomics over the broken x86 asm.
include/atomic/x86-gcc.h:
Do not mark source operands as input/output operands.
Add proper memory clobbers.
include/my_atomic.h:
Add notes about my_atomic_add and my_atomic_cas behaviors.
unittest/mysys/my_atomic-t.c:
Remove work around, if it fails, there is either a problem
with the atomic operations code or the specific compiler
version should be black-listed.
The atomic operations implementation on 5.1 has a few problems,
which might cause tests to abort randomly. Since no code in 5.1
uses atomic operations, simply remove the code.
Solaris 10 Sparc 64bit.
include/my_atomic.h:
Prototypes in the non-inline (extern) case were wrong: they were
missing "U_a" i.e. "volatile *". Caused a segfault in my_atomic-t
on Solaris10 Sparc 64.
storage/maria/ma_loghandler.c:
Move "buffer" array up in the struct, to get it aligned on long-boundary
so that page cache can use bmove512() (it was not aligned and bmove512()
was used, causing SIGBUS on Solaris10 Sparc 64).
storage/maria/unittest/ma_pagecache_consist.c:
doing *(uint*)(charbuff)=something is not ok on sparc machines, we must
use int4store/uint4korr. Fixes a SIGBUS on Solaris10 Sparc 64.
-new option WITH_MARIA_STORAGE_ENGINE for config.js
-correct build errors
-build test executables
-downport changes for atomic functions from 5.2
-remove LOCK_uuid_generator from C++ files to avoid linker errors
-new function my_uuid2str()
BitKeeper/deleted/.del-x86-msvc.h:
Delete: include/atomic/x86-msvc.h
CMakeLists.txt:
Windows fixes:
-New option WITH_MARIA_STORAGE_ENGINE
-Add unit tests
include/Makefile.am:
replace x86-msvc.h with generic-msvc.h
include/config-win.h:
my_chmod() support
include/my_atomic.h:
Downport my_atomic from 5.2 tree
include/my_bit.h:
Correct unresolved symbol errors on Windows
include/my_pthread.h:
pthread_mutex_unlock now returns 0 (was void previously)
defined PTHREAD_STACK_MIN
include/my_sys.h:
New function my_uuid2str()
define MY_UUID_STRING_LENGTH
include/atomic/nolock.h:
Downport my_atomic from 5.2 tree
libmysqld/CMakeLists.txt:
New option WITH_MARIA_STORAGE_ENGINE
mysys/CMakeLists.txt:
Add missing files
mysys/lf_dynarray.c:
Fix compiler errors on Windows
mysys/my_getncpus.c:
Windows port
mysys/my_uuid.c:
Windows fixes: there is no random() on Windows, use ANSI rand()
New function my_uuid2str()
mysys/my_winthread.c:
Downport from 5.2 tree
-Call my_thread_end() before pthread_exit()
-Avoid crash if pthread_create is called with NULL attributes
sql/CMakeLists.txt:
Link mysqld with Maria storage engine
sql/item_func.cc:
Remove LOCK_uuid_generator from C++ to avoid linker errors.
Use dedicated mutex for short uuids
sql/item_strfunc.cc:
Use my_uuid() and my_uuid2str() functions from mysys.
sql/item_strfunc.h:
Define MY_UUID_STRING_LENGTH in my_sys.h
sql/mysql_priv.h:
LOCK_uuid_generator must be declared as extern "C"
sql/mysqld.cc:
Init and destroy LOCK_uuid_short mutex
storage/maria/CMakeLists.txt:
-Use the same source files as in Makefile.am
-Build test binaries
storage/maria/ha_maria.cc:
snprintf->my_snprintf
storage/maria/lockman.c:
Fix compiler error on Windows
storage/maria/ma_check.c:
Fix compiler error on Windows
storage/maria/ma_loghandler.c:
Fix compile errors
my_open()/my_sync() do not work for directories on Windows
storage/maria/ma_recovery.c:
Fix compile error on Windows
storage/maria/ma_test2.c:
Rename variable to avoid naming conflict with Microsoft C runtime
function
storage/maria/ma_test3.c:
Fix build errors on Windows
storage/maria/tablockman.c:
Fix build errors on Windows
storage/maria/unittest/Makefile.am:
Add CMakeLists.txt
storage/maria/unittest/ma_pagecache_consist.c:
Fix build errors on Windows
remove loop from get_len()
storage/maria/unittest/ma_pagecache_single.c:
Fix build errors on Windows
storage/maria/unittest/ma_test_loghandler-t.c:
Windows fixes
-Avoid division by 0 in expressions like
x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows)
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Windows fixes
-Avoid division by 0 in expressions like
x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows)
-remove loop in get_len()
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Windows fixes
-Avoid division by 0 in expressions like
x/(RAND_MAX/y), where y is larger than RAND_MAX(==0x7fff on Windows)
-remove loop in get_len()
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Fix build errors on Windows
storage/maria/unittest/test_file.c:
Correct the code to get file size on Windows.
stat() information can be outdated and thus cannot be trusted.
On Vista,stat() returns file size=0 until the file is closed at the
first time.
storage/myisam/CMakeLists.txt:
Fix compiler errors on Windows
Build test executables
storage/myisam/mi_test2.c:
Rename variable to avoid naming conflict with Microsoft C runtime
function
storage/myisam/mi_test3.c:
Fix build errors on Windows
strings/CMakeLists.txt:
Add missing file
unittest/unit.pl:
Windows:
downport unittest changes from 5.2 bk tree
unittest/mysys/Makefile.am:
Windows:
downport unittest changes from 5.2 bk tree
unittest/mysys/my_atomic-t.c:
Windows:
downport unittest changes from 5.2 bk tree
unittest/mytap/Makefile.am:
Windows:
downport unittest changes from 5.2 bk tree
unittest/mytap/tap.c:
Windows:
downport unittest changes from 5.2 bk tree
win/configure.js:
Add WITH_MARIA_STORAGE_ENGINE configure option
unittest/mytap/CMakeLists.txt:
Add missing file
unittest/mysys/CMakeLists.txt:
Add missing file
storage/maria/unittest/CMakeLists.txt:
Add missing file
BitKeeper/etc/ignore:
Added comments maria-win.patch to the ignore list
include/atomic/generic-msvc.h:
Implement atomic operations with MSVC intrinsics
include/my_atomic.h:
transparent_union doesn't work in g++, doesn't work on darwin/ppc64
storage/maria/ma_blockrec.c:
compiler warning
storage/maria/ma_loghandler.c:
compiler warning
storage/maria/ma_page.c:
compiler warning
include/my_atomic.h:
To avoid compiler problems on some platforms, static inline
should be a macro here.
include/my_bit.h:
To avoid compiler problems on windows and solaris
mysys/my_create.c:
To avoid compiler problems on windows.
mysys/my_delete.c:
To avoid compiler problems on windows.