From 62818a5d32e8d373bc9beee0ccd551c5d25cef64 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Mon, 31 Oct 2022 08:36:39 +0100 Subject: [PATCH] DRAFT lib: Add readv, writev. * include/linux/arm/syscall.h (SYS_readv, SYS_writev): New defines. * include/linux/x86/syscall.h (SYS_readv, SYS_writev): New defines. * include/linux/x86_64/syscall.h (SYS_readv, SYS_writev): New defines. * include/sys/uio.h, lib/linux/readv.c, lib/linux/writev.c: New files. * build-aux/configure-lib.sh (libc_gnu_SOURCES): Add them. --- build-aux/configure-lib.sh | 2 ++ include/linux/arm/syscall.h | 2 ++ include/linux/x86/syscall.h | 2 ++ include/linux/x86_64/syscall.h | 4 +++- include/sys/uio.h | 40 ++++++++++++++++++++++++++++++++++ lib/linux/readv.c | 30 +++++++++++++++++++++++++ lib/linux/writev.c | 30 +++++++++++++++++++++++++ 7 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 include/sys/uio.h create mode 100644 lib/linux/readv.c create mode 100644 lib/linux/writev.c diff --git a/build-aux/configure-lib.sh b/build-aux/configure-lib.sh index 0c0fce3f..edae972e 100644 --- a/build-aux/configure-lib.sh +++ b/build-aux/configure-lib.sh @@ -432,6 +432,7 @@ lib/linux/munmap.c lib/linux/nanosleep.c lib/linux/pipe.c lib/linux/readlink.c +lib/linux/readv.c lib/linux/rename.c lib/linux/setgid.c lib/linux/setitimer.c @@ -439,6 +440,7 @@ lib/linux/setuid.c lib/linux/signal.c lib/linux/sigprogmask.c lib/linux/symlink.c +lib/linux/writev.c " fi diff --git a/include/linux/arm/syscall.h b/include/linux/arm/syscall.h index 7ef30bbd..dfeab446 100644 --- a/include/linux/arm/syscall.h +++ b/include/linux/arm/syscall.h @@ -94,6 +94,8 @@ // gcc-4.6.4 #define SYS_mmap 0x5a #define SYS_munmap 0x5b +#define SYS_readv 0x91 +#define SYS_writev 0x92 #if __SIZEOF_LONG_LONG__ == 8 diff --git a/include/linux/x86/syscall.h b/include/linux/x86/syscall.h index 4efeca73..23295450 100644 --- a/include/linux/x86/syscall.h +++ b/include/linux/x86/syscall.h @@ -94,6 +94,8 @@ // gcc-4.6.4 #define SYS_mmap 0x5a #define SYS_munmap 0x5b +#define SYS_readv 0x91 +#define SYS_writev 0x92 #if __SIZEOF_LONG_LONG__ == 8 diff --git a/include/linux/x86_64/syscall.h b/include/linux/x86_64/syscall.h index ad1e22d3..eca07af6 100644 --- a/include/linux/x86_64/syscall.h +++ b/include/linux/x86_64/syscall.h @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2018,2022 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -88,5 +88,7 @@ // gcc-4.6.4 #define SYS_mmap 0x09 #define SYS_munmap 0x0b +#define SYS_readv 0x13 +#define SYS_writev 0x14 #endif // __MES_LINUX_X86_64_SYSCALL_H diff --git a/include/sys/uio.h b/include/sys/uio.h new file mode 100644 index 00000000..74a7f47a --- /dev/null +++ b/include/sys/uio.h @@ -0,0 +1,40 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2022 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ +#ifndef __MES_SYS_UIO_H +#define __MES_SYS_UIO_H 1 + +#if SYSTEM_LIBC +#undef __MES_SYS_TYPES_H +#include_next +#else // ! SYSTEM_LIBC + +#include + +struct iovec +{ void *iov_base; + size_t iov_len; +}; + +ssize_t readv (int filedes, struct iovec const *vector, int count); +ssize_t writev (int filedes, struct iovec const *vector, int count); + +#endif // ! SYSTEM_LIBC + +#endif // __MES_SYS_TYPES_H diff --git a/lib/linux/readv.c b/lib/linux/readv.c new file mode 100644 index 00000000..d5914d1e --- /dev/null +++ b/lib/linux/readv.c @@ -0,0 +1,30 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2022 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include +#include +#include + +ssize_t +readv (int filedes, struct iovec const *vector, int count) +{ + return _sys_call3 (SYS_readv, filedes, (long) vector, count); +} diff --git a/lib/linux/writev.c b/lib/linux/writev.c new file mode 100644 index 00000000..c15e3014 --- /dev/null +++ b/lib/linux/writev.c @@ -0,0 +1,30 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2022 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include +#include +#include + +ssize_t +writev (int filedes, struct iovec const *vector, int count) +{ + return _sys_call3 (SYS_writev, filedes, (long) vector, count); +}