Bare metal library
Posted: Sun Apr 19, 2020 4:42 pm
Currently a lot of us bring in some form of c library in order obtain simple functions like memset or memcpy. Bringing in the entire C library is totally unnecessary for these kind of functions which in turn might use some form of compiler hook or library in order to use optimized functions. With the compiler there are specialized functions but these often have funky names which makes it non portable.
The functions I really need for the bare metal stuff are:
memcpy
memset
memcmp
memsearchbyte - search for a given byte, strlen could be implemented easily using this
memsearchword - search for a given word
memsearcharray- search memory for a given byte array, can implemented using memcmp
With these types of functions you can come pretty far. You are welcome to mention any other function you think should be added.
LLVM already have some of this as intrinsics but it would be nice to have a "standard bare metal library" that gives us this basic functionality. Most of the C library operates on its stupid null terminated strings, something that kernels should avoid anyway. Rust which is more modern has done this more or less with its core library. Of course you could write all these things yourself but you don't really want to write an optimized function for every CPU architecture each with its own special tricks to make it optimized.
Do we have any such library?
The functions I really need for the bare metal stuff are:
memcpy
memset
memcmp
memsearchbyte - search for a given byte, strlen could be implemented easily using this
memsearchword - search for a given word
memsearcharray- search memory for a given byte array, can implemented using memcmp
With these types of functions you can come pretty far. You are welcome to mention any other function you think should be added.
LLVM already have some of this as intrinsics but it would be nice to have a "standard bare metal library" that gives us this basic functionality. Most of the C library operates on its stupid null terminated strings, something that kernels should avoid anyway. Rust which is more modern has done this more or less with its core library. Of course you could write all these things yourself but you don't really want to write an optimized function for every CPU architecture each with its own special tricks to make it optimized.
Do we have any such library?