Blame sysdeps/i386/memcopy.h

Packit 6c4009
/* memcopy.h -- definitions for memory copy functions.  i386 version.
Packit 6c4009
   Copyright (C) 1991-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
   Contributed by Torbjorn Granlund (tege@sics.se).
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sysdeps/generic/memcopy.h>
Packit 6c4009
Packit 6c4009
#undef	OP_T_THRES
Packit 6c4009
#define	OP_T_THRES	8
Packit 6c4009
Packit 6c4009
#undef	BYTE_COPY_FWD
Packit 6c4009
#define BYTE_COPY_FWD(dst_bp, src_bp, nbytes)				      \
Packit 6c4009
  do {									      \
Packit 6c4009
    int __d0;								      \
Packit 6c4009
    asm volatile(/* Clear the direction flag, so copying goes forward.  */    \
Packit 6c4009
		 "cld\n"						      \
Packit 6c4009
		 /* Copy bytes.  */					      \
Packit 6c4009
		 "rep\n"						      \
Packit 6c4009
		 "movsb" :						      \
Packit 6c4009
		 "=D" (dst_bp), "=S" (src_bp), "=c" (__d0) :		      \
Packit 6c4009
		 "0" (dst_bp), "1" (src_bp), "2" (nbytes) :		      \
Packit 6c4009
		 "memory");						      \
Packit 6c4009
  } while (0)
Packit 6c4009
Packit 6c4009
#undef	BYTE_COPY_BWD
Packit 6c4009
#define BYTE_COPY_BWD(dst_ep, src_ep, nbytes)				      \
Packit 6c4009
  do									      \
Packit 6c4009
    {									      \
Packit 6c4009
      int __d0;								      \
Packit 6c4009
      asm volatile(/* Set the direction flag, so copying goes backwards.  */  \
Packit 6c4009
		   "std\n"						      \
Packit 6c4009
		   /* Copy bytes.  */					      \
Packit 6c4009
		   "rep\n"						      \
Packit 6c4009
		   "movsb\n"						      \
Packit 6c4009
		   /* Clear the dir flag.  Convention says it should be 0. */ \
Packit 6c4009
		   "cld" :						      \
Packit 6c4009
		   "=D" (dst_ep), "=S" (src_ep), "=c" (__d0) :		      \
Packit 6c4009
		   "0" (dst_ep - 1), "1" (src_ep - 1), "2" (nbytes) :	      \
Packit 6c4009
		   "memory");						      \
Packit 6c4009
      dst_ep += 1;							      \
Packit 6c4009
      src_ep += 1;							      \
Packit 6c4009
    } while (0)
Packit 6c4009
Packit 6c4009
#undef	WORD_COPY_FWD
Packit 6c4009
#define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes)		      \
Packit 6c4009
  do									      \
Packit 6c4009
    {									      \
Packit 6c4009
      int __d0;								      \
Packit 6c4009
      asm volatile(/* Clear the direction flag, so copying goes forward.  */  \
Packit 6c4009
		   "cld\n"						      \
Packit 6c4009
		   /* Copy longwords.  */				      \
Packit 6c4009
		   "rep\n"						      \
Packit 6c4009
		   "movsl" :						      \
Packit 6c4009
 		   "=D" (dst_bp), "=S" (src_bp), "=c" (__d0) :		      \
Packit 6c4009
		   "0" (dst_bp), "1" (src_bp), "2" ((nbytes) / 4) :	      \
Packit 6c4009
		   "memory");						      \
Packit 6c4009
      (nbytes_left) = (nbytes) % 4;					      \
Packit 6c4009
    } while (0)
Packit 6c4009
Packit 6c4009
#undef	WORD_COPY_BWD
Packit 6c4009
#define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes)		      \
Packit 6c4009
  do									      \
Packit 6c4009
    {									      \
Packit 6c4009
      int __d0;								      \
Packit 6c4009
      asm volatile(/* Set the direction flag, so copying goes backwards.  */  \
Packit 6c4009
		   "std\n"						      \
Packit 6c4009
		   /* Copy longwords.  */				      \
Packit 6c4009
		   "rep\n"						      \
Packit 6c4009
		   "movsl\n"						      \
Packit 6c4009
		   /* Clear the dir flag.  Convention says it should be 0. */ \
Packit 6c4009
		   "cld" :						      \
Packit 6c4009
		   "=D" (dst_ep), "=S" (src_ep), "=c" (__d0) :		      \
Packit 6c4009
		   "0" (dst_ep - 4), "1" (src_ep - 4), "2" ((nbytes) / 4) :   \
Packit 6c4009
		   "memory");						      \
Packit 6c4009
      dst_ep += 4;							      \
Packit 6c4009
      src_ep += 4;							      \
Packit 6c4009
      (nbytes_left) = (nbytes) % 4;					      \
Packit 6c4009
    } while (0)