diff options
-rwxr-xr-x | emcc | 17 | ||||
-rw-r--r-- | system/lib/libc.symbols | 33 | ||||
-rw-r--r-- | system/lib/libc/gen/err.c | 49 | ||||
-rw-r--r-- | system/lib/libc/gen/errx.c | 49 | ||||
-rw-r--r-- | system/lib/libc/gen/verr.c | 58 | ||||
-rw-r--r-- | system/lib/libc/gen/verrx.c | 51 | ||||
-rw-r--r-- | system/lib/libc/gen/vwarn.c | 55 | ||||
-rw-r--r-- | system/lib/libc/gen/vwarnx.c | 48 | ||||
-rw-r--r-- | system/lib/libc/gen/warn.c | 49 | ||||
-rw-r--r-- | system/lib/libc/gen/warnx.c | 49 | ||||
-rw-r--r-- | system/lib/libc/musl/readme.txt | 4 | ||||
-rw-r--r-- | system/lib/libc/musl/src/legacy/err.c | 67 | ||||
-rw-r--r-- | system/lib/libc/musl/src/misc/getopt.c | 74 | ||||
-rw-r--r-- | system/lib/libc/musl/src/misc/getopt_long.c | 59 | ||||
-rw-r--r-- | system/lib/libc/musl/src/stdio/__toread.c | 10 | ||||
-rw-r--r-- | system/lib/libc/musl/src/stdio/__towrite.c | 18 | ||||
-rw-r--r-- | system/lib/libc/musl/src/stdlib/strtod.c | 24 | ||||
-rw-r--r-- | system/lib/libc/stdlib/getopt_long.c | 511 | ||||
-rw-r--r-- | system/lib/libc/stdlib/strtod.c | 305 | ||||
-rw-r--r-- | system/lib/libcextra.symbols | 23 | ||||
-rw-r--r-- | tools/shared.py | 2 |
21 files changed, 275 insertions, 1280 deletions
@@ -1440,15 +1440,6 @@ try: libc_files = [ 'dlmalloc.c', os.path.join('libcxx', 'new.cpp'), - os.path.join('libc', 'stdlib', 'getopt_long.c'), - os.path.join('libc', 'gen', 'err.c'), - os.path.join('libc', 'gen', 'errx.c'), - os.path.join('libc', 'gen', 'warn.c'), - os.path.join('libc', 'gen', 'warnx.c'), - os.path.join('libc', 'gen', 'verr.c'), - os.path.join('libc', 'gen', 'verrx.c'), - os.path.join('libc', 'gen', 'vwarn.c'), - os.path.join('libc', 'gen', 'vwarnx.c'), ] musl_files = [ ['internal', [ @@ -1462,6 +1453,7 @@ try: ['stdio', [ '__overflow.c', '__toread.c', + '__towrite.c', '__uflow.c', ]], ['stdlib', [ @@ -1511,6 +1503,9 @@ try: ['internal', [ 'intscan.c', ]], + ['legacy', [ + 'err.c', + ]], ['locale', [ 'iconv.c', 'iswalnum_l.c', @@ -1563,6 +1558,10 @@ try: 'tgammaf.c', 'tgammal.c' ]], + ['misc', [ + 'getopt.c', + 'getopt_long.c', + ]], ['multibyte', [ 'btowc.c', 'mblen.c', diff --git a/system/lib/libc.symbols b/system/lib/libc.symbols index 04fb40d6..6f80ef90 100644 --- a/system/lib/libc.symbols +++ b/system/lib/libc.symbols @@ -41,32 +41,18 @@ W _ZnwjRKSt9nothrow_t T __floatscan T __overflow - T __seek_on_exit T __shgetc T __shlim W __strtod_l W __strtof_l W __strtold_l T __toread - W __towrite_used + T __towrite T __uflow - T _err - T _errx - T _verr - T _verrx - T _vwarn - T _vwarnx - T _warn - T _warnx T atof W bulk_free W calloc - W err - W errx W free - T getopt - T getopt_long - T getopt_long_only W independent_calloc W independent_comalloc W mallinfo @@ -80,11 +66,6 @@ W malloc_usable_size W mallopt W memalign - C optarg - D opterr - D optind - D optopt - C optreset W posix_memalign W pvalloc W realloc @@ -92,15 +73,9 @@ T scalbn T scalbnl T strtod - W strtod_l + T strtod_l T strtof - W strtof_l + T strtof_l T strtold - W strtold_l + T strtold_l W valloc - W verr - W verrx - W vwarn - W vwarnx - W warn - W warnx diff --git a/system/lib/libc/gen/err.c b/system/lib/libc/gen/err.c deleted file mode 100644 index 218a3bfc..00000000 --- a/system/lib/libc/gen/err.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: err.c,v 1.11 2012/12/05 23:19:59 deraadt Exp $ */ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <err.h> -#include <stdarg.h> - -#define __dead __attribute__((__noreturn__)) - -/* PRINTFLIKE2 */ -__dead void -_err(int eval, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - _verr(eval, fmt, ap); - va_end(ap); -} - -/* PRINTFLIKE2 */ -__dead void -err(int eval, const char *fmt, ...) __attribute__((weak, alias("_err"))); diff --git a/system/lib/libc/gen/errx.c b/system/lib/libc/gen/errx.c deleted file mode 100644 index a16643c7..00000000 --- a/system/lib/libc/gen/errx.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: errx.c,v 1.10 2012/12/05 23:19:59 deraadt Exp $ */ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <err.h> -#include <stdarg.h> - -#define __dead __attribute__((__noreturn__)) - -/* PRINTFLIKE2 */ -__dead void -_errx(int eval, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - _verrx(eval, fmt, ap); - va_end(ap); -} - -/* PRINTFLIKE2 */ -__dead void -errx(int eval, const char *fmt, ...) __attribute__((weak, alias("_errx"))); diff --git a/system/lib/libc/gen/verr.c b/system/lib/libc/gen/verr.c deleted file mode 100644 index 90f5870f..00000000 --- a/system/lib/libc/gen/verr.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: verr.c,v 1.9 2012/12/05 23:20:00 deraadt Exp $ */ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <err.h> -#include <errno.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <stdarg.h> - -extern char *__progname; /* Program name, from crt0. */ - -#define __dead __attribute__((__noreturn__)) - -__dead void -_verr(int eval, const char *fmt, va_list ap) -{ - int sverrno; - - sverrno = errno; - (void)fprintf(stderr, "%s: ", __progname); - if (fmt != NULL) { - (void)vfprintf(stderr, fmt, ap); - (void)fprintf(stderr, ": "); - } - (void)fprintf(stderr, "%s\n", strerror(sverrno)); - exit(eval); -} - -__dead void -verr(int eval, const char *fmt, va_list ap) __attribute__((weak, alias("_verr"))); diff --git a/system/lib/libc/gen/verrx.c b/system/lib/libc/gen/verrx.c deleted file mode 100644 index b712c65c..00000000 --- a/system/lib/libc/gen/verrx.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $OpenBSD: verrx.c,v 1.9 2012/12/05 23:20:00 deraadt Exp $ */ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <err.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> - -extern char *__progname; /* Program name, from crt0. */ - -#define __dead __attribute__((__noreturn__)) - -__dead void -_verrx(int eval, const char *fmt, va_list ap) -{ - (void)fprintf(stderr, "%s: ", __progname); - if (fmt != NULL) - (void)vfprintf(stderr, fmt, ap); - (void)fprintf(stderr, "\n"); - exit(eval); -} - -__dead void -verrx(int eval, const char *fmt, va_list ap) __attribute__((weak, alias("_verrx"))); diff --git a/system/lib/libc/gen/vwarn.c b/system/lib/libc/gen/vwarn.c deleted file mode 100644 index 37acef35..00000000 --- a/system/lib/libc/gen/vwarn.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: vwarn.c,v 1.9 2012/12/05 23:20:00 deraadt Exp $ */ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <err.h> -#include <errno.h> -#include <stdio.h> -#include <string.h> -#include <stdarg.h> - -extern char *__progname; /* Program name, from crt0. */ - -void -_vwarn(const char *fmt, va_list ap) -{ - int sverrno; - - sverrno = errno; - (void)fprintf(stderr, "%s: ", __progname); - if (fmt != NULL) { - (void)vfprintf(stderr, fmt, ap); - (void)fprintf(stderr, ": "); - } - (void)fprintf(stderr, "%s\n", strerror(sverrno)); -} - -void -vwarn(const char *fmt, va_list ap) __attribute__((weak, alias("_vwarn"))); - diff --git a/system/lib/libc/gen/vwarnx.c b/system/lib/libc/gen/vwarnx.c deleted file mode 100644 index a81a5a0d..00000000 --- a/system/lib/libc/gen/vwarnx.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $OpenBSD: vwarnx.c,v 1.9 2012/12/05 23:20:00 deraadt Exp $ */ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <err.h> -#include <stdio.h> -#include <stdarg.h> - -extern char *__progname; /* Program name, from crt0. */ - -void -_vwarnx(const char *fmt, va_list ap) -{ - (void)fprintf(stderr, "%s: ", __progname); - if (fmt != NULL) - (void)vfprintf(stderr, fmt, ap); - (void)fprintf(stderr, "\n"); -} - -void -vwarnx(const char *fmt, va_list ap) __attribute__((weak, alias("_vwarnx"))); - diff --git a/system/lib/libc/gen/warn.c b/system/lib/libc/gen/warn.c deleted file mode 100644 index c0dd2cd7..00000000 --- a/system/lib/libc/gen/warn.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: warn.c,v 1.10 2012/12/05 23:20:00 deraadt Exp $ */ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <err.h> -#include <stdarg.h> - -#define __dead __attribute__((__noreturn__)) - -/* PRINTFLIKE1 */ -void -_warn(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - _vwarn(fmt, ap); - va_end(ap); -} - -/* PRINTFLIKE1 */ -void -warn(const char *fmt, ...) __attribute__((weak, alias("_warn"))); diff --git a/system/lib/libc/gen/warnx.c b/system/lib/libc/gen/warnx.c deleted file mode 100644 index 7909cf2c..00000000 --- a/system/lib/libc/gen/warnx.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD: warnx.c,v 1.9 2012/12/05 23:20:00 deraadt Exp $ */ -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include <err.h> -#include <stdarg.h> - -#define __dead __attribute__((__noreturn__)) - -/* PRINTFLIKE1 */ -void -_warnx(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - _vwarnx(fmt, ap); - va_end(ap); -} - -/* PRINTFLIKE1 */ -void -warnx(const char *fmt, ...) __attribute__((weak, alias("_warnx"))); diff --git a/system/lib/libc/musl/readme.txt b/system/lib/libc/musl/readme.txt index 5e6f8389..9b9b6ad2 100644 --- a/system/lib/libc/musl/readme.txt +++ b/system/lib/libc/musl/readme.txt @@ -9,4 +9,6 @@ Differences from upstream musl include: * We flag __assert_fail as _Noreturn. * Disable FLOCK, FUNLOCK and FFINALLOCK * Simplify fputwc to not rely on musl stream internals - +* signgam is no longer a weak alias of __signgam. +* __toread and __towrite have had shutdown functionality removed. +* Expand aliases for strto*_l() to short functions to remove warnings about incompatible pointer types. diff --git a/system/lib/libc/musl/src/legacy/err.c b/system/lib/libc/musl/src/legacy/err.c new file mode 100644 index 00000000..0d6ab524 --- /dev/null +++ b/system/lib/libc/musl/src/legacy/err.c @@ -0,0 +1,67 @@ +#include <err.h> +#include <stdio.h> +#include <stdarg.h> +#include <stdlib.h> + +extern char *__progname; + +void vwarn(const char *fmt, va_list ap) +{ + fprintf (stderr, "%s: ", __progname); + if (fmt) { + vfprintf(stderr, fmt, ap); + fputs (": ", stderr); + } + perror(0); +} + +void vwarnx(const char *fmt, va_list ap) +{ + fprintf (stderr, "%s: ", __progname); + if (fmt) vfprintf(stderr, fmt, ap); + putc('\n', stderr); +} + +_Noreturn void verr(int status, const char *fmt, va_list ap) +{ + vwarn(fmt, ap); + exit(status); +} + +_Noreturn void verrx(int status, const char *fmt, va_list ap) +{ + vwarnx(fmt, ap); + exit(status); +} + +void warn(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vwarn(fmt, ap); + va_end(ap); +} + +void warnx(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vwarnx(fmt, ap); + va_end(ap); +} + +_Noreturn void err(int status, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + verr(status, fmt, ap); + va_end(ap); +} + +_Noreturn void errx(int status, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + verrx(status, fmt, ap); + va_end(ap); +} diff --git a/system/lib/libc/musl/src/misc/getopt.c b/system/lib/libc/musl/src/misc/getopt.c new file mode 100644 index 00000000..f1a1639c --- /dev/null +++ b/system/lib/libc/musl/src/misc/getopt.c @@ -0,0 +1,74 @@ +#include <unistd.h> +#include <wchar.h> +#include <string.h> +#include <limits.h> +#include <stdlib.h> +#include "libc.h" + +char *optarg; +int optind=1, opterr=1, optopt, __optpos, __optreset=0; + +#define optpos __optpos +weak_alias(__optreset, optreset); + +int getopt(int argc, char * const argv[], const char *optstring) +{ + int i; + wchar_t c, d; + int k, l; + char *optchar; + + if (!optind || __optreset) { + __optreset = 0; + __optpos = 0; + optind = 1; + } + + if (optind >= argc || !argv[optind] || argv[optind][0] != '-' || !argv[optind][1]) + return -1; + if (argv[optind][1] == '-' && !argv[optind][2]) + return optind++, -1; + + if (!optpos) optpos++; + if ((k = mbtowc(&c, argv[optind]+optpos, MB_LEN_MAX)) < 0) { + k = 1; + c = 0xfffd; /* replacement char */ + } + optchar = argv[optind]+optpos; + optopt = c; + optpos += k; + + if (!argv[optind][optpos]) { + optind++; + optpos = 0; + } + + for (i=0; (l = mbtowc(&d, optstring+i, MB_LEN_MAX)) && d!=c; i+=l>0?l:1); + + if (d != c) { + if (optstring[0] != ':' && opterr) { + write(2, argv[0], strlen(argv[0])); + write(2, ": illegal option: ", 18); + write(2, optchar, k); + write(2, "\n", 1); + } + return '?'; + } + if (optstring[i+1] == ':') { + if (optind >= argc) { + if (optstring[0] == ':') return ':'; + if (opterr) { + write(2, argv[0], strlen(argv[0])); + write(2, ": option requires an argument: ", 31); + write(2, optchar, k); + write(2, "\n", 1); + } + return '?'; + } + optarg = argv[optind++] + optpos; + optpos = 0; + } + return c; +} + +weak_alias(getopt, __posix_getopt); diff --git a/system/lib/libc/musl/src/misc/getopt_long.c b/system/lib/libc/musl/src/misc/getopt_long.c new file mode 100644 index 00000000..4ef5a5c7 --- /dev/null +++ b/system/lib/libc/musl/src/misc/getopt_long.c @@ -0,0 +1,59 @@ +#define _GNU_SOURCE +#include <stddef.h> +#include <getopt.h> +#include <stdio.h> + +extern int __optpos, __optreset; + +static int __getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx, int longonly) +{ + if (!optind || __optreset) { + __optreset = 0; + __optpos = 0; + optind = 1; + } + if (optind >= argc || !argv[optind] || argv[optind][0] != '-') return -1; + if ((longonly && argv[optind][1]) || + (argv[optind][1] == '-' && argv[optind][2])) + { + int i; + for (i=0; longopts[i].name; i++) { + const char *name = longopts[i].name; + char *opt = argv[optind]+1; + if (*opt == '-') opt++; + for (; *name && *name == *opt; name++, opt++); + if (*name || (*opt && *opt != '=')) continue; + if (*opt == '=') { + if (!longopts[i].has_arg) continue; + optarg = opt+1; + } else { + if (longopts[i].has_arg == required_argument) { + if (!(optarg = argv[++optind])) + return ':'; + } else optarg = NULL; + } + optind++; + if (idx) *idx = i; + if (longopts[i].flag) { + *longopts[i].flag = longopts[i].val; + return 0; + } + return longopts[i].val; + } + if (argv[optind][1] == '-') { + optind++; + return '?'; + } + } + return getopt(argc, argv, optstring); +} + +int getopt_long(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx) +{ + return __getopt_long(argc, argv, optstring, longopts, idx, 0); +} + +int getopt_long_only(int argc, char *const *argv, const char *optstring, const struct option *longopts, int *idx) +{ + return __getopt_long(argc, argv, optstring, longopts, idx, 1); +} diff --git a/system/lib/libc/musl/src/stdio/__toread.c b/system/lib/libc/musl/src/stdio/__toread.c index 2e804f64..f00cc467 100644 --- a/system/lib/libc/musl/src/stdio/__toread.c +++ b/system/lib/libc/musl/src/stdio/__toread.c @@ -12,13 +12,3 @@ int __toread(FILE *f) f->rpos = f->rend = f->buf; return 0; } - -static const int dummy = 0; -weak_alias(dummy, __towrite_used); - -void __stdio_exit(void); - -void __seek_on_exit() -{ - if (!__towrite_used) __stdio_exit(); -} diff --git a/system/lib/libc/musl/src/stdio/__towrite.c b/system/lib/libc/musl/src/stdio/__towrite.c new file mode 100644 index 00000000..3698d8b7 --- /dev/null +++ b/system/lib/libc/musl/src/stdio/__towrite.c @@ -0,0 +1,18 @@ +#include "stdio_impl.h" + +int __towrite(FILE *f) +{ + f->mode |= f->mode-1; + if (f->flags & (F_NOWR)) { + f->flags |= F_ERR; + return EOF; + } + /* Clear read buffer (easier than summoning nasal demons) */ + f->rpos = f->rend = 0; + + /* Activate write through the buffer. */ + f->wpos = f->wbase = f->buf; + f->wend = f->buf + f->buf_size; + + return 0; +} diff --git a/system/lib/libc/musl/src/stdlib/strtod.c b/system/lib/libc/musl/src/stdlib/strtod.c index 461dcf85..35f640da 100644 --- a/system/lib/libc/musl/src/stdlib/strtod.c +++ b/system/lib/libc/musl/src/stdlib/strtod.c @@ -32,9 +32,21 @@ long double strtold(const char *restrict s, char **restrict p) return strtox(s, p, 2); } -weak_alias(strtof, strtof_l); -weak_alias(strtod, strtod_l); -weak_alias(strtold, strtold_l); -weak_alias(strtof, __strtof_l); -weak_alias(strtod, __strtod_l); -weak_alias(strtold, __strtold_l); +float strtof_l(const char *restrict s, char **restrict p, struct __locale_struct *loc) +{ + return strtof(s, p); +} + +double strtod_l(const char *restrict s, char **restrict p, struct __locale_struct *loc) +{ + return strtod(s, p); +} + +long double strtold_l(const char *restrict s, char **restrict p, struct __locale_struct *loc) +{ + return strtold(s, p); +} + +weak_alias(strtof_l, __strtof_l); +weak_alias(strtod_l, __strtod_l); +weak_alias(strtold_l, __strtold_l); diff --git a/system/lib/libc/stdlib/getopt_long.c b/system/lib/libc/stdlib/getopt_long.c deleted file mode 100644 index e149fe0a..00000000 --- a/system/lib/libc/stdlib/getopt_long.c +++ /dev/null @@ -1,511 +0,0 @@ -/* $OpenBSD: getopt_long.c,v 1.25 2011/03/05 22:10:11 guenther Exp $ */ -/* $NetBSD: getopt_long.c,v 1.15 2002/01/31 22:43:40 tv Exp $ */ - -/* - * Copyright (c) 2002 Todd C. Miller <Todd.Miller@courtesan.com> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTIO |