Commit Graph

30 Commits

Author SHA1 Message Date
David Chisnall
2efcddfc3d Rework free list so that 0 is the placeholder.
This is needed because in some configurations the constructor for the
global placeholder is not called before the first allocation (i.e. when
other globals call the allocator in their constructor) and so we ended
up following a null pointer.
2019-07-05 14:20:24 +01:00
Matthew Parkinson
54879fbb4a Make GCC happy with inline 2019-07-02 15:38:28 +01:00
Matthew Parkinson
b74116e209 Fixes 2019-07-02 14:58:13 +01:00
Matthew Parkinson
eb4e28e8d0 CR Feedback
Removed stub from message queue, and use an actual allocation.
2019-07-02 14:08:05 +01:00
Matthew Parkinson
fdcbcf7016 Add prefetch to mpscq. 2019-07-02 14:07:42 +01:00
Matthew Parkinson
621b7e6b9a Clang format. 2019-07-02 10:51:18 +01:00
Matthew Parkinson
3c7d122dea Add macro for ASSUME and FAST_PATH/SLOW_PATH
Fixes GCC warning that was incorrect using an ASSUME.

Made fast path and slow path Macros so we can add additional attributes.
2019-07-01 14:35:36 +01:00
Matthew Parkinson
48416e3241 CR Feedback 2019-05-14 21:16:11 +01:00
Matthew Parkinson
b484619f20 Added branch predictor hint. 2019-05-14 21:16:11 +01:00
Matthew Parkinson
3c7582f717 Remove two unused functions. 2019-05-10 15:12:26 +01:00
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
840e00b430 Fix sign warning. 2019-04-30 14:08:41 +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
49ece8f4e1 Enable the static analyser from clang-tidy.
Fix a false positive.  The loops in the pagemap accessor are too
complicated for the static analyser to check, so it doesn't spot that a
non-null return is impossible.
2019-04-30 09:46:01 +01:00
David Chisnall
d06e539732 Add more checks.
Add missing parentheses in UNUSED (shouldn't matter, but keeps a checker
that may catch real bugs elsewhere happy).
2019-04-30 09:46:01 +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
4a0299ec77 Clang format 2019-04-29 11:02:47 +01:00
Matthew Parkinson
f1835813bd uintptr_max instead of -1/~0 2019-04-29 11:02:47 +01:00
Matthew Parkinson
c471e1a271 CR 2019-04-29 11:02:47 +01:00
Matthew Parkinson
8eb6e36966 Add comment about min/max. 2019-04-29 11:02:47 +01:00
Matthew Parkinson
37afe9d079 Clang format 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
Matthew Parkinson
ccccd686fb Merge pull request #16 from Microsoft/Sizeclass
Simplified sizeclass calculations and added tests.
2019-02-19 13:07:08 +00:00
Matthew Parkinson
c02077a06a Bug fix in umul code for 32-bit Win 2019-02-15 14:36:47 +00:00
Matthew Parkinson
e004641cec Added to comment. 2019-02-11 14:47:12 +00:00
Matthew Parkinson
9981bad9b5 clang format 2019-02-11 14:47:12 +00:00
Matthew Parkinson
1272078487 Simplified size class calculation
The rounding code can be integrated directly into the sizeclass code,
which means, the code paths can be simplified slightly.

The special case for zero mantissa bits is not required, as the compiler
generates the same code from the more complex path due to
eliminating dead code after folding the constant zero through.
2019-02-11 14:47:12 +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