]) dnl SQUID_CHECK_FUNC_STRNSTR
-dnl check that va_copy is implemented and works
-dnl sets squid_cv_func_va_copy and defines HAVE_VA_COPY
-AC_DEFUN([SQUID_CHECK_FUNC_VACOPY],[
-
-# check that the system provides a functional va_copy call
-
-AH_TEMPLATE(HAVE_VA_COPY, [The system implements a functional va_copy() ])
-AC_CACHE_CHECK(if va_copy is implemented, squid_cv_func_va_copy,
- AC_RUN_IFELSE([AC_LANG_SOURCE([[
- #include <stdarg.h>
- #include <stdlib.h>
- int f (int i, ...) {
- va_list args1, args2;
- va_start (args1, i);
- va_copy (args2, args1);
- if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
- return 1;
- va_end (args1); va_end (args2);
- return 0;
- }
- int main(int argc, char **argv) { return f (0, 42); }
- ]])],[squid_cv_func_va_copy="yes"],[squid_cv_func_va_copy="no"],[:])
-)
-if test "$squid_cv_func_va_copy" = "yes" ; then
- AC_DEFINE(HAVE_VA_COPY, 1)
-fi
-
-]) dnl SQUID_CHECK_FUNC_VACOPY
-
-dnl same sa SQUID_CHECK_FUNC_VACOPY, but checks __va_copy
-dnl sets squid_cv_func___va_copy, and defines HAVE___VA_COPY
-AC_DEFUN([SQUID_CHECK_FUNC___VACOPY],[
-
-AH_TEMPLATE(HAVE___VA_COPY,[Some systems have __va_copy instead of va_copy])
-AC_CACHE_CHECK(if __va_copy is implemented, squid_cv_func___va_copy,
- AC_RUN_IFELSE([AC_LANG_SOURCE([[
- #include <stdarg.h>
- #include <stdlib.h>
- int f (int i, ...) {
- va_list args1, args2;
- va_start (args1, i);
- __va_copy (args2, args1);
- if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
- return 1;
- va_end (args1); va_end (args2);
- return 0;
- }
- int main(int argc, char **argv) { return f (0, 42); }
- ]])],[squid_cv_func___va_copy="yes"],[squid_cv_func___va_copy="no"],[:])
-)
-if test "$squid_cv_func___va_copy" = "yes" ; then
- AC_DEFINE(HAVE___VA_COPY, 1)
-fi
-]) dnl SQUID_CHECK_FUNC___VACOPY
-
-
dnl check that epoll actually works
dnl sets squid_cv_epoll_works to "yes" or "no"
AC_DEFUN([SQUID_CHECK_EPOLL],[
#include "MemBuf.h"
#include "profiler/Profiler.h"
-#ifdef VA_COPY
-#undef VA_COPY
-#endif
-#if defined HAVE_VA_COPY
-#define VA_COPY va_copy
-#elif defined HAVE___VA_COPY
-#define VA_COPY __va_copy
-#endif
-
/* local constants */
/* default values for buffer sizes, used by memBufDefInit */
void
MemBuf::vappendf(const char *fmt, va_list vargs)
{
-#ifdef VA_COPY
- va_list ap;
-#endif
-
int sz = 0;
assert(fmt);
assert(buf);
mb_size_t free_space = capacity - size;
/* put as much as we can */
-#ifdef VA_COPY
/* Fix of bug 753r. The value of vargs is undefined
* after vsnprintf() returns. Make a copy of vargs
* incase we loop around and call vsnprintf() again.
*/
- VA_COPY(ap,vargs);
+ va_list ap;
+ va_copy(ap,vargs);
sz = vsnprintf(buf + size, free_space, fmt, ap);
va_end(ap);
-#else /* VA_COPY */
- sz = vsnprintf(buf + size, free_space, fmt, vargs);
-#endif /*VA_COPY*/
/* check for possible overflow */
/* snprintf on Linuz returns -1 on overflows */
/* snprintf on FreeBSD returns at least free_space on overflows */
#include <iostream>
#include <sstream>
-#ifdef VA_COPY
-#undef VA_COPY
-#endif
-#if defined HAVE_VA_COPY
-#define VA_COPY va_copy
-#elif defined HAVE___VA_COPY
-#define VA_COPY __va_copy
-#endif
-
InstanceIdDefinitions(SBuf, "SBuf");
SBufStats SBuf::stats;
size_type requiredSpaceEstimate = strlen(fmt)*2;
char *space = rawSpace(requiredSpaceEstimate);
-#ifdef VA_COPY
va_list ap;
- VA_COPY(ap, vargs);
+ va_copy(ap, vargs);
sz = vsnprintf(space, spaceSize(), fmt, ap);
va_end(ap);
-#else
- sz = vsnprintf(space, spaceSize(), fmt, vargs);
-#endif
Must2(sz >= 0, "vsnprintf() output error");
/* check for possible overflow */
*buf = 0;
int x;
-#ifdef VA_COPY
- va_args ap;
+ va_list ap;
/* Fix of bug 753r. The value of vargs is undefined
* after vsnprintf() returns. Make a copy of vargs
* incase we loop around and call vsnprintf() again.
*/
- VA_COPY(ap,vargs);
+ va_copy(ap,vargs);
errno = 0;
if ((x = vsnprintf(buf, sizeof(buf), fmt, ap)) < 0) {
fatal(xstrerr(errno));
return;
}
va_end(ap);
-#else /* VA_COPY */
- errno = 0;
- if ((x = vsnprintf(buf, sizeof(buf), fmt, vargs)) < 0) {
- fatal(xstrerr(errno));
- return;
- }
-#endif /*VA_COPY*/
if (x < static_cast<int>(sizeof(buf))) {
append(buf, x);