From c971e02614ece78c8a0a9d3b5ee2913b231573d6 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 10 Feb 2019 23:16:47 +0100 Subject: [PATCH] mescc: Mes C Library: Explode linux/tcc.c. WIP --- lib/linux/close.c | 27 +++++++++++++++++++++++++++ lib/linux/lseek.c | 25 +++++++++++++++++++++++++ lib/linux/rmdir.c | 25 +++++++++++++++++++++++++ lib/linux/stat.c | 25 +++++++++++++++++++++++++ lib/linux/tcc.c | 31 +++++-------------------------- 5 files changed, 107 insertions(+), 26 deletions(-) create mode 100644 lib/linux/close.c create mode 100644 lib/linux/lseek.c create mode 100644 lib/linux/rmdir.c create mode 100644 lib/linux/stat.c diff --git a/lib/linux/close.c b/lib/linux/close.c new file mode 100644 index 00000000..7876169e --- /dev/null +++ b/lib/linux/close.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018 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 . + */ + +int +close (int filedes) +{ + if (filedes > 2) + __ungetc_buf[filedes] = -1; + return _sys_call1 (SYS_close, (int)filedes); +} diff --git a/lib/linux/lseek.c b/lib/linux/lseek.c new file mode 100644 index 00000000..7f6fc85a --- /dev/null +++ b/lib/linux/lseek.c @@ -0,0 +1,25 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018 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 . + */ + +off_t +lseek (int filedes, off_t offset, int whence) +{ + return _sys_call3 (SYS_lseek, (int)filedes, (long)offset, (int)whence); +} diff --git a/lib/linux/rmdir.c b/lib/linux/rmdir.c new file mode 100644 index 00000000..ab95d231 --- /dev/null +++ b/lib/linux/rmdir.c @@ -0,0 +1,25 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018 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 . + */ + +int +rmdir (char const *file_name) +{ + return _sys_call1 (SYS_rmdir, (long)file_name); +} diff --git a/lib/linux/stat.c b/lib/linux/stat.c new file mode 100644 index 00000000..3f9e43c4 --- /dev/null +++ b/lib/linux/stat.c @@ -0,0 +1,25 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2016,2017,2018 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 . + */ + +int +stat (char const *file_name, struct stat *statbuf) +{ + return _sys_call2 (SYS_stat, (long)file_name, (long)statbuf); +} diff --git a/lib/linux/tcc.c b/lib/linux/tcc.c index d57b58cc..b6f6d8d0 100644 --- a/lib/linux/tcc.c +++ b/lib/linux/tcc.c @@ -1,6 +1,6 @@ /* -*-comment-start: "//";comment-end:""-*- * GNU Mes --- Maxwell Equations of Software - * Copyright © 2016,2017,2018 Jan (janneke) Nieuwenhuizen + * Copyright © 2016,2017,2018,2019 Jan (janneke) Nieuwenhuizen * * This file is part of GNU Mes. * @@ -20,28 +20,7 @@ #include -int -close (int filedes) -{ - if (filedes > 2) - __ungetc_buf[filedes] = -1; - return _sys_call1 (SYS_close, (int)filedes); -} - -off_t -lseek (int filedes, off_t offset, int whence) -{ - return _sys_call3 (SYS_lseek, (int)filedes, (long)offset, (int)whence); -} - -int -rmdir (char const *file_name) -{ - return _sys_call1 (SYS_rmdir, (long)file_name); -} - -int -stat (char const *file_name, struct stat *statbuf) -{ - return _sys_call2 (SYS_stat, (long)file_name, (long)statbuf); -} +#include +#include +#include +#include