Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ebeafd4bb | |||
| 03cce766cd | |||
| 5b252d2b4e | |||
| 08c846d641 | |||
| 6ca46fe79f | |||
| ba3a9dd163 | |||
| a28c4818ab | |||
| 49ecd8fde5 |
+26
-1
@@ -7,6 +7,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [1.0.0-pre.7] - 2026-03-07
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- `stk_module_load()`: added missing dependency failure logging when a module is deferred to the pending queue.
|
||||||
|
|
||||||
|
## [1.0.0-pre.6] - 2026-03-07
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- `stk_poll()`: replaced per-module `stk_pending_add()` calls inside the load holes and `append_modules` loops with batch collection followed by a single `stk_pending_add_batch()` call after both loops complete.
|
||||||
|
|
||||||
|
## [1.0.0-pre.5] - 2026-03-07
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- `stk_init()`: replaced per-module `stk_pending_add()` calls inside the deferred module loop with batch collection followed by a single `stk_pending_add_batch()` call after the loop.
|
||||||
|
|
||||||
|
## [1.0.0-pre.4] - 2026-03-07
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- `stk_pending_retry()`: replaced per-module `realloc` at `attempt_load` with a single bulk allocation upfront (`module_count + stk_pending_count`) before the retry loop.
|
||||||
|
- `stk_poll()`: replaced per-module `stk_pending_add()` calls inside the unload and cascade loops with batch collection followed by a single `stk_pending_add_batch()` call after each loop.
|
||||||
|
|
||||||
## [1.0.0-pre.3] - 2026-03-07
|
## [1.0.0-pre.3] - 2026-03-07
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
@@ -162,7 +183,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Dependency management and versioning not yet implemented
|
- Dependency management and versioning not yet implemented
|
||||||
- API is unstable and subject to change in future releases
|
- API is unstable and subject to change in future releases
|
||||||
|
|
||||||
[Unreleased]: https://github.com/anth64/stk/compare/v1.0.0-pre.3...HEAD
|
[Unreleased]: https://github.com/anth64/stk/compare/v1.0.0-pre.7...HEAD
|
||||||
|
[1.0.0-pre.7]: https://github.com/anth64/stk/compare/v1.0.0-pre.6...v1.0.0-pre.7
|
||||||
|
[1.0.0-pre.6]: https://github.com/anth64/stk/compare/v1.0.0-pre.5...v1.0.0-pre.6
|
||||||
|
[1.0.0-pre.5]: https://github.com/anth64/stk/compare/v1.0.0-pre.4...v1.0.0-pre.5
|
||||||
|
[1.0.0-pre.4]: https://github.com/anth64/stk/compare/v1.0.0-pre.3...v1.0.0-pre.4
|
||||||
[1.0.0-pre.3]: https://github.com/anth64/stk/compare/v1.0.0-pre.2...v1.0.0-pre.3
|
[1.0.0-pre.3]: https://github.com/anth64/stk/compare/v1.0.0-pre.2...v1.0.0-pre.3
|
||||||
[1.0.0-pre.2]: https://github.com/anth64/stk/compare/v1.0.0-pre.1...v1.0.0-pre.2
|
[1.0.0-pre.2]: https://github.com/anth64/stk/compare/v1.0.0-pre.1...v1.0.0-pre.2
|
||||||
[1.0.0-pre.1]: https://github.com/anth64/stk/compare/v0.1.3...v1.0.0-pre.1
|
[1.0.0-pre.1]: https://github.com/anth64/stk/compare/v0.1.3...v1.0.0-pre.1
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ stk_init();
|
|||||||
|
|
||||||
## Project Status
|
## Project Status
|
||||||
|
|
||||||
**Current Version:** 1.0.0-pre.3
|
**Current Version:** 1.0.0-pre.7
|
||||||
|
|
||||||
### What Works
|
### What Works
|
||||||
- Cross-platform module loading and hot-reloading
|
- Cross-platform module loading and hot-reloading
|
||||||
|
|||||||
+4
-3
@@ -563,6 +563,7 @@ unsigned char stk_module_load(const char *path, int index)
|
|||||||
|
|
||||||
result = stk_validate_dependencies_single(index);
|
result = stk_validate_dependencies_single(index);
|
||||||
if (result != STK_MOD_INIT_SUCCESS) {
|
if (result != STK_MOD_INIT_SUCCESS) {
|
||||||
|
stk_log_dependency_failures(index, "Deferring");
|
||||||
stk_module_discard(index);
|
stk_module_discard(index);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -1026,6 +1027,9 @@ size_t stk_pending_retry(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stk_module_realloc_memory(module_count + stk_pending_count) != 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
for (i = 0; i < stk_pending_count; i++) {
|
for (i = 0; i < stk_pending_count; i++) {
|
||||||
extract_module_id(stk_pending[i], pending_id);
|
extract_module_id(stk_pending[i], pending_id);
|
||||||
if (is_mod_loaded(pending_id) >= 0) {
|
if (is_mod_loaded(pending_id) >= 0) {
|
||||||
@@ -1073,9 +1077,6 @@ size_t stk_pending_retry(void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
attempt_load:
|
attempt_load:
|
||||||
if (stk_module_realloc_memory(module_count + 1) != 0)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
result = stk_module_load(stk_pending[i], module_count);
|
result = stk_module_load(stk_pending[i], module_count);
|
||||||
if (result != STK_MOD_INIT_SUCCESS)
|
if (result != STK_MOD_INIT_SUCCESS)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -136,10 +136,11 @@ unsigned char stk_init(void)
|
|||||||
size_t index, test_count;
|
size_t index, test_count;
|
||||||
char full_path[STK_PATH_MAX_OS];
|
char full_path[STK_PATH_MAX_OS];
|
||||||
char tmp_path[STK_PATH_MAX_OS];
|
char tmp_path[STK_PATH_MAX_OS];
|
||||||
char mod_tmp_path[STK_PATH_MAX_OS];
|
|
||||||
int load_result;
|
int load_result;
|
||||||
unsigned char dep_result;
|
unsigned char dep_result;
|
||||||
size_t *order = NULL;
|
size_t *order = NULL;
|
||||||
|
char (*init_batch)[STK_PATH_MAX_OS] = NULL;
|
||||||
|
size_t init_batch_count = 0;
|
||||||
|
|
||||||
platform_mkdir(stk_mod_dir);
|
platform_mkdir(stk_mod_dir);
|
||||||
build_path(stk_tmp_dir, sizeof(stk_tmp_dir), stk_mod_dir, stk_tmp_name);
|
build_path(stk_tmp_dir, sizeof(stk_tmp_dir), stk_mod_dir, stk_tmp_name);
|
||||||
@@ -206,17 +207,25 @@ unsigned char stk_init(void)
|
|||||||
stk_error_string(dep_result));
|
stk_error_string(dep_result));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_batch = malloc(module_count * sizeof(*init_batch));
|
||||||
|
|
||||||
for (j = 0; j < module_count; j++) {
|
for (j = 0; j < module_count; j++) {
|
||||||
index = order ? order[j] : j;
|
index = order ? order[j] : j;
|
||||||
dep_result = stk_validate_dependencies_single(index);
|
dep_result = stk_validate_dependencies_single(index);
|
||||||
if (dep_result != STK_MOD_INIT_SUCCESS) {
|
if (dep_result != STK_MOD_INIT_SUCCESS) {
|
||||||
stk_log_dependency_failures(index, "Deferring");
|
stk_log_dependency_failures(index, "Deferring");
|
||||||
build_path(mod_tmp_path, sizeof(mod_tmp_path),
|
if (init_batch) {
|
||||||
|
build_path(init_batch[init_batch_count],
|
||||||
|
sizeof(init_batch[init_batch_count]),
|
||||||
stk_tmp_dir, stk_modules[index].id);
|
stk_tmp_dir, stk_modules[index].id);
|
||||||
strncat(mod_tmp_path, STK_MODULE_EXT,
|
strncat(
|
||||||
sizeof(mod_tmp_path) - strlen(mod_tmp_path) -
|
init_batch[init_batch_count],
|
||||||
|
STK_MODULE_EXT,
|
||||||
|
sizeof(init_batch[init_batch_count]) -
|
||||||
|
strlen(init_batch[init_batch_count]) -
|
||||||
1);
|
1);
|
||||||
stk_pending_add(mod_tmp_path);
|
init_batch_count++;
|
||||||
|
}
|
||||||
stk_module_discard(index);
|
stk_module_discard(index);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -227,6 +236,14 @@ unsigned char stk_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (init_batch_count > 0)
|
||||||
|
stk_pending_add_batch(
|
||||||
|
(const char (*)[STK_PATH_MAX_OS])init_batch,
|
||||||
|
init_batch_count);
|
||||||
|
|
||||||
|
free(init_batch);
|
||||||
|
init_batch = NULL;
|
||||||
|
|
||||||
if (order) {
|
if (order) {
|
||||||
free(order);
|
free(order);
|
||||||
order = NULL;
|
order = NULL;
|
||||||
@@ -303,15 +320,19 @@ size_t stk_poll(void)
|
|||||||
size_t expanded_count;
|
size_t expanded_count;
|
||||||
size_t index, oi;
|
size_t index, oi;
|
||||||
int is_orig;
|
int is_orig;
|
||||||
char dep_tmp_path[STK_PATH_MAX_OS];
|
|
||||||
size_t write;
|
size_t write;
|
||||||
size_t li;
|
size_t li;
|
||||||
int fi;
|
int fi;
|
||||||
int file_index, mod_index, target_index;
|
int file_index, mod_index, target_index;
|
||||||
size_t cascade_indices[STK_PATH_MAX];
|
size_t cascade_indices[STK_PATH_MAX];
|
||||||
size_t cascade_count;
|
size_t cascade_count;
|
||||||
char cascade_tmp_path[STK_PATH_MAX_OS];
|
|
||||||
size_t j, k, cascade_write;
|
size_t j, k, cascade_write;
|
||||||
|
char (*dep_batch)[STK_PATH_MAX_OS] = NULL;
|
||||||
|
size_t dep_batch_count = 0;
|
||||||
|
char (*cascade_batch)[STK_PATH_MAX_OS] = NULL;
|
||||||
|
size_t cascade_batch_count = 0;
|
||||||
|
char (*load_batch)[STK_PATH_MAX_OS] = NULL;
|
||||||
|
size_t load_batch_count = 0;
|
||||||
|
|
||||||
if (module_count > 0) {
|
if (module_count > 0) {
|
||||||
module_ids = malloc(module_count * sizeof(*module_ids));
|
module_ids = malloc(module_count * sizeof(*module_ids));
|
||||||
@@ -403,6 +424,9 @@ begin_operations:
|
|||||||
stk_collect_dependents(unload_order, &expanded_count);
|
stk_collect_dependents(unload_order, &expanded_count);
|
||||||
stk_sort_unload_order(unload_order, expanded_count);
|
stk_sort_unload_order(unload_order, expanded_count);
|
||||||
|
|
||||||
|
dep_batch = malloc(expanded_count * sizeof(*dep_batch));
|
||||||
|
dep_batch_count = 0;
|
||||||
|
|
||||||
for (i = 0; i < expanded_count; i++) {
|
for (i = 0; i < expanded_count; i++) {
|
||||||
index = unload_order[i];
|
index = unload_order[i];
|
||||||
|
|
||||||
@@ -417,17 +441,27 @@ begin_operations:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!is_orig) {
|
if (!is_orig && dep_batch) {
|
||||||
build_path(dep_tmp_path, sizeof(dep_tmp_path),
|
build_path(dep_batch[dep_batch_count],
|
||||||
|
sizeof(dep_batch[dep_batch_count]),
|
||||||
stk_tmp_dir, stk_modules[index].id);
|
stk_tmp_dir, stk_modules[index].id);
|
||||||
strncat(dep_tmp_path, STK_MODULE_EXT,
|
strncat(
|
||||||
sizeof(dep_tmp_path) -
|
dep_batch[dep_batch_count], STK_MODULE_EXT,
|
||||||
strlen(dep_tmp_path) - 1);
|
sizeof(dep_batch[dep_batch_count]) -
|
||||||
stk_pending_add(dep_tmp_path);
|
strlen(dep_batch[dep_batch_count]) - 1);
|
||||||
|
dep_batch_count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
stk_module_unload(index);
|
stk_module_unload(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dep_batch_count > 0)
|
||||||
|
stk_pending_add_batch(
|
||||||
|
(const char (*)[STK_PATH_MAX_OS])dep_batch,
|
||||||
|
dep_batch_count);
|
||||||
|
|
||||||
|
free(dep_batch);
|
||||||
|
dep_batch = NULL;
|
||||||
free(unload_order);
|
free(unload_order);
|
||||||
unload_order = NULL;
|
unload_order = NULL;
|
||||||
} else {
|
} else {
|
||||||
@@ -494,6 +528,9 @@ begin_operations:
|
|||||||
stk_sort_load_order(loaded_mod_indices, load_count, file_list,
|
stk_sort_load_order(loaded_mod_indices, load_count, file_list,
|
||||||
stk_tmp_dir);
|
stk_tmp_dir);
|
||||||
|
|
||||||
|
load_batch = malloc(load_count * sizeof(*load_batch));
|
||||||
|
load_batch_count = 0;
|
||||||
|
|
||||||
for (i = 0; i < holes_to_fill; ++i) {
|
for (i = 0; i < holes_to_fill; ++i) {
|
||||||
target_index = unloaded_mod_indices[i];
|
target_index = unloaded_mod_indices[i];
|
||||||
file_index = loaded_mod_indices[i];
|
file_index = loaded_mod_indices[i];
|
||||||
@@ -504,7 +541,9 @@ begin_operations:
|
|||||||
load_result = stk_module_load(tmp_path, target_index);
|
load_result = stk_module_load(tmp_path, target_index);
|
||||||
if (load_result == STK_MOD_DEP_NOT_FOUND_ERROR ||
|
if (load_result == STK_MOD_DEP_NOT_FOUND_ERROR ||
|
||||||
load_result == STK_MOD_DEP_VERSION_MISMATCH_ERROR) {
|
load_result == STK_MOD_DEP_VERSION_MISMATCH_ERROR) {
|
||||||
stk_pending_add(tmp_path);
|
if (load_batch)
|
||||||
|
memcpy(load_batch[load_batch_count++], tmp_path,
|
||||||
|
STK_PATH_MAX_OS);
|
||||||
} else if (load_result != STK_MOD_INIT_SUCCESS) {
|
} else if (load_result != STK_MOD_INIT_SUCCESS) {
|
||||||
stk_log(STK_LOG_ERROR, "Failed to load module %s: %s",
|
stk_log(STK_LOG_ERROR, "Failed to load module %s: %s",
|
||||||
file_list[file_index],
|
file_list[file_index],
|
||||||
@@ -517,7 +556,7 @@ begin_operations:
|
|||||||
if (load_count > unload_count)
|
if (load_count > unload_count)
|
||||||
goto append_modules;
|
goto append_modules;
|
||||||
|
|
||||||
goto validate_deps;
|
goto finish_loads;
|
||||||
|
|
||||||
append_modules:
|
append_modules:
|
||||||
for (; i < load_count; ++i) {
|
for (; i < load_count; ++i) {
|
||||||
@@ -530,7 +569,9 @@ append_modules:
|
|||||||
successful_appends);
|
successful_appends);
|
||||||
if (load_result == STK_MOD_DEP_NOT_FOUND_ERROR ||
|
if (load_result == STK_MOD_DEP_NOT_FOUND_ERROR ||
|
||||||
load_result == STK_MOD_DEP_VERSION_MISMATCH_ERROR) {
|
load_result == STK_MOD_DEP_VERSION_MISMATCH_ERROR) {
|
||||||
stk_pending_add(tmp_path);
|
if (load_batch)
|
||||||
|
memcpy(load_batch[load_batch_count++], tmp_path,
|
||||||
|
STK_PATH_MAX_OS);
|
||||||
} else if (load_result != STK_MOD_INIT_SUCCESS) {
|
} else if (load_result != STK_MOD_INIT_SUCCESS) {
|
||||||
stk_log(STK_LOG_ERROR, "Failed to load module %s: %s",
|
stk_log(STK_LOG_ERROR, "Failed to load module %s: %s",
|
||||||
file_list[file_index],
|
file_list[file_index],
|
||||||
@@ -545,6 +586,15 @@ append_modules:
|
|||||||
if (successful_appends < (load_count - holes_to_fill))
|
if (successful_appends < (load_count - holes_to_fill))
|
||||||
stk_module_realloc_memory(module_count);
|
stk_module_realloc_memory(module_count);
|
||||||
|
|
||||||
|
finish_loads:
|
||||||
|
if (load_batch_count > 0)
|
||||||
|
stk_pending_add_batch(
|
||||||
|
(const char (*)[STK_PATH_MAX_OS])load_batch,
|
||||||
|
load_batch_count);
|
||||||
|
|
||||||
|
free(load_batch);
|
||||||
|
load_batch = NULL;
|
||||||
|
|
||||||
goto validate_deps;
|
goto validate_deps;
|
||||||
|
|
||||||
validate_deps:
|
validate_deps:
|
||||||
@@ -569,18 +619,37 @@ validate_deps:
|
|||||||
if (cascade_count == 0)
|
if (cascade_count == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
cascade_batch = malloc(cascade_count * sizeof(*cascade_batch));
|
||||||
|
cascade_batch_count = 0;
|
||||||
|
|
||||||
for (j = 0; j < cascade_count; j++) {
|
for (j = 0; j < cascade_count; j++) {
|
||||||
index = cascade_indices[j];
|
index = cascade_indices[j];
|
||||||
stk_log_dependency_failures(index, "Unloading");
|
stk_log_dependency_failures(index, "Unloading");
|
||||||
build_path(cascade_tmp_path, sizeof(cascade_tmp_path),
|
if (cascade_batch) {
|
||||||
|
build_path(
|
||||||
|
cascade_batch[cascade_batch_count],
|
||||||
|
sizeof(cascade_batch[cascade_batch_count]),
|
||||||
stk_tmp_dir, stk_modules[index].id);
|
stk_tmp_dir, stk_modules[index].id);
|
||||||
strncat(cascade_tmp_path, STK_MODULE_EXT,
|
strncat(
|
||||||
sizeof(cascade_tmp_path) -
|
cascade_batch[cascade_batch_count],
|
||||||
strlen(cascade_tmp_path) - 1);
|
STK_MODULE_EXT,
|
||||||
stk_pending_add(cascade_tmp_path);
|
sizeof(cascade_batch[cascade_batch_count]) -
|
||||||
|
strlen(cascade_batch
|
||||||
|
[cascade_batch_count]) -
|
||||||
|
1);
|
||||||
|
cascade_batch_count++;
|
||||||
|
}
|
||||||
stk_module_unload(index);
|
stk_module_unload(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cascade_batch_count > 0)
|
||||||
|
stk_pending_add_batch(
|
||||||
|
(const char (*)[STK_PATH_MAX_OS])cascade_batch,
|
||||||
|
cascade_batch_count);
|
||||||
|
|
||||||
|
free(cascade_batch);
|
||||||
|
cascade_batch = NULL;
|
||||||
|
|
||||||
cascade_write = 0;
|
cascade_write = 0;
|
||||||
for (j = 0; j < module_count; j++) {
|
for (j = 0; j < module_count; j++) {
|
||||||
if (stk_modules[j].handle != NULL) {
|
if (stk_modules[j].handle != NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user