buddy_alloc.c 1.2025.9 → 1.2025.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +12 -0
- package/README.md +48 -7
- package/buddy_alloc.h +12 -6
- package/package.json +19 -7
- package/CMakeLists.txt +0 -21
- package/CODE_OF_CONDUCT.md +0 -128
- package/CONTRIBUTING.md +0 -3
- package/LICENSE.md +0 -5
- package/Makefile +0 -59
- package/SECURITY.md +0 -5
- package/compile_flags.txt +0 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (C) 2021 by Stanislav Paskalev <spaskalev@protonmail.com>
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any purpose
|
|
4
|
+
with or without fee is hereby granted.
|
|
5
|
+
|
|
6
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
7
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
8
|
+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
9
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
|
10
|
+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
11
|
+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
|
|
12
|
+
THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
# buddy_alloc
|
|
2
|
-
A buddy memory allocator for C, by [Stanislav Paskalev](https://github.com/spaskalev).
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
A buddy memory allocator for C, by [Stanislav Paskalev](https://github.com/spaskalev). [[Latest release](https://github.com/spaskalev/buddy_alloc/releases/latest)]
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
[](https://github.com/spaskalev/buddy_alloc/actions/workflows/main.yml) [](https://github.com/spaskalev/buddy_alloc/actions/workflows/codeql.yml)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
<br>
|
|
8
9
|
|
|
9
10
|
## Licensing
|
|
10
11
|
|
|
11
12
|
This project is licensed under the 0BSD license. See the LICENSE.md file for details.
|
|
12
13
|
|
|
14
|
+
<br>
|
|
15
|
+
|
|
13
16
|
## Overview
|
|
14
17
|
|
|
15
18
|
This is a memory allocator suitable for use in applications that require predictable allocation and deallocation behavior. The allocator's metadata is kept separate from the arena and its size is a function of the arena and minimum allocations sizes.
|
|
16
19
|
|
|
20
|
+
<br>
|
|
21
|
+
|
|
17
22
|
## Features
|
|
18
23
|
|
|
19
24
|
- Bounded allocation and deallocation cost
|
|
@@ -24,18 +29,42 @@ This is a memory allocator suitable for use in applications that require predict
|
|
|
24
29
|
- Endian-agnostic, works on both LE and BE
|
|
25
30
|
- Compiles with GCC, Clang, MSVC and Pelles C
|
|
26
31
|
|
|
32
|
+
<br>
|
|
33
|
+
|
|
27
34
|
## Installation
|
|
28
35
|
|
|
29
36
|
Run:
|
|
30
|
-
|
|
37
|
+
|
|
38
|
+
```sh
|
|
31
39
|
$ npm i buddy_alloc.c
|
|
32
40
|
```
|
|
33
41
|
|
|
34
42
|
And then include `buddy_alloc.h` as follows:
|
|
43
|
+
|
|
35
44
|
```c
|
|
36
|
-
|
|
45
|
+
// main.c
|
|
46
|
+
#define BUDDY_ALLOC_IMPLEMENTATION
|
|
47
|
+
#include <buddy_alloc.h>
|
|
48
|
+
|
|
49
|
+
int main() { /* ... */ }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Finally, compile while adding the path `node_modules/buddy_alloc.c` to your compiler's include paths.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
$ clang -I./node_modules/buddy_alloc.c main.c # or, use gcc
|
|
56
|
+
$ gcc -I./node_modules/buddy_alloc.c main.c
|
|
37
57
|
```
|
|
38
58
|
|
|
59
|
+
You may also use a simpler approach with the [cpoach](https://www.npmjs.com/package/cpoach.sh) tool, which automatically adds the necessary include paths of all the installed dependencies for your project.
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
$ cpoach clang main.c # or, use gcc
|
|
63
|
+
$ cpoach gcc main.c
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
<br>
|
|
67
|
+
|
|
39
68
|
## Usage
|
|
40
69
|
|
|
41
70
|
Initializing and using the buddy allocator with metadata external to the arena is done using the `buddy_init` function.
|
|
@@ -72,6 +101,8 @@ buddy_free(buddy, data);
|
|
|
72
101
|
free(buddy_arena);
|
|
73
102
|
```
|
|
74
103
|
|
|
104
|
+
<br>
|
|
105
|
+
|
|
75
106
|
## Metadata sizing
|
|
76
107
|
|
|
77
108
|
The following table documents the allocator metadata space requirements according to desired arena (8MB to 1024GB) and alignment/minimum allocation (64B to 8KB) sizes. The resulting values are rounded up to the nearest unit.
|
|
@@ -99,6 +130,8 @@ The following table documents the allocator metadata space requirements accordin
|
|
|
99
130
|
1024 GB | 8193MB | 4097MB | 2049MB | 1025MB | 513MB | 257MB | 129MB | 65MB |
|
|
100
131
|
```
|
|
101
132
|
|
|
133
|
+
<br>
|
|
134
|
+
|
|
102
135
|
## Design
|
|
103
136
|
|
|
104
137
|
The allocator was designed with the following requirements in mind.
|
|
@@ -113,6 +146,8 @@ The following were not design goals
|
|
|
113
146
|
- To be used by multiple threads at the same time without additional locking.
|
|
114
147
|
- To be a general purpose malloc() replacement.
|
|
115
148
|
|
|
149
|
+
<br>
|
|
150
|
+
|
|
116
151
|
## Rationale
|
|
117
152
|
|
|
118
153
|
### Why use a custom allocator (like buddy_alloc) ?
|
|
@@ -127,6 +162,8 @@ An application developer may also need object allocation that is relocatable. Us
|
|
|
127
162
|
|
|
128
163
|
With the introduction of the `buddy_walk` function the allocator can be used to iterate all the allocated slots with its arena. This can be used for example for a space-bounded mailbox where a failure to allocate means the mailbox is full and the walk can be used to process its content. This can also form the basis of a managed heap for garbage collection.
|
|
129
164
|
|
|
165
|
+
<br>
|
|
166
|
+
|
|
130
167
|
## Implementation
|
|
131
168
|
|
|
132
169
|
```
|
|
@@ -169,7 +206,7 @@ The allocator uses a bitset-backed perfect binary tree to track allocations. The
|
|
|
169
206
|
|
|
170
207
|
### Allocation and deallocation
|
|
171
208
|
|
|
172
|
-
The binary tree nodes are labeled with the largest allocation slot available under them. This allows allocation to happen with a limited number of operations. Allocations that cannot be satisfied are fast to fail. Once a free node of the desired size is found it is marked as used and the nodes leading to root of the tree are updated to account for any difference in the largest available size. Deallocation works in a similar way - the allocated block size for the given address is found, marked as free and the same node update as with allocation is used to update the tree upwards.
|
|
209
|
+
The binary tree nodes are labeled with the largest allocation slot available under them. This allows allocation to happen with a limited number of operations. Allocations that cannot be satisfied are fast to fail. Once a free node of the desired size is found it is marked as used and the nodes leading to root of the tree are updated to account for any difference in the largest available size. Deallocation works in a similar way - the allocated block size for the given address is found, marked as free and the same node update as with allocation is used to update the tree upwards.
|
|
173
210
|
|
|
174
211
|
#### Fragmentation
|
|
175
212
|
|
|
@@ -187,6 +224,8 @@ The perfect binary tree always tracks an arena which size is a power-of-two. Whe
|
|
|
187
224
|
|
|
188
225
|
Resizing is available for both split and embedded allocator modes and supports both growing the arena and shrinking it. Checks are present that prevent shrinking the arena when memory that is to be reduced is still allocated.
|
|
189
226
|
|
|
227
|
+
<br>
|
|
228
|
+
|
|
190
229
|
## Users
|
|
191
230
|
|
|
192
231
|
If you are using buddy_alloc in your project and you would like project to be featured here please send a PR or file an issue. If you like buddy_alloc please star it on GitHub so that more users can learn of it. Thanks!
|
|
@@ -201,5 +240,7 @@ If you are using buddy_alloc in your project and you would like project to be fe
|
|
|
201
240
|
<br>
|
|
202
241
|
|
|
203
242
|
|
|
243
|
+
[](https://wolfram77.github.io)<br>
|
|
244
|
+
[](https://github.com/spaskalev/buddy_alloc)
|
|
204
245
|
[](https://nodef.github.io)
|
|
205
246
|

|
package/buddy_alloc.h
CHANGED
|
@@ -1413,7 +1413,7 @@ static inline unsigned char *buddy_tree_bits(struct buddy_tree *t);
|
|
|
1413
1413
|
static void buddy_tree_populate_size_for_order(struct buddy_tree *t);
|
|
1414
1414
|
static inline size_t buddy_tree_size_for_order(struct buddy_tree *t, uint8_t to);
|
|
1415
1415
|
static void write_to_internal_position(struct buddy_tree* t, struct internal_position pos, size_t value);
|
|
1416
|
-
static size_t read_from_internal_position(unsigned char *bitset, struct internal_position pos);
|
|
1416
|
+
static inline size_t read_from_internal_position(unsigned char *bitset, struct internal_position pos);
|
|
1417
1417
|
static inline unsigned char compare_with_internal_position(unsigned char *bitset, struct internal_position pos, size_t value);
|
|
1418
1418
|
|
|
1419
1419
|
#ifdef BUDDY_EXPERIMENTAL_CHANGE_TRACKING
|
|
@@ -1689,7 +1689,7 @@ static void write_to_internal_position(struct buddy_tree* t, struct internal_pos
|
|
|
1689
1689
|
#endif
|
|
1690
1690
|
}
|
|
1691
1691
|
|
|
1692
|
-
static size_t read_from_internal_position(unsigned char *bitset, struct internal_position pos) {
|
|
1692
|
+
static inline size_t read_from_internal_position(unsigned char *bitset, struct internal_position pos) {
|
|
1693
1693
|
if (! bitset_test(bitset, pos.bitset_location)) {
|
|
1694
1694
|
return 0; /* Fast test without complete extraction */
|
|
1695
1695
|
}
|
|
@@ -2066,8 +2066,11 @@ static void bitset_set_range(unsigned char *bitset, struct bitset_range range) {
|
|
|
2066
2066
|
} else {
|
|
2067
2067
|
bitset[range.from_bucket] |= bitset_char_mask[range.from_index][7];
|
|
2068
2068
|
bitset[range.to_bucket] |= bitset_char_mask[0][range.to_index];
|
|
2069
|
-
|
|
2070
|
-
|
|
2069
|
+
|
|
2070
|
+
range.from_bucket++;
|
|
2071
|
+
|
|
2072
|
+
if (range.to_bucket - range.from_bucket) {
|
|
2073
|
+
memset(bitset + range.from_bucket, 255u, range.to_bucket - range.from_bucket);
|
|
2071
2074
|
}
|
|
2072
2075
|
}
|
|
2073
2076
|
}
|
|
@@ -2079,8 +2082,11 @@ static void bitset_clear_range(unsigned char* bitset, struct bitset_range range)
|
|
|
2079
2082
|
else {
|
|
2080
2083
|
bitset[range.from_bucket] &= ~bitset_char_mask[range.from_index][7];
|
|
2081
2084
|
bitset[range.to_bucket] &= ~bitset_char_mask[0][range.to_index];
|
|
2082
|
-
|
|
2083
|
-
|
|
2085
|
+
|
|
2086
|
+
range.from_bucket++;
|
|
2087
|
+
|
|
2088
|
+
if (range.to_bucket - range.from_bucket) {
|
|
2089
|
+
memset(bitset + range.from_bucket, 0, range.to_bucket - range.from_bucket);
|
|
2084
2090
|
}
|
|
2085
2091
|
}
|
|
2086
2092
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "buddy_alloc.c",
|
|
3
|
-
"version": "1.2025.
|
|
3
|
+
"version": "1.2025.11",
|
|
4
4
|
"description": "A single header buddy memory allocator for C & C++; Stanislav Paskalev (2021).",
|
|
5
|
-
"keywords": [
|
|
6
|
-
|
|
5
|
+
"keywords": [
|
|
6
|
+
"c",
|
|
7
|
+
"library",
|
|
8
|
+
"memory",
|
|
9
|
+
"allocator",
|
|
10
|
+
"buddy",
|
|
11
|
+
"allocation"
|
|
12
|
+
],
|
|
13
|
+
"homepage": "https://github.com/nodef/buddy_alloc.c#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/nodef/buddy_alloc.c/issues"
|
|
16
|
+
},
|
|
7
17
|
"repository": {
|
|
8
18
|
"type": "git",
|
|
9
19
|
"url": "git+https://github.com/nodef/buddy_alloc.c.git"
|
|
10
20
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"
|
|
21
|
+
"license": "0BSD",
|
|
22
|
+
"author": "wolfram77@gmail.com",
|
|
23
|
+
"main": "buddy_alloc.h",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"test": "bash build.sh test"
|
|
26
|
+
}
|
|
15
27
|
}
|
package/CMakeLists.txt
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
cmake_minimum_required(VERSION 3.10)
|
|
2
|
-
project(buddy_alloc)
|
|
3
|
-
set(C_STANDARD C99)
|
|
4
|
-
|
|
5
|
-
# Compile C tests
|
|
6
|
-
project(buddy_tests)
|
|
7
|
-
set(C_STANDARD C99)
|
|
8
|
-
set(SOURCE_FILES tests.c)
|
|
9
|
-
add_executable(buddy_tests ${SOURCE_FILES})
|
|
10
|
-
|
|
11
|
-
# Compile CPP translation unit
|
|
12
|
-
project(buddy_cpp_translation_unit)
|
|
13
|
-
set(CXX_STANDARD C++11)
|
|
14
|
-
set(SOURCE_FILES testcxx.cpp)
|
|
15
|
-
add_executable(buddy_cpp_translation_unit ${SOURCE_FILES})
|
|
16
|
-
|
|
17
|
-
# Compile benchmark
|
|
18
|
-
project(buddy_bench)
|
|
19
|
-
set(C_STANDARD C99)
|
|
20
|
-
set(SOURCE_FILES bench.c)
|
|
21
|
-
add_executable(buddy_bench ${SOURCE_FILES})
|
package/CODE_OF_CONDUCT.md
DELETED
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
|
2
|
-
|
|
3
|
-
## Our Pledge
|
|
4
|
-
|
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
-
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
-
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
-
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity
|
|
10
|
-
and orientation.
|
|
11
|
-
|
|
12
|
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
-
diverse, inclusive, and healthy community.
|
|
14
|
-
|
|
15
|
-
## Our Standards
|
|
16
|
-
|
|
17
|
-
Examples of behavior that contributes to a positive environment for our
|
|
18
|
-
community include:
|
|
19
|
-
|
|
20
|
-
* Demonstrating empathy and kindness toward other people
|
|
21
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
-
* Giving and gracefully accepting constructive feedback
|
|
23
|
-
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
-
and learning from the experience
|
|
25
|
-
* Focusing on what is best not just for us as individuals, but for the
|
|
26
|
-
overall community
|
|
27
|
-
|
|
28
|
-
Examples of unacceptable behavior include:
|
|
29
|
-
|
|
30
|
-
* The use of sexualized language or imagery, and sexual attention or
|
|
31
|
-
advances of any kind
|
|
32
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
-
* Public or private harassment
|
|
34
|
-
* Publishing others' private information, such as a physical or email
|
|
35
|
-
address, without their explicit permission
|
|
36
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
-
professional setting
|
|
38
|
-
|
|
39
|
-
## Enforcement Responsibilities
|
|
40
|
-
|
|
41
|
-
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
-
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
-
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
-
or harmful.
|
|
45
|
-
|
|
46
|
-
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
-
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
-
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
-
decisions when appropriate.
|
|
50
|
-
|
|
51
|
-
## Scope
|
|
52
|
-
|
|
53
|
-
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
-
an individual is officially representing the community in public spaces.
|
|
55
|
-
Examples of representing our community include using an official e-mail address,
|
|
56
|
-
posting via an official social media account, or acting as an appointed
|
|
57
|
-
representative at an online or offline event.
|
|
58
|
-
|
|
59
|
-
## Enforcement
|
|
60
|
-
|
|
61
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
-
reported to the community leaders responsible for enforcement at
|
|
63
|
-
https://github.com/spaskalev/buddy_alloc/discussions.
|
|
64
|
-
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
-
|
|
66
|
-
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
-
reporter of any incident.
|
|
68
|
-
|
|
69
|
-
## Enforcement Guidelines
|
|
70
|
-
|
|
71
|
-
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
-
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
-
|
|
74
|
-
### 1. Correction
|
|
75
|
-
|
|
76
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
-
unprofessional or unwelcome in the community.
|
|
78
|
-
|
|
79
|
-
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
-
clarity around the nature of the violation and an explanation of why the
|
|
81
|
-
behavior was inappropriate. A public apology may be requested.
|
|
82
|
-
|
|
83
|
-
### 2. Warning
|
|
84
|
-
|
|
85
|
-
**Community Impact**: A violation through a single incident or series
|
|
86
|
-
of actions.
|
|
87
|
-
|
|
88
|
-
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
-
interaction with the people involved, including unsolicited interaction with
|
|
90
|
-
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
-
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
-
like social media. Violating these terms may lead to a temporary or
|
|
93
|
-
permanent ban.
|
|
94
|
-
|
|
95
|
-
### 3. Temporary Ban
|
|
96
|
-
|
|
97
|
-
**Community Impact**: A serious violation of community standards, including
|
|
98
|
-
sustained inappropriate behavior.
|
|
99
|
-
|
|
100
|
-
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
-
communication with the community for a specified period of time. No public or
|
|
102
|
-
private interaction with the people involved, including unsolicited interaction
|
|
103
|
-
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
-
Violating these terms may lead to a permanent ban.
|
|
105
|
-
|
|
106
|
-
### 4. Permanent Ban
|
|
107
|
-
|
|
108
|
-
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
-
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
-
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
-
|
|
112
|
-
**Consequence**: A permanent ban from any sort of public interaction within
|
|
113
|
-
the community.
|
|
114
|
-
|
|
115
|
-
## Attribution
|
|
116
|
-
|
|
117
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
-
version 2.0, available at
|
|
119
|
-
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
|
120
|
-
|
|
121
|
-
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
|
122
|
-
enforcement ladder](https://github.com/mozilla/diversity).
|
|
123
|
-
|
|
124
|
-
[homepage]: https://www.contributor-covenant.org
|
|
125
|
-
|
|
126
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
|
127
|
-
https://www.contributor-covenant.org/faq. Translations are available at
|
|
128
|
-
https://www.contributor-covenant.org/translations.
|
package/CONTRIBUTING.md
DELETED
package/LICENSE.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
Copyright (C) 2021 by Stanislav Paskalev <spaskalev@protonmail.com>
|
|
2
|
-
|
|
3
|
-
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
|
|
4
|
-
|
|
5
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
package/Makefile
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Copyright 2021 Stanislav Paskalev <spaskalev@protonmail.com>
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
# Disable default implicit rules
|
|
6
|
-
MAKEFLAGS += --no-builtin-rules
|
|
7
|
-
.SUFFIXES:
|
|
8
|
-
|
|
9
|
-
LLVM_VERSION?=11
|
|
10
|
-
CC?=clang-$(LLVM_VERSION)
|
|
11
|
-
CXX?=clang++-$(LLVM_VERSION)
|
|
12
|
-
CFLAGS?=-std=c99 --coverage -pg -no-pie -fno-builtin -g -O0 -Og -fstrict-aliasing -fstack-protector-all -fsanitize=undefined -fsanitize=bounds -pedantic -Wall -Wextra -Werror -Wfatal-errors -Wformat=2 -Wformat-security -Wconversion -Wcast-qual -Wnull-dereference -Wstack-protector -Warray-bounds -Warray-bounds-pointer-arithmetic -Wassign-enum -Wbad-function-cast -Wconditional-uninitialized -Wfloat-equal -Wformat-type-confusion -Widiomatic-parentheses -Wimplicit-fallthrough -Wloop-analysis -Wpointer-arith -Wshift-sign-overflow -Wshorten-64-to-32 -Wswitch-enum -Wtautological-constant-in-range-compare -Wunreachable-code-aggressive -Wthread-safety -Wthread-safety-beta -Wcomma -Wdeclaration-after-statement -D_FORTIFY_SOURCE=3
|
|
13
|
-
CXXFLAGS?=-std=c++11 --coverage -pg -no-pie -fno-builtin -g -O0 -Og -fstrict-aliasing -fstack-protector-all -fsanitize=undefined -fsanitize=bounds -pedantic -Wall -Wextra -Wformat=2 -Wformat-security -Wconversion -Wcast-qual -Wnull-dereference -Wstack-protector -Warray-bounds -Warray-bounds-pointer-arithmetic -Wassign-enum -Wbad-function-cast -Wconditional-uninitialized -Wfloat-equal -Wformat-type-confusion -Widiomatic-parentheses -Wimplicit-fallthrough -Wloop-analysis -Wpointer-arith -Wshift-sign-overflow -Wshorten-64-to-32 -Wswitch-enum -Wtautological-constant-in-range-compare -Wunreachable-code-aggressive -Wthread-safety -Wthread-safety-beta -Wcomma -Wdeclaration-after-statement -D_FORTIFY_SOURCE=3
|
|
14
|
-
LLVM_COV?=llvm-cov-$(LLVM_VERSION)
|
|
15
|
-
CPPCHECK?=cppcheck
|
|
16
|
-
|
|
17
|
-
TESTS_SRC=tests.c
|
|
18
|
-
TESTCXX_SRC=testcxx.cpp
|
|
19
|
-
LIB_SRC=buddy_alloc.h
|
|
20
|
-
BENCH_SRC=bench.c
|
|
21
|
-
BENCH_CFLAGS?=-O2
|
|
22
|
-
|
|
23
|
-
test: tests.out
|
|
24
|
-
rm -f *.gcda
|
|
25
|
-
./tests.out
|
|
26
|
-
$(LLVM_COV) gcov -b $(TESTS_SRC) | paste -s -d ',' | sed -e 's/,,/,\n/' | cut -d ',' -f 1,2,3
|
|
27
|
-
! grep '#####:' $(LIB_SRC).gcov
|
|
28
|
-
! grep -E '^branch\s*[0-9]? never executed$$' $(LIB_SRC).gcov
|
|
29
|
-
|
|
30
|
-
tests.out: $(TESTS_SRC) $(LIB_SRC) test-cppcheck check-recursion
|
|
31
|
-
$(CC) $(CFLAGS) $(TESTS_SRC) -o $@
|
|
32
|
-
|
|
33
|
-
test-cppcheck: $(TESTS_SRC)
|
|
34
|
-
$(CPPCHECK) --error-exitcode=1 --inline-suppr --quiet $^
|
|
35
|
-
|
|
36
|
-
test-cpp-translation-unit: $(TESTCXX_SRC)
|
|
37
|
-
$(CXX) $(CXXFLAGS) $(TESTCXX_SRC) -o $@
|
|
38
|
-
|
|
39
|
-
test-multiplatform: $(TESTS_SRC)
|
|
40
|
-
# 64-bit
|
|
41
|
-
powerpc64-linux-gnu-gcc -static $(TESTS_SRC) && ./a.out
|
|
42
|
-
aarch64-linux-gnu-gcc -static $(TESTS_SRC) && ./a.out
|
|
43
|
-
# 32-bit
|
|
44
|
-
i686-linux-gnu-gcc -static -g tests.c && ./a.out
|
|
45
|
-
powerpc-linux-gnu-gcc -static $(TESTS_SRC) && ./a.out
|
|
46
|
-
|
|
47
|
-
bench: $(BENCH_SRC) $(LIB_SRC)
|
|
48
|
-
$(CC) $(BENCH_CFLAGS) $(BENCH_SRC) -o $@
|
|
49
|
-
./$@
|
|
50
|
-
|
|
51
|
-
check-recursion: $(LIB_SRC)
|
|
52
|
-
[ $$( cflow --no-main $(LIB_SRC) | grep -c 'recursive:' ) -eq "0" ]
|
|
53
|
-
|
|
54
|
-
clean:
|
|
55
|
-
rm -f a.out *.gcda *.gcno *.gcov tests.out bench
|
|
56
|
-
|
|
57
|
-
.PHONY: test clean test-cppcheck
|
|
58
|
-
|
|
59
|
-
.PRECIOUS: tests.out testcxx.out
|
package/SECURITY.md
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
# Security Policy
|
|
2
|
-
|
|
3
|
-
Please report all issues via [GitHub's issues page](https://github.com/spaskalev/buddy_alloc/issues).
|
|
4
|
-
|
|
5
|
-
If your report contains confidential information you can use GitHub's private reporting of a security vulnerability as documented [here](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing-information-about-vulnerabilities/privately-reporting-a-security-vulnerability).
|
package/compile_flags.txt
DELETED