Minor fixes to comments.
[AROS.git] / rom / exec / copymemquick.c
blob19d3f6bbbbb1b89b7b424c529889ecbe2b48df99
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Copy aligned memory.
6 Lang: english
7 */
8 #include <aros/debug.h>
9 #include <aros/libcall.h>
10 #include <exec/types.h>
12 /*****************************************************************************
14 NAME */
16 AROS_LH3I(void, CopyMemQuick,
18 /* SYNOPSIS */
19 AROS_LHA(CONST_APTR, source, A0),
20 AROS_LHA(APTR, dest, A1),
21 AROS_LHA(ULONG, size, D0),
23 /* LOCATION */
24 struct ExecBase *, SysBase, 105, Exec)
26 /* FUNCTION
27 Copy some longwords from one destination in memory to another using
28 a fast copying method.
30 INPUTS
31 source - Pointer to source area (must be ULONG aligned)
32 dest - Pointer to destination (must be ULONG aligned)
33 size - number of bytes to copy (must be a multiple of sizeof(ULONG)).
34 May be zero.
36 RESULT
38 NOTES
39 The source and destination areas are not allowed to overlap.
41 EXAMPLE
43 BUGS
45 SEE ALSO
46 CopyMem()
48 INTERNALS
50 ******************************************************************************/
52 AROS_LIBFUNC_INIT
54 ULONG low,high;
55 const ULONG *src = source;
56 ULONG *dst = dest;
58 /* Calculate number of ULONGs to copy */
59 size/=sizeof(ULONG);
62 To minimize the loop overhead I copy more than one (eight) ULONG per
63 iteration. Therefore I need to split size into size/8 and the rest.
65 low =size&7;
66 high=size/8;
68 /* Then copy for both parts */
69 if(low)
71 *dst++=*src++;
72 while(--low);
75 Partly unrolled copying loop. The predecrement helps the compiler to
76 find the best possible loop. The if is necessary to do this.
78 if(high)
81 *dst++=*src++;
82 *dst++=*src++;
83 *dst++=*src++;
84 *dst++=*src++;
85 *dst++=*src++;
86 *dst++=*src++;
87 *dst++=*src++;
88 *dst++=*src++;
89 }while(--high);
90 AROS_LIBFUNC_EXIT
91 } /* CopyMemQuick */