home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / exec / copymemquick.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  2.6 KB  |  111 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: copymemquick.c,v 1.7 1997/01/01 03:46:07 ldp Exp $
  4.     $Log: copymemquick.c,v $
  5.     Revision 1.7  1997/01/01 03:46:07  ldp
  6.     Committed Amiga native (support) code
  7.  
  8.     Changed clib to proto
  9.  
  10.     Revision 1.6  1996/12/10 13:51:41  aros
  11.     Moved all #include's in the first column so makedepend can see it.
  12.  
  13.     Revision 1.5  1996/10/24 15:50:46  aros
  14.     Use the official AROS macros over the __AROS versions.
  15.  
  16.     Revision 1.4  1996/08/13 13:55:59  digulla
  17.     Replaced AROS_LA by AROS_LHA
  18.     Replaced some AROS_LH*I by AROS_LH*
  19.     Sorted and added includes
  20.  
  21.     Revision 1.3  1996/08/01 17:41:07  digulla
  22.     Added standard header for all files
  23.  
  24.     Desc:
  25.     Lang:
  26. */
  27. #include <aros/libcall.h>
  28. #include <exec/types.h>
  29.  
  30. /*****************************************************************************
  31.  
  32.     NAME */
  33.  
  34.     AROS_LH3I(void, CopyMemQuick,
  35.  
  36. /*  SYNOPSIS */
  37.     AROS_LHA(APTR,  source, A0),
  38.     AROS_LHA(APTR,  dest,   A1),
  39.     AROS_LHA(ULONG, size,   D0),
  40.  
  41. /*  LOCATION */
  42.     struct ExecBase *, SysBase, 105, Exec)
  43.  
  44. /*  FUNCTION
  45.     Copy some longwords from one destination in memory to another using
  46.     a fast copying method.
  47.  
  48.     INPUTS
  49.     source - Pointer to source area (must be ULONG aligned)
  50.     dest   - Pointer to destination (must be ULONG aligned)
  51.     size   - number of bytes to copy (must be a multiple of sizeof(ULONG))
  52.  
  53.     RESULT
  54.  
  55.     NOTES
  56.     The source and destination area are not allowed to overlap.
  57.  
  58.     EXAMPLE
  59.  
  60.     BUGS
  61.  
  62.     SEE ALSO
  63.     CopyMem()
  64.  
  65.     INTERNALS
  66.  
  67.     HISTORY
  68.     22-10-95    Created by M. Fleischer
  69.  
  70. ******************************************************************************/
  71. {
  72.     AROS_LIBFUNC_INIT
  73.  
  74.     ULONG low,high;
  75.  
  76.     /* Calculate number of ULONGs to copy */
  77.     size/=sizeof(ULONG);
  78.  
  79.     /*
  80.     To minimize the loop overhead I copy more than one (eight) ULONG per
  81.     iteration. Therefore I need to split size into size/8 and the rest.
  82.     */
  83.     low =size&7;
  84.     high=size/8;
  85.  
  86.     /* Then copy for both parts */
  87.     if(low)
  88.     do
  89.         *((ULONG *)dest)++=*((ULONG *)source)++;
  90.     while(--low);
  91.  
  92.     /*
  93.     Partly unrolled copying loop. The predecrement helps the compiler to
  94.     find the best possible loop. The if is necessary to do this.
  95.     */
  96.     if(high)
  97.     do
  98.     {
  99.         *((ULONG *)dest)++=*((ULONG *)source)++;
  100.         *((ULONG *)dest)++=*((ULONG *)source)++;
  101.         *((ULONG *)dest)++=*((ULONG *)source)++;
  102.         *((ULONG *)dest)++=*((ULONG *)source)++;
  103.         *((ULONG *)dest)++=*((ULONG *)source)++;
  104.         *((ULONG *)dest)++=*((ULONG *)source)++;
  105.         *((ULONG *)dest)++=*((ULONG *)source)++;
  106.         *((ULONG *)dest)++=*((ULONG *)source)++;
  107.     }while(--high);
  108.     AROS_LIBFUNC_EXIT
  109. } /* CopyMemQuick */
  110.  
  111.