xref: /openbsd-src/libexec/ld.so/m88k/memcpy.c (revision d3d281f473cdab789c63242419a39dac665f400b)
1*d3d281f4Smiod /*	$OpenBSD: memcpy.c,v 1.1 2013/01/20 23:01:44 miod Exp $	*/
2*d3d281f4Smiod /*	$NetBSD: bcopy.c,v 1.5 1995/04/22 13:46:50 cgd Exp $	*/
3*d3d281f4Smiod 
4*d3d281f4Smiod /*-
5*d3d281f4Smiod  * Copyright (c) 1993
6*d3d281f4Smiod  *	The Regents of the University of California.  All rights reserved.
7*d3d281f4Smiod  *
8*d3d281f4Smiod  * Redistribution and use in source and binary forms, with or without
9*d3d281f4Smiod  * modification, are permitted provided that the following conditions
10*d3d281f4Smiod  * are met:
11*d3d281f4Smiod  * 1. Redistributions of source code must retain the above copyright
12*d3d281f4Smiod  *    notice, this list of conditions and the following disclaimer.
13*d3d281f4Smiod  * 2. Redistributions in binary form must reproduce the above copyright
14*d3d281f4Smiod  *    notice, this list of conditions and the following disclaimer in the
15*d3d281f4Smiod  *    documentation and/or other materials provided with the distribution.
16*d3d281f4Smiod  * 3. Neither the name of the University nor the names of its contributors
17*d3d281f4Smiod  *    may be used to endorse or promote products derived from this software
18*d3d281f4Smiod  *    without specific prior written permission.
19*d3d281f4Smiod  *
20*d3d281f4Smiod  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21*d3d281f4Smiod  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*d3d281f4Smiod  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*d3d281f4Smiod  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24*d3d281f4Smiod  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*d3d281f4Smiod  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*d3d281f4Smiod  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*d3d281f4Smiod  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*d3d281f4Smiod  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*d3d281f4Smiod  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*d3d281f4Smiod  * SUCH DAMAGE.
31*d3d281f4Smiod  *
32*d3d281f4Smiod  *	@(#)bcopy.c	8.1 (Berkeley) 6/11/93
33*d3d281f4Smiod  */
34*d3d281f4Smiod 
35*d3d281f4Smiod #include <sys/types.h>
36*d3d281f4Smiod 
37*d3d281f4Smiod /*
38*d3d281f4Smiod  * This is designed to be small, not fast.
39*d3d281f4Smiod  */
40*d3d281f4Smiod void *
memcpy(s1,s2,n)41*d3d281f4Smiod memcpy(s1, s2, n)
42*d3d281f4Smiod 	void *s1;
43*d3d281f4Smiod 	const void *s2;
44*d3d281f4Smiod 	size_t n;
45*d3d281f4Smiod {
46*d3d281f4Smiod 	register const char *f = s2;
47*d3d281f4Smiod 	register char *t = s1;
48*d3d281f4Smiod 
49*d3d281f4Smiod 	if (f < t) {
50*d3d281f4Smiod 		f += n;
51*d3d281f4Smiod 		t += n;
52*d3d281f4Smiod 		while (n-- > 0)
53*d3d281f4Smiod 			*--t = *--f;
54*d3d281f4Smiod 	} else
55*d3d281f4Smiod 		while (n-- > 0)
56*d3d281f4Smiod 			*t++ = *f++;
57*d3d281f4Smiod 	return s1;
58*d3d281f4Smiod }
59