1203aff2dSNoah Goldstein //===-- Implementation of sched_yield -------------------------------------===// 2203aff2dSNoah Goldstein // 3203aff2dSNoah Goldstein // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4203aff2dSNoah Goldstein // See https://llvm.org/LICENSE.txt for license information. 5203aff2dSNoah Goldstein // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6203aff2dSNoah Goldstein // 7203aff2dSNoah Goldstein //===----------------------------------------------------------------------===// 8203aff2dSNoah Goldstein 9203aff2dSNoah Goldstein #include "src/sched/sched_yield.h" 10203aff2dSNoah Goldstein 11203aff2dSNoah Goldstein #include "src/__support/OSUtil/syscall.h" // For internal syscall function. 12203aff2dSNoah Goldstein #include "src/__support/common.h" 13*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 14203aff2dSNoah Goldstein #include "src/errno/libc_errno.h" 15203aff2dSNoah Goldstein 16203aff2dSNoah Goldstein #include <sys/syscall.h> // For syscall numbers. 17203aff2dSNoah Goldstein 18*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 19203aff2dSNoah Goldstein 20203aff2dSNoah Goldstein LLVM_LIBC_FUNCTION(int, sched_yield, ()) { 21b6bc9d72SGuillaume Chatelet int ret = LIBC_NAMESPACE::syscall_impl<int>(SYS_sched_yield); 22203aff2dSNoah Goldstein // As of writing this, yield() cannot fail 23203aff2dSNoah Goldstein if (ret < 0) { 24203aff2dSNoah Goldstein libc_errno = -ret; 25203aff2dSNoah Goldstein return -1; 26203aff2dSNoah Goldstein } 27203aff2dSNoah Goldstein return 0; 28203aff2dSNoah Goldstein } 29203aff2dSNoah Goldstein 30*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 31