OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [arch/] [m68k/] [lib/] [memcpy.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
#include <linux/types.h>
2
 
3
void * memcpy(void * to, const void * from, size_t n)
4
{
5
  void *xto = to;
6
  size_t temp, temp1;
7
 
8
  if (!n)
9
    return xto;
10
  if ((long) to & 1)
11
    {
12
      char *cto = to;
13
      const char *cfrom = from;
14
      *cto++ = *cfrom++;
15
      to = cto;
16
      from = cfrom;
17
      n--;
18
    }
19
  if (n > 2 && (long) to & 2)
20
    {
21
      short *sto = to;
22
      const short *sfrom = from;
23
      *sto++ = *sfrom++;
24
      to = sto;
25
      from = sfrom;
26
      n -= 2;
27
    }
28
  temp = n >> 2;
29
  if (temp)
30
    {
31
      long *lto = to;
32
      const long *lfrom = from;
33
 
34
      __asm__ __volatile__("movel %2,%3\n\t"
35
                           "andw  #7,%3\n\t"
36
                           "lsrl  #3,%2\n\t"
37
                           "negw  %3\n\t"
38
                           "jmp   %%pc@(1f,%3:w:2)\n\t"
39
                           "4:\t"
40
                           "movel %0@+,%1@+\n\t"
41
                           "movel %0@+,%1@+\n\t"
42
                           "movel %0@+,%1@+\n\t"
43
                           "movel %0@+,%1@+\n\t"
44
                           "movel %0@+,%1@+\n\t"
45
                           "movel %0@+,%1@+\n\t"
46
                           "movel %0@+,%1@+\n\t"
47
                           "movel %0@+,%1@+\n\t"
48
                           "1:\t"
49
                           "dbra  %2,4b\n\t"
50
                           "clrw  %2\n\t"
51
                           "subql #1,%2\n\t"
52
                           "jpl   4b\n\t"
53
                           : "=a" (lfrom), "=a" (lto), "=d" (temp),
54
                           "=&d" (temp1)
55
                           : "0" (lfrom), "1" (lto), "2" (temp)
56
                           );
57
      to = lto;
58
      from = lfrom;
59
    }
60
  if (n & 2)
61
    {
62
      short *sto = to;
63
      const short *sfrom = from;
64
      *sto++ = *sfrom++;
65
      to = sto;
66
      from = sfrom;
67
    }
68
  if (n & 1)
69
    {
70
      char *cto = to;
71
      const char *cfrom = from;
72
      *cto = *cfrom;
73
    }
74
  return xto;
75
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.