Message ID | 20220704174858.329326-4-ammar.faizi@intel.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | aarch64 support | expand |
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
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 --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) {