From dc627931848ed6af40be4f7d5bdb8e33d28b8333 Mon Sep 17 00:00:00 2001 From: Stefan Tauner Date: Tue, 27 Jan 2015 18:07:50 +0000 Subject: Make strnlen() visible in old versions of glibc Strnlen() is in POSIX 2008 but was a GNU extension up to glibc 2.10 requiring to define _GNU_SOURCE. This fixes compilation on CentOS 4.9. Also, move our implementation of strnlen() that was added to support DJGPP to helpers.c. Corresponding to flashrom svn r1878. Signed-off-by: Stefan Tauner Acked-by: Carl-Daniel Hailfinger --- helpers.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'helpers.c') diff --git a/helpers.c b/helpers.c index 5685d299..7a146c37 100644 --- a/helpers.c +++ b/helpers.c @@ -91,3 +91,13 @@ char* strtok_r(char *str, const char *delim, char **nextp) } #endif +/* There is no strnlen in DJGPP */ +#if defined(__DJGPP__) +size_t strnlen(const char *str, size_t n) +{ + size_t i; + for (i = 0; i < n && str[i] != '\0'; i++) + ; + return i; +} +#endif -- cgit v1.2.1