Back to index

glibc  2.9
memcopy.h
Go to the documentation of this file.
00001 /* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #include <sysdeps/generic/memcopy.h>
00020 
00021 #undef OP_T_THRES
00022 #define OP_T_THRES 32
00023 
00024 #undef BYTE_COPY_FWD
00025 #define BYTE_COPY_FWD(dst_bp, src_bp, nbytes)                               \
00026   do                                                                 \
00027     {                                                                \
00028       size_t __nbytes = nbytes;                                             \
00029       asm volatile("mtspr   1,%2\n"                                         \
00030                  "lsx              6,0,%1\n"                                \
00031                  "stsx      6,0,%0" : /* No outputs.  */ :                  \
00032                  "b" (dst_bp), "b" (src_bp), "r" (__nbytes) :               \
00033                  "6", "7", "8", "9", "10", "11", "12", "13");               \
00034       dst_bp += __nbytes;                                            \
00035       src_bp += __nbytes;                                            \
00036     } while (0)
00037 
00038 #undef BYTE_COPY_BWD
00039 #define BYTE_COPY_BWD(dst_ep, src_ep, nbytes)                               \
00040   do                                                                 \
00041     {                                                                \
00042       size_t __nbytes = (nbytes);                                    \
00043       dst_ep -= __nbytes;                                            \
00044       src_ep -= __nbytes;                                            \
00045       asm volatile("mtspr   1,%2\n"                                         \
00046                  "lsx              6,0,%1\n"                                \
00047                  "stsx      6,0,%0" : /* No outputs.  */ :                  \
00048                  "b" (dst_ep), "b" (src_ep), "r" (__nbytes) :               \
00049                  "6", "7", "8", "9", "10", "11", "12", "13");               \
00050     } while (0)
00051 
00052 #undef WORD_COPY_FWD
00053 #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes)                  \
00054   do                                                                 \
00055     {                                                                \
00056       size_t __nblocks = (nbytes) / 32;                                     \
00057       if (__nblocks != 0)                                            \
00058        asm volatile("mtctr  %4\n"                                    \
00059                    "lsi     6,%1,32\n"                               \
00060                    "ai      %1,%1,32\n"                              \
00061                    "stsi    6,%0,32\n"                               \
00062                    "ai      %0,%0,32\n"                              \
00063                    "bdn     $-16" :                                         \
00064                    "=b" (dst_bp), "=b" (src_bp) :                           \
00065                    "0" (dst_bp), "1" (src_bp), "r" (__nblocks) :            \
00066                    "6", "7", "8", "9", "10", "11", "12", "13");             \
00067       (nbytes_left) = (nbytes) % 32;                                        \
00068     } while (0)
00069 
00070 #undef WORD_COPY_BWD
00071 #define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes)                  \
00072   do                                                                 \
00073     {                                                                \
00074       size_t __nblocks = (nbytes) / 32;                                     \
00075       if (__nblocks != 0)                                            \
00076        asm volatile("mtctr  %4\n"                                    \
00077                    "ai      %1,%1,-32\n"                             \
00078                    "lsi     6,%1,32\n"                               \
00079                    "ai      %0,%0,-32\n"                             \
00080                    "stsi    6,%0,32\n"                               \
00081                    "bdn     $-16" :                                         \
00082                    "=b" (dst_ep), "=b" (src_ep) :                           \
00083                    "0" (dst_ep), "1" (src_ep), "r" (__nblocks) :            \
00084                    "6", "7", "8", "9", "10", "11", "12", "13");             \
00085       (nbytes_left) = (nbytes) % 32;                                        \
00086     } while (0)