NativeClient complains about __memset_chk being undefined on OSX.

Work around this. There might be a better fix, but at least the
test suite compiles with the newlib.
This commit is contained in:
Frank Denis 2016-04-29 20:34:24 +02:00
parent 7a667edbd0
commit 251b836f01

View File

@ -4,12 +4,32 @@
/* C++Builder defines a "random" macro */
#undef random
#ifdef __native_client__
# define memset(dst, c, n) xmemset(dst, c, n)
static void *
xmemset(void *dst, int c, size_t n)
{
unsigned char *dst_ = (unsigned char *) dst;
const unsigned char c_ = (unsigned char) c;
size_t i;
for (i = 0; i < n; i++) {
dst_[i] = c_;
}
return dst;
}
#endif
#ifdef __EMSCRIPTEN__
# define strcmp(s1, s2) xstrcmp(s1, s2)
int
static int
strcmp(const char *s1, const char *s2) {
while (*s1 == *s2++) { if (*s1++ == 0) return 0; }
while (*s1 == *s2++) {
if (*s1++ == 0) {
return 0;
}
}
return *(unsigned char *) s1 - *(unsigned char *) --s2;
}
#endif