Update.
[glibc.git] / sysdeps / m68k / memcopy.h
blob862e1b8a7f97243327d66783d03cd54e797fd9ee
1 /* memcopy.h -- definitions for memory copy functions. Motorola 68020 version.
2 Copyright (C) 1991 Free Software Foundation, Inc.
3 Contributed by Torbjorn Granlund (tege@sics.se).
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
15 You should have received a copy of the GNU Library General Public
16 License along with the GNU C Library; see the file COPYING.LIB. If
17 not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18 Cambridge, MA 02139, USA. */
20 #include <sysdeps/generic/memcopy.h>
22 #if defined(__mc68020__) || defined(mc68020)
24 #undef OP_T_THRES
25 #define OP_T_THRES 16
27 /* WORD_COPY_FWD and WORD_COPY_BWD are not symmetric on the 68020,
28 because of its weird instruction overlap characteristics. */
30 #undef WORD_COPY_FWD
31 #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
32 do \
33 { \
34 size_t __nwords = (nbytes) / sizeof (op_t); \
35 size_t __nblocks = __nwords / 8 + 1; \
36 dst_bp -= (8 - __nwords % 8) * sizeof (op_t); \
37 src_bp -= (8 - __nwords % 8) * sizeof (op_t); \
38 switch (__nwords % 8) \
39 do \
40 { \
41 ((op_t *) dst_bp)[0] = ((op_t *) src_bp)[0]; \
42 case 7: \
43 ((op_t *) dst_bp)[1] = ((op_t *) src_bp)[1]; \
44 case 6: \
45 ((op_t *) dst_bp)[2] = ((op_t *) src_bp)[2]; \
46 case 5: \
47 ((op_t *) dst_bp)[3] = ((op_t *) src_bp)[3]; \
48 case 4: \
49 ((op_t *) dst_bp)[4] = ((op_t *) src_bp)[4]; \
50 case 3: \
51 ((op_t *) dst_bp)[5] = ((op_t *) src_bp)[5]; \
52 case 2: \
53 ((op_t *) dst_bp)[6] = ((op_t *) src_bp)[6]; \
54 case 1: \
55 ((op_t *) dst_bp)[7] = ((op_t *) src_bp)[7]; \
56 case 0: \
57 src_bp += 32; \
58 dst_bp += 32; \
59 __nblocks--; \
60 } \
61 while (__nblocks != 0); \
62 (nbytes_left) = (nbytes) % sizeof (op_t); \
63 } while (0)
65 #undef WORD_COPY_BWD
66 #define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
67 do \
68 { \
69 size_t __nblocks = (nbytes) / 32 + 1; \
70 switch ((nbytes) / sizeof (op_t) % 8) \
71 do \
72 { \
73 *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
74 case 7: \
75 *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
76 case 6: \
77 *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
78 case 5: \
79 *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
80 case 4: \
81 *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
82 case 3: \
83 *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
84 case 2: \
85 *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
86 case 1: \
87 *--((op_t *) dst_ep) = *--((op_t *) src_ep); \
88 case 0: \
89 __nblocks--; \
90 } \
91 while (__nblocks != 0); \
92 (nbytes_left) = (nbytes) % sizeof (op_t); \
93 } while (0)
95 #endif