- Move stk_dep_t to public header
- Rename stk_set_module_dependencies_fn to stk_set_module_deps_sym
- Change default deps symbol name from stk_mod_dependencies to stk_mod_deps
- Read deps as direct exported stk_dep_t array instead of function call
- Update sentinel check to .id[0] != '\0'
- Default module version to 0.0.0 if not provided or invalid
- Remove deps_func from union in stk_module_load
- Make stk_validate_dependencies and stk_topo_sort non static
- Add extern declarations in stk.c
- Run stk_validate_dependencies after module loads in stk_init
- Validation failure is fatal; unload all modules and return error code
- Run stk_topo_sort after validation, sort failure is logged but not fatal
- Add validate_deps label in stk_poll so all load/unload paths run validation
- Add dep error codes to stk_error_string
- Consolidate handles, function pointers, metadata, and deps into single stk_mod_t
- Remove all separate metadata arrays and index mappings
- Simplify init, free, realloc, load, and unload significantly
- stk.c externs reduced to stk_modules and module_count
- Add tight-packed arrays with index mappings for name, version, and description
- Resolve optional metadata symbols at load time via platform_get_symbol
- Add setter functions for metadata symbol name overrides
- platform_mkdir now checks if directory exists before creating
- Add FILE_ATTRIBUTE_HIDDEN for dot-prefixed directories on Windows
- Create parent mods directory before temp directory
- Move module unload before copy in reload sequence to fix issue on Windows
- Force CMD shell in test makefile on Windows
Test makefile now uses cmd.exe instead of bash on Windows, fixing
syntax errors when running via build.bat.
Reverse enum so lower values = less severe, higher = more severe.
This makes the filter check (level < min_log_level) work correctly.
- DEBUG (0) - least severe, filtered by default
- INFO (1) - default minimum level
- WARN (2) - warnings and above
- ERROR (3) - most severe, always shown
Fixes incorrect filtering where ERROR/WARN were being blocked.
- Update stk_version.h: 0.0.4 → 0.1.0
- Add CHANGELOG entry for 0.1.0 release
- C89 compliance fixes
- Flags bitfield system
- Enhanced logging system
- Update README project status and API reference
- Document new logging functions and configuration
- Replace stk_initialized with stk_flags bitfield
- Add STK_FLAG_INITIALIZED (0x01) and STK_FLAG_LOGGING_ENABLED (0x02)
- Add stk_set_logging_enabled() and stk_is_logging_enabled() API
- Single byte for all boolean state and settings
Logging enabled by default, packs all flags into one byte for efficiency.
BREAKING CHANGE: Public API now uses unsigned char instead of uint8_t
- Remove stdint.h dependency (C99 feature, not C89, I am a fucking idiot)
- Replace uint8_t with unsigned char throughout codebase
- Affects stk_init() return type and internal functions
- Corrects unintended C99 dependency, restoring intended C89 compliance
When spamming file changes rapidly, inotify can report stale UNLOAD/RELOAD
events for modules that were already unloaded by previous events in the same
poll cycle. This caused is_mod_loaded() to return -1, which was then cast to
size_t (18446744073709551615) and used as an array index, causing segfaults.
Additionally, event counts were calculated before validation, causing loops to
run more iterations than valid indices were populated, reading garbage values.
Changes:
- stk.c: Check if is_mod_loaded() returns valid index (>= 0) before adding
to unload/reload lists
- stk.c: Reset and recalculate counts after populating arrays with only valid
indices to prevent loop overrun
- Skip processing events for modules that are no longer loaded
This completes the Linux stability fixes started in v0.0.2.
Fixes multiple issues causing segfaults when hot-reloading modules
on Linux, particularly when file changes are detected rapidly:
- Enable is_file_ready() check on Linux to prevent loading partially-written
shared libraries (previously only used on Windows/BSD)
- Fix event deduplication on Linux to actually remove duplicate inotify events
instead of just marking them, preventing double-free on same module
- Reorder reload operations to unload old module only after successfully
copying new version, avoiding invalid state when copy fails
Changes:
- platform.c: Remove __linux__ guards around is_file_ready() function
- platform.c: Add compaction step after deduplication to remove -1 entries
- stk.c: Move module unload to after platform_copy_file() in reload loop
These changes make Linux hot-reload as robust as Windows/BSD implementations.
- Install headers to /include/stk/ instead of /include/
- Update README examples to use #include <stk/stk.h>
- Update Windows install instructions to reflect stk/ directory structure
- Add MPL-2.0 license badge to README
- Clarify DLL can be placed in binary or lib directory on Windows
This prevents header name collisions with other libraries and follows
standard library distribution conventions (similar to SDL).
Users now include stk headers as <stk/stk.h> rather than <stk.h>.
- Add PREFIX, LIBDIR, and INCDIR variables (default: /usr/local)
- Implement install target that builds release and installs to system paths
- Implement uninstall target to cleanly remove installed files
- Support custom install locations via PREFIX variable
- Add helpful message on Windows directing users to manual installation
Both gmake.mk and bmake.mk now support standard installation workflow
on Unix-like systems (Linux, BSD, macOS). Windows users are instructed
to copy files manually as per platform conventions.
Usage:
make install # Install to /usr/local (requires root)
make PREFIX=$HOME install # Install to custom location
make uninstall # Remove installed files
- Replace undefined 'len' variable references with 'name_len'
- Add explicit null terminators after memcpy operations
- Move name_len declaration to Windows-specific scope to eliminate unused variable warning on BSD
- Standardize string copy pattern across all platforms: strlen -> clamp -> memcpy -> null terminate
- Fix increment operator placement for clarity (i++ moved outside array indexing)
- Remove duplicate name_len declaration in platform_directory_watch_check
This ensures proper bounds checking and null termination for filenames
on both Windows and BSD systems, preventing potential buffer overflows
when handling long filenames (approaching STK_PATH_MAX).
- Add OS detection for Windows vs Unix platforms
- Handle .exe extension on Windows for test program
- Fix directory creation with Windows-native commands (mkdir/copy vs mkdir -p/cp)
- Update clean target to use appropriate commands per platform
- Set PATH environment for DLL loading on Windows
- Remove broken uname detection that fails on Windows
Prevent potential format string mismatches on platforms where
size_t and unsigned long may have different sizes by explicitly
casting size_t variables to unsigned long when using %lu format
specifier in printf calls.
- Use absolute path ${.CURDIR}/test in main bmake.mk
- Replace automatic variable $< with explicit source filenames in test/bmake.mk
- Ensure proper directory navigation and source file compilation
- Fixes "undefined symbol: main" linker error on BSD systems
- Add test target to both bmake.mk and gmake.mk Makefiles
- Add test-related artifacts to .gitignore (excluding DLLs/shared libs)
- Create test directory with cross-platform Makefiles (bmake.mk, gmake.mk)
- Implement cross-platform test program with signal handling (test.c)
- Add test module source for compilation (test_mod.c)
- Set up automated test environment with mods/ directory
- Support both POSIX and Windows platforms
The test infrastructure allows running integration tests via 'make test'
and demonstrates stk library functionality with dynamic module loading.
Generated DLLs/shared libraries are excluded from version control.
- In stk_module_load: Use memcpy with explicit length check instead of strncpy
- In platform_directory_init_scan: Same fix for directory scanning
- In stk_module_realloc_memory: Replace realloc with malloc+memcpy approach
to avoid potential use-after-free issues and compiler warnings
- All changes maintain same functionality with improved safety
- Update module load and memory functions to use fixed-width uint8_t
- Implement STK_MOD_REALLOC_FAILURE for granular memory error tracking
- Clean up logging prefixes in stk_poll for consistency
- Update error string helper to support new module error codes
On Windows, module IDs were failing to load because paths were being
constructed with hardcoded forward slashes. Oops...
- Added platform.h to centralize path separator macros.
- Updated build_path in stk.c to use STK_PATH_SEP_STR instead of "/".
- Cleaned up redundant platform logic in module.c.
Add platform-specific protections against race conditions when
module files are written rapidly (compilation, copying, etc).
Linux (inotify):
- Deduplicate events within a poll cycle to prevent double-unload
- When duplicate RELOAD events occur, earlier events are skipped
and only the final event is processed
BSD (kqueue):
- Add file readiness check with flock() before processing mtime changes
- Files that aren't ready have their mtime reset, skipping the reload
All Unix platforms:
- Use atomic .tmp + rename for module copying to prevent loading
partially-written files
Writes that occur during an active reload or when files aren't
ready are skipped. A subsequent write is required to trigger
detection of those changes.
Fixes segfault caused by processing duplicate reload events
(Linux) or copying incomplete files mid-write (BSD).