-
Notifications
You must be signed in to change notification settings - Fork 804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add an alternative way to override LFS_MALLOC etc #1004
base: devel
Are you sure you want to change the base?
Conversation
Tests passed ✓, Code: 17064 B (+0.0%), Stack: 1440 B (+0.0%), Structs: 812 B (+0.0%)
|
Hi @yamt, thanks for creating a PR, and sorry about such a late response. This is a clever naming solution, I was stuck and couldn't think of a name since LFS_CONFIG was taken. These should have probably been named LFS_CONFIG/LFS_UTIL but that's with hindsight. Will bring this in on the next minor/patch release (is it unreasonable to slip this in on a patch release?) |
the ci failure seems unrelated to this PR. |
|
With the existing method, (-DLFS_MALLOC=my_malloc) users often had to use compiler options like -include, which was not so portable. This change introduces another way to provide partial overrides of lfs_util.h using a user-provided header.
8b951c6
to
4a845be
Compare
Tests passed ✓, Code: 17064 B, Stack: 1440 B, Structs: 812 B
|
👀 |
Doesn't this effectively make A better implementation would be to have |
I think it's a bit too late to be bikeshedding this. The only reason this isn't already merged is delays on my end in making a minor release (sorry! in hindsight the upcoming minor release should have been split into multiple releases). Though discussion can influence future API changes.
This is an interesting and clever workaround, but thinking from the perspective of a new user, you're asking them to do 2 things (define LFS_CONFIG and (un)define LFS_SKIP_UTILS) instead of 1 (define LFS_DEFINES). I suspect LFS_DEFINES will be more common for users who aren't doing a full OS integration, so having it require more steps isn't the greatest. I'm not against dropping LFS_CONFIG on a later major API change if LFS_DEFINES (renamed -> LFS_CONFIG?) can fully replace it.
This gets a bit tricky for things like the type definitions. Though maybe we require all user-provided types to also be macros? #ifdef LFS_SIZE_T
typedef LFS_SIZE_T lfs_size_t
#else
#include <stdint.h>
typedef uint32_t lfs_size_t
#endif |
With the existing method, (-DLFS_MALLOC=my_malloc) users often had to use compiler options like -include, which was not so portable.
This change introduces another way to provide partial overrides of lfs_util.h using a user-provided header.