Add RISC-V port for libgloss

Contributor list:
    - Andrew Waterman  <andrew@sifive.com>
    - Palmer Dabbelt  <palmer@dabbelt.com>
    - Kito Cheng  <kito.cheng@gmail.com>
    - Alex Suykov  <alex.suykov@gmail.com>
This commit is contained in:
Kito Cheng 2017-07-27 16:45:47 +08:00 committed by Jeff Johnston
parent 7040b2de08
commit c496cbb6bd
9 changed files with 4340 additions and 0 deletions

5
libgloss/configure vendored
View File

@ -679,6 +679,7 @@ sparc_leon
sparc
wince
mips
riscv
rs6000
mn10200
mn10300
@ -2455,6 +2456,10 @@ case "${target}" in
mips*-*-*)
subdirs="$subdirs mips"
;;
riscv*-*-*)
subdirs="$subdirs riscv"
;;
powerpc-*-*|powerpcle-*-*)
subdirs="$subdirs rs6000"

View File

@ -78,6 +78,9 @@ case "${target}" in
mips*-*-*)
AC_CONFIG_SUBDIRS([mips])
;;
riscv*-*-*)
AC_CONFIG_SUBDIRS([riscv])
;;
powerpc-*-*|powerpcle-*-*)
AC_CONFIG_SUBDIRS([rs6000])
;;

200
libgloss/riscv/Makefile.in Normal file
View File

@ -0,0 +1,200 @@
#-------------------------------------------------------------------------
# Source files
#-------------------------------------------------------------------------
gloss_hdrs = \
machine/syscall.h \
gloss_srcs = \
syscalls.c \
# Extra files
crt0_asm = crt0.S
# Multilib support variables.
# TOP is used instead of MULTI{BUILD,SRC}TOP.
MULTIDIRS =
MULTISUBDIR =
MULTIDO = true
MULTICLEAN = true
#-------------------------------------------------------------------------
# Basic setup
#-------------------------------------------------------------------------
# Remove all default implicit rules since they can cause subtle bugs
# and they just make things run slower
.SUFFIXES:
% : %,v
% : RCS/%,v
% : RCS/%
% : s.%
% : SCCS/s.%
# Default is to build the prereqs of the all target (defined at bottom)
default : all
.PHONY : default
# Source directory
obj_dir := .
src_dir := @srcdir@
VPATH := $(src_dir) $(src_dir)/machine
# Installation directories
prefix := @prefix@
DESTDIR ?= $(prefix)
install_hdrs_dir := $(DESTDIR)$(prefix)/$(target_alias)/include/machine
install_libs_dir = $(DESTDIR)$(prefix)/$(target_alias)/lib${MULTISUBDIR}
#-------------------------------------------------------------------------
# Programs and flags
#-------------------------------------------------------------------------
# C compiler
CC := @CC@
CFLAGS := @CFLAGS@
CPPFLAGS := -I$(obj_dir) -I$(src_dir)
COMPILE := $(CC) -MMD -MP $(CPPFLAGS) $(CFLAGS)
# Library creation
AR := @AR@
RANLIB := @RANLIB@
# Installation
INSTALL := @INSTALL@
INSTALL_DATA := @INSTALL_DATA@
#-------------------------------------------------------------------------
# Build Object Files from C Source
#-------------------------------------------------------------------------
gloss_c_srcs = $(filter %.c, $(gloss_srcs))
gloss_c_objs = $(patsubst %.c, %.o, $(notdir $(gloss_c_srcs)))
gloss_c_deps = $(patsubst %.c, %.d, $(notdir $(gloss_c_srcs)))
$(gloss_c_objs) : %.o : %.c
$(COMPILE) -c $<
objs += $(gloss_c_objs)
deps += $(gloss_c_deps)
junk += $(gloss_c_deps) $(gloss_c_objs)
#-------------------------------------------------------------------------
# Build Object Files from Assembly Source
#-------------------------------------------------------------------------
gloss_asm_srcs = $(filter %.S, $(gloss_srcs))
gloss_asm_objs = $(patsubst %.S, %.o, $(notdir $(gloss_asm_srcs)))
gloss_asm_deps = $(patsubst %.S, %.d, $(notdir $(gloss_asm_srcs)))
$(gloss_asm_objs) : %.o : %.S
$(COMPILE) -c $<
objs += $(gloss_asm_objs)
deps += $(gloss_asm_deps)
junk += $(gloss_asm_deps) $(gloss_asm_objs)
#-------------------------------------------------------------------------
# Build libgloss.a
#-------------------------------------------------------------------------
gloss_lib = libgloss.a
$(gloss_lib) : $(objs)
$(AR) rcv $@ $^
$(RANLIB) $@
junk += $(gloss_libs)
install_hdrs += $(gloss_hdrs)
install_libs += $(gloss_lib)
#-------------------------------------------------------------------------
# Build crt0.o
#-------------------------------------------------------------------------
crt0_obj = $(patsubst %.S, %.o, $(crt0_asm))
crt0_deps = $(patsubst %.S, %.d, $(crt0_asm))
$(crt0_obj) : %.o : %.S
$(COMPILE) -c $<
deps += $(crt0_deps)
junk += $(crt0_deps) $(crt0_obj)
install_libs += $(crt0_obj)
#-------------------------------------------------------------------------
# Autodependency files
#-------------------------------------------------------------------------
-include $(deps)
deps : $(deps)
.PHONY : deps
#-------------------------------------------------------------------------
# Installation
#-------------------------------------------------------------------------
install_hdrs_wdir += $(addprefix $(src_dir)/, $(install_hdrs))
install-hdrs : $(install_hdrs_wdir)
test -d $(install_hdrs_dir) || mkdir -p $(install_hdrs_dir)
for file in $^; do \
$(INSTALL_DATA) $$file $(install_hdrs_dir)/; \
done
install-libs : $(install_libs)
test -d $(install_libs_dir) || mkdir -p $(install_libs_dir)
for file in $^; do \
$(INSTALL_DATA) $$file $(install_libs_dir)/$$file; \
done
install : install-hdrs install-libs
.PHONY : install install-hdrs install-libs
#-------------------------------------------------------------------------
# Regenerate configure information
#-------------------------------------------------------------------------
configure_prereq = \
$(src_dir)/configure.in \
$(src_dir)/configure : $(configure_prereq)
cd $(src_dir) && autoconf
config.status : $(src_dir)/configure
./config.status --recheck
Makefile : $(src_dir)/Makefile.in config.status
./config.status
dist_junk += config.status Makefile config.log
#-------------------------------------------------------------------------
# Default
#-------------------------------------------------------------------------
all : $(install_libs)
.PHONY : all
#-------------------------------------------------------------------------
# Clean up junk
#-------------------------------------------------------------------------
clean :
rm -rf *~ \#* $(junk)
distclean :
rm -rf *~ \#* $(junk) $(dist_junk)
.PHONY : clean distclean

72
libgloss/riscv/aclocal.m4 vendored Normal file
View File

@ -0,0 +1,72 @@
#=========================================================================
# aclocal.m4 for maven libgloss
#=========================================================================
# We cannot use the normal AC_PROG_CC since that macro will try and do a
# link with the found compiler. Since we don't have all the startup
# files setup yet (that's what we are compiling in libgloss!) we want to
# find a compiler without actually doing a link. So the LIB_AC_PROG_CC
# check is copied from xcc/src/libgloss/acinclude.m4
#-------------------------------------------------------------------------
# LIB_AC_PROG_CC_GNU
#-------------------------------------------------------------------------
AC_DEFUN([LIB_AC_PROG_CC_GNU],
[
AC_CACHE_CHECK(whether we are using GNU C, ac_cv_prog_gcc,
[dnl The semicolon is to pacify NeXT's syntax-checking cpp.
cat > conftest.c <<EOF
#ifdef __GNUC__
yes;
#endif
EOF
if AC_TRY_COMMAND(${CC-cc} -E conftest.c) | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
fi
])
])
#-------------------------------------------------------------------------
# LIB_AC_PROG_CC
#-------------------------------------------------------------------------
AC_DEFUN([LIB_AC_PROG_CC],
[
AC_BEFORE([$0],[AC_PROG_CPP])dnl
AC_CHECK_PROG(CC, gcc, gcc)
if test -z "$CC"; then
AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
fi
LIB_AC_PROG_CC_GNU
if test $ac_cv_prog_gcc = yes; then
GCC=yes
dnl Check whether -g works, even if CFLAGS is set, in case the package
dnl plays around with CFLAGS (such as to build both debugging and
dnl normal versions of a library), tasteless as that idea is.
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
_AC_PROG_CC_G
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
elif test $ac_cv_prog_cc_g = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-O2"
fi
else
GCC=
test "${CFLAGS+set}" = set || CFLAGS="-g"
fi
])

3460
libgloss/riscv/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
#=========================================================================
# configure.ac for riscv libgloss and crt0
#=========================================================================
#-------------------------------------------------------------------------
# Setup
#-------------------------------------------------------------------------
AC_INIT([crt0.S])
AC_CONFIG_SRCDIR([crt0.S])
AC_CONFIG_AUX_DIR([${srcdir}/../..])
#-------------------------------------------------------------------------
# Checks for programs
#-------------------------------------------------------------------------
LIB_AC_PROG_CC
AC_CHECK_TOOL([AR],[ar])
AC_CHECK_TOOL([RANLIB],[ranlib])
AC_PROG_INSTALL
#-------------------------------------------------------------------------
# Output
#-------------------------------------------------------------------------
if test "$srcdir" = "." ; then
if test "${with_target_subdir}" != "." ; then
libgloss_topdir="${srcdir}/${with_multisrctop}../../.."
else
libgloss_topdir="${srcdir}/${with_multisrctop}../.."
fi
else
libgloss_topdir="${srcdir}/../.."
fi
AC_CONFIG_AUX_DIR($libgloss_topdir)
AC_CONFIG_FILES(Makefile,
. ${libgloss_topdir}/config-ml.in,
srcdir=${srcdir}
target=${target}
with_multisubdir=${with_multisubdir}
ac_configure_args="${ac_configure_args} --enable-multilib"
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
libgloss_topdir=${libgloss_topdir}
)
AC_OUTPUT

54
libgloss/riscv/crt0.S Normal file
View File

@ -0,0 +1,54 @@
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
This copyrighted material is made available to anyone wishing to use,
modify, copy, or redistribute it subject to the terms and conditions
of the BSD License. This program is distributed in the hope that
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
including the implied warranties of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. A copy of this license is available at
http://www.opensource.org/licenses.
*/
#=========================================================================
# crt0.S : Entry point for RISC-V user programs
#=========================================================================
.text
.global _start
.type _start, @function
_start:
# Initialize global pointer
.option push
.option norelax
1:auipc gp, %pcrel_hi(__global_pointer$)
addi gp, gp, %pcrel_lo(1b)
.option pop
# Clear the bss segment
la a0, _edata
la a2, _end
sub a2, a2, a0
li a1, 0
call memset
la a0, __libc_fini_array # Register global termination functions
call atexit # to be called upon exit
call __libc_init_array # Run global initialization functions
lw a0, 0(sp) # a0 = argc
addi a1, sp, __SIZEOF_POINTER__ # a1 = argv
li a2, 0 # a2 = envp = NULL
call main
tail exit
.size _start, .-_start
.global _init
.type _init, @function
.global _fini
.type _fini, @function
_init:
_fini:
# These don't have to do anything since we use init_array/fini_array.
ret
.size _init, .-_init
.size _fini, .-_fini

View File

@ -0,0 +1,82 @@
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
This copyrighted material is made available to anyone wishing to use,
modify, copy, or redistribute it subject to the terms and conditions
of the BSD License. This program is distributed in the hope that
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
including the implied warranties of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. A copy of this license is available at
http://www.opensource.org/licenses.
*/
#ifndef _MACHINE_SYSCALL_H
#define _MACHINE_SYSCALL_H
#define SYS_getcwd 17
#define SYS_dup 23
#define SYS_fcntl 25
#define SYS_faccessat 48
#define SYS_chdir 49
#define SYS_openat 56
#define SYS_close 57
#define SYS_getdents 61
#define SYS_lseek 62
#define SYS_read 63
#define SYS_write 64
#define SYS_writev 66
#define SYS_pread 67
#define SYS_pwrite 68
#define SYS_fstatat 79
#define SYS_fstat 80
#define SYS_exit 93
#define SYS_exit_group 94
#define SYS_kill 129
#define SYS_rt_sigaction 134
#define SYS_times 153
#define SYS_uname 160
#define SYS_gettimeofday 169
#define SYS_getpid 172
#define SYS_getuid 174
#define SYS_geteuid 175
#define SYS_getgid 176
#define SYS_getegid 177
#define SYS_brk 214
#define SYS_munmap 215
#define SYS_mremap 216
#define SYS_mmap 222
#define SYS_open 1024
#define SYS_link 1025
#define SYS_unlink 1026
#define SYS_mkdir 1030
#define SYS_access 1033
#define SYS_stat 1038
#define SYS_lstat 1039
#define SYS_time 1062
#define SYS_getmainvars 2011
extern long __syscall_error(long);
static inline long
__internal_syscall(long n, long _a0, long _a1, long _a2, long _a3)
{
register long a0 asm("a0") = _a0;
register long a1 asm("a1") = _a1;
register long a2 asm("a2") = _a2;
register long a3 asm("a3") = _a3;
#ifdef __riscv_32e
register long syscall_id asm("t0") = n;
#else
register long syscall_id asm("a7") = n;
#endif
asm volatile ("scall"
: "+r"(a0) : "r"(a1), "r"(a2), "r"(a3), "r"(syscall_id));
if (a0 < 0)
return __syscall_error (a0);
else
return a0;
}
#endif

419
libgloss/riscv/syscalls.c Normal file
View File

@ -0,0 +1,419 @@
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
This copyrighted material is made available to anyone wishing to use,
modify, copy, or redistribute it subject to the terms and conditions
of the BSD License. This program is distributed in the hope that
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
including the implied warranties of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. A copy of this license is available at
http://www.opensource.org/licenses.
========================================================================
syscalls.c : Newlib operating system interface
========================================================================
This is the maven implementation of the narrow newlib operating
system interface. It is based on the minimum stubs in the newlib
documentation, the error stubs in libnosys, and the previous scale
implementation. Please do not include any additional system calls or
other functions in this file. Additional header and source files
should be in the machine subdirectory.
Here is a list of the functions which make up the operating system
interface. The file management instructions execute syscall assembly
instructions so that a proxy kernel (or the simulator) can marshal up
the request to the host machine. The process management functions are
mainly just stubs since for now maven only supports a single process.
- File management functions
+ open : (v) open file
+ lseek : (v) set position in file
+ read : (v) read from file
+ write : (v) write to file
+ fstat : (z) status of an open file
+ stat : (z) status of a file by name
+ close : (z) close a file
+ link : (z) rename a file
+ unlink : (z) remote file's directory entry
- Process management functions
+ execve : (z) transfer control to new proc
+ fork : (z) create a new process
+ getpid : (v) get process id
+ kill : (z) send signal to child process
+ wait : (z) wait for a child process
- Misc functions
+ isatty : (v) query whether output stream is a terminal
+ times : (z) timing information for current process
+ sbrk : (v) increase program data space
+ _exit : (-) exit program without cleaning up files
There are two types of system calls. Those which return a value when
everything is okay (marked with (v) in above list) and those which
return a zero when everything is okay (marked with (z) in above
list). On an error (ie. when the error flag is 1) the return value is
always an errno which should correspond to the numbers in
newlib/libc/include/sys/errno.h
See the newlib documentation for more information
http://sourceware.org/newlib/libc.html#Syscalls
*/
#include <machine/syscall.h>
#include <sys/stat.h>
#include <sys/times.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>
#include <utime.h>
#define syscall_errno(n, a, b, c, d) \
__internal_syscall(n, (long)(a), (long)(b), (long)(c), (long)(d))
long
__syscall_error(long a0)
{
errno = -a0;
return -1;
}
/* Open a file. */
int
_open(const char *name, int flags, int mode)
{
return syscall_errno (SYS_open, name, flags, mode, 0);
}
/* Open file relative to given directory. */
int
_openat(int dirfd, const char *name, int flags, int mode)
{
return syscall_errno (SYS_openat, dirfd, name, flags, mode);
}
/* Set position in a file. */
off_t
_lseek(int file, off_t ptr, int dir)
{
return syscall_errno (SYS_lseek, file, ptr, dir, 0);
}
/* Read from a file. */
ssize_t
_read(int file, void *ptr, size_t len)
{
return syscall_errno (SYS_read, file, ptr, len, 0);
}
/* Write to a file. */
ssize_t
_write(int file, const void *ptr, size_t len)
{
return syscall_errno (SYS_write, file, ptr, len, 0);
}
struct kernel_stat
{
unsigned long long st_dev;
unsigned long long st_ino;
unsigned int st_mode;
unsigned int st_nlink;
unsigned int st_uid;
unsigned int st_gid;
unsigned long long st_rdev;
unsigned long long __pad1;
long long st_size;
int st_blksize;
int __pad2;
long long st_blocks;
struct timespec st_atim;
struct timespec st_mtim;
struct timespec st_ctim;
int __glibc_reserved[2];
};
/* Convert linux's stat64 sturct to newlib's stat. */
static void
conv_stat (struct stat *st, struct kernel_stat *kst)
{
st->st_dev = kst->st_dev;
st->st_ino = kst->st_ino;
st->st_mode = kst->st_mode;
st->st_nlink = kst->st_nlink;
st->st_uid = kst->st_uid;
st->st_gid = kst->st_gid;
st->st_rdev = kst->st_rdev;
st->st_size = kst->st_size;
st->st_blocks = kst->st_blocks;
st->st_blksize = kst->st_blksize;
st->st_atime = kst->st_atim.tv_sec;
st->st_mtime = kst->st_mtim.tv_sec;
st->st_ctime = kst->st_ctim.tv_sec;
}
/* Status of an open file. The sys/stat.h header file required is
distributed in the include subdirectory for this C library. */
int
_fstat(int file, struct stat *st)
{
struct kernel_stat kst;
int rv = syscall_errno (SYS_fstat, file, &kst, 0, 0);
conv_stat (st, &kst);
return rv;
}
/* Status of a file (by name). */
int
_stat(const char *file, struct stat *st)
{
struct kernel_stat kst;
int rv = syscall_errno (SYS_stat, file, &kst, 0, 0);
conv_stat (st, &kst);
return rv;
}
/* Status of a link (by name). */
int
_lstat(const char *file, struct stat *st)
{
struct kernel_stat kst;
int rv = syscall_errno (SYS_lstat, file, &kst, 0, 0);
conv_stat (st, &kst);
return rv;
}
/* Status of a file (by name) in a given directory. */
int
_fstatat(int dirfd, const char *file, struct stat *st, int flags)
{
struct kernel_stat kst;
int rv = syscall_errno (SYS_fstatat, dirfd, file, &kst, flags);
conv_stat (st, &kst);
return rv;
}
/* Permissions of a file (by name). */
int
_access(const char *file, int mode)
{
return syscall_errno (SYS_access, file, mode, 0, 0);
}
/* Permissions of a file (by name) in a given directory. */
int
_faccessat(int dirfd, const char *file, int mode, int flags)
{
return syscall_errno (SYS_faccessat, dirfd, file, mode, flags);
}
/* Close a file. */
int
_close(int file)
{
return syscall_errno (SYS_close, file, 0, 0, 0);
}
/* Establish a new name for an existing file. */
int
_link(const char *old_name, const char *new_name)
{
return syscall_errno (SYS_link, old_name, new_name, 0, 0);
}
/* Remove a file's directory entry. */
int
_unlink(const char *name)
{
return syscall_errno (SYS_unlink, name, 0, 0, 0);
}
/* Transfer control to a new process. Minimal implementation for a
system without processes from newlib documentation. */
int
_execve(const char *name, char *const argv[], char *const env[])
{
errno = ENOMEM;
return -1;
}
/* Create a new process. Minimal implementation for a system without
processes from newlib documentation. */
int
_fork()
{
errno = EAGAIN;
return -1;
}
/* Get process id. This is sometimes used to generate strings unlikely
to conflict with other processes. Minimal implementation for a
system without processes just returns 1. */
int
_getpid()
{
return 1;
}
/* Send a signal. Minimal implementation for a system without processes
just causes an error. */
int
_kill(int pid, int sig)
{
errno = EINVAL;
return -1;
}
/* Wait for a child process. Minimal implementation for a system without
processes just causes an error. */
int
_wait(int *status)
{
errno = ECHILD;
return -1;
}
/* Query whether output stream is a terminal. For consistency with the
other minimal implementations, which only support output to stdout,
this minimal implementation is suggested by the newlib docs. */
int
_isatty(int file)
{
struct stat s;
int ret = _fstat (file, &s);
return ret == -1 ? -1 : !!(s.st_mode & S_IFCHR);
}
/* Get the current time. Only relatively correct. */
int
_gettimeofday(struct timeval *tp, void *tz)
{
return syscall_errno (SYS_gettimeofday, tp, 0, 0, 0);
}
/* Timing information for current process. From
newlib/libc/include/sys/times.h the tms struct fields are as follows:
- clock_t tms_utime : user clock ticks
- clock_t tms_stime : system clock ticks
- clock_t tms_cutime : children's user clock ticks
- clock_t tms_cstime : children's system clock ticks
Since maven does not currently support processes we set both of the
children's times to zero. Eventually we might want to separately
account for user vs system time, but for now we just return the total
number of cycles since starting the program. */
clock_t
_times(struct tms *buf)
{
// when called for the first time, initialize t0
static struct timeval t0;
if(t0.tv_sec == 0)
_gettimeofday (&t0,0);
struct timeval t;
_gettimeofday (&t, 0);
long long utime = (t.tv_sec - t0.tv_sec) * 1000000 + (t.tv_usec - t0.tv_usec);
buf->tms_utime = utime * CLOCKS_PER_SEC / 1000000;
buf->tms_stime = buf->tms_cstime = buf->tms_cutime = 0;
return -1;
}
/* Get the current time. Only relatively correct. */
int
_ftime(struct timeb *tp)
{
tp->time = tp->millitm = 0;
return 0;
}
/* Stub. */
int
_utime(const char *path, const struct utimbuf *times)
{
return -1;
}
/* Stub. */
int
_chown(const char *path, uid_t owner, gid_t group)
{
return -1;
}
/* Stub. */
int
_chmod(const char *path, mode_t mode)
{
return -1;
}
/* Stub. */
int
_chdir(const char *path)
{
return -1;
}
/* Stub. */
char *
_getcwd(char *buf, size_t size)
{
return NULL;
}
/* Get configurable system variables. */
long
_sysconf(int name)
{
switch (name)
{
case _SC_CLK_TCK:
return CLOCKS_PER_SEC;
}
return -1;
}
/* Increase program data space. As malloc and related functions depend
on this, it is useful to have a working implementation. The following
is suggested by the newlib docs and suffices for a standalone
system. */
void *
_sbrk(ptrdiff_t incr)
{
static unsigned long heap_end;
if (heap_end == 0)
{
long brk = syscall_errno (SYS_brk, 0, 0, 0, 0);
if (brk == -1)
return (void *)-1;
heap_end = brk;
}
if (syscall_errno (SYS_brk, heap_end + incr, 0, 0, 0) != heap_end + incr)
return (void *)-1;
heap_end += incr;
return (void *)(heap_end - incr);
}
/* Exit a program without cleaning up files. */
void
_exit(int exit_status)
{
syscall_errno (SYS_exit, exit_status, 0, 0, 0);
while (1);
}