diff options
author | joerg <joerg@pkgsrc.org> | 2012-07-02 16:02:53 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2012-07-02 16:02:53 +0000 |
commit | 528ceb0e15b4badcb750ad2e47d5c37d65a3bb72 (patch) | |
tree | 367ec0eafc6115c6ef25d86202c8c2dae8b2f90e /pkgtools/libnbcompat | |
parent | dc3eaa6058337b9b1be2718afd10e27b1c351252 (diff) | |
download | pkgsrc-528ceb0e15b4badcb750ad2e47d5c37d65a3bb72.tar.gz |
If either va_copy or __builtin_va_copy is supported, use that in the
asprintf fallback implementation. If neither is supported, still try to
work by copying va_list directly. Should fix PR 45767.
Diffstat (limited to 'pkgtools/libnbcompat')
-rw-r--r-- | pkgtools/libnbcompat/Makefile | 4 | ||||
-rw-r--r-- | pkgtools/libnbcompat/files/asprintf.c | 19 | ||||
-rwxr-xr-x | pkgtools/libnbcompat/files/configure | 122 | ||||
-rw-r--r-- | pkgtools/libnbcompat/files/configure.ac | 28 | ||||
-rw-r--r-- | pkgtools/libnbcompat/files/nbcompat/config.h.in | 6 |
5 files changed, 158 insertions, 21 deletions
diff --git a/pkgtools/libnbcompat/Makefile b/pkgtools/libnbcompat/Makefile index f15cb6275cc..77b25cc16aa 100644 --- a/pkgtools/libnbcompat/Makefile +++ b/pkgtools/libnbcompat/Makefile @@ -1,11 +1,11 @@ -# $NetBSD: Makefile,v 1.76 2011/12/28 19:19:31 joerg Exp $ +# $NetBSD: Makefile,v 1.77 2012/07/02 16:02:53 joerg Exp $ # # NOTE: If you update this package, it is *mandatory* that you update # pkgsrc/pkgtools/libnbcompat/files/README to reflect the actual # list of tested and supported platforms. # -DISTNAME= libnbcompat-20111228 +DISTNAME= libnbcompat-20120702 CATEGORIES= pkgtools devel MASTER_SITES= # empty DISTFILES= # empty diff --git a/pkgtools/libnbcompat/files/asprintf.c b/pkgtools/libnbcompat/files/asprintf.c index 3071565fe29..347f95bdae4 100644 --- a/pkgtools/libnbcompat/files/asprintf.c +++ b/pkgtools/libnbcompat/files/asprintf.c @@ -1,4 +1,4 @@ -/* $NetBSD: asprintf.c,v 1.2 2007/07/20 00:10:06 tnn Exp $ */ +/* $NetBSD: asprintf.c,v 1.3 2012/07/02 16:02:53 joerg Exp $ */ /*- * Copyright (c) 2007 Joerg Sonnenberger <joerg@NetBSD.org>. @@ -56,6 +56,7 @@ vasprintf(char **ret, const char *fmt, va_list ap) char *buf, *new_buf; size_t len; int retval; + va_list ap2; len = 128; buf = malloc(len); @@ -64,10 +65,21 @@ vasprintf(char **ret, const char *fmt, va_list ap) return -1; } +#if defined(HAVE_VA_COPY) + va_copy(ap2, ap); +#define my_va_end(ap2) va_end(ap2) +#elif defined(HAVE___BUILTIN_VA_COPY) + __builtin_va_copy(ap2, ap); +#define my_va_end(ap2) __builtin_va_end(ap2) +#else + ap2 = ap; +#define my_va_end(ap2) do {} while (0) +#endif retval = vsnprintf(buf, len, fmt, ap); if (retval < 0) { free(buf); *ret = NULL; + va_end(ap2); return -1; } @@ -77,6 +89,7 @@ vasprintf(char **ret, const char *fmt, va_list ap) *ret = buf; else *ret = new_buf; + my_va_end(ap2); return retval; } @@ -85,9 +98,11 @@ vasprintf(char **ret, const char *fmt, va_list ap) buf = malloc(len); if (buf == NULL) { *ret = NULL; + my_va_end(ap2); return -1; } - retval = vsnprintf(buf, len, fmt, ap); + retval = vsnprintf(buf, len, fmt, ap2); + my_va_end(ap2); if (retval != len - 1) { free(buf); *ret = NULL; diff --git a/pkgtools/libnbcompat/files/configure b/pkgtools/libnbcompat/files/configure index b211dbe0437..dcb871d9038 100755 --- a/pkgtools/libnbcompat/files/configure +++ b/pkgtools/libnbcompat/files/configure @@ -1,8 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for libnbcompat 20080605. +# Generated by GNU Autoconf 2.68 for libnbcompat 20120702. # -# Report bugs to <grant@NetBSD.org>. +# Report bugs to <joerg@NetBSD.org>. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -238,7 +238,7 @@ fi $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else - $as_echo "$0: Please tell bug-autoconf@gnu.org and grant@NetBSD.org + $as_echo "$0: Please tell bug-autoconf@gnu.org and joerg@NetBSD.org $0: about your system, including any error possibly output $0: before this message. Then install a modern shell, or $0: manually run the script under such a shell if you do @@ -560,9 +560,9 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='libnbcompat' PACKAGE_TARNAME='libnbcompat' -PACKAGE_VERSION='20080605' -PACKAGE_STRING='libnbcompat 20080605' -PACKAGE_BUGREPORT='grant@NetBSD.org' +PACKAGE_VERSION='20120702' +PACKAGE_STRING='libnbcompat 20120702' +PACKAGE_BUGREPORT='joerg@NetBSD.org' PACKAGE_URL='' # Factoring default headers for most tests. @@ -1229,7 +1229,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures libnbcompat 20080605 to adapt to many kinds of systems. +\`configure' configures libnbcompat 20120702 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1299,7 +1299,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of libnbcompat 20080605:";; + short | recursive ) echo "Configuration of libnbcompat 20120702:";; esac cat <<\_ACEOF @@ -1323,7 +1323,7 @@ Some influential environment variables: Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to <grant@NetBSD.org>. +Report bugs to <joerg@NetBSD.org>. _ACEOF ac_status=$? fi @@ -1386,7 +1386,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -libnbcompat configure 20080605 +libnbcompat configure 20120702 generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. @@ -1719,7 +1719,7 @@ $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" > { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ( $as_echo "## ------------------------------- ## -## Report this to grant@NetBSD.org ## +## Report this to joerg@NetBSD.org ## ## ------------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; @@ -2217,7 +2217,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by libnbcompat $as_me 20080605, which was +It was created by libnbcompat $as_me 20120702, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ @@ -4486,6 +4486,98 @@ esac fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for va_copy" >&5 +$as_echo_n "checking for va_copy... " >&6; } +if ${pkg_cv_have_va_copy+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <stdarg.h> + +int +main () +{ + + va_list ap, ap2; + va_copy(ap2, ap); + return 0; +; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + pkg_cv_have_va_copy=yes +else + pkg_cv_have_va_copy=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pkg_cv_have_va_copy" >&5 +$as_echo "$pkg_cv_have_va_copy" >&6; } + if test "x$pkg_cv_have_va_copy" = "xyes"; then + $as_echo "#define HAVE_VA_COPY 1" >>confdefs.h + + + else + : +] + : + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_va_copy" >&5 +$as_echo_n "checking for __builtin_va_copy... " >&6; } +if ${pkg_cv_have___builtin_va_copy+:} false; then : + $as_echo_n "(cached) " >&6 +else + + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include <stdarg.h> + +int +main () +{ + + va_list ap, ap2; + __builtin_va_copy(ap2, ap); + return 0; +; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + pkg_cv_have___builtin_va_copy=yes +else + pkg_cv_have___builtin_va_copy=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pkg_cv_have___builtin_va_copy" >&5 +$as_echo "$pkg_cv_have___builtin_va_copy" >&6; } + if test "x$pkg_cv_have___builtin_va_copy" = "xyes"; then + $as_echo "#define HAVE___BUILTIN_VA_COPY 1" >>confdefs.h + + + else + : +] + : + fi + + for ac_header in md5.h do : ac_fn_c_check_header_mongrel "$LINENO" "md5.h" "ac_cv_header_md5_h" "$ac_includes_default" @@ -7572,7 +7664,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by libnbcompat $as_me 20080605, which was +This file was extended by libnbcompat $as_me 20120702, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -7628,13 +7720,13 @@ $config_files Configuration headers: $config_headers -Report bugs to <grant@NetBSD.org>." +Report bugs to <joerg@NetBSD.org>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -libnbcompat config.status 20080605 +libnbcompat config.status 20120702 configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" diff --git a/pkgtools/libnbcompat/files/configure.ac b/pkgtools/libnbcompat/files/configure.ac index aed6d3270ed..2ed63eac4c1 100644 --- a/pkgtools/libnbcompat/files/configure.ac +++ b/pkgtools/libnbcompat/files/configure.ac @@ -1,8 +1,8 @@ -dnl $NetBSD: configure.ac,v 1.78 2011/12/28 19:19:31 joerg Exp $ +dnl $NetBSD: configure.ac,v 1.79 2012/07/02 16:02:53 joerg Exp $ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.52) -AC_INIT([libnbcompat], [20080605], [grant@NetBSD.org]) +AC_INIT([libnbcompat], [20120702], [joerg@NetBSD.org]) AC_CONFIG_HEADER(nbcompat/config.h) AC_ARG_PROGRAM @@ -78,6 +78,30 @@ AC_CHECK_FUNC(regexec, [:], [ AC_LIBOBJ(regfree) ]) +AC_MSG_TRY_LINK([for va_copy], pkg_cv_have_va_copy, [ +#include <stdarg.h> +], [ + va_list ap, ap2; + va_copy(ap2, ap); + return 0; +], AC_DEFINE(HAVE_VA_COPY) + AH_TEMPLATE([HAVE_VA_COPY], [ + Define to 1 if the `va_copy' function is supported. + ]), [:] +]) + +AC_MSG_TRY_LINK([for __builtin_va_copy], pkg_cv_have___builtin_va_copy, [ +#include <stdarg.h> +], [ + va_list ap, ap2; + __builtin_va_copy(ap2, ap); + return 0; +], AC_DEFINE(HAVE___BUILTIN_VA_COPY) + AH_TEMPLATE([HAVE___BUILTIN_VA_COPY], [ + Define to 1 if the `__builtin_va_copy' function is supported. + ]), [:] +]) + AC_CHECK_HEADERS([md5.h], [ AC_MSG_TRY_COMPILE([for MD5Init in md5.h], pkg_cv_have_md5init, [ #include <sys/types.h> diff --git a/pkgtools/libnbcompat/files/nbcompat/config.h.in b/pkgtools/libnbcompat/files/nbcompat/config.h.in index 24458931076..ca86087d2ed 100644 --- a/pkgtools/libnbcompat/files/nbcompat/config.h.in +++ b/pkgtools/libnbcompat/files/nbcompat/config.h.in @@ -508,6 +508,9 @@ /* Define to 1 if you have the <utime.h> header file. */ #undef HAVE_UTIME_H +/* Define to 1 if the `va_copy' function is supported. */ +#undef HAVE_VA_COPY + /* Define to 1 if you have the `vfork' function. */ #undef HAVE_VFORK @@ -541,6 +544,9 @@ /* define if your compiler has __attribute__ */ #undef HAVE___ATTRIBUTE__ +/* Define to 1 if the `__builtin_va_copy' function is supported. */ +#undef HAVE___BUILTIN_VA_COPY + /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT |