| //===----------------------------------------------------------------------===// | |
| // | |
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | |
| // See https://llvm.org/LICENSE.txt for license information. | |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | |
| // | |
| //===----------------------------------------------------------------------===// | |
| /// | |
| /// \file | |
| /// Linux implementation of __sched_cpualloc. | |
| /// | |
| //===----------------------------------------------------------------------===// | |
| #include "src/sched/sched_cpualloc.h" | |
| #include "hdr/errno_macros.h" | |
| #include "hdr/sched_macros.h" | |
| #include "hdr/stdint_proxy.h" | |
| #include "hdr/types/cpu_set_t.h" | |
| #include "hdr/types/size_t.h" | |
| #include "src/__support/checked_ptr.h" | |
| #include "src/__support/common.h" | |
| #include "src/__support/libc_errno.h" | |
| #include "src/__support/macros/config.h" | |
| namespace LIBC_NAMESPACE_DECL { | |
| LLVM_LIBC_FUNCTION(cpu_set_t *, __sched_cpualloc, (size_t count)) { | |
| CheckedPtr<uint8_t[]> bytes = | |
| make_unique_for_overwrite<uint8_t[]>(CPU_ALLOC_SIZE(count)); | |
| if (!bytes) { | |
| libc_errno = ENOMEM; | |
| return nullptr; | |
| } | |
| return reinterpret_cast<cpu_set_t *>(bytes.release()); | |
| } | |
| } // namespace LIBC_NAMESPACE_DECL |