summaryrefslogtreecommitdiff
path: root/libc/src/pthread/pthread_attr_init.cpp
diff options
context:
space:
mode:
authorSiva Chandra Reddy <sivachandra@google.com>2022-04-08 08:07:22 +0000
committerSiva Chandra Reddy <sivachandra@google.com>2022-04-11 16:08:49 +0000
commit0258f566466268704caa2476f20e4a87a6257d06 (patch)
treec4d958a5f2881305de83c67bceab39d63697f3f7 /libc/src/pthread/pthread_attr_init.cpp
parent1c8366f9f2aa436538949aa2b76f96980bb0de27 (diff)
[libc] Add a definition of pthread_attr_t and its getters and setters.
Not all attributes have been added to phtread_attr_t in this patch. They will be added gradually in future patches. Reviewed By: lntue Differential Revision: https://reviews.llvm.org/D123423
Diffstat (limited to 'libc/src/pthread/pthread_attr_init.cpp')
-rw-r--r--libc/src/pthread/pthread_attr_init.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/libc/src/pthread/pthread_attr_init.cpp b/libc/src/pthread/pthread_attr_init.cpp
new file mode 100644
index 000000000000..84b352022874
--- /dev/null
+++ b/libc/src/pthread/pthread_attr_init.cpp
@@ -0,0 +1,28 @@
+//===-- Implementation of the pthread_attr_init ---------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "pthread_attr_init.h"
+
+#include "src/__support/common.h"
+
+#include <linux/param.h> // For EXEC_PAGESIZE.
+#include <pthread.h>
+
+namespace __llvm_libc {
+
+LLVM_LIBC_FUNCTION(int, pthread_attr_init, (pthread_attr_t * attr)) {
+ *attr = pthread_attr_t{
+ false, // Not detached
+ nullptr, // Let the thread manage its stack
+ 1 << 16, // 64KB stack size
+ EXEC_PAGESIZE, // Default page size for the guard size.
+ };
+ return 0;
+}
+
+} // namespace __llvm_libc