arch/m68k-amiga: Define the gcc symbol 'start' instead of using .bss
[AROS.git] / rom / exec / copymemquick.c
blob436fb49b0dad988366d6ea88663ba891f92b7f78
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 #ifdef __mc68000 // FIXME: remove after CopyMemQuick() problems found and fixed
59 if ((size & 3) || ((ULONG)source & 3) || ((ULONG)dest & 3)) {
60 bug("Unaligned CopyMemQuick(%x,%x,%x)!\n", source, dest, size);
61 Alert(AO_ExecLib | AN_MemoryInsane); /* bogus but unique */
63 #endif
65 /* Calculate number of ULONGs to copy */
66 size/=sizeof(ULONG);
69 To minimize the loop overhead I copy more than one (eight) ULONG per
70 iteration. Therefore I need to split size into size/8 and the rest.
72 low =size&7;
73 high=size/8;
75 /* Then copy for both parts */
76 if(low)
78 *dst++=*src++;
79 while(--low);
82 Partly unrolled copying loop. The predecrement helps the compiler to
83 find the best possible loop. The if is necessary to do this.
85 if(high)
88 *dst++=*src++;
89 *dst++=*src++;
90 *dst++=*src++;
91 *dst++=*src++;
92 *dst++=*src++;
93 *dst++=*src++;
94 *dst++=*src++;
95 *dst++=*src++;
96 }while(--high);
97 AROS_LIBFUNC_EXIT
98 } /* CopyMemQuick */