Commit graph

64 commits

Author SHA1 Message Date
Marko Mäkelä
cf483a7766 MDEV-17441 fixup: Remove unused my_atomic long macros 2022-03-24 09:53:52 +02:00
Monty
fa0397849a Move c++ code from my_atomic.h to my_atomic_wrapper.h
This is because it breaks code that is using extern "C" when including
my_atomic, which is the case with ha_s3.cc
2020-05-19 14:07:34 +03:00
Marko Mäkelä
386f168ab3 MDEV-22456 after-merge fix: introduce Atomic_relaxed
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.
2020-05-18 15:02:55 +03:00
Robert Bindar
e8392e58b2 MDEV-19696 - Cleanup gcc sync builtins
Since 10.4 requires C++11 capable compiler, gcc sync builtins became
dead code. Remove relevant cmake checks and cleanup include files.
2019-07-03 12:11:22 +03:00
Marko Mäkelä
be85d3e61b Merge 10.2 into 10.3 2019-05-14 17:18:46 +03:00
Marko Mäkelä
26a14ee130 Merge 10.1 into 10.2 2019-05-13 17:54:04 +03:00
Vicențiu Ciorbaru
cb248f8806 Merge branch '5.5' into 10.1 2019-05-11 22:19:05 +03:00
Vicențiu Ciorbaru
5543b75550 Update FSF Address
* Update wrong zip-code
2019-05-11 21:29:06 +03:00
Oleksandr Byelkin
28f08d3753 Merge branch '10.1' into 10.2 2018-09-14 08:47:22 +02:00
Sergei Golubchik
aec54fb938 MDEV-9627 clang builds fail on i386
don't use C11 atomics unless HAVE_GCC_C11_ATOMICS is defined
2018-09-04 09:19:48 +02:00
Otto Kekäläinen
c9c28bef3c Minor spelling fixes in code comments, docs and output
This commit does not touch any variable names or any other actual code,
and thus should not in any way affect how the code works.
2018-01-12 16:49:02 +02:00
Marko Mäkelä
34841d2305 Merge bb-10.2-ext into 10.3 2017-12-12 09:57:17 +02:00
Marko Mäkelä
8695c816e7 Wrap __atomic_compare_exchange_n() as valid C 2017-12-11 15:57:51 +02:00
Sergey Vojtovich
b3346c2f41 Restore LF_BACKOFF
Moved InnoDB UT_RELAX_CPU() to server. Restored cross-platform LF_BACKOFF
implementation basing on UT_RELAX_CPU().
2017-12-08 13:44:45 +02:00
Sergey Vojtovich
1029b22feb MDEV-13728 - Import MySQL 5.7 atomic operations for MSVC and Solaris
gcc_sync.h, solaris.h, generic-msvc.h copied verbatim.
2017-11-27 18:35:53 +04:00
Eugene Kosov
bbfd18c691 fix unsynchronized read (#463)
* fix unsynchronized read

* use relaxed atomic instead of seq_cst
2017-10-09 23:55:05 +04:00
Sergey Vojtovich
77a5dab5a2 MDEV-11212 - Clean-up MariaDB atomic operations
According to gcc manual sync builtins are getting deprecated. Make compilation
possible if only atomic builtins are available.
2016-12-13 16:38:20 +04:00
Sergey Vojtovich
c10e523d78 MDEV-11212 - Clean-up MariaDB atomic operations
No more black magic for gcc atomic bultins. Fixes some warnings.
2016-12-13 16:38:20 +04:00
Sergey Vojtovich
81f280789b MDEV-11212 - Clean-up MariaDB atomic operations
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.
2016-12-13 16:38:20 +04:00
Sergey Vojtovich
c23399d3de MDEV-11212 - Clean-up MariaDB atomic operations
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.
2016-12-13 16:38:20 +04:00
Sergey Vojtovich
bb9928160f MDEV-11212 - Clean-up MariaDB atomic operations
Removed MY_ATOMIC_HAS_8_16: never defined.
2016-12-13 16:38:20 +04:00
Sergey Vojtovich
8f9999b5fc MDEV-11212 - Clean-up MariaDB atomic operations
Removed my_atomic_initialize(): it doesn't make sense anymore.
2016-12-13 16:38:20 +04:00
Sergey Vojtovich
1369e70b56 MDEV-11212 - Clean-up MariaDB atomic operations
Removed "somewhat broken native x86 implementation". Should never be used on
supported platforms.
2016-12-13 16:38:20 +04:00
Sergey Vojtovich
71e11bce34 MDEV-8791 - AIX: Unresolved Symbols during linking
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.
2016-10-31 12:18:23 +04:00
Sergey Vojtovich
f4d885c4e9 MDEV-10813 - Clean-up InnoDB atomics, memory barriers and mutexes
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.
2016-10-17 18:35:48 +04:00
Monty
3d4a7390c1 MDEV-6150 Speed up connection speed by moving creation of THD to new thread
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)
2016-02-07 10:34:03 +02:00
Sergei Golubchik
e695db0f2d MDEV-7437 remove suport for "atomics" with rwlocks 2015-01-13 10:15:21 +01:00
Sergey Vojtovich
e813f9b9b3 MDEV-6693 - Atomic operations with explicit memory barrier
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.
2014-10-14 14:58:35 +04:00
Sergei Golubchik
0e007344ea mysql-5.5.18 merge 2011-11-03 19:17:05 +01:00
Kent Boortz
02e07e3b51 Updated/added copyright headers 2011-06-30 17:46:53 +02:00
Sergei Golubchik
0accbd0364 lots of post-merge changes 2011-04-25 17:22:25 +02:00
Sergei Golubchik
65ca700def merge.
checkpoint.
does not compile.
2010-11-25 18:17:28 +01:00
Davi Arnaut
ecd4a294a5 WL#5498: Remove dead and unused source code
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.
2010-07-23 17:18:36 -03:00
Davi Arnaut
93e38e8a3e Bug#22320: my_atomic-t unit test fails
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.
2010-07-23 09:37:10 -03:00
Davi Arnaut
cd41cd953d Bug#22320: my_atomic-t unit test fails
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.
2010-07-05 09:00:39 -03:00
Alexander Nozdrin
1dd2f90faf Auto-merge from mysql-next-mr-bugfixing. 2010-02-23 18:49:21 +03:00
Konstantin Osipov
fcc9c8627a Fix compiler warnings in my_atomic.h
include/atomic/x86-gcc.h:
  Fix a warning about empty while loop body.
include/my_atomic.h:
  Fix a warning about empty while loop body.
2010-02-19 17:20:29 +03:00
Vladislav Vaintroub
9cabc9fd8a prettification of package names and fix compile bug on OSX/ppc 2010-01-28 11:09:05 +01:00
Sergei Golubchik
3bfb8797d0 fix atomic/solaris.h to conform
remove duplicated boilerplate code
2009-12-23 09:27:41 +01:00
Mikael Ronstrom
d4f23f0cf6 Yet one more fix for Solaris atomics in builds 2009-12-19 18:24:52 +01:00
Mikael Ronstrom
d60b5fa260 Fixed Solaris build issues 2009-12-19 17:44:45 +01:00
Mikael Ronstrom
a99300e264 Fixed solaris builds 2009-12-19 12:48:39 +01:00
Mikael Ronstrom
0d28ae37e5 Fixed 64-bit atomics on Win x86 and removed support for 8 and 16-bit atomic operations 2009-12-15 17:07:43 +01:00
Mikael Ronstrom
bae553cfcd Backported my_atomic from 6.0-codebase and added support for 64-bit atomics to enable removal of LOCK_thread_count from every query, removed LOCK_thread_count from use in dispatch_command and close of query which is used in every query, now uses atomic increments/decrements instead 2009-10-12 11:00:39 +02:00
Mikael Ronstrom
a4785fc4a2 Moved atomics from 6.0 codebase to prepare for using atomic increments in places where LOCK_thread_count previously was used 2009-10-09 14:21:29 +02:00
Mikael Ronstrom
e82dac8dab Performance patch: Mysql atomic patch 2008-10-13 22:03:12 +02:00
unknown
788b95bc72 Fixes for bugs (my_atomic and Maria log handler) observed on
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.
2008-02-20 16:58:43 +01:00
unknown
ce8de7afdf Windows fixes
-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
2008-01-10 13:21:53 +01:00
unknown
2df4e9996a pushbuild fixes to please gcc and darwin/ppc64
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
2007-12-14 23:26:17 +01:00
unknown
32d207ca32 Fixes to merge between 5.1-main and 5.1-marvel
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.
2007-10-15 18:22:19 +03:00