1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 22:21:16 +02:00

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 <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
This commit is contained in:
Stefan Tauner
2015-01-27 18:07:50 +00:00
parent 0cbd8c2558
commit dc62793184
3 changed files with 20 additions and 10 deletions

View File

@ -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