Our great sponsors
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
The solution isn't to stop using rand(). The solution is to stop using newlib.
If you're doing your own custom memory management like this, you shouldn't even have a malloc implementation at all. newlib is too bloated for even your use case. At this point, chances are you're using a trivial subset of the C library and it'd be easy to roll your own. You can import bits and pieces from other projects (I personally sometimes copy and paste bits from PDClib for this). In such a tight embedded project, chances are you don't even have threads; why even pull in that reentrancy code?
Freestanding C code with no standard library isn't scary. If you need an example, look at what we do for m1n1:
https://github.com/AsahiLinux/m1n1/tree/main/src
One of the more experienced embedded Ada devs out there wrote this: https://github.com/simonjwright/stack_usage
I’m not sure if it would meet your requirements or not.