xref: /freebsd/share/man/man9/bcopy.9 (revision 7f55dbe6ae89c356db1bc4fb2c42d9d007ae5da1)
1b94f4389SBrooks Davis.\" Copyright (c) 1990, 1991, 1993
2b94f4389SBrooks Davis.\"	The Regents of the University of California.  All rights reserved.
3b94f4389SBrooks Davis.\"
4b94f4389SBrooks Davis.\" This code is derived from software contributed to Berkeley by
5b94f4389SBrooks Davis.\" Chris Torek.
6b94f4389SBrooks Davis.\"
7b94f4389SBrooks Davis.\" Redistribution and use in source and binary forms, with or without
8b94f4389SBrooks Davis.\" modification, are permitted provided that the following conditions
9b94f4389SBrooks Davis.\" are met:
10b94f4389SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright
11b94f4389SBrooks Davis.\"    notice, this list of conditions and the following disclaimer.
12b94f4389SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright
13b94f4389SBrooks Davis.\"    notice, this list of conditions and the following disclaimer in the
14b94f4389SBrooks Davis.\"    documentation and/or other materials provided with the distribution.
15b94f4389SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors
16b94f4389SBrooks Davis.\"    may be used to endorse or promote products derived from this software
17b94f4389SBrooks Davis.\"    without specific prior written permission.
18b94f4389SBrooks Davis.\"
19b94f4389SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20b94f4389SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21b94f4389SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22b94f4389SBrooks Davis.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23b94f4389SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24b94f4389SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25b94f4389SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26b94f4389SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27b94f4389SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28b94f4389SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29b94f4389SBrooks Davis.\" SUCH DAMAGE.
30b94f4389SBrooks Davis.\"
31*7f55dbe6SBrooks Davis.Dd July 1, 2026
32b94f4389SBrooks Davis.Dt BCOPY 9
33b94f4389SBrooks Davis.Os
34b94f4389SBrooks Davis.Sh NAME
35b94f4389SBrooks Davis.Nm bcopy
36b94f4389SBrooks Davis.Nd copy bytes in object
37b94f4389SBrooks Davis.Sh SYNOPSIS
38b94f4389SBrooks Davis.In sys/systm.h
39b94f4389SBrooks Davis.Ft void
40b94f4389SBrooks Davis.Fn bcopy "const void *src" "void *dst" "size_t len"
41b94f4389SBrooks Davis.Sh DESCRIPTION
42b94f4389SBrooks DavisThe
43b94f4389SBrooks Davis.Fn bcopy
44b94f4389SBrooks Davisfunction copies
45b94f4389SBrooks Davis.Fa len
46b94f4389SBrooks Davisbytes from object
47b94f4389SBrooks Davis.Fa src
48b94f4389SBrooks Davisto object
49*7f55dbe6SBrooks Davis.Fa dst
50*7f55dbe6SBrooks Davispreserving the provenance of pointers in the copied object
51*7f55dbe6SBrooks Davis.Pq see Xr memory_model 7 for further information .
52b94f4389SBrooks DavisThe two objects may overlap.
53b94f4389SBrooks DavisIf
54b94f4389SBrooks Davis.Fa len
55b94f4389SBrooks Davisis zero, no bytes are copied.
56b94f4389SBrooks Davis.Pp
57b94f4389SBrooks DavisThe
58b94f4389SBrooks Davis.Fn bcopy
59b94f4389SBrooks Davisfunction is deprecated and
60b94f4389SBrooks Davis.Fn memcpy
61b94f4389SBrooks Davisor
62b94f4389SBrooks Davis.Fn memmove
63b94f4389SBrooks Davisshould be used as appropriate in new code.
64b94f4389SBrooks Davis.Sh SEE ALSO
65b94f4389SBrooks Davis.Xr memcpy 9 ,
66b94f4389SBrooks Davis.Xr memmove 9
67b94f4389SBrooks Davis.Sh HISTORY
68b94f4389SBrooks DavisA
69b94f4389SBrooks Davis.Fn bcopy
70b94f4389SBrooks Davisfunction appeared in
71b94f4389SBrooks Davis.Bx 4.2 .
72b94f4389SBrooks Davis.Pp
73b94f4389SBrooks Davis.St -p1003.1-2008
74b94f4389SBrooks Davisremoves the specification of
75b94f4389SBrooks Davis.Fn bcopy
76b94f4389SBrooks Davisand it is marked as LEGACY in
77b94f4389SBrooks Davis.St -p1003.1-2004 .
78b94f4389SBrooks DavisNew programs should use
79b94f4389SBrooks Davis.Xr memmove 3 .
80b94f4389SBrooks DavisIf the input and output buffer do not overlap, then
81b94f4389SBrooks Davis.Xr memcpy 3
82b94f4389SBrooks Davisis more efficient.
83b94f4389SBrooks DavisNote that
84b94f4389SBrooks Davis.Fn bcopy
85b94f4389SBrooks Davistakes
86b94f4389SBrooks Davis.Ar src
87b94f4389SBrooks Davisand
88b94f4389SBrooks Davis.Ar dst
89b94f4389SBrooks Davisin the opposite order from
90b94f4389SBrooks Davis.Fn memmove
91b94f4389SBrooks Davisand
92b94f4389SBrooks Davis.Fn memcpy .
93b94f4389SBrooks DavisIn practice,
94b94f4389SBrooks Davis.In sys/systm.h
95b94f4389SBrooks Davisdefines
96b94f4389SBrooks Davis.Fn bcopy
97b94f4389SBrooks Davisas a macro that calls
98b94f4389SBrooks Davis.Fn memmove
99b94f4389SBrooks Davissince
100b94f4389SBrooks Davis.Fx 12.0 .
101