From ee82c8a9b1e1cad32e1493f01a55bcdbd472dd2d Mon Sep 17 00:00:00 2001 From: hzc1998 <2323168280@qq.com> Date: Tue, 25 Oct 2022 00:58:33 +0800 Subject: [PATCH 01/11] refactor(fs): update fs name --- src/process/system.c | 2 +- src/stdio/__fmodeflags.c | 16 ++++++++-------- src/stdio/__fopen_rb_ca.c | 2 +- src/stdio/__init_stdio.c | 6 +++--- src/stdio/__stdio_seek.c | 2 +- src/stdio/freopen.c | 2 +- src/stdio/remove.c | 2 +- src/stdio/rename.c | 2 +- src/stdio/tmpfile.c | 4 ++-- src/stdio/tmpnam.c | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/process/system.c b/src/process/system.c index f2e39b0..196af21 100644 --- a/src/process/system.c +++ b/src/process/system.c @@ -6,7 +6,7 @@ int system(const char *cmd) { NX_Error err; - char appPath[NX_VFS_MAX_NAME] = {0}; + char appPath[NX_FILE_MAX_NAME] = {0}; char *spacePos; char * cmdline = (char *)cmd; NX_U32 exitCode; diff --git a/src/stdio/__fmodeflags.c b/src/stdio/__fmodeflags.c index 3832dc6..0d1f7e0 100644 --- a/src/stdio/__fmodeflags.c +++ b/src/stdio/__fmodeflags.c @@ -4,13 +4,13 @@ int __fmodeflags(const char *mode) { int flags; - if (strchr(mode, '+')) flags = NX_VFS_O_RDWR; - else if (*mode == 'r') flags = NX_VFS_O_RDONLY; - else flags = NX_VFS_O_WRONLY; - if (strchr(mode, 'x')) flags |= NX_VFS_O_EXCL; - //FIXME: if (strchr(mode, 'e')) flags |= NX_VFS_O_CLOEXEC; - if (*mode != 'r') flags |= NX_VFS_O_CREAT; - if (*mode == 'w') flags |= NX_VFS_O_TRUNC; - if (*mode == 'a') flags |= NX_VFS_O_APPEND; + if (strchr(mode, '+')) flags = NX_FILE_RDWR; + else if (*mode == 'r') flags = NX_FILE_RDONLY; + else flags = NX_FILE_WRONLY; + if (strchr(mode, 'x')) flags |= NX_FILE_EXCL; + //FIXME: if (strchr(mode, 'e')) flags |= NX_FILE_CLOEXEC; + if (*mode != 'r') flags |= NX_FILE_CREAT; + if (*mode == 'w') flags |= NX_FILE_TRUNC; + if (*mode == 'a') flags |= NX_FILE_APPEND; return flags; } diff --git a/src/stdio/__fopen_rb_ca.c b/src/stdio/__fopen_rb_ca.c index 6075abd..e3f7176 100644 --- a/src/stdio/__fopen_rb_ca.c +++ b/src/stdio/__fopen_rb_ca.c @@ -6,7 +6,7 @@ FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t le { memset(f, 0, sizeof *f); - f->fd = NX_FileOpen(filename, NX_VFS_O_RDONLY, 0666); + f->fd = NX_FileOpen(filename, NX_FILE_RDONLY, 0666); if (f->fd < 0) return 0; f->flags = F_NOWR | F_PERM; diff --git a/src/stdio/__init_stdio.c b/src/stdio/__init_stdio.c index 18918bf..342f044 100644 --- a/src/stdio/__init_stdio.c +++ b/src/stdio/__init_stdio.c @@ -5,12 +5,12 @@ void __init_stdio(void) { /* open stdio device */ - stdin->fd = NX_FileOpen("/dev/console", NX_VFS_O_RDONLY, 0666); + stdin->fd = NX_FileOpen("/dev/console", NX_FILE_RDONLY, 0666); assert(stdin->fd >= 0); - stdout->fd = NX_FileOpen("/dev/console", NX_VFS_O_WRONLY, 0666); + stdout->fd = NX_FileOpen("/dev/console", NX_FILE_WRONLY, 0666); assert(stdout->fd >= 0); - stderr->fd = NX_FileOpen("/dev/console", NX_VFS_O_WRONLY, 0666); + stderr->fd = NX_FileOpen("/dev/console", NX_FILE_WRONLY, 0666); assert(stderr->fd >= 0); /* no buffer for stdin & stdout */ diff --git a/src/stdio/__stdio_seek.c b/src/stdio/__stdio_seek.c index 00f8dc1..0c05145 100644 --- a/src/stdio/__stdio_seek.c +++ b/src/stdio/__stdio_seek.c @@ -3,5 +3,5 @@ off_t __stdio_seek(FILE *f, off_t off, int whence) { - return NX_FileSeek(f->fd, off, whence); + return NX_FileSetPointer(f->fd, off, whence); } diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index 11b8faf..4758539 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -19,7 +19,7 @@ FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *re fflush(f); if (!filename) { - fl &= ~(NX_VFS_O_CREAT|NX_VFS_O_EXCL); + fl &= ~(NX_FILE_CREAT|NX_FILE_EXCL); } else { f2 = fopen(filename, mode); if (!f2) goto fail; diff --git a/src/stdio/remove.c b/src/stdio/remove.c index 4580575..c2ee859 100644 --- a/src/stdio/remove.c +++ b/src/stdio/remove.c @@ -4,5 +4,5 @@ int remove(const char *path) { - return NX_PathUnlink(path) == NX_EOK ? 0 : -1; + return NX_FileDelete(path) == NX_EOK ? 0 : -1; } diff --git a/src/stdio/rename.c b/src/stdio/rename.c index 14a0a48..f2383c1 100644 --- a/src/stdio/rename.c +++ b/src/stdio/rename.c @@ -3,5 +3,5 @@ int rename(const char *old, const char *new) { - return NX_PathRename(old, new) == NX_EOK ? 0 : -1; + return NX_FileRename(old, new) == NX_EOK ? 0 : -1; } diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c index 73d4020..7309ff9 100644 --- a/src/stdio/tmpfile.c +++ b/src/stdio/tmpfile.c @@ -13,9 +13,9 @@ FILE *tmpfile(void) int try; for (try=0; try= 0) { - NX_PathUnlink(s); + NX_FileDelete(s); f = __fdopen(fd, "w+"); if (!f) NX_FileClose(fd); return f; diff --git a/src/stdio/tmpnam.c b/src/stdio/tmpnam.c index f772466..6d7cdac 100644 --- a/src/stdio/tmpnam.c +++ b/src/stdio/tmpnam.c @@ -15,8 +15,8 @@ char *tmpnam(char *buf) for (try=0; try Date: Wed, 26 Oct 2022 02:26:15 +0800 Subject: [PATCH 02/11] fix(stdio): func NX_FileClose not found in fopen --- src/stdio/fopen.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index a6154a8..4eccc0a 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -1,6 +1,7 @@ #include "stdio_impl.h" #include #include +#include FILE *fopen(const char *restrict filename, const char *restrict mode) { -- Gitee From 4011c36c2a23518bd221812764dbefad250518cb Mon Sep 17 00:00:00 2001 From: hzc1998 <2323168280@qq.com> Date: Sat, 29 Oct 2022 01:12:16 +0800 Subject: [PATCH 03/11] fix(time): use time stamp for time --- src/time/time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/time/time.c b/src/time/time.c index 98bd1e5..465371b 100644 --- a/src/time/time.c +++ b/src/time/time.c @@ -13,8 +13,8 @@ time_t time(time_t * t) NX_Time nxtm; NX_TimeGet(&nxtm); - tm.tm_year = nxtm.year - 1900; /* start from */ - tm.tm_mon = nxtm.month - 1; + tm.tm_year = nxtm.year; + tm.tm_mon = nxtm.month; tm.tm_mday = nxtm.day; tm.tm_hour = nxtm.hour; tm.tm_min = nxtm.minute; -- Gitee From e67ef0df4dfcf943bc722414c0542eaedbc36330 Mon Sep 17 00:00:00 2001 From: hzc1998 <2323168280@qq.com> Date: Sat, 29 Oct 2022 15:10:06 +0800 Subject: [PATCH 04/11] feat(stdio): update open file mode --- src/stdio/__fopen_rb_ca.c | 2 +- src/stdio/__init_stdio.c | 6 +++--- src/stdio/fopen.c | 2 +- src/stdio/tmpfile.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/stdio/__fopen_rb_ca.c b/src/stdio/__fopen_rb_ca.c index e3f7176..d0b7314 100644 --- a/src/stdio/__fopen_rb_ca.c +++ b/src/stdio/__fopen_rb_ca.c @@ -6,7 +6,7 @@ FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t le { memset(f, 0, sizeof *f); - f->fd = NX_FileOpen(filename, NX_FILE_RDONLY, 0666); + f->fd = NX_FileOpen(filename, NX_FILE_RDONLY, 0); if (f->fd < 0) return 0; f->flags = F_NOWR | F_PERM; diff --git a/src/stdio/__init_stdio.c b/src/stdio/__init_stdio.c index 342f044..6d4229f 100644 --- a/src/stdio/__init_stdio.c +++ b/src/stdio/__init_stdio.c @@ -5,12 +5,12 @@ void __init_stdio(void) { /* open stdio device */ - stdin->fd = NX_FileOpen("/dev/console", NX_FILE_RDONLY, 0666); + stdin->fd = NX_FileOpen("/dev/console", NX_FILE_RDONLY, 0); assert(stdin->fd >= 0); - stdout->fd = NX_FileOpen("/dev/console", NX_FILE_WRONLY, 0666); + stdout->fd = NX_FileOpen("/dev/console", NX_FILE_WRONLY, 0); assert(stdout->fd >= 0); - stderr->fd = NX_FileOpen("/dev/console", NX_FILE_WRONLY, 0666); + stderr->fd = NX_FileOpen("/dev/console", NX_FILE_WRONLY, 0); assert(stderr->fd >= 0); /* no buffer for stdin & stdout */ diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index 4eccc0a..344db03 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -18,7 +18,7 @@ FILE *fopen(const char *restrict filename, const char *restrict mode) /* Compute the flags to pass to open() */ flags = __fmodeflags(mode); - fd = NX_FileOpen(filename, flags, 0666); + fd = NX_FileOpen(filename, flags, NX_FILE_MODE_READ | NX_FILE_MODE_WRITE); if (fd < 0) return 0; f = __fdopen(fd, mode); diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c index 7309ff9..10acfff 100644 --- a/src/stdio/tmpfile.c +++ b/src/stdio/tmpfile.c @@ -13,7 +13,7 @@ FILE *tmpfile(void) int try; for (try=0; try= 0) { NX_FileDelete(s); f = __fdopen(fd, "w+"); -- Gitee From 79900185483787714c103209bcd8e924d4209014 Mon Sep 17 00:00:00 2001 From: Jasonhu <2323168280@qq.com> Date: Sun, 13 Nov 2022 22:35:33 +0800 Subject: [PATCH 05/11] feat(stdio): update io device path --- src/stdio/__init_stdio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stdio/__init_stdio.c b/src/stdio/__init_stdio.c index 6d4229f..20faf29 100644 --- a/src/stdio/__init_stdio.c +++ b/src/stdio/__init_stdio.c @@ -5,12 +5,12 @@ void __init_stdio(void) { /* open stdio device */ - stdin->fd = NX_FileOpen("/dev/console", NX_FILE_RDONLY, 0); + stdin->fd = NX_FileOpen("/Objects/Device/console", NX_FILE_RDONLY, 0); assert(stdin->fd >= 0); - stdout->fd = NX_FileOpen("/dev/console", NX_FILE_WRONLY, 0); + stdout->fd = NX_FileOpen("/Objects/Device/console", NX_FILE_WRONLY, 0); assert(stdout->fd >= 0); - stderr->fd = NX_FileOpen("/dev/console", NX_FILE_WRONLY, 0); + stderr->fd = NX_FileOpen("/Objects/Device/console", NX_FILE_WRONLY, 0); assert(stderr->fd >= 0); /* no buffer for stdin & stdout */ -- Gitee From a258c633114766975d3b3d7c2ee1581c6da1757e Mon Sep 17 00:00:00 2001 From: Jasonhu <2323168280@qq.com> Date: Mon, 14 Nov 2022 23:00:52 +0800 Subject: [PATCH 06/11] feat: update device path --- src/stdio/__init_stdio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/stdio/__init_stdio.c b/src/stdio/__init_stdio.c index 20faf29..65011f0 100644 --- a/src/stdio/__init_stdio.c +++ b/src/stdio/__init_stdio.c @@ -5,12 +5,12 @@ void __init_stdio(void) { /* open stdio device */ - stdin->fd = NX_FileOpen("/Objects/Device/console", NX_FILE_RDONLY, 0); + stdin->fd = NX_FileOpen("/System/Device/console", NX_FILE_RDONLY, 0); assert(stdin->fd >= 0); - stdout->fd = NX_FileOpen("/Objects/Device/console", NX_FILE_WRONLY, 0); + stdout->fd = NX_FileOpen("/System/Device/console", NX_FILE_WRONLY, 0); assert(stdout->fd >= 0); - stderr->fd = NX_FileOpen("/Objects/Device/console", NX_FILE_WRONLY, 0); + stderr->fd = NX_FileOpen("/System/Device/console", NX_FILE_WRONLY, 0); assert(stderr->fd >= 0); /* no buffer for stdin & stdout */ -- Gitee From 17aee4c66e392df4afd1959b15d1455582ec6c5a Mon Sep 17 00:00:00 2001 From: Jasonhu <2323168280@qq.com> Date: Thu, 17 Nov 2022 03:12:30 +0800 Subject: [PATCH 07/11] feat: rename nxbase as nxos --- Makefile | 21 +++++++++++---------- README.md | 2 +- setup.bat | 2 +- setup.sh | 2 +- src/Makefile | 11 ++++------- src/env/__libc_start_main.c | 2 +- src/errno/errno.c | 2 +- src/exit/_Exit.c | 2 +- src/exit/abort.c | 2 +- src/include/signal.h | 2 +- src/internal/locale_impl.h | 2 +- src/process/system.c | 2 +- src/stdio/__fmodeflags.c | 2 +- src/stdio/__fopen_rb_ca.c | 2 +- src/stdio/__init_stdio.c | 2 +- src/stdio/__stdio_close.c | 2 +- src/stdio/__stdio_read.c | 2 +- src/stdio/__stdio_seek.c | 2 +- src/stdio/__stdio_write.c | 2 +- src/stdio/__towrite.c | 2 +- src/stdio/fopen.c | 2 +- src/stdio/freopen.c | 2 +- src/stdio/remove.c | 2 +- src/stdio/rename.c | 2 +- src/stdio/tmpfile.c | 2 +- src/stdio/tmpnam.c | 2 +- src/stdlib/malloc.c | 2 +- src/temp/__randname.c | 2 +- src/time/clock.c | 2 +- src/time/time.c | 2 +- src/time/timespec_get.c | 2 +- 31 files changed, 44 insertions(+), 46 deletions(-) diff --git a/Makefile b/Makefile index 58c6db4..4d86f76 100644 --- a/Makefile +++ b/Makefile @@ -12,14 +12,15 @@ MAKE :=make CP :=cp -SDK_DIR := ./sdk +SDK_DIR := ../sdk SDK_INC_DIR := $(SDK_DIR)/include SDK_LIB_DIR := $(SDK_DIR)/lib -LIBNXBASE_NAME := libnxbase.a -LIBNXBASE_DIR := ../nxos-baselib -LIBNXBASE_LIB_DIR := $(LIBNXBASE_DIR)/build/ -LIBNXBASE_INC_DIR := $(LIBNXBASE_DIR)/src/include +LIBXLIBC_NAME := libxlibc.a +LIBXLIBC_LIB_DIR := ./build/ +LIBXLIBC_INC_DIR := ./src/include +LIBXLIBC_ARCH_INC_DIR := ./src/arch/$(ARCH)/include +LIBXLIBC_GENERIC_INC_DIR := ./src/arch/generic # # Cmds @@ -32,8 +33,8 @@ all: clean: @$(MAKE) -s -C src clean O=../build -# update lib -ulib: - @$(CP) $(LIBNXBASE_LIB_DIR)/$(LIBNXBASE_NAME) $(SDK_LIB_DIR) - @$(CP) -r $(LIBNXBASE_INC_DIR)/* $(SDK_INC_DIR) - @echo copy user lib done. +install: + @$(CP) $(LIBXLIBC_LIB_DIR)/$(LIBXLIBC_NAME) $(SDK_LIB_DIR) + @$(CP) -r $(LIBXLIBC_INC_DIR)/* $(SDK_INC_DIR) + @$(CP) -r $(LIBXLIBC_ARCH_INC_DIR)/* $(SDK_INC_DIR) + @$(CP) -r $(LIBXLIBC_GENERIC_INC_DIR)/* $(SDK_INC_DIR) diff --git a/README.md b/README.md index da67ba7..7d3e058 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ setup.bat # windows环境,默认x86 source setup.sh # linux环境 setup.bat riscv64 # windows环境 source setup.sh riscv64 # linux环境 -# 2. 更新nxbase基础库 +# 2. 更新nxos基础库 make ulib # 3. 编译库 make diff --git a/setup.bat b/setup.bat index fa89774..4a8b671 100644 --- a/setup.bat +++ b/setup.bat @@ -37,7 +37,7 @@ if "%def_arch%" == "x86" ( echo Set environment for xlibc. echo [CROSS COMPILE ] %CROSS_COMPILE% echo [ARCH ] %def_arch% -echo [NXBASE ARCH ] %ARCH% +echo [NXOS ARCH ] %ARCH% :end @echo on diff --git a/setup.sh b/setup.sh index 9ddea27..43151df 100755 --- a/setup.sh +++ b/setup.sh @@ -53,4 +53,4 @@ esac echo "Set environment for for xlibc." echo [CROSS COMPILE ] $CROSS_COMPILE echo [ARCH ] $def_arch -echo [NXBASE ARCH ] $ARCH +echo [NXOS ARCH ] $ARCH diff --git a/src/Makefile b/src/Makefile index 2e78b04..b34a71a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,7 +2,7 @@ sinclude ../scripts/xbuild/env.mk # we have build dir, so need double last level LINK_ROOT_PATH := ../.. -COMPILE_ROOT_PATH := .. +COMPILE_ROOT_PATH := ../.. ARCH ?= x86 @@ -33,15 +33,12 @@ X_LDFLAGS += -T $(LINK_ROOT_PATH)/ldscripts/$(ARCH).ld LINK_SDK_DIR := $(LINK_ROOT_PATH)/sdk COMPILE_SDK_DIR := $(COMPILE_ROOT_PATH)/sdk -LIBS_DIR := $(LINK_SDK_DIR)/lib - X_INCDIRS := include arch/$(ARCH)/include $(COMPILE_SDK_DIR)/include internal X_INCDIRS += arch/generic +X_LIBDIRS := $(LINK_SDK_DIR)/lib -X_LIBDIRS := $(LIBS_DIR) - -# we must link nxbase lib. -X_LIBS += libnxbase.a +# we must link nxos lib. +X_LIBS += libnxos.a SRC += multibyte/ SRC += time/ diff --git a/src/env/__libc_start_main.c b/src/env/__libc_start_main.c index 236e4eb..216e9df 100644 --- a/src/env/__libc_start_main.c +++ b/src/env/__libc_start_main.c @@ -1,4 +1,4 @@ -#include +#include #include #include #include "stdio_impl.h" diff --git a/src/errno/errno.c b/src/errno/errno.c index 3cbea15..934ddd1 100644 --- a/src/errno/errno.c +++ b/src/errno/errno.c @@ -1,5 +1,5 @@ #include -#include +#include int *__errno_location(void) { diff --git a/src/exit/_Exit.c b/src/exit/_Exit.c index a01c356..96f02bf 100644 --- a/src/exit/_Exit.c +++ b/src/exit/_Exit.c @@ -1,5 +1,5 @@ #include -#include +#include _Noreturn void _Exit(int ec) { diff --git a/src/exit/abort.c b/src/exit/abort.c index 1ad3566..9ef2b7f 100644 --- a/src/exit/abort.c +++ b/src/exit/abort.c @@ -1,5 +1,5 @@ #include -#include +#include _Noreturn void abort(void) { diff --git a/src/include/signal.h b/src/include/signal.h index bb372b0..d086e58 100644 --- a/src/include/signal.h +++ b/src/include/signal.h @@ -1,7 +1,7 @@ #ifndef _SIGNAL_H #define _SIGNAL_H -#include +#include #ifdef __cplusplus extern "C" { diff --git a/src/internal/locale_impl.h b/src/internal/locale_impl.h index b037185..1a3dabf 100644 --- a/src/internal/locale_impl.h +++ b/src/internal/locale_impl.h @@ -4,7 +4,7 @@ #include #include #include "libc.h" -#include +#include #define LOCALE_NAME_MAX 23 diff --git a/src/process/system.c b/src/process/system.c index 196af21..a02aa4f 100644 --- a/src/process/system.c +++ b/src/process/system.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include "libc.h" int system(const char *cmd) diff --git a/src/stdio/__fmodeflags.c b/src/stdio/__fmodeflags.c index 0d1f7e0..8117a5f 100644 --- a/src/stdio/__fmodeflags.c +++ b/src/stdio/__fmodeflags.c @@ -1,4 +1,4 @@ -#include +#include #include int __fmodeflags(const char *mode) diff --git a/src/stdio/__fopen_rb_ca.c b/src/stdio/__fopen_rb_ca.c index d0b7314..81f6b49 100644 --- a/src/stdio/__fopen_rb_ca.c +++ b/src/stdio/__fopen_rb_ca.c @@ -1,6 +1,6 @@ #include "stdio_impl.h" #include -#include +#include FILE *__fopen_rb_ca(const char *filename, FILE *f, unsigned char *buf, size_t len) { diff --git a/src/stdio/__init_stdio.c b/src/stdio/__init_stdio.c index 65011f0..8a2c35b 100644 --- a/src/stdio/__init_stdio.c +++ b/src/stdio/__init_stdio.c @@ -1,4 +1,4 @@ -#include +#include #include #include "stdio_impl.h" diff --git a/src/stdio/__stdio_close.c b/src/stdio/__stdio_close.c index 44502b8..58e2ae2 100644 --- a/src/stdio/__stdio_close.c +++ b/src/stdio/__stdio_close.c @@ -1,5 +1,5 @@ #include "stdio_impl.h" -#include +#include static int dummy(int fd) { diff --git a/src/stdio/__stdio_read.c b/src/stdio/__stdio_read.c index 62da921..5954c12 100644 --- a/src/stdio/__stdio_read.c +++ b/src/stdio/__stdio_read.c @@ -1,5 +1,5 @@ #include "stdio_impl.h" -#include +#include struct iovec { void *iov_base; /* starting address of buffer */ diff --git a/src/stdio/__stdio_seek.c b/src/stdio/__stdio_seek.c index 0c05145..eecd42f 100644 --- a/src/stdio/__stdio_seek.c +++ b/src/stdio/__stdio_seek.c @@ -1,5 +1,5 @@ #include "stdio_impl.h" -#include +#include off_t __stdio_seek(FILE *f, off_t off, int whence) { diff --git a/src/stdio/__stdio_write.c b/src/stdio/__stdio_write.c index f9fa660..05f598c 100644 --- a/src/stdio/__stdio_write.c +++ b/src/stdio/__stdio_write.c @@ -1,5 +1,5 @@ #include "stdio_impl.h" -#include +#include struct iovec { void *iov_base; /* starting address of buffer */ diff --git a/src/stdio/__towrite.c b/src/stdio/__towrite.c index d2931a0..23ba3fd 100644 --- a/src/stdio/__towrite.c +++ b/src/stdio/__towrite.c @@ -1,5 +1,5 @@ #include "stdio_impl.h" -#include +#include int __towrite(FILE *f) { diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index 344db03..5347162 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -1,7 +1,7 @@ #include "stdio_impl.h" #include #include -#include +#include FILE *fopen(const char *restrict filename, const char *restrict mode) { diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index 4758539..1b079dd 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -1,5 +1,5 @@ #include "stdio_impl.h" -#include +#include /* The basic idea of this implementation is to open a new FILE, * hack the necessary parts of the new FILE into the old one, then diff --git a/src/stdio/remove.c b/src/stdio/remove.c index c2ee859..1fa7dbc 100644 --- a/src/stdio/remove.c +++ b/src/stdio/remove.c @@ -1,6 +1,6 @@ #include #include -#include +#include int remove(const char *path) { diff --git a/src/stdio/rename.c b/src/stdio/rename.c index f2383c1..5e1bfec 100644 --- a/src/stdio/rename.c +++ b/src/stdio/rename.c @@ -1,5 +1,5 @@ #include -#include +#include int rename(const char *old, const char *new) { diff --git a/src/stdio/tmpfile.c b/src/stdio/tmpfile.c index 10acfff..beeca4d 100644 --- a/src/stdio/tmpfile.c +++ b/src/stdio/tmpfile.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include "stdio_impl.h" diff --git a/src/stdio/tmpnam.c b/src/stdio/tmpnam.c index 6d7cdac..123c6d6 100644 --- a/src/stdio/tmpnam.c +++ b/src/stdio/tmpnam.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include #define MAXTRIES 100 diff --git a/src/stdlib/malloc.c b/src/stdlib/malloc.c index fffb96b..a94477a 100644 --- a/src/stdlib/malloc.c +++ b/src/stdlib/malloc.c @@ -1,5 +1,5 @@ #include -#include +#include void* malloc( size_t size ) { diff --git a/src/temp/__randname.c b/src/temp/__randname.c index a719fec..4ba333e 100644 --- a/src/temp/__randname.c +++ b/src/temp/__randname.c @@ -1,5 +1,5 @@ #include -#include +#include /* This assumes that a check for the template size has already been made */ diff --git a/src/time/clock.c b/src/time/clock.c index 90c9cbf..774cd2a 100644 --- a/src/time/clock.c +++ b/src/time/clock.c @@ -1,6 +1,6 @@ #include #include -#include +#include clock_t clock(void) { diff --git a/src/time/time.c b/src/time/time.c index 465371b..d1b1a81 100644 --- a/src/time/time.c +++ b/src/time/time.c @@ -3,7 +3,7 @@ */ #include -#include +#include #include "time_impl.h" time_t time(time_t * t) diff --git a/src/time/timespec_get.c b/src/time/timespec_get.c index 0476877..a09a10e 100644 --- a/src/time/timespec_get.c +++ b/src/time/timespec_get.c @@ -1,5 +1,5 @@ #include -#include +#include /* There is no other implemented value than TIME_UTC; all other values * are considered erroneous. */ -- Gitee From 21f6b43c85981037f711e476cbc1f8fb6334b413 Mon Sep 17 00:00:00 2001 From: Jasonhu <2323168280@qq.com> Date: Sun, 27 Nov 2022 17:31:37 +0800 Subject: [PATCH 08/11] feat: update exec api --- src/process/system.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/process/system.c b/src/process/system.c index a02aa4f..4d2e443 100644 --- a/src/process/system.c +++ b/src/process/system.c @@ -5,7 +5,7 @@ int system(const char *cmd) { - NX_Error err; + NX_Solt solt; char appPath[NX_FILE_MAX_NAME] = {0}; char *spacePos; char * cmdline = (char *)cmd; @@ -32,8 +32,8 @@ int system(const char *cmd) NX_StrCopyN(appPath, cmdline, spacePos - cmdline + 1); } - err = NX_ProcessLaunch(appPath, NX_PROC_FLAG_WAIT, &exitCode, cmdline, libc.envline); - if (err != NX_EOK) + solt = NX_ProcessLaunch(appPath, NX_THREAD_CREATE_WAIT, &exitCode, cmdline, libc.envline); + if (solt == NX_SOLT_INVALID_VALUE) { return -1; } -- Gitee From 5bf5b78b1aeacf8fe9a4d05013b606fc445c1a4d Mon Sep 17 00:00:00 2001 From: Jasonhu <2323168280@qq.com> Date: Thu, 8 Dec 2022 22:57:16 +0800 Subject: [PATCH 09/11] feat(exit): print assert info --- src/exit/assert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/exit/assert.c b/src/exit/assert.c index 79d4495..94edd82 100644 --- a/src/exit/assert.c +++ b/src/exit/assert.c @@ -3,6 +3,6 @@ _Noreturn void __assert_fail(const char *expr, const char *file, int line, const char *func) { - // fprintf(stderr, "Assertion failed: %s (%s: %s: %d)\n", expr, file, func, line); + fprintf(stderr, "Assertion failed: %s (%s: %s: %d)\n", expr, file, func, line); abort(); } -- Gitee From 1d94515d6a5d1e23c22a70570a2b5c1be311b141 Mon Sep 17 00:00:00 2001 From: Jasonhu <2323168280@qq.com> Date: Thu, 8 Dec 2022 22:57:40 +0800 Subject: [PATCH 10/11] feat(stdio): defin NULL if not define --- src/include/stdio.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/include/stdio.h b/src/include/stdio.h index abdf893..d320daa 100644 --- a/src/include/stdio.h +++ b/src/include/stdio.h @@ -14,11 +14,13 @@ extern "C" { #define __NEED_struct__IO_FILE #endif +#ifndef NULL #ifdef __cplusplus -#define NULL 0L +#define NULL 0 #else -#define NULL ((void*)0) +#define NULL ((void *)0) #endif +#endif /* NULL */ #undef EOF #define EOF (-1) -- Gitee From d54b0004d306a6e5ac0586b64b92f45241b38771 Mon Sep 17 00:00:00 2001 From: "Li.XiongHui" Date: Fri, 14 Jul 2023 14:22:03 +0800 Subject: [PATCH 11/11] feat: update compile env to support zsh shell --- README.md | 6 +++--- setup.sh | 37 ++++++++++--------------------------- 2 files changed, 13 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 7d3e058..8d440cc 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,8 @@ setup.bat # windows环境,默认x86 source setup.sh # linux环境 setup.bat riscv64 # windows环境 source setup.sh riscv64 # linux环境 -# 2. 更新nxos基础库 -make ulib -# 3. 编译库 +# 2. 编译库 make +# 3. 安装库 +make install ``` diff --git a/setup.sh b/setup.sh index 43151df..719693f 100755 --- a/setup.sh +++ b/setup.sh @@ -15,29 +15,9 @@ # source setup.sh [arch] # example: source setup.sh # x86 # example: source setup.sh riscv64 # riscv64 - -# supported targe list -supported_arch="x86 riscv64" - -def_arch="unknown" - -# find arch in arch list -if [ -z $1 ] -then - def_arch="x86" # default arch is x86 -else - for arch in $supported_arch - do - if [ $arch = $1 ] - then - def_arch=$arch - break - fi - done -fi - # set env -case $def_arch in +arch=$1 +case $arch in "x86") export CROSS_COMPILE= export ARCH=x86 @@ -46,11 +26,14 @@ case $def_arch in export CROSS_COMPILE=riscv64-unknown-elf- export ARCH=riscv64 ;; - *) echo "unknown arch! " $def_arch + "qemu_riscv64") + export CROSS_COMPILE=riscv64-unknown-elf- + export ARCH=riscv64 + ;; + *) echo "unknown arch! " $arch return 1 esac -echo "Set environment for for xlibc." -echo [CROSS COMPILE ] $CROSS_COMPILE -echo [ARCH ] $def_arch -echo [NXOS ARCH ] $ARCH +echo "Set environment for nxos-user." +echo "[CROSS COMPILE ] $CROSS_COMPILE" +echo "[ARCH ] $arch" \ No newline at end of file -- Gitee