git.y1.nz

gbdk-2020

GameBoy Development Kit
download: https://git.y1.nz/archives/gbdk.tar.gz
README | Files | Log | Refs | LICENSE

gbdk-lib/libc/asm/mos6502/_memmove.c

      1 /*-------------------------------------------------------------------------
      2    _memmove.c - part of string library functions
      3 
      4    Copyright (C) 1999, Sandeep Dutta . sandeep.dutta@usa.net
      5    Adapted By -  Erik Petrich  . epetrich@users.sourceforge.net
      6    from _memcpy.c which was originally
      7 
      8    This library is free software; you can redistribute it and/or modify it
      9    under the terms of the GNU General Public License as published by the
     10    Free Software Foundation; either version 2, or (at your option) any
     11    later version.
     12 
     13    This library is distributed in the hope that it will be useful,
     14    but WITHOUT ANY WARRANTY; without even the implied warranty of
     15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16    GNU General Public License for more details.
     17 
     18    You should have received a copy of the GNU General Public License
     19    along with this library; see the file COPYING. If not, write to the
     20    Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
     21    MA 02110-1301, USA.
     22 
     23    As a special exception, if you link this library with other files,
     24    some of which are compiled with SDCC, to produce an executable,
     25    this library does not by itself cause the resulting executable to
     26    be covered by the GNU General Public License. This exception does
     27    not however invalidate any other reasons why the executable file
     28    might be covered by the GNU General Public License.
     29 -------------------------------------------------------------------------*/
     30 #include <string.h>
     31 #include <stdint.h>
     32 
     33 void *memmove (void *dst, const void *src, size_t size)
     34 {
     35 	size_t c = size;
     36 	if (c == 0)
     37 		return dst;
     38 
     39 	char *d = dst;
     40 	const char *s = src;
     41 	if (s < d) {
     42 		d += c;
     43 		s += c;
     44 		do {
     45 			*--d = *--s;
     46 		} while (--c);
     47 	} else {
     48 		do {
     49 			*d++ = *s++;
     50 		} while (--c);
     51 	}
     52 
     53 	return dst;
     54 }

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.