From f7fc9ef51051490b8b3639f2e6eac7831118110a Mon Sep 17 00:00:00 2001 From: Max Wash Date: Fri, 1 May 2020 20:39:22 +0100 Subject: [PATCH] Small changes to Magenta sys files --- photon/libc/include/stddef.h | 5 ----- photon/libc/sys/magenta/fio.c | 4 ++-- photon/libc/sys/magenta/sys/types.h | 10 ++++++++-- photon/libc/sys/magenta/system.c | 4 +--- scripts/create-sysroot.sh | 24 ++++++++++++++++++++---- 5 files changed, 31 insertions(+), 16 deletions(-) diff --git a/photon/libc/include/stddef.h b/photon/libc/include/stddef.h index 591a8ae..f4f764d 100644 --- a/photon/libc/include/stddef.h +++ b/photon/libc/include/stddef.h @@ -20,11 +20,6 @@ typedef __intptr_t ptrdiff_t; typedef __uintptr_t size_t; #endif -#ifndef __ssize_t_defined -#define __ssize_t_defined -typedef __intptr_t ssize_t; -#endif - #if defined(__cplusplus) } #endif /* defined(__cplusplus) */ diff --git a/photon/libc/sys/magenta/fio.c b/photon/libc/sys/magenta/fio.c index c85b78b..214e43f 100644 --- a/photon/libc/sys/magenta/fio.c +++ b/photon/libc/sys/magenta/fio.c @@ -1,6 +1,6 @@ +#include "sys/types.h" #include "__fio.h" #include "__syscall.h" -#include "unistd.h" struct __io_file __stdin = {}; struct __io_file __stdout = {}; @@ -38,7 +38,7 @@ unsigned int __fio_write(struct __io_file *f, const char *buf, unsigned int sz) unsigned int __fio_flush(struct __io_file *f) { ssize_t res = 0;//write(f->fd, f->buf, f->buf_idx); - if (res != f->buf_idx) { + if ((size_t)res != f->buf_idx) { f->err = 1; } diff --git a/photon/libc/sys/magenta/sys/types.h b/photon/libc/sys/magenta/sys/types.h index d0fcbfb..19912c9 100644 --- a/photon/libc/sys/magenta/sys/types.h +++ b/photon/libc/sys/magenta/sys/types.h @@ -24,9 +24,15 @@ typedef unsigned int uid_t; typedef unsigned long useconds_t; typedef unsigned long long dev_t; -#ifndef __SIZE_T_DEFINED +#ifndef __size_t_DEFINED typedef __uintptr_t size_t; -#define __SIZE_T_DEFINED +#define __size_t_DEFINED #endif +#ifndef __ssize_t_defined +#define __ssize_t_defined +typedef __intptr_t ssize_t; +#endif + + #endif diff --git a/photon/libc/sys/magenta/system.c b/photon/libc/sys/magenta/system.c index d9025ad..f3ba3d4 100644 --- a/photon/libc/sys/magenta/system.c +++ b/photon/libc/sys/magenta/system.c @@ -1,7 +1,5 @@ -#include "unistd.h" - _Noreturn void __exit(int code) { - _exit(code); + /* TODO Exit syscall */ while (1) {} } diff --git a/scripts/create-sysroot.sh b/scripts/create-sysroot.sh index 4f18971..05b2fc0 100755 --- a/scripts/create-sysroot.sh +++ b/scripts/create-sysroot.sh @@ -16,12 +16,28 @@ platform_sys_headers=$(find $source_dir/photon/libc/sys/$platform/sys \ -maxdepth 1 -type f \( -iname "*.h" ! -iname "__*" \)) platform_sys_arch_headers=$(find $source_dir/photon/libc/sys/$platform/machine/$machine \ -maxdepth 1 -type f \( -iname "*.h" ! -iname "__*" \)) -cp -t $build_dir/sysroot/usr/include $platform_headers -cp -t $build_dir/sysroot/usr/include/sys $platform_sys_headers -cp -t $build_dir/sysroot/usr/include/sys $platform_sys_arch_headers + +if [ ! -z "$platform_headers" ]; then + cp -t $build_dir/sysroot/usr/include $platform_headers +fi + +if [ ! -z "$platform_sys_headers" ]; then + cp -t $build_dir/sysroot/usr/include/sys $platform_sys_headers +fi + +if [ ! -z "$platform_sys_arch_headers" ]; then + cp -t $build_dir/sysroot/usr/include/sys $platform_sys_arch_headers +fi machine_arch_headers=$(find $source_dir/photon/libc/machine/$machine/ \ -type f \( -iname "*.h" ! -iname "__*" \)) machine_generic_headers=$(find $source_dir/photon/libc/include/machine/ \ -type f \( -iname "*.h" ! -iname "__*" \)) -cp -t $build_dir/sysroot/usr/include/machine $machine_generic_headers $machine_arch_headers + +if [ ! -z "$machine_generic_headers" ]; then + cp -t $build_dir/sysroot/usr/include/machine $machine_generic_headers +fi + +if [ ! -z "$machine_arch_headers" ]; then + cp -t $build_dir/sysroot/usr/include/machine $machine_arch_headers +fi