4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
26 #include <sys/salib.h>
28 #include <sys/systm.h>
32 * Implementations of functions described in memory(3C).
33 * These functions match the section 3C manpages.
36 * The SunStudio compiler may generate calls to _memmove, _memset,
37 * and _memcpy; So we need to make sure that the correct symbols
38 * exist for these calls.
40 #pragma weak _memmove = memmove
42 memmove(void *s1
, const void *s2
, size_t n
)
52 #pragma weak _memset = memset
54 memset(void *s
, int c
, size_t n
)
58 if ((unsigned char)c
== '\0')
61 for (t
= (unsigned char *)s
; n
> 0; n
--)
62 *t
++ = (unsigned char)c
;
68 memcmp(const void *s1
, const void *s2
, size_t n
)
70 const uchar_t
*ps1
= s1
;
71 const uchar_t
*ps2
= s2
;
73 if (s1
!= s2
&& n
!= 0) {
76 return (ps1
[-1] - ps2
[-1]);
83 #pragma weak _memcpy = memcpy
85 memcpy(void *s1
, const void *s2
, size_t n
)
92 memchr(const void *sptr
, int c1
, size_t n
)
95 unsigned char c
= (unsigned char)c1
;
96 const unsigned char *sp
= sptr
;
100 return ((void *)--sp
);