xref: /openbsd-src/sys/lib/libsa/memcpy.c (revision 7a2189da75c696c4404ba58cd970151833ffe027)
1*7a2189daSderaadt /*	$OpenBSD: memcpy.c,v 1.6 2019/04/20 22:59:04 deraadt Exp $	*/
2e31e80fdSmickey /*	$NetBSD: bcopy.c,v 1.5 1995/04/22 13:46:50 cgd Exp $	*/
36273ac13Sderaadt 
46273ac13Sderaadt /*-
56273ac13Sderaadt  * Copyright (c) 1993
66273ac13Sderaadt  *	The Regents of the University of California.  All rights reserved.
76273ac13Sderaadt  *
86273ac13Sderaadt  * Redistribution and use in source and binary forms, with or without
96273ac13Sderaadt  * modification, are permitted provided that the following conditions
106273ac13Sderaadt  * are met:
116273ac13Sderaadt  * 1. Redistributions of source code must retain the above copyright
126273ac13Sderaadt  *    notice, this list of conditions and the following disclaimer.
136273ac13Sderaadt  * 2. Redistributions in binary form must reproduce the above copyright
146273ac13Sderaadt  *    notice, this list of conditions and the following disclaimer in the
156273ac13Sderaadt  *    documentation and/or other materials provided with the distribution.
1629295d1cSmillert  * 3. Neither the name of the University nor the names of its contributors
176273ac13Sderaadt  *    may be used to endorse or promote products derived from this software
186273ac13Sderaadt  *    without specific prior written permission.
196273ac13Sderaadt  *
206273ac13Sderaadt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
216273ac13Sderaadt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
226273ac13Sderaadt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
236273ac13Sderaadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
246273ac13Sderaadt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
256273ac13Sderaadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
266273ac13Sderaadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
276273ac13Sderaadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
286273ac13Sderaadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
296273ac13Sderaadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
306273ac13Sderaadt  * SUCH DAMAGE.
316273ac13Sderaadt  *
32e31e80fdSmickey  *	@(#)bcopy.c	8.1 (Berkeley) 6/11/93
336273ac13Sderaadt  */
346273ac13Sderaadt 
356273ac13Sderaadt #include <sys/types.h>
366273ac13Sderaadt #include "stand.h"
376273ac13Sderaadt 
38e31e80fdSmickey /*
39e31e80fdSmickey  * This is designed to be small, not fast.
40e31e80fdSmickey  */
416273ac13Sderaadt void *
memcpy(void * s1,const void * s2,size_t n)4253c346fbSderaadt memcpy(void *s1, const void *s2, size_t n)
436273ac13Sderaadt {
4453c346fbSderaadt 	const char *f = s2;
4553c346fbSderaadt 	char *t = s1;
46e31e80fdSmickey 
47e31e80fdSmickey 	while (n-- > 0)
48e31e80fdSmickey 		*t++ = *f++;
496273ac13Sderaadt 	return s1;
506273ac13Sderaadt }
51