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

Merge branch 'master' into 'master'

Install openlibm from Makefile

See merge request !138
parents 8fd77a4b 829bc64a
No related branches found
No related tags found
1 merge request!138Install openlibm from Makefile
......@@ -36,6 +36,8 @@ install: all
mkdir -pv "$(DESTDIR)/include"
cp -rv "include"/* "$(DESTDIR)/include"
cp -rv "target/include"/* "$(DESTDIR)/include"
cp -rv "target/openlibm/include"/* "$(DESTDIR)/include"
cp -rv "target/openlibm/src"/*.h "$(DESTDIR)/include"
cp -v "$(BUILD)/debug/libc.a" "$(DESTDIR)/lib"
cp -v "$(BUILD)/debug/crt0.o" "$(DESTDIR)/lib"
cp -v "$(BUILD)/openlibm/libopenlibm.a" "$(DESTDIR)/lib/libm.a"
......
use core::cell::UnsafeCell;
use core::sync::atomic::AtomicBool;
use core::ptr;
use super::{constants, internal, BUFSIZ, FILE, UNGET};
struct GlobalFile(UnsafeCell<FILE>);
impl GlobalFile {
const fn new(file: FILE) -> Self {
GlobalFile(UnsafeCell::new(file))
}
fn get(&self) -> *mut FILE {
self.0.get()
}
}
// statics need to be Sync
unsafe impl Sync for GlobalFile {}
#[allow(non_upper_case_globals)]
static mut default_stdin_buf: [u8; BUFSIZ as usize + UNGET] = [0; BUFSIZ as usize + UNGET];
#[allow(non_upper_case_globals)]
static mut default_stdin: GlobalFile = GlobalFile::new(FILE {
static mut default_stdin: FILE = FILE {
flags: constants::F_PERM | constants::F_NOWR | constants::F_BADJ,
rpos: ptr::null_mut(),
rend: ptr::null_mut(),
......@@ -32,13 +19,13 @@ static mut default_stdin: GlobalFile = GlobalFile::new(FILE {
buf_char: -1,
unget: UNGET,
lock: AtomicBool::new(false),
});
};
#[allow(non_upper_case_globals)]
static mut default_stdout_buf: [u8; BUFSIZ as usize] = [0; BUFSIZ as usize];
#[allow(non_upper_case_globals)]
static mut default_stdout: GlobalFile = GlobalFile::new(FILE {
static mut default_stdout: FILE = FILE {
flags: constants::F_PERM | constants::F_NORD | constants::F_BADJ,
rpos: ptr::null_mut(),
rend: ptr::null_mut(),
......@@ -51,13 +38,13 @@ static mut default_stdout: GlobalFile = GlobalFile::new(FILE {
buf_char: b'\n' as i8,
unget: 0,
lock: AtomicBool::new(false),
});
};
#[allow(non_upper_case_globals)]
static mut default_stderr_buf: [u8; BUFSIZ as usize] = [0; BUFSIZ as usize];
#[allow(non_upper_case_globals)]
static mut default_stderr: GlobalFile = GlobalFile::new(FILE {
static mut default_stderr: FILE = FILE {
flags: constants::F_PERM | constants::F_NORD | constants::F_BADJ,
rpos: ptr::null_mut(),
rend: ptr::null_mut(),
......@@ -70,19 +57,19 @@ static mut default_stderr: GlobalFile = GlobalFile::new(FILE {
buf_char: -1,
unget: 0,
lock: AtomicBool::new(false),
});
};
#[no_mangle]
pub extern "C" fn __stdin() -> *mut FILE {
unsafe { default_stdin.get() }
unsafe { &mut default_stdin }
}
#[no_mangle]
pub extern "C" fn __stdout() -> *mut FILE {
unsafe { default_stdout.get() }
unsafe { &mut default_stdout }
}
#[no_mangle]
pub extern "C" fn __stderr() -> *mut FILE {
unsafe { default_stderr.get() }
unsafe { &mut default_stderr }
}
#include <stdio.h>
#include <malloc.h>
int main(int argc, char ** argv) {
int a = 0;
......
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