diff options
author | Freya Murphy <freya@freyacat.org> | 2025-04-03 12:30:34 -0400 |
---|---|---|
committer | Freya Murphy <freya@freyacat.org> | 2025-04-03 12:30:34 -0400 |
commit | ec3c37d1d40d7b288584c234f4c3e7a600f2353d (patch) | |
tree | bb587b33c4c793ff7a3317dfa958d69b0fa318a1 /lib/memcpy.c | |
parent | move boot only headers to boot (diff) | |
download | comus-ec3c37d1d40d7b288584c234f4c3e7a600f2353d.tar.gz comus-ec3c37d1d40d7b288584c234f4c3e7a600f2353d.tar.bz2 comus-ec3c37d1d40d7b288584c234f4c3e7a600f2353d.zip |
new libs
Diffstat (limited to 'lib/memcpy.c')
-rw-r--r-- | lib/memcpy.c | 46 |
1 files changed, 7 insertions, 39 deletions
diff --git a/lib/memcpy.c b/lib/memcpy.c index 020cc68..ec56537 100644 --- a/lib/memcpy.c +++ b/lib/memcpy.c @@ -1,42 +1,10 @@ -/** -** @file memcpy.c -** -** @author Numerous CSCI-452 classes -** -** @brief C implementations of common library functions -*/ +#include <string.h> -#ifndef MEMCPY_SRC_INC -#define MEMCPY_SRC_INC - -#include <common.h> - -#include <lib.h> - -/** -** memcpy(dst,src,len) -** -** Copy a block from one place to another -** -** May not correctly deal with overlapping buffers -** -** @param dst Destination buffer -** @param src Source buffer -** @param len Buffer size (in bytes) -*/ -void memcpy(void *dst, register const void *src, register uint32_t len) +void *memcpy(void *restrict dest, const void *restrict src, size_t n) { - register uint8_t *dest = dst; - register const uint8_t *source = src; - - /* - ** We could speed this up by unrolling it and copying - ** words at a time (instead of bytes). - */ - - while (len--) { - *dest++ = *source++; - } + char *d = dest; + const char *s = src; + for (; n; n--) + *d++ = *s++; + return dest; } - -#endif |