diff mbox

libbacktrace patch committed: Declare strnlen if not declared

Message ID mcr7grrpb69.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor Sept. 18, 2012, 4:07 p.m. UTC
This patch to libbacktrace declares strnlen if it is not declared in a
standard header file.  If necessary, the actual definition will come
from libiberty.  Bootstrapped on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian


2012-09-18  Ian Lance Taylor  <iant@google.com>

	* configure.ac: Check whether strnlen is declared.
	* dwarf.c: Declare strnlen if not declared.
diff mbox

Patch

Index: dwarf.c
===================================================================
--- dwarf.c	(revision 191432)
+++ dwarf.c	(working copy)
@@ -44,6 +44,11 @@  POSSIBILITY OF SUCH DAMAGE.  */
 #include "backtrace.h"
 #include "internal.h"
 
+#ifndef HAVE_DECL_STRNLEN
+/* The function is defined in libiberty if needed.  */
+extern size_t strnlen (const char *, size_t);
+#endif
+
 /* A buffer to read DWARF info.  */
 
 struct dwarf_buf
Index: configure.ac
===================================================================
--- configure.ac	(revision 191432)
+++ configure.ac	(working copy)
@@ -199,6 +199,8 @@  if test "$ALLOC_FILE" = "alloc.lo"; then
 fi
 AC_SUBST(BACKTRACE_USES_MALLOC)
 
+AC_CHECK_DECLS(strnlen)
+
 AC_CACHE_CHECK([whether tests can run],
   [libbacktrace_cv_sys_native],
   [AC_RUN_IFELSE([AC_LANG_PROGRAM([], [return 0;])],