unsupported
),
};
- ecx.machine.env_vars.map.insert(OsString::from(name), var_ptr);
+ ecx.machine.env_vars.map.insert(name, var_ptr);
}
}
}
let target_os = &this.tcx.sess.target.os;
assert!(
target_os == "linux" || target_os == "macos",
- "`getcwd` is only available for the UNIX target family"
+ "`chdir` is only available for the UNIX target family"
);
let path = this.read_path_from_c_str(this.read_pointer(path_op)?)?;
Ok(())
}
+
+ fn getpid(&mut self) -> InterpResult<'tcx, i32> {
+ let this = self.eval_context_mut();
+ let target_os = &this.tcx.sess.target.os;
+ assert!(
+ target_os == "linux" || target_os == "macos",
+ "`getpid` is only available for the UNIX target family"
+ );
+
+ this.check_no_isolation("`getpid`")?;
+
+ // The reason we need to do this wacky of a conversion is because
+ // `libc::getpid` returns an i32, however, `std::process::id()` return an u32.
+ // So we un-do the conversion that stdlib does and turn it back into an i32.
+
+ Ok(std::process::id() as i32)
+ }
+
+ #[allow(non_snake_case)]
+ fn GetCurrentProcessId(&mut self) -> InterpResult<'tcx, u32> {
+ let this = self.eval_context_mut();
+ this.assert_target_os("windows", "GetCurrentProcessId");
+
+ this.check_no_isolation("`GetCurrentProcessId`")?;
+
+ Ok(std::process::id())
+ }
}