Leaked source code of windows server 2003
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.

89 lines
2.4 KiB

  1. /***
  2. *memset.c - set a section of memory to all one byte
  3. *
  4. * Copyright (c) 1988-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * contains the memset() routine
  8. *
  9. *Revision History:
  10. * 05-31-89 JCR C version created.
  11. * 02-27-90 GJF Fixed calling type, #include <cruntime.h>, fixed
  12. * copyright.
  13. * 08-14-90 SBM Compiles cleanly with -W3
  14. * 10-01-90 GJF New-style function declarator. Also, rewrote expr. to
  15. * avoid using cast as an lvalue.
  16. * 04-01-91 SRW Add #pragma function for i386 _WIN32_ and _CRUISER_
  17. * builds
  18. * 07-16-93 SRW ALPHA Merge
  19. * 09-01-93 GJF Merged NT SDK and Cuda versions.
  20. * 11-12-93 GJF Replace _MIPS_ and _ALPHA_ with _M_MRX000 and
  21. * _M_ALPHA (resp.).
  22. * 11-17-93 CFW Fix RtlFillMemory prototype typo.
  23. * 12-03-93 GJF Turn on #pragma function for all MS front-ends (esp.,
  24. * Alpha compiler).
  25. * 10-02-94 BWT Add PPC support.
  26. * 10-07-97 RDL Added IA64.
  27. * 07-15-01 PML Remove all ALPHA, MIPS, and PPC code
  28. *
  29. *******************************************************************************/
  30. #include <cruntime.h>
  31. #include <string.h>
  32. #ifdef _MSC_VER
  33. #pragma function(memset)
  34. #endif
  35. /***
  36. *char *memset(dst, val, count) - sets "count" bytes at "dst" to "val"
  37. *
  38. *Purpose:
  39. * Sets the first "count" bytes of the memory starting
  40. * at "dst" to the character value "val".
  41. *
  42. *Entry:
  43. * void *dst - pointer to memory to fill with val
  44. * int val - value to put in dst bytes
  45. * size_t count - number of bytes of dst to fill
  46. *
  47. *Exit:
  48. * returns dst, with filled bytes
  49. *
  50. *Exceptions:
  51. *
  52. *******************************************************************************/
  53. void * __cdecl memset (
  54. void *dst,
  55. int val,
  56. size_t count
  57. )
  58. {
  59. void *start = dst;
  60. #if defined(_M_IA64) || defined(_M_AMD64)
  61. {
  62. #if !defined(LIBCNTPR)
  63. __declspec(dllimport)
  64. #endif
  65. void RtlFillMemory( void *, size_t count, char );
  66. RtlFillMemory( dst, count, (char)val );
  67. }
  68. #else
  69. while (count--) {
  70. *(char *)dst = (char)val;
  71. dst = (char *)dst + 1;
  72. }
  73. #endif
  74. return(start);
  75. }