-
Notifications
You must be signed in to change notification settings - Fork 152
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Avoid macro redefinitions and function name collisions between sources #445
Conversation
libbf.c
Outdated
@@ -179,10 +179,6 @@ static inline __maybe_unused limb_t shld(limb_t a1, limb_t a0, long shift) | |||
return a1; | |||
} | |||
|
|||
#define malloc(s) malloc_is_forbidden(s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thsi ones are here to prevent accidental allocations, they need to exist. Perhaps we could skip them with some define @chqrlie ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the easiest way to maintain current behaviour would be to just #undef
them at the end of the respective source file, so that the (intentional) malloc
calls in subsequent sources aren't affected in a jumbo build.
How does that sound?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
Great! Updated the changes, safe for re-review when you've got a minute
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah hold on, was just testing with cmake's -DCMAKE_UNITY_BUILD=ON
and there are a few more collisions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That should be all for now. There are a couple of places where CMakeLists
needs to be changed when using -DCMAKE_UNITY_BUILD=ON
with -DBUILD_QJS_LIBC=ON
but I'll make a separate PR for that
Thanks! |
When experimenting with a jumbo build for the quickjs sources, I found a few cases of functions/macros with the same name in multiple sources.
This PR simply renames the offending functions and removes unused macros, but it could also be resolved by adding them to the public API for a given header