Skip to content
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

Fix the representation of C void pointers in LLVM IR #11539

Merged
merged 1 commit into from
Jan 14, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/libstd/libc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,19 @@ pub mod types {
This type is only useful as a pointer target. Do not use it as a
return type for FFI functions which have the `void` return type in
C. Use the unit type `()` or omit the return type instead.

For LLVM to recognize the void pointer type and by extension
functions like malloc(), we need to have it represented as i8* in
LLVM bitcode. The enum used here ensures this and prevents misuse
of the "raw" type by only having private variants.. We need two
variants, because the compiler complains about the repr attribute
otherwise.
*/
pub enum c_void {}
#[repr(u8)]
pub enum c_void {
priv variant1,
priv variant2
}
pub enum FILE {}
pub enum fpos_t {}
}
Expand Down