pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: tnftp build fails on aix 6.1 for 2015Q4



I've attached an updated patch which uses the vasprintf implementation
from libnbcompat.


On Sat, Jan 9, 2016 at 7:21 AM, Joerg Sonnenberger
<joerg%britannica.bec.de@localhost> wrote:
> On Sat, Jan 09, 2016 at 12:05:10AM -0600, J Raynor wrote:
>> I got your email after I had sent in my patch.  Should my patch be
>> reworked to include the vasprintf implementation from libnbcompat?
>> Or is the implementation in the patch ok?
>
> The nbcompat implementation is better, it avoids running the formatting
> twice for common shortish cases and it handles the potential missing
> va_copy better.
>
> Joerg
Index: files/configure
===================================================================
RCS file: /cvsroot/pkgsrc/net/tnftp/files/configure,v
retrieving revision 1.17
diff -u -r1.17 configure
--- files/configure	4 Oct 2015 14:44:06 -0000	1.17
+++ files/configure	10 Jan 2016 22:32:38 -0000
@@ -14390,6 +14390,110 @@
 
 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
+
+
+
+ac_fn_c_check_func "$LINENO" "vasprintf" "ac_cv_func_vasprintf"
+if test "x$ac_cv_func_vasprintf" = xyes; then :
+  $as_echo "#define HAVE_VASPRINTF 1" >>confdefs.h
+
+else
+  case " $LIBOBJS " in
+  *" vasprintf.$ac_objext "* ) ;;
+  *) LIBOBJS="$LIBOBJS vasprintf.$ac_objext"
+ ;;
+esac
+
+fi
 
 for ac_func in getcwd gethostbyaddr gethostbyname gethostbyname2 gethostname \
                 getpass getpassphrase getpgrp gettimeofday isascii \
Index: files/configure.ac
===================================================================
RCS file: /cvsroot/pkgsrc/net/tnftp/files/configure.ac,v
retrieving revision 1.7
diff -u -r1.7 configure.ac
--- files/configure.ac	4 Oct 2015 14:44:06 -0000	1.7
+++ files/configure.ac	10 Jan 2016 22:32:38 -0000
@@ -298,7 +298,7 @@
 AC_REPLACE_FUNCS([dirname err fgetln getaddrinfo getnameinfo \
                   inet_ntop inet_pton mkstemp setprogname sl_init snprintf \
                   strdup strerror strlcat strlcpy strptime strsep strunvis \
-                  strvis timegm usleep utimes])
+                  strvis timegm usleep utimes vasprintf])
 AC_CHECK_FUNCS([getcwd gethostbyaddr gethostbyname gethostbyname2 gethostname \
                 getpass getpassphrase getpgrp gettimeofday isascii \
                 memchr memmove memset realpath regcomp \
@@ -363,6 +363,30 @@
                              [AC_DEFINE([HAVE_POLL], [1])],
                              [$accheck_includes])])
 
+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.
+	]), [:]
+])
+
 AS_IF([test "$ac_cv_func_strptime" = yes],
       [AC_MSG_CHECKING([if strptime() needs separators between conversions])
        AC_RUN_IFELSE([AC_LANG_PROGRAM([[
Index: files/tnftp.h
===================================================================
RCS file: /cvsroot/pkgsrc/net/tnftp/files/tnftp.h,v
retrieving revision 1.14
diff -u -r1.14 tnftp.h
--- files/tnftp.h	4 Nov 2014 22:38:26 -0000	1.14
+++ files/tnftp.h	10 Jan 2016 22:32:38 -0000
@@ -442,6 +442,10 @@
 int utimes(const char *, const struct timeval *);
 #endif
 
+#if !defined(HAVE_VASPRINTF)
+int vasprintf(char **, const char *, va_list);
+#endif
+
 #if !defined(HAVE_MEMMOVE)
 # define memmove(a,b,c)	bcopy((b),(a),(c))
 	/* XXX: add others #defines for borken systems? */
Index: files/tnftp_config.h.in
===================================================================
RCS file: /cvsroot/pkgsrc/net/tnftp/files/tnftp_config.h.in,v
retrieving revision 1.2
diff -u -r1.2 tnftp_config.h.in
--- files/tnftp_config.h.in	4 Nov 2014 22:38:26 -0000	1.2
+++ files/tnftp_config.h.in	10 Jan 2016 22:32:38 -0000
@@ -421,6 +421,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
 
@@ -436,6 +439,9 @@
 /* Define to 1 if `vfork' works. */
 #undef HAVE_WORKING_VFORK
 
+/* Define to 1 if the `__builtin_va_copy' function is supported. */
+#undef HAVE___BUILTIN_VA_COPY
+
 /* Define to the sub-directory in which libtool stores uninstalled libraries.
    */
 #undef LT_OBJDIR
Index: files/libnetbsd/Makefile.in
===================================================================
RCS file: /cvsroot/pkgsrc/net/tnftp/files/libnetbsd/Makefile.in,v
retrieving revision 1.5
diff -u -r1.5 Makefile.in
--- files/libnetbsd/Makefile.in	31 Oct 2014 18:59:32 -0000	1.5
+++ files/libnetbsd/Makefile.in	10 Jan 2016 22:32:39 -0000
@@ -39,7 +39,8 @@
 	err.c fgetln.c getaddrinfo.c getnameinfo.c glob.c inet_ntop.c \
 	inet_pton.c mkstemp.c setprogname.c sl_init.c snprintf.c \
 	strdup.c strerror.c strlcat.c strlcpy.c strptime.c strsep.c \
-	strtoll.c strunvis.c strvis.c timegm.c usleep.c utimes.c
+	strtoll.c strunvis.c strvis.c timegm.c usleep.c utimes.c \
+	vasprintf.c
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/buildaux/ax_check_openssl.m4 \
 	$(top_srcdir)/buildaux/libtool.m4 \
@@ -300,6 +301,7 @@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/timegm.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/usleep.Plo@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/utimes.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vasprintf.Plo@am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
Index: files/libnetbsd/vasprintf.c
===================================================================
RCS file: files/libnetbsd/vasprintf.c
diff -N files/libnetbsd/vasprintf.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/libnetbsd/vasprintf.c	10 Jan 2016 22:32:39 -0000
@@ -0,0 +1,94 @@
+/* $NetBSD: asprintf.c,v 1.3 2012/07/02 16:02:53 joerg Exp $ */
+
+/*-
+ * Copyright (c) 2007 Joerg Sonnenberger <joerg%NetBSD.org@localhost>.
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * COPYRIGHT HOLDERS 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 "tnftp.h"
+
+int
+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);
+	if (buf == NULL) {
+		*ret = NULL;
+		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;
+	}
+
+	if (retval < len) {
+		new_buf = realloc(buf, retval + 1);
+		if (new_buf == NULL)
+			*ret = buf;
+		else
+			*ret = new_buf;
+		my_va_end(ap2);
+		return retval;
+	}
+
+	len = (size_t)retval + 1;
+	free(buf);
+	buf = malloc(len);
+	if (buf == NULL) {
+		*ret = NULL;
+		my_va_end(ap2);
+		return -1;
+	}
+	retval = vsnprintf(buf, len, fmt, ap2);
+	my_va_end(ap2);
+	if (retval != len - 1) {
+		free(buf);
+		*ret = NULL;
+		return -1;
+	}
+	*ret = buf;
+	return retval;
+}


Home | Main Index | Thread Index | Old Index