mescc: Mes C Library: Explode libc-mini.c.
* include/libmes.h: Add declarations. * lib/mes/eputs.c: New file, explode from lib/libc-mini.c. * lib/mes/oputs.c: Likewise. * lib/stdlib/exit.c: Likewise. * lib/stdlib/puts.c: Likewise. * lib/string/strlen.c: Likewise. * lib/libc-mini.c: Include explodings.
This commit is contained in:
parent
3e4a56a05b
commit
38a7077b72
|
@ -21,11 +21,35 @@
|
||||||
#ifndef __MES_LIBMES_H
|
#ifndef __MES_LIBMES_H
|
||||||
#define __MES_LIBMES_H
|
#define __MES_LIBMES_H
|
||||||
|
|
||||||
|
#ifndef _SIZE_T
|
||||||
|
#define _SIZE_T
|
||||||
|
#ifndef __SIZE_T
|
||||||
|
#define __SIZE_T
|
||||||
|
#ifndef __MES_SIZE_T
|
||||||
|
#define __MES_SIZE_T
|
||||||
|
#undef size_t
|
||||||
|
typedef unsigned long size_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef _SSIZE_T
|
||||||
|
#define _SSIZE_T
|
||||||
|
#ifndef __SSIZE_T
|
||||||
|
#define __SSIZE_T
|
||||||
|
#ifndef __MES_SSIZE_T
|
||||||
|
#define __MES_SSIZE_T
|
||||||
|
#undef ssize_t
|
||||||
|
typedef long ssize_t;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
int __mes_debug ();
|
int __mes_debug ();
|
||||||
char const* number_to_ascii (int number, int base, int signed_p);
|
char const* number_to_ascii (long number, int base, int signed_p);
|
||||||
char const* itoa (int number);
|
char const* itoa (long number);
|
||||||
char const* utoa (unsigned number);
|
char const* utoa (unsigned long number);
|
||||||
char const* itoab (int x, int base);
|
char const* itoab (long x, int base);
|
||||||
int _atoi (char const**, int base);
|
int _atoi (char const**, int base);
|
||||||
int atoi (char const *s);
|
int atoi (char const *s);
|
||||||
int eputc (int c);
|
int eputc (int c);
|
||||||
|
@ -38,5 +62,6 @@ int isdigit (int c);
|
||||||
int isspace (int c);
|
int isspace (int c);
|
||||||
int isxdigit (int c);
|
int isxdigit (int c);
|
||||||
int oputs (char const* s);
|
int oputs (char const* s);
|
||||||
|
ssize_t write (int filedes, void const *buffer, size_t size);
|
||||||
|
|
||||||
#endif //__MES_LIBMES_H
|
#endif //__MES_LIBMES_H
|
||||||
|
|
|
@ -18,64 +18,10 @@
|
||||||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <errno.h>
|
#include <string/strlen.c>
|
||||||
|
#include <mes/eputs.c>
|
||||||
#ifndef _SIZE_T
|
#include <mes/oputs.c>
|
||||||
#define _SIZE_T
|
#include <stdlib/puts.c>
|
||||||
#ifndef __SIZE_T
|
|
||||||
#define __SIZE_T
|
|
||||||
#ifndef __MES_SIZE_T
|
|
||||||
#define __MES_SIZE_T
|
|
||||||
#undef size_t
|
|
||||||
typedef unsigned long size_t;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _SSIZE_T
|
|
||||||
#define _SSIZE_T
|
|
||||||
#ifndef __SSIZE_T
|
|
||||||
#define __SSIZE_T
|
|
||||||
#ifndef __MES_SSIZE_T
|
|
||||||
#define __MES_SSIZE_T
|
|
||||||
#undef ssize_t
|
|
||||||
typedef long ssize_t;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ssize_t write (int filedes, void const *buffer, size_t size);
|
|
||||||
|
|
||||||
size_t
|
|
||||||
strlen (char const* s)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
while (s[i]) i++;
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
eputs (char const* s)
|
|
||||||
{
|
|
||||||
int i = strlen (s);
|
|
||||||
write (2, s, i);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
oputs (char const* s)
|
|
||||||
{
|
|
||||||
int i = strlen (s);
|
|
||||||
write (1, s, i);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
puts (char const* s)
|
|
||||||
{
|
|
||||||
oputs (s);
|
|
||||||
return oputs ("\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#if __GNU__
|
#if __GNU__
|
||||||
#include <hurd/libc-mini.c>
|
#include <hurd/libc-mini.c>
|
||||||
|
@ -85,12 +31,4 @@ puts (char const* s)
|
||||||
#error both __GNU__ and _linux__ are undefined, choose one
|
#error both __GNU__ and _linux__ are undefined, choose one
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void (*__call_at_exit) (void);
|
#include <stdlib/exit.c>
|
||||||
|
|
||||||
void
|
|
||||||
exit (int code)
|
|
||||||
{
|
|
||||||
if (__call_at_exit)
|
|
||||||
(*__call_at_exit) ();
|
|
||||||
_exit (code);
|
|
||||||
}
|
|
||||||
|
|
29
lib/mes/eputs.c
Normal file
29
lib/mes/eputs.c
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2016,2017,2018 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 <libmes.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
eputs (char const* s)
|
||||||
|
{
|
||||||
|
int i = strlen (s);
|
||||||
|
write (2, s, i);
|
||||||
|
return 0;
|
||||||
|
}
|
29
lib/mes/oputs.c
Normal file
29
lib/mes/oputs.c
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2016,2017,2018 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 <libmes.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
oputs (char const* s)
|
||||||
|
{
|
||||||
|
int i = strlen (s);
|
||||||
|
write (1, s, i);
|
||||||
|
return 0;
|
||||||
|
}
|
31
lib/stdlib/exit.c
Normal file
31
lib/stdlib/exit.c
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2016,2017,2018 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 <libmes.h>
|
||||||
|
|
||||||
|
void (*__call_at_exit) (void);
|
||||||
|
|
||||||
|
void
|
||||||
|
exit (int code)
|
||||||
|
{
|
||||||
|
if (__call_at_exit)
|
||||||
|
(*__call_at_exit) ();
|
||||||
|
_exit (code);
|
||||||
|
}
|
28
lib/stdlib/puts.c
Normal file
28
lib/stdlib/puts.c
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2016,2017,2018 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 <libmes.h>
|
||||||
|
|
||||||
|
int
|
||||||
|
puts (char const* s)
|
||||||
|
{
|
||||||
|
oputs (s);
|
||||||
|
return oputs ("\n");
|
||||||
|
}
|
30
lib/string/strlen.c
Normal file
30
lib/string/strlen.c
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/* -*-comment-start: "//";comment-end:""-*-
|
||||||
|
* GNU Mes --- Maxwell Equations of Software
|
||||||
|
* Copyright © 2016,2017,2018 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 <libmes.h>
|
||||||
|
|
||||||
|
size_t
|
||||||
|
strlen (char const* s)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
while (s[i])
|
||||||
|
i++;
|
||||||
|
return i;
|
||||||
|
}
|
Loading…
Reference in a new issue