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

Merged relibc with branch

parents 05b4b764 30ec8aa2
No related branches found
No related tags found
1 merge request!136Fixing some things in stdio
image: "rust:latest"
image: "rustlang/rust:nightly"
stages:
- build
- test
before_script:
- git submodule update --init --recursive
- rustup toolchain add nightly
- rustup target add x86_64-unknown-redox --toolchain nightly
- rustup toolchain add "$(cat rust-toolchain)"
- rustup target add x86_64-unknown-redox --toolchain "$(cat rust-toolchain)"
- rustup show # Print version info for debugging
cache:
untracked: true
build:linux:
stage: build
script:
- make all
#build:redox:
# script:
# - make all
build:redox:
stage: build
variables:
TARGET: x86_64-unknown-redox
script:
# Install x86_64-unknown-redox-gcc
# This can't be in before_script because that overrides
# the global before_script.
- apt-get update -qq
- apt-get install -qq apt-transport-https build-essential curl git gnupg software-properties-common
- apt-key adv --keyserver keyserver.ubuntu.com --recv-keys AA12E97F0881517F
- add-apt-repository 'deb https://static.redox-os.org/toolchain/apt /'
- apt-get update -qq && apt-get install -qq x86-64-unknown-redox-gcc
# Main script
- make all
test:linux:
stage: test
dependencies:
- build:linux
script:
- make test
- cd tests && make verify
fmt:
stage: test
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
allow_failure: true
......@@ -304,6 +304,7 @@ dependencies = [
"sys_wait 0.1.0",
"time 0.1.0",
"unistd 0.1.0",
"wchar 0.1.0",
"wctype 0.1.0",
]
......@@ -403,7 +404,7 @@ dependencies = [
"errno 0.1.0",
"fcntl 0.1.0",
"platform 0.1.0",
"stdlib 0.1.0",
"ralloc 1.0.0",
"string 0.1.0",
"va_list 0.1.0",
]
......@@ -418,7 +419,9 @@ dependencies = [
"platform 0.1.0",
"ralloc 1.0.0",
"rand 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"string 0.1.0",
"time 0.1.0",
"wchar 0.1.0",
]
[[package]]
......@@ -428,7 +431,7 @@ dependencies = [
"cbindgen 0.5.2",
"errno 0.1.0",
"platform 0.1.0",
"stdlib 0.1.0",
"ralloc 1.0.0",
]
[[package]]
......@@ -606,6 +609,18 @@ name = "vec_map"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "wchar"
version = "0.1.0"
dependencies = [
"cbindgen 0.5.2",
"errno 0.1.0",
"platform 0.1.0",
"stdio 0.1.0",
"time 0.1.0",
"va_list 0.1.0",
]
[[package]]
name = "wctype"
version = "0.1.0"
......
......@@ -39,6 +39,7 @@ sys_utsname = { path = "src/sys_utsname" }
sys_wait = { path = "src/sys_wait" }
time = { path = "src/time" }
unistd = { path = "src/unistd" }
wchar = { path = "src/wchar" }
wctype = { path = "src/wctype" }
[dependencies.compiler_builtins]
......
......@@ -7,11 +7,11 @@ ifneq ($(TARGET),)
endif
ifeq ($(TARGET),aarch64-unknown-linux-gnu)
CC="aarch64-linux-gnu-gcc"
CC=aarch64-linux-gnu-gcc
endif
ifeq ($(TARGET),x86_64-unknown-redox)
CC="x86_64-unknown-redox-gcc"
CC=x86_64-unknown-redox-gcc
endif
SRC=\
......
#!/bin/bash
#!/usr/bin/env bash
ARGS=()
for crate in relibc $(find src -name Cargo.toml | cut -d '/' -f2 | grep -v template)
......
#ifndef _BITS_UNISTD_H
#define _BITS_UNISTD_H
int execl(const char *path, const char* argv0, ...);
int execle(const char *path, const char* argv0, ...);
#endif
#ifndef _BITS_WCHAR_H
#define _BITS_WCHAR_H
#include <stdint.h>
typedef signed short wchar_t;
typedef signed int wint_t;
#define WEOF (0xFFFFFFFFu)
typedef int32_t wchar_t;
typedef uint32_t wint_t;
#endif /* _BITS_WCHAR_H */
#ifndef _STDDEF_H
#define _STDDEF_H
#include <stdint.h>
#define NULL 0
typedef signed long long ptrdiff_t;
typedef unsigned char wchar_t;
typedef int32_t wchar_t;
typedef unsigned long long size_t;
......
/* Copyright (C) 2008-2018 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
/*
* ISO C Standard: 7.18 Integer types <stdint.h>
*/
#ifndef _STDINT_H
#define _STDINT_H
#define INT8_C(value) ((int8_t) value)
#define INT8_MIN -0x80
#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
typedef int64_t intmax_t;
#define UINTMAX_C(value) value ## ULL
#define UINTMAX_MIN UINT64_MIN
#define UINTMAX_MAX UINT64_MAX
typedef uint64_t uintmax_t;
#define INTPTR_MIN INT64_MIN
#define INTPTR_MAX INT64_MAX
typedef int64_t intptr_t;
#define UINTPTR_MIN UINT64_MIN
#define UINTPTR_MAX UINT64_MAX
typedef uint64_t uintptr_t;
/* 7.8.1.1 Exact-width integer types */
#ifdef __INT8_TYPE__
typedef __INT8_TYPE__ int8_t;
#endif
#ifdef __INT16_TYPE__
typedef __INT16_TYPE__ int16_t;
#endif
#ifdef __INT32_TYPE__
typedef __INT32_TYPE__ int32_t;
#endif
#ifdef __INT64_TYPE__
typedef __INT64_TYPE__ int64_t;
#endif
#ifdef __UINT8_TYPE__
typedef __UINT8_TYPE__ uint8_t;
#endif
#ifdef __UINT16_TYPE__
typedef __UINT16_TYPE__ uint16_t;
#endif
#ifdef __UINT32_TYPE__
typedef __UINT32_TYPE__ uint32_t;
#endif
#ifdef __UINT64_TYPE__
typedef __UINT64_TYPE__ uint64_t;
#endif
/* 7.8.1.2 Minimum-width integer types */
typedef __INT_LEAST8_TYPE__ int_least8_t;
typedef __INT_LEAST16_TYPE__ int_least16_t;
typedef __INT_LEAST32_TYPE__ int_least32_t;
typedef __INT_LEAST64_TYPE__ int_least64_t;
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
/* 7.8.1.3 Fastest minimum-width integer types */
typedef __INT_FAST8_TYPE__ int_fast8_t;
typedef __INT_FAST16_TYPE__ int_fast16_t;
typedef __INT_FAST32_TYPE__ int_fast32_t;
typedef __INT_FAST64_TYPE__ int_fast64_t;
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
/* 7.8.1.4 Integer types capable of holding object pointers */
#ifdef __INTPTR_TYPE__
typedef __INTPTR_TYPE__ intptr_t;
#endif
#ifdef __UINTPTR_TYPE__
typedef __UINTPTR_TYPE__ uintptr_t;
#endif
/* 7.8.1.5 Greatest-width integer types */
typedef __INTMAX_TYPE__ intmax_t;
typedef __UINTMAX_TYPE__ uintmax_t;
#if (!defined __cplusplus || __cplusplus >= 201103L \
|| defined __STDC_LIMIT_MACROS)
/* 7.18.2 Limits of specified-width integer types */
#ifdef __INT8_MAX__
# undef INT8_MAX
# define INT8_MAX __INT8_MAX__
# undef INT8_MIN
# define INT8_MIN (-INT8_MAX - 1)
#endif
#ifdef __UINT8_MAX__
# undef UINT8_MAX
# define UINT8_MAX __UINT8_MAX__
#endif
#ifdef __INT16_MAX__
# undef INT16_MAX
# define INT16_MAX __INT16_MAX__
# undef INT16_MIN
# define INT16_MIN (-INT16_MAX - 1)
#endif
#ifdef __UINT16_MAX__
# undef UINT16_MAX
# define UINT16_MAX __UINT16_MAX__
#endif
#ifdef __INT32_MAX__
# undef INT32_MAX
# define INT32_MAX __INT32_MAX__
# undef INT32_MIN
# define INT32_MIN (-INT32_MAX - 1)
#endif
#ifdef __UINT32_MAX__
# undef UINT32_MAX
# define UINT32_MAX __UINT32_MAX__
#endif
#ifdef __INT64_MAX__
# undef INT64_MAX
# define INT64_MAX __INT64_MAX__
# undef INT64_MIN
# define INT64_MIN (-INT64_MAX - 1)
#endif
#ifdef __UINT64_MAX__
# undef UINT64_MAX
# define UINT64_MAX __UINT64_MAX__
#endif
#undef INT_LEAST8_MAX
#define INT_LEAST8_MAX __INT_LEAST8_MAX__
#undef INT_LEAST8_MIN
#define INT_LEAST8_MIN (-INT_LEAST8_MAX - 1)
#undef UINT_LEAST8_MAX
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
#undef INT_LEAST16_MAX
#define INT_LEAST16_MAX __INT_LEAST16_MAX__
#undef INT_LEAST16_MIN
#define INT_LEAST16_MIN (-INT_LEAST16_MAX - 1)
#undef UINT_LEAST16_MAX
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
#undef INT_LEAST32_MAX
#define INT_LEAST32_MAX __INT_LEAST32_MAX__
#undef INT_LEAST32_MIN
#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)
#undef UINT_LEAST32_MAX
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
#undef INT_LEAST64_MAX
#define INT_LEAST64_MAX __INT_LEAST64_MAX__
#undef INT_LEAST64_MIN
#define INT_LEAST64_MIN (-INT_LEAST64_MAX - 1)
#undef UINT_LEAST64_MAX
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
#undef INT_FAST8_MAX
#define INT_FAST8_MAX __INT_FAST8_MAX__
#undef INT_FAST8_MIN
#define INT_FAST8_MIN (-INT_FAST8_MAX - 1)
#undef UINT_FAST8_MAX
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
#undef INT_FAST16_MAX
#define INT_FAST16_MAX __INT_FAST16_MAX__
#undef INT_FAST16_MIN
#define INT_FAST16_MIN (-INT_FAST16_MAX - 1)
#undef UINT_FAST16_MAX
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
#undef INT_FAST32_MAX
#define INT_FAST32_MAX __INT_FAST32_MAX__
#undef INT_FAST32_MIN
#define INT_FAST32_MIN (-INT_FAST32_MAX - 1)
#undef UINT_FAST32_MAX
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
#undef INT_FAST64_MAX
#define INT_FAST64_MAX __INT_FAST64_MAX__
#undef INT_FAST64_MIN
#define INT_FAST64_MIN (-INT_FAST64_MAX - 1)
#undef UINT_FAST64_MAX
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
#ifdef __INTPTR_MAX__
# undef INTPTR_MAX
# define INTPTR_MAX __INTPTR_MAX__
# undef INTPTR_MIN
# define INTPTR_MIN (-INTPTR_MAX - 1)
#endif
#ifdef __UINTPTR_MAX__
# undef UINTPTR_MAX
# define UINTPTR_MAX __UINTPTR_MAX__
#endif
#undef INTMAX_MAX
#define INTMAX_MAX __INTMAX_MAX__
#undef INTMAX_MIN
#define INTMAX_MIN (-INTMAX_MAX - 1)
#undef UINTMAX_MAX
#define UINTMAX_MAX __UINTMAX_MAX__
/* 7.18.3 Limits of other integer types */
#undef PTRDIFF_MAX
#define PTRDIFF_MAX __PTRDIFF_MAX__
#undef PTRDIFF_MIN
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
#undef SIG_ATOMIC_MAX
#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
#undef SIG_ATOMIC_MIN
#define SIG_ATOMIC_MIN __SIG_ATOMIC_MIN__
#undef SIZE_MAX
#define SIZE_MAX __SIZE_MAX__
#undef WCHAR_MAX
#define WCHAR_MAX __WCHAR_MAX__
#undef WCHAR_MIN
#define WCHAR_MIN __WCHAR_MIN__
#undef WINT_MAX
#define WINT_MAX __WINT_MAX__
#undef WINT_MIN
#define WINT_MIN __WINT_MIN__
#endif /* (!defined __cplusplus || __cplusplus >= 201103L
|| defined __STDC_LIMIT_MACROS) */
#if (!defined __cplusplus || __cplusplus >= 201103L \
|| defined __STDC_CONSTANT_MACROS)
#undef INT8_C
#define INT8_C(c) __INT8_C(c)
#undef INT16_C
#define INT16_C(c) __INT16_C(c)
#undef INT32_C
#define INT32_C(c) __INT32_C(c)
#undef INT64_C
#define INT64_C(c) __INT64_C(c)
#undef UINT8_C
#define UINT8_C(c) __UINT8_C(c)
#undef UINT16_C
#define UINT16_C(c) __UINT16_C(c)
#undef UINT32_C
#define UINT32_C(c) __UINT32_C(c)
#undef UINT64_C
#define UINT64_C(c) __UINT64_C(c)
#undef INTMAX_C
#define INTMAX_C(c) __INTMAX_C(c)
#undef UINTMAX_C
#define UINTMAX_C(c) __UINTMAX_C(c)
#endif /* (!defined __cplusplus || __cplusplus >= 201103L
|| defined __STDC_CONSTANT_MACROS) */
#ifdef __STDC_WANT_IEC_60559_BFP_EXT__
/* TS 18661-1 widths of integer types. */
#ifdef __INT8_TYPE__
# undef INT8_WIDTH
# define INT8_WIDTH 8
#endif
#ifdef __UINT8_TYPE__
# undef UINT8_WIDTH
# define UINT8_WIDTH 8
#endif
#ifdef __INT16_TYPE__
# undef INT16_WIDTH
# define INT16_WIDTH 16
#endif
#ifdef __UINT16_TYPE__
# undef UINT16_WIDTH
# define UINT16_WIDTH 16
#endif
#ifdef __INT32_TYPE__
# undef INT32_WIDTH
# define INT32_WIDTH 32
#endif
#ifdef __UINT32_TYPE__
# undef UINT32_WIDTH
# define UINT32_WIDTH 32
#endif
#ifdef __INT64_TYPE__
# undef INT64_WIDTH
# define INT64_WIDTH 64
#endif
#ifdef __UINT64_TYPE__
# undef UINT64_WIDTH
# define UINT64_WIDTH 64
#endif
#undef INT_LEAST8_WIDTH
#define INT_LEAST8_WIDTH __INT_LEAST8_WIDTH__
#undef UINT_LEAST8_WIDTH
#define UINT_LEAST8_WIDTH __INT_LEAST8_WIDTH__
#undef INT_LEAST16_WIDTH
#define INT_LEAST16_WIDTH __INT_LEAST16_WIDTH__
#undef UINT_LEAST16_WIDTH
#define UINT_LEAST16_WIDTH __INT_LEAST16_WIDTH__
#undef INT_LEAST32_WIDTH
#define INT_LEAST32_WIDTH __INT_LEAST32_WIDTH__
#undef UINT_LEAST32_WIDTH
#define UINT_LEAST32_WIDTH __INT_LEAST32_WIDTH__
#undef INT_LEAST64_WIDTH
#define INT_LEAST64_WIDTH __INT_LEAST64_WIDTH__
#undef UINT_LEAST64_WIDTH
#define UINT_LEAST64_WIDTH __INT_LEAST64_WIDTH__
#undef INT_FAST8_WIDTH
#define INT_FAST8_WIDTH __INT_FAST8_WIDTH__
#undef UINT_FAST8_WIDTH
#define UINT_FAST8_WIDTH __INT_FAST8_WIDTH__
#undef INT_FAST16_WIDTH
#define INT_FAST16_WIDTH __INT_FAST16_WIDTH__
#undef UINT_FAST16_WIDTH
#define UINT_FAST16_WIDTH __INT_FAST16_WIDTH__
#undef INT_FAST32_WIDTH
#define INT_FAST32_WIDTH __INT_FAST32_WIDTH__
#undef UINT_FAST32_WIDTH
#define UINT_FAST32_WIDTH __INT_FAST32_WIDTH__
#undef INT_FAST64_WIDTH
#define INT_FAST64_WIDTH __INT_FAST64_WIDTH__
#undef UINT_FAST64_WIDTH
#define UINT_FAST64_WIDTH __INT_FAST64_WIDTH__
#ifdef __INTPTR_TYPE__
# undef INTPTR_WIDTH
# define INTPTR_WIDTH __INTPTR_WIDTH__
#endif
#ifdef __UINTPTR_TYPE__
# undef UINTPTR_WIDTH
# define UINTPTR_WIDTH __INTPTR_WIDTH__
#endif
#undef INTMAX_WIDTH
#define INTMAX_WIDTH __INTMAX_WIDTH__
#undef UINTMAX_WIDTH
#define UINTMAX_WIDTH __INTMAX_WIDTH__
#undef PTRDIFF_WIDTH
#define PTRDIFF_WIDTH __PTRDIFF_WIDTH__
#undef SIG_ATOMIC_WIDTH
#define SIG_ATOMIC_WIDTH __SIG_ATOMIC_WIDTH__
#undef SIZE_WIDTH
#define SIZE_WIDTH __SIZE_WIDTH__
#undef WCHAR_WIDTH
#define WCHAR_WIDTH __WCHAR_WIDTH__
#undef WINT_WIDTH
#define WINT_WIDTH __WINT_WIDTH__
#define SIZE_MAX UINT64_MAX
#endif
typedef long sig_atomic_t;
#endif /* _STDINT_H */
#endif /* _GCC_STDINT_H */
......@@ -9,19 +9,13 @@ fn_single_line = false
where_single_line = false
imports_indent = "Visual"
imports_layout = "Mixed"
reorder_extern_crates = true
reorder_extern_crates_in_group = true
reorder_imports = false
reorder_imported_names = true
spaces_within_parens_and_brackets = false
remove_blank_lines_at_start_or_end_of_block = true
fn_args_density = "Tall"
brace_style = "SameLineWhere"
trailing_comma = "Vertical"
blank_lines_upper_bound = 1
blank_lines_lower_bound = 0
force_explicit_abi = true
write_mode = "Overwrite"
disable_all_formatting = false
skip_children = false
hide_parse_errors = false
......
#ifndef _BITS_EXEC_H
#define _BITS_EXEC_H
#include <stdarg.h>
#include <stddef.h>
int execv(const char *path, char *const *argv);
int execl(const char *path, const char* argv0, ...)
{
......@@ -22,6 +24,8 @@ int execl(const char *path, const char* argv0, ...)
}
}
int execve(const char *path, char *const *argv, char *const *envp);
int execle(const char *path, const char* argv0, ...)
{
int argc;
......
#![no_std]
#[macro_use] extern crate stdlib;
extern crate ctype;
extern crate errno;
......
......@@ -29,6 +29,7 @@ pub extern crate sys_utsname;
pub extern crate sys_wait;
pub extern crate time;
pub extern crate unistd;
pub extern crate wchar;
pub extern crate wctype;
#[cfg(not(test))]
......
......@@ -8,6 +8,3 @@ sc = "0.2"
[target.'cfg(target_os = "redox")'.dependencies]
redox_syscall = "0.1"
[dependencies]
ralloc = { path = "../../ralloc" }
......@@ -2,8 +2,6 @@
#![no_std]
#![allow(non_camel_case_types)]
#![feature(alloc)]
#![feature(global_allocator)]
//TODO #![feature(thread_local)]
#[cfg(all(not(feature = "no_std"), target_os = "linux"))]
......@@ -24,17 +22,12 @@ mod sys;
#[path = "redox/mod.rs"]
mod sys;
extern crate alloc;
extern crate ralloc;
pub mod types;
use core::fmt;
use types::*;
#[global_allocator]
static ALLOCATOR: ralloc::Allocator = ralloc::Allocator;
//TODO #[thread_local]
#[allow(non_upper_case_globals)]
#[no_mangle]
......
use core::ptr;
use core::slice;
use core::mem;
use alloc::Vec;
use syscall;
use syscall::flag::*;
use syscall::data::TimeSpec as redox_timespec;
......@@ -68,58 +67,6 @@ pub fn dup2(fd1: c_int, fd2: c_int) -> c_int {
e(syscall::dup2(fd1 as usize, fd2 as usize, &[])) as c_int
}
pub fn execve(path: *const c_char, argv: *const *mut c_char, envp: *const *mut c_char) -> c_int {
unsafe {
let mut env = envp;
while !(*env).is_null() {
let slice = c_str(*env);
// Should always contain a =, but worth checking
if let Some(sep) = slice.iter().position(|&c| c == b'=') {
// If the environment variable has no name, do not attempt
// to add it to the env.
if sep > 0 {
let mut path = b"env:".to_vec();
path.extend_from_slice(&slice[..sep]);
match syscall::open(&path, O_WRONLY | O_CREAT) {
Ok(fd) => {
// If the environment variable has no value, there
// is no need to write anything to the env scheme.
if sep + 1 < slice.len() {
let n = match syscall::write(fd, &slice[sep + 1..]) {
Ok(n) => n,
err => {
return e(err) as c_int;
}
};
}
// Cleanup after adding the variable.
match syscall::close(fd) {
Ok(_) => (),
err => {
return e(err) as c_int;
}
}
}
err => {
return e(err) as c_int;
}
}
}
}
env = env.offset(1);
}
let mut args: Vec<[usize; 2]> = Vec::new();
let mut arg = argv;
while !(*arg).is_null() {
args.push([*arg as usize, c_str(*arg).len()]);
arg = arg.offset(1);
}
e(syscall::execve(c_str(path), &args)) as c_int
}
}
pub fn exit(status: c_int) -> ! {
let _ = syscall::exit(status as usize);
loop {}
......
......@@ -44,8 +44,8 @@ pub type c_char = i8;
pub type c_long = i64;
pub type c_ulong = u64;
pub type wchar_t = i16;
pub type wint_t = i32;
pub type wchar_t = i32;
pub type wint_t = u32;
pub type wctype_t = i64;
pub type off_t = i64;
......
*
!.gitignore
......@@ -12,7 +12,7 @@ errno = { path = "../errno"}
fcntl = { path = "../fcntl" }
lazy_static = { version = "*", features = ["nightly", "spin_no_std"] }
platform = { path = "../platform" }
ralloc = { path = "../../ralloc" }
ralloc = { path = "../../ralloc", default-features = false }
string = { path = "../string" }
stdlib = { path = "../stdlib" }
va_list = { path = "../../va_list", features = ["no_std"] }
use super::{BUFSIZ, FILE, UNGET};
use super::{internal, BUFSIZ, FILE, UNGET};
use ralloc;
use core::{mem, ptr};
use core::sync::atomic::AtomicBool;
use platform::types::*;
use super::constants::*;
......@@ -62,8 +64,8 @@ pub unsafe fn _fdopen(fd: c_int, mode: *const c_char) -> Option<*mut FILE> {
flags |= F_APP;
}
let f = ralloc::alloc(mem::size_of::<FILE>(), 1) as *mut FILE;
// Allocate the file
let f = malloc(size_of::<FILE>()) as *mut FILE;
if f.is_null() {
None
} else {
......
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