mescc: Mes C library: Move common getcwd, open bits to posix.
* lib/linux/_getcwd.c: Rename from getcwd.c. * lib/linux/_open3.c: Rename from open.c. * lib/posix/getcwd.c: New file with bits from ../linux/getcwd.c. * lib/posix/open.c: New file with bits ../linux/getcwd.c. * build-aux/build-lib.sh (libc_SOURCES): Update.
This commit is contained in:
parent
b562179c9c
commit
acb5608b70
|
@ -86,9 +86,11 @@ $libmes_SOURCES
|
|||
lib/mes/__assert_fail.c
|
||||
lib/mes/__mes_debug.c
|
||||
lib/posix/execv.c
|
||||
lib/posix/getcwd.c
|
||||
lib/posix/getenv.c
|
||||
lib/posix/isatty.c
|
||||
lib/posix/read.c
|
||||
lib/posix/open.c
|
||||
lib/posix/setenv.c
|
||||
lib/posix/wait.c
|
||||
lib/stdio/fgetc.c
|
||||
|
@ -122,10 +124,10 @@ lib/linux/dup2.c
|
|||
lib/linux/execve.c
|
||||
lib/linux/fork.c
|
||||
lib/linux/fsync.c
|
||||
lib/linux/getcwd.c
|
||||
lib/linux/_getcwd.c
|
||||
lib/linux/gettimeofday.c
|
||||
lib/linux/ioctl.c
|
||||
lib/linux/open.c
|
||||
lib/linux/_open3.c
|
||||
lib/linux/_read.c
|
||||
lib/linux/time.c
|
||||
lib/linux/unlink.c
|
||||
|
|
|
@ -41,6 +41,7 @@ char * fdgets (char *s, int count, int fd);
|
|||
int fdputc (int c, int fd);
|
||||
int fdputs (char const *s, int fd);
|
||||
int fdungetc (int c, int fd);
|
||||
char * _getcwd (char *buffer, size_t size);
|
||||
int isnumber (int c, int base);
|
||||
int mes_open (char const *file_name, int flags, int mask);
|
||||
int _open2 (char const *file_name, int flags);
|
||||
|
|
32
lib/linux/_getcwd.c
Normal file
32
lib/linux/_getcwd.c
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* -*-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-mini.h>
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
|
||||
char *
|
||||
_getcwd (char *buffer, size_t size)
|
||||
{
|
||||
int r = _sys_call2 (SYS_getcwd, (long) buffer, (long) size);
|
||||
if (r >= 0)
|
||||
return buffer;
|
||||
return 0;
|
||||
}
|
34
lib/linux/_open3.c
Normal file
34
lib/linux/_open3.c
Normal file
|
@ -0,0 +1,34 @@
|
|||
/* -*-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>
|
||||
|
||||
int
|
||||
_open3 (char const *file_name, int flags, int mask)
|
||||
{
|
||||
int r = _sys_call3 (SYS_open, (long) file_name, (int) flags, (int) mask);
|
||||
__ungetc_init ();
|
||||
if (r > 2)
|
||||
__ungetc_clear (r);
|
||||
return r;
|
||||
}
|
|
@ -18,20 +18,9 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <linux/syscall.h>
|
||||
#include <syscall.h>
|
||||
#include <limits.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
char *
|
||||
_getcwd (char *buffer, size_t size)
|
||||
{
|
||||
int r = _sys_call2 (SYS_getcwd, (long) buffer, (long) size);
|
||||
if (r >= 0)
|
||||
return buffer;
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *
|
||||
getcwd (char *buffer, size_t size)
|
||||
{
|
|
@ -18,22 +18,10 @@
|
|||
* 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>
|
||||
#include <stdarg.h>
|
||||
|
||||
int
|
||||
_open3 (char const *file_name, int flags, int mask)
|
||||
{
|
||||
int r = _sys_call3 (SYS_open, (long) file_name, (int) flags, (int) mask);
|
||||
__ungetc_init ();
|
||||
if (r > 2)
|
||||
__ungetc_clear (r);
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
_open2 (char const *file_name, int flags)
|
||||
{
|
|
@ -169,8 +169,10 @@ $CC -g -D HAVE_CONFIG_H=1 -I include -I include/$mes_kernel/$mes_cpu\
|
|||
lib/mes/__assert_fail.c\
|
||||
lib/mes/__mes_debug.c\
|
||||
lib/posix/execv.c\
|
||||
lib/posix/getcwd.c\
|
||||
lib/posix/getenv.c\
|
||||
lib/posix/isatty.c\
|
||||
lib/posix/open.c\
|
||||
lib/posix/setenv.c\
|
||||
lib/posix/wait.c\
|
||||
lib/stdio/fgetc.c\
|
||||
|
@ -201,10 +203,10 @@ $CC -g -D HAVE_CONFIG_H=1 -I include -I include/$mes_kernel/$mes_cpu\
|
|||
lib/linux/execve.c\
|
||||
lib/linux/fork.c\
|
||||
lib/linux/fsync.c\
|
||||
lib/linux/getcwd.c\
|
||||
lib/linux/_getcwd.c\
|
||||
lib/linux/gettimeofday.c\
|
||||
lib/linux/ioctl.c\
|
||||
lib/linux/open.c\
|
||||
lib/linux/_open3.c\
|
||||
lib/linux/read.c\
|
||||
lib/linux/time.c\
|
||||
lib/linux/unlink.c\
|
||||
|
|
Loading…
Reference in a new issue