diff options
author | bje <bje> | 1998-07-12 15:07:25 +0000 |
---|---|---|
committer | bje <bje> | 1998-07-12 15:07:25 +0000 |
commit | 98d13090d6fcf0f1646e2c037c83745805455d0a (patch) | |
tree | 5e6f14bed4174655cf41b50c42b8ab967e60c88e | |
parent | fcffe39c2af8374e7c994dac0b6bc0719c6a561f (diff) |
1998-07-13 Ben Elliston <bje@cygnus.com>
* condvar.c (pthread_condattr_init): Implement.
(pthread_condattr_destroy): Likewise.
(pthread_condattr_setpshared): Likewise.
(pthread_condattr_getpshared): Likewise.
-rw-r--r-- | condvar.c | 65 |
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; +} |