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.

88 lines
2.3 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. *
  28. *******************************************************************************/
  29. #include <cruntime.h>
  30. #include <string.h>
  31. #ifdef _MSC_VER
  32. #pragma function(memset)
  33. #endif
  34. /***
  35. *char *memset(dst, val, count) - sets "count" bytes at "dst" to "val"
  36. *
  37. *Purpose:
  38. * Sets the first "count" bytes of the memory starting
  39. * at "dst" to the character value "val".
  40. *
  41. *Entry:
  42. * void *dst - pointer to memory to fill with val
  43. * int val - value to put in dst bytes
  44. * size_t count - number of bytes of dst to fill
  45. *
  46. *Exit:
  47. * returns dst, with filled bytes
  48. *
  49. *Exceptions:
  50. *
  51. *******************************************************************************/
  52. void * __cdecl memset (
  53. void *dst,
  54. int val,
  55. size_t count
  56. )
  57. {
  58. void *start = dst;
  59. #if defined(_M_IA64) || defined(_M_AMD64)
  60. {
  61. #if !defined(LIBCNTPR)
  62. __declspec(dllimport)
  63. #endif
  64. void RtlFillMemory( void *, size_t count, char );
  65. RtlFillMemory( dst, count, (char)val );
  66. }
  67. #else
  68. while (count--) {
  69. *(char *)dst = (char)val;
  70. dst = (char *)dst + 1;
  71. }
  72. #endif
  73. return(start);
  74. }