2015-01-23 05:02:13 -05:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2016-03-18 17:13:23 -04:00
|
|
|
/* C++Builder defines a "random" macro */
|
2016-03-18 12:56:37 -04:00
|
|
|
#undef random
|
|
|
|
|
2016-04-29 14:34:24 -04:00
|
|
|
#ifdef __native_client__
|
|
|
|
# define memset(dst, c, n) xmemset(dst, c, n)
|
2016-04-29 14:36:06 -04:00
|
|
|
|
2016-04-29 14:34:24 -04:00
|
|
|
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
|
|
|
|
|
2015-01-23 05:02:13 -05:00
|
|
|
#ifdef __EMSCRIPTEN__
|
|
|
|
# define strcmp(s1, s2) xstrcmp(s1, s2)
|
|
|
|
|
2016-04-29 14:34:24 -04:00
|
|
|
static int
|
2015-01-23 05:02:13 -05:00
|
|
|
strcmp(const char *s1, const char *s2) {
|
2016-04-29 14:34:24 -04:00
|
|
|
while (*s1 == *s2++) {
|
|
|
|
if (*s1++ == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2015-01-23 05:02:13 -05:00
|
|
|
return *(unsigned char *) s1 - *(unsigned char *) --s2;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
static void
|
|
|
|
srandom(unsigned seed)
|
|
|
|
{
|
|
|
|
srand(seed);
|
|
|
|
}
|
|
|
|
|
|
|
|
static long
|
|
|
|
random(void)
|
|
|
|
{
|
|
|
|
return (long) rand();
|
|
|
|
}
|
|
|
|
#endif
|