]> git.lizzy.rs Git - rust.git/blobdiff - src/shims/foreign_items/posix/linux.rs
avoid using unchecked casts or arithmetic
[rust.git] / src / shims / foreign_items / posix / linux.rs
index 4d3e1798ce14856ab4f18e352129ac279a1dea3e..023fee4ca7b1eef68bc37bed701bb41680e52751 100644 (file)
@@ -27,6 +27,20 @@ fn emulate_foreign_item_by_name(
                 this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;
             }
 
+            // The only reason this is not in the `posix` module is because the `macos` item has a
+            // different name.
+            "opendir" => {
+                let result = this.opendir(args[0])?;
+                this.write_scalar(result, dest)?;
+            }
+
+            // The `macos` module has a parallel foreign item, `readdir_r`, which uses a different
+            // struct layout.
+            "readdir64_r" => {
+                let result = this.linux_readdir64_r(args[0], args[1], args[2])?;
+                this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;
+            }
+
             // Time related shims
 
             // This is a POSIX function but it has only been tested on linux.
@@ -100,7 +114,7 @@ fn getrandom<'tcx>(
     // neither of which have any effect on our current PRNG.
     let _flags = this.read_scalar(args[2])?.to_i32()?;
 
-    this.gen_random(ptr, len as usize)?;
+    this.gen_random(ptr, len)?;
     this.write_scalar(Scalar::from_uint(len, dest.layout.size), dest)?;
     Ok(())
 }