Ver código fonte

Add dlfcn, fixes for glib and gstreamer

Jeremy Soller 6 anos atrás
pai
commit
46020f466f

+ 7 - 0
src/header/dlfcn/cbindgen.toml

@@ -0,0 +1,7 @@
+sys_includes = []
+include_guard = "_DLFCN_H"
+language = "C"
+style = "Tag"
+
+[enum]
+prefix_with_name = true

+ 34 - 0
src/header/dlfcn/mod.rs

@@ -0,0 +1,34 @@
+//! dlfcn implementation for Redox, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/dlfcn.h.html
+
+use core::{ptr, str};
+
+use c_str::CStr;
+use platform::types::*;
+
+pub const RTLD_LAZY: c_int = 0x0001;
+pub const RTLD_NOW: c_int = 0x0002;
+pub const RTLD_GLOBAL: c_int = 0x0100;
+pub const RTLD_LOCAL: c_int = 0x0000;
+
+#[no_mangle]
+pub unsafe extern "C" fn dlopen(filename: *const c_char, flags: c_int) -> *mut c_void {
+    let filename_cstr = CStr::from_ptr(filename);
+    let filename_str = str::from_utf8_unchecked(filename_cstr.to_bytes());
+    eprintln!("dlopen({}, {:#>04X})", filename_str, flags);
+    ptr::null_mut()
+}
+
+#[no_mangle]
+pub extern "C" fn dlsym(handle: *mut c_void, symbol: *const c_char) -> *mut c_void {
+    ptr::null_mut()
+}
+
+#[no_mangle]
+pub extern "C" fn dlclose(handle: *mut c_void) -> c_int {
+    0
+}
+
+#[no_mangle]
+pub extern "C" fn dlerror() -> *mut c_char {
+    ptr::null_mut()
+}

+ 1 - 0
src/header/mod.rs

@@ -3,6 +3,7 @@ pub mod arpa_inet;
 pub mod assert;
 pub mod ctype;
 pub mod dirent;
+pub mod dlfcn;
 pub mod errno;
 pub mod fcntl;
 pub mod _fenv;

+ 2 - 0
src/header/netinet_in/mod.rs

@@ -64,10 +64,12 @@ pub const INADDR_ALLHOSTS_GROUP: u32 = 0xE000_0001;
 pub const INADDR_ALLRTRS_GROUP: u32 = 0xE000_0002;
 pub const INADDR_MAX_LOCAL_GROUP: u32 = 0xE000_00FF;
 
+#[no_mangle]
 pub static in6addr_any: in6_addr = in6_addr {
     s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
 };
 
+#[no_mangle]
 pub static in6addr_loopback: in6_addr = in6_addr {
     s6_addr: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]
 };

+ 4 - 4
src/header/unistd/mod.rs

@@ -590,11 +590,11 @@ pub extern "C" fn ttyname_r(fildes: c_int, name: *mut c_char, namesize: size_t)
 }
 
 #[no_mangle]
-pub extern "C" fn ualarm(value: useconds_t, interval: useconds_t) -> useconds_t {
+pub extern "C" fn ualarm(usecs: useconds_t, interval: useconds_t) -> useconds_t {
     let mut timer = sys_time::itimerval {
         it_value: sys_time::timeval {
             tv_sec: 0,
-            tv_usec: value as suseconds_t,
+            tv_usec: usecs as suseconds_t,
         },
         it_interval: sys_time::timeval {
             tv_sec: 0,
@@ -602,7 +602,7 @@ pub extern "C" fn ualarm(value: useconds_t, interval: useconds_t) -> useconds_t
         },
     };
     let errno_backup = unsafe { platform::errno };
-    let usecs = if sys_time::setitimer(sys_time::ITIMER_REAL, &timer, &mut timer) < 0 {
+    let ret = if sys_time::setitimer(sys_time::ITIMER_REAL, &timer, &mut timer) < 0 {
         0
     } else {
         timer.it_value.tv_sec as useconds_t * 1_000_000 + timer.it_value.tv_usec as useconds_t
@@ -611,7 +611,7 @@ pub extern "C" fn ualarm(value: useconds_t, interval: useconds_t) -> useconds_t
         platform::errno = errno_backup;
     }
 
-    usecs
+    ret
 }
 
 #[no_mangle]