1e3638e83SSiva Chandra Reddy //===-- Linux implementation of wait --------------------------------------===// 2e3638e83SSiva Chandra Reddy // 3e3638e83SSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4e3638e83SSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information. 5e3638e83SSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6e3638e83SSiva Chandra Reddy // 7e3638e83SSiva Chandra Reddy //===----------------------------------------------------------------------===// 8e3638e83SSiva Chandra Reddy 9e3638e83SSiva Chandra Reddy #include "src/__support/common.h" 10c9783d2bSMikhail R. Gadelha #include "src/__support/libc_assert.h" 11e3638e83SSiva Chandra Reddy 12*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h" 13c9783d2bSMikhail R. Gadelha #include "src/sys/wait/wait.h" 14c9783d2bSMikhail R. Gadelha #include "src/sys/wait/wait4Impl.h" 15e3638e83SSiva Chandra Reddy 16*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL { 17e3638e83SSiva Chandra Reddy 18e3638e83SSiva Chandra Reddy LLVM_LIBC_FUNCTION(pid_t, wait, (int *wait_status)) { 19c9783d2bSMikhail R. Gadelha auto result = internal::wait4impl(-1, wait_status, 0, 0); 20c9783d2bSMikhail R. Gadelha if (!result.has_value()) { 21c9783d2bSMikhail R. Gadelha libc_errno = result.error(); 22e3638e83SSiva Chandra Reddy return -1; 23e3638e83SSiva Chandra Reddy } 24c9783d2bSMikhail R. Gadelha return result.value(); 25e3638e83SSiva Chandra Reddy } 26e3638e83SSiva Chandra Reddy 27*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL 28