FIX: Move the mem* functions to laihost_mem* functions.#130
FIX: Move the mem* functions to laihost_mem* functions.#130TheDarkBomber wants to merge 2 commits intomanagarm:masterfrom
mem* functions to laihost_mem* functions.#130Conversation
These functions are highly likely to be included in operating system kernels already. By prefixing these with lai_, this prevents any conflicts and allows the kernel to be built when including both LAI headers and the header containing the kernel's `mem*` functions.
Requiring the host to implement these functions further emphasises the point made in the previous commit.
What kind of conflicts? AFAICT lai declares these functions but it does not provide definitions. |
|
if a given definition of mem* conflicts with the one in lai, it's likely the wrong definition, and also, I'm decently sure the header declaring these isn't public anyway. adding new laihost symbols for functions that are de-facto standardized by gcc requiring them seems unuseful. what problem did you observe in practice that this solves? maybe there's a better solution |
|
GCC requires these functions to be implemented in freestanding anyway,
From: https://gcc.gnu.org/onlinedocs/gcc/Standards.html#Standards The reason the distinction between these and malloc is made, is because many kernels have different and nonstandard implementations of malloc. |
Currently, the functions
memcpy,memset,memcmp, andmemmove(not necessarily in that order) are declared directly in one of LAI's header files. This can cause conflicts if the kernel has already declared these functions.To rectify this, this pull request changes those functions into functions required by the host. If the kernel has a standards-compliant implementation of these functions, they can easily integrate these into its LAI bindings by appending the following linker script:
This change will also make the behaviour of the LAI API more consistent, as other C standard functions are defined as host functions in LAI, such as
malloc,realloc, andfree; which a kernel developer would use a linker script to define the LAI bindings for.