Back to index

glibc  2.9
memcopy.h
Go to the documentation of this file.
00001 /* Copyright (C) 2001 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 /* We override the word-copying macros, partly because misalignment in one
00022    pointer isn't cause for a special function, partly because we want to
00023    get rid of wordcopy.c; these macros are only used in memmove.c (and
00024    it's sibling bcopy) since we have arch-specific mempcpy, memcpy and
00025    memset.  */
00026 
00027 #undef OP_T_THRES
00028 #define OP_T_THRES OPSIZ
00029 
00030 #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes)            \
00031   do                                                           \
00032     {                                                          \
00033       unsigned long enddst_bp = dst_bp + nbytes - (nbytes % OPSIZ);   \
00034       nbytes_left = (nbytes % OPSIZ);                                 \
00035       while (dst_bp < (unsigned long) enddst_bp)               \
00036        {                                                       \
00037          op_t x = *(op_t *) src_bp;                                   \
00038          src_bp += sizeof x;                                          \
00039          *(op_t *) dst_bp = x;                                        \
00040          dst_bp += sizeof x;                                          \
00041        }                                                       \
00042     } while (0)
00043 
00044 #define WORD_COPY_BWD(dst_bp, src_bp, nbytes_left, nbytes)            \
00045   do                                                           \
00046     {                                                          \
00047       unsigned long enddst_bp = dst_bp - nbytes + (nbytes % OPSIZ);   \
00048       nbytes_left = (nbytes % OPSIZ);                                 \
00049       while (dst_bp > enddst_bp)                               \
00050        {                                                       \
00051          op_t x;                                               \
00052          src_bp -= sizeof x;                                          \
00053          x = *(op_t *) src_bp;                                        \
00054          dst_bp -= sizeof x;                                          \
00055          *(op_t *) dst_bp = x;                                        \
00056        }                                                       \
00057     } while (0)