summaryrefslogtreecommitdiffstats
path: root/include/jemalloc/internal/atomic.h
Commit message (Collapse)AuthorAgeFilesLines
* Move CPP_PROLOGUE and CPP_EPILOGUE to the .cppDavid Goldblatt2017-04-191-4/+0
| | | | This lets us avoid having to specify them in every C file.
* Header refactoring: move atomic.h out of the catch-allDavid Goldblatt2017-04-111-0/+4
|
* Remove the pre-C11-atomics API, which is now unusedDavid Goldblatt2017-04-051-45/+0
|
* Fix ATOMIC_{ACQUIRE,RELEASE,ACQ_REL} definitions.Jason Evans2017-03-091-3/+3
|
* Reintroduce JEMALLOC_ATOMIC_U64David Goldblatt2017-03-091-2/+10
| | | | | | The C11 atomics backport removed this #define, which degraded atomic 64-bit reads to require a lock even on platforms that support them. This commit fixes that.
* Add atomic types for ssize_tDavid Goldblatt2017-03-071-0/+3
|
* Introduce a backport of C11 atomicsDavid Goldblatt2017-03-031-0/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This introduces a backport of C11 atomics. It has four implementations; ranked in order of preference, they are: - GCC/Clang __atomic builtins - GCC/Clang __sync builtins - MSVC _Interlocked builtins - C11 atomics, from <stdatomic.h> The primary advantages are: - Close adherence to the standard API gives us a defined memory model. - Type safety: atomic objects are now separate types from non-atomic ones, so that it's impossible to mix up atomic and non-atomic updates (which is undefined behavior that compilers are starting to take advantage of). - Efficiency: we can specify ordering for operations, avoiding fences and atomic operations on strongly ordered architectures (example: `atomic_write_u32(ptr, val);` involves a CAS loop, whereas `atomic_store(ptr, val, ATOMIC_RELEASE);` is a plain store. This diff leaves in the current atomics API (implementing them in terms of the backport). This lets us transition uses over piecemeal. Testing: This is by nature hard to test. I've manually tested the first three options on Linux on gcc by futzing with the #defines manually, on freebsd with gcc and clang, on MSVC, and on OS X with clang. All of these were x86 machines though, and we don't have any test infrastructure set up for non-x86 platforms.
* Break up headers into constituent partsDavid Goldblatt2017-01-121-651/+0
| | | | | | | | | | This is part of a broader change to make header files better represent the dependencies between one another (see https://github.com/jemalloc/jemalloc/issues/533). It breaks up component headers into smaller parts that can be made to have a simpler dependency graph. For the autogenerated headers (smoothstep.h and size_classes.h), no splitting was necessary, so I didn't add support to emit multiple headers.
* Rename atomic_*_{uint32,uint64,u}() to atomic_*_{u32,u64,zu}().Jason Evans2016-11-071-99/+99
| | | | This change conforms to naming conventions throughout the codebase.
* Revert "Define 64-bits atomics unconditionally"Jason Evans2016-11-071-8/+10
| | | | | | This reverts commit c2942e2c0e097e7c75a3addd0b9c87758f91692e. This resolves #495.
* Define 64-bits atomics unconditionallyMike Hommey2016-06-091-10/+8
| | | | They are used on all platforms in prng.h.
* Refactor arenas array (fixes deadlock).Jason Evans2016-02-251-2/+2
| | | | | | | | | | | | Refactor the arenas array, which contains pointers to all extant arenas, such that it starts out as a sparse array of maximum size, and use double-checked atomics-based reads as the basis for fast and simple arena_get(). Additionally, reduce arenas_lock's role such that it only protects against arena initalization races. These changes remove the possibility for arena lookups to trigger locking, which resolves at least one known (fork-related) deadlock. This resolves #315.
* Fix type errors in C11 versions of atomic_*() functions.Chi-hung Hsieh2015-05-281-8/+8
|
* Use InterlockedCompareExchange instead of non-existing ↵Mike Hommey2015-03-171-1/+1
| | | | InterlockedCompareExchange32
* Move centralized chunk management into arenas.Jason Evans2015-02-121-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all centralized data structures related to huge allocations and recyclable chunks into arena_t, so that each arena can manage huge allocations and recyclable virtual memory completely independently of other arenas. Add chunk node caching to arenas, in order to avoid contention on the base allocator. Use chunks_rtree to look up huge allocations rather than a red-black tree. Maintain a per arena unsorted list of huge allocations (which will be needed to enumerate huge allocations during arena reset). Remove the --enable-ivsalloc option, make ivsalloc() always available, and use it for size queries if --enable-debug is enabled. The only practical implications to this removal are that 1) ivsalloc() is now always available during live debugging (and the underlying radix tree is available during core-based debugging), and 2) size query validation can no longer be enabled independent of --enable-debug. Remove the stats.chunks.{current,total,high} mallctls, and replace their underlying statistics with simpler atomically updated counters used exclusively for gdump triggering. These statistics are no longer very useful because each arena manages chunks independently, and per arena statistics provide similar information. Simplify chunk synchronization code, now that base chunk allocation cannot cause recursive lock acquisition.
* Remove unnecessary xchg* lock prefixes.Jason Evans2015-02-111-2/+2
|
* Implement more atomic operations.Jason Evans2015-02-051-82/+384
| | | | | | - atomic_*_p(). - atomic_cas_*(). - atomic_write_*().
* Add a C11 atomics-based implementation of atomic.h API.Chih-hung Hsieh2014-12-071-0/+28
|
* Style fixes.Jason Evans2014-12-061-2/+2
|
* Add atomic operations tests and fix latent bugs.Jason Evans2014-08-071-12/+29
|
* Add support for MSVCMike Hommey2012-05-011-0/+28
| | | | Tested with MSVC 8 32 and 64 bits.
* Add atomic(9) implementations of atomic operations.Jason Evans2012-04-171-5/+41
| | | | | Add atomic(9) implementations of atomic operations. These are used on FreeBSD for non-x86 architectures.
* Use __sync_add_and_fetch and __sync_sub_and_fetch when they are availableMike Hommey2012-03-261-3/+15
| | | | | | | These functions may be available as inlines or as libgcc functions. In the former case, a __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macro is defined. But we still want to use these functions in the latter case, when we don't have our own implementation.
* Remove ephemeral mutexes.Jason Evans2012-03-241-0/+30
| | | | | | | | | | | Remove ephemeral mutexes from the prof machinery, and remove malloc_mutex_destroy(). This simplifies mutex management on systems that call malloc()/free() inside pthread_mutex_{create,destroy}(). Add atomic_*_u() for operation on unsigned values. Fix prof_printf() to call malloc_vsnprintf() rather than malloc_snprintf().
* Restructure atomic_*_z().Jason Evans2012-03-231-16/+29
| | | | | Restructure atomic_*_z() so that no casting within macros is necessary. This avoids warnings when compiling with clang.
* Add SH4 and mips architecture support.Jason Evans2012-03-051-0/+16
| | | | Submitted by Andreas Vinsander.
* Simplify small size class infrastructure.Jason Evans2012-02-291-2/+2
| | | | | | | | | | | | Program-generate small size class tables for all valid combinations of LG_TINY_MIN, LG_QUANTUM, and PAGE_SHIFT. Use the appropriate table to generate all relevant data structures, and remove the distinction between tiny/quantum/cacheline/subpage bins. Remove --enable-dynamic-page-shift. This option didn't prove useful in practice, and it prevented optimizations. Add Tilera architecture support.
* Move repo contents in jemalloc/ to top level.Jason Evans2011-04-011-0/+169