1*db8a88feSMichael Jones //===-- Implementation of mempcpy ----------------------------------------===//
2*db8a88feSMichael Jones //
3*db8a88feSMichael Jones // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*db8a88feSMichael Jones // See https://llvm.org/LICENSE.txt for license information.
5*db8a88feSMichael Jones // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*db8a88feSMichael Jones //
7*db8a88feSMichael Jones //===----------------------------------------------------------------------===//
8*db8a88feSMichael Jones 
9*db8a88feSMichael Jones #include "src/string/mempcpy.h"
10*db8a88feSMichael Jones #include "src/string/memcpy.h"
11*db8a88feSMichael Jones 
12*db8a88feSMichael Jones #include "src/__support/common.h"
13*db8a88feSMichael Jones #include <stddef.h> // For size_t.
14*db8a88feSMichael Jones 
15*db8a88feSMichael Jones namespace __llvm_libc {
16*db8a88feSMichael Jones 
17*db8a88feSMichael Jones LLVM_LIBC_FUNCTION(void *, mempcpy,
18*db8a88feSMichael Jones                    (void *__restrict dest, const void *__restrict src,
19*db8a88feSMichael Jones                     size_t count)) {
20*db8a88feSMichael Jones   void *result = __llvm_libc::memcpy(dest, src, count);
21*db8a88feSMichael Jones   return result == nullptr
22*db8a88feSMichael Jones              ? result
23*db8a88feSMichael Jones              : static_cast<void *>(static_cast<char *>(result) + count);
24*db8a88feSMichael Jones }
25*db8a88feSMichael Jones 
26*db8a88feSMichael Jones } // namespace __llvm_libc
27