summaryrefslogtreecommitdiff
path: root/atomic
Commit message (Collapse)AuthorAgeFilesLines
* atomic64: Generic apr_atomic_read64() to always use a lock.ylavic2023-02-151-12/+0
| | | | | | | | | | | | | | | | | Don't play games with sizeof(void*) to determine whether a raw load intruction is atomic or not. Systems that fall back to the generic implementation are not eligible for the compiler builtins or CPU native atomic intructions already, and we don't want to reimplement that here (e.g. alignment, ordering guarantees, ...). * atomic/unix/mutex64.c(apr_atomic_read64): No #ifdefery, always take the lock. Follow up to r1907541. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1907678 13f79535-47bb-0310-9956-ffa450edef68
* atomic: No raw 64bit load/store on 32bit systems or anything but x86_64 or ↵ylavic2023-02-142-8/+10
| | | | | | | | | | | | | | | | | | | s390x. Raw 64 bit load and store need two intructions on 32bit systems (tearing) so they are not atomic, and only x86(_64) and s390(x) have stong mempry ordering guarantees. Always use builtin functions for the cases where raw load/store don't work as expected. * atomic/unix/builtins.c, atomic/unix/builtins64.c: Use an accept-list rather than a reject-list to define WEAK_MEMORY_ORDERING. Test APR_SIZEOF_VOIDP < 8 to force usage of __sync builtins for _read{32,64} and _set{32,64} on 32bit systems when __atomic_{load,store} buitlins are not available. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1907637 13f79535-47bb-0310-9956-ffa450edef68
* apr_atomic: Generic apr_atomic_read64() needs a mutex on 32bit systems ↵ylavic2023-02-091-0/+19
| | | | | | | | | | | | | | | | (tearing). A 64bit load on a 32 bit CPU/system uses two instructions (tearing), so ensure atomicity with regard to other atomic functions by using the (same) lock. test_atomics_threaded64() fails because of this on 32bit systems. PR 66457. * atomic/unix/mutex64.c(apr_atomic_read64): Use locking when APR_SIZEOF_VOIDP < 8 git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1907541 13f79535-47bb-0310-9956-ffa450edef68
* Call apr__atomic_generic64_init() if neededsf2023-02-051-0/+4
| | | | | | | | | | | | | | | | | | | Otherwise we get a segfault. Seen on Debian on powerpc with /* Define if compiler provides 32bit atomic builtins */ #define HAVE_ATOMIC_BUILTINS 1 /* Define if compiler provides 64bit atomic builtins */ /* #undef HAVE_ATOMIC_BUILTINS64 */ /* Define if compiler provides 32bit __atomic builtins */ #define HAVE__ATOMIC_BUILTINS 1 /* Define if compiler provides 64bit __atomic builtins */ /* #undef HAVE__ATOMIC_BUILTINS64 */ /* Define if use of generic atomics is requested */ /* #undef USE_ATOMICS_GENERIC */ git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1907442 13f79535-47bb-0310-9956-ffa450edef68
* Try to use 64 bit __atomic builtins only when they are available.sf2023-02-051-8/+8
| | | | | | | | | | | | | | | | | | | | Otherwise we get link errors. Seen on Debian on armel and this configure result: /* Define if compiler provides 32bit atomic builtins */ #define HAVE_ATOMIC_BUILTINS 1 /* Define if compiler provides 64bit atomic builtins */ #define HAVE_ATOMIC_BUILTINS64 1 /* Define if compiler provides 32bit __atomic builtins */ #define HAVE__ATOMIC_BUILTINS 1 /* Define if compiler provides 64bit __atomic builtins */ /* #undef HAVE__ATOMIC_BUILTINS64 */ /* Define if use of generic atomics is requested */ /* #undef USE_ATOMICS_GENERIC */ git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1907441 13f79535-47bb-0310-9956-ffa450edef68
* Remove trailing whitespaces in *.c.ivan2022-11-202-12/+12
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1905414 13f79535-47bb-0310-9956-ffa450edef68
* atomic: Detect 32bit and 64bit atomic builtins separately.ylavic2022-06-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some 32bit platforms provide 32bit but not 64bit atomics, detect and distinctly set/use HAVE_ATOMIC_BUILTINS/HAVE_ATOMIC_BUILTINS64 and USE_ATOMICS_BUILTINS/USE_ATOMICS_BUILTINS64. These platforms NEED_ATOMICS_GENERIC64 as 64bit implementation. * configure.in(): Use stdint.h's uint{32,64}_t as atomic type for testing atomic builtins when available, otherwise "unsigned int" for 32bit testing and "unsigned long long" as 64bit. * configure.in(): AC_TRY_RUN each 32bit and 64bit type separately, the former determining HAVE_ATOMIC_BUILTINS and the latter HAVE_ATOMIC_BUILTINS64. * include/arch/unix/apr_arch_atomic.h(): Define USE_ATOMICS_BUILTINS64 when HAVE_ATOMIC_BUILTINS64, otherise define NEED_ATOMICS_GENERIC64 * include/arch/unix/apr_arch_atomic.h(): Check defined(__powerpc__) for USE_ATOMICS_PPC. * atomic/unix/builtins64.c(): Implement for USE_ATOMICS_BUILTINS64 only. BZ 63566. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902266 13f79535-47bb-0310-9956-ffa450edef68
* atomic: Follow up r1902257: No cast for InterlockedCompareExchangePointer().ylavic2022-06-261-9/+5
| | | | | | | | | Both 32 and 64 bit InterlockedCompareExchangePointer() seem to have the same API, so be it.. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902259 13f79535-47bb-0310-9956-ffa450edef68
* atomic: Avoid casts and/or use correct ones.ylavic2022-06-263-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | * atomic/os390/atomic.c(apr_atomic_xchgptr): Dereferencing without casting is fine/better. * atomic/unix/mutex.c(apr_atomic_casptr, apr_atomic_xchgptr): Dereferencing without casting is fine/better. * atomic/win32/apr_atomic.c(apr_atomic_add32, apr_atomic_sub32, apr_atomic_inc32, apr_atomic_dev32, apr_atomic_set32, apr_atomic_cas32, apr_atomic_xchg32): Native Interlocked 32bit functions expect "long volatile *", don't cast out volatility. * atomic/win32/apr_atomic.c(apr_atomic_casptr): 32bit InterlockedCompareExchangePointer() expects "long volatile *", don't cast to (void **). * atomic/win32/apr_atomic.c(apr_atomic_xchgptr): InterlockedExchangePointer() for both 32bit and 64bit expects "void *volatile *", no need to cast. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902257 13f79535-47bb-0310-9956-ffa450edef68
* atomic: Fix -Wincompatible-pointer-types-discards-qualifiersylavic2022-06-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | atomic/unix/builtins.c:117:38: warning: passing 'void **' to parameter of type 'volatile void **' discards qualifiers in nested pointer types [-Wincompatible-pointer-types-discards-qualifiers] __atomic_compare_exchange_n(mem, (void **)&cmp, ptr, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); ^~~~~~~~~~~~~ This warning is weird, because 'volatile void **' is not a thing usually, it happens on macos in apr-1.x, where apr_atomic_casptr() is (ill-)defined as: APR_DECLARE(void*) apr_atomic_casptr(volatile void **mem, void *ptr, const void *cmp); but not on trunk's: APR_DECLARE(void*) apr_atomic_casptr(void *volatile *mem, void *ptr, const void *cmp); The mark clearly indicates that (void **)&cmp is the culprit though (compiler bug?). Let's see if using the generic (void *) cast helps, the goal of the (void **) cast was to remove constantness only (__atomic_compare_exchange_n will modify the pointer on stack, but not the pointed to value), (void *) will do that too without any volatile qualifier issue possibly. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902233 13f79535-47bb-0310-9956-ffa450edef68
* apr_atomic_set64: Follow up to r1868129.ylavic2022-01-071-0/+7
| | | | | | | | Like for apr_atomic_read64() in r1868502, use direct memory write on x86_x64. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1896811 13f79535-47bb-0310-9956-ffa450edef68
* Follow up to r1894621: restore apr_atomic_init::apr__atomic_generic64_init().ylavic2021-11-031-1/+1
| | | | | | | | | Even if apr__atomic_generic64_init() is currently a noop when !APR_HAS_THREADS, it may change later without apr_atomic_init() noticing (thanks Rüdiger). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1894719 13f79535-47bb-0310-9956-ffa450edef68
* apr_atomic: Fix load/store for weak memory ordering architectures.ylavic2021-10-293-16/+73
| | | | | | | | | | | | | | | | Volatile access prevents compiler reordering of load/store but it's not enough for weakly ordered archs like ARM32 and PowerPC[64]. While __atomic builtins provide load and store, __sync builtins don't so let's use an atomic add of zero for the former and atomic exchange for the latter. The assembly code for PowerPC was not correct either, fix apr_atomic_read32() and apr_atomic_set32() and add the necessary memory barriers for the others. PR 50586. git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1894622 13f79535-47bb-0310-9956-ffa450edef68
* apr_atomic: Use __atomic builtins when available.ylavic2021-10-293-12/+84
| | | | | | | | | | Unlike Intel's atomic builtins (__sync_*), the more recent __atomic builtins provide atomic load and store for weakly ordered architectures like ARM32 or powerpc[64], so use them when available (gcc 4.6.3+). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1894621 13f79535-47bb-0310-9956-ffa450edef68
* Revert r1894618.ylavic2021-10-294-131/+28
| | | | git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1894619 13f79535-47bb-0310-9956-ffa450edef68
* apr_atomic: Use __atomic builtins when available.ylavic2021-10-294-28/+131
| | | | | | | | | | | Unlike Intel's atomic builtins (__sync_*), the more recent __atomic builtins provide atomic load and store for weakly ordered architectures like ARM32 or powerpc[64], so use them when available (gcc 4.6.3+). [Reverted by r1894619] git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1894618 13f79535-47bb-0310-9956-ffa450edef68
* * atomic/win32/apr_atomic64.civan2019-10-161-0/+7
| | | | | | | | | | | (apr_atomic_read64): Use direct memory read when compiled for x86_x64, since 64-bit reads are atomic in 64-bit Windows [1]. Suggested by: Yann Ylavic [1] https://docs.microsoft.com/en-us/windows/win32/sync/interlocked-variable-access git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1868502 13f79535-47bb-0310-9956-ffa450edef68
* apr_atomic_read64(): Fix non-atomic read on 32-bit Windows.ivan2019-10-081-1/+3
| | | | | | | | | | | | | | * atomic/win32/apr_atomic64.c (apr_atomic_read64): Use InterlockedCompareExchange64() instead of direct memory read. * test/testatomic.c (test_atomics_threaded_setread64): New test. (test_func_set64): Helepr for test_atomics_threaded_setread64 test. * CHANGES: Add changelog entry. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1868129 13f79535-47bb-0310-9956-ffa450edef68
* Address some warnings raised by MSVC-32/64.ylavic2019-04-031-39/+11
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1856873 13f79535-47bb-0310-9956-ffa450edef68
* atomics: follow up to r1841078: provide specific initializer for generic 64bitylavic2019-01-179-12/+37
| | | | | | | | | | The can't be two apr_atomic_init(), atomic/mutex64.c shouldn't implement one since generic/mutex implementation may be used by several platforms. So introduce private apr__atomic_generic64_init() and use it where needed. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1851541 13f79535-47bb-0310-9956-ffa450edef68
* Add in Atomics for 64bit intsjim2018-09-173-0/+335
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1841078 13f79535-47bb-0310-9956-ffa450edef68
* atomic: fix API of atomic_{cas,xchg}ptr() for APR-2.ylavic2016-10-069-20/+20
| | | | | | | | The pointer ought to be declared volatile, not void. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1763666 13f79535-47bb-0310-9956-ffa450edef68
* Fix errors when building on Visual Studio 2013 whilegsmith2015-04-241-49/+8
| | | | | | | | | | maintaining the ability to build on Visual Studio 6 with Windows Server 2003 R2 SDK. PR: 57191 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1675751 13f79535-47bb-0310-9956-ffa450edef68
* Fix amd64 assembler version of apr_atomic_xchgptr()sf2013-04-211-1/+1
| | | | | | | | PR: 51851 Submitted by: Mattias Engdegård <mattiase acm org> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1470348 13f79535-47bb-0310-9956-ffa450edef68
* Fix PPC atomics to work with gcc 4.0sf2013-04-201-24/+24
| | | | | | | | PR: 54840 Submitted by: Mattias Engdegård <mattiase acm org> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1470186 13f79535-47bb-0310-9956-ffa450edef68
* Added blocking for MSVC pragma.fuankg2011-03-251-0/+2
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@1085462 13f79535-47bb-0310-9956-ffa450edef68
* Some folks are ignoring the Tab prohibitionswrowe2010-03-222-84/+84
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@925965 13f79535-47bb-0310-9956-ffa450edef68
* * Fix some gcc compiler warnings on Solarisrpluem2008-06-041-1/+1
| | | | | | | Patch to atomic/unix/solaris.c submitted by: Henry Jen <henryjen ztune.net> git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@663342 13f79535-47bb-0310-9956-ffa450edef68
* Apparently I'm too wordy, even the compiler agrees.wrowe2007-10-241-1/+1
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@588081 13f79535-47bb-0310-9956-ffa450edef68
* Match win32's volatility declaration (except for mingw)wrowe2007-10-231-1/+3
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@587593 13f79535-47bb-0310-9956-ffa450edef68
* implement apr_atomic_xchgptr() for z/OStrawick2007-10-221-0/+17
| | | | | | | | Submitted by: David Jones <oscaremma gmail.com> reviewed by: trawick git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@587057 13f79535-47bb-0310-9956-ffa450edef68
* Implement apr_atomic_casptr() for z/OS.trawick2007-10-181-0/+24
| | | | | | | | Submitted by: David Jones <oscaremma gmail.com> Reviewed by: trawick git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@585935 13f79535-47bb-0310-9956-ffa450edef68
* * Fix compiler warning.rpluem2007-10-141-1/+1
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@584523 13f79535-47bb-0310-9956-ffa450edef68
* * Dereference mem as it is a double pointer.rpluem2007-10-141-1/+1
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@584522 13f79535-47bb-0310-9956-ffa450edef68
* Cleanup asm constraints (+ operand is both read and written by the instruction)davi2007-08-041-12/+9
| | | | | | | and clobbers. The xchg instruction always asserts the lock signal. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@562765 13f79535-47bb-0310-9956-ffa450edef68
* Prefer solaris builtins even on x86, and fix a compiler warning.davi2007-08-041-1/+1
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@562764 13f79535-47bb-0310-9956-ffa450edef68
* Fix win32 stub for apr_atomic_xchgptr.davi2007-07-121-1/+1
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@555695 13f79535-47bb-0310-9956-ffa450edef68
* Fix a mis-merge of PPC memory barriers.davi2007-07-111-4/+2
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@555258 13f79535-47bb-0310-9956-ffa450edef68
* Introduce apr_atomic_xchgptr, which atomically exchanges a pair of pointerdavi2007-07-108-0/+116
| | | | | | | values. Missing OS/390 implementation. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@554995 13f79535-47bb-0310-9956-ffa450edef68
* New apr_atomic implementation for S/390 native atomic operations.davi2007-07-071-0/+132
| | | | | | | Tested on: RHEL AS 4 (Nahant Update 4), IBM/S390, running under VM (64 bit mode), gcc 3.4.6 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@554095 13f79535-47bb-0310-9956-ffa450edef68
* New apr_atomic implementation for PowerPC native atomic operations.davi2007-07-041-0/+178
| | | | | | | PR: 42806 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@553293 13f79535-47bb-0310-9956-ffa450edef68
* New apr_atomic implementation for Solaris 10 native atomic operations.davi2007-07-041-0/+74
| | | | | | | PR: 42806 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@553292 13f79535-47bb-0310-9956-ffa450edef68
* New apr_atomic implementation for ia32 (x86 and x86_64) native atomic ↵davi2007-07-041-0/+111
| | | | | | | | | | | | operations, plus apr_atomic_casptr. PR: 42806 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@553291 13f79535-47bb-0310-9956-ffa450edef68
* Given a modern compiler, this patch provides fast atomic operations on variousdavi2007-07-041-0/+74
| | | | | | | | | | | | | | platforms (alpha, ia32, ia64, powerpc, etc). Tested on: 2x Pentium D, Ubuntu 7.04, gcc 4.1.2 16x Itanium II, RHEL 5, gcc 4.1.1 PR: 42806 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@553290 13f79535-47bb-0310-9956-ffa450edef68
* This patch tries to address some of the apr_atomic problems by reorganizingdavi2007-07-042-464/+192
| | | | | | | | | | the various backends. The generic implementation is used when no specialized implementation fits the defined criterias, or when the user forces the choice. PR: 42806 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@553289 13f79535-47bb-0310-9956-ffa450edef68
* Avoid overwriting the hash_mutex table for applications that incorrectly callsdavi2007-06-301-0/+16
| | | | | | | | | | apr_atomic_init(). Noticied by: Tim Jones PR: 42760 git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@552161 13f79535-47bb-0310-9956-ffa450edef68
* Fix up integer type on Solaris 10 (gcc) compiles.jerenkrantz2006-08-311-1/+1
| | | | | | | | | * atomic/unix/apr_atomic.c (apr_atomic_dec32): Match declaration in apr_atomic.h for Solaris 10 implementation. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@438796 13f79535-47bb-0310-9956-ffa450edef68
* Fix the typo.jorton2006-08-034-4/+4
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@428317 13f79535-47bb-0310-9956-ffa450edef68
* Update license header.jorton2006-08-034-24/+24
| | | | git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@428313 13f79535-47bb-0310-9956-ffa450edef68
* Add __MINGW32__ versions of the Win32 Atomic functions, that all do their ↵pquerna2006-07-151-1/+15
| | | | | | own evil casting -- but it allows 100% of the testatomic cases to pass, when previously, it aborted if you tried to call any of the atomic functions. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@422168 13f79535-47bb-0310-9956-ffa450edef68