zos: add strnlen() implementation

Add an implementation of strnlen() which is not provided by default.

PR-URL: https://github.com/libuv/libuv/pull/1631
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
John Barboza 2017-11-16 20:20:39 -05:00 committed by Ben Noordhuis
parent 0b18f57be5
commit 88d716e126
2 changed files with 10 additions and 0 deletions

View File

@ -427,3 +427,12 @@ ssize_t os390_readlink(const char* path, char* buf, size_t len) {
return rlen;
}
size_t strnlen(const char* str, size_t maxlen) {
void* p = memchr(str, 0, maxlen);
if (p == NULL)
return maxlen;
else
return p - str;
}

View File

@ -66,5 +66,6 @@ int scandir(const char* maindir, struct dirent*** namelist,
const struct dirent **));
char *mkdtemp(char* path);
ssize_t os390_readlink(const char* path, char* buf, size_t len);
size_t strnlen(const char* str, size_t maxlen);
#endif /* UV_OS390_SYSCALL_H_ */