blob: 0a5d1af661abfaf76b4c5a2afd3ca1b4b04482e4 [file] [log] [blame]
Siva Chandra Reddy0258f562022-04-08 08:07:22 +00001//===-- Implementation of the pthread_attr_setstacksize -----------------===//
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//===----------------------------------------------------------------------===//
8
9#include "pthread_attr_setstacksize.h"
10
11#include "src/__support/common.h"
Petr Hosek5ff3ff32024-07-12 09:28:41 -070012#include "src/__support/macros/config.h"
Job Henandez Lara46944b02024-10-05 16:31:36 -070013#include "src/errno/libc_errno.h"
Siva Chandra Reddy0258f562022-04-08 08:07:22 +000014
Siva Chandra Reddy0258f562022-04-08 08:07:22 +000015#include <pthread.h>
16
Petr Hosek5ff3ff32024-07-12 09:28:41 -070017namespace LIBC_NAMESPACE_DECL {
Siva Chandra Reddy0258f562022-04-08 08:07:22 +000018
19LLVM_LIBC_FUNCTION(int, pthread_attr_setstacksize,
20 (pthread_attr_t *__restrict attr, size_t stacksize)) {
Noah Goldstein6a185712023-04-20 15:05:04 -050021 // TODO: Should we also ensure stacksize % EXEC_PAGESIZE == 0?
Siva Chandra Reddy0258f562022-04-08 08:07:22 +000022 if (stacksize < PTHREAD_STACK_MIN)
23 return EINVAL;
24 attr->__stack = nullptr;
25 attr->__stacksize = stacksize;
26 return 0;
27}
28
Petr Hosek5ff3ff32024-07-12 09:28:41 -070029} // namespace LIBC_NAMESPACE_DECL