Parcourir la source

Fix ARM compilation.
-Upd configure (merge with Hercule configure.in)
-upd nullpo.c and atomic.h to allow arm compilation, testedon Epiphany parallela.

Lighta il y a 11 ans
Parent
commit
55134d1ae1
7 fichiers modifiés avec 1517 ajouts et 253 suppressions
  1. 1089 72
      configure
  2. 342 108
      configure.in
  3. 7 1
      src/common/atomic.h
  4. 8 10
      src/common/nullpo.c
  5. 53 0
      src/common/utils.c
  6. 10 0
      src/common/utils.h
  7. 8 62
      src/tool/mapcache.c

Fichier diff supprimé car celui-ci est trop grand
+ 1089 - 72
configure


+ 342 - 108
configure.in

@@ -45,7 +45,7 @@ AC_ARG_ENABLE(
 	[packetver],
 	AC_HELP_STRING(
 		[--enable-packetver=ARG],
-		[Sets the PACKETVER define of the map-server. (see src/map/clif.h)]
+		[Sets the PACKETVER define. (see src/common/mmo.h)]
 	),
 	[enable_packetver="$enableval"],
 	[enable_packetver=""]
@@ -247,18 +247,18 @@ AC_ARG_WITH(
 	),
 	[
 		if test "$withval" == "no";	 then
-			CFLAGS="$CFLAGS -DMAXCONN=16384"
+			CPPFLAGS="$CPPFLAGS -DMAXCONN=16384"
 		else
 
 			if ! test "$withval" -ge 0 -o "$withval" -lt 0 2>&- ; then
 				AC_MSG_ERROR([Invalid argument --with-maxconn=$withval ... stopping])
 			else
-				CFLAGS="$CFLAGS -DMAXCONN=$withval"
+				CPPFLAGS="$CPPFLAGS -DMAXCONN=$withval"
 			fi
 		fi
 	],
 	[
-		CFLAGS="$CFLAGS -DMAXCONN=16384"
+		CPPFLAGS="$CPPFLAGS -DMAXCONN=16384"
 	]
 )
 
@@ -455,16 +455,37 @@ fi
 #
 AC_MSG_CHECKING([whether $CC produces 32bit code])
 AC_RUN_IFELSE(
-	[
+	[AC_LANG_SOURCE([
 		int main(int argc, char **argv){
 			if(sizeof(void*) == 4) return 0;
 			else return 1;
 		}
-	],
+	])],
 	[
 		AC_MSG_RESULT([yes])
+		AC_MSG_CHECKING([whether $CC supports -march=i686 (and we can run it)])
+		OLD_CFLAGS="$CFLAGS"
+		OLD_LDFLAGS="$LDFLAGS"
 		CFLAGS="$CFLAGS -march=i686"
 		LDFLAGS="$LDFLAGS -march=i686"
+		AC_RUN_IFELSE(
+			[AC_LANG_SOURCE([
+				int main(int argc, char **argv) { return 0; }
+			])],
+			[
+				AC_MSG_RESULT([yes])
+			],
+			[
+				AC_MSG_RESULT([no])
+				CFLAGS="$OLD_CFLAGS"
+				LDFLAGS="$OLD_LDFLAGS"
+			],
+			[
+				AC_MSG_RESULT([guessing no])
+				CFLAGS="$OLD_CFLAGS"
+				LDFLAGS="$OLD_LDFLAGS"
+			]
+		)
 	],
 	[
 		AC_MSG_RESULT([no])
@@ -481,38 +502,23 @@ AC_RUN_IFELSE(
 #
 AC_MSG_CHECKING([whether $CC supports __thread specifier (TLS)])
 AC_RUN_IFELSE(
-	[
+	[AC_LANG_SOURCE([
 		__thread int g_Test = -1;
 
 		int main(int argc, char **argv){
 			g_Test = 0;
 			return g_Test;
 		}
-	],
+	])],
 	[
 		AC_MSG_RESULT([yes])
-		CFLAGS="$CFLAGS -DHAS_TLS"
+		CPPFLAGS="$CPPFLAGS -DHAS_TLS"
 	],
 	[
 		AC_MSG_RESULT([no])
 	]
 )
 
-
-AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
-OLD_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wno-unused-parameter"
-AC_COMPILE_IFELSE(
-	[int foo;],
-	[AC_MSG_RESULT([no])],
-	[
-		AC_MSG_RESULT([yes])
-		PROD_WARN="$PROD_WARN -Wno-unused-parameter"
-	]
-)
-CFLAGS="$OLD_CFLAGS"
-
-
 #
 # LTO Support test
 #
@@ -526,11 +532,11 @@ if test "$enable_lto" != "no" ; then
 
 	AC_MSG_CHECKING([whether $CC supports -flto])
 	AC_RUN_IFELSE(
-		[
+		[AC_LANG_SOURCE([
 			int main(int argc, char **argv){
-               return 0;
-           }
-		],
+				return 0;
+			}
+		])],
 		[
 			AC_MSG_RESULT([yes])
 		],
@@ -546,55 +552,147 @@ if test "$enable_lto" != "no" ; then
 fi
 
 
-
-AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
-OLD_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wno-pointer-sign"
-AC_COMPILE_IFELSE(
-	[int foo;],
+AC_DEFUN(AC_CHECK_COMPILER_WFLAG,
 	[
-		AC_MSG_RESULT([yes])
-		AC_MSG_CHECKING([whether $CC can actually use -Wno-pointer-sign])
-		# This option causes warnings in C++ mode
-		# Note: -Werror must be before -Wno-pointer-sign, otherwise it does not do anything
-		CFLAGS="$OLD_CFLAGS -Werror -Wno-pointer-sign"
+		AC_MSG_CHECKING([whether $CC supports -W$1])
+		OLD_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS -Werror -W$1"
 		AC_COMPILE_IFELSE(
-			[int foo;],
+			[AC_LANG_SOURCE([int foo;])],
 			[
 				AC_MSG_RESULT([yes])
-				PROD_WARN="$PROD_WARN -Wno-pointer-sign"
+				CFLAGS="$OLD_CFLAGS -W$1"
+				# Optionally, run a test
+				if test "x$2" != "x"; then
+					AC_MSG_CHECKING([whether $CC can actually use -W$1])
+					CFLAGS="$OLD_CFLAGS -Werror -W$1"
+					AC_COMPILE_IFELSE(
+						[AC_LANG_SOURCE([$2])],
+						[
+							AC_MSG_RESULT([no])
+							CFLAGS="$OLD_CFLAGS"
+						]
+						[
+							AC_MSG_RESULT([yes])
+							CFLAGS="$OLD_CFLAGS -W$1"
+						],
+					)
+				fi
 			],
 			[
 				AC_MSG_RESULT([no])
+				CFLAGS="$OLD_CFLAGS"
 			]
 		)
-	],
-	[
-		AC_MSG_RESULT([no])
 	]
 )
-CFLAGS="$OLD_CFLAGS"
 
-
-AC_MSG_CHECKING([whether $CC supports -Wno-switch])
-OLD_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wno-switch"
-AC_COMPILE_IFELSE(
-	[int foo;],
-	[	AC_MSG_RESULT([yes])
-	],
+AC_DEFUN(AC_CHECK_COMPILER_WNOFLAG,
 	[
-		AC_MSG_RESULT([no])
-		CFLAGS="$OLD_CFLAGS"
+		AC_MSG_CHECKING([whether $CC supports -Wno-$1])
+		OLD_CFLAGS="$CFLAGS"
+		CFLAGS="$CFLAGS -Werror -Wno-$1"
+		AC_COMPILE_IFELSE(
+			[AC_LANG_SOURCE([int foo;])],
+			[
+				# Recent versions of gcc don't fail if -Wno-foo is not recognized
+				# (unless there are also other warnings), so we also check for -Wfoo
+				# which always fails if not supported
+				CFLAGS="$OLD_CFLAGS -Werror -W$1"
+				AC_COMPILE_IFELSE(
+					[AC_LANG_SOURCE([int foo;])],
+					[
+						AC_MSG_RESULT([yes])
+						CFLAGS="$OLD_CFLAGS -Wno-$1"
+						# Optionally, run a test
+						if test "x$2" != "x"; then
+							AC_MSG_CHECKING([whether $CC can actually use -Wno-$1])
+							CFLAGS="$OLD_CFLAGS -Werror -W$1"
+							AC_COMPILE_IFELSE(
+								[AC_LANG_SOURCE([$2])],
+								[
+									AC_MSG_RESULT([not needed but enabled])
+									CFLAGS="$OLD_CFLAGS"
+								],
+								[
+									CFLAGS="$OLD_CFLAGS -Werror -Wno-$1"
+									AC_COMPILE_IFELSE(
+										[AC_LANG_SOURCE([$2])],
+										[
+											AC_MSG_RESULT([yes])
+											CFLAGS="$OLD_CFLAGS -Wno-$1"
+										],
+										[
+											AC_MSG_RESULT([no])
+											CFLAGS="$OLD_CFLAGS"
+										]
+									)
+								]
+							)
+						fi
+					],
+					[
+						AC_MSG_RESULT([no])
+						CFLAGS="$OLD_CFLAGS"
+					]
+				)
+			],
+			[
+				AC_MSG_RESULT([no])
+				CFLAGS="$OLD_CFLAGS"
+			]
+		)
 	]
 )
 
+AC_CHECK_COMPILER_WNOFLAG(unused-parameter, [int foo(int bar) { return 0; }])
+AC_CHECK_COMPILER_WNOFLAG(maybe-uninitialized)
+AC_CHECK_COMPILER_WNOFLAG(clobbered)
+AC_CHECK_COMPILER_WFLAG(empty-body)
+AC_CHECK_COMPILER_WFLAG(newline-eof)
+AC_CHECK_COMPILER_WFLAG(int-conversion)
+AC_CHECK_COMPILER_WFLAG(enum-conversion)
+AC_CHECK_COMPILER_WFLAG(shorten-64-to-32)
+AC_CHECK_COMPILER_WFLAG(constant-conversion)
+AC_CHECK_COMPILER_WFLAG(bool-conversion)
+AC_CHECK_COMPILER_WNOFLAG(switch)
+AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers)
+
+# Certain versions of gcc make -Wshadow completely useless by making it flood
+# you with unnecessary warnings <https://lkml.org/lkml/2006/11/28/239>
+# Let's check if we can really use it
+SAVED_OLD_CFLAGS="$CFLAGS"
+AC_CHECK_COMPILER_WFLAG(shadow)
+if test "x$CFLAGS" != "x$SAVED_OLD_CFLAGS"; then
+	AC_MSG_CHECKING([whether $CC can efficiently use -Wshadow])
+	NEW_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS -Werror -Wshadow"
+	AC_COMPILE_IFELSE(
+		[AC_LANG_SOURCE([
+			int foo(void) {
+				return 0;
+			}
+			int bar(void) {
+				int foo = 0;
+				return foo + 1;
+			}
+		])],
+		[
+			AC_MSG_RESULT([yes])
+			CFLAGS="$NEW_CFLAGS"
+		],
+		[
+			AC_MSG_RESULT([no])
+			CFLAGS="$SAVED_OLD_CFLAGS"
+		]
+	)
+fi
 
 AC_MSG_CHECKING([whether $CC supports -fPIC])
 OLD_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -fPIC"
 AC_COMPILE_IFELSE(
-	[int foo;],
+	[AC_LANG_SOURCE([int foo;])],
 	[
 		AC_MSG_RESULT([yes])
 		compiler_supports_pic="yes"
@@ -606,6 +704,152 @@ AC_COMPILE_IFELSE(
 )
 CFLAGS="$OLD_CFLAGS"
 
+#
+# option for shared objects
+#
+AC_MSG_CHECKING([how to make shared objects])
+OLD_CFLAGS="$CFLAGS"
+compiler_shared_objects=""
+compiler_supports_shared_objects="no"
+if test "$compiler_supports_pic" = "yes" ; then
+	my_shared_test_flags="$CFLAGS -fPIC"
+fi
+# default
+CFLAGS="$my_shared_test_flags -shared"
+AC_LINK_IFELSE(
+	[AC_LANG_SOURCE([
+		int bar = 0;
+
+		int foo(void)
+		{
+			return bar;
+		}
+	])],
+	[
+		compiler_shared_objects="-shared"
+		compiler_supports_shared_objects="yes"
+	]
+)
+# BeOS specific
+CFLAGS="$my_shared_test_flags -nostart"
+AC_LINK_IFELSE(
+	[AC_LANG_SOURCE([
+		int bar = 0;
+
+		int foo(void)
+		{
+			return bar;
+		}
+	])],
+	[
+		compiler_shared_objects="-nostart"
+		compiler_supports_shared_objects="yes"
+	]
+)
+CFLAGS="$OLD_CFLAGS"
+if test "$compiler_supports_shared_objects" = "no" ; then
+	AC_MSG_RESULT([not supported])
+	AC_MSG_NOTICE([compiler is unable to generate shared objects, disabled plugins (optional)])
+	WITH_PLUGINS="no"
+else
+	AC_MSG_RESULT([$compiler_shared_objects $compiler_supports_shared_objects])
+	SOFLAGS="$SOFLAGS $compiler_shared_objects"
+	AC_SUBST([SOFLAGS])
+
+	#
+	# On certain platforms, undefined references on shared libraries won't be checked
+	# unless explicitly required with the --no-undefined linker option
+	#
+	AC_MSG_CHECKING([whether $CC needs -Wl,--no-undefined to check for undefined references in shared objects])
+	OLD_CFLAGS="$CFLAGS"
+	CFLAGS="$SOFLAGS"
+	AC_LINK_IFELSE(
+		[AC_LANG_SOURCE([
+			void foo(void) {
+				foobar();
+			}
+		])],
+		[
+			CFLAGS="$SOFLAGS -Wl,--no-undefined"
+			AC_LINK_IFELSE(
+				[AC_LANG_SOURCE([
+					int bar = 0;
+
+					int foo(void) {
+						return bar;
+					}
+				])],
+				[
+					AC_MSG_RESULT([yes])
+					SOFLAGS="$SOFLAGS -Wl,--no-undefined"
+				],
+				[
+					AC_MSG_RESULT([unsupported (undefined references check will be ignored)])
+				]
+			)
+		],
+		[
+			AC_MSG_RESULT([no])
+		]
+	)
+	CFLAGS="$OLD_CFLAGS"
+
+	#
+	# shared objects need position independent code; some platforms emit
+	# it always, others need -fPIC
+	#
+	AC_MSG_CHECKING([whether $CC needs -fPIC for shared objects])
+	OLD_CFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS $SOFLAGS"
+	WITH_PLUGINS="yes"
+	AC_LINK_IFELSE(
+		[AC_LANG_SOURCE([
+			int bar = 0;
+
+			int foo(void)
+			{
+				return bar;
+			}
+		])],
+		[
+			AC_MSG_RESULT([no])
+			CFLAGS="$OLD_CFLAGS"
+		],
+		[
+			if test "$compiler_supports_pic" = "yes" ; then
+				# Verify if -shared really fails due to lack of -fPIC or something else
+				CFLAGS="$CFLAGS -fPIC"
+				AC_LINK_IFELSE(
+					[AC_LANG_SOURCE([
+						int bar = 0;
+
+						int foo(void)
+						{
+							return bar;
+						}
+					])],
+					[
+						AC_MSG_RESULT([yes])
+						CFLAGS="$OLD_CFLAGS -fPIC"
+					],
+					[
+						AC_MSG_RESULT([no, but fails for another reason])
+						AC_MSG_ERROR([compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping])
+					]
+				)
+			else
+				# Disable compilation of plugins (optional), so 'make all' does not fail
+				AC_MSG_RESULT([yes, but unsupported])
+				AC_MSG_NOTICE([compiler is unable to generate position independent code, disabled plugins (optional)])
+				WITH_PLUGINS="no"
+			fi
+		]
+	)
+
+fi
+my_shared_test_flags=""
+AC_SUBST([WITH_PLUGINS])
+
 
 #
 # -O2 implies -fstrict-aliasing, but the code is not safe for that
@@ -614,7 +858,7 @@ AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
 OLD_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS -fno-strict-aliasing"
 AC_COMPILE_IFELSE(
-	[int foo;],
+	[AC_LANG_SOURCE([int foo;])],
 	[AC_MSG_RESULT([yes])],
 	[
 		AC_MSG_RESULT([no])
@@ -622,22 +866,6 @@ AC_COMPILE_IFELSE(
 	]
 )
 
-#
-# check if support conversion check
-#
-AC_MSG_CHECKING([whether $CC supports -Wconversion])
-OLD_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -Wconversion"
-AC_COMPILE_IFELSE(
-	[int foo;],
-	[
-		AC_MSG_RESULT([yes])
-		EXTRA_WARN="-Wconversion"
-	],
-	[AC_MSG_RESULT([no])]
-)
-CFLAGS="$OLD_CFLAGS"
-
 
 ###############################################################################
 # Check for libraries and header files.
@@ -647,46 +875,50 @@ CFLAGS="$OLD_CFLAGS"
 #
 # setrlimit - used to set the socket limit
 #
-AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"])
+AC_CHECK_FUNC([setrlimit],[CPPFLAGS="$CPPFLAGS -DHAVE_SETRLIMIT"])
 
 
 #
 # strnlen - string length with upper scan bound
 #
-AC_CHECK_FUNC([strnlen],[CFLAGS="$CFLAGS -DHAVE_STRNLEN"])
+AC_CHECK_FUNC([strnlen],[CPPFLAGS="$CPPFLAGS -DHAVE_STRNLEN"])
 
 # libconfig
 AC_CHECK_FUNCS([uselocale])
 AC_CHECK_FUNCS([newlocale])
 AC_CHECK_FUNCS([freelocale])
-AC_CHECK_HEADERS([xlocale.h])
+AC_CHECK_HEADERS([xlocale.h], [], [], [
+AC_LANG_SOURCE([#ifdef HAVE_XLOCALE_H
+     # include <xlocale.h>
+     #endif
+     ])])
 
 #
 # Memory manager
 #
 case $enable_manager in
 	"no")
-		CFLAGS="$CFLAGS -DNO_MEMMGR"
+		CPPFLAGS="$CPPFLAGS -DNO_MEMMGR"
 		;;
 	"builtin")
 		# enabled by default
 		;;
 	"memwatch")
-		CFLAGS="$CFLAGS -DMEMWATCH"
+		CPPFLAGS="$CPPFLAGS -DMEMWATCH"
 		AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
 		;;
 	"dmalloc")
-		CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
+		CPPFLAGS="$CPPFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
 		LIBS="$LIBS -ldmalloc"
 		AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
 		;;
 	"gcollect")
-		CFLAGS="$CFLAGS -DGCOLLECT"
+		CPPFLAGS="$CPPFLAGS -DGCOLLECT"
 		LIBS="$LIBS -lgc"
 		AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
 		;;
 	"bcheck")
-		CFLAGS="$CFLAGS -DBCHECK"
+		CPPFLAGS="$CPPFLAGS -DBCHECK"
 		;;
 esac
 
@@ -695,7 +927,7 @@ esac
 # Packetver
 #
 if test -n "$enable_packetver" ; then
-	CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver"
+	CPPFLAGS="$CPPFLAGS -DPACKETVER=$enable_packetver"
 fi
 
 
@@ -705,14 +937,14 @@ fi
 case $enable_debug in
 	"no")
 		# default value
-		CFLAGS="$CFLAGS"
+		CPPFLAGS="$CPPFLAGS"
 		;;
 	"yes")
-		CFLAGS="$CFLAGS -g -DDEBUG"
+		CPPFLAGS="$CPPFLAGS -g -DDEBUG"
 		LDFLAGS="$LDFLAGS -g"
 		;;
 	"gdb")
-		CFLAGS="$CFLAGS -ggdb -DDEBUG"
+		CPPFLAGS="$CPPFLAGS -ggdb -DDEBUG"
 		LDFLAGS="$LDFLAGS -g"
 		;;
 esac
@@ -723,10 +955,10 @@ esac
 case $enable_prere in
 	"no")
 		# default value
-		CFLAGS="$CFLAGS"
+		CPPFLAGS="$CPPFLAGS"
 		;;
 	"yes")
-		CFLAGS="$CFLAGS -DPRERE"
+		CPPFLAGS="$CPPFLAGS -DPRERE"
 		;;
 esac
 
@@ -735,13 +967,13 @@ esac
 #
 case $enable_warn in
 	"no") #default
-		CFLAGS="$CFLAGS $PROD_WARN"
+		CPPFLAGS="$CPPFLAGS $PROD_WARN"
 		;;
 	"yes")
-		CFLAGS="$CFLAGS"
+		CPPFLAGS="$CPPFLAGS"
 		;;
 	"extra")
-		CFLAGS="$CFLAGS $EXTRA_WARN"
+		CPPFLAGS="$CPPFLAGS $EXTRA_WARN"
 		;;
 esac
 
@@ -753,7 +985,7 @@ case $enable_buildbot in
 		# default value
 		;;
 	"yes")
-		CFLAGS="$CFLAGS -DBUILDBOT"
+		CPPFLAGS="$CPPFLAGS -DBUILDBOT"
 		;;
 esac
 
@@ -765,7 +997,7 @@ case $enable_rdtsc in
 		#default value
 		;;
 	1)
-		CFLAGS="$CFLAGS -DENABLE_RDTSC"
+		CPPFLAGS="$CPPFLAGS -DENABLE_RDTSC"
 		;;
 esac
 
@@ -791,8 +1023,12 @@ if test -n "${ZLIB_HOME}" ; then
 	LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
 	CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
 fi
-AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
-AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
+AC_SEARCH_LIBS([inflateEnd], [z], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
+AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])],
+[AC_LANG_SOURCE([#ifdef HAVE_ZLIB_H
+     # include <zlib.h>
+     #endif
+ ])])
 
 
 #
@@ -818,20 +1054,20 @@ AC_SEARCH_LIBS([clock_gettime], [rt])
 if test "$ac_cv_search_clock_gettime" != "no" ; then
 	AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
 	AC_RUN_IFELSE(
-		[
+		[AC_LANG_SOURCE([
 			#include <sys/time.h>
 			#include <time.h>
 			#include <unistd.h>
-
+			
 			int main(int argc, char** argv)
 			{
 				struct timespec tval;
 				return clock_gettime(CLOCK_MONOTONIC, &tval);
 			}
-		],
+		])],
 		[
 			AC_MSG_RESULT([yes])
-			CFLAGS="$CFLAGS -DHAVE_MONOTONIC_CLOCK"
+			CPPFLAGS="$CPPFLAGS -DHAVE_MONOTONIC_CLOCK"
 		],
 		[
 			# either it failed to compile (CLOCK_MONOTONIC undefined)
@@ -848,15 +1084,13 @@ fi
 #
 # pthread
 #
-AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
-AC_CHECK_LIB([pthread], [pthread_sigmask], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
-AC_CHECK_LIB([pthread], [pthread_attr_init], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
-AC_CHECK_LIB([pthread], [pthread_attr_setstacksize], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
-AC_CHECK_LIB([pthread], [pthread_attr_destroy], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
-AC_CHECK_LIB([pthread], [pthread_cancel], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
-AC_CHECK_LIB([pthread], [pthread_join], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
-
-LDFLAGS="$LDFLAGS -lpthread"
+AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
+AC_SEARCH_LIBS([pthread_sigmask], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
+AC_SEARCH_LIBS([pthread_attr_init], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
+AC_SEARCH_LIBS([pthread_attr_setstacksize], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
+AC_SEARCH_LIBS([pthread_attr_destroy], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
+AC_SEARCH_LIBS([pthread_cancel], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
+AC_SEARCH_LIBS([pthread_join], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
 
 
 #
@@ -990,7 +1224,7 @@ else
 	AC_MSG_RESULT([no])
 fi
 
-AC_MSG_NOTICE([Configure finish, CFLAGS= $CFLAGS])
+AC_MSG_NOTICE([Configure finish, CPPFLAGS= $CPPFLAGS])
 AC_MSG_NOTICE([LDFLAGS=$LDFLAGS])
 #AC_MSG_NOTICE([PROD_WARN= $PROD_WARN])
 #AC_MSG_NOTICE([EXTRA_WARN= $EXTRA_WARN])

+ 7 - 1
src/common/atomic.h

@@ -87,10 +87,16 @@ forceinline volatile int64 InterlockedExchange64(volatile int64 *target, int64 v
 
 #elif defined(__GNUC__)
 
-#if !defined(__x86_64__) && !defined(__i386__)
+// The __sync functions are available on x86 or ARMv6+
+//need to proper dig into arm macro, 
+//see http://sourceforge.net/p/predef/wiki/Architectures/
+#if !defined(__x86_64__) && !defined(__i386__) \
+        && ( !defined(__ARM_ARCH_VERSION__) || __ARM_ARCH_VERSION__ < 6 ) \
+        && ( !defined(__ARM_ARCH) && __ARM_ARCH < 6 )   
 #error Your Target Platfrom is not supported
 #endif
 
+
 static forceinline int64 InterlockedExchangeAdd64(volatile int64 *addend, int64 increment){
         return __sync_fetch_and_add(addend, increment);
 }//end: InterlockedExchangeAdd64()

+ 8 - 10
src/common/nullpo.c

@@ -6,13 +6,12 @@
 #include <string.h>
 #include "nullpo.h"
 #include "../common/showmsg.h"
-// #include "logs.h" // 布石してみる
 
 static void nullpo_info_core(const char *file, int line, const char *func, 
                              const char *fmt, va_list ap);
 
 /*======================================
- * Nullチェック 及び 情報出力
+ * Null Information output and check
  *--------------------------------------*/
 int nullpo_chk_f(const char *file, int line, const char *func, const void *target,
                  const char *fmt, ...)
@@ -30,16 +29,17 @@ int nullpo_chk_f(const char *file, int line, const char *func, const void *targe
 
 int nullpo_chk(const char *file, int line, const char *func, const void *target)
 {
+        va_list ap;
 	if (target != NULL)
 		return 0;
 	
-	nullpo_info_core(file, line, func, NULL, NULL);
+	nullpo_info_core(file, line, func, NULL, ap);
 	return 1;
 }
 
 
 /*======================================
- * nullpo情報出力(外部呼出し向けラッパ)
+ * nullpo Information output (external call)
  *--------------------------------------*/
 void nullpo_info_f(const char *file, int line, const char *func, 
                  const char *fmt, ...)
@@ -53,12 +53,13 @@ void nullpo_info_f(const char *file, int line, const char *func,
 
 void nullpo_info(const char *file, int line, const char *func)
 {
-	nullpo_info_core(file, line, func, NULL, NULL);
+        va_list ap;
+	nullpo_info_core(file, line, func, NULL, ap);
 }
 
 
 /*======================================
- * nullpo情報出力(Main)
+ * nullpo intelligence Output (Main)
  *--------------------------------------*/
 static void nullpo_info_core(const char *file, int line, const char *func, 
                              const char *fmt, va_list ap)
@@ -79,13 +80,10 @@ static void nullpo_info_core(const char *file, int line, const char *func,
 		{
 			vprintf(fmt, ap);
 			
-			// 最後に改行したか確認
+			// Check whether the new line at the end
 			if (fmt[strlen(fmt)-1] != '\n')
 				ShowMessage("\n");
 		}
 	}
 	ShowMessage("--- end nullpo info ----------------------------------------\n");
-	
-	// ここらでnullpoログをファイルに書き出せたら
-	// まとめて提出できるなと思っていたり。
 }

+ 53 - 0
src/common/utils.c

@@ -259,6 +259,59 @@ uint32 MakeDWord(uint16 word0, uint16 word1)
 		( (uint32)(word1 << 0x10) );
 }
 
+/*************************************
+* Big-endian compatibility functions *
+*************************************/
+
+// Converts an int16 from current machine order to little-endian
+int16 MakeShortLE(int16 val)
+{
+	unsigned char buf[2];
+	buf[0] = (unsigned char)( (val & 0x00FF)         );
+	buf[1] = (unsigned char)( (val & 0xFF00) >> 0x08 );
+	return *((int16*)buf);
+}
+
+// Converts an int32 from current machine order to little-endian
+int32 MakeLongLE(int32 val)
+{
+	unsigned char buf[4];
+	buf[0] = (unsigned char)( (val & 0x000000FF)         );
+	buf[1] = (unsigned char)( (val & 0x0000FF00) >> 0x08 );
+	buf[2] = (unsigned char)( (val & 0x00FF0000) >> 0x10 );
+	buf[3] = (unsigned char)( (val & 0xFF000000) >> 0x18 );
+	return *((int32*)buf);
+}
+
+// Reads an uint16 in little-endian from the buffer
+uint16 GetUShort(const unsigned char* buf)
+{
+	return	 ( ((uint16)(buf[0]))         )
+			|( ((uint16)(buf[1])) << 0x08 );
+}
+
+// Reads an uint32 in little-endian from the buffer
+uint32 GetULong(const unsigned char* buf)
+{
+	return	 ( ((uint32)(buf[0]))         )
+			|( ((uint32)(buf[1])) << 0x08 )
+			|( ((uint32)(buf[2])) << 0x10 )
+			|( ((uint32)(buf[3])) << 0x18 );
+}
+
+// Reads an int32 in little-endian from the buffer
+int32 GetLong(const unsigned char* buf)
+{
+	return (int32)GetULong(buf);
+}
+
+// Reads a float (32 bits) from the buffer
+float GetFloat(const unsigned char* buf)
+{
+	uint32 val = GetULong(buf);
+	return *((float*)(void*)&val);
+}
+
 uint32 date2version(int date) {
 	if(date < 20040906) return 5;
 	else if(date < 20040920) return 10;

+ 10 - 0
src/common/utils.h

@@ -29,6 +29,16 @@ extern uint16 GetWord(uint32 val, int idx);
 extern uint16 MakeWord(uint8 byte0, uint8 byte1);
 extern uint32 MakeDWord(uint16 word0, uint16 word1);
 
+//////////////////////////////////////////////////////////////////////////
+// Big-endian compatibility functions
+//////////////////////////////////////////////////////////////////////////
+extern int16 MakeShortLE(int16 val);
+extern int32 MakeLongLE(int32 val);
+extern uint16 GetUShort(const unsigned char* buf);
+extern uint32 GetULong(const unsigned char* buf);
+extern int32 GetLong(const unsigned char* buf);
+extern float GetFloat(const unsigned char* buf);
+
 uint32 date2version(int date);
 
 int levenshtein(const char *s1, const char *s2);

+ 8 - 62
src/tool/mapcache.c

@@ -1,14 +1,6 @@
 // Copyright (c) Athena Dev Teams - Licensed under GNU GPL
 // For more information, see LICENCE in the main folder
 
-#include "../common/cbasetypes.h"
-#include "../common/grfio.h"
-#include "../common/malloc.h"
-#include "../common/mmo.h"
-#include "../common/showmsg.h"
-
-#include "../config/renewal.h"
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -17,6 +9,14 @@
 #include <unistd.h>
 #endif
 
+#include "../common/cbasetypes.h"
+#include "../common/grfio.h"
+#include "../common/malloc.h"
+#include "../common/mmo.h"
+#include "../common/showmsg.h"
+
+#include "../config/renewal.h"
+
 #define NO_WATER 1000000
 
 char grf_list_file[256] = "conf/grf-files.txt";
@@ -50,60 +50,6 @@ struct map_info {
 };
 
 
-/*************************************
-* Big-endian compatibility functions *
-*************************************/
-
-// Converts an int16 from current machine order to little-endian
-int16 MakeShortLE(int16 val)
-{
-	unsigned char buf[2];
-	buf[0] = (unsigned char)( (val & 0x00FF)         );
-	buf[1] = (unsigned char)( (val & 0xFF00) >> 0x08 );
-	return *((int16*)buf);
-}
-
-// Converts an int32 from current machine order to little-endian
-int32 MakeLongLE(int32 val)
-{
-	unsigned char buf[4];
-	buf[0] = (unsigned char)( (val & 0x000000FF)         );
-	buf[1] = (unsigned char)( (val & 0x0000FF00) >> 0x08 );
-	buf[2] = (unsigned char)( (val & 0x00FF0000) >> 0x10 );
-	buf[3] = (unsigned char)( (val & 0xFF000000) >> 0x18 );
-	return *((int32*)buf);
-}
-
-// Reads an uint16 in little-endian from the buffer
-uint16 GetUShort(const unsigned char* buf)
-{
-	return	 ( ((uint16)(buf[0]))         )
-			|( ((uint16)(buf[1])) << 0x08 );
-}
-
-// Reads an uint32 in little-endian from the buffer
-uint32 GetULong(const unsigned char* buf)
-{
-	return	 ( ((uint32)(buf[0]))         )
-			|( ((uint32)(buf[1])) << 0x08 )
-			|( ((uint32)(buf[2])) << 0x10 )
-			|( ((uint32)(buf[3])) << 0x18 );
-}
-
-// Reads an int32 in little-endian from the buffer
-int32 GetLong(const unsigned char* buf)
-{
-	return (int32)GetULong(buf);
-}
-
-// Reads a float (32 bits) from the buffer
-float GetFloat(const unsigned char* buf)
-{
-	uint32 val = GetULong(buf);
-	return *((float*)(void*)&val);
-}
-
-
 // Reads a map from GRF's GAT and RSW files
 int read_map(char *name, struct map_data *m)
 {

Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff