aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc
diff options
context:
space:
mode:
authorArijit Kumar Das <arijitkdgit.official@gmail.com>2025-07-17 16:21:16 +0530
committerThomas Schwinge <tschwinge@baylibre.com>2025-07-17 14:43:19 +0200
commit5d8c71af5e0fa5cdc99d9f741624920e34756418 (patch)
treef142f4bd13a5e2a542f48e2cdbb8b864295d5177 /newlib/libc
parentf0912e9a74cd082b9ae2e9844095a4743e526529 (diff)
downloadnewlib-5d8c71af5e0fa5cdc99d9f741624920e34756418.zip
newlib-5d8c71af5e0fa5cdc99d9f741624920e34756418.tar.gz
newlib-5d8c71af5e0fa5cdc99d9f741624920e34756418.tar.bz2
nvptx: Change 'read' and 'write' to 'ssize_t' return type
This commit changes the return type of the read() and write() syscalls for nvptx to ssize_t. This would allow large files to be handled properly by these syscalls in situations where the read/write buffer length exceeds INT_MAX, for example. This also makes the syscall signatures fully complaint with their current POSIX specifications. We additionally define two macros: '_READ_WRITE_RETURN_TYPE' as _ssize_t and '_READ_WRITE_BUFSIZE_TYPE' as __size_t in libc/include/sys/config.h under __nvptx__ for consistency. Signed-off-by: Arijit Kumar Das <arijitkdgit.official@gmail.com>
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/include/sys/config.h5
-rw-r--r--newlib/libc/machine/nvptx/misc.c2
-rw-r--r--newlib/libc/machine/nvptx/write.c3
3 files changed, 8 insertions, 2 deletions
diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h
index 4c9acc5..c3cd51e 100644
--- a/newlib/libc/include/sys/config.h
+++ b/newlib/libc/include/sys/config.h
@@ -12,6 +12,11 @@
#define __DYNAMIC_REENT__
#endif
+#ifdef __nvptx__
+#define _READ_WRITE_RETURN_TYPE _ssize_t
+#define _READ_WRITE_BUFSIZE_TYPE __size_t
+#endif
+
/* exceptions first */
#if defined(__H8500__) || defined(__W65__)
#define __SMALL_BITFIELDS
diff --git a/newlib/libc/machine/nvptx/misc.c b/newlib/libc/machine/nvptx/misc.c
index 56e66b9..829921e 100644
--- a/newlib/libc/machine/nvptx/misc.c
+++ b/newlib/libc/machine/nvptx/misc.c
@@ -62,7 +62,7 @@ open (const char *pathname, int flags, ...) {
return -1;
}
-int
+ssize_t
read(int fd, void *buf, size_t count) {
return 0;
}
diff --git a/newlib/libc/machine/nvptx/write.c b/newlib/libc/machine/nvptx/write.c
index 0544dd0..38f0868 100644
--- a/newlib/libc/machine/nvptx/write.c
+++ b/newlib/libc/machine/nvptx/write.c
@@ -18,7 +18,8 @@
#include <unistd.h>
#include <errno.h>
-_READ_WRITE_RETURN_TYPE write (int fd, const void *buf, size_t count)
+ssize_t
+write (int fd, const void *buf, size_t count)
{
size_t i;
char *b = (char *)buf;