Update.
[glibc.git] / sysdeps / i386 / memcopy.h
blob576f9969575129003035ebc2ee99865ff5b041f3
1 /* memcopy.h -- definitions for memory copy functions. i386 version.
2 Copyright (C) 1991, 1997 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4 Contributed by Torbjorn Granlund (tege@sics.se).
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public License as
8 published by the Free Software Foundation; either version 2 of the
9 License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public
17 License along with the GNU C Library; see the file COPYING.LIB. If not,
18 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 #include <sysdeps/generic/memcopy.h>
23 #undef OP_T_THRES
24 #define OP_T_THRES 8
26 #undef BYTE_COPY_FWD
27 #define BYTE_COPY_FWD(dst_bp, src_bp, nbytes) \
28 asm volatile(/* Clear the direction flag, so copying goes forward. */ \
29 "cld\n" \
30 /* Copy bytes. */ \
31 "rep\n" \
32 "movsb" : \
33 "=D" (dst_bp), "=S" (src_bp) : \
34 "0" (dst_bp), "1" (src_bp), "c" (nbytes) : \
35 "cx")
37 #undef BYTE_COPY_BWD
38 #define BYTE_COPY_BWD(dst_ep, src_ep, nbytes) \
39 do \
40 { \
41 asm volatile(/* Set the direction flag, so copying goes backwards. */ \
42 "std\n" \
43 /* Copy bytes. */ \
44 "rep\n" \
45 "movsb\n" \
46 /* Clear the dir flag. Convention says it should be 0. */ \
47 "cld" : \
48 "=D" (dst_ep), "=S" (src_ep) : \
49 "0" (dst_ep - 1), "1" (src_ep - 1), "c" (nbytes) : \
50 "cx"); \
51 dst_ep += 1; \
52 src_ep += 1; \
53 } while (0)
55 #undef WORD_COPY_FWD
56 #define WORD_COPY_FWD(dst_bp, src_bp, nbytes_left, nbytes) \
57 do \
58 { \
59 asm volatile(/* Clear the direction flag, so copying goes forward. */ \
60 "cld\n" \
61 /* Copy longwords. */ \
62 "rep\n" \
63 "movsl" : \
64 "=D" (dst_bp), "=S" (src_bp) : \
65 "0" (dst_bp), "1" (src_bp), "c" ((nbytes) / 4) : \
66 "cx"); \
67 (nbytes_left) = (nbytes) % 4; \
68 } while (0)
70 #undef WORD_COPY_BWD
71 #define WORD_COPY_BWD(dst_ep, src_ep, nbytes_left, nbytes) \
72 do \
73 { \
74 asm volatile(/* Set the direction flag, so copying goes backwards. */ \
75 "std\n" \
76 /* Copy longwords. */ \
77 "rep\n" \
78 "movsl\n" \
79 /* Clear the dir flag. Convention says it should be 0. */ \
80 "cld" : \
81 "=D" (dst_ep), "=S" (src_ep) : \
82 "0" (dst_ep - 4), "1" (src_ep - 4), "c" ((nbytes) / 4) : \
83 "cx"); \
84 dst_ep += 4; \
85 src_ep += 4; \
86 (nbytes_left) = (nbytes) % 4; \
87 } while (0)