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:
Jan Nieuwenhuizen 2018-08-16 11:07:33 +02:00
parent 3e4a56a05b
commit 38a7077b72
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
7 changed files with 181 additions and 71 deletions

View file

@ -21,11 +21,35 @@
#ifndef __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 ();
char const* number_to_ascii (int number, int base, int signed_p);
char const* itoa (int number);
char const* utoa (unsigned number);
char const* itoab (int x, int base);
char const* number_to_ascii (long number, int base, int signed_p);
char const* itoa (long number);
char const* utoa (unsigned long number);
char const* itoab (long x, int base);
int _atoi (char const**, int base);
int atoi (char const *s);
int eputc (int c);
@ -38,5 +62,6 @@ int isdigit (int c);
int isspace (int c);
int isxdigit (int c);
int oputs (char const* s);
ssize_t write (int filedes, void const *buffer, size_t size);
#endif //__MES_LIBMES_H

View file

@ -18,64 +18,10 @@
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.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
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");
}
#include <string/strlen.c>
#include <mes/eputs.c>
#include <mes/oputs.c>
#include <stdlib/puts.c>
#if __GNU__
#include <hurd/libc-mini.c>
@ -85,12 +31,4 @@ puts (char const* s)
#error both __GNU__ and _linux__ are undefined, choose one
#endif
void (*__call_at_exit) (void);
void
exit (int code)
{
if (__call_at_exit)
(*__call_at_exit) ();
_exit (code);
}
#include <stdlib/exit.c>

29
lib/mes/eputs.c Normal file
View 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
View 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
View 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
View 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
View 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;
}