|
|
1.1 ! root 1: /* bcopy -- copy memory regions of arbitary length ! 2: Copyright (C) 1991 Free Software Foundation, Inc. ! 3: ! 4: This file is part of the libiberty library. ! 5: Libiberty is free software; you can redistribute it and/or ! 6: modify it under the terms of the GNU Library General Public ! 7: License as published by the Free Software Foundation; either ! 8: version 2 of the License, or (at your option) any later version. ! 9: ! 10: Libiberty is distributed in the hope that it will be useful, ! 11: but WITHOUT ANY WARRANTY; without even the implied warranty of ! 12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ! 13: Library General Public License for more details. ! 14: ! 15: You should have received a copy of the GNU Library General Public ! 16: License along with libiberty; see the file COPYING.LIB. If ! 17: not, write to the Free Software Foundation, Inc., 675 Mass Ave, ! 18: Cambridge, MA 02139, USA. */ ! 19: ! 20: /* ! 21: ! 22: NAME ! 23: ! 24: bcopy -- copy memory regions of arbitrary length ! 25: ! 26: SYNOPSIS ! 27: ! 28: void bcopy (char *in, char *out, int length) ! 29: ! 30: DESCRIPTION ! 31: ! 32: Copy LENGTH bytes from memory region pointed to by IN to memory ! 33: region pointed to by OUT. ! 34: ! 35: BUGS ! 36: Significant speed improvements can be made in some cases by ! 37: implementing copies of multiple bytes simultaneously, or unrolling ! 38: the copy loop. ! 39: ! 40: */ ! 41: ! 42: void ! 43: bcopy (src, dest, len) ! 44: register char *src, *dest; ! 45: int len; ! 46: { ! 47: if (dest < src) ! 48: while (len--) ! 49: *dest++ = *src++; ! 50: else ! 51: { ! 52: char *lasts = src + (len-1); ! 53: char *lastd = dest + (len-1); ! 54: while (len--) ! 55: *(char *)lastd-- = *(char *)lasts--; ! 56: } ! 57: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.