-
Notifications
You must be signed in to change notification settings - Fork 68
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
Improvement Meta-list v2 #228
Comments
Do we have support for Came up in https://discourse.julialang.org/t/clang-jl-wrapper-generation-warnings-missing-parts/34093/7?u=viralbshah and https://twitter.com/DocSparse/status/1345479244466544641 |
Handing function-like macros with libclang is not easy because macros are processed by the preprocessor, there is actually no much information left in the cursors(AST). One needs to tokenize and retrieve the source code of the macro definition and then manually parse the raw string to do something meaningful. As macro definitions may contain any valid C code, to support function-like macros in a generic way is equivalent to implement a C-to-Julia source code translator. But it looks like C11's Generic selection macros have a simple fixed pattern which, I think, could be supported in Clang.jl, I'm going to submit a PR |
Another item for the list: C bitfields. Even though according to Linus Torvalds bitfields are usually a terrible idea, they're still used in the Linux kernel's structs, which I need to be able to manipulate in BPFnative.jl. Even though the layout of such structs are implementation-dependent, I thing we should try to implement support for these, using the host architecture as a hint as to the layout. We can use the |
@jpsamaroo Could you elaborate more about how to implement the necessary bit-twiddling operations? libclang can tell UPDATE:I implemented an ugly version here: but I feel like there must be a more elegant implementation. |
For a |
I am afraid the biggest issue is not bit manipulation but the internal layout. The C language does not define a standard layout for bit fields, unless explicit alignment directives (like struct S {
unsigned b1 : 30;
unsigned b2 : 4;
unsigned b3 : 30;
}; how much space does S need? We have to figure out these implementation defined behavior to ensure bit fields are handled correctly. |
That info can be queried from libclang, specifically, |
Thanks! I didn't expect it to return offset in bits instead of bytes. However, as this information is only from Clang, other compilers might have different implementation. Anyway, having them is a good starting ground. |
Clang should be ABI compatible with gcc(at least that's the goal). As this package is mainly for generating static bindings for Julia JLL packages where only mingw/gcc/clang is used in the build environment, so it's ok to make such an assumption. BTW, this is the implementation used in Clang, which may serve as a good reference for the impl of |
Well... I just give up reading gcc's implementation to check whether it's compatible with Clang's or not. |
Up-for-grabs
vararg
functions: WARNING: Skipping VarArg Function CLCursor (Clang.cindex.FunctionDecl) #146 callback to support possible vararg definitions? #17 (for Julia 1.5+)Done
__attribute__
no methodvalue(::CLPackedAttr)
#224trouble wraping glib #206Issues wrapping libLLVM #168 Minor issues when wrapping libav #81 (the ultimate solution would be to make a package like rust's libc)Long-shot Issues
va_list
? (not sure about the use-cases)The text was updated successfully, but these errors were encountered: