Add kernel memory functions & other memory-related changes (#590)
New Features - Added policy-based memory allocation APIs with capability flags and optional alignment: `memory_alloc_with_policy`, `memory_realloc_with_policy`, `memory_calloc_with_policy`, and `memory_free`. - Switched heap memory reporting to `memory_print_stats`. Bug Fixes - Improved allocation robustness with capability fallback behavior. - Added overflow-safe handling for aligned zero-initialized allocations. - Tightened const-correctness for generated device-tree device arrays. Tests - Added unit tests for default policy, alignment, zero-initialization, realloc preservation, freeing, and memory stats reporting.
This commit is contained in:
committed by
GitHub
parent
f21c0df6fe
commit
03a6285328
@@ -350,7 +350,7 @@ def generate_devicetree_c(filename: str, items: list[object], bindings: list[Bin
|
||||
for item in items:
|
||||
if type(item) is Device:
|
||||
write_device_structs(file, item, None, bindings, devices, verbose)
|
||||
file.write("struct DtsDevice dts_devices[] = {\n")
|
||||
file.write("const struct DtsDevice dts_devices[] = {\n")
|
||||
for item in items:
|
||||
if type(item) is Device:
|
||||
write_device_list_entry(file, item, bindings, verbose)
|
||||
@@ -379,7 +379,7 @@ def generate_devicetree_c(filename: str, items: list[object], bindings: list[Bin
|
||||
file.write(f"extern struct Module {symbol};\n")
|
||||
file.write("\n")
|
||||
# Create array of symbol variables
|
||||
file.write("struct Module* dts_modules[] = {\n")
|
||||
file.write("struct Module* const dts_modules[] = {\n")
|
||||
for symbol in module_symbol_names:
|
||||
file.write(f"\t&{symbol},\n")
|
||||
file.write("\tNULL\n")
|
||||
@@ -397,10 +397,10 @@ def generate_devicetree_h(filename: str):
|
||||
#endif
|
||||
|
||||
// Array of device tree modules terminated with DTS_MODULE_TERMINATOR
|
||||
extern struct DtsDevice dts_devices[];
|
||||
extern const struct DtsDevice dts_devices[];
|
||||
|
||||
// Array of module symbols terminated with NULL
|
||||
extern struct Module* dts_modules[];
|
||||
extern struct Module* const dts_modules[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ static struct Device bool_test_device = {
|
||||
.internal = NULL
|
||||
};
|
||||
|
||||
struct DtsDevice dts_devices[] = {
|
||||
const struct DtsDevice dts_devices[] = {
|
||||
{ &root, "test,root", DTS_DEVICE_STATUS_OKAY },
|
||||
{ &test_device, "test,generic-device", DTS_DEVICE_STATUS_OKAY },
|
||||
{ &bool_test_device, "test,bool-device", DTS_DEVICE_STATUS_OKAY },
|
||||
@@ -59,7 +59,7 @@ struct DtsDevice dts_devices[] = {
|
||||
|
||||
extern struct Module data_module;
|
||||
|
||||
struct Module* dts_modules[] = {
|
||||
struct Module* const dts_modules[] = {
|
||||
&data_module,
|
||||
NULL
|
||||
};
|
||||
|
||||
@@ -7,10 +7,10 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Array of device tree modules terminated with DTS_MODULE_TERMINATOR
|
||||
extern struct DtsDevice dts_devices[];
|
||||
extern const struct DtsDevice dts_devices[];
|
||||
|
||||
// Array of module symbols terminated with NULL
|
||||
extern struct Module* dts_modules[];
|
||||
extern struct Module* const dts_modules[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user