From bc20ef464cb08411d85e5ff83dfb2e40bb86b75b Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Thu, 11 Jul 2013 23:29:52 +0200 Subject: [PATCH] Split pread and pwrite into their own files. --- libc/Makefile | 2 ++ libc/unistd/pread.cpp | 34 ++++++++++++++++++++++++++++++++++ libc/unistd/pwrite.cpp | 34 ++++++++++++++++++++++++++++++++++ libc/unistd/read.cpp | 7 ------- libc/unistd/write.cpp | 7 ------- 5 files changed, 70 insertions(+), 14 deletions(-) create mode 100644 libc/unistd/pread.cpp create mode 100644 libc/unistd/pwrite.cpp diff --git a/libc/Makefile b/libc/Makefile index dafe6359..25d5ead8 100644 --- a/libc/Makefile +++ b/libc/Makefile @@ -382,6 +382,8 @@ unistd/memstat.o \ unistd/mkpartition.o \ unistd/pathconf.o \ unistd/pipe.o \ +unistd/pread.o \ +unistd/pwrite.o \ unistd/readlinkat.o \ unistd/readlink.o \ unistd/read.o \ diff --git a/libc/unistd/pread.cpp b/libc/unistd/pread.cpp new file mode 100644 index 00000000..3276349a --- /dev/null +++ b/libc/unistd/pread.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + + This file is part of the Sortix C Library. + + The Sortix C Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + The Sortix C Library 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 Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with the Sortix C Library. If not, see . + + unistd/pread.cpp + Reads from a file descriptor at the given offset. + +*******************************************************************************/ + +#include + +#include + +DEFN_SYSCALL4(ssize_t, sys_pread, SYSCALL_PREAD, int, void*, size_t, off_t); + +extern "C" ssize_t pread(int fd, void* buf, size_t count, off_t offset) +{ + return sys_pread(fd, buf, count, offset); +} diff --git a/libc/unistd/pwrite.cpp b/libc/unistd/pwrite.cpp new file mode 100644 index 00000000..07abf56b --- /dev/null +++ b/libc/unistd/pwrite.cpp @@ -0,0 +1,34 @@ +/******************************************************************************* + + Copyright(C) Jonas 'Sortie' Termansen 2011, 2012. + + This file is part of the Sortix C Library. + + The Sortix C Library is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or (at your + option) any later version. + + The Sortix C Library 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 Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with the Sortix C Library. If not, see . + + unistd/pwrite.cpp + Writes to a file descriptor at the given offset. + +*******************************************************************************/ + +#include + +#include + +DEFN_SYSCALL4(ssize_t, sys_pwrite, SYSCALL_PWRITE, int, const void*, size_t, off_t); + +extern "C" ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) +{ + return sys_pwrite(fd, buf, count, offset); +} diff --git a/libc/unistd/read.cpp b/libc/unistd/read.cpp index 96abc31b..9fc1e894 100644 --- a/libc/unistd/read.cpp +++ b/libc/unistd/read.cpp @@ -33,10 +33,3 @@ extern "C" ssize_t read(int fd, void* buf, size_t count) { return sys_read(fd, buf, count); } - -DEFN_SYSCALL4(ssize_t, sys_pread, SYSCALL_PREAD, int, void*, size_t, off_t); - -extern "C" ssize_t pread(int fd, void* buf, size_t count, off_t offset) -{ - return sys_pread(fd, buf, count, offset); -} diff --git a/libc/unistd/write.cpp b/libc/unistd/write.cpp index 77d1163e..c1640c28 100644 --- a/libc/unistd/write.cpp +++ b/libc/unistd/write.cpp @@ -33,10 +33,3 @@ extern "C" ssize_t write(int fd, const void* buf, size_t count) { return sys_write(fd, buf, count); } - -DEFN_SYSCALL4(ssize_t, sys_pwrite, SYSCALL_PWRITE, int, const void*, size_t, off_t); - -extern "C" ssize_t pwrite(int fd, const void* buf, size_t count, off_t offset) -{ - return sys_pwrite(fd, buf, count, offset); -}