From 457d120770a206457ee6d30c50c912233dfe244e Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 24 Aug 2018 20:57:34 +0200 Subject: [PATCH] mescc: Mes C Library: Explode libc+gnu.c. * modified: include/math.h: Add declarations. * lib/posix/getopt.c: Rename from lib/getopt.c. * lib/gcc.c: Remove. * lib/m4.c: Remove. * lib/ctype/isalnum.c: New file, explode from libc+gnu.c. * lib/ctype/isalpha.c: Likewise. * lib/ctype/isascii.c: Likewise. * lib/ctype/iscntrl.c: Likewise. * lib/ctype/isnumber.c: Likewise. * lib/ctype/isprint.c: Likewise. * lib/ctype/ispunct.c: Likewise. * lib/math/fabs.c: Likewise. * lib/posix/alarm.c: Likewise. * lib/posix/mktemp.c: Likewise. * lib/posix/raise.c: Likewise. * lib/posix/sbrk.c: Likewise. * lib/posix/sleep.c: Likewise. * lib/posix/unsetenv.c: Likewise. * lib/stdio/clearerr.c: Likewise. * lib/stdio/fdgets.c: Likewise. * lib/stdio/feof.c: Likewise. * lib/stdio/fgets.c: Likewise. * lib/stdio/fileno.c: Likewise. * lib/stdio/freeopen.c: Likewise. * lib/stdio/freopen.c: Likewise. * lib/stdio/perror.c: Likewise. * lib/stdlib/__exit.c: Likewise. * lib/stdlib/abs.c: Likewise. * lib/stdlib/atexit.c: Likewise. * lib/stdlib/atol.c: Likewise. * lib/stdlib/bsearch.c: Likewise. * lib/stdlib/mbstowcs.c: Likewise. * lib/string/bcmp.c: Likewise. * lib/string/bcopy.c: Likewise. * lib/string/bzero.c: Likewise. * lib/string/index.c: Likewise. * lib/string/rindex.c: Likewise. * lib/string/strcspn.c: Likewise. * lib/string/strdup.c: Likewise. * lib/string/strerror.c: Likewise. * lib/string/strncat.c: Likewise. * lib/string/strpbrk.c: Likewise. * lib/string/strspn.c: Likewise. * lib/stub/__cleanup.c: Likewise. * lib/stub/atof.c: Likewise. * lib/stub/chown.c: Likewise. * lib/stub/ctime.c: Likewise. * lib/stub/fpurge.c: Likewise. * lib/stub/freadahead.c: Likewise. * lib/stub/frexp.c: Likewise. * lib/stub/fscanf.c: Likewise. * lib/stub/getpwnam.c: Likewise. * lib/stub/gmtime.c: Likewise. * lib/stub/pclose.c: Likewise. * lib/stub/popen.c: Likewise. * lib/stub/rewind.c: Likewise. * lib/stub/setbuf.c: Likewise. * lib/stub/sigsetmask.c: Likewise. * lib/stub/strftime.c: Likewise. * lib/stub/sys_siglist.c: Likewise. * lib/stub/system.c: Likewise. * lib/stub/times.c: Likewise. * lib/stub/umask.c: Likewise. * lib/stub/utime.c: Likewise. * lib/libc+gnu.c: Include explodings. * lib/libg.c: Likewise. * lib/libgetopt.c: Include explodings. --- include/math.h | 3 +- lib/binutils.c | 306 --------------------------------------- lib/ctype/isalnum.c | 27 ++++ lib/ctype/isalpha.c | 27 ++++ lib/ctype/isascii.c | 27 ++++ lib/ctype/iscntrl.c | 27 ++++ lib/ctype/isnumber.c | 2 +- lib/ctype/isprint.c | 27 ++++ lib/ctype/ispunct.c | 27 ++++ lib/gcc.c | 107 -------------- lib/libc+gnu.c | 71 ++++++++- lib/libg.c | 80 ++++++++-- lib/libgetopt.c | 2 +- lib/m4.c | 253 -------------------------------- lib/math/fabs.c | 29 ++++ lib/posix/alarm.c | 37 +++++ lib/{ => posix}/getopt.c | 0 lib/posix/mktemp.c | 35 +++++ lib/posix/raise.c | 27 ++++ lib/posix/sbrk.c | 34 +++++ lib/posix/sleep.c | 31 ++++ lib/posix/unsetenv.c | 39 +++++ lib/stdio/clearerr.c | 27 ++++ lib/stdio/fdgets.c | 39 +++++ lib/stdio/feof.c | 30 ++++ lib/stdio/fgets.c | 27 ++++ lib/stdio/fileno.c | 27 ++++ lib/stdio/freeopen.c | 28 ++++ lib/stdio/freopen.c | 28 ++++ lib/stdio/perror.c | 27 ++++ lib/stdlib/__exit.c | 25 ++++ lib/stdlib/abs.c | 29 ++++ lib/stdlib/atexit.c | 27 ++++ lib/stdlib/atol.c | 27 ++++ lib/stdlib/bsearch.c | 35 +++++ lib/stdlib/mbstowcs.c | 37 +++++ lib/string/bcmp.c | 27 ++++ lib/string/bcopy.c | 27 ++++ lib/string/bzero.c | 27 ++++ lib/string/index.c | 27 ++++ lib/string/rindex.c | 27 ++++ lib/string/strcspn.c | 33 +++++ lib/string/strdup.c | 31 ++++ lib/string/strerror.c | 79 ++++++++++ lib/string/strncat.c | 33 +++++ lib/string/strpbrk.c | 33 +++++ lib/string/strspn.c | 33 +++++ lib/stub/__cleanup.c | 31 ++++ lib/stub/atof.c | 31 ++++ lib/stub/chown.c | 33 +++++ lib/stub/ctime.c | 32 ++++ lib/stub/fpurge.c | 33 +++++ lib/stub/freadahead.c | 33 +++++ lib/stub/frexp.c | 31 ++++ lib/stub/fscanf.c | 32 ++++ lib/stub/getpwnam.c | 33 +++++ lib/stub/gmtime.c | 34 +++++ lib/stub/pclose.c | 32 ++++ lib/stub/popen.c | 32 ++++ lib/stub/rewind.c | 32 ++++ lib/stub/setbuf.c | 32 ++++ lib/stub/sigsetmask.c | 32 ++++ lib/stub/strftime.c | 32 ++++ lib/stub/sys_siglist.c | 32 ++++ lib/stub/system.c | 32 ++++ lib/stub/times.c | 33 +++++ lib/stub/umask.c | 32 ++++ lib/stub/utime.c | 31 ++++ 68 files changed, 1998 insertions(+), 685 deletions(-) delete mode 100644 lib/binutils.c create mode 100644 lib/ctype/isalnum.c create mode 100644 lib/ctype/isalpha.c create mode 100644 lib/ctype/isascii.c create mode 100644 lib/ctype/iscntrl.c create mode 100644 lib/ctype/isprint.c create mode 100644 lib/ctype/ispunct.c delete mode 100644 lib/gcc.c delete mode 100644 lib/m4.c create mode 100644 lib/math/fabs.c create mode 100644 lib/posix/alarm.c rename lib/{ => posix}/getopt.c (100%) create mode 100644 lib/posix/mktemp.c create mode 100644 lib/posix/raise.c create mode 100644 lib/posix/sbrk.c create mode 100644 lib/posix/sleep.c create mode 100644 lib/posix/unsetenv.c create mode 100644 lib/stdio/clearerr.c create mode 100644 lib/stdio/fdgets.c create mode 100644 lib/stdio/feof.c create mode 100644 lib/stdio/fgets.c create mode 100644 lib/stdio/fileno.c create mode 100644 lib/stdio/freeopen.c create mode 100644 lib/stdio/freopen.c create mode 100644 lib/stdio/perror.c create mode 100644 lib/stdlib/__exit.c create mode 100644 lib/stdlib/abs.c create mode 100644 lib/stdlib/atexit.c create mode 100644 lib/stdlib/atol.c create mode 100644 lib/stdlib/bsearch.c create mode 100644 lib/stdlib/mbstowcs.c create mode 100644 lib/string/bcmp.c create mode 100644 lib/string/bcopy.c create mode 100644 lib/string/bzero.c create mode 100644 lib/string/index.c create mode 100644 lib/string/rindex.c create mode 100644 lib/string/strcspn.c create mode 100644 lib/string/strdup.c create mode 100644 lib/string/strerror.c create mode 100644 lib/string/strncat.c create mode 100644 lib/string/strpbrk.c create mode 100644 lib/string/strspn.c create mode 100644 lib/stub/__cleanup.c create mode 100644 lib/stub/atof.c create mode 100644 lib/stub/chown.c create mode 100644 lib/stub/ctime.c create mode 100644 lib/stub/fpurge.c create mode 100644 lib/stub/freadahead.c create mode 100644 lib/stub/frexp.c create mode 100644 lib/stub/fscanf.c create mode 100644 lib/stub/getpwnam.c create mode 100644 lib/stub/gmtime.c create mode 100644 lib/stub/pclose.c create mode 100644 lib/stub/popen.c create mode 100644 lib/stub/rewind.c create mode 100644 lib/stub/setbuf.c create mode 100644 lib/stub/sigsetmask.c create mode 100644 lib/stub/strftime.c create mode 100644 lib/stub/sys_siglist.c create mode 100644 lib/stub/system.c create mode 100644 lib/stub/times.c create mode 100644 lib/stub/umask.c create mode 100644 lib/stub/utime.c diff --git a/include/math.h b/include/math.h index 14b20815..aea4e923 100644 --- a/include/math.h +++ b/include/math.h @@ -27,5 +27,6 @@ double ldexp (double x, int exp); #endif // ! WITH_GLIBC -#endif // __MES_MATH_H +double fabs (double number); +#endif // __MES_MATH_H diff --git a/lib/binutils.c b/lib/binutils.c deleted file mode 100644 index 53f0822c..00000000 --- a/lib/binutils.c +++ /dev/null @@ -1,306 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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 . - */ - -#include -#include -#include - -int -abs (int x) -{ - if (x < 0) - return -x; - return x; -} - -int -chown (char const *file_name, uid_t owner, gid_t group) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("chown stub\n"); - stub = 1; - errno = 0; - return 0; -} - -int -ctime (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("ctime stub\n"); - stub = 1; - errno = 0; - return 0; -} - -char * -fdgets (char *s, int count, int fd) -{ - int c = 0; - char *p = s; - while (--count > 0 && c != '\n') - { - c = fdgetc (fd); - if (c == EOF) - break; - *p++ = c; - } - if (p == s && (c == EOF || count == -1)) - return 0; - *p = 0; - return s; -} - -int -feof (FILE *stream) -{ - char c = fgetc (stream); - if (c != EOF) - ungetc (c, stream); - return c == EOF; -} - -char * -fgets (char *s, int count, FILE *stream) -{ - return fdgets (s, count, (int)stream); -} - -int -frexp (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("frexp stub\n"); - stub = 1; - return 0; -} - -void -perror (char const *message) -{ - fprintf (stderr, "%s: %s\n", strerror (errno), message); -} - -int -sigsetmask (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("sigsetmask stub\n"); - stub = 1; - errno = 0; - return 0; -} - -size_t -strcspn (char const *string, char const *stopset) -{ - char *p = string; - while (*p) - if (strchr (stopset, *p)) - break; - else - p++; - return p - string; -} - -char * -strncat (char *to, char const *from, size_t size) -{ - if (size == 0) - return to; - char *p = strchr (to , '\0'); - while (*from && size-- > 0) - *p++ = *from++; - *p = 0; - return to; -} - -char * -strpbrk (char const *string, char const* stopset) -{ - char *p = string; - while (*p) - if (strchr (stopset, *p)) - break; - else - p++; - return p; -} - -size_t -strspn (char const *string, char const *skipset) -{ - char *p = string; - while (*p) - if (!strchr (skipset, *p)) - break; - else - p++; - return p - string; -} - -int -sys_siglist (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("sys_siglist stub\n"); - stub = 1; - errno = 0; - return 0; -} - -int -umask (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("umask stub\n"); - stub = 1; - errno = 0; - return 0; -} - -int -utime (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("utime stub\n"); - errno = 0; - return 0; -} - -// binutils-2.10.1 -int -fscanf (FILE *stream, char const *template, ...) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("fscan stub\n"); - stub = 1; - return 0; -} - -int -isascii (int c) -{ - return c >= 0 && c <= 127; -} - -void * -#if __MESC__ -bsearch (void const *key, void const *array, size_t count, size_t size, void (*compare) ()) -#else -bsearch (void const *key, void const *array, size_t count, size_t size, comparison_fn_t compare) -#endif -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("bsearch stub\n"); - stub = 1; - return 0; -} - -struct tm * -gmtime (time_t const *time) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("gmtime stub\n"); - stub = 1; - errno = 0; - return localtime (time); -} - -#if __SBRK_CHAR_PTRDIFF -char * -sbrk (ptrdiff_t) -#else -void * -sbrk (intptr_t delta) -#endif -{ - if (delta >= 0) - return malloc (delta); - return __brk; -} - -// binutils 2.30 -char * -strdup (char const *s) -{ - size_t length = strlen (s) + 1; - char *p = (char*)malloc (length); - if (p) - return memcpy (p, s, length); - return 0; -} - -int -raise (int signum) -{ - kill (getpid (), signum); -} - -size_t -strftime (char *s, size_t size, char const *template, - struct tm const *brokentime) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("strftime stub\n"); - stub = 1; - return template; -} - -#if !__MESC__ -typedef char wchar_t[]; - -size_t -mbstowcs (wchar_t *wstring, char const *string, - size_t size) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("mbstowcs stub\n"); - stub = 1; - strcpy (wstring, string); - return strlen (string); -} -#endif - -void -clearerr (FILE *stream) -{ - errno = 0; -} - -double -fabs (double number) -{ - if (number < 0) - return -number; - return number; -} diff --git a/lib/ctype/isalnum.c b/lib/ctype/isalnum.c new file mode 100644 index 00000000..f7917ac8 --- /dev/null +++ b/lib/ctype/isalnum.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +isalnum (int c) +{ + return isdigit (c) || isalpha (c); +} diff --git a/lib/ctype/isalpha.c b/lib/ctype/isalpha.c new file mode 100644 index 00000000..142a8844 --- /dev/null +++ b/lib/ctype/isalpha.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +isalpha (int c) +{ + return islower (c) || isupper (c); +} diff --git a/lib/ctype/isascii.c b/lib/ctype/isascii.c new file mode 100644 index 00000000..48fa8f88 --- /dev/null +++ b/lib/ctype/isascii.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +isascii (int c) +{ + return c >= 0 && c <= 127; +} diff --git a/lib/ctype/iscntrl.c b/lib/ctype/iscntrl.c new file mode 100644 index 00000000..82d4c3de --- /dev/null +++ b/lib/ctype/iscntrl.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +iscntrl (int c) +{ + return c >= 0 && c < 32; +} diff --git a/lib/ctype/isnumber.c b/lib/ctype/isnumber.c index 023e9015..4c378865 100644 --- a/lib/ctype/isnumber.c +++ b/lib/ctype/isnumber.c @@ -18,7 +18,7 @@ * along with GNU Mes. If not, see . */ -#include +#include int isnumber (int c, int base) diff --git a/lib/ctype/isprint.c b/lib/ctype/isprint.c new file mode 100644 index 00000000..b0b4be8c --- /dev/null +++ b/lib/ctype/isprint.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +isprint (int c) +{ + return c >= 32 && c < 127; +} diff --git a/lib/ctype/ispunct.c b/lib/ctype/ispunct.c new file mode 100644 index 00000000..5266012e --- /dev/null +++ b/lib/ctype/ispunct.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +ispunct (int c) +{ + return isprint (c) && !isspace (c) && !isalnum (c); +} diff --git a/lib/gcc.c b/lib/gcc.c deleted file mode 100644 index 00afafa0..00000000 --- a/lib/gcc.c +++ /dev/null @@ -1,107 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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 . - */ - -#include -#include -#include -#include -#include - -FILE * -freopen (char const *file_name, char const *opentype, FILE *stream) -{ - fclose (stream); - return fopen (file_name, opentype); -} - -clock_t -times (struct tms *buffer) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("times stub\n"); - stub = 1; - return 0; -} - -unsigned int -sleep (unsigned int seconds) -{ - struct timespec requested_time; - struct timespec remaining; - requested_time.tv_sec = seconds; - requested_time.tv_nsec = 0; - return nanosleep (&requested_time, &remaining); -} - -// gcc-3.4 -void -unsetenv (char const *name) -{ - int length = strlen (name); - char **p = environ; - while (*p) - { - if (!strncmp (name, *p, length) && *(*p + length) == '=') - { - char **q = p; - q[0] = q[1]; - while (*q++) - q[0] = q[1]; - } - p++; - } -} - -// gcc-3.0 -int -atexit (void (*function) (void)) -{ - __call_at_exit = function; -} - -unsigned int -alarm (unsigned int seconds) -{ -#if !__MESC__ - struct itimerval old; - struct itimerval new; - new.it_interval.tv_usec = 0; - new.it_interval.tv_sec = 0; - new.it_value.tv_usec = 0; - new.it_value.tv_sec = (long int) seconds; - if (setitimer (ITIMER_REAL, &new, &old) < 0) - return 0; - return old.it_value.tv_sec; -#endif -} - -// gcc-2.95.3 - -struct passwd * -getpwnam (const char *NAME) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("getpwnam stub\n"); - stub = 1; - errno = 0; - return 0; -} diff --git a/lib/libc+gnu.c b/lib/libc+gnu.c index e2303090..8974e87e 100644 --- a/lib/libc+gnu.c +++ b/lib/libc+gnu.c @@ -28,10 +28,73 @@ #error both __GNU__ and _linux__ are undefined, choose one #endif -#include -#include -#include +// m4 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// binutils +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// gcc + +#include +#include +#include +#include +#include +#include +#include + #if !__GNU__ #include #endif -#include + +#include +#include diff --git a/lib/libg.c b/lib/libg.c index bf3ee22c..166b8a5f 100644 --- a/lib/libg.c +++ b/lib/libg.c @@ -46,19 +46,75 @@ #error both __GNU__ and _linux__ are undefined, choose one #endif -#include -#include -#include +// m4 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -int -__cleanup () -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("__cleanup stub\n"); - stub = 1; - return 0; -} +// binutils +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// gcc + +#include +#include +#include +#include +#include +#include +#include + +#if !__GNU__ +#include +#endif + +//#include +#include int __libc_subinit () diff --git a/lib/libgetopt.c b/lib/libgetopt.c index d8f0dbfc..3eb4cc23 100644 --- a/lib/libgetopt.c +++ b/lib/libgetopt.c @@ -18,4 +18,4 @@ * along with GNU Mes. If not, see . */ -#include +#include diff --git a/lib/m4.c b/lib/m4.c deleted file mode 100644 index aaee5639..00000000 --- a/lib/m4.c +++ /dev/null @@ -1,253 +0,0 @@ -/* -*-comment-start: "//";comment-end:""-*- - * GNU Mes --- Maxwell Equations of Software - * Copyright © 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 . - */ - -#include - -#include "stdlib/abort.c" - -int -atof (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("atof stub\n"); - stub = 1; - return 0; -} - -int -atol (char const *s) -{ - return atoi (s); -} - -int -bcmp (void const *s1, void const *s2, size_t size) -{ - return memcmp (s1, s2, size); -} - -void -bcopy (void const *src, void *dest, size_t n) -{ - memmove (dest, src, n); -} - -int -bzero (void *block, size_t size) -{ - return memset (block, 0, size); -} - -int -fileno (FILE *stream) -{ - return (int)stream; -} - -int -fpurge (FILE *stream) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("fpurge stub\n"); - stub = 1; - errno = 0; - return 0; -} - -size_t -freadahead (FILE *fp) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("freadahead stub\n"); - stub = 1; - errno = 0; - return 0; -} - -int -index (char const *s, int c) -{ - return strchr (s, c); -} - -int -isalnum (int c) -{ - return isdigit (c) || isalpha (c); -} - -int -isalpha (int c) -{ - return islower (c) || isupper (c); -} - -int -iscntrl (int c) -{ - return c >= 0 && c < 32; -} - -int -isprint (int c) -{ - return c >= 32 && c < 127; -} - -int -ispunct (int c) -{ - return isprint (c) && !isspace (c) && !isalnum (c); -} - -char * -mktemp (char *template) -{ - char *p = strchr (template, '\0'); - int q = (int)template; - *--p = ((unsigned char)(q >> 4)) % 26 + 'a'; - *--p = ((unsigned char)(q >> 8)) % 26 + 'a'; - *--p = ((unsigned char)(q >> 12)) % 26 + 'a'; - *--p = ((unsigned char)(q >> 16)) % 26 + 'a'; - *--p = ((unsigned char)(q >> 20)) % 26 + 'a'; - *--p = ((unsigned char)(q >> 24)) % 26 + 'a'; - return template; -} - -int -pclose (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("pclose stub\n"); - stub = 1; - errno = 0; - return 0; -} - -int -popen (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("popen stub\n"); - stub = 1; - errno = 0; - return 0; -} - -int -rindex (char const *s, int c) -{ - return strrchr (s, c); -} - -int -rewind (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("rewind stub\n"); - stub = 1; - errno = 0; - return 0; -} - -int -setbuf (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("setbuf stub\n"); - stub = 1; - errno = 0; - return 0; -} - -int -system (int x) -{ - static int stub = 0; - if (__mes_debug () && !stub) - eputs ("system stub\n"); - stub = 1; - errno = 0; - return 0; -} - -char *sys_errlist[] = { - "error 00", - "error 01", - "error 02", - "error 03", - "error 04", - "error 05", - "error 06", - "error 07", - "error 08", - "error 09", - "error 10", - "error 11", - "error 12", - "error 13", - "error 14", - "error 15", - "error 16", - "error 17", - "error 18", - "error 19", - "error 20", - "error 21", - "error 22", - "error 23", - "error 24", - "error 25", - "error 26", - "error 27", - "error 28", - "error 29", - "error 30", - "error 31", - "error 32", - "error 33", - "error 34", - "error 35", - "error 36", - "error 37", - "error 38", - "error 39", -}; - -int sys_nerr = 39; - -char * -strerror (int errnum) -{ - if (__mes_debug ()) - { - eputs ("strerror errnum="); eputs (itoa (errnum)); eputs ("\n"); - } - if (errnum > 0 && errnum <= sys_nerr) - return sys_errlist[errnum]; - return "sterror: unknown error"; -} diff --git a/lib/math/fabs.c b/lib/math/fabs.c new file mode 100644 index 00000000..5726c728 --- /dev/null +++ b/lib/math/fabs.c @@ -0,0 +1,29 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +//#include + +double +fabs (double number) +{ + if (number < 0) + return -number; + return number; +} diff --git a/lib/posix/alarm.c b/lib/posix/alarm.c new file mode 100644 index 00000000..5261c2e7 --- /dev/null +++ b/lib/posix/alarm.c @@ -0,0 +1,37 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +unsigned int +alarm (unsigned int seconds) +{ +#if !__MESC__ + struct itimerval old; + struct itimerval new; + new.it_interval.tv_usec = 0; + new.it_interval.tv_sec = 0; + new.it_value.tv_usec = 0; + new.it_value.tv_sec = (long int) seconds; + if (setitimer (ITIMER_REAL, &new, &old) < 0) + return 0; + return old.it_value.tv_sec; +#endif +} diff --git a/lib/getopt.c b/lib/posix/getopt.c similarity index 100% rename from lib/getopt.c rename to lib/posix/getopt.c diff --git a/lib/posix/mktemp.c b/lib/posix/mktemp.c new file mode 100644 index 00000000..256db921 --- /dev/null +++ b/lib/posix/mktemp.c @@ -0,0 +1,35 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +char * +mktemp (char *template) +{ + char *p = strchr (template, '\0'); + int q = (int)template; + *--p = ((unsigned char)(q >> 4)) % 26 + 'a'; + *--p = ((unsigned char)(q >> 8)) % 26 + 'a'; + *--p = ((unsigned char)(q >> 12)) % 26 + 'a'; + *--p = ((unsigned char)(q >> 16)) % 26 + 'a'; + *--p = ((unsigned char)(q >> 20)) % 26 + 'a'; + *--p = ((unsigned char)(q >> 24)) % 26 + 'a'; + return template; +} diff --git a/lib/posix/raise.c b/lib/posix/raise.c new file mode 100644 index 00000000..f05c210f --- /dev/null +++ b/lib/posix/raise.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +raise (int signum) +{ + kill (getpid (), signum); +} diff --git a/lib/posix/sbrk.c b/lib/posix/sbrk.c new file mode 100644 index 00000000..723db5f1 --- /dev/null +++ b/lib/posix/sbrk.c @@ -0,0 +1,34 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +#if __SBRK_CHAR_PTRDIFF +char * +sbrk (ptrdiff_t) +#else +void * +sbrk (intptr_t delta) +#endif +{ + if (delta >= 0) + return malloc (delta); + return __brk; +} diff --git a/lib/posix/sleep.c b/lib/posix/sleep.c new file mode 100644 index 00000000..4e3377a4 --- /dev/null +++ b/lib/posix/sleep.c @@ -0,0 +1,31 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +unsigned int +sleep (unsigned int seconds) +{ + struct timespec requested_time; + struct timespec remaining; + requested_time.tv_sec = seconds; + requested_time.tv_nsec = 0; + return nanosleep (&requested_time, &remaining); +} diff --git a/lib/posix/unsetenv.c b/lib/posix/unsetenv.c new file mode 100644 index 00000000..70aed68a --- /dev/null +++ b/lib/posix/unsetenv.c @@ -0,0 +1,39 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +void +unsetenv (char const *name) +{ + int length = strlen (name); + char **p = environ; + while (*p) + { + if (!strncmp (name, *p, length) && *(*p + length) == '=') + { + char **q = p; + q[0] = q[1]; + while (*q++) + q[0] = q[1]; + } + p++; + } +} diff --git a/lib/stdio/clearerr.c b/lib/stdio/clearerr.c new file mode 100644 index 00000000..3be2ba9c --- /dev/null +++ b/lib/stdio/clearerr.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +void +clearerr (FILE *stream) +{ + errno = 0; +} diff --git a/lib/stdio/fdgets.c b/lib/stdio/fdgets.c new file mode 100644 index 00000000..b151a451 --- /dev/null +++ b/lib/stdio/fdgets.c @@ -0,0 +1,39 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +char * +fdgets (char *s, int count, int fd) +{ + int c = 0; + char *p = s; + while (--count > 0 && c != '\n') + { + c = fdgetc (fd); + if (c == EOF) + break; + *p++ = c; + } + if (p == s && (c == EOF || count == -1)) + return 0; + *p = 0; + return s; +} diff --git a/lib/stdio/feof.c b/lib/stdio/feof.c new file mode 100644 index 00000000..0e7149fd --- /dev/null +++ b/lib/stdio/feof.c @@ -0,0 +1,30 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +feof (FILE *stream) +{ + char c = fgetc (stream); + if (c != EOF) + ungetc (c, stream); + return c == EOF; +} diff --git a/lib/stdio/fgets.c b/lib/stdio/fgets.c new file mode 100644 index 00000000..fb6d5f77 --- /dev/null +++ b/lib/stdio/fgets.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +char * +fgets (char *s, int count, FILE *stream) +{ + return fdgets (s, count, (int)stream); +} diff --git a/lib/stdio/fileno.c b/lib/stdio/fileno.c new file mode 100644 index 00000000..f5fe98ee --- /dev/null +++ b/lib/stdio/fileno.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +fileno (FILE *stream) +{ + return (int)stream; +} diff --git a/lib/stdio/freeopen.c b/lib/stdio/freeopen.c new file mode 100644 index 00000000..757e48b8 --- /dev/null +++ b/lib/stdio/freeopen.c @@ -0,0 +1,28 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +FILE * +freopen (char const *file_name, char const *opentype, FILE *stream) +{ + fclose (stream); + return fopen (file_name, opentype); +} diff --git a/lib/stdio/freopen.c b/lib/stdio/freopen.c new file mode 100644 index 00000000..757e48b8 --- /dev/null +++ b/lib/stdio/freopen.c @@ -0,0 +1,28 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +FILE * +freopen (char const *file_name, char const *opentype, FILE *stream) +{ + fclose (stream); + return fopen (file_name, opentype); +} diff --git a/lib/stdio/perror.c b/lib/stdio/perror.c new file mode 100644 index 00000000..8ac72364 --- /dev/null +++ b/lib/stdio/perror.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +void +perror (char const *message) +{ + fprintf (stderr, "%s: %s\n", strerror (errno), message); +} diff --git a/lib/stdlib/__exit.c b/lib/stdlib/__exit.c new file mode 100644 index 00000000..4eb7c764 --- /dev/null +++ b/lib/stdlib/__exit.c @@ -0,0 +1,25 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 +__exit (int status) +{ + exit (status); +} diff --git a/lib/stdlib/abs.c b/lib/stdlib/abs.c new file mode 100644 index 00000000..338aeaff --- /dev/null +++ b/lib/stdlib/abs.c @@ -0,0 +1,29 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +abs (int x) +{ + if (x < 0) + return -x; + return x; +} diff --git a/lib/stdlib/atexit.c b/lib/stdlib/atexit.c new file mode 100644 index 00000000..df35321e --- /dev/null +++ b/lib/stdlib/atexit.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +atexit (void (*function) (void)) +{ + __call_at_exit = function; +} diff --git a/lib/stdlib/atol.c b/lib/stdlib/atol.c new file mode 100644 index 00000000..93395373 --- /dev/null +++ b/lib/stdlib/atol.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +atol (char const *s) +{ + return atoi (s); +} diff --git a/lib/stdlib/bsearch.c b/lib/stdlib/bsearch.c new file mode 100644 index 00000000..a6303021 --- /dev/null +++ b/lib/stdlib/bsearch.c @@ -0,0 +1,35 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +void * +#if __MESC__ +bsearch (void const *key, void const *array, size_t count, size_t size, void (*compare) ()) +#else +bsearch (void const *key, void const *array, size_t count, size_t size, comparison_fn_t compare) +#endif +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("bsearch stub\n"); + stub = 1; + return 0; +} diff --git a/lib/stdlib/mbstowcs.c b/lib/stdlib/mbstowcs.c new file mode 100644 index 00000000..9330f355 --- /dev/null +++ b/lib/stdlib/mbstowcs.c @@ -0,0 +1,37 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +#if !__MESC__ +typedef char wchar_t[]; + +size_t +mbstowcs (wchar_t *wstring, char const *string, + size_t size) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("mbstowcs stub\n"); + stub = 1; + strcpy (wstring, string); + return strlen (string); +} +#endif diff --git a/lib/string/bcmp.c b/lib/string/bcmp.c new file mode 100644 index 00000000..bf2c5972 --- /dev/null +++ b/lib/string/bcmp.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +bcmp (void const *s1, void const *s2, size_t size) +{ + return memcmp (s1, s2, size); +} diff --git a/lib/string/bcopy.c b/lib/string/bcopy.c new file mode 100644 index 00000000..7b02a1d6 --- /dev/null +++ b/lib/string/bcopy.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +void +bcopy (void const *src, void *dest, size_t n) +{ + memmove (dest, src, n); +} diff --git a/lib/string/bzero.c b/lib/string/bzero.c new file mode 100644 index 00000000..69bdcca3 --- /dev/null +++ b/lib/string/bzero.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +bzero (void *block, size_t size) +{ + return memset (block, 0, size); +} diff --git a/lib/string/index.c b/lib/string/index.c new file mode 100644 index 00000000..3841d94c --- /dev/null +++ b/lib/string/index.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +index (char const *s, int c) +{ + return strchr (s, c); +} diff --git a/lib/string/rindex.c b/lib/string/rindex.c new file mode 100644 index 00000000..848fae70 --- /dev/null +++ b/lib/string/rindex.c @@ -0,0 +1,27 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +rindex (char const *s, int c) +{ + return strrchr (s, c); +} diff --git a/lib/string/strcspn.c b/lib/string/strcspn.c new file mode 100644 index 00000000..4a4ed5e2 --- /dev/null +++ b/lib/string/strcspn.c @@ -0,0 +1,33 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +size_t +strcspn (char const *string, char const *stopset) +{ + char *p = string; + while (*p) + if (strchr (stopset, *p)) + break; + else + p++; + return p - string; +} diff --git a/lib/string/strdup.c b/lib/string/strdup.c new file mode 100644 index 00000000..5a81323e --- /dev/null +++ b/lib/string/strdup.c @@ -0,0 +1,31 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +char * +strdup (char const *s) +{ + size_t length = strlen (s) + 1; + char *p = (char*)malloc (length); + if (p) + return memcpy (p, s, length); + return 0; +} diff --git a/lib/string/strerror.c b/lib/string/strerror.c new file mode 100644 index 00000000..d409482a --- /dev/null +++ b/lib/string/strerror.c @@ -0,0 +1,79 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +char *sys_errlist[] = + { + "error 00", + "error 01", + "error 02", + "error 03", + "error 04", + "error 05", + "error 06", + "error 07", + "error 08", + "error 09", + "error 10", + "error 11", + "error 12", + "error 13", + "error 14", + "error 15", + "error 16", + "error 17", + "error 18", + "error 19", + "error 20", + "error 21", + "error 22", + "error 23", + "error 24", + "error 25", + "error 26", + "error 27", + "error 28", + "error 29", + "error 30", + "error 31", + "error 32", + "error 33", + "error 34", + "error 35", + "error 36", + "error 37", + "error 38", + "error 39", + }; + +int sys_nerr = 39; + +char * +strerror (int errnum) +{ + if (__mes_debug ()) + { + eputs ("strerror errnum="); eputs (itoa (errnum)); eputs ("\n"); + } + if (errnum > 0 && errnum <= sys_nerr) + return sys_errlist[errnum]; + return "sterror: unknown error"; +} diff --git a/lib/string/strncat.c b/lib/string/strncat.c new file mode 100644 index 00000000..ff3ba121 --- /dev/null +++ b/lib/string/strncat.c @@ -0,0 +1,33 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +char * +strncat (char *to, char const *from, size_t size) +{ + if (size == 0) + return to; + char *p = strchr (to , '\0'); + while (*from && size-- > 0) + *p++ = *from++; + *p = 0; + return to; +} diff --git a/lib/string/strpbrk.c b/lib/string/strpbrk.c new file mode 100644 index 00000000..a79a8122 --- /dev/null +++ b/lib/string/strpbrk.c @@ -0,0 +1,33 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +char * +strpbrk (char const *string, char const* stopset) +{ + char *p = string; + while (*p) + if (strchr (stopset, *p)) + break; + else + p++; + return p; +} diff --git a/lib/string/strspn.c b/lib/string/strspn.c new file mode 100644 index 00000000..d668d29d --- /dev/null +++ b/lib/string/strspn.c @@ -0,0 +1,33 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +size_t +strspn (char const *string, char const *skipset) +{ + char *p = string; + while (*p) + if (!strchr (skipset, *p)) + break; + else + p++; + return p - string; +} diff --git a/lib/stub/__cleanup.c b/lib/stub/__cleanup.c new file mode 100644 index 00000000..f7299fca --- /dev/null +++ b/lib/stub/__cleanup.c @@ -0,0 +1,31 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +__cleanup () +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("__cleanup stub\n"); + stub = 1; + return 0; +} diff --git a/lib/stub/atof.c b/lib/stub/atof.c new file mode 100644 index 00000000..3cc951d9 --- /dev/null +++ b/lib/stub/atof.c @@ -0,0 +1,31 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +atof (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("atof stub\n"); + stub = 1; + return 0; +} diff --git a/lib/stub/chown.c b/lib/stub/chown.c new file mode 100644 index 00000000..bf44169a --- /dev/null +++ b/lib/stub/chown.c @@ -0,0 +1,33 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include +#include + +int +chown (char const *file_name, uid_t owner, gid_t group) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("chown stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/ctime.c b/lib/stub/ctime.c new file mode 100644 index 00000000..30c7475b --- /dev/null +++ b/lib/stub/ctime.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +ctime (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("ctime stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/fpurge.c b/lib/stub/fpurge.c new file mode 100644 index 00000000..991cd493 --- /dev/null +++ b/lib/stub/fpurge.c @@ -0,0 +1,33 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include +#include + +int +fpurge (FILE *stream) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("fpurge stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/freadahead.c b/lib/stub/freadahead.c new file mode 100644 index 00000000..136b03a7 --- /dev/null +++ b/lib/stub/freadahead.c @@ -0,0 +1,33 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include +#include + +size_t +freadahead (FILE *fp) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("freadahead stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/frexp.c b/lib/stub/frexp.c new file mode 100644 index 00000000..22c1e6cf --- /dev/null +++ b/lib/stub/frexp.c @@ -0,0 +1,31 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +frexp (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("frexp stub\n"); + stub = 1; + return 0; +} diff --git a/lib/stub/fscanf.c b/lib/stub/fscanf.c new file mode 100644 index 00000000..daae853d --- /dev/null +++ b/lib/stub/fscanf.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include +#include + +int +fscanf (FILE *stream, char const *template, ...) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("fscan stub\n"); + stub = 1; + return 0; +} diff --git a/lib/stub/getpwnam.c b/lib/stub/getpwnam.c new file mode 100644 index 00000000..472b42aa --- /dev/null +++ b/lib/stub/getpwnam.c @@ -0,0 +1,33 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include +#include + +struct passwd * +getpwnam (const char *NAME) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("getpwnam stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/gmtime.c b/lib/stub/gmtime.c new file mode 100644 index 00000000..85e45ddd --- /dev/null +++ b/lib/stub/gmtime.c @@ -0,0 +1,34 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include +#include +#include + +struct tm * +gmtime (time_t const *time) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("gmtime stub\n"); + stub = 1; + errno = 0; + return localtime (time); +} diff --git a/lib/stub/pclose.c b/lib/stub/pclose.c new file mode 100644 index 00000000..244bcc74 --- /dev/null +++ b/lib/stub/pclose.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +pclose (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("pclose stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/popen.c b/lib/stub/popen.c new file mode 100644 index 00000000..294a24c3 --- /dev/null +++ b/lib/stub/popen.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +popen (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("popen stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/rewind.c b/lib/stub/rewind.c new file mode 100644 index 00000000..e62d3fb8 --- /dev/null +++ b/lib/stub/rewind.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +rewind (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("rewind stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/setbuf.c b/lib/stub/setbuf.c new file mode 100644 index 00000000..debf05b7 --- /dev/null +++ b/lib/stub/setbuf.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +setbuf (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("setbuf stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/sigsetmask.c b/lib/stub/sigsetmask.c new file mode 100644 index 00000000..4c6b570c --- /dev/null +++ b/lib/stub/sigsetmask.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +sigsetmask (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("sigsetmask stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/strftime.c b/lib/stub/strftime.c new file mode 100644 index 00000000..ad7a26be --- /dev/null +++ b/lib/stub/strftime.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +size_t +strftime (char *s, size_t size, char const *template, + struct tm const *brokentime) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("strftime stub\n"); + stub = 1; + return template; +} diff --git a/lib/stub/sys_siglist.c b/lib/stub/sys_siglist.c new file mode 100644 index 00000000..6f4aef35 --- /dev/null +++ b/lib/stub/sys_siglist.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +sys_siglist (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("sys_siglist stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/system.c b/lib/stub/system.c new file mode 100644 index 00000000..401854aa --- /dev/null +++ b/lib/stub/system.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +system (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("system stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/times.c b/lib/stub/times.c new file mode 100644 index 00000000..4de69cbd --- /dev/null +++ b/lib/stub/times.c @@ -0,0 +1,33 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include +#include +#include + +clock_t +times (struct tms *buffer) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("times stub\n"); + stub = 1; + return 0; +} diff --git a/lib/stub/umask.c b/lib/stub/umask.c new file mode 100644 index 00000000..41c736b6 --- /dev/null +++ b/lib/stub/umask.c @@ -0,0 +1,32 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +umask (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("umask stub\n"); + stub = 1; + errno = 0; + return 0; +} diff --git a/lib/stub/utime.c b/lib/stub/utime.c new file mode 100644 index 00000000..67247c9a --- /dev/null +++ b/lib/stub/utime.c @@ -0,0 +1,31 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 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 . + */ + +#include + +int +utime (int x) +{ + static int stub = 0; + if (__mes_debug () && !stub) + eputs ("utime stub\n"); + errno = 0; + return 0; +}