Skip to content

Commit

Permalink
rustc_codegen_llvm: use safe references for ModuleBuffer.
Browse files Browse the repository at this point in the history
  • Loading branch information
irinagpopa committed Jul 30, 2018
1 parent b643e51 commit ab4f93c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/back/lto.rs
Expand Up @@ -527,7 +527,7 @@ impl SerializedModule {
}
}

pub struct ModuleBuffer(*mut llvm::ModuleBuffer);
pub struct ModuleBuffer(&'static mut llvm::ModuleBuffer);

unsafe impl Send for ModuleBuffer {}
unsafe impl Sync for ModuleBuffer {}
Expand All @@ -550,7 +550,7 @@ impl ModuleBuffer {

impl Drop for ModuleBuffer {
fn drop(&mut self) {
unsafe { llvm::LLVMRustModuleBufferFree(self.0); }
unsafe { llvm::LLVMRustModuleBufferFree(&mut *(self.0 as *mut _)); }
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/librustc_codegen_llvm/llvm/ffi.rs
Expand Up @@ -1563,10 +1563,10 @@ extern "C" {
pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char);
pub fn LLVMRustUnsetComdat(V: &Value);
pub fn LLVMRustSetModulePIELevel(M: &Module);
pub fn LLVMRustModuleBufferCreate(M: &Module) -> *mut ModuleBuffer;
pub fn LLVMRustModuleBufferPtr(p: *const ModuleBuffer) -> *const u8;
pub fn LLVMRustModuleBufferLen(p: *const ModuleBuffer) -> usize;
pub fn LLVMRustModuleBufferFree(p: *mut ModuleBuffer);
pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
pub fn LLVMRustModuleCost(M: &Module) -> u64;

pub fn LLVMRustThinLTOAvailable() -> bool;
Expand Down

0 comments on commit ab4f93c

Please sign in to comment.