summaryrefslogtreecommitdiff
path: root/helpers.c
diff options
context:
space:
mode:
authorstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2015-01-27 18:07:50 +0000
committerstefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2015-01-27 18:07:50 +0000
commit9f9b0b6db7f3ad9f159c3c0061591d0133cf3824 (patch)
tree8a458f2a546da385a13b3662586000286e3aa02d /helpers.c
parentad215f66742e19bfaf3f681cd93c1d8a17f3f916 (diff)
downloadflashrom-9f9b0b6db7f3ad9f159c3c0061591d0133cf3824.tar.gz
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. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1878 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'helpers.c')
-rw-r--r--helpers.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/helpers.c b/helpers.c
index 5685d29..7a146c3 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