diff --git a/build-aux/build-lib.sh b/build-aux/build-lib.sh index 22caf6e9..db102336 100755 --- a/build-aux/build-lib.sh +++ b/build-aux/build-lib.sh @@ -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 diff --git a/include/mes/lib.h b/include/mes/lib.h index 7145dab1..63d1eba9 100644 --- a/include/mes/lib.h +++ b/include/mes/lib.h @@ -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); diff --git a/lib/linux/_getcwd.c b/lib/linux/_getcwd.c new file mode 100644 index 00000000..55db9a02 --- /dev/null +++ b/lib/linux/_getcwd.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2019 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 + +char * +_getcwd (char *buffer, size_t size) +{ + int r = _sys_call2 (SYS_getcwd, (long) buffer, (long) size); + if (r >= 0) + return buffer; + return 0; +} diff --git a/lib/linux/_open3.c b/lib/linux/_open3.c new file mode 100644 index 00000000..e1bf1f7b --- /dev/null +++ b/lib/linux/_open3.c @@ -0,0 +1,34 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018,2019 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 + +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; +} diff --git a/lib/linux/getcwd.c b/lib/posix/getcwd.c similarity index 83% rename from lib/linux/getcwd.c rename to lib/posix/getcwd.c index fbb67282..39dd3bf9 100644 --- a/lib/linux/getcwd.c +++ b/lib/posix/getcwd.c @@ -18,20 +18,9 @@ * along with GNU Mes. If not, see . */ -#include -#include #include #include -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) { diff --git a/lib/linux/open.c b/lib/posix/open.c similarity index 82% rename from lib/linux/open.c rename to lib/posix/open.c index 28c65739..256f2f13 100644 --- a/lib/linux/open.c +++ b/lib/posix/open.c @@ -18,22 +18,10 @@ * along with GNU Mes. If not, see . */ -#include -#include #include #include #include -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) { diff --git a/simple.sh b/simple.sh index f87d0977..4c096463 100755 --- a/simple.sh +++ b/simple.sh @@ -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\