summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--attr.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/attr.c b/attr.c
index 6f89672..0e72575 100644
--- a/attr.c
+++ b/attr.c
@@ -100,12 +100,45 @@ pthread_attr_init(pthread_attr_t *attr)
attr->cancelability = PTHREAD_CANCEL_ENABLE;
attr->canceltype = PTHREAD_CANCEL_DEFERRED;
+ attr->detached = PTHREAD_CREATE_JOINABLE;
attr->valid = 0;
return 0;
}
int
+pthread_attr_getdetachstate(const pthread_attr_t *attr,
+ int *detachstate)
+{
+ if (is_attr(attr) != 0 || detachstate == NULL)
+ {
+ return EINVAL;
+ }
+
+ *detachstate = attr->detached;
+ return 0;
+}
+
+int
+pthread_attr_setdetachstate(pthread_attr_t *attr,
+ int detachstate)
+{
+ if (is_attr(attr) != 0)
+ {
+ return EINVAL;
+ }
+
+ if (detachstate != PTHREAD_CREATE_JOINABLE ||
+ detachstate != PTHREAD_CREATE_DETACHED)
+ {
+ return EINVAL;
+ }
+
+ attr->detached = detachstate;
+ return 0;
+}
+
+int
pthread_attr_destroy(pthread_attr_t *attr)
{
if (is_attr(attr) != 0)