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.
This commit is contained in:
Jan (janneke) Nieuwenhuizen 2022-10-31 08:36:39 +01:00
parent 9004a9d1fb
commit 8c9b95b3a9
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
7 changed files with 109 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -1,6 +1,6 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
* Copyright © 2018,2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* 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

40
include/sys/uio.h Normal file
View File

@ -0,0 +1,40 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef __MES_SYS_UIO_H
#define __MES_SYS_UIO_H 1
#if SYSTEM_LIBC
#undef __MES_SYS_TYPES_H
#include_next <sys/uio.h>
#else // ! SYSTEM_LIBC
#include <sys/types.h>
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

30
lib/linux/readv.c Normal file
View File

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <sys/uio.h>
ssize_t
readv (int filedes, struct iovec const *vector, int count)
{
return _sys_call3 (SYS_readv, filedes, (long) vector, count);
}

30
lib/linux/writev.c Normal file
View File

@ -0,0 +1,30 @@
/* -*-comment-start: "//";comment-end:""-*-
* GNU Mes --- Maxwell Equations of Software
* Copyright © 2022 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
*
* 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 <http://www.gnu.org/licenses/>.
*/
#include <mes/lib.h>
#include <linux/syscall.h>
#include <arch/syscall.h>
#include <sys/uio.h>
ssize_t
writev (int filedes, struct iovec const *vector, int count)
{
return _sys_call3 (SYS_writev, filedes, (long) vector, count);
}