浏览代码

Add lldiv

Jeremy Soller 6 年之前
父节点
当前提交
89832b3ac8
共有 1 个文件被更改,包括 19 次插入5 次删除
  1. 19 5
      src/header/stdlib/mod.rs

+ 19 - 5
src/header/stdlib/mod.rs

@@ -357,16 +357,30 @@ pub extern "C" fn ldiv(numer: c_long, denom: c_long) -> ldiv_t {
     }
 }
 
-// #[no_mangle]
-pub extern "C" fn lrand48() -> c_long {
-    unimplemented!();
-}
-
 #[no_mangle]
 pub extern "C" fn llabs(i: c_longlong) -> c_longlong {
     i.abs()
 }
 
+#[repr(C)]
+pub struct lldiv_t {
+    quot: c_longlong,
+    rem: c_longlong,
+}
+
+#[no_mangle]
+pub extern "C" fn lldiv(numer: c_longlong, denom: c_longlong) -> lldiv_t {
+    lldiv_t {
+        quot: numer / denom,
+        rem: numer % denom,
+    }
+}
+
+// #[no_mangle]
+pub extern "C" fn lrand48() -> c_long {
+    unimplemented!();
+}
+
 #[no_mangle]
 pub unsafe extern "C" fn malloc(size: size_t) -> *mut c_void {
     platform::alloc(size)