Merge commit '9276b3991ba20d5a5660887ba81b0bc7bed25a0c'
[unleashed.git] / share / man / man9f / memchr.9f
blobba71a32613578049139557c00792513fa0f11a2c
1 '\" te
2 .\" Copyright (c) 2006, Sun Microsystems, Inc., All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH MEMCHR 9F "Jan 15, 2014"
7 .SH NAME
8 memchr, memcmp, memcpy, memmove, memset \- Memory operations
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/sunddi.h>
16 \fBvoid *\fR\fBmemchr\fR(\fBconst void *\fR\fIs\fR, \fBint\fR \fIc\fR, \fBsize_t\fR \fIn\fR);
17 .fi
19 .LP
20 .nf
21 \fBint\fR \fBmemcmp\fR(\fBconst void *\fR\fIs1\fR, \fBconst void *\fR\fIs2\fR, \fBsize_t\fR \fIn\fR);
22 .fi
24 .LP
25 .nf
26 \fBvoid *\fR\fBmemcpy\fR(\fBvoid *restrict\fR \fIs1\fR, \fBconst void *restrict\fR \fIs2\fR, \fBsize_t\fR \fIn\fR);
27 .fi
29 .LP
30 .nf
31 \fBvoid *\fR\fBmemmove\fR(\fBvoid *\fR\fIs1\fR, \fBconst void *\fR\fIs2\fR, \fBsize_t\fR \fIn\fR);
32 .fi
34 .LP
35 .nf
36 \fBvoid *\fR\fBmemset\fR(\fBvoid *\fR\fIs\fR, \fBint\fR \fIc\fR, \fBsize_t\fR \fIn\fR);
37 .fi
39 .SH INTERFACE LEVEL
40 .sp
41 .LP
42 Solaris DDI specific (Solaris DDI).
43 .SH PARAMETERS
44 .sp
45 .ne 2
46 .na
47 \fB\fIdst\fR\fR
48 .ad
49 .RS 10n
50 Pointers to character strings.
51 .RE
53 .sp
54 .ne 2
55 .na
56 \fB\fIn\fR\fR
57 .ad
58 .RS 10n
59 Count of characters to be copied.
60 .RE
62 .sp
63 .ne 2
64 .na
65 \fB\fIs1\fR, \fIs2\fR\fR
66 .ad
67 .RS 10n
68 Pointers to character strings.
69 .RE
71 .SH DESCRIPTION
72 .sp
73 .LP
74 These functions operate as efficiently as possible on memory areas (arrays of
75 bytes bounded by a count, not terminated by a null character). They do not
76 check for the overflow of any receiving memory area.
77 .sp
78 .LP
79 The \fBmemchr()\fR function returns a pointer to the first occurrence of
80 \fIc\fR (converted to an \fBunsigned char\fR) in the first \fIn\fR bytes (each
81 interpreted as an \fBunsigned char\fR) of memory area \fIs\fR, or a null
82 pointer if \fIc\fR does not occur.
83 .sp
84 .LP
85 The \fBmemcmp()\fR function compares its arguments, looking at the first
86 \fIn\fR bytes (each interpreted as an \fBunsigned char\fR), and returns an
87 integer less than, equal to, or greater than 0, according as \fIs1\fR is
88 lexicographically less than, equal to, or greater than \fIs2\fR when taken to
89 be unsigned characters.
90 .sp
91 .LP
92 The \fBmemcpy()\fR function copies \fIn\fR bytes from memory area \fIs2\fR to
93 \fIs1\fR. It returns \fIs1\fR. If copying takes place between objects that
94 overlap, the behavior is undefined.
95 .sp
96 .LP
97 The \fBmemmove()\fR function copies \fIn\fR bytes from memory area \fIs2\fR to
98 memory area \fIs1\fR. Copying between objects that overlap will take place
99 correctly. It returns \fIs1\fR.
102 The \fBmemset()\fR function sets the first \fIn\fR bytes in memory area \fIs\fR
103 to the value of \fIc\fR (converted to an \fBunsigned char\fR). It returns
104 \fIs\fR.
105 .SH USAGE
108 Using \fBmemcpy()\fR might be faster than using \fBmemmove()\fR if the
109 application knows that the objects being copied do not overlap.
110 .SH CONTEXT
113 These functions can be called from user, interrupt, or kernel context.
114 .SH SEE ALSO
117 \fBbcopy\fR(9F), \fBddi_copyin\fR(9F), \fBstrcpy\fR(9F)
120 \fIWriting Device Drivers\fR