memset.c 704 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (C) 2002 Manuel Novoa III
  3. * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org>
  4. *
  5. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  6. */
  7. #include "_string.h"
  8. #ifdef WANT_WIDE
  9. # define Wmemset wmemset
  10. #else
  11. /* Experimentally off - libc_hidden_proto(memset) */
  12. # define Wmemset memset
  13. #endif
  14. Wvoid *Wmemset(Wvoid *s, Wint c, size_t n)
  15. {
  16. register Wuchar *p = (Wuchar *) s;
  17. #ifdef __BCC__
  18. /* bcc can optimize the counter if it thinks it is a pointer... */
  19. register const char *np = (const char *) n;
  20. #else
  21. # define np n
  22. #endif
  23. while (np) {
  24. *p++ = (Wuchar) c;
  25. --np;
  26. }
  27. return s;
  28. }
  29. #undef np
  30. #ifndef WANT_WIDE
  31. libc_hidden_def(memset)
  32. #endif