quirks.h 828 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <stdlib.h>
  2. /* C++Builder defines a "random" macro */
  3. #undef random
  4. #ifdef __native_client__
  5. # define memset(dst, c, n) xmemset(dst, c, n)
  6. static void *
  7. xmemset(void *dst, int c, size_t n)
  8. {
  9. unsigned char * dst_ = (unsigned char *) dst;
  10. const unsigned char c_ = (unsigned char) c;
  11. size_t i;
  12. for (i = 0; i < n; i++) {
  13. dst_[i] = c_;
  14. }
  15. return dst;
  16. }
  17. #endif
  18. #ifdef __EMSCRIPTEN__
  19. # define strcmp(s1, s2) xstrcmp(s1, s2)
  20. static int
  21. strcmp(const char *s1, const char *s2)
  22. {
  23. while (*s1 == *s2++) {
  24. if (*s1++ == 0) {
  25. return 0;
  26. }
  27. }
  28. return *(unsigned char *) s1 - *(unsigned char *) --s2;
  29. }
  30. #endif
  31. #ifdef _WIN32
  32. static void
  33. srandom(unsigned seed)
  34. {
  35. srand(seed);
  36. }
  37. static long
  38. random(void)
  39. {
  40. return (long) rand();
  41. }
  42. #endif