Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libc / src / pthread / pthread_attr_getstack.cpp
blob8788fbc1ffdd33b9d22bd7554322f565bf467cfe
1 //===-- Implementation of the pthread_attr_getstack -----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "pthread_attr_getstack.h"
10 #include "pthread_attr_getstacksize.h"
12 #include "src/__support/common.h"
13 #include "src/__support/macros/optimization.h"
15 #include <pthread.h>
17 namespace LIBC_NAMESPACE {
19 LLVM_LIBC_FUNCTION(int, pthread_attr_getstack,
20 (const pthread_attr_t *__restrict attr,
21 void **__restrict stack, size_t *__restrict stacksize)) {
22 // As of writing this `pthread_attr_getstacksize` can never fail.
23 int result = LIBC_NAMESPACE::pthread_attr_getstacksize(attr, stacksize);
24 if (LIBC_UNLIKELY(result != 0))
25 return result;
26 *stack = attr->__stack;
27 return 0;
30 } // namespace LIBC_NAMESPACE