Back to index

glibc  2.9
memcopy.h
Go to the documentation of this file.
00001 /* memcopy.h -- definitions for memory copy functions.  Motorola 68020 version.
00002    Copyright (C) 1991, 1997, 2004 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Torbjorn Granlund (tege@sics.se).
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <sysdeps/generic/memcopy.h>
00022 
00023 #if    defined(__mc68020__) || defined(mc68020)
00024 
00025 #undef OP_T_THRES
00026 #define       OP_T_THRES    16
00027 
00028 /* WORD_COPY_FWD and WORD_COPY_BWD are not symmetric on the 68020,
00029    because of its weird instruction overlap characteristics.  */
00030 
00031 #undef WORD_COPY_FWD
00032 #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes)                  \
00033   do                                                                 \
00034     {                                                                \
00035       size_t __nwords = (nbytes) / sizeof (op_t);                           \
00036       size_t __nblocks = __nwords / 8 + 1;                                  \
00037       dst_bp -= (8 - __nwords % 8) * sizeof (op_t);                         \
00038       src_bp -= (8 - __nwords % 8) * sizeof (op_t);                         \
00039       switch (__nwords % 8)                                          \
00040        do                                                            \
00041          {                                                           \
00042            ((op_t *) dst_bp)[0] = ((op_t *) src_bp)[0];              \
00043          case 7:                                                     \
00044            ((op_t *) dst_bp)[1] = ((op_t *) src_bp)[1];              \
00045          case 6:                                                     \
00046            ((op_t *) dst_bp)[2] = ((op_t *) src_bp)[2];              \
00047          case 5:                                                     \
00048            ((op_t *) dst_bp)[3] = ((op_t *) src_bp)[3];              \
00049          case 4:                                                     \
00050            ((op_t *) dst_bp)[4] = ((op_t *) src_bp)[4];              \
00051          case 3:                                                     \
00052            ((op_t *) dst_bp)[5] = ((op_t *) src_bp)[5];              \
00053          case 2:                                                     \
00054            ((op_t *) dst_bp)[6] = ((op_t *) src_bp)[6];              \
00055          case 1:                                                     \
00056            ((op_t *) dst_bp)[7] = ((op_t *) src_bp)[7];              \
00057          case 0:                                                     \
00058            src_bp += 32;                                             \
00059            dst_bp += 32;                                             \
00060            __nblocks--;                                              \
00061          }                                                           \
00062       while (__nblocks != 0);                                               \
00063       (nbytes_left) = (nbytes) % sizeof (op_t);                             \
00064     } while (0)
00065 
00066 #undef WORD_COPY_BWD
00067 #define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes)                  \
00068   do                                                                 \
00069     {                                                                \
00070       size_t __nblocks = (nbytes) / 32 + 1;                                 \
00071       op_t *__dst_ep = (op_t *) (dst_ep);                            \
00072       op_t *__src_ep = (op_t *) (src_ep);                            \
00073       switch ((nbytes) / sizeof (op_t) % 8)                                 \
00074        do                                                            \
00075          {                                                           \
00076            *--__dst_ep = *--__src_ep;                                       \
00077          case 7:                                                     \
00078            *--__dst_ep = *--__src_ep;                                       \
00079          case 6:                                                     \
00080            *--__dst_ep = *--__src_ep;                                       \
00081          case 5:                                                     \
00082            *--__dst_ep = *--__src_ep;                                       \
00083          case 4:                                                     \
00084            *--__dst_ep = *--__src_ep;                                       \
00085          case 3:                                                     \
00086            *--__dst_ep = *--__src_ep;                                       \
00087          case 2:                                                     \
00088            *--__dst_ep = *--__src_ep;                                       \
00089          case 1:                                                     \
00090            *--__dst_ep = *--__src_ep;                                       \
00091          case 0:                                                     \
00092            __nblocks--;                                              \
00093          }                                                           \
00094       while (__nblocks != 0);                                               \
00095       (nbytes_left) = (nbytes) % sizeof (op_t);                             \
00096       (dst_ep) = (unsigned long) __dst_ep;                                  \
00097       (src_ep) = (unsigned long) __src_ep;                                  \
00098     } while (0)
00099 
00100 #endif