Miri is failing the smalloc tests due to poorly written tests, mainly
due to the fact that raw pointers were derived from mutable refs. Fixup
the tests to use the global allocator funcitons directly.
Fix several issues in the slab allocator identified by the heap stress
tests (intermittent) and running the tests under Miri.
1. Fix Undefined Behavior. Previously, the allocator created temporary
`&mut Frame` references while raw pointers to that frame existed in the
intrusive `partial` or `free` lists. Under Miri's strict aliasing rules,
creating a unique reference to the whole struct invalidated the list
pointers.
The fix implements "split borrowing": we now maintain raw pointers to
the frame and only create mutable references to the `.state` field
when needed, ensuring the `.link` field remains valid for the
intrusive list.
2. Fix `free_list_sz` accounting. In `try_alloc`, the `free_list_sz`
counter was not being decremented when a slab was successfully popped
from the free list. This caused the allocator to believe it had free
slabs when the list was actually empty, leading to panics during
batch-free operations.
3. Increase heap stress tests. The test suite now runs the stress test
in a loop to catch state persistence bugs and ensures the allocator is
fully torn down and reset between iterations.
Fixes: #220
Rework uname to avoid hardcoded datetime and add unit tests
Restructure `uname` so that:
- there is an internal function that does the main logic and can be tested by unit tests
- Generate an env var in build.rs that is the actual build datetime timestamp
- Avoid hardcoded date in the version string
- Use the timestamp in the building of `uname` response, so the data is the actual build time
- add a simple unit test for the sysname field
- add more complex test for the version field that checks the date formatting (not exhaustively)
NOTE: The build timestamp can be used by any other function, syscall or part of the code if required.