try to make sure compiler/include/mmakefile is always refreshed correctly.
[AROS.git] / rom / exec / copymemquick.c
blob015a5861c9755413613af3e0cfa0bcb2cb867b66
1 /*
2 Copyright © 1995-2012, 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(IPTR, 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
49 64-bit sizes are not handled yet.
51 ******************************************************************************/
53 AROS_LIBFUNC_INIT
55 ULONG low,high;
56 const ULONG *src = source;
57 ULONG *dst = dest;
59 /* Calculate number of ULONGs to copy */
60 size/=sizeof(ULONG);
63 To minimize the loop overhead I copy more than one (eight) ULONG per
64 iteration. Therefore I need to split size into size/8 and the rest.
66 low =size&7;
67 high=size/8;
69 /* Then copy for both parts */
70 if(low)
72 *dst++=*src++;
73 while(--low);
76 Partly unrolled copying loop. The predecrement helps the compiler to
77 find the best possible loop. The if is necessary to do this.
79 if(high)
82 *dst++=*src++;
83 *dst++=*src++;
84 *dst++=*src++;
85 *dst++=*src++;
86 *dst++=*src++;
87 *dst++=*src++;
88 *dst++=*src++;
89 *dst++=*src++;
90 }while(--high);
91 AROS_LIBFUNC_EXIT
92 } /* CopyMemQuick */