diff mbox series

[liburing,v3,03/10] arch: syscall: Add `__sys_read()` syscall

Message ID 20220704174858.329326-4-ammar.faizi@intel.com (mailing list archive)
State New
Headers show
Series aarch64 support | expand

Commit Message

Ammar Faizi July 4, 2022, 5:54 p.m. UTC
From: Ammar Faizi <ammarfaizi2@gnuweeb.org>

A prep patch to support aarch64 nolibc. We will use this to get the
page size by reading /proc/self/auxv.

Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
---
 src/arch/generic/syscall.h | 7 +++++++
 src/arch/syscall-defs.h    | 5 +++++
 2 files changed, 12 insertions(+)

Comments

Alviro Iskandar Setiawan July 4, 2022, 6:12 p.m. UTC | #1
On Tue, Jul 5, 2022 at 12:54 AM Ammar Faizi wrote:
> From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
>
> A prep patch to support aarch64 nolibc. We will use this to get the
> page size by reading /proc/self/auxv.
>
> Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
[...]
> +static inline int __sys_read(int fd, void *buffer, size_t size)
> +{
> +       return (int) __do_syscall3(__NR_read, fd, buffer, size);
> +}

__sys_read should return ssize_t and the cast should also (ssize_t).

With that fixed:

Reviewed-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>

tq

-- Viro
Ammar Faizi July 4, 2022, 6:16 p.m. UTC | #2
On 7/5/22 1:12 AM, Alviro Iskandar Setiawan wrote:
> On Tue, Jul 5, 2022 at 12:54 AM Ammar Faizi wrote:
>> From: Ammar Faizi <ammarfaizi2@gnuweeb.org>
>>
>> A prep patch to support aarch64 nolibc. We will use this to get the
>> page size by reading /proc/self/auxv.
>>
>> Signed-off-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
> [...]
>> +static inline int __sys_read(int fd, void *buffer, size_t size)
>> +{
>> +       return (int) __do_syscall3(__NR_read, fd, buffer, size);
>> +}
> 
> __sys_read should return ssize_t and the cast should also (ssize_t).

Ah right, I missed it. Will fix in v4.

> With that fixed:
> 
> Reviewed-by: Alviro Iskandar Setiawan <alviro.iskandar@gnuweeb.org>

Thanks!
diff mbox series

Patch

diff --git a/src/arch/generic/syscall.h b/src/arch/generic/syscall.h
index 71b2234..22252a1 100644
--- a/src/arch/generic/syscall.h
+++ b/src/arch/generic/syscall.h
@@ -50,6 +50,13 @@  static inline int __sys_open(const char *pathname, int flags, mode_t mode)
 	return (ret < 0) ? -errno : ret;
 }
 
+static inline ssize_t __sys_read(int fd, void *buffer, size_t size)
+{
+	ssize_t ret;
+	ret = read(fd, buffer, size);
+	return (ret < 0) ? -errno : ret;
+}
+
 static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
 			       int fd, off_t offset)
 {
diff --git a/src/arch/syscall-defs.h b/src/arch/syscall-defs.h
index 9d4424d..32750b5 100644
--- a/src/arch/syscall-defs.h
+++ b/src/arch/syscall-defs.h
@@ -17,6 +17,11 @@  static inline int __sys_open(const char *pathname, int flags, mode_t mode)
 #endif
 }
 
+static inline int __sys_read(int fd, void *buffer, size_t size)
+{
+	return (int) __do_syscall3(__NR_read, fd, buffer, size);
+}
+
 static inline void *__sys_mmap(void *addr, size_t length, int prot, int flags,
 			       int fd, off_t offset)
 {