]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
dwarf.c: If the system header files do not declare strnlen, provide our own version.
authorIan Lance Taylor <iant@google.com>
Thu, 4 Oct 2012 15:16:09 +0000 (15:16 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Thu, 4 Oct 2012 15:16:09 +0000 (15:16 +0000)
* dwarf.c: If the system header files do not declare strnlen,
provide our own version.

From-SVN: r192082

libbacktrace/ChangeLog
libbacktrace/dwarf.c

index 88a7eb0ba8e131322f2e398e320532ef6005b9a0..528b493020496d704e28944deed2f7494d9d3aea 100644 (file)
@@ -1,3 +1,8 @@
+2012-10-04  Ian Lance Taylor  <iant@google.com>
+
+       * dwarf.c: If the system header files do not declare strnlen,
+       provide our own version.
+
 2012-10-03  Ian Lance Taylor  <iant@google.com>
 
        * dwarf.c (read_uleb128): Fix overflow test.
index 25973cb76218b23720bd601f29678fdc6d01a80f..4e13fc541ee96231aff426fbe01c30635d20c8c0 100644 (file)
@@ -44,8 +44,22 @@ POSSIBILITY OF SUCH DAMAGE.  */
 #include "internal.h"
 
 #if !defined(HAVE_DECL_STRNLEN) || !HAVE_DECL_STRNLEN
-/* The function is defined in libiberty if needed.  */
-extern size_t strnlen (const char *, size_t);
+
+/* If strnlen is not declared, provide our own version.  */
+
+static size_t
+xstrnlen (const char *s, size_t maxlen)
+{
+  size_t i;
+
+  for (i = 0; i < maxlen; ++i)
+    if (s[i] == '\0')
+      break;
+  return i;
+}
+
+#define strnlen xstrnlen
+
 #endif
 
 /* A buffer to read DWARF info.  */