diff options
author | Ian Lance Taylor <iant@google.com> | 2012-10-04 15:16:09 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2012-10-04 15:16:09 +0000 |
commit | 244e2d9cd325af32ef126c0d59e8e75650f5654a (patch) | |
tree | 09b2bafa02f9c5af3d13f2fff0501186da346651 /libbacktrace | |
parent | 678771ad9cf341b31f3a7717eefb868cac2221ec (diff) | |
download | gcc-244e2d9cd325af32ef126c0d59e8e75650f5654a.tar.gz |
dwarf.c: If the system header files do not declare strnlen, provide our own version.
* dwarf.c: If the system header files do not declare strnlen,
provide our own version.
From-SVN: r192082
Diffstat (limited to 'libbacktrace')
-rw-r--r-- | libbacktrace/ChangeLog | 5 | ||||
-rw-r--r-- | libbacktrace/dwarf.c | 18 |
2 files changed, 21 insertions, 2 deletions
diff --git a/libbacktrace/ChangeLog b/libbacktrace/ChangeLog index 88a7eb0ba8e..528b4930204 100644 --- a/libbacktrace/ChangeLog +++ b/libbacktrace/ChangeLog @@ -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. diff --git a/libbacktrace/dwarf.c b/libbacktrace/dwarf.c index 25973cb7621..4e13fc541ee 100644 --- a/libbacktrace/dwarf.c +++ b/libbacktrace/dwarf.c @@ -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. */ |