10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
51651Spetede * Common Development and Distribution License (the "License").
61651Spetede * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
216515Sraf
220Sstevel@tonic-gate /*
23*12391SSurya.Prakki@Sun.COM * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate /* Copyright (c) 1988 AT&T */
270Sstevel@tonic-gate /* All Rights Reserved */
280Sstevel@tonic-gate
290Sstevel@tonic-gate #if !defined(_KMDB) && !defined(_BOOT) && !defined(_KERNEL)
300Sstevel@tonic-gate
316812Sraf #include "lint.h"
320Sstevel@tonic-gate
336812Sraf #endif /* !_KMDB && !_BOOT && !_KERNEL */
341651Spetede
35*12391SSurya.Prakki@Sun.COM /*
36*12391SSurya.Prakki@Sun.COM * The SunStudio compiler may generate calls to _memcpy; So we
37*12391SSurya.Prakki@Sun.COM * need to make sure that the correct symbol exists for these calls.
38*12391SSurya.Prakki@Sun.COM */
391651Spetede #pragma weak _memcpy = memcpy
401651Spetede
410Sstevel@tonic-gate #include <sys/types.h>
420Sstevel@tonic-gate
430Sstevel@tonic-gate #if defined(_KERNEL)
440Sstevel@tonic-gate #include <sys/systm.h>
453446Smrj #elif !defined(_BOOT)
460Sstevel@tonic-gate #include <stddef.h>
470Sstevel@tonic-gate #include <string.h>
483446Smrj #endif
493446Smrj
503446Smrj #include "memcpy.h"
510Sstevel@tonic-gate
520Sstevel@tonic-gate /*
530Sstevel@tonic-gate * Copy s0 to s, always copy n bytes.
540Sstevel@tonic-gate * Return s
550Sstevel@tonic-gate */
560Sstevel@tonic-gate void *
memcpy(void * s,const void * s0,size_t n)570Sstevel@tonic-gate memcpy(void *s, const void *s0, size_t n)
580Sstevel@tonic-gate {
590Sstevel@tonic-gate if (n != 0) {
600Sstevel@tonic-gate char *s1 = s;
610Sstevel@tonic-gate const char *s2 = s0;
620Sstevel@tonic-gate
630Sstevel@tonic-gate do {
640Sstevel@tonic-gate *s1++ = *s2++;
650Sstevel@tonic-gate } while (--n != 0);
660Sstevel@tonic-gate }
670Sstevel@tonic-gate return (s);
680Sstevel@tonic-gate }
69