Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.3 KiB

  1. /* Copyright (c) 1998 Microsoft Corporation */
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #ifdef _DEBUG
  5. void __cdecl _assert ( void *expr, void *filename, unsigned lineno )
  6. {
  7. DebugBreak();
  8. }
  9. #endif
  10. #ifdef _DEBUG
  11. #if 0 // These are intrinsics and cause an error in the NT build
  12. int __cdecl memcmp (
  13. const void * buf1,
  14. const void * buf2,
  15. size_t count
  16. )
  17. {
  18. if (!count)
  19. return(0);
  20. while ( --count && *(char *)buf1 == *(char *)buf2 ) {
  21. buf1 = (char *)buf1 + 1;
  22. buf2 = (char *)buf2 + 1;
  23. }
  24. return( *((unsigned char *)buf1) - *((unsigned char *)buf2) );
  25. }
  26. void * __cdecl memcpy (
  27. void * dst,
  28. const void * src,
  29. size_t count
  30. )
  31. {
  32. void * ret = dst;
  33. #if defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC)
  34. {
  35. extern void RtlMoveMemory( void *, const void *, size_t count );
  36. RtlMoveMemory( dst, src, count );
  37. }
  38. #else /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
  39. /*
  40. * copy from lower addresses to higher addresses
  41. */
  42. while (count--) {
  43. *(char *)dst = *(char *)src;
  44. dst = (char *)dst + 1;
  45. src = (char *)src + 1;
  46. }
  47. #endif /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
  48. return(ret);
  49. }
  50. void * __cdecl memset (
  51. void *dst,
  52. int val,
  53. size_t count
  54. )
  55. {
  56. void *start = dst;
  57. #if defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC)
  58. {
  59. extern void RtlFillMemory( void *, size_t count, char );
  60. RtlFillMemory( dst, count, (char)val );
  61. }
  62. #else /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
  63. while (count--) {
  64. *(char *)dst = (char)val;
  65. dst = (char *)dst + 1;
  66. }
  67. #endif /* defined (_M_MRX000) || defined (_M_ALPHA) || defined (_M_PPC) */
  68. return(start);
  69. }
  70. #endif
  71. #endif
  72. void __cdecl _purecall(
  73. void
  74. )
  75. {
  76. }
  77. static long holdrand = 1L;
  78. void __cdecl srand (
  79. unsigned int seed
  80. )
  81. {
  82. holdrand = (long)seed;
  83. }
  84. int __cdecl rand (
  85. void
  86. )
  87. {
  88. return(((holdrand = holdrand * 214013L + 2531011L) >> 16) & 0x7fff);
  89. }