]> git.lizzy.rs Git - rust.git/commitdiff
rustc_llvm: Expose setting more DLL storage classes
authorAlex Crichton <alex@alexcrichton.com>
Mon, 11 May 2015 19:24:12 +0000 (12:24 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 12 May 2015 21:50:36 +0000 (14:50 -0700)
Currently only `dllexport` is used, but more integration will require using
`dllimport` as well.

src/librustc_llvm/lib.rs
src/rustllvm/RustWrapper.cpp

index 2a2aa2bf4cf93dcfc530e7e0504a4703ef050a4a..54031e4b04d25f350854e1e83aa378cfa1d5cfd7 100644 (file)
@@ -55,6 +55,7 @@
 pub use self::Visibility::*;
 pub use self::DiagnosticSeverity::*;
 pub use self::Linkage::*;
+pub use self::DLLStorageClassTypes::*;
 
 use std::ffi::CString;
 use std::cell::RefCell;
@@ -123,6 +124,15 @@ pub enum DiagnosticSeverity {
     Note,
 }
 
+
+#[repr(C)]
+#[derive(Copy, Clone)]
+pub enum DLLStorageClassTypes {
+    DefaultStorageClass = 0,
+    DLLImportStorageClass = 1,
+    DLLExportStorageClass = 2,
+}
+
 bitflags! {
     flags Attribute : u32 {
         const ZExt            = 1 << 0,
@@ -2075,7 +2085,8 @@ pub fn LLVMRustArchiveChildData(ACR: ArchiveChildRef,
     pub fn LLVMRustArchiveIteratorFree(AIR: ArchiveIteratorRef);
     pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
 
-    pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
+    pub fn LLVMRustSetDLLStorageClass(V: ValueRef,
+                                      C: DLLStorageClassTypes);
 
     pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
                                   data: *mut *const c_char) -> c_int;
@@ -2125,6 +2136,12 @@ pub fn SetLinkage(global: ValueRef, link: Linkage) {
     }
 }
 
+pub fn SetDLLStorageClass(global: ValueRef, class: DLLStorageClassTypes) {
+    unsafe {
+        LLVMRustSetDLLStorageClass(global, class);
+    }
+}
+
 pub fn SetUnnamedAddr(global: ValueRef, unnamed: bool) {
     unsafe {
         LLVMSetUnnamedAddr(global, unnamed as Bool);
index 375c5fc746c5b80843b0d03ccb7c2c9aac447264..5a2d1ec42071fd0f9812fe10abbe14011434430d 100644 (file)
@@ -837,9 +837,10 @@ LLVMRustArchiveChildData(Archive::Child *child, size_t *size) {
 }
 
 extern "C" void
-LLVMRustSetDLLExportStorageClass(LLVMValueRef Value) {
+LLVMRustSetDLLStorageClass(LLVMValueRef Value,
+                           GlobalValue::DLLStorageClassTypes Class) {
     GlobalValue *V = unwrap<GlobalValue>(Value);
-    V->setDLLStorageClass(GlobalValue::DLLExportStorageClass);
+    V->setDLLStorageClass(Class);
 }
 
 // Note that the two following functions look quite similar to the