소스 검색

* Updated configure/make scripts to resolve various issues.
- Added detection whether or not -fPIC switch is required when compiling shared objects (plug-ins) to resolve compile issues on 64-bit platforms (topic:208746).
- Native 'strnlen' implementations are now detected and disable the one in strlib (bugreport:1261).
- Define 'DB_MANUAL_CAST_TO_UNION' is now set when necessary (bugreport:1261).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14708 54d463be-8e91-2dee-dedb-b68131a5f0ec

ai4rei 14 년 전
부모
커밋
ba8bd70b0c
6개의 변경된 파일469개의 추가작업 그리고 9개의 파일을 삭제
  1. 5 0
      Changelog-Trunk.txt
  2. 15 3
      Makefile.in
  3. 336 3
      configure
  4. 107 0
      configure.in
  5. 1 2
      src/common/strlib.c
  6. 5 1
      src/common/strlib.h

+ 5 - 0
Changelog-Trunk.txt

@@ -1,5 +1,10 @@
 Date	Added
 
+2011/02/16
+	* Updated configure/make scripts to resolve various issues. [Ai4rei]
+	- Added detection whether or not -fPIC switch is required when compiling shared objects (plug-ins) to resolve compile issues on 64-bit platforms (topic:208746).
+	- Native 'strnlen' implementations are now detected and disable the one in strlib (bugreport:1261).
+	- Define 'DB_MANUAL_CAST_TO_UNION' is now set when necessary (bugreport:1261).
 2011/02/15
 	* Added support for client GM command /check (related r12076). [Ai4rei]
 2011/02/14

+ 15 - 3
Makefile.in

@@ -2,7 +2,7 @@
 
 HAVE_MYSQL=@HAVE_MYSQL@
 ifeq ($(HAVE_MYSQL),yes)
-	ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql tools converters plugins import save
+	ALL_DEPENDS=common common_sql login login_sql char char_sql map map_sql tools converters import save
 	SQL_DEPENDS=common_sql login_sql char_sql map_sql import save
 	COMMON_SQL_DEPENDS=
 	LOGIN_SQL_DEPENDS=common_sql
@@ -10,7 +10,7 @@ ifeq ($(HAVE_MYSQL),yes)
 	MAP_SQL_DEPENDS=common_sql
 	CONVERTERS_DEPENDS=common_sql
 else
-	ALL_DEPENDS=common login char map tools plugins import save
+	ALL_DEPENDS=common login char map tools import save
 	SQL_DEPENDS=needs_mysql
 	COMMON_SQL_DEPENDS=needs_mysql
 	LOGIN_SQL_DEPENDS=needs_mysql
@@ -19,6 +19,14 @@ else
 	CONVERTERS_DEPENDS=needs_mysql
 endif
 
+WITH_PLUGINS=@WITH_PLUGINS@
+ifeq ($(WITH_PLUGINS),yes)
+	ALL_DEPENDS+=plugins
+	PLUGIN_DEPENDS=common
+else
+	PLUGIN_DEPENDS=no_plugins
+endif
+
 #####################################################################
 .PHONY: txt sql conf \
 	common common_sql \
@@ -66,7 +74,7 @@ tools:
 converters: $(CONVERTERS_DEPENDS)
 	@$(MAKE) -C src/txt-converter
 
-plugins addons: common
+plugins addons: $(PLUGIN_DEPENDS)
 	@$(MAKE) -C src/plugins
 
 import:
@@ -129,6 +137,10 @@ needs_mysql:
 	@echo "MySQL not found or disabled by the configure script"
 	@exit 1
 
+no_plugins:
+	@echo "Plugins disabled by the configure script"
+	@exit 1
+
 #####################################################################
 # TODO
 

+ 336 - 3
configure

@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 13486 .
+# From configure.in Revision: 14708 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59.
 #
@@ -311,7 +311,7 @@ ac_includes_default="\
 # include <unistd.h>
 #endif"
 
-ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP EGREP MYSQL_CONFIG_HOME HAVE_MYSQL MYSQL_VERSION MYSQL_CFLAGS MYSQL_LIBS HAVE_PCRE PCRE_LIBS PCRE_CFLAGS DLLEXT LIBOBJS LTLIBOBJS'
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT CPP WITH_PLUGINS EGREP MYSQL_CONFIG_HOME HAVE_MYSQL MYSQL_VERSION MYSQL_CFLAGS MYSQL_LIBS HAVE_PCRE PCRE_LIBS PCRE_CFLAGS DLLEXT LIBOBJS LTLIBOBJS'
 ac_subst_files=''
 
 # Initialize some variables set by options.
@@ -1333,7 +1333,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
                     ac_config_files="$ac_config_files Makefile src/common/Makefile"
 
-                              ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile"
+                    ac_config_files="$ac_config_files src/char/Makefile src/login/Makefile"
 
                     ac_config_files="$ac_config_files src/char_sql/Makefile src/txt-converter/Makefile"
 
@@ -3257,6 +3257,240 @@ fi
 rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
 
 
+echo "$as_me:$LINENO: checking whether $CC supports -fPIC" >&5
+echo $ECHO_N "checking whether $CC supports -fPIC... $ECHO_C" >&6
+OLD_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -fPIC"
+cat >conftest.$ac_ext <<_ACEOF
+int foo;
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&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); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (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); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (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
+
+		echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+		compiler_supports_pic="yes"
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+		compiler_supports_pic="no"
+
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+CFLAGS="$OLD_CFLAGS"
+
+
+#
+# -shared needs position independent code; some platforms emit it
+# always, others need -fPIC
+#
+echo "$as_me:$LINENO: checking whether $CC needs -fPIC for shared objects" >&5
+echo $ECHO_N "checking whether $CC needs -fPIC for shared objects... $ECHO_C" >&6
+OLD_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -shared"
+WITH_PLUGINS="yes"
+cat >conftest.$ac_ext <<_ACEOF
+
+		int foo(void)
+		{
+			return 0;
+		}
+
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 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); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (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); }; } &&
+	 { ac_try='test -s 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
+
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+		CFLAGS="$OLD_CFLAGS"
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+		if test "$compiler_supports_pic" = "yes" ; then
+			# Verify if -shared really fails due to lack of -fPIC or something else
+			CFLAGS="$CFLAGS -fPIC"
+			cat >conftest.$ac_ext <<_ACEOF
+
+					int foo(void)
+					{
+						return 0;
+					}
+
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 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); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (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); }; } &&
+	 { ac_try='test -s 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
+
+					echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+					CFLAGS="$OLD_CFLAGS -fPIC"
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+					echo "$as_me:$LINENO: result: no, but fails for another reason" >&5
+echo "${ECHO_T}no, but fails for another reason" >&6
+					{ { echo "$as_me:$LINENO: error: compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping" >&5
+echo "$as_me: error: compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping" >&2;}
+   { (exit 1); exit 1; }; }
+
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+		else
+			# Disable compilation of plugins (optional), so 'make all' does not fail
+			echo "$as_me:$LINENO: result: yes, but unsupported" >&5
+echo "${ECHO_T}yes, but unsupported" >&6
+			{ echo "$as_me:$LINENO: compiler is unable to generate position independent code, disabled plugins (optional)" >&5
+echo "$as_me: compiler is unable to generate position independent code, disabled plugins (optional)" >&6;}
+			WITH_PLUGINS="no"
+		fi
+
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+
+
+
+#
+# DB_MANUAL_CAST_TO_UNION
+#
+echo "$as_me:$LINENO: checking whether $CC is able to typecast to union" >&5
+echo $ECHO_N "checking whether $CC is able to typecast to union... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+
+		typedef union Foonion
+		{
+			int i;
+			unsigned int ui;
+			const char* s;
+		}
+		Foonion;
+
+		int bar(Foonion onion)
+		{
+			return onion.i;
+		}
+
+		int foo(void)
+		{
+			int i = 0;
+
+			return bar(((Foonion)(int)i));
+		}
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&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); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (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); }; } &&
+	 { ac_try='test -s conftest.$ac_objext'
+  { (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
+
+		echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+
+		echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+		CFLAGS="$CFLAGS -DDB_MANUAL_CAST_TO_UNION"
+
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
 
 ###############################################################################
 # Check for libraries and header files.
@@ -3362,6 +3596,104 @@ fi
 
 
 
+#
+# strnlen - string length with upper scan bound
+#
+echo "$as_me:$LINENO: checking for strnlen" >&5
+echo $ECHO_N "checking for strnlen... $ECHO_C" >&6
+if test "${ac_cv_func_strnlen+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+/* Define strnlen to an innocuous variant, in case <limits.h> declares strnlen.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define strnlen innocuous_strnlen
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char strnlen (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef strnlen
+
+/* Override any gcc2 internal prototype to avoid an error.  */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+   builtin and then its argument prototype would still apply.  */
+char strnlen ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_strnlen) || defined (__stub___strnlen)
+choke me
+#else
+char (*f) () = strnlen;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != strnlen;
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+  (eval $ac_link) 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); } &&
+	 { ac_try='test -z "$ac_c_werror_flag"
+			 || test ! -s conftest.err'
+  { (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); }; } &&
+	 { ac_try='test -s 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_func_strnlen=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_func_strnlen=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+      conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_strnlen" >&5
+echo "${ECHO_T}$ac_cv_func_strnlen" >&6
+if test $ac_cv_func_strnlen = yes; then
+  CFLAGS="$CFLAGS -DHAVE_STRNLEN"
+fi
+
+
 
 #
 # Memory manager
@@ -5725,6 +6057,7 @@ s,@ac_ct_CC@,$ac_ct_CC,;t t
 s,@EXEEXT@,$EXEEXT,;t t
 s,@OBJEXT@,$OBJEXT,;t t
 s,@CPP@,$CPP,;t t
+s,@WITH_PLUGINS@,$WITH_PLUGINS,;t t
 s,@EGREP@,$EGREP,;t t
 s,@MYSQL_CONFIG_HOME@,$MYSQL_CONFIG_HOME,;t t
 s,@HAVE_MYSQL@,$HAVE_MYSQL,;t t

+ 107 - 0
configure.in

@@ -339,6 +339,108 @@ AC_COMPILE_IFELSE(
 )
 
 
+AC_MSG_CHECKING([whether $CC supports -fPIC])
+OLD_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -fPIC"
+AC_COMPILE_IFELSE(
+	[int foo;],
+	[
+		AC_MSG_RESULT([yes])
+		compiler_supports_pic="yes"
+	],
+	[
+		AC_MSG_RESULT([no])
+		compiler_supports_pic="no"
+	]
+)
+CFLAGS="$OLD_CFLAGS"
+
+
+#
+# -shared needs 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 -shared"
+WITH_PLUGINS="yes"
+AC_LINK_IFELSE(
+	[
+		int foo(void)
+		{
+			return 0;
+		}
+	],
+	[
+		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(
+				[
+					int foo(void)
+					{
+						return 0;
+					}
+				],
+				[
+					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
+	]
+)
+AC_SUBST([WITH_PLUGINS])
+
+
+#
+# DB_MANUAL_CAST_TO_UNION
+#
+AC_MSG_CHECKING([whether $CC is able to typecast to union])
+AC_COMPILE_IFELSE(
+	[
+		typedef union Foonion
+		{
+			int i;
+			unsigned int ui;
+			const char* s;
+		}
+		Foonion;
+		
+		int bar(Foonion onion)
+		{
+			return onion.i;
+		}
+		
+		int foo(void)
+		{
+			int i = 0;
+		
+			return bar(((Foonion)(int)i));
+		}
+	],
+	[
+		AC_MSG_RESULT([yes])
+	],
+	[
+		AC_MSG_RESULT([no])
+		CFLAGS="$CFLAGS -DDB_MANUAL_CAST_TO_UNION"
+	]
+)
+
 
 ###############################################################################
 # Check for libraries and header files.
@@ -351,6 +453,11 @@ AC_COMPILE_IFELSE(
 AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"])
 
 
+#
+# strnlen - string length with upper scan bound
+#
+AC_CHECK_FUNC([strnlen],[CFLAGS="$CFLAGS -DHAVE_STRNLEN"])
+
 
 #
 # Memory manager

+ 1 - 2
src/common/strlib.c

@@ -8,7 +8,6 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <errno.h>
 
 
@@ -241,7 +240,7 @@ char* _strtok_r(char *s1, const char *s2, char **lasts)
 }
 #endif
 
-#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(CYGWIN)
+#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN)
 /* Find the length of STRING, but scan at most MAXLEN characters.
    If no '\0' terminator is found in that many characters, return MAXLEN.  */
 size_t strnlen (const char* string, size_t maxlen)

+ 5 - 1
src/common/strlib.h

@@ -9,6 +9,10 @@
 #endif
 #include <stdarg.h>
 
+#define __USE_GNU  // required to enable strnlen on some platforms
+#include <string.h>
+#undef __USE_GNU
+
 char* jstrescape (char* pt);
 char* jstrescapecpy (char* pt, const char* spt);
 int jmemescapecpy (char* pt, const char* spt, int size);
@@ -24,7 +28,7 @@ const char *stristr(const char *haystack, const char *needle);
 char* _strtok_r(char* s1, const char* s2, char** lasts);
 #endif
 
-#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(CYGWIN)
+#if !(defined(WIN32) && defined(_MSC_VER) && _MSC_VER >= 1400) && !defined(HAVE_STRNLEN)
 size_t strnlen (const char* string, size_t maxlen);
 #endif