Skip to content
Snippets Groups Projects
Commit 78e421cb authored by Jeremy Soller's avatar Jeremy Soller
Browse files

Implement some functions on Linux

parent 9fb0b77d
No related branches found
No related tags found
No related merge requests found
#include <fcntl.h>
#include <unistd.h>
int main(int argc, char **argv) {
int fd = creat("create.out", 0755);
if (fd >= 0) {
write(fd, "Hello World!\n", 14);
close(fd);
return 0;
} else {
write(2, "creat failed\n", 14);
return 1;
}
}
#include <unistd.h>
void _start(void) {
int main(int argc, char **argv) {
write(STDOUT_FILENO, "Hello World!\n", 14);
return 0;
}
......@@ -8,4 +8,4 @@ build = "build.rs"
cbindgen = { path = "../cbindgen" }
[dependencies]
common = { path = "../common" }
platform = { path = "../platform" }
......@@ -2,9 +2,9 @@
#![no_std]
extern crate common;
extern crate platform;
pub use common::*;
pub use platform::types::*;
pub const NULL: c_int = 0;
......@@ -28,7 +28,7 @@ pub const STDERR_FILENO: c_int = 2;
#[no_mangle]
pub extern "C" fn _exit(status: c_int) {
unimplemented!();
platform::exit(status)
}
#[no_mangle]
......@@ -63,7 +63,7 @@ pub extern "C" fn chown(path: *const c_char, owner: uid_t, group: gid_t) -> c_in
#[no_mangle]
pub extern "C" fn close(fildes: c_int) -> c_int {
unimplemented!();
platform::close(fildes)
}
#[no_mangle]
......@@ -448,7 +448,10 @@ pub extern "C" fn vfork() -> pid_t {
#[no_mangle]
pub extern "C" fn write(fildes: c_int, buf: *const c_void, nbyte: size_t) -> ssize_t {
unimplemented!();
use core::slice;
let buf = unsafe { slice::from_raw_parts(buf as *const u8, nbyte as usize) };
platform::write(fildes, buf)
}
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment