+177
-441
Diff
round #0
+1
build/BUCK
+1
build/BUCK
···
1
+
# This file exists so that `//build:defs.bzl` is a valid load path.
+36
build/defs.bzl
+36
build/defs.bzl
···
1
+
load("@prelude//platforms:defs.bzl", "host_configuration")
2
+
3
+
HOSTED = [host_configuration.cpu, host_configuration.os]
4
+
5
+
def k23_rust_library(name, crate = None, deps = [], test_deps = [], test_features = [], tests = True, **kwargs):
6
+
"""Define a kernel library with an optional companion test rule.
7
+
8
+
Args:
9
+
name: Library name. Sources are globbed from `{name}/src/**/*.rs`.
10
+
crate: Crate name override (e.g. "kutil"). Defaults to None (uses `name`).
11
+
deps: Dependencies shared between the library and its tests.
12
+
test_deps: Additional dependencies only needed by tests.
13
+
test_features: Features only enabled for tests.
14
+
tests: Whether to generate a companion rust_test rule. Defaults to True.
15
+
**kwargs: Extra arguments forwarded to rust_library (e.g. `features`).
16
+
"""
17
+
native.rust_library(
18
+
name = name,
19
+
srcs = native.glob(["{}/src/**/*.rs".format(name)]),
20
+
crate = crate,
21
+
deps = deps,
22
+
tests = [":{}_tests".format(name)] if tests else [],
23
+
visibility = ["PUBLIC"],
24
+
**kwargs,
25
+
)
26
+
27
+
if tests:
28
+
native.rust_test(
29
+
name = "{}_tests".format(name),
30
+
srcs = native.glob(["{}/src/**/*.rs".format(name)]),
31
+
crate = crate,
32
+
deps = deps + test_deps,
33
+
features = test_features if test_features else [],
34
+
visibility = ["PUBLIC"],
35
+
target_compatible_with = HOSTED,
36
+
)
+32
-4
build/toolchains/BUCK
+32
-4
build/toolchains/BUCK
···
5
5
load(":flake.bzl", "flake")
6
6
load(":rust.bzl", "rust_toolchain")
7
7
load(":cxx.bzl", "clang_toolchain")
8
+
load(":transitions.bzl", "configuration_transition")
8
9
9
10
flake.package(
10
11
name = "python",
···
66
67
crate = "core",
67
68
srcs = [":rust_toolchain"],
68
69
crate_root = "out.link/lib/rustlib/src/rust/library/core/src/lib.rs",
69
-
incoming_transition = "root//build/transitions:rust_bootstrap",
70
+
incoming_transition = ":rust_bootstrap",
70
71
visibility = ["PUBLIC"],
71
72
)
72
73
···
79
80
deps = [
80
81
":rust_core"
81
82
],
82
-
incoming_transition = "root//build/transitions:rust_bootstrap",
83
+
incoming_transition = ":rust_bootstrap",
83
84
visibility = ["PUBLIC"],
84
85
)
85
86
···
92
93
":rust_core",
93
94
":rust_compiler_builtins"
94
95
],
95
-
incoming_transition = "root//build/transitions:rust_bootstrap",
96
+
incoming_transition = ":rust_bootstrap",
96
97
visibility = ["PUBLIC"],
97
98
)
98
99
···
115
116
rustc_target_triple = select({
116
117
"prelude//os:none": select({
117
118
"prelude//cpu:riscv64": "riscv64gc-k23-none-kernel",
118
-
"prelude//cpu:arm64": "aarch64-unknown-none",
119
119
}),
120
120
"DEFAULT": None
121
121
}),
···
184
184
name = "remote_test_execution",
185
185
visibility = ["PUBLIC"],
186
186
)
187
+
188
+
# =============================================================================
189
+
# Configuration Transitions
190
+
# =============================================================================
191
+
192
+
configuration_transition(
193
+
name = "panic_abort",
194
+
constraint_values = [
195
+
"constraints//:panic[abort]",
196
+
],
197
+
visibility = ["PUBLIC"],
198
+
)
199
+
200
+
configuration_transition(
201
+
name = "panic_unwind",
202
+
constraint_values = [
203
+
"constraints//:panic[unwind]",
204
+
],
205
+
visibility = ["PUBLIC"],
206
+
)
207
+
208
+
configuration_transition(
209
+
name = "rust_bootstrap",
210
+
constraint_values = [
211
+
"constraints//:rust-mode[bootstrap]",
212
+
],
213
+
visibility = ["PUBLIC"],
214
+
)
+12
-18
build/toolchains/rust.bzl
+12
-18
build/toolchains/rust.bzl
···
93
93
## Examples
94
94
95
95
```starlark
96
-
# use the `rustc` flake package output from `./nix` to provide the Rust compiler and rustdoc
96
+
# expose the Rust toolchain from the Nix flake
97
97
flake.package(
98
-
name = "rustc",
99
-
binaries = ["rustdoc"],
100
-
binary = "rustc",
101
-
path = "nix",
98
+
name = "rust_toolchain",
99
+
package = "rustToolchain",
100
+
binaries = ["rustc", "rustdoc", "clippy-driver", "miri-driver"],
101
+
path = "root//:flake",
102
102
)
103
103
104
-
# use the `clippy` flake package output from `./nix` to provide the clippy tool
105
-
flake.package(
106
-
name = "clippy",
107
-
binary = "clippy-driver",
108
-
path = "nix",
109
-
)
110
-
111
-
# provide the `rust` toolchain using the `:rustc` and `:clippy` targets
112
-
nix_rust_toolchain(
104
+
# provide the `rust` toolchain using sub-targets of the flake package
105
+
rust_toolchain(
113
106
name = "rust",
114
-
clippy = ":clippy",
115
-
default_edition = "2021",
116
-
rustc = ":rustc",
117
-
rustdoc = ":rustc[rustdoc]", # use the rustdoc binary from the `rustc` target
107
+
rustc = ":rust_toolchain[rustc]",
108
+
clippy = ":rust_toolchain[clippy-driver]",
109
+
rustdoc = ":rust_toolchain[rustdoc]",
110
+
miri_driver = ":rust_toolchain[miri-driver]",
111
+
default_edition = "2024",
118
112
visibility = ["PUBLIC"],
119
113
)
120
114
```
build/transitions/defs.bzl
build/toolchains/transitions.bzl
build/transitions/defs.bzl
build/toolchains/transitions.bzl
-25
build/transitions/BUCK
-25
build/transitions/BUCK
···
1
-
load(":defs.bzl", "configuration_transition")
2
-
3
-
configuration_transition(
4
-
name = "panic_abort",
5
-
constraint_values = [
6
-
"constraints//:panic[abort]",
7
-
],
8
-
visibility = ["PUBLIC"],
9
-
)
10
-
11
-
configuration_transition(
12
-
name = "panic_unwind",
13
-
constraint_values = [
14
-
"constraints//:panic[unwind]",
15
-
],
16
-
visibility = ["PUBLIC"],
17
-
)
18
-
19
-
configuration_transition(
20
-
name = "rust_bootstrap",
21
-
constraint_values = [
22
-
"constraints//:rust-mode[bootstrap]",
23
-
],
24
-
visibility = ["PUBLIC"],
25
-
)
+37
-313
lib/BUCK
+37
-313
lib/BUCK
···
1
-
load("@prelude//platforms:defs.bzl", "host_configuration")
1
+
load("//build:defs.bzl", "k23_rust_library")
2
2
3
-
_HOSTED = [host_configuration.cpu,host_configuration.os]
4
-
5
-
rust_library(
3
+
k23_rust_library(
6
4
name = "util",
7
-
srcs = glob(["util/src/**/*.rs"]),
8
-
crate = "kutil",
9
-
tests = [":util_tests"],
10
-
visibility = ["PUBLIC"],
11
-
)
12
-
13
-
rust_test(
14
-
name = "util_tests",
15
-
srcs = glob(["util/src/**/*.rs"]),
16
5
crate = "kutil",
17
-
visibility = ["PUBLIC"],
18
-
target_compatible_with = _HOSTED
19
6
)
20
7
21
-
rust_library(
8
+
k23_rust_library(
22
9
name = "trap",
23
-
srcs = glob(["trap/src/**/*.rs"]),
24
-
tests = [":trap_tests"],
25
-
visibility = ["PUBLIC"],
26
-
)
27
-
28
-
rust_test(
29
-
name = "trap_tests",
30
-
srcs = glob(["trap/src/**/*.rs"]),
31
-
visibility = ["PUBLIC"],
32
-
target_compatible_with = _HOSTED
10
+
crate = "ktrap",
33
11
)
34
12
35
-
rust_library(
13
+
k23_rust_library(
36
14
name = "arrayvec",
37
-
srcs = glob(["arrayvec/src/**/*.rs"]),
38
15
crate = "karrayvec",
39
-
tests = [":arrayvec_tests"],
40
-
visibility = ["PUBLIC"],
41
16
)
42
17
43
-
rust_test(
44
-
name = "arrayvec_tests",
45
-
srcs = glob(["arrayvec/src/**/*.rs"]),
46
-
crate = "karrayvec",
47
-
visibility = ["PUBLIC"],
48
-
target_compatible_with = _HOSTED
49
-
)
50
-
51
-
rust_library(
18
+
k23_rust_library(
52
19
name = "fastrand",
53
-
srcs = glob(["fastrand/src/**/*.rs"]),
54
-
crate = "kfastrand",
55
-
tests = [":fastrand_tests"],
56
-
visibility = ["PUBLIC"],
57
-
)
58
-
59
-
rust_test(
60
-
name = "fastrand_tests",
61
-
srcs = glob(["fastrand/src/**/*.rs"]),
62
20
crate = "kfastrand",
63
-
visibility = ["PUBLIC"],
64
-
target_compatible_with = _HOSTED
65
21
)
66
22
67
-
rust_library(
23
+
k23_rust_library(
68
24
name = "wavltree",
69
-
srcs = glob(["wavltree/src/**/*.rs"]),
70
-
tests = [":wavltree_tests"],
71
-
visibility = ["PUBLIC"],
25
+
crate = "kwavltree",
26
+
test_deps = ["//third-party:rand"],
72
27
)
73
28
74
-
rust_test(
75
-
name = "wavltree_tests",
76
-
srcs = glob(["wavltree/src/**/*.rs"]),
77
-
deps = ["//third-party:rand"],
78
-
visibility = ["PUBLIC"],
79
-
target_compatible_with = _HOSTED
80
-
)
81
-
82
-
rust_library(
29
+
k23_rust_library(
83
30
name = "cpu-local",
84
-
srcs = glob(["cpu-local/src/**/*.rs"]),
85
-
crate = "kcpu_local",
86
-
deps = [
87
-
":util",
88
-
],
89
-
tests = [":cpu-local_tests"],
90
-
visibility = ["PUBLIC"],
91
-
)
92
-
93
-
rust_test(
94
-
name = "cpu-local_tests",
95
-
srcs = glob(["cpu-local/src/**/*.rs"]),
96
31
crate = "kcpu_local",
97
32
deps = [
98
33
":util",
99
34
],
100
-
visibility = ["PUBLIC"],
101
-
target_compatible_with = _HOSTED
102
35
)
103
36
104
-
rust_library(
37
+
k23_rust_library(
105
38
name = "spin",
106
-
srcs = glob(["spin/src/**/*.rs"]),
107
39
crate = "kspin",
108
40
deps = [
109
41
":util",
110
42
"//third-party:cfg-if",
111
43
"//third-party:lock_api",
112
44
],
113
-
tests = [":spin_tests"],
114
-
visibility = ["PUBLIC"],
115
-
)
116
-
117
-
rust_test(
118
-
name = "spin_tests",
119
-
srcs = glob(["spin/src/**/*.rs"]),
120
-
crate = "kspin",
121
-
deps = [
122
-
":util",
123
-
"//third-party:cfg-if",
124
-
"//third-party:lock_api",
45
+
test_deps = [
125
46
"//third-party:lazy_static",
126
47
"//third-party:rand",
127
48
],
128
-
visibility = ["PUBLIC"],
129
-
target_compatible_with = _HOSTED
130
49
)
131
50
132
-
rust_library(
51
+
k23_rust_library(
133
52
name = "fdt",
134
-
srcs = glob(["fdt/src/**/*.rs"]),
135
-
crate = "kfdt",
136
-
deps = [
137
-
"//third-party:fallible-iterator",
138
-
],
139
-
tests = [":fdt_tests"],
140
-
visibility = ["PUBLIC"],
141
-
)
142
-
143
-
rust_test(
144
-
name = "fdt_tests",
145
-
srcs = glob(["fdt/src/**/*.rs"]),
146
53
crate = "kfdt",
147
54
deps = [
148
55
"//third-party:fallible-iterator",
149
56
],
150
-
visibility = ["PUBLIC"],
151
-
target_compatible_with = _HOSTED
152
57
)
153
58
154
-
rust_library(
59
+
k23_rust_library(
155
60
name = "riscv",
156
-
srcs = glob(["riscv/src/**/*.rs"]),
61
+
crate = "kriscv",
157
62
deps = [
158
63
":spin",
159
64
":trap",
160
65
"//third-party:cfg-if",
161
66
"//third-party:bitflags",
162
67
],
163
-
tests = [":riscv_tests"],
164
-
visibility = ["PUBLIC"],
165
68
)
166
69
167
-
rust_test(
168
-
name = "riscv_tests",
169
-
srcs = glob(["riscv/src/**/*.rs"]),
170
-
deps = [
171
-
":spin",
172
-
":trap",
173
-
"//third-party:cfg-if",
174
-
"//third-party:bitflags",
175
-
],
176
-
visibility = ["PUBLIC"],
177
-
target_compatible_with = _HOSTED
178
-
)
179
-
180
-
rust_library(
70
+
k23_rust_library(
181
71
name = "abort",
182
-
srcs = glob(["abort/src/**/*.rs"]),
183
72
crate = "kabort",
184
73
deps = [
185
74
"//third-party:cfg-if",
186
75
] + select({
187
76
"prelude//cpu/constraints:riscv64": [":riscv"],
188
-
# "prelude//cpu/constraints:riscv32": [":riscv"],
189
-
"DEFAULT": []
77
+
"DEFAULT": [],
190
78
}),
191
-
tests = [":abort_tests"],
192
-
visibility = ["PUBLIC"],
193
-
)
194
-
195
-
rust_test(
196
-
name = "abort_tests",
197
-
srcs = glob(["abort/src/**/*.rs"]),
198
-
crate = "kabort",
199
-
deps = [
200
-
"//third-party:cfg-if",
201
-
],
202
-
visibility = ["PUBLIC"],
203
-
target_compatible_with = _HOSTED
204
79
)
205
80
206
-
rust_library(
81
+
k23_rust_library(
207
82
name = "uart-16550",
208
-
srcs = glob(["uart-16550/src/**/*.rs"]),
209
83
crate = "kuart_16550",
210
84
deps = [
211
85
":spin",
212
86
"//third-party:bitflags",
213
87
],
214
-
tests = [":uart-16550_tests"],
215
-
visibility = ["PUBLIC"],
216
88
)
217
89
218
-
rust_test(
219
-
name = "uart-16550_tests",
220
-
srcs = glob(["uart-16550/src/**/*.rs"]),
221
-
crate = "kuart_16550",
222
-
deps = [
223
-
":spin",
224
-
"//third-party:bitflags",
225
-
],
226
-
visibility = ["PUBLIC"],
227
-
target_compatible_with = _HOSTED
228
-
)
229
-
230
-
rust_library(
90
+
k23_rust_library(
231
91
name = "sharded-slab",
232
-
srcs = glob(["sharded-slab/src/**/*.rs"]),
233
92
crate = "ksharded_slab",
234
93
deps = [
235
94
":spin",
236
95
":cpu-local",
237
96
"//third-party:log",
238
97
],
239
-
tests = [":sharded-slab_tests"],
240
-
visibility = ["PUBLIC"],
241
98
)
242
99
243
-
rust_test(
244
-
name = "sharded-slab_tests",
245
-
srcs = glob(["sharded-slab/src/**/*.rs"]),
246
-
crate = "ksharded_slab",
247
-
deps = [
248
-
":spin",
249
-
":cpu-local",
250
-
"//third-party:log",
251
-
],
252
-
visibility = ["PUBLIC"],
253
-
target_compatible_with = _HOSTED
254
-
)
255
-
256
-
rust_library(
100
+
k23_rust_library(
257
101
name = "unwind",
258
-
srcs = glob(["unwind/src/**/*.rs"]),
259
102
crate = "kunwind",
260
103
deps = [
261
104
":spin",
···
265
108
"//third-party:fallible-iterator",
266
109
"//third-party:tracing",
267
110
],
268
-
# tests = [":unwind_tests"],
269
-
visibility = ["PUBLIC"],
111
+
tests = False,
270
112
)
271
113
272
-
# rust_test(
273
-
# name = "unwind_tests",
274
-
# srcs = glob(["unwind/src/**/*.rs"]),
275
-
# crate = "kunwind",
276
-
# deps = [
277
-
# ":spin",
278
-
# ":abort",
279
-
# "//third-party:cfg-if",
280
-
# "//third-party:gimli",
281
-
# "//third-party:fallible-iterator",
282
-
# "//third-party:tracing",
283
-
# ],
284
-
# visibility = ["PUBLIC"],
285
-
# target_compatible_with = []
286
-
# )
287
-
288
-
rust_library(
114
+
k23_rust_library(
289
115
name = "addr2line",
290
-
srcs = glob(["addr2line/src/**/*.rs"]),
291
116
crate = "kaddr2line",
292
117
deps = [
293
118
":spin",
···
295
120
"//third-party:smallvec",
296
121
"//third-party:fallible-iterator",
297
122
],
298
-
# tests = [":addr2line_tests"],
299
-
visibility = ["PUBLIC"],
123
+
tests = False,
300
124
)
301
125
302
-
# rust_test(
303
-
# name = "addr2line_tests",
304
-
# srcs = glob(["addr2line/src/**/*.rs"]),
305
-
# crate = "kaddr2line",
306
-
# deps = [
307
-
# ":spin",
308
-
# "//third-party:gimli",
309
-
# "//third-party:smallvec",
310
-
# "//third-party:fallible-iterator",
311
-
# ],
312
-
# visibility = ["PUBLIC"],
313
-
# target_compatible_with = _HOSTED
314
-
# )
315
-
316
-
rust_library(
126
+
k23_rust_library(
317
127
name = "backtrace",
318
-
srcs = glob(["backtrace/src/**/*.rs"]),
319
128
crate = "kbacktrace",
320
129
deps = [
321
130
":addr2line",
···
326
135
"//third-party:rustc-demangle",
327
136
"//third-party:fallible-iterator",
328
137
],
329
-
# tests = [":backtrace_tests"],
330
-
visibility = ["PUBLIC"],
138
+
tests = False,
331
139
)
332
140
333
-
# rust_test(
334
-
# name = "backtrace_tests",
335
-
# srcs = glob(["backtrace/src/**/*.rs"]),
336
-
# crate = "kbacktrace",
337
-
# deps = [
338
-
# ":addr2line",
339
-
# ":arrayvec",
340
-
# ":unwind",
341
-
# "//third-party:gimli",
342
-
# "//third-party:xmas-elf",
343
-
# "//third-party:rustc-demangle",
344
-
# "//third-party:fallible-iterator",
345
-
# ],
346
-
# visibility = ["PUBLIC"],
347
-
# )
348
-
349
-
rust_library(
141
+
k23_rust_library(
350
142
name = "panic-unwind",
351
-
srcs = glob(["panic-unwind/src/**/*.rs"]),
352
-
crate = "panic_unwind",
143
+
crate = "kpanic_unwind",
353
144
deps = [
354
145
":unwind",
355
146
":spin",
356
147
":cpu-local",
357
148
":abort",
358
-
"//third-party:tracing"
149
+
"//third-party:tracing",
359
150
],
360
-
361
-
# deps = [
362
-
# ] + select({
363
-
# "prelude//cpu/constraints:riscv64": [":riscv"],
364
-
# # "prelude//cpu/constraints:riscv32": [":riscv"],
365
-
# "DEFAULT": []
366
-
# }),
367
-
# tests = [":panic-unwind_tests"],
368
-
visibility = ["PUBLIC"],
151
+
tests = False,
369
152
)
370
153
371
-
# rust_test(
372
-
# name = "panic-unwind_tests",
373
-
# srcs = glob(["panic-unwind/src/**/*.rs"]),
374
-
# crate = "kpanic_unwind",
375
-
# deps = [
376
-
# ":spin",
377
-
# ":cpu-local",
378
-
# ":unwind",
379
-
# ":abort",
380
-
# "//third-party:tracing",
381
-
# ],
382
-
# visibility = ["PUBLIC"],
383
-
# )
384
-
385
-
rust_library(
154
+
k23_rust_library(
386
155
name = "mem-core",
387
-
srcs = glob(["mem-core/src/**/*.rs"]),
388
156
crate = "kmem_core",
389
157
deps = [
390
158
":arrayvec",
···
393
161
"//third-party:log",
394
162
"//third-party:lock_api",
395
163
],
396
-
tests = [":mem-core_tests"],
397
-
visibility = ["PUBLIC"],
398
-
)
399
-
400
-
rust_test(
401
-
name = "mem-core_tests",
402
-
srcs = glob(["mem-core/src/**/*.rs"]),
403
-
crate = "kmem_core",
404
-
deps = [
405
-
":arrayvec",
406
-
":riscv",
164
+
test_deps = [
407
165
":cpu-local",
408
166
":spin",
409
-
"//third-party:mycelium-bitfield",
410
-
"//third-party:log",
411
-
"//third-party:lock_api",
412
167
"//third-party:proptest",
413
168
"//third-party:proptest-derive",
414
169
"//third-party:parking_lot",
415
170
"//third-party:tracing-subscriber",
416
171
],
417
-
features = ["test_utils"],
418
-
visibility = ["PUBLIC"],
419
-
target_compatible_with = _HOSTED
172
+
test_features = ["test_utils"],
420
173
)
421
174
422
-
rust_library(
175
+
k23_rust_library(
423
176
name = "range-tree",
424
-
srcs = glob(["range-tree/src/**/*.rs"]),
177
+
crate = "krange_tree",
425
178
deps = [
426
179
"//third-party:cfg-if",
427
180
"//third-party:tracing",
428
181
],
429
-
tests = [":range-tree_tests"],
430
-
visibility = ["PUBLIC"],
431
-
)
432
-
433
-
rust_test(
434
-
name = "range-tree_tests",
435
-
srcs = glob(["range-tree/src/**/*.rs"]),
436
-
deps = [
437
-
"//third-party:cfg-if",
438
-
"//third-party:tracing",
182
+
test_deps = [
439
183
"//third-party:proptest",
440
184
"//third-party:rand",
441
185
"//third-party:tracing-subscriber",
442
186
"//third-party:nonmax",
443
187
],
444
-
visibility = ["PUBLIC"],
445
-
target_compatible_with = _HOSTED
446
188
)
447
189
448
-
rust_library(
190
+
k23_rust_library(
449
191
name = "wast",
450
-
srcs = glob(["wast/src/**/*.rs"]),
451
192
crate = "kwast",
452
193
deps = [
453
194
":cpu-local",
···
458
199
"//third-party:memchr",
459
200
"//third-party:bumpalo",
460
201
],
461
-
tests = [":wast_tests"],
462
-
visibility = ["PUBLIC"],
463
-
)
464
-
465
-
rust_test(
466
-
name = "wast_tests",
467
-
srcs = glob(["wast/src/**/*.rs"]),
468
-
crate = "kwast",
469
-
deps = [
470
-
":cpu-local",
471
-
"//third-party:leb128fmt",
472
-
"//third-party:wasm-encoder",
473
-
"//third-party:hashbrown",
474
-
"//third-party:unicode-width",
475
-
"//third-party:memchr",
476
-
"//third-party:bumpalo",
202
+
test_deps = [
477
203
"//third-party:wat",
478
204
"//third-party:anyhow",
479
205
"//third-party:libtest-mimic",
480
206
"//third-party:wasmparser",
481
207
],
482
-
visibility = ["PUBLIC"],
483
-
target_compatible_with = _HOSTED
484
208
)
+3
-3
lib/_kmem/src/address_space.rs
+3
-3
lib/_kmem/src/address_space.rs
···
12
12
use core::ops::{ControlFlow, Range};
13
13
use core::ptr::NonNull;
14
14
15
-
use anyhow::{Context, format_err};
16
-
use rand::Rng;
15
+
use anyhow::{format_err, Context};
16
+
use kwavltree::WAVLTree;
17
17
use rand::distr::Uniform;
18
+
use rand::Rng;
18
19
use rand_chacha::ChaCha20Rng;
19
-
use wavltree::WAVLTree;
20
20
21
21
use crate::address_space::region::AddressSpaceRegion;
22
22
use crate::{AccessRules, AddressRangeExt, VirtualAddress};
+9
-9
lib/_kmem/src/address_space/region.rs
+9
-9
lib/_kmem/src/address_space/region.rs
···
32
32
33
33
/// Links to other regions in the WAVL tree
34
34
#[pin]
35
-
links: wavltree::Links<AddressSpaceRegion>,
35
+
links: kwavltree::Links<AddressSpaceRegion>,
36
36
}
37
37
38
38
impl AddressSpaceRegion {
···
50
50
51
51
max_gap: 0,
52
52
subtree_range: spot..spot.checked_add(layout.size()).unwrap(),
53
-
links: wavltree::Links::new(),
53
+
links: kwavltree::Links::new(),
54
54
}
55
55
}
56
56
···
98
98
Some(unsafe { self.links.parent()?.as_ref() })
99
99
}
100
100
101
-
/// Update the gap search metadata of this region. This method is called in the [`wavltree::Linked`]
101
+
/// Update the gap search metadata of this region. This method is called in the [`kwavltree::Linked`]
102
102
/// implementation below after each tree mutation that impacted this node or its subtree in some way
103
103
/// (insertion, rotation, deletion).
104
104
///
···
169
169
170
170
// Safety: the pinning and !Unpin requirements are enforced by the `#[pin_project(!Unpin)]` attribute
171
171
// of the `AddressSpaceRegion`. see above.
172
-
unsafe impl wavltree::Linked for AddressSpaceRegion {
172
+
unsafe impl kwavltree::Linked for AddressSpaceRegion {
173
173
/// Any heap-allocated type that owns an element may be used.
174
174
///
175
175
/// An element *must not* move while part of an intrusive data
···
180
180
181
181
/// Convert an owned `Handle` into a raw pointer
182
182
fn into_ptr(handle: Self::Handle) -> NonNull<Self> {
183
-
// Safety: wavltree treats the ptr as pinned
183
+
// Safety: kwavltree treats the ptr as pinned
184
184
unsafe { NonNull::from(Box::leak(Pin::into_inner_unchecked(handle))) }
185
185
}
186
186
···
191
191
unsafe { Pin::new_unchecked(Box::from_raw(ptr.as_ptr())) }
192
192
}
193
193
194
-
unsafe fn links(ptr: NonNull<Self>) -> NonNull<wavltree::Links<Self>> {
194
+
unsafe fn links(ptr: NonNull<Self>) -> NonNull<kwavltree::Links<Self>> {
195
195
ptr.map_addr(|addr| {
196
196
let offset = offset_of!(Self, links);
197
197
addr.checked_add(offset).unwrap()
···
219
219
parent: NonNull<Self>,
220
220
sibling: Option<NonNull<Self>>,
221
221
lr_child: Option<NonNull<Self>>,
222
-
side: wavltree::Side,
222
+
side: kwavltree::Side,
223
223
) {
224
224
let this = self.project();
225
225
// Safety: caller ensures ptr is valid
···
229
229
this.subtree_range.end = _parent.subtree_range.end;
230
230
*this.max_gap = _parent.max_gap;
231
231
232
-
if side == wavltree::Side::Left {
232
+
if side == kwavltree::Side::Left {
233
233
Self::update_gap_metadata(parent, sibling, lr_child);
234
234
} else {
235
235
Self::update_gap_metadata(parent, lr_child, sibling);
···
241
241
mod tests {
242
242
use core::alloc::Layout;
243
243
244
-
use wavltree::WAVLTree;
244
+
use kwavltree::WAVLTree;
245
245
246
246
use super::*;
247
247
use crate::{AccessRules, VirtualAddress};
+1
-1
lib/abort/src/lib.rs
+1
-1
lib/abort/src/lib.rs
+5
-5
lib/mem-core/src/arch/riscv64.rs
+5
-5
lib/mem-core/src/arch/riscv64.rs
···
1
1
use core::ops::Range;
2
2
3
-
use riscv::satp;
4
-
use riscv::sbi::rfence::{sfence_vma, sfence_vma_asid};
3
+
use kriscv::satp;
4
+
use kriscv::sbi::rfence::{sfence_vma, sfence_vma_asid};
5
5
6
6
use crate::arch::PageTableLevel;
7
7
use crate::{
8
-
AddressRangeExt, GIB, KIB, MIB, MemoryAttributes, PhysicalAddress, TIB, VirtualAddress,
9
-
WriteOrExecute,
8
+
AddressRangeExt, MemoryAttributes, PhysicalAddress, VirtualAddress, WriteOrExecute, GIB, KIB,
9
+
MIB, TIB,
10
10
};
11
11
12
12
/// The number of usable bits in a `PhysicalAddress`. This may be used for address canonicalization.
···
327
327
use super::*;
328
328
use crate::arch::PageTableEntry;
329
329
use crate::test_utils::proptest::{aligned_phys, phys};
330
-
use crate::{KIB, MemoryAttributes};
330
+
use crate::{MemoryAttributes, KIB};
331
331
332
332
proptest! {
333
333
#[test]
+4
-4
lib/range-tree/benches/comparisons.rs
+4
-4
lib/range-tree/benches/comparisons.rs
···
10
10
use std::ptr::NonNull;
11
11
12
12
use brie_tree::BTree;
13
-
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
13
+
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
14
+
use krange_tree::RangeTree;
15
+
use kwavltree::{Linked, Links, WAVLTree};
14
16
use nonmax::NonMaxU64;
15
17
use pin_project::pin_project;
16
-
use rand::Rng;
17
18
use rand::distr::Uniform;
18
19
use rand::prelude::SliceRandom;
19
-
use range_tree::RangeTree;
20
-
use wavltree::{Linked, Links, WAVLTree};
20
+
use rand::Rng;
21
21
22
22
pub const KIB: u64 = 1024;
23
23
pub const MIB: u64 = KIB * 1024;
+1
-1
lib/range-tree/tests/gaps.rs
+1
-1
lib/range-tree/tests/gaps.rs
+1
-1
lib/range-tree/tests/insertion.rs
+1
-1
lib/range-tree/tests/insertion.rs
+1
-1
lib/range-tree/tests/lookup.rs
+1
-1
lib/range-tree/tests/lookup.rs
+1
-1
lib/range-tree/tests/proptest.rs
+1
-1
lib/range-tree/tests/proptest.rs
+1
-1
lib/riscv/src/trap.rs
+1
-1
lib/riscv/src/trap.rs
+2
-2
lib/wavltree/benches/insertions_deletions.rs
+2
-2
lib/wavltree/benches/insertions_deletions.rs
···
3
3
use std::pin::Pin;
4
4
use std::ptr::NonNull;
5
5
6
-
use criterion::{Criterion, criterion_group, criterion_main};
6
+
use criterion::{criterion_group, criterion_main, Criterion};
7
+
use kwavltree::{Linked, Links, WAVLTree};
7
8
use rand::prelude::SliceRandom;
8
9
use rand::thread_rng;
9
-
use wavltree::{Linked, Links, WAVLTree};
10
10
11
11
#[derive(Default)]
12
12
struct WAVLEntry {
+2
-2
lib/wavltree/fuzz/fuzz_targets/inserts.rs
+2
-2
lib/wavltree/fuzz/fuzz_targets/inserts.rs
···
1
1
#![no_main]
2
2
3
+
use kwavltree::Linked;
4
+
use kwavltree::{Links, WAVLTree};
3
5
use libfuzzer_sys::fuzz_target;
4
6
use std::cmp::Ordering;
5
7
use std::mem::offset_of;
6
8
use std::pin::Pin;
7
9
use std::ptr::NonNull;
8
-
use wavltree::Linked;
9
-
use wavltree::{Links, WAVLTree};
10
10
11
11
#[derive(Default)]
12
12
struct TestEntry {
+2
-2
lib/wavltree/fuzz/fuzz_targets/inserts_deletes.rs
+2
-2
lib/wavltree/fuzz/fuzz_targets/inserts_deletes.rs
···
1
1
#![no_main]
2
2
3
+
use kwavltree::Linked;
4
+
use kwavltree::{Links, WAVLTree};
3
5
use libfuzzer_sys::fuzz_target;
4
6
use std::fmt;
5
7
use std::mem::offset_of;
6
8
use std::pin::Pin;
7
9
use std::ptr::NonNull;
8
-
use wavltree::Linked;
9
-
use wavltree::{Links, WAVLTree};
10
10
11
11
#[derive(Default)]
12
12
struct TestEntry {
+15
-15
lib/wavltree/src/lib.rs
+15
-15
lib/wavltree/src/lib.rs
···
32
32
//! # use core::ptr::NonNull;
33
33
//! #[derive(Default)]
34
34
//! struct MyNode {
35
-
//! links: wavltree::Links<Self>,
35
+
//! links: kwavltree::Links<Self>,
36
36
//! value: usize,
37
37
//! }
38
38
//!
···
46
46
//!
47
47
//! // Participation in an intrusive collection requires a bit more effort
48
48
//! // on the values's part.
49
-
//! unsafe impl wavltree::Linked for MyNode {
49
+
//! unsafe impl kwavltree::Linked for MyNode {
50
50
//! /// The owning handle type, must ensure participating values are pinned in memory.
51
51
//! type Handle = Pin<Box<Self>>;
52
52
//! /// The key type by which entries are identified.
···
64
64
//! }
65
65
//!
66
66
//! /// Return the links of the node pointed to by ptr.
67
-
//! unsafe fn links(ptr: NonNull<Self>) -> NonNull<wavltree::Links<Self>> {
67
+
//! unsafe fn links(ptr: NonNull<Self>) -> NonNull<kwavltree::Links<Self>> {
68
68
//! ptr.map_addr(|addr| {
69
69
//! let offset = offset_of!(Self, links);
70
70
//! addr.checked_add(offset).unwrap()
···
79
79
//! }
80
80
//!
81
81
//! fn main() {
82
-
//! let mut tree = wavltree::WAVLTree::new();
82
+
//! let mut tree = kwavltree::WAVLTree::new();
83
83
//! tree.insert(Box::pin(MyNode::new(42)));
84
84
//! tree.insert(Box::pin(MyNode::new(17)));
85
85
//! tree.insert(Box::pin(MyNode::new(9)));
···
190
190
/// Suppose we have an element type like this:
191
191
/// ```rust
192
192
/// struct Entry {
193
-
/// links: wavltree::Links<Self>,
193
+
/// links: kwavltree::Links<Self>,
194
194
/// data: usize,
195
195
/// }
196
196
/// ```
···
199
199
/// might look like this:
200
200
///
201
201
/// ```
202
-
/// use wavltree::Linked;
202
+
/// use kwavltree::Linked;
203
203
/// use core::ptr::NonNull;
204
204
///
205
205
/// # struct Entry {
206
-
/// # links: wavltree::Links<Self>,
206
+
/// # links: kwavltree::Links<Self>,
207
207
/// # data: usize
208
208
/// # }
209
209
///
···
215
215
/// # unsafe fn from_ptr(ptr: NonNull<Self>) -> Self::Handle { ptr }
216
216
/// // ...
217
217
///
218
-
/// unsafe fn links(mut target: NonNull<Self>) -> NonNull<wavltree::Links<Self>> {
218
+
/// unsafe fn links(mut target: NonNull<Self>) -> NonNull<kwavltree::Links<Self>> {
219
219
/// // Borrow the target's `links` field.
220
220
/// let links = &mut target.as_mut().links;
221
221
/// // Convert that reference into a pointer.
···
235
235
///
236
236
/// ```
237
237
/// use core::ptr::{self, NonNull};
238
-
/// # use wavltree::Linked;
238
+
/// # use kwavltree::Linked;
239
239
/// # struct Entry {
240
-
/// # links: wavltree::Links<Self>,
240
+
/// # links: kwavltree::Links<Self>,
241
241
/// # data: usize,
242
242
/// # }
243
243
///
···
249
249
/// # unsafe fn from_ptr(ptr: NonNull<Self>) -> Self::Handle { ptr }
250
250
/// // ...
251
251
///
252
-
/// unsafe fn links(target: NonNull<Self>) -> NonNull<wavltree::Links<Self>> {
252
+
/// unsafe fn links(target: NonNull<Self>) -> NonNull<kwavltree::Links<Self>> {
253
253
/// // Note that we use the `map_addr` method here that is part of the strict-provenance
254
254
/// target
255
255
/// .map_addr(|addr| {
···
298
298
///
299
299
/// ```rust
300
300
/// struct Entry {
301
-
/// links: wavltree::Links<Self>,
301
+
/// links: kwavltree::Links<Self>,
302
302
/// age: u16,
303
303
/// name: String
304
304
/// }
···
311
311
/// # use std::ptr::NonNull;
312
312
///
313
313
/// # struct Entry {
314
-
/// # links: wavltree::Links<Self>,
314
+
/// # links: kwavltree::Links<Self>,
315
315
/// # age: u16,
316
316
/// # name: String
317
317
/// # }
318
318
///
319
-
/// unsafe impl wavltree::Linked for Entry {
319
+
/// unsafe impl kwavltree::Linked for Entry {
320
320
/// # type Handle = NonNull<Self>;
321
321
/// # fn into_ptr(r: Self::Handle) -> NonNull<Self> { r }
322
322
/// # unsafe fn from_ptr(ptr: NonNull<Self>) -> Self::Handle { ptr }
323
-
/// # unsafe fn links(ptr: NonNull<Self>) -> NonNull<wavltree::Links<Entry>> { ptr.map_addr(|a| {
323
+
/// # unsafe fn links(ptr: NonNull<Self>) -> NonNull<kwavltree::Links<Entry>> { ptr.map_addr(|a| {
324
324
/// # a.checked_add(core::mem::offset_of!(Self, links)).unwrap()
325
325
/// # }).cast() }
326
326
/// // ...
+5
-25
platforms/BUCK
+5
-25
platforms/BUCK
···
1
-
load("@prelude//platforms:defs.bzl", "host_configuration")
2
-
3
1
filegroup(
4
-
name = "targets",
5
-
srcs = [
6
-
"./riscv64gc-k23-none-kernel.json"
7
-
],
8
-
visibility = ["PUBLIC"],
2
+
name = "targets",
3
+
srcs = [
4
+
"./riscv64gc-k23-none-kernel.json",
5
+
],
6
+
visibility = ["PUBLIC"],
9
7
)
10
8
11
9
_CONSTRAINT_DEFAULTS = [
···
25
23
visibility = ["PUBLIC"],
26
24
)
27
25
28
-
platform(
29
-
name = "riscv64-release",
30
-
constraint_values = [
31
-
"prelude//cpu/constraints:riscv64",
32
-
"prelude//os/constraints:none",
33
-
] + _CONSTRAINT_DEFAULTS,
34
-
visibility = ["PUBLIC"],
35
-
)
36
-
37
26
platform(
38
27
name = "aarch64",
39
28
constraint_values = [
···
51
40
] + _CONSTRAINT_DEFAULTS,
52
41
visibility = ["PUBLIC"],
53
42
)
54
-
55
-
# execution_platform(
56
-
# name = "host",
57
-
# constraint_values = [
58
-
# host_configuration.cpu,
59
-
# host_configuration.os,
60
-
# ],
61
-
# visibility = ["PUBLIC"],
62
-
# )
+5
-7
sys/BUCK
+5
-7
sys/BUCK
···
1
-
load("@prelude//platforms:defs.bzl", "host_configuration")
2
-
3
-
_HOSTED = [host_configuration.cpu,host_configuration.os]
1
+
load("//build:defs.bzl", "HOSTED")
4
2
5
3
# =============================================================================
6
4
# System Libraries
···
53
51
],
54
52
features = ["counters"],
55
53
visibility = ["PUBLIC"],
56
-
target_compatible_with = _HOSTED
54
+
target_compatible_with = HOSTED,
57
55
)
58
56
59
57
# =============================================================================
···
63
61
rust_binary(
64
62
name = "kernel",
65
63
srcs = glob(["kernel/**/*.rs"]),
66
-
incoming_transition = "//build/transitions:panic_unwind",
64
+
incoming_transition = "toolchains//:panic_unwind",
67
65
deps = [
68
66
"//third-party:log",
69
-
"//lib:panic-unwind"
67
+
"//lib:panic-unwind",
70
68
],
71
69
)
72
70
···
76
74
deps = [
77
75
"//third-party:log",
78
76
],
79
-
incoming_transition = "//build/transitions:panic_abort",
77
+
incoming_transition = "toolchains//:panic_abort",
80
78
env = {
81
79
"KERNEL": "$(location :kernel)",
82
80
},
History
1 round
0 comments
jonaskruckenberg.de
submitted
#0
1 commit
expand
collapse
cleanup
expand 0 comments
This pull has been deleted (possibly by jj abandon or jj squash)