-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[libc] Allow each function can have extra attributes by defining LLVM_LIBC_FUNCTION_ATTR_func macro. #116160
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
[libc] Allow each function can have extra attributes by defining LLVM_LIBC_FUNCTION_ATTR_func macro. #116160
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,9 +21,24 @@ | |||||
#define LLVM_LIBC_FUNCTION_ATTR | ||||||
#endif | ||||||
|
||||||
// Allow each function `func` can have extra attributes specified by defining: | ||||||
// `LLVM_LIBC_FUNCTION_ATTR_func` macro, which should always start with | ||||||
// "LLVM_LIBC_EMPTY," | ||||||
// | ||||||
// For example: | ||||||
// #define LLVM_LIBC_FUNCTION_ATTR_memcpy LLVM_LIBC_EMPTY, __attribute__((weak)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Let's encourage the usage of the C++11/C23 style attribute syntax, rather than the GNU C extension syntax. Though, don't we expect this to be used by the command line cmake invocation? Perhaps an example of that in this comment, or moving our bazel files over to use that would be welcome additions to this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps worth documenting any new command line options in docs/dev/implementation_standard.rst.
lntue marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
#define LLVM_LIBC_EMPTY | ||||||
|
||||||
#define GET_SECOND(first, second, ...) second | ||||||
#define EXPAND_THEN_SECOND(name) GET_SECOND(name, LLVM_LIBC_EMPTY, ) | ||||||
lntue marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
#define LLVM_LIBC_ATTR(name) EXPAND_THEN_SECOND(LLVM_LIBC_FUNCTION_ATTR_##name) | ||||||
#define EXPAND_ATTR(name) LLVM_LIBC_ATTR(name) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think you need There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're right, |
||||||
|
||||||
// MacOS needs to be excluded because it does not support aliasing. | ||||||
#if defined(LIBC_COPT_PUBLIC_PACKAGING) && (!defined(__APPLE__)) | ||||||
#define LLVM_LIBC_FUNCTION_IMPL(type, name, arglist) \ | ||||||
EXPAND_ATTR(name) \ | ||||||
LLVM_LIBC_FUNCTION_ATTR decltype(LIBC_NAMESPACE::name) \ | ||||||
__##name##_impl__ __asm__(#name); \ | ||||||
decltype(LIBC_NAMESPACE::name) name [[gnu::alias(#name)]]; \ | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.