From 58fb0cf764ac47204d22a10c709a4635d8bb5f0a Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 24 Aug 2019 19:05:58 +0200 Subject: [PATCH] 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. --- include/time.h | 2 +- lib/stub/getgrgid.c | 10 ++++++++-- lib/stub/getgrnam.c | 10 ++++++++-- lib/stub/getpgid.c | 1 + lib/stub/getpgrp.c | 1 + lib/stub/mktime.c | 3 ++- lib/stub/setgrent.c | 1 + 7 files changed, 22 insertions(+), 6 deletions(-) diff --git a/include/time.h b/include/time.h index 60cc0f44..161d006f 100644 --- a/include/time.h +++ b/include/time.h @@ -59,7 +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 mktime (struct tm *broken_time); +time_t mktime (struct tm *broken_time); int nanosleep (struct timespec const *requested_time, struct timespec const *remaining); time_t time (time_t * tloc); diff --git a/lib/stub/getgrgid.c b/lib/stub/getgrgid.c index 9859b8dd..88898714 100644 --- a/lib/stub/getgrgid.c +++ b/lib/stub/getgrgid.c @@ -19,6 +19,7 @@ */ #include +#include #include struct group * @@ -27,8 +28,13 @@ getgrgid (gid_t gid) static int stub = 0; if (__mes_debug () && !stub) eputs ("getgrid stub\n"); - static char *groups[2] = {"root", 0 }; - static struct group root = {"root", 0, groups}; + static char *groups[2] = { "root", 0 }; +#if SYSTEM_LIBC + static struct group root = { "root", 0, 0 }; + root.gr_mem = groups; +#else + static struct group root = { "root", 0, groups }; +#endif stub = 1; errno = 0; return &root; diff --git a/lib/stub/getgrnam.c b/lib/stub/getgrnam.c index 466d738e..4efde888 100644 --- a/lib/stub/getgrnam.c +++ b/lib/stub/getgrnam.c @@ -19,6 +19,7 @@ */ #include +#include #include struct group * @@ -27,8 +28,13 @@ getgrnam (char const *name) static int stub = 0; if (__mes_debug () && !stub) eputs ("getgrid stub\n"); - static char *groups[2] = {"root", 0 }; - static struct group root = {"root", 0, groups}; + static char *groups[2] = { "root", 0 }; +#if SYSTEM_LIBC + static struct group root = { "root", 0, 0 }; + root.gr_mem = groups; +#else + static struct group root = { "root", 0, groups }; +#endif stub = 1; errno = 0; return &root; diff --git a/lib/stub/getpgid.c b/lib/stub/getpgid.c index f82d3c5e..8ad82ee2 100644 --- a/lib/stub/getpgid.c +++ b/lib/stub/getpgid.c @@ -19,6 +19,7 @@ */ #include +#include #include int diff --git a/lib/stub/getpgrp.c b/lib/stub/getpgrp.c index 7b7510b1..a9ddcaae 100644 --- a/lib/stub/getpgrp.c +++ b/lib/stub/getpgrp.c @@ -19,6 +19,7 @@ */ #include +#include #include pid_t diff --git a/lib/stub/mktime.c b/lib/stub/mktime.c index 65e49acf..093d73b6 100644 --- a/lib/stub/mktime.c +++ b/lib/stub/mktime.c @@ -19,9 +19,10 @@ */ #include +#include #include -int +time_t mktime (struct tm *broken_time) { static int stub = 0; diff --git a/lib/stub/setgrent.c b/lib/stub/setgrent.c index 5e6e27e2..daa6d89d 100644 --- a/lib/stub/setgrent.c +++ b/lib/stub/setgrent.c @@ -19,6 +19,7 @@ */ #include +#include void setgrent (void)