902aa402b3830b9c9aa26758390b6eb93b42a0f5
Stefan Schuermans added file headers

Stefan Schuermans authored 12 years ago

1) /* MIPS I system
Stefan Schuermans replace email address in he...

Stefan Schuermans authored 12 years ago

2)  * Copyright 2011-2012 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans added file headers

Stefan Schuermans authored 12 years ago

3)  * Copyleft GNU public license V2 or later
4)  *          http://www.gnu.org/copyleft/gpl.html
5)  */
6) 
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

7) #include "memcpy.h"
8) 
9) /**
10)  * @brief copy memory
11)  * @param[in] dest pointer to destination buffer
12)  * @param[in] src pointer to source data
13)  * @param[in] sz size of data to copy
14)  */
15) void memcpy(void *dest, const void *src, unsigned int sz)
16) {
17)   unsigned int *dest4;
18)   const unsigned int *src4;
19)   unsigned int sz4;
20)   unsigned char *dest1;
21)   const unsigned char *src1;
22) 
23)   // word aligned memory addresses -> fast copy
24)   if (((unsigned int)dest & 3) == 0 && ((unsigned int)src & 3) == 0) {
25)     dest4 = dest;
26)     src4 = src;
Stefan Schuermans fixed memcpy (it coppied to...

Stefan Schuermans authored 12 years ago

27)     sz4 = sz >> 2;
28)     for ( ; sz4 > 0; --sz4)
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

29)       *dest4++ = *src4++;
Stefan Schuermans fixed memcpy (it coppied to...

Stefan Schuermans authored 12 years ago

30)     // there might still be a few bytes to copy now
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

31)     dest = dest4;
32)     src = src4;
Stefan Schuermans fixed memcpy (it coppied to...

Stefan Schuermans authored 12 years ago

33)     sz &= 3;
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

34)   }
35) 
36)   // safe and slow fallback: copy byte-wise
37)   dest1 = dest;
38)   src1 = src;
39)   for ( ; sz > 0; --sz)
40)     *dest1++ = *src1++;
41) }
42)