summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2006-01-25 20:44:50 +0000
committerrob rob@31f1291d-b8d6-0310-a050-a5561fc1590b <rob rob@31f1291d-b8d6-0310-a050-a5561fc1590b@5417fbe8-f217-4b02-8779-1006273d7864>2006-01-25 20:44:50 +0000
commit033ce652559ac342a94bdf9edbabe77ed1e81369 (patch)
treec8c662808401929e4fafcefe24b835b558cf3edf
parent9435ddae0c408d39c623f6bdc7650c2bf0981c0c (diff)
Added va_copy macro, along with a autoconf test.
git-svn-id: svn://svn.anope.org/anope/trunk@959 31f1291d-b8d6-0310-a050-a5561fc1590b git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@686 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--Changes4
-rwxr-xr-xconfigure69
-rw-r--r--configure.in43
-rw-r--r--include/services.h14
-rw-r--r--include/sysconf.h.in5
-rw-r--r--src/log.c10
6 files changed, 133 insertions, 12 deletions
diff --git a/Changes b/Changes
index f267d51bc..d85b6fe50 100644
--- a/Changes
+++ b/Changes
@@ -9,6 +9,10 @@ Provided by nenolod. <nenolod@nenolod.net> - 2005
Provided by illu. <illu@rs2i.net> - 2006
01/25 F Updated the french language file. [ #00]
+Provided by Trystan <trystan@nomadirc.net> - 2006
+01/25 F va_copy issue for various platforms. [ #00]
+
+
Anope Version 1.7.13
--------------------
diff --git a/configure b/configure
index c91ac99ed..7216be0aa 100755
--- a/configure
+++ b/configure
@@ -1306,6 +1306,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
if test $# = 0; then
echo "You might want to run ./Config or provide some parameters to this script."
echo "./configure --help for information about this script"
@@ -2740,6 +2741,74 @@ if test $ac_cv_lib_bsd_revoke = yes; then
fi
x="0";
+
+
+
+echo "$as_me:$LINENO: checking whether va_list assignments need array notation" >&5
+echo $ECHO_N "checking whether va_list assignments need array notation... $ECHO_C" >&6
+if test "${ac_cv_valistisarray+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_valistisarray=false
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+ #include <stdarg.h>
+ void foo(int i, ...) {
+ va_list ap1, ap2;
+ va_start(ap1, i);
+ ap2 = ap1;
+ if (va_arg(ap2, int) != 123 || va_arg(ap1, int) != 123) { exit(1); }
+ va_end(ap1); va_end(ap2);
+ }
+ int main()
+ { foo(0, 123); return(0); }
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_valistisarray=false
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_valistisarray=true
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+
+
+if test "$ac_cv_valistisarray" = true ; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_VA_LIST_AS_ARRAY 1
+_ACEOF
+
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
DIS_MYSQL=" MySql: No"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
diff --git a/configure.in b/configure.in
index f170d9317..c761f7c4f 100644
--- a/configure.in
+++ b/configure.in
@@ -10,7 +10,8 @@ dnl Based heavily on the Unreal configure.in script, and extra thanks to
dnl codemastr from UnrealIRCD.
-AC_INIT(src/actions.c)
+AC_INIT
+AC_CONFIG_SRCDIR([src/actions.c])
if test $# = 0; then
echo "You might want to run ./Config or provide some parameters to this script."
echo "./configure --help for information about this script"
@@ -19,12 +20,12 @@ fi
AC_CONFIG_HEADER(include/sysconf.h)
AC_PROG_CC
-if test "$ac_cv_prog_gcc" = "yes"; then
+if test "$ac_cv_c_compiler_gnu" = "yes"; then
# CFLAGS="$CFLAGS -funsigned-char"
AC_CACHE_CHECK(if gcc has a working -pipe, ac_cv_pipe, [
save_cflags="$CFLAGS"
CFLAGS="$CFLAGS -pipe"
- AC_TRY_COMPILE(,, ac_cv_pipe="yes", ac_cv_pipe="no")
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ac_cv_pipe="yes"],[ac_cv_pipe="no"])
CFLAGS="$save_cflags"
])
if test "$ac_cv_pipe" = "yes"; then
@@ -43,6 +44,36 @@ AC_CHECK_LIB(socket, socket,ANOPELIBS="$ANOPELIBS-lsocket ")
AC_CHECK_LIB(resolv, res_query,ANOPELIBS="$ANOPELIBS-lresolv ")
AC_CHECK_LIB(bsd, revoke,ANOPELIBS="$ANOPELIBS-lbsd ")
x="0";
+
+dnl Does this platform require array notation to assign to a va_list?
+dnl If cross-compiling, we assume va_list is "normal". If this breaks
+dnl you, set ac_cv_valistisarray=true and maybe define HAVE_VA_LIST_AS_ARRAY
+dnl also just to be sure.
+
+dnl NOTE: this autoconf test is taken from mozilla: www.mozilla.org.
+
+AC_MSG_CHECKING(whether va_list assignments need array notation)
+AC_CACHE_VAL(ac_cv_valistisarray,
+ [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
+ #include <stdarg.h>
+ void foo(int i, ...) {
+ va_list ap1, ap2;
+ va_start(ap1, i);
+ ap2 = ap1;
+ if (va_arg(ap2, int) != 123 || va_arg(ap1, int) != 123) { exit(1); }
+ va_end(ap1); va_end(ap2);
+ }
+ int main()
+ { foo(0, 123); return(0); }]])],[ac_cv_valistisarray=false],[ac_cv_valistisarray=true],[ac_cv_valistisarray=false])])
+
+if test "$ac_cv_valistisarray" = true ; then
+ AC_DEFINE(HAVE_VA_LIST_AS_ARRAY,[1],[va_list as array])
+ AC_MSG_RESULT(yes)
+else
+ AC_MSG_RESULT(no)
+fi
+
+
DIS_MYSQL=" MySql: No"
AC_ARG_WITH(mysql, [ --without-mysql Do not use MySQL even if we find it],,[
AM_PATH_MYSQLCLIENT(,[
@@ -97,13 +128,13 @@ AC_DEFINE(STATIC_LINKING,"NO_MODULES","modules not available")
hold_cflags=$CFLAGS
CFLAGS="$CFLAGS -export-dynamic"
AC_CACHE_CHECK(if we need the -export-dynamic flag, ac_cv_export_dynamic, [
-AC_TRY_LINK(, [int i];, ac_cv_export_dynamic=yes, ac_cv_export_dynamic=no)])
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[int i;]])],[ac_cv_export_dynamic=yes],[ac_cv_export_dynamic=no])])
if test "$ac_cv_export_dynamic" = "no"; then
CFLAGS=$hold_cflags
fi
AC_CACHE_CHECK(for compiler option to produce PIC,ac_cv_pic,[
-if test "$ac_cv_prog_gcc" = "yes"; then
+if test "$ac_cv_c_compiler_gnu" = "yes"; then
ac_cv_pic="-fPIC -DPIC -shared"
case `uname -s` in
Darwin*[)]
@@ -124,7 +155,7 @@ fi
])
-if test "$ac_cv_prog_gcc" = "yes"; then
+if test "$ac_cv_c_compiler_gnu" = "yes"; then
case `uname -s` in
Darwin*[)]
SHARED="-bundle -flat_namespace -undefined suppress"
diff --git a/include/services.h b/include/services.h
index b155c9f47..e2bd9b697 100644
--- a/include/services.h
+++ b/include/services.h
@@ -146,6 +146,20 @@
#include "sockets.h"
+#ifndef va_copy
+# ifdef __va_copy
+# define VA_COPY(DEST,SRC) __va_copy((DEST),(SRC))
+# else
+# define VA_COPY(DEST, SRC) memcpy ((&DEST), (&SRC), sizeof(va_list))
+# endif
+#else
+# ifdef HAVE_VA_LIST_AS_ARRAY
+# define VA_COPY(DEST,SRC) (*(DEST) = *(SRC))
+# else
+# define VA_COPY(DEST, SRC) va_copy(DEST, SRC)
+# endif
+#endif
+
#ifdef _AIX
/* Some AIX boxes seem to have bogus includes that don't have these
* prototypes. */
diff --git a/include/sysconf.h.in b/include/sysconf.h.in
index 370330ead..86a2715a4 100644
--- a/include/sysconf.h.in
+++ b/include/sysconf.h.in
@@ -90,6 +90,9 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
+/* va_list as array */
+#undef HAVE_VA_LIST_AS_ARRAY
+
/* "Module dir" */
#undef MODULE_PATH
@@ -177,7 +180,7 @@
#include <stdio.h>
/* We KNOW these are not ansi, we are defining them here to suppress the warning
- * s messages on a "make strict" compile */
+ * * s messages on a "make strict" compile */
int snprintf(char *str, size_t size, const char *format, ...);
int vprintf(const char *format, va_list ap);
int vfprintf(FILE *stream, const char *format, va_list ap);
diff --git a/src/log.c b/src/log.c
index 1d2048a10..98a84a61f 100644
--- a/src/log.c
+++ b/src/log.c
@@ -144,9 +144,9 @@ void alog(const char *fmt, ...)
*
* --nenolod
*/
- va_copy(logargs, args);
- va_copy(consoleargs, args);
- va_copy(logchanargs, args);
+ VA_COPY(logargs, args);
+ VA_COPY(consoleargs, args);
+ VA_COPY(logchanargs, args);
time(&t);
tm = *localtime(&t);
@@ -220,8 +220,8 @@ void log_perror(const char *fmt, ...)
*
* --nenolod
*/
- va_copy(logargs, args);
- va_copy(consoleargs, args);
+ VA_COPY(logargs, args);
+ VA_COPY(consoleargs, args);
time(&t);
tm = *localtime(&t);