mescc: Mes C Library: Move posix bits to read.
* lib/linux/_read.c: Rename from read. * lib/posix/read.c: New file. * build-aux/build-lib.sh (libc_SOURCES): Update. * include/mes/lib.h (_read): Declare.
This commit is contained in:
parent
58864b181d
commit
b562179c9c
|
@ -88,6 +88,7 @@ lib/mes/__mes_debug.c
|
||||||
lib/posix/execv.c
|
lib/posix/execv.c
|
||||||
lib/posix/getenv.c
|
lib/posix/getenv.c
|
||||||
lib/posix/isatty.c
|
lib/posix/isatty.c
|
||||||
|
lib/posix/read.c
|
||||||
lib/posix/setenv.c
|
lib/posix/setenv.c
|
||||||
lib/posix/wait.c
|
lib/posix/wait.c
|
||||||
lib/stdio/fgetc.c
|
lib/stdio/fgetc.c
|
||||||
|
@ -125,7 +126,7 @@ lib/linux/getcwd.c
|
||||||
lib/linux/gettimeofday.c
|
lib/linux/gettimeofday.c
|
||||||
lib/linux/ioctl.c
|
lib/linux/ioctl.c
|
||||||
lib/linux/open.c
|
lib/linux/open.c
|
||||||
lib/linux/read.c
|
lib/linux/_read.c
|
||||||
lib/linux/time.c
|
lib/linux/time.c
|
||||||
lib/linux/unlink.c
|
lib/linux/unlink.c
|
||||||
lib/linux/waitpid.c
|
lib/linux/waitpid.c
|
||||||
|
|
|
@ -48,6 +48,7 @@ int _open3 (char const *file_name, int flags, int mask);
|
||||||
int oputc (int c);
|
int oputc (int c);
|
||||||
int oputs (char const *s);
|
int oputs (char const *s);
|
||||||
char *search_path (char const *file_name);
|
char *search_path (char const *file_name);
|
||||||
|
ssize_t _read (int fd, void *buffer, size_t size);
|
||||||
|
|
||||||
extern char *__brk;
|
extern char *__brk;
|
||||||
extern void (*__call_at_exit) (void);
|
extern void (*__call_at_exit) (void);
|
||||||
|
|
30
lib/linux/_read.c
Normal file
30
lib/linux/_read.c
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2016,2017,2018,2019 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 <linux/syscall.h>
|
||||||
|
#include <syscall.h>
|
||||||
|
#include <mes/lib.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
_read (int filedes, void *buffer, size_t size)
|
||||||
|
{
|
||||||
|
return _sys_call3 (SYS_read, (int) filedes, (long) buffer, (long) size);
|
||||||
|
}
|
48
lib/posix/read.c
Normal file
48
lib/posix/read.c
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2016,2017,2018,2019 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 <fcntl.h>
|
||||||
|
|
||||||
|
ssize_t
|
||||||
|
read (int filedes, void *buffer, size_t size)
|
||||||
|
{
|
||||||
|
ssize_t bytes = _read (filedes, buffer, size);
|
||||||
|
if (__mes_debug () > 4)
|
||||||
|
{
|
||||||
|
if (bytes == 1)
|
||||||
|
{
|
||||||
|
eputs ("read fd=");
|
||||||
|
eputs (itoa ((int) filedes));
|
||||||
|
eputs (" c=");
|
||||||
|
eputc (*(char *) buffer);
|
||||||
|
eputs ("\n");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
eputs ("read fd=");
|
||||||
|
eputs (itoa ((int) filedes));
|
||||||
|
eputs (" bytes=");
|
||||||
|
eputs (itoa (bytes));
|
||||||
|
eputs ("\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
Loading…
Reference in a new issue