Commit Graph

32 Commits

Author SHA1 Message Date
Matthew Parkinson
8fcedfc290 Fix the GCC build (#40)
* Make it compile with GCC.  
* Add GCC to CI.
* Add warning to documentation about using GCC.
2019-05-05 19:58:37 +01:00
David Chisnall
8bd136c224 Remove all instances of static_cast<size_t>(1).
In preparation for removing magic numbers, simplify code that is
computing masks with a single bit set.
2019-04-30 11:50:32 +01:00
David Chisnall
5c197e4ae4 [NFC] More checks, comments on end of namespace braces. 2019-04-30 09:46:01 +01:00
David Chisnall
c2679188ad Fix the build on Windows. 2019-04-30 09:38:35 +01:00
David Chisnall
28fac4d700 Fix the remaining clang-tidy warnings.
This introduces a new `address_t` type and two new casts: `pointer_cast`
and `address_cast` for casting between an `address_t` and a pointer.
These should make it easier to audit the codebase for casts between
pointers and integers.  In particular, the remaining `reinterpret_cast`s
and `pointer_cast`s should be the only places where we could perform
invalid pointer arithmetic.

Also adds a `pointer_offset` helper that adds an offset (in bytes) to a
pointer, preserving its original type.  This is a sufficiently common
pattern that it seemed worthwhile to centralise it.
2019-04-29 13:37:05 +01:00
David Chisnall
4bafca9be7 [NFC] Automatic fixes from clang-tidy. 2019-04-29 11:33:07 +01:00
Matthew Parkinson
37afe9d079 Clang format 2019-04-29 11:02:47 +01:00
Matthew Parkinson
f88bcdbf58 Made alloc_chunk typed
Alloc_chunk now allocates and calls the constructor.
2019-04-29 11:02:47 +01:00
Matthew Parkinson
47428a096c Removing some casts and uses of void* 2019-04-29 11:02:47 +01:00
Matthew Parkinson
4faf9f3bee Use fewer header files
Removing some includes to reduce the code that is dragged in.
2019-04-29 11:02:47 +01:00
David Chisnall
45a31e75d1 Add some comments. 2019-02-25 12:54:16 +00:00
David Chisnall
6a5359b177 Pull aligned allocation out of the PAL.
The PAL can now advertise that it supports aligned allocation.  If it
does not, then the memory provider will do the alignment for it.

This change still leaves the PAL responsible for systematic testing, but
it should now be much easier to lift that out.
2019-02-25 12:54:16 +00:00
David Chisnall
d6e89b7c60 Fix Matt's code review comments. 2019-02-25 11:27:53 +00:00
David Chisnall
01bd77b356 Remove some ugly templated things.
Replace them with some very simple constexpr things.  This is what the
code used to look like, but it appears that I fundamentally
misunderstood why it didn't work.  This version should be a lot more
maintainable.
2019-02-25 11:27:53 +00:00
David Chisnall
1892538ad1 Clean up PAL feature detection API. 2019-02-25 11:27:53 +00:00
David Chisnall
a24e6270cc Provide a generic PAL feature detection mechanism.
We can support up to 64 optional features, currently only one is used.
2019-02-25 11:27:53 +00:00
David Chisnall
80630a359f Clean up interface to the low memory notifications.
- Rename MemoryProviderState to PAL to reflect what is now is.
 - Hide calls to the PAL's low memory functions behind something that
   returns a default value if they're not implemented.
2019-02-25 11:27:53 +00:00
David Chisnall
e2a12802d5 Hide the low memory notification PAL code. 2019-02-25 11:27:53 +00:00
David Chisnall
f6349092c9 Remove debugging define.
This was enabled so CI would run it.  It probably should be enabled for
some testing, but via CMake, not like this.
2019-02-25 11:27:53 +00:00
David Chisnall
6af4c97726 Explicitly qualify a method.
Either clang or cl has a bug: cl accepts the unqualified (inherited)
method name, clang rejects it.  Both accept the qualified name.
2019-02-25 11:27:53 +00:00
David Chisnall
71cfb6da1e [NFC] clangformat 2019-02-25 11:27:53 +00:00
David Chisnall
66cec23b23 Initial cut at a lazy decommit strategy.
This does not deallocate memory until the OS tells us that we are short
on memory, then tries to decommit all of the cached chunks (except for
the first page, used for the linked lists).

Nowhere near enough testing to commit to master yet!
2019-02-25 11:27:53 +00:00
Matthew Parkinson
5e149b083f One more constexpr 2019-02-15 17:43:27 +00:00
Matthew Parkinson
8698f87018 Added some constexpr to some ifs. 2019-02-15 16:12:38 +00:00
Matthew Parkinson
ac8e5e4e5b Fix comment to represent current PAL API. 2019-02-15 09:24:01 +00:00
Matthew Parkinson
adeecfb0f1 Added bug fix to alignment of using. 2019-02-14 20:08:04 +00:00
Paul Liétar
79b432ddab Fix the condition on when to allocate a new block.
Previously we would pretty much always allocate a new block for each
allocator, making them 16MiB aligned.
2019-02-12 12:47:22 +00:00
Matthew Parkinson
745a2a53d1 Clang format 2019-01-22 17:18:54 +00:00
Matthew Parkinson
cb70aa3f7f Restricted another array to bounds. 2019-01-22 11:19:57 +00:00
Matthew Parkinson
c1e23c497f Made alignment a template parameter. 2019-01-18 17:00:10 +00:00
Matthew Parkinson
a62e77f930 Align pagemap entries to OS_PAGE_SIZE
Guarantee the page map is page aligned.  Fix public API.
2019-01-18 15:22:08 +00:00
Matthew Parkinson
4f9d991449 Initial commit of snmalloc
History squashed from internal development.

Internal history has commit hash:
  e27a0e485c44a5003a802de2661ce3b21e120316
2019-01-15 14:17:55 +00:00