From 98d13090d6fcf0f1646e2c037c83745805455d0a Mon Sep 17 00:00:00 2001 From: bje Date: Sun, 12 Jul 1998 15:07:25 +0000 Subject: 1998-07-13 Ben Elliston * condvar.c (pthread_condattr_init): Implement. (pthread_condattr_destroy): Likewise. (pthread_condattr_setpshared): Likewise. (pthread_condattr_getpshared): Likewise. --- condvar.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 condvar.c (limited to 'condvar.c') 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; +} -- cgit v1.2.3