From 8a93fa68ffe78614bf28f5caca9ae819f816fa67 Mon Sep 17 00:00:00 2001 From: flysand7 Date: Tue, 25 Jul 2023 16:09:15 +1100 Subject: [PATCH] Change tinyrt inclusion macros to always be defined --- build.lua | 6 ++---- src/linux/tinyrt.c | 11 ++++++----- src/tinyrt.h | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/build.lua b/build.lua index 0f7771b..0cd2a67 100755 --- a/build.lua +++ b/build.lua @@ -115,10 +115,8 @@ for line in io.lines(tinyrt_manifest_path) do local api_name = line_it():upper() local has_impl = line_it() if has_impl == '0' or has_impl == '1' then - if has_impl == '1' then - local api_define = '#define RT_API_' .. api_name .. '\n' - tinyrt_iface_hdr:write(api_define) - end + local api_define = '#define RT_API_' .. api_name .. ' '..has_impl..'\n' + tinyrt_iface_hdr:write(api_define) else print('SYNTAX ERROR AT LINE '..i..': Expected 1 or 0 for the value') end diff --git a/src/linux/tinyrt.c b/src/linux/tinyrt.c index d7e951f..aed3827 100644 --- a/src/linux/tinyrt.c +++ b/src/linux/tinyrt.c @@ -39,11 +39,12 @@ static RT_Status rt_file_read(u64 size, void *buffer, RT_File *from, u64 *out_by } static RT_Status rt_file_write(RT_File *to, u64 size, void *buffer, u64 *out_bytes_written) { - i64 bytes_written = syscall_write(to->fd, buffer, size); - if(bytes_written < 0) { - return RT_STATUS_FILE_IO_ERROR; - } - *out_bytes_written = bytes_written; + // Call the syscall + i64 status = syscall_write(to->fd, buffer, size); + if(-status == EBADF) return RT_ERROR_BAD_PARAM; + if(-status == EIO) return RT_STATUS_FILE_IO_ERROR; + if(-status > 0) return RT_STATUS_FILE_IO_ERROR; + *out_bytes_written = status; return RT_STATUS_OK; } diff --git a/src/tinyrt.h b/src/tinyrt.h index c392e8c..3dac071 100644 --- a/src/tinyrt.h +++ b/src/tinyrt.h @@ -42,7 +42,7 @@ static RT_Status rt_init(); static RT_Status rt_deinit(); // File API -#if defined(RT_API_FILE) +#if RT_API_FILE == 1 struct RT_File typedef RT_File; struct RT_File { union {