From ac165ba9bfdfd92f62c65ab0449852eff7bd4d91 Mon Sep 17 00:00:00 2001 From: bje Date: Wed, 22 Jul 1998 09:22:58 +0000 Subject: i1998-07-22 Ben Elliston * attr.c (pthread_setstacksize): Update test of attr argument. (pthread_getstacksize): Likewise. (pthread_setstackaddr): Likewise. (pthread_getstackaddr): Likewise. (pthread_attr_init): No need to allocate any storage. (pthread_attr_destroy): No need to free any storage. * mutex.c (is_attr): Not likely to be needed; remove. (remove_attr): Likewise. (insert_attr): Likewise. * pthread.h (pthread_attr_t): Moved here from implement.h. * implement.h (_pthread_mutexattr_t): Moved to a public definition in pthread.h. There was little gain in hiding these details. (_pthread_condattr_t): Likewise. --- ChangeLog | 16 ++++++++++++++++ attr.c | 24 ++++++++++-------------- implement.h | 8 -------- mutex.c | 29 ----------------------------- pthread.h | 4 ++++ 5 files changed, 30 insertions(+), 51 deletions(-) diff --git a/ChangeLog b/ChangeLog index 35b3d82..4d7c4ae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,22 @@ 1998-07-22 Ben Elliston + * attr.c (pthread_setstacksize): Update test of attr argument. + (pthread_getstacksize): Likewise. + (pthread_setstackaddr): Likewise. + (pthread_getstackaddr): Likewise. + (pthread_attr_init): No need to allocate any storage. + (pthread_attr_destroy): No need to free any storage. + + * mutex.c (is_attr): Not likely to be needed; remove. + (remove_attr): Likewise. + (insert_attr): Likewise. + + * implement.h (_pthread_mutexattr_t): Moved to a public definition + in pthread.h. There was little gain in hiding these details. + (_pthread_condattr_t): Likewise. + * pthread.h (pthread_atfork): Add function prototype. + (pthread_attr_t): Moved here from implement.h. * fork.c (pthread_atfork): Preliminary implementation. (_pthread_fork): Likewise. diff --git a/attr.c b/attr.c index a99cf53..1b4f348 100644 --- a/attr.c +++ b/attr.c @@ -18,13 +18,13 @@ pthread_attr_setstacksize(pthread_attr_t *attr, return EINVAL; } - if (is_attr(attr) != 0) + if (attr == NULL) { return EINVAL; } /* Everything is okay. */ - (_pthread_attr_t *) (attr->ptr)->stacksize = stacksize; + attr->stacksize = stacksize; return 0; } @@ -32,13 +32,13 @@ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) { - if (is_attr(attr) != 0) + if (attr == NULL) { return EINVAL; } /* Everything is okay. */ - *stacksize = (_pthread_attr_t *) (attr->ptr)->stacksize; + *stacksize = attr->stacksize; return 0; } @@ -46,7 +46,7 @@ int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr) { - if ((is_attr(attr) != 0)) + if (attr == NULL) { return EINVAL; } @@ -59,7 +59,7 @@ int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr) { - if ((is_attr(attr) != 0)) + if (attr == NULL) { return EINVAL; } @@ -77,24 +77,20 @@ pthread_attr_init(pthread_attr_t *attr) return EINVAL; } - attr->ptr = malloc(sizeof(_pthread_attr_t)); - if (attr->ptr == NULL) - { - return ENOMEM; - } - /* FIXME: Fill out the structure with default values. */ + attr->stacksize = 0; + return 0; } int pthread_attr_destroy(pthread_attr_t *attr) { - if (is_attr(attr) != 0) + if (attr == NULL) { return EINVAL; } - free (attr->ptr); + /* Nothing to do. */ return 0; } diff --git a/implement.h b/implement.h index 2a7e192..4f9a3e2 100644 --- a/implement.h +++ b/implement.h @@ -35,14 +35,6 @@ typedef struct { size_t stacksize; } _pthread_attr_t; -typedef struct { - /* Nothing needed yet. */ -} _pthread_mutexattr_t; - -typedef struct { - /* Nothing needed yet. */ -} _pthread_condattr_t; - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ diff --git a/mutex.c b/mutex.c index da8737a..7633f91 100644 --- a/mutex.c +++ b/mutex.c @@ -8,35 +8,6 @@ #include "pthread.h" #include "implement.h" -static int -insert_attr(pthread_mutexattr_t *attr) -{ - /* Add this attribute object to a list. */ - - /* FIXME: implement using some dynamic scheme. */ - return 0; -} - -static int -is_attr(pthread_mutexattr_t *attr) -{ - /* Return 0 if present, 1 otherwise. */ - - /* FIXME: implement. For now, pretend the attribute is always okay, unless - it is NULL. */ - - return (attr == NULL) ? 1 : 0; -} - -static int -remove_attr(pthread_mutexattr_t *attr) -{ - /* Remove this attribute object from the list. */ - - /* FIXME: implement. */ - return 0; -} - int pthread_mutex_init(pthread_mutex_t *mutex, pthread_mutex_attr_t *attr) { diff --git a/pthread.h b/pthread.h index 82b1a93..a3bd854 100644 --- a/pthread.h +++ b/pthread.h @@ -26,6 +26,10 @@ typedef HANDLE pthread_t; typedef CRITICAL_SECTION pthread_mutex_t; typedef DWORD pthread_key_t; +typedef struct { + size_t stacksize; +} pthread_attr_t; + typedef struct { enum { SIGNAL, BROADCAST, NUM_EVENTS }; -- cgit v1.2.3