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 and the American National Standards Committee X3, 6b94f4389SBrooks Davis.\" on Information Processing Systems. 7b94f4389SBrooks Davis.\" 8b94f4389SBrooks Davis.\" Redistribution and use in source and binary forms, with or without 9b94f4389SBrooks Davis.\" modification, are permitted provided that the following conditions 10b94f4389SBrooks Davis.\" are met: 11b94f4389SBrooks Davis.\" 1. Redistributions of source code must retain the above copyright 12b94f4389SBrooks Davis.\" notice, this list of conditions and the following disclaimer. 13b94f4389SBrooks Davis.\" 2. Redistributions in binary form must reproduce the above copyright 14b94f4389SBrooks Davis.\" notice, this list of conditions and the following disclaimer in the 15b94f4389SBrooks Davis.\" documentation and/or other materials provided with the distribution. 16b94f4389SBrooks Davis.\" 3. Neither the name of the University nor the names of its contributors 17b94f4389SBrooks Davis.\" may be used to endorse or promote products derived from this software 18b94f4389SBrooks Davis.\" without specific prior written permission. 19b94f4389SBrooks Davis.\" 20b94f4389SBrooks Davis.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21b94f4389SBrooks Davis.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22b94f4389SBrooks Davis.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23b94f4389SBrooks Davis.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24b94f4389SBrooks Davis.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25b94f4389SBrooks Davis.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26b94f4389SBrooks Davis.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27b94f4389SBrooks Davis.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28b94f4389SBrooks Davis.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29b94f4389SBrooks Davis.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30b94f4389SBrooks Davis.\" SUCH DAMAGE. 31b94f4389SBrooks Davis.\" 32*7f55dbe6SBrooks Davis.Dd July 1, 2026 33b94f4389SBrooks Davis.Dt MEMCPY 9 34b94f4389SBrooks Davis.Os 35b94f4389SBrooks Davis.Sh NAME 36*7f55dbe6SBrooks Davis.Nm memcpy , 37*7f55dbe6SBrooks Davis.Nm memcpy_data 38b94f4389SBrooks Davis.Nd copy bytes in memory 39b94f4389SBrooks Davis.Sh SYNOPSIS 40b94f4389SBrooks Davis.In sys/systm.h 41b94f4389SBrooks Davis.Ft void * 42b94f4389SBrooks Davis.Fn memcpy "void *dst" "const void *src" "size_t len" 43*7f55dbe6SBrooks Davis.Ft void * 44*7f55dbe6SBrooks Davis.Fn memcpy_data "void *dst" "const void *src" "size_t len" 45b94f4389SBrooks Davis.Sh DESCRIPTION 46b94f4389SBrooks DavisThe 47b94f4389SBrooks Davis.Fn memcpy 48b94f4389SBrooks Davisfunction copies 49b94f4389SBrooks Davis.Fa len 50b94f4389SBrooks Davisbytes from object 51b94f4389SBrooks Davis.Fa src 52b94f4389SBrooks Davisto object 53*7f55dbe6SBrooks Davis.Fa dst 54*7f55dbe6SBrooks Davisin a manner that preserves the provenance of pointers in the copied object 55*7f55dbe6SBrooks Davis.Pq see Xr memory_model 7 for further information . 56b94f4389SBrooks DavisIf 57b94f4389SBrooks Davis.Fa src 58b94f4389SBrooks Davisand 59b94f4389SBrooks Davis.Fa dst 60b94f4389SBrooks Davisoverlap, the results are not defined. 61*7f55dbe6SBrooks DavisThe 62*7f55dbe6SBrooks Davis.Fn memcpy_data 63*7f55dbe6SBrooks Davisfunction does the same except that it does not preserve the provenance 64*7f55dbe6SBrooks Davisof pointers in the copied object. 65*7f55dbe6SBrooks DavisOn CHERI targets, the validity tag of any copied capability is 66*7f55dbe6SBrooks Davisexplicitly cleared. 67b94f4389SBrooks Davis.Sh RETURN VALUES 68b94f4389SBrooks DavisThe 69b94f4389SBrooks Davis.Fn memcpy 70*7f55dbe6SBrooks Davisand 71*7f55dbe6SBrooks Davis.Fn memcpy_data 72*7f55dbe6SBrooks Davisfunctions return the original value of 73b94f4389SBrooks Davis.Fa dst . 74b94f4389SBrooks Davis.Sh SEE ALSO 75b94f4389SBrooks Davis.Xr bcopy 9 , 76*7f55dbe6SBrooks Davis.Xr memmove 9 , 77*7f55dbe6SBrooks Davis.Xr memmove_data 9 78b94f4389SBrooks Davis.Sh STANDARDS 79b94f4389SBrooks DavisThe 80b94f4389SBrooks Davis.Fn memcpy 81b94f4389SBrooks Davisfunction 82b94f4389SBrooks Davisconforms to 83b94f4389SBrooks Davis.St -isoC . 84b94f4389SBrooks Davis.Sh HISTORY 85b94f4389SBrooks DavisThe 86b94f4389SBrooks Davis.Fn memcpy 87b94f4389SBrooks Davisfunction first appeared in 88b94f4389SBrooks Davis.At V 89b94f4389SBrooks Davisand was reimplemented for 90b94f4389SBrooks Davis.Bx 4.3 Tahoe . 91*7f55dbe6SBrooks DavisThe 92*7f55dbe6SBrooks Davis.Fn memcpy_data 93*7f55dbe6SBrooks Davisfunction first appeared in 94*7f55dbe6SBrooks Davis.Fx 16.0 . 95