summaryrefslogtreecommitdiff
path: root/condvar.c
diff options
context:
space:
mode:
Diffstat (limited to 'condvar.c')
-rw-r--r--condvar.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/condvar.c b/condvar.c
new file mode 100644
index 0000000..871f50d
--- /dev/null
+++ b/condvar.c
@@ -0,0 +1,65 @@
+/*
+ * condvar.c
+ *
+ * Description:
+ * This translation unit implements condition variables and their primitives.
+ */
+
+#include "pthread.h"
+
+int
+pthread_cond_init(pthread_condattr_t *attr)
+{
+ if (attr == NULL)
+ {
+ /* This is disallowed. */
+ return EINVAL;
+ }
+
+ attr->ptr = malloc(sizeof(_pthread_condattr_t));
+ if (attr->ptr == NULL)
+ {
+ return ENOMEM;
+ }
+
+ /* FIXME: fill out the structure with default values. */
+ return 0;
+}
+
+int
+pthread_condattr_destroy(pthread_condattr_t *attr)
+{
+ if (is_attr(attr) != 0)
+ {
+ return EINVAL;
+ }
+
+ free(attr->ptr);
+ return 0;
+}
+
+int
+pthread_condattr_setpshared(pthread_condattr_t *attr,
+ int pshared)
+{
+ if (is_attr(attr) != 0)
+ {
+ return EINVAL;
+ }
+
+ (_pthread_condattr_t *) (attr->ptr)->pshared = pshared;
+ return 0;
+}
+
+int
+pthread_condattr_getpshared(pthread_condattr_t *attr,
+ int *pshared)
+{
+ if (is_attr(attr) != 0)
+ {
+ return EINVAL;
+ }
+
+ *pshared = (_pthread_condattr_t *) (attr->ptr)->pshared;
+ return 0;
+}