build: Improve --with-system-libc support.
* build-aux/build-lib.sh: Avoid building libc for --with-system-libc. Make libmes richer. build-aux/check-mescc.sh: Enable 50-malloc test. * include/dirstream.h: Use HAVE_DIRSTREAM_H to cater for non-existing dirstream.h. * include/grp.h[SYSTEM_LIBC]: Typo. * include/mes/lib.h (__brk, __call_at_exit)[SYSTEM_LIBC]: Declare. * include/stdlib.h (comparison_fn_t)[SYSTEM_LIBC]: Declare. * include/time.h (mktime): Return time_t. * lib/posix/isatty.c [SYSTEM_LIBC]: Do not (re)declare termios. * lib/stub/mktime.c (mktime): Return time_t. * lib/tests/scaffold/41-ternary.c (main): Remove assumption that locals are initialized. * lib/tests/scaffold/70-stdarg.c: Cater for SYSTEM_LIBC. * lib/tests/setjmp/80-setjmp.c: Declare jmp buf. * lib/*/*.c: Add missing mes/lib.h, errno.h includes.
This commit is contained in:
parent
9f60920538
commit
dd0a0d779a
|
@ -52,6 +52,8 @@ fi
|
|||
|
||||
libmes_SOURCES="
|
||||
$libc_mini_SOURCES
|
||||
lib/ctype/isnumber.c
|
||||
lib/mes/abtol.c
|
||||
lib/mes/itoa.c
|
||||
lib/mes/ltoa.c
|
||||
lib/mes/ltoab.c
|
||||
|
@ -70,12 +72,13 @@ lib/mes/oputc.c
|
|||
if test $mes_libc = mes; then
|
||||
libmes_SOURCES="$libmes_SOURCES
|
||||
lib/stdlib/atoi.c
|
||||
lib/mes/abtol.c
|
||||
lib/ctype/isdigit.c
|
||||
lib/ctype/isnumber.c
|
||||
lib/ctype/isspace.c
|
||||
lib/ctype/isxdigit.c
|
||||
"
|
||||
else
|
||||
libmes_SOURCES="$libmes_SOURCES
|
||||
"
|
||||
fi
|
||||
|
||||
libc_SOURCES="
|
||||
|
@ -184,55 +187,7 @@ lib/stub/ldexp.c
|
|||
lib/stub/mprotect.c
|
||||
lib/stub/localtime.c
|
||||
lib/stub/sigemptyset.c
|
||||
lib/ctype/islower.c
|
||||
lib/ctype/isupper.c
|
||||
lib/ctype/tolower.c
|
||||
lib/ctype/toupper.c
|
||||
lib/mes/search-path.c
|
||||
lib/posix/execvp.c
|
||||
lib/stdio/fclose.c
|
||||
lib/stdio/fdopen.c
|
||||
lib/stdio/ferror.c
|
||||
lib/stdio/fflush.c
|
||||
lib/stdio/fopen.c
|
||||
lib/stdio/fprintf.c
|
||||
lib/stdio/fread.c
|
||||
lib/stdio/fseek.c
|
||||
lib/stdio/ftell.c
|
||||
lib/stdio/fwrite.c
|
||||
lib/stdio/printf.c
|
||||
lib/stdio/remove.c
|
||||
lib/stdio/snprintf.c
|
||||
lib/stdio/sprintf.c
|
||||
lib/stdio/sscanf.c
|
||||
lib/stdio/vfprintf.c
|
||||
lib/stdio/vprintf.c
|
||||
lib/stdio/vsnprintf.c
|
||||
lib/stdio/vsprintf.c
|
||||
lib/stdio/vsscanf.c
|
||||
lib/stdlib/calloc.c
|
||||
lib/stdlib/qsort.c
|
||||
lib/stdlib/strtof.c
|
||||
lib/stdlib/strtol.c
|
||||
lib/stdlib/strtold.c
|
||||
lib/stdlib/strtoll.c
|
||||
lib/stdlib/strtoul.c
|
||||
lib/stdlib/strtoull.c
|
||||
lib/string/memmem.c
|
||||
lib/string/memmove.c
|
||||
lib/string/strcat.c
|
||||
lib/string/strchr.c
|
||||
lib/string/strlwr.c
|
||||
lib/string/strncpy.c
|
||||
lib/string/strrchr.c
|
||||
lib/string/strstr.c
|
||||
lib/string/strupr.c
|
||||
lib/stub/sigaction.c
|
||||
lib/stub/ldexp.c
|
||||
lib/stub/mprotect.c
|
||||
lib/stub/localtime.c
|
||||
lib/stub/sigemptyset.c
|
||||
xslib/stub/strtod.c
|
||||
lib/stub/strtod.c
|
||||
lib/$mes_cpu-mes-$compiler/setjmp.c
|
||||
"
|
||||
|
||||
|
@ -367,10 +322,12 @@ if test -e libmes.s; then
|
|||
cp libmes.s $mes_cpu-mes
|
||||
fi
|
||||
|
||||
if test $mes_libc = mes; then
|
||||
archive libc.a $libc_SOURCES
|
||||
cp libc.a $mes_cpu-mes
|
||||
if test -e libc.s; then
|
||||
cp libc.S $mes_cpu-mes
|
||||
cp libc.s $mes_cpu-mes
|
||||
fi
|
||||
fi
|
||||
|
||||
archive libc+tcc.a $libc_tcc_SOURCES
|
||||
|
|
|
@ -101,6 +101,7 @@ lib/tests/scaffold/48-global-static.c
|
|||
lib/tests/assert/50-assert.c
|
||||
lib/tests/mes/50-itoa.c
|
||||
lib/tests/posix/50-getenv.c
|
||||
lib/tests/stdlib/50-malloc.c
|
||||
lib/tests/string/50-strcmp.c
|
||||
lib/tests/string/50-strcpy.c
|
||||
lib/tests/string/50-strncmp.c
|
||||
|
|
|
@ -50,7 +50,7 @@ fi
|
|||
|
||||
if test $mes_libc = system; then
|
||||
crt1=
|
||||
LIBS=-lmes
|
||||
LIBS='-l mes'
|
||||
else
|
||||
crt1=crt1.o
|
||||
fi
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef __MES_DIRSTREAM_H
|
||||
#define __MES_DIRSTREAM_H 1
|
||||
|
||||
#if SYSTEM_LIBC
|
||||
#if SYSTEM_LIBC && HAVE_DIRSTREAM_H
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#if SYSTEM_LIBC
|
||||
#undef __MES_GRP_H
|
||||
#include_next <pwd.h>
|
||||
#include_next <grp.h>
|
||||
#else // ! SYSTEM_LIBC
|
||||
|
||||
#include <sys/types.h>
|
||||
|
|
|
@ -41,6 +41,7 @@ char * fdgets (char *s, int count, int fd);
|
|||
int fdputc (int c, int fd);
|
||||
int fdputs (char const *s, int fd);
|
||||
int fdungetc (int c, int fd);
|
||||
int isnumber (int c, int base);
|
||||
int mes_open (char const *file_name, int flags, int mask);
|
||||
int _open2 (char const *file_name, int flags);
|
||||
int _open3 (char const *file_name, int flags, int mask);
|
||||
|
@ -48,10 +49,10 @@ int oputc (int c);
|
|||
int oputs (char const *s);
|
||||
char *search_path (char const *file_name);
|
||||
|
||||
#if !SYSTEM_LIBC
|
||||
|
||||
extern char *__brk;
|
||||
extern void (*__call_at_exit) (void);
|
||||
|
||||
#if !SYSTEM_LIBC
|
||||
void __assert_fail (char *s);
|
||||
void _exit (int code);
|
||||
long brk (void *addr);
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
#ifndef __MES_STDLIB_H
|
||||
#define __MES_STDLIB_H 1
|
||||
|
||||
#ifndef __MES_COMPARISON_FN_T
|
||||
#define __MES_COMPARISON_FN_T
|
||||
typedef int (*comparison_fn_t) (void const *, void const *);
|
||||
#endif
|
||||
|
||||
#if SYSTEM_LIBC
|
||||
#ifndef _GNU_SOURCE
|
||||
#define _GNU_SOURCE
|
||||
|
@ -56,11 +61,6 @@ unsigned long long strtoull (char const *string, char **tailptr, int base);
|
|||
#define EXIT_FAILURE 1
|
||||
#define EXIT_SUCCESS 0
|
||||
|
||||
#ifndef __MES_COMPARISON_FN_T
|
||||
#define __MES_COMPARISON_FN_T
|
||||
typedef int (*comparison_fn_t) (void const *, void const *);
|
||||
#endif
|
||||
|
||||
void *bsearch (void const *key, void const *array, size_t count, size_t size, comparison_fn_t compare);
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
|
|
@ -59,6 +59,7 @@ struct timespec
|
|||
int clock_gettime (clockid_t clk_id, struct timespec *tp);
|
||||
struct tm *localtime (time_t const *timep);
|
||||
struct tm *gmtime (time_t const *time);
|
||||
int nanosleep (struct timespec const *requested_time, struct timespec const *remaining);
|
||||
time_t time (time_t * tloc);
|
||||
|
||||
#endif // ! SYSTEM_LIBC
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
// Taken from GNU C Library 1.06.4
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <dirent.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
// Taken from GNU C Library 2.2.5
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <stddef.h>
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <string.h>
|
||||
#include <termio.h>
|
||||
|
||||
#if !SYSTEM_LIBC
|
||||
typedef unsigned char cc_t;
|
||||
typedef unsigned int speed_t;
|
||||
typedef unsigned int tcflag_t;
|
||||
|
@ -39,6 +40,7 @@ struct termios
|
|||
cc_t c_line;
|
||||
cc_t c_cc[NCCS];
|
||||
};
|
||||
#endif
|
||||
|
||||
struct ktermios
|
||||
{
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -26,7 +27,7 @@ printf (char const *format, ...)
|
|||
{
|
||||
va_list ap;
|
||||
int r;
|
||||
#if __GNUC__ && __x86_64__
|
||||
#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC
|
||||
#define __FUNCTION_ARGS 1
|
||||
ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3;
|
||||
#undef __FUNCTION_ARGS
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -26,7 +27,7 @@ snprintf (char *str, size_t size, char const *format, ...)
|
|||
{
|
||||
va_list ap;
|
||||
int r;
|
||||
#if __GNUC__ && __x86_64__
|
||||
#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC
|
||||
#define __FUNCTION_ARGS 3
|
||||
ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3;
|
||||
#undef __FUNCTION_ARGS
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -26,7 +27,7 @@ sprintf (char *str, char const *format, ...)
|
|||
{
|
||||
va_list ap;
|
||||
int r;
|
||||
#if __GNUC__ && __x86_64__
|
||||
#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC
|
||||
#define __FUNCTION_ARGS 2
|
||||
ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3;
|
||||
#undef __FUNCTION_ARGS
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
|
||||
int
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
|
||||
size_t
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
char *
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
|
||||
struct passwd *
|
||||
|
|
|
@ -19,10 +19,11 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
|
||||
struct passwd *
|
||||
getpwuid ()
|
||||
getpwuid (uid_t uid)
|
||||
{
|
||||
static int stub = 0;
|
||||
if (__mes_debug () && !stub)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
pclose (int x)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
popen (int x)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <pwd.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
rand (void)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
rewind (int x)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
setbuf (int x)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
sigsetmask (int x)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
sys_siglist (int x)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
system (int x)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
|
||||
char *
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
umask (int x)
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
|
||||
int
|
||||
utime (int x)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <mes/lib.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* -*-comment-start: "//";comment-end:""-*-
|
||||
* GNU Mes --- Maxwell Equations of Software
|
||||
* Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
* Copyright © 2017,2018,2019 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
||||
*
|
||||
* This file is part of GNU Mes.
|
||||
*
|
||||
|
@ -23,7 +23,7 @@
|
|||
int
|
||||
main ()
|
||||
{
|
||||
int f;
|
||||
int f = 0;
|
||||
int t = 1;
|
||||
int one = t;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ stdarg1 (long *one, ...)
|
|||
int r;
|
||||
|
||||
va_start (ap, one);
|
||||
#if __GNUC__ && __x86_64__
|
||||
#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC
|
||||
#define __FUNCTION_ARGS 1
|
||||
ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3;
|
||||
#undef __FUNCTION_ARGS
|
||||
|
@ -54,7 +54,7 @@ stdarg2 (long *one, long *two, ...)
|
|||
int r;
|
||||
|
||||
va_start (ap, two);
|
||||
#if __GNUC__ && __x86_64__
|
||||
#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC
|
||||
#define __FUNCTION_ARGS 2
|
||||
ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3;
|
||||
#undef __FUNCTION_ARGS
|
||||
|
@ -78,7 +78,7 @@ stdarg3 (long *one, long *two, long *three, ...)
|
|||
int r;
|
||||
|
||||
va_start (ap, three);
|
||||
#if __GNUC__ && __x86_64__
|
||||
#if __GNUC__ && __x86_64__ && !SYSTEM_LIBC
|
||||
#define __FUNCTION_ARGS 3
|
||||
ap += (__FOO_VARARGS + (__FUNCTION_ARGS << 1)) << 3;
|
||||
#undef __FUNCTION_ARGS
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <setjmp.h>
|
||||
|
||||
int foo;
|
||||
jmp_buf buf;
|
||||
|
||||
void
|
||||
second ()
|
||||
|
|
Loading…
Reference in a new issue