diff options
-rw-r--r-- | Changelog-Trunk.txt | 9 | ||||
-rw-r--r-- | Makefile.in | 17 | ||||
-rwxr-xr-x | configure | 521 | ||||
-rw-r--r-- | configure.in | 118 | ||||
-rw-r--r-- | src/common/Makefile.in | 2 | ||||
-rw-r--r-- | src/common/cbasetypes.h | 12 | ||||
-rw-r--r-- | src/common/malloc.c | 22 | ||||
-rw-r--r-- | src/common/malloc.h | 35 | ||||
-rw-r--r-- | src/common/nullpo.h | 49 | ||||
-rw-r--r-- | src/map/path.c | 4 |
10 files changed, 709 insertions, 80 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index b8c84d2aa..1bfd14d37 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,15 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/11/19 + * Nullpo's disabled on release builds. + * Added timestamps to the log of memory leaks. + * Moved definition of __func__ to cbasetypes.h. + * Configure script updated: + - added option to select the memory manager + - added option to enable MAPREGSQL + - added option to enable DEBUG + * common's Makefile deleting svnversion.h on 'clean' target. [FlavioJS] 2007/11/18 * Implemented a small change that was long overdue: Displaying the char-select screen now uses a single SQL query instead of up to 9. diff --git a/Makefile.in b/Makefile.in index ac121ff24..a2b1cd150 100644 --- a/Makefile.in +++ b/Makefile.in @@ -130,23 +130,6 @@ needs_mysql: ##################################################################### # TODO -# Server Packet Protocol version (also defined in src/common/mmo.h) -# CFLAGS += -DPACKETVER=8 - -# Makes map-wide script variables be saved to SQL instead of TXT files. -# CFLAGS += -DMAPREGSQL - -# OPT += -DGCOLLECT -# LIBS += -lgc - -# OPT += -DMEMWATCH - -# OPT += -DDMALLOC -DDMALLOC_FUNC_CHECK -# LIBS += -ldmalloc - -# OPT += -DBCHECK - - install: conf/%.conf conf/%.txt $(shell mkdir -p /opt/eathena/bin/) $(shell mkdir -p /opt/eathena/etc/eathena/) @@ -1,5 +1,5 @@ #! /bin/sh -# From configure.in Revision: 11695. +# From configure.in Revision: 11760. # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # @@ -1249,6 +1249,16 @@ if test -n "$ac_init_help"; then cat <<\_ACEOF +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-manager=ARG memory managers: no, builtin, memwatch, dmalloc, + gcollect, bcheck (defaults to builtin) + --enable-mapregsql Makes map-wide script variables be saved to SQL + instead of TXT files in the sql map-server. (defauts + to no) + --enable-debug Compiles in debug mode. (defauts to no) + Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) @@ -1707,6 +1717,76 @@ ac_config_files="$ac_config_files src/map/Makefile src/plugins/Makefile src/tool # +# Memory managers +# +# Check whether --enable-manager was given. +if test "${enable_manager+set}" = set; then + enableval=$enable_manager; + enable_manager="$enableval" + case $enableval in + "no");; + "builtin");; + "memwatch");; + "dmalloc");; + "gcollect");; + "bcheck");; + *) { { echo "$as_me:$LINENO: error: unknown memory manager '$enable_manager'... stopping" >&5 +echo "$as_me: error: unknown memory manager '$enable_manager'... stopping" >&2;} + { (exit 1); exit 1; }; };; + esac + +else + enable_manager="builtin" + +fi + + + +# +# mapregsql +# +# Check whether --enable-mapregsql was given. +if test "${enable_mapregsql+set}" = set; then + enableval=$enable_mapregsql; + enable_mapregsql="$enableval" + case $enableval in + no);; + yes);; + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-mapregsql=$enable_mapregsql... stopping" >&5 +echo "$as_me: error: invalid argument --enable-mapregsql=$enable_mapregsql... stopping" >&2;} + { (exit 1); exit 1; }; };; + esac + +else + enable_mapregsql="no" + +fi + + + +# +# debug +# +# Check whether --enable-debug was given. +if test "${enable_debug+set}" = set; then + enableval=$enable_debug; + enable_debug="$enableval" + case $enableval in + no);; + yes);; + *) { { echo "$as_me:$LINENO: error: invalid argument --enable-debug=$enable_mapregsql... stopping" >&5 +echo "$as_me: error: invalid argument --enable-debug=$enable_mapregsql... stopping" >&2;} + { (exit 1); exit 1; }; };; + esac + +else + enable_debug="no" + +fi + + + +# # Enable/disable MySql and optionally specify the path (optional library) # @@ -3837,6 +3917,445 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +case $enableval in + "no") + CFLAGS="$CFLAGS -DNO_MEMMGR" + ;; + "builtin") + # enabled by default + ;; + "memwatch") + CFLAGS="$CFLAGS -DMEMWATCH" + if test "${ac_cv_header_memwatch_h+set}" = set; then + { echo "$as_me:$LINENO: checking for memwatch.h" >&5 +echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6; } +if test "${ac_cv_header_memwatch_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking memwatch.h usability" >&5 +echo $ECHO_N "checking memwatch.h usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <memwatch.h> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking memwatch.h presence" >&5 +echo $ECHO_N "checking memwatch.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <memwatch.h> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: memwatch.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: memwatch.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: memwatch.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: memwatch.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: memwatch.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: memwatch.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: memwatch.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: memwatch.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: memwatch.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: memwatch.h: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for memwatch.h" >&5 +echo $ECHO_N "checking for memwatch.h... $ECHO_C" >&6; } +if test "${ac_cv_header_memwatch_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_memwatch_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_memwatch_h" >&5 +echo "${ECHO_T}$ac_cv_header_memwatch_h" >&6; } + +fi +if test $ac_cv_header_memwatch_h = yes; then + : +else + { { echo "$as_me:$LINENO: error: memwatch header not found... stopping" >&5 +echo "$as_me: error: memwatch header not found... stopping" >&2;} + { (exit 1); exit 1; }; } +fi + + + ;; + "dmalloc") + CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK" + LIBS="$LIBS -ldmalloc" + if test "${ac_cv_header_dmalloc_h+set}" = set; then + { echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6; } +if test "${ac_cv_header_dmalloc_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking dmalloc.h usability" >&5 +echo $ECHO_N "checking dmalloc.h usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <dmalloc.h> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking dmalloc.h presence" >&5 +echo $ECHO_N "checking dmalloc.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <dmalloc.h> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: dmalloc.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: dmalloc.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: dmalloc.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: dmalloc.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: dmalloc.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: dmalloc.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: dmalloc.h: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for dmalloc.h" >&5 +echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6; } +if test "${ac_cv_header_dmalloc_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_dmalloc_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5 +echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6; } + +fi +if test $ac_cv_header_dmalloc_h = yes; then + : +else + { { echo "$as_me:$LINENO: error: dmalloc header not found... stopping" >&5 +echo "$as_me: error: dmalloc header not found... stopping" >&2;} + { (exit 1); exit 1; }; } +fi + + + ;; + "gcollect") + CFLAGS="$CFLAGS -DGCOLLECT" + LIBS="$LIBS -lgc" + if test "${ac_cv_header_gc_h+set}" = set; then + { echo "$as_me:$LINENO: checking for gc.h" >&5 +echo $ECHO_N "checking for gc.h... $ECHO_C" >&6; } +if test "${ac_cv_header_gc_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +echo "${ECHO_T}$ac_cv_header_gc_h" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking gc.h usability" >&5 +echo $ECHO_N "checking gc.h usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <gc.h> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking gc.h presence" >&5 +echo $ECHO_N "checking gc.h presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <gc.h> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: gc.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: gc.h: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: gc.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: gc.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: gc.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: gc.h: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: gc.h: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: gc.h: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: gc.h: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: gc.h: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for gc.h" >&5 +echo $ECHO_N "checking for gc.h... $ECHO_C" >&6; } +if test "${ac_cv_header_gc_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_gc_h=$ac_header_preproc +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_gc_h" >&5 +echo "${ECHO_T}$ac_cv_header_gc_h" >&6; } + +fi +if test $ac_cv_header_gc_h = yes; then + : +else + { { echo "$as_me:$LINENO: error: gcollect header not found... stopping" >&5 +echo "$as_me: error: gcollect header not found... stopping" >&2;} + { (exit 1); exit 1; }; } +fi + + + ;; + "bcheck") + CFLAGS="$CFLAGS -DBCHECK" + ;; +esac + + + +if test "$enable_mapregsql" = "yes" ; then + CFLAGS="$CFLAGS -DMAPREGSQL" +fi + + + +if test "$enable_debug" = "yes" ; then + CFLAGS="$CFLAGS -DDEBUG" +fi + + + MYSQL_VERSION="" MYSQL_CFLAGS="" MYSQL_LIBS="" diff --git a/configure.in b/configure.in index dc5da9c54..1ac99c495 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_INIT(eAthena) -AC_REVISION($Revision: 11695$) +AC_REVISION($Revision$) AC_PREREQ([2.61]) AC_CONFIG_SRCDIR([src/common/cbasetypes.h]) AC_CONFIG_FILES([Makefile src/common/Makefile]) @@ -12,6 +12,73 @@ AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile]) # +# Memory managers +# +AC_ARG_ENABLE( + [manager], + AC_HELP_STRING( + [--enable-manager=ARG], + [memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin)] + ), + [ + enable_manager="$enableval" + case $enableval in + "no");; + "builtin");; + "memwatch");; + "dmalloc");; + "gcollect");; + "bcheck");; + *) AC_MSG_ERROR([[unknown memory manager '$enable_manager'... stopping]]);; + esac + ], + [enable_manager="builtin"] +) + + +# +# mapregsql +# +AC_ARG_ENABLE( + [mapregsql], + AC_HELP_STRING( + [--enable-mapregsql], + [Makes map-wide script variables be saved to SQL instead of TXT files in the sql map-server. (defauts to no)] + ), + [ + enable_mapregsql="$enableval" + case $enableval in + no);; + yes);; + *) AC_MSG_ERROR([[invalid argument --enable-mapregsql=$enable_mapregsql... stopping]]);; + esac + ], + [enable_mapregsql="no"] +) + + +# +# debug +# +AC_ARG_ENABLE( + [debug], + AC_HELP_STRING( + [--enable-debug], + [Compiles in debug mode. (defauts to no)] + ), + [ + enable_debug="$enableval" + case $enableval in + no);; + yes);; + *) AC_MSG_ERROR([[invalid argument --enable-debug=$enable_mapregsql... stopping]]);; + esac + ], + [enable_debug="no"] +) + + +# # Enable/disable MySql and optionally specify the path (optional library) # AC_ARG_WITH( @@ -165,6 +232,55 @@ AC_COMPILE_IFELSE( dnl +dnl Memory manager +dnl + +case $enableval in + "no") + CFLAGS="$CFLAGS -DNO_MEMMGR" + ;; + "builtin") + # enabled by default + ;; + "memwatch") + CFLAGS="$CFLAGS -DMEMWATCH" + AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])]) + ;; + "dmalloc") + CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK" + LIBS="$LIBS -ldmalloc" + AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])]) + ;; + "gcollect") + CFLAGS="$CFLAGS -DGCOLLECT" + LIBS="$LIBS -lgc" + AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])]) + ;; + "bcheck") + CFLAGS="$CFLAGS -DBCHECK" + ;; +esac + + +dnl +dnl Memory manager +dnl + +if test "$enable_mapregsql" = "yes" ; then + CFLAGS="$CFLAGS -DMAPREGSQL" +fi + + +dnl +dnl Debug +dnl + +if test "$enable_debug" = "yes" ; then + CFLAGS="$CFLAGS -DDEBUG" +fi + + +dnl dnl Check MySQL library (optional) dnl diff --git a/src/common/Makefile.in b/src/common/Makefile.in index c22cc721c..94f42a956 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -17,7 +17,7 @@ txt: obj common sql: $(SQL_DEPENDS) clean: - rm -rf *.o obj obj_sql + rm -rf *.o obj obj_sql svnversion.h help: @echo "possible targets are 'txt' 'sql' 'all' 'clean' 'help'" diff --git a/src/common/cbasetypes.h b/src/common/cbasetypes.h index d31d515a8..557e263fb 100644 --- a/src/common/cbasetypes.h +++ b/src/common/cbasetypes.h @@ -52,6 +52,18 @@ #define DEBUG #endif +// debug function name +#ifndef __NETBSD__ +#if __STDC_VERSION__ < 199901L +# if __GNUC__ >= 2 +# define __func__ __FUNCTION__ +# else +# define __func__ "" +# endif +#endif +#endif + + // disable attributed stuff on non-GNU #if !defined(__GNUC__) && !defined(MINGW) # define __attribute__(x) diff --git a/src/common/malloc.c b/src/common/malloc.c index 414770156..a65ee7eed 100644 --- a/src/common/malloc.c +++ b/src/common/malloc.c @@ -1,15 +1,18 @@ // Copyright (c) Athena Dev Teams - Licensed under GNU GPL // For more information, see LICENCE in the main folder -#include <stdio.h> -#include <stdlib.h> -#include <string.h> #include "../common/malloc.h" #include "../common/core.h" #include "../common/showmsg.h" -#ifdef MINICORE - #undef LOG_MEMMGR +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <time.h> + +// no logging for minicore +#if defined(MINICORE) && defined(LOG_MEMMGR) +#undef LOG_MEMMGR #endif void* aMalloc_(size_t size, const char *file, int line, const char *func) @@ -553,12 +556,17 @@ static FILE *log_fp; static void memmgr_log (char *buf) { - if (!log_fp) { + time_t raw; + struct tm* t; + if( !log_fp ) + { log_fp = fopen(memmer_logfile,"w"); if (!log_fp) log_fp = stdout; fprintf(log_fp, "Memory manager: Memory leaks found (Revision %s).\n", get_svn_revision()); } - fprintf(log_fp, buf); + time(&raw); + t = localtime(&raw); + fprintf(log_fp, "%04d%02d%02d%02d%02d%02d %s", (t->tm_year+1900), (t->tm_mon+1), t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, buf); return; } #endif diff --git a/src/common/malloc.h b/src/common/malloc.h index 43eff40f1..1efc4686f 100644 --- a/src/common/malloc.h +++ b/src/common/malloc.h @@ -13,28 +13,28 @@ // and I have doubts our implementation works. // -> They should NOT be used, period. -#ifndef __NETBSD__ -#if __STDC_VERSION__ < 199901L -# if __GNUC__ >= 2 -# define __func__ __FUNCTION__ -# else -# define __func__ "" -# endif +#define ALC_MARK __FILE__, __LINE__, __func__ + +// disable built-in memory manager when using another manager +#if defined(MEMWATCH) || defined(DMALLOC) || defined(GCOLLECT) || defined(BCHECK) +#if !defined(NO_MEMMGR) +#define NO_MEMMGR #endif #endif -#define ALC_MARK __FILE__, __LINE__, __func__ -////////////////////////////////////////////////////////////////////// -// Whether to use Athena's built-in Memory Manager (enabled by default) -// To disable just comment the following line -#if !defined(DMALLOC) && !defined(BCHECK) - #define USE_MEMMGR +// Use built-in memory manager by default +#if !defined(NO_MEMMGR) && !defined(USE_MEMMGR) +#define USE_MEMMGR #endif -// Whether to enable Memory Manager's logging -#define LOG_MEMMGR + +////////////////////////////////////////////////////////////////////// +// Athena's built-in Memory Manager #ifdef USE_MEMMGR +// Enable memory manager logging by default +#define LOG_MEMMGR + # define aMalloc(n) _mmalloc(n,ALC_MARK) # define aMallocA(n) _mmalloc(n,ALC_MARK) # define aCalloc(m,n) _mcalloc(m,n,ALC_MARK) @@ -71,7 +71,7 @@ ////////////// Memory Managers ////////////////// -#ifdef MEMWATCH +#if defined(MEMWATCH) # include "memwatch.h" # define MALLOC(n,file,line,func) mwMalloc((n),(file),(line)) @@ -108,7 +108,6 @@ void * _bcallocA(size_t, size_t); char * _bstrdup(const char *); -/* FIXME Why is this the same as #else? [FlavioJS] #elif defined(BCHECK) # define MALLOC(n,file,line,func) malloc(n) @@ -118,7 +117,7 @@ # define REALLOC(p,n,file,line,func) realloc((p),(n)) # define STRDUP(p,file,line,func) strdup(p) # define FREE(p,file,line,func) free(p) -*/ + #else # define MALLOC(n,file,line,func) malloc(n) diff --git a/src/common/nullpo.h b/src/common/nullpo.h index 0238d2b6d..8ee86a782 100644 --- a/src/common/nullpo.h +++ b/src/common/nullpo.h @@ -5,28 +5,15 @@ #define _NULLPO_H_ -#define NULLPO_CHECK 1 - // 全体のスイッチを宣言しているヘッダがあれば - // そこに移動していただけると - -#ifndef __NETBSD__ -#if __STDC_VERSION__ < 199901L -# if __GNUC__ >= 2 -# define __func__ __FUNCTION__ -# else -# define __func__ "" -# endif -#endif -#endif +#include "../common/cbasetypes.h" +#define NLP_MARK __FILE__, __LINE__, __func__ -#if !defined(__GNUC__) && !defined(MINGW) -# define __attribute__(x) /* nothing */ +// enabled by default on debug builds +#if defined(DEBUG) && !defined(NULLPO_CHECK) +#define NULLPO_CHECK #endif - -#define NLP_MARK __FILE__, __LINE__, __func__ - /*---------------------------------------------------------------------------- * Macros *---------------------------------------------------------------------------- @@ -81,7 +68,7 @@ *-------------------------------------- */ -#if NULLPO_CHECK +#if defined(NULLPO_CHECK) #define nullpo_ret(t) \ if (nullpo_chk(NLP_MARK, (void *)(t))) {return(0);} @@ -137,25 +124,25 @@ // 良い方法が思いつかなかったので・・・苦肉の策です。 // 一応ワーニングは出ないはず -#define nullpo_ret(t) if((t)){;} -#define nullpo_retv(t) if((t)){;} -#define nullpo_retr(ret, t) if((t)){;} -#define nullpo_retb(t) if((t)){;} +#define nullpo_ret(t) (void)(t) +#define nullpo_retv(t) (void)(t) +#define nullpo_retr(ret, t) (void)(t) +#define nullpo_retb(t) (void)(t) // 可変引数マクロに関する条件コンパイル #if __STDC_VERSION__ >= 199901L /* C99に対応 */ -#define nullpo_ret_f(t, fmt, ...) if((t)){;} -#define nullpo_retv_f(t, fmt, ...) if((t)){;} -#define nullpo_retr_f(ret, t, fmt, ...) if((t)){;} -#define nullpo_retb_f(t, fmt, ...) if((t)){;} +#define nullpo_ret_f(t, fmt, ...) (void)(t) +#define nullpo_retv_f(t, fmt, ...) (void)(t) +#define nullpo_retr_f(ret, t, fmt, ...) (void)(t) +#define nullpo_retb_f(t, fmt, ...) (void)(t) #elif __GNUC__ >= 2 /* GCC用 */ -#define nullpo_ret_f(t, fmt, args...) if((t)){;} -#define nullpo_retv_f(t, fmt, args...) if((t)){;} -#define nullpo_retr_f(ret, t, fmt, args...) if((t)){;} -#define nullpo_retb_f(t, fmt, args...) if((t)){;} +#define nullpo_ret_f(t, fmt, args...) (void)(t) +#define nullpo_retv_f(t, fmt, args...) (void)(t) +#define nullpo_retr_f(ret, t, fmt, args...) (void)(t) +#define nullpo_retb_f(t, fmt, args...) (void)(t) #else /* その他の場合・・・ orz */ diff --git a/src/map/path.c b/src/map/path.c index 50c2f2192..3d4b99fc9 100644 --- a/src/map/path.c +++ b/src/map/path.c @@ -8,10 +8,6 @@ #include "map.h" #include "battle.h" -#ifdef MEMWATCH -#include "memwatch.h" -#endif - #include <stdio.h> #include <stdlib.h> #include <string.h> |