Commit Graph

151 Commits

Author SHA1 Message Date
Max
92ca918488 Remove interface linking for PRIVATE linkage (#799)
Some checks failed
snmalloc Benchmarking CI / benchmark (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-22.04 Debug (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-24.04 Debug (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-24.04-arm Debug (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-22.04 Debug C++17 (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-24.04 Debug with pthread destructors (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-22.04 Release (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-24.04 Release (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-24.04-arm Release (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-24.04 Release individual mitigations (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-24.04 Release libstdc++ (Build only) (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-22.04 Release clang + libstdc++ (Build only) (push) Has been cancelled
snmalloc CI / Ubuntu - ubuntu-22.04 Release Traced Build (push) Has been cancelled
snmalloc CI / Bazel - macos-13 Debug (push) Has been cancelled
snmalloc CI / Bazel - macos-14 Debug (push) Has been cancelled
snmalloc CI / Bazel - macos-15 Debug (push) Has been cancelled
snmalloc CI / Bazel - ubuntu-22.04 Debug (push) Has been cancelled
snmalloc CI / Bazel - ubuntu-24.04 Debug (push) Has been cancelled
snmalloc CI / Bazel - macos-13 Release (push) Has been cancelled
snmalloc CI / Bazel - macos-14 Release (push) Has been cancelled
snmalloc CI / Bazel - macos-15 Release (push) Has been cancelled
snmalloc CI / Bazel - ubuntu-22.04 Release (push) Has been cancelled
snmalloc CI / Bazel - ubuntu-24.04 Release (push) Has been cancelled
snmalloc CI / Mac OS macos-13 Debug (push) Has been cancelled
snmalloc CI / Mac OS macos-14 Debug (push) Has been cancelled
snmalloc CI / Mac OS macos-15 Debug (push) Has been cancelled
snmalloc CI / Mac OS macos-13 Debug -DSNMALLOC_USE_CXX17=ON (push) Has been cancelled
snmalloc CI / Mac OS macos-14 Debug -DSNMALLOC_USE_CXX17=ON (push) Has been cancelled
snmalloc CI / Mac OS macos-15 Debug -DSNMALLOC_USE_CXX17=ON (push) Has been cancelled
snmalloc CI / Mac OS macos-13 Release (push) Has been cancelled
snmalloc CI / Mac OS macos-14 Release (push) Has been cancelled
snmalloc CI / Mac OS macos-15 Release (push) Has been cancelled
snmalloc CI / Mac OS macos-13 Release -DSNMALLOC_USE_CXX17=ON (push) Has been cancelled
snmalloc CI / Mac OS macos-14 Release -DSNMALLOC_USE_CXX17=ON (push) Has been cancelled
snmalloc CI / Mac OS macos-15 Release -DSNMALLOC_USE_CXX17=ON (push) Has been cancelled
snmalloc CI / FreeBSD-13.2 Debug (push) Has been cancelled
snmalloc CI / FreeBSD-13.2 Release (push) Has been cancelled
snmalloc CI / NetBSD-9.2 Release (push) Has been cancelled
snmalloc CI / Sanitizer - ubuntu-22.04 Release libc++ (TSan + UBSan) (push) Has been cancelled
snmalloc CI / Sanitizer - ubuntu-24.04 Release libc++ (TSan + UBSan) (push) Has been cancelled
snmalloc CI / Crossbuild - Debug cross-build for riscv64-linux-gnu (push) Has been cancelled
snmalloc CI / Crossbuild - Release cross-build for riscv64-linux-gnu (push) Has been cancelled
snmalloc CI / Crossbuild - Debug cross-build for aarch64-linux-gnu (push) Has been cancelled
snmalloc CI / Crossbuild - Release cross-build for aarch64-linux-gnu (push) Has been cancelled
snmalloc CI / Crossbuild - Debug cross-build for arm-linux-gnueabihf (push) Has been cancelled
snmalloc CI / Crossbuild - Release cross-build for arm-linux-gnueabihf (push) Has been cancelled
snmalloc CI / Windows - windows-2022 ARM64 Debug (push) Has been cancelled
snmalloc CI / Windows - windows-2022 ARM64 Release (push) Has been cancelled
snmalloc CI / Windows - windows-2022 ARM64EC Debug (push) Has been cancelled
snmalloc CI / Windows - windows-2022 ARM64EC Release (push) Has been cancelled
snmalloc CI / Windows - windows-2022 Win32 Debug (push) Has been cancelled
snmalloc CI / Windows - windows-2022 Win32 Debug -T ClangCL (push) Has been cancelled
snmalloc CI / Windows - windows-2025 Win32 Debug (push) Has been cancelled
snmalloc CI / Windows - windows-2025 Win32 Debug -T ClangCL (push) Has been cancelled
snmalloc CI / Windows - windows-2022 Win32 Release (push) Has been cancelled
snmalloc CI / Windows - windows-2022 Win32 Release -T ClangCL (push) Has been cancelled
snmalloc CI / Windows - windows-2025 Win32 Release (push) Has been cancelled
snmalloc CI / Windows - windows-2025 Win32 Release -T ClangCL (push) Has been cancelled
snmalloc CI / Windows - windows-2022 x64 Debug (push) Has been cancelled
snmalloc CI / Windows - windows-2022 x64 Debug -T ClangCL (push) Has been cancelled
snmalloc CI / Windows - windows-2025 x64 Debug (push) Has been cancelled
snmalloc CI / Windows - windows-2025 x64 Debug -T ClangCL (push) Has been cancelled
snmalloc CI / Windows - windows-2022 x64 Release (push) Has been cancelled
snmalloc CI / Windows - windows-2022 x64 Release -T ClangCL (push) Has been cancelled
snmalloc CI / Windows - windows-2025 x64 Release (push) Has been cancelled
snmalloc CI / Windows - windows-2025 x64 Release -T ClangCL (push) Has been cancelled
snmalloc CI / Windows - windows-2022 x64 Release Windows 8 compatible (push) Has been cancelled
snmalloc CI / Format check (push) Has been cancelled
snmalloc CI / Fuzzing (push) Has been cancelled
snmalloc CI / Self Vendored STL - macos-latest clang++ (push) Has been cancelled
snmalloc CI / Self Vendored STL - ubuntu-24.04 clang++-18 (push) Has been cancelled
snmalloc CI / Self Vendored STL - windows-2022 clang-cl (push) Has been cancelled
snmalloc CI / Self Vendored STL - ubuntu-24.04 g++-14 (push) Has been cancelled
snmalloc CI / gwp-asan (ubuntu-24.04, Debug) (push) Has been cancelled
snmalloc CI / gwp-asan (ubuntu-24.04, RelWithDebInfo) (push) Has been cancelled
snmalloc CI / gwp-asan (ubuntu-24.04-arm, Debug) (push) Has been cancelled
snmalloc CI / gwp-asan (ubuntu-24.04-arm, RelWithDebInfo) (push) Has been cancelled
snmalloc CI / all-checks (push) Has been cancelled
snmalloc CI for Morello / morello Debug Hybrid (push) Has been cancelled
snmalloc CI for Morello / morello Debug Purecap (push) Has been cancelled
snmalloc CI for Morello / morello Release Hybrid (push) Has been cancelled
snmalloc CI for Morello / morello Release Purecap (push) Has been cancelled
2025-10-20 10:27:12 +01:00
Matthew Parkinson
fbedb31504 CMAKE: Libs should not require headers (#797)
The API exposed by the various libraries in snmalloc all obey standard
C std lib conventions, so no headers are required to consume them. This
change updates the CMake configuration to not require headers for the
libraries.
2025-10-17 16:42:50 +01:00
Matthew Parkinson
3385660fd7 Update minimum CMake version (#793)
The use of CACHE in the SNMALLOC_STATIC_LIBRARY_PREFIX was not correctly handled by cmake before 3.21.

> The “set(CACHE)” command no longer removes a normal variable of the
same name, if any. See policy “CMP0126”.

Changing the minimum version means that containing projects can do:

```CMake
set(SNMALLOC_STATIC_LIBRARY_PREFIX "my_prefix")
```

Without this, there were weird behaviours that the first compile used "sn_" and then subsequent compiles used "my_prefix".

Thanks to @achamayou for debugging this in CCF. https://github.com/microsoft/CCF/pull/7161
2025-08-05 11:19:42 +01:00
Matthew Parkinson
452fcc44b0 Add exception handling for new operator (#791)
The new operator in the snmalloc did not throw exceptions in the case of
allocation failure.  Moreover, it was not possible to override the
behaviour of the failure of the new operator using the
std::set_new_handler function.

This PR adds the necessary code to the snmalloc new operator to
throw std::bad_alloc when the allocation fails. It also allows the
std::set_new_handler function to be used to set a custom handler for
allocation failures.
2025-07-15 09:57:34 +01:00
Matthew Parkinson
0064c01b82 Improving handling first allocation being for TLS (#767)
* handle reentrancy during initialization

* use finialization list if possible

* Add test for reentrancy of C++ destructors and allocation

* Add test for reentrancy of setspecific

* Add new mode for directly calling __cxa_thread_atexit_impl

---------

Co-authored-by: Schrodinger ZHU Yifan <yifanzhu@rochester.edu>
2025-05-07 19:28:37 +01:00
Jaya Kasa
a63f0c1ac3 feat: add support for bazel (#759) 2025-05-07 09:09:44 +01:00
Will Brown
e6bf8570d0 [Rust] add support for optionally compiling libc functions (#763)
* add SNMALLOC_RUST_LIBC_API option
2025-04-03 13:56:41 +01:00
Matthew Parkinson
ccc03ce0fc Protection against fork (#735)
If a thread forks, while another thread is holding an snmalloc lock, then the allocator could stop working.

This patch attempts to protect against the cases of this. There is one case that is not covered. If a fork occurs during the very first allocation. This can result in the installation of the fork handler racing with the fork, and all bets are off.
2025-03-04 13:44:59 +00:00
Matthew Parkinson
5f7baef755 Refactor: Remove unused features and functions, and move most allocator operations to a global namespace. (#750)
* Factor out explicit Config type

Instead of using snmalloc::Alloc::Config, expose snmalloc::Config, which is then used to derive the allocator type.

* Move globalalloc to front end.

* Remove unneed template parameter from global snmalloc functions.

* Remove SNMALLOC_PASS_THROUGH

VeronaRT now has an abstraction layer which can easily replace the allocator.
Having such a complex integration still in snmalloc does not make sense.

* Take some global functions off of local alloc.

* Drop comparison overloads on atomic Capptr.

Performing a comparison on two atomic ptr is a complex operation, and should not be implicit.  The memory model order and such things needs to be considered by the caller.

* Remove function_ref and use templates

The implementation prefers to use templates over the function_ref.  This now only exists in the Pal for a currently unused feature.

* Removing function_ref reduces stl needs.

* Remove use of __is_convertible to support older g++

* Inline function that is only used once.

* Remove unused function

* Restrict ThreadAlloc usage to globalalloc

This commit introduces various inline functions on snmalloc:: that perform allocation/deallocation using the thread local allocator.

They remove all usage from a particular test.

* Move cheri checks to own file.

* Refactor is_owned checks.

* Move alloc_size and check_size to globalalloc.

* Minor simplification of dealloc path

* Fix up is_owned to take a config

* Improve usage of scoped allocator.

* Handle Config_ in globalalloc.
2025-02-22 19:53:27 +00:00
Matthew Parkinson
a3fe420af2 Fix HAS_EXCEPTION on Windows. (#743) 2025-02-05 16:54:51 +00:00
Matthew Parkinson
b3efd49c9a Mistaken commit of message_once (#741) 2025-02-05 11:16:41 +00:00
Schrodinger ZHU Yifan
16b96245f6 Enable a seconary allocator support (e.g. GWP-Asan) (#737) 2025-02-05 09:03:11 +00:00
Matthew Parkinson
e3e558472d Update CMakeLists.txt (#734)
* Handle platforms that have `_GLIBCXX_ASSERTIONS`, which require the stdlib++ to be included.
* Stop override of memcpy with FORTIFY_SOURCE enabled
* Add to .gitignore
* Add data for graphs in release notes.
* Minor tidy on CMake.
2025-01-23 13:36:08 +00:00
Schrodinger ZHU Yifan
0111a410a2 [proxy](7/n) self vendor array and algorithm headers (#722)
* [proxy](7/n) proxy array and algorithm headers

* [wip] address CRs

* undo comment

* format

* fix build

* simplify macro dispatching
2025-01-09 13:49:22 +00:00
Matthew Parkinson
046c5ac766 Limit remote batch size (#724)
When processing a remote batch, the system will process every single message that was available at the start of processing.
This can lead to a long pause time if there have been a considerable number of frees to this thread.

This commit introduces a new mechanism to only process messages up to a limit of 1MiB. The limit is configurable using CMake.

Choosing too small a limit can cause freeing to never catch up with the incoming messages.
2025-01-07 14:29:34 +00:00
Schrodinger ZHU Yifan
feff2e8151 [proxy](1/n) start self-vendored STL with atomic (#715)
* [proxy] start self-vendored STL

* address CR
2025-01-03 07:49:32 +00:00
Matthew Parkinson
f57e27de19 Fixes: Sets _HAS_EXCEPTIONS=0 globally #701 (#707)
This makes the `_HAS_EXCEPTIONS` flag on windows only apply to libraries, and not if the library is used header only.
2024-12-12 09:36:12 +00:00
Jean-Michaël Celerier
d6ad197d3c cmake: look for rdynamic instead of hardcoding it (#699) 2024-12-01 07:45:23 +00:00
David CARLIER
33b7f656ab neasing netbsd build. (#696)
all 3rd party packages are located in /usr/pkg so we lessen the burden
to set these.
2024-11-25 08:29:09 +00:00
Schrodinger ZHU Yifan
0b53b9301e fuzzing test and detect the memmove error (#688)
* fuzzing

* add an additional random walk test
2024-11-19 13:48:18 +00:00
Schrodinger ZHU Yifan
f7fe702f77 implement polite waiting (#685)
* implement polite waiting

* Update src/snmalloc/pal/pal_linux.h

Co-authored-by: Matthew Parkinson <mjp41@users.noreply.github.com>

* fix build issues

* fix more build issues

* support _umtx_op for freebsd

* unify waiting style

* fix

* address CR

Co-authored-by: Matthew Parkinson <mjp41@users.noreply.github.com>

* support macos

* static dispatch os APIs for apple

* make wait_on_address configurable via cmake

* undo extra include

* fix macos build

* fix clang-tidy build

---------

Co-authored-by: Matthew Parkinson <mjp41@users.noreply.github.com>
2024-11-16 07:33:11 +00:00
Matthew Parkinson
ab4fe84804 Provide option to CMake for Page Size (#664)
* Pickup page size from unistd.h

This uses the PAGESIZE constant from the unistd.h on POSIX.
This should make the code more resilient to being compiled on platforms with
different page sizes.

* Allow pagesize to come from cmake.

* Update src/snmalloc/pal/pal_posix.h

Co-authored-by: Nathaniel Filardo <105816689+nwf-msr@users.noreply.github.com>

---------

Co-authored-by: Nathaniel Filardo <105816689+nwf-msr@users.noreply.github.com>
2024-09-25 11:27:31 +01:00
Nathaniel Wesley Filardo
fb776da909 WIP: BatchIt (#677)
* Rename dealloc_local_object_slower to _meta

Unlike its brethren, `dealloc_local_object` and
`dealloc_local_object_slow`, the `dealloc_local_object_slower` method
does not take a pointer to free space.  Make this slightly more apparent
by renaming it and adding some commentary to both definition and call
site.

* corealloc: get meta in dealloc_local_object

Make both _fast() and _slow() arms take the meta as an argument; _meta()
already did.

* Introduce RemoteMessage structure

Plumb its use around remoteallocator and remotecache

* NFC: Plumb metadata to remotecache dealloc

* Initial steps in batched remote messages

This prepares the recipient to process a batched message.

* Initial dealloc-side batching machinery

Exercise recipient machinery by having the senders collect adjacent frees to
the same slab into a batch.

* Match free batch keying to slab freelist keying

* freelist: add append_segment

* SlabMetadata: machinery for returning multiple objects

This might involve multiple (I think at most two, at the moment) transitions in
the slab lifecycle state machine.  Towards that end, return indicators to the
caller that the slow path must be taken and how many objects of the original
set have not yet been counted as returned.

* corealloc: operate ring-at-a-time on remote queues

* RemoteCache associative cache of rings

* RemoteCache: N-set caching

* Initial CHERI support for free rings

* Matt's fix for slow-path codegen

* Try: remotecache: don't store allocator IDs

We can, as Matt so kindly reminds me, go get them from the pagemap.  Since we
need this value only when closing a ring, the read from over there is probably
not very onerous.  (We could also get the slab pointer from an object in the
ring, but we need that whenever inserting into the cache, so it's probably more
sensible to store that locally?)

* Make BatchIt optional

Move ring set bits and associativity knobs to allocconfig and expose them via
CMake.  If associtivity is zero, use non-batched implementations of the
`RemoteMessage` and `RemoteDeallocCacheBatching` classes.

By default, kick BatchIt on when we have enough room in the minimum allocation
size to do it.  Exactly how much space is enough is a function of which
mitigations we have enabled and whether or not we are compiling with C++20.

This commit reverts the change to `MIN_ALLOC_SIZE` made in "Introduce
RemoteMessage structure" now that we have multiple types, and zies, of
remote messages to choose from.

* RemoteDeallocCacheBatching: store metas as address

There's no need for a full pointer here, it'd just make the structure larger on
CHERI.

* NFC: plumb entropy from LocalAlloc to BatchIt

* BatchIt random eviction

In order not to thwart `mitigations(random_preserve)` too much, if it's on in
combination with BatchIt, roll the dice every time we append to a batch to
decide if we should stochastically evict this batch.  By increasing the number
of batches, we allow the recipient allocator increased opportunity to randomly
stripe batches across the two `freelist::Builder` segments associated with each
slab.

---------

Co-authored-by: Nathaniel Wesley Filardo <nfilardo@microsoft.com>
Co-authored-by: Matthew Parkinson <mattpark@microsoft.com>
2024-09-23 19:18:09 +01:00
Nathaniel Filardo
8b95b9a916 Bottom commits from BatchIt (#675)
* msvc: set __cplusplus to the actual value in use

* ds_core/bits: add mask_bits; convert one_at_bit-s

* remotecache: enable reserve_space multiple objects

* nits

* Small changes to tracing

- Trace "Handling remote" once per batch, rather than per element

- Remote queue events also log the associated metaslab; we'll use this
  to assess the efficacy of https://github.com/microsoft/snmalloc/issues/634

* freelist builder: allow forcibly tracking length

* Try forward declaring freelist::Builder to appease macos-14

* freelist: tweak intra-slab obfuscation keys by meta address

* NFC: freelist: allow `next` to be arbitrary value

* Switch to a central, tweaked key for all free lists

* allocconfig: introduce some properties of slabs

We'll use these to pack values in message queues.

- Maximum distance between two objects in a single slab
- Maximum number of objects in a slab

* NFC: Templatize LocalCache on Config

* NFC: split dealloc_local_object_slow

We'll use the _slower form when we're just stepping a slab through
multiple rounds of state transition (to come), which can't involve
the actual memory object in question.

* NFC: make freelist::Object::T-s by placement new

* NFC: CoreAlloc: split dealloc_local_object

The pattern of `if (!fast()) { slow() }` occurs in a few places, including in
contexts where we already know the entry and so don't need to look it up.
2024-09-12 17:06:53 -04:00
Nathaniel Filardo
6bd6db5f61 Remove the SNMALLOC_USE_CXX17 C preprocessor symbol (#667)
* Revise search for no-unique-addres

* Remove SNMALLOC_USE_CXX17 as preprocessor symbol

Just test __cplusplus in the last place we were using it.
2024-06-28 10:19:32 -04:00
Matthew Parkinson
2a7eabef6c Configurable client meta-data (#662)
This provide a way to configure snmalloc to provide per object meta-data that is out of band. This can be used to provide different mitigations on top of snmalloc, such as storing memory tags in a compressed form, or provide a miracle pointer like feature.

This also includes a couple of TSAN fixes as it wasn't fully on in CI.
2024-06-13 09:32:07 -04:00
Matthew Parkinson
2dba088d24 Refactor new/delete overrides (#660)
Produce static library that only overrides new and delete. This allows for a static library to be added that only overrides new and delete.
2024-06-06 10:23:12 +01:00
Nathaniel Filardo
846a926155 NFC: sizeclass: differentiate minimum step size and minimum allocation sizes (#651)
* Move sizeclass debugging code to sizeclass test

The sizeclass was already testing most of this, so just add the missing bits.
Forgo some tests whose failure would have implied earlier failures.

This moves the last dynamic call of size_to_sizeclass_const into tests
(and so, too, to_exp_mant_const).  sizeclasstable.h still contains a static
call to compute NUM_SMALL_SIZECLASSES from MAX_SMALL_SIZECLASS_SIZE.

* Remove unused to_exp_mant

Only its _const sibling is used, and little at that, now that almost everything
to do with sizes and size classes is table-driven.

* test/memcpy: trap, if we can, before exiting

This just means I don't need to remember to set a breakpoint on exit

* test/memcpy: don't assume sizeclass 0 is allocable

* test/memory: don't assume sizeclass 0 is allocable

* test/sizeclass: handle nonzero minimum sizeclasses

* sizeclass: distinguish min alloc and step size

Add support for a minimum allocation size that isn't the minimum step of
the sizeclass table.

* Expose MIN_ALLOC_{,STEP}_SIZE through cmake

* test/sizeclass: report MIN_ALLOC_{STEP_,}SIZE
2024-05-24 18:49:39 +01:00
Matthew A Johnson
35eef33099 Adding an option to disable TLS (#632)
Signed-off-by: Matthew A Johnson <matjoh@microsoft.com>
2023-09-13 10:17:10 +00:00
Matthew Parkinson
7b597335ae Disable empty static prefix for Windows. (#629) 2023-08-25 14:17:04 +01:00
Matthew Parkinson
c2e4a12e21 Using exclusive mode prefetch (#627)
* Using exclusive mode prefetch

The prefetching is always used to move the cache line to the current
core for writing.  This change makes it use exclusive mode prefetch
and enables it as a feature flag for x64.

* Debug platform for BSDs

* CI fixes

* More CI

* Update ARM prefetch

* Update x64 prefetch default
2023-08-09 07:15:37 +01:00
Matthew Parkinson
9d4466093a Move to clang-format 15 (#621)
The current version requires clang-format-9.  This now getting hard to get.
This commit moves it to the clang-format-15, which is the latest in 22.04.

Also, updates clang-tidy to 15 as well.
2023-07-18 11:24:07 +01:00
Matthew Parkinson
dc1268886a Improve CMake slightly (#620)
* Prefix build testing flag with SNMALLOC

* Only add clangformat target is testing enabled.
2023-06-28 11:42:19 +01:00
David CARLIER
d9f5bd0500 pass through enable malloc build for dragonflybsd. (#614) 2023-05-30 21:25:59 +01:00
Matthew Parkinson
ccca98a709 Factor checks under separate feature flags. (#587)
All the checks and mitigations have been placed under feature flags.
These can be controlled by defining

  SNMALLOC_CHECK_CLIENT_MITIGATIONS

This can take a term that represents the mitigations that should be enabled.
E.g.
  -DSNMALLOC_CHECK_CLIENT_MITIGATIONS=nochecks+random_pagemap

The CMake uses this to build numerous versions of the LD_PRELOAD library and
tests to allow individual features to be benchmarked.

Co-authored-by: Nathaniel Wesley Filardo <nfilardo@microsoft.com>
2023-03-23 13:41:02 +00:00
David Chisnall
b9b9055bbf Try vm-actions instead of cross-platform-actions (#589)
This uses VirtualBox instead of xhyve.  It might be slower, but should
be more reliable.

Tests run on FreeBSD, NetBSD, and OpenBSD.  Only the FreeBSD ones are
passing at the moment, the others will keep running but aren't added as
dependencies for the action used to guard commits.
2023-02-20 12:05:53 +00:00
Nathaniel Wesley Filardo
704843d5ff Add BUILD_TESTING cmake option
As with CTest, but without the full machinery thereof.  This facilitates
package builders to use the usual build targets (all, install) without
needing to build the test programs if they're just going to get dropped
on the floor.
2022-12-16 16:43:47 +00:00
David CARLIER
5bb5701b45 LTO support proposal. (#573)
* LTO support proposal.

* giving choice
2022-12-09 20:30:56 +00:00
Matthias Wahl
6b0bda01c7 Support older linux systems (#545)
* Fix pal_linux.h for older linux systems

Where MADV_FREE is not defined - replaced with MADV_DONTNEED
Where GRND_NONBLOCK is not defined in <sys/random.h> but in <linux/random.h>

* Check for linux/random.h in CMake

as __has_include seems to not be reliable

* Use CMake module CheckIncludeFilesCXX

as C language isn't enabled by default everywhere

* Move madvise flag ifdefs into constexpr for cleaner code
2022-06-17 06:16:32 +01:00
Nathaniel Wesley Filardo
3e72ef63ad NFC: cmake: add SNMALLOC_LINK_ICF, default on
ICF currently breaks building on Morello, so allow cmake to notch it out.
2022-06-09 14:20:36 +01:00
Matthew Parkinson
e17672d3c1 Missing PRIVATE in cmake. (#539) 2022-06-07 16:13:36 +01:00
Matthew Parkinson
563d5a5cee Make clang on Windows use /Debug 2022-05-03 15:59:31 +01:00
Matthew Parkinson
56ccb5c794 Enable memcpy checks for check shim (#515)
Build three levels of checking
  - None
  - Checks memcpy only
  - Checks (full)

Currently you can build checks without enabling the memcpy protection.
This PR fixes that.
2022-05-03 14:26:25 +01:00
David Carlier
bf54eeb7be New option to name reserved pages. 2022-04-18 21:01:40 +01:00
David Chisnall
f6e9796bbc Introduce header layering (#503)
See src/snmalloc/README.md for an explanation of the layers.

Some other cleanups on the way:

Fine-grained stats support is now gone.

It's been broken for two years, it depends on iostream (which then
causes linker failures with libstdc++) and it's collecting the wrong
stats for the new design.  After discussion with @mjp41, it's better to
remove it and introduce new stats support later, rather than keep broken
code in the main branch.

Tracing was controlled with a preprocessor macro, now there's also a
CMake option.
2022-04-06 09:59:33 +01:00
Matthew Parkinson
a022a75b91 Fix Debug symbols for Windows CI. (#483) 2022-03-20 19:28:03 +00:00
David Carlier
c27dd10c39 shared lib linkage build fix for OpenBSD.
disable purposely --no-undefined for this platform.
2022-02-28 09:16:16 +00:00
Matthew Parkinson
4f2d3ebf33 Enable sanitizers in CI. 2021-12-15 14:45:53 +00:00
David CARLIER
360efa2123 export netbsd's reallocarr proposal. (#433)
* export netbsd's reallocarr proposal.

acts subtly differently from reallocarray, returns an error code
and first argument as receiver.

* not export by default

* ci tests

* apply suggestions

* doc addition

* Apply suggestions from code review

Co-authored-by: Matthew Parkinson <mjp41@users.noreply.github.com>
2021-12-02 14:49:32 +00:00
Schrodinger ZHU Yifan
71d5bb8756 add SYS_getrandom fallback for posix PAL (#431)
* add SYS_getrandom fallback for posix PAL

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>

* address CR

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>

* guard and comments

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>

* more fallback behavior

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>

* fix random device fd

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>

* special handling for EAGAIN

Signed-off-by: SchrodingerZhu <i@zhuyi.fan>
2021-12-02 10:38:50 +00:00