Skip to content
Snippets Groups Projects
Commit a2dc2212 authored by Tom Almeida's avatar Tom Almeida
Browse files

Merge branch 'master' into 'master'

# Conflicts:
#   src/stdio/src/default.rs
parents 7e731e0b 29a626cd
No related branches found
No related tags found
1 merge request!136Fixing some things in stdio
image: "rust:latest"
before_script:
- git submodule update --init --recursive
- rustup toolchain add nightly
- rustup target add x86_64-unknown-redox --toolchain nightly
- rustup show # Print version info for debugging
build:linux:
script:
- make all
#build:redox:
# script:
# - make all
test:linux:
script:
- make test
fmt:
script:
- rustup component add rustfmt-preview
- ./fmt.sh -- --check
# TODO: Set up a docker image with a redox vm that would allow to
# run things like tests under redox
This diff is collapsed.
......@@ -11,19 +11,20 @@ crate-type = ["staticlib"]
members = ["src/crt0"]
[build-dependencies]
cc = "1.0"
cc = "1.0.17"
[dependencies]
compiler_builtins = { git = "https://github.com/rust-lang-nursery/compiler-builtins.git", default-features = false }
ctype = { path = "src/ctype" }
errno = { path = "src/errno" }
fcntl = { path = "src/fcntl" }
fenv = { path = "src/fenv" }
float = { path = "src/float" }
grp = { path = "src/grp" }
inttypes = { path = "src/inttypes" }
locale = { path = "src/locale" }
netinet = { path = "src/netinet" }
platform = { path = "src/platform" }
setjmp = { path = "src/setjmp" }
semaphore = { path = "src/semaphore" }
signal = { path = "src/signal" }
stdio = { path = "src/stdio" }
......@@ -34,11 +35,17 @@ sys_resource = { path = "src/sys_resource" }
sys_socket = { path = "src/sys_socket" }
sys_stat = { path = "src/sys_stat" }
sys_time = { path = "src/sys_time" }
sys_utsname = { path = "src/sys_utsname" }
sys_wait = { path = "src/sys_wait" }
time = { path = "src/time" }
unistd = { path = "src/unistd" }
wctype = { path = "src/wctype" }
[dependencies.compiler_builtins]
git = "https://github.com/rust-lang-nursery/compiler-builtins.git"
default-features = false
features = ["no-lang-items", "mangled-names"]
[profile.dev]
panic = "abort"
......
......@@ -38,6 +38,8 @@ install: all
cp -rv "target/include"/* "$(DESTDIR)/include"
cp -v "$(BUILD)/debug/libc.a" "$(DESTDIR)/lib"
cp -v "$(BUILD)/debug/crt0.o" "$(DESTDIR)/lib"
cp -rv "openlibm/include"/* "$(DESTDIR)/include"
cp -rv "openlibm/src"/*.h "$(DESTDIR)/include"
cp -v "$(BUILD)/openlibm/libopenlibm.a" "$(DESTDIR)/lib/libm.a"
libc: $(BUILD)/debug/libc.a $(BUILD)/debug/crt0.o
......@@ -52,7 +54,7 @@ $(BUILD)/debug/libc.a: $(SRC)
touch $@
$(BUILD)/debug/crt0.o: $(SRC)
cargo rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@
CARGO_INCREMENTAL=0 cargo --verbose --verbose rustc --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@
touch $@
$(BUILD)/release/libc.a: $(SRC)
......@@ -60,7 +62,7 @@ $(BUILD)/release/libc.a: $(SRC)
touch $@
$(BUILD)/release/crt0.o: $(SRC)
cargo rustc --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@
CARGO_INCREMENTAL=0 cargo rustc --release --manifest-path src/crt0/Cargo.toml $(CARGOFLAGS) -- --emit obj=$@
touch $@
$(BUILD)/openlibm: openlibm
......
#ifndef _ASSERT_H
#define _ASSERT_H
#ifdef NDEBUG
# define assert(cond)
#else
# include <stdio.h>
# define assert(cond) if (!(cond)) { \
fprintf(stderr, "%s: %s:%d: Assertion `%s` failed.\n", __func__, __FILE__, __LINE__, #cond); \
abort(); \
}
#endif
#endif
#ifndef _BITS_EXEC_H
#define _BITS_EXEC_H
int execl(const char *path, const char* argv0, ...)
{
int argc;
va_list ap;
va_start(ap, argv0);
for (argc = 1; va_arg(ap, const char*); argc++);
va_end(ap);
{
int i;
char *argv[argc+1];
va_start(ap, argv0);
argv[0] = (char *)argv0;
for (i = 1; i < argc; i++) {
argv[i] = va_arg(ap, char *);
}
argv[i] = NULL;
va_end(ap);
return execv(path, argv);
}
}
int execle(const char *path, const char* argv0, ...)
{
int argc;
va_list ap;
va_start(ap, argv0);
for (argc = 1; va_arg(ap, const char *); argc++);
va_end(ap);
{
int i;
char *argv[argc+1];
char **envp;
va_start(ap, argv0);
argv[0] = (char *)argv0;
for (i = 1; i <= argc; i++) {
argv[i] = va_arg(ap, char *);
}
envp = va_arg(ap, char **);
va_end(ap);
return execve(path, argv, envp);
}
}
#endif
#ifndef _BITS_INTTYPE_H
#define _BITS_INTTYPE_H
#define PRId8 "hhd"
#define PRId16 "hd"
#define PRId32 "ld"
#define PRId64 "Ld"
#define PRIdLEAST8 "hhd"
#define PRIdLEAST16 "hd"
#define PRIdLEAST32 "ld"
#define PRIdLEAST64 "Ld"
#define PRIdFAST8 "hhd"
#define PRIdFAST16 "hd"
#define PRIdFAST32 "ld"
#define PRIdFAST64 "Ld"
#define PRIi8 "hhi"
#define PRIi16 "hi"
#define PRIi32 "li"
#define PRIi64 "Li"
#define PRIiLEAST8 "hhi"
#define PRIiLEAST16 "hi"
#define PRIiLEAST32 "li"
#define PRIiLEAST64 "Li"
#define PRIiFAST8 "hhi"
#define PRIiFAST16 "hi"
#define PRIiFAST32 "li"
#define PRIiFAST64 "Li"
#define PRIo8 "hho"
#define PRIo16 "ho"
#define PRIo32 "lo"
#define PRIo64 "Lo"
#define PRIoLEAST8 "hho"
#define PRIoLEAST16 "ho"
#define PRIoLEAST32 "lo"
#define PRIoLEAST64 "Lo"
#define PRIoFAST8 "hho"
#define PRIoFAST16 "ho"
#define PRIoFAST32 "lo"
#define PRIoFAST64 "Lo"
#define PRIu8 "hhu"
#define PRIu16 "hu"
#define PRIu32 "lu"
#define PRIu64 "Lu"
#define PRIuLEAST8 "hhu"
#define PRIuLEAST16 "hu"
#define PRIuLEAST32 "lu"
#define PRIuLEAST64 "Lu"
#define PRIuFAST8 "hhu"
#define PRIuFAST16 "hu"
#define PRIuFAST32 "lu"
#define PRIuFAST64 "Lu"
#define PRIx8 "hhx"
#define PRIx16 "hx"
#define PRIx32 "lx"
#define PRIx64 "Lx"
#define PRIxLEAST8 "hhx"
#define PRIxLEAST16 "hx"
#define PRIxLEAST32 "lx"
#define PRIxLEAST64 "Lx"
#define PRIxFAST8 "hhx"
#define PRIxFAST16 "hx"
#define PRIxFAST32 "lx"
#define PRIxFAST64 "Lx"
#define PRIX8 "hhX"
#define PRIX16 "hX"
#define PRIX32 "lX"
#define PRIX64 "LX"
#define PRIXLEAST8 "hhX"
#define PRIXLEAST16 "hX"
#define PRIXLEAST32 "lX"
#define PRIXLEAST64 "LX"
#define PRIXFAST8 "hhX"
#define PRIXFAST16 "hX"
#define PRIXFAST32 "lX"
#define PRIXFAST64 "LX"
#define PRIdMAX "jd"
#define PRIiMAX "ji"
#define PRIoMAX "jo"
#define PRIuMAX "ju"
#define PRIxMAX "jx"
#define PRIXMAX "jX"
#define PRIdPTR "td"
#define PRIiPTR "ti"
#define PRIoPTR "to"
#define PRIuPTR "tu"
#define PRIxPTR "tx"
#define PRIXPTR "tX"
#define SCNd8 "hhd"
#define SCNd16 "hd"
#define SCNd32 "ld"
#define SCNd64 "Ld"
#define SCNdLEAST8 "hhd"
#define SCNdLEAST16 "hd"
#define SCNdLEAST32 "ld"
#define SCNdLEAST64 "Ld"
#define SCNdFAST8 "hhd"
#define SCNdFAST16 "hd"
#define SCNdFAST32 "ld"
#define SCNdFAST64 "Ld"
#define SCNi8 "hhi"
#define SCNi16 "hi"
#define SCNi32 "li"
#define SCNi64 "Li"
#define SCNiLEAST8 "hhi"
#define SCNiLEAST16 "hi"
#define SCNiLEAST32 "li"
#define SCNiLEAST64 "Li"
#define SCNiFAST8 "hhi"
#define SCNiFAST16 "hi"
#define SCNiFAST32 "li"
#define SCNiFAST64 "Li"
#define SCNo8 "hho"
#define SCNo16 "ho"
#define SCNo32 "lo"
#define SCNo64 "Lo"
#define SCNoLEAST8 "hho"
#define SCNoLEAST16 "ho"
#define SCNoLEAST32 "lo"
#define SCNoLEAST64 "Lo"
#define SCNoFAST8 "hho"
#define SCNoFAST16 "ho"
#define SCNoFAST32 "lo"
#define SCNoFAST64 "Lo"
#define SCNu8 "hhu"
#define SCNu16 "hu"
#define SCNu32 "lu"
#define SCNu64 "Lu"
#define SCNuLEAST8 "hhu"
#define SCNuLEAST16 "hu"
#define SCNuLEAST32 "lu"
#define SCNuLEAST64 "Lu"
#define SCNuFAST8 "hhu"
#define SCNuFAST16 "hu"
#define SCNuFAST32 "lu"
#define SCNuFAST64 "Lu"
#define SCNx8 "hhx"
#define SCNx16 "hx"
#define SCNx32 "lx"
#define SCNx64 "Lx"
#define SCNxLEAST8 "hhx"
#define SCNxLEAST16 "hx"
#define SCNxLEAST32 "lx"
#define SCNxLEAST64 "Lx"
#define SCNxFAST8 "hhx"
#define SCNxFAST16 "hx"
#define SCNxFAST32 "lx"
#define SCNxFAST64 "Lx"
#define SCNdMAX "jd"
#define SCNiMAX "ji"
#define SCNoMAX "jo"
#define SCNuMAX "ju"
#define SCNxMAX "jx"
#define SCNdPTR "td"
#define SCNiPTR "ti"
#define SCNoPTR "to"
#define SCNuPTR "tu"
#define SCNxPTR "tx"
#endif
......@@ -2,6 +2,7 @@
#define _BITS_STDIO_H
#define EOF (-1)
#define BUFSIZ 1024
#define stdin __stdin()
#define stdout __stdout()
#define stderr __stderr()
......
#ifndef _BITS_STAT_H
#define _BITS_STAT_H
#define S_ISDIR(mode) mode & S_IFMT == S_IFDIR
#define S_ISCHR(mode) mode & S_IFMT == S_IFCHR
#define S_ISBLK(mode) mode & S_IFMT == S_IFBLK
#define S_ISREG(mode) mode & S_IFMT == S_IFREG
#define S_ISIFO(mode) mode & S_IFMT == S_IFIFO
#define S_ISLNK(mode) mode & S_IFMT == S_IFLNK
#endif
#define OPENLIBM_USE_HOST_FENV_H 1
#include <openlibm.h>
#define OPENLIBM_USE_HOST_FENV_H 1
#include <openlibm.h>
#ifndef _SETJMP_H
#define _SETJMP_H
#ifdef __arch64__
typedef unsigned long jmp_buf[22];
#endif
#ifdef __arm__
typedef unsigned long long jmp_buf[32];
#endif
#ifdef __i386__
typedef unsigned long jmp_buf[6];
#endif
#ifdef __m68k__
typedef unsigned long jmp_buf[39];
#endif
#ifdef __microblaze__
typedef unsigned long jmp_buf[18];
#endif
#ifdef __mips__
typedef unsigned long long jmp_buf[13];
#endif
#ifdef __mips64__
typedef unsigned long long jmp_buf[23];
#endif
#ifdef __mipsn32__
typedef unsigned long long jmp_buf[23];
#endif
#ifdef __or1k__
typedef unsigned long jmp_buf[13];
#endif
#ifdef __powerpc__
typedef unsigned long long jmp_buf[56];
#endif
#ifdef __powerpc64__
typedef uint128_t jmp_buf[32];
#endif
#ifdef __s390x__
typedef unsigned long jmp_buf[18];
#endif
#ifdef __sh__
typedef unsigned long jmp_buf[15];
#endif
#ifdef __x32__
typedef unsigned long long jmp_buf[8];
#endif
#ifdef __x86_64__
typedef unsigned long jmp_buf[8];
#endif
int setjmp(jmp_buf buf);
void longjmp(jmp_buf buf, int value);
#endif /* _SETJMP_H */
......@@ -6,41 +6,105 @@
#define INT8_MAX 0x7F
typedef signed char int8_t;
#define INT_LEAST8_MIN -0x80
#define INT_LEAST8_MAX 0x7F
typedef signed char int_least8_t;
#define INT_FAST8_MIN -0x80
#define INT_FAST8_MAX 0x7F
typedef signed char int_fast8_t;
#define UINT8_C(value) ((uint8_t) value ## U)
#define UINT8_MIN 0x00
#define UINT8_MAX 0xFF
typedef unsigned char uint8_t;
#define UINT_LEAST8_MIN 0x00
#define UINT_LEAST8_MAX 0xFF
typedef unsigned char uint_least8_t;
#define UINT_FAST8_MIN 0x00
#define UINT_FAST8_MAX 0xFF
typedef unsigned char uint_fast8_t;
#define INT16_C(value) value
#define INT16_MIN -0x8000
#define INT16_MAX 0x7FFF
typedef signed short int16_t;
#define INT_LEAST16_MIN -0x8000
#define INT_LEAST16_MAX 0x7FFF
typedef signed short int_least16_t;
#define INT_FAST16_MIN -0x8000
#define INT_FAST16_MAX 0x7FFF
typedef signed short int_fast16_t;
#define UINT16_C(value) value ## U
#define UINT16_MIN 0x0000
#define UINT16_MAX 0xFFFF
typedef unsigned short uint16_t;
#define UINT_LEAST16_MIN 0x0000
#define UINT_LEAST16_MAX 0xFFFF
typedef unsigned short uint_least16_t;
#define UINT_FAST16_MIN 0x0000
#define UINT_FAST16_MAX 0xFFFF
typedef unsigned short uint_fast16_t;
#define INT32_C(value) value ## L
#define INT32_MIN -0x80000000
#define INT32_MAX 0x7FFFFFFF
typedef signed long int32_t;
#define INT_LEAST32_MIN -0x80000000
#define INT_LEAST32_MAX 0x7FFFFFFF
typedef signed long int_least32_t;
#define INT_FAST32_MIN -0x80000000
#define INT_FAST32_MAX 0x7FFFFFFF
typedef signed long int_fast32_t;
#define UINT32_C(value) value ## UL
#define UINT32_MIN 0x00000000
#define UINT32_MAX 0xFFFFFFFF
typedef unsigned long uint32_t;
#define UINT_LEAST32_MIN 0x00000000
#define UINT_LEAST32_MAX 0xFFFFFFFF
typedef unsigned long uint_least32_t;
#define UINT_FAST32_MIN 0x00000000
#define UINT_FAST32_MAX 0xFFFFFFFF
typedef unsigned long uint_fast32_t;
#define INT64_C(value) value ## LL
#define INT64_MIN -0x8000000000000000
#define INT64_MAX 0x7FFFFFFFFFFFFFFF
typedef signed long long int64_t;
#define INT_LEAST64_MIN -0x8000000000000000
#define INT_LEAST64_MAX 0x7FFFFFFFFFFFFFFF
typedef signed long long int_least64_t;
#define INT_FAST64_MIN -0x8000000000000000
#define INT_FAST64_MAX 0x7FFFFFFFFFFFFFFF
typedef signed long long int_fast64_t;
#define UINT64_C(value) value ## ULL
#define UINT64_MIN 0x0000000000000000
#define UINT64_MAX 0xFFFFFFFFFFFFFFFF
typedef unsigned long long uint64_t;
#define UINT_LEAST64_MIN 0x0000000000000000
#define UINT_LEAST64_MAX 0xFFFFFFFFFFFFFFFF
typedef unsigned long long uint_least64_t;
#define UINT_FAST64_MIN 0x0000000000000000
#define UINT_FAST64_MAX 0xFFFFFFFFFFFFFFFF
typedef unsigned long long uint_fast64_t;
#define INTMAX_C(value) value ## LL
#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
......@@ -61,4 +125,6 @@ typedef uint64_t uintptr_t;
#define SIZE_MAX UINT64_MAX
typedef long sig_atomic_t;
#endif /* _STDINT_H */
Subproject commit 2d8d44970eb5bb2ecc55f5ced8a33f21ed9407f4
Subproject commit 867c809039aef77dbce22e98b1009b8995dfa868
nightly-2018-03-04
nightly-2018-06-19
......@@ -2,8 +2,9 @@
#![no_std]
#![feature(asm)]
#![feature(lang_items)]
#![feature(linkage)]
#![feature(naked_functions)]
#![feature(panic_implementation)]
extern crate platform;
......@@ -59,7 +60,14 @@ pub unsafe extern "C" fn _start_rust(sp: &'static Stack) -> ! {
platform::exit(main(argc, argv));
}
#[lang = "panic_fmt"]
pub extern "C" fn rust_begin_unwind(_fmt: ::core::fmt::Arguments, _file: &str, _line: u32) -> ! {
loop {}
#[panic_implementation]
#[linkage = "weak"]
#[no_mangle]
pub extern "C" fn rust_begin_unwind(pi: &::core::panic::PanicInfo) -> ! {
use core::fmt::Write;
let mut w = platform::FileWriter(2);
let _ = w.write_fmt(format_args!("RELIBC CRT0 PANIC: {}\n", pi));
platform::exit(1);
}
sys_includes = ["sys/types.h"]
sys_includes = ["stdint.h", "sys/types.h"]
include_guard = "_FENV_H"
language = "C"
......
[package]
name = "inttypes"
version = "0.1.0"
authors = ["jD91mZM2 <me@krake.one>"]
build = "build.rs"
[build-dependencies]
cbindgen = { path = "../../cbindgen" }
[dependencies]
ctype = { path = "../ctype" }
errno = { path = "../errno" }
platform = { path = "../platform" }
stdlib = { path = "../stdlib" }
extern crate cbindgen;
use std::{env, fs};
fn main() {
let crate_dir = env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
fs::create_dir_all("../../target/include").expect("failed to create include directory");
cbindgen::generate(crate_dir)
.expect("failed to generate bindings")
.write_to_file("../../target/include/inttypes.h");
}
sys_includes = ["stdint.h"]
include_guard = "_INTTYPES_H"
trailer = "#include <bits/inttypes.h>"
language = "C"
[enum]
prefix_with_name = true
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