diff options
author | rpj <rpj> | 1998-07-22 16:42:53 +0000 |
---|---|---|
committer | rpj <rpj> | 1998-07-22 16:42:53 +0000 |
commit | f33f4460f9de9c2d2ae6f3bf05caed391c6ad485 (patch) | |
tree | 12bb86525d369c1c4de220bb58d92d3eab2f5a7e /attr.c | |
parent | b84f1cc523f4236200689b2f78b16b26bc05f429 (diff) |
Wed Jul 22 00:16:22 1998 Ross Johnson <rpj@ixobrychus.canberra.edu.au>
* attr.c, implement.h, pthread.h, ChangeLog: Resolve CVS merge
conflicts.
* private.c (_pthread_find_thread_entry): Changes to return type
to support leaner _pthread_threads_table[] which now only stores
_pthread_thread_thread_t *.
(_pthread_new_thread_entry): Internal changes.
(_pthread_delete_thread_entry): Internal changes to avoid contention.
Calling routines changed accordingly.
* pthread.h: Modified cleanup macros to use new generic push and pop.
Added destructor and atfork stacks to _pthread_threads_thread_t.
* cleanup.c (_pthread_handler_push, _pthread_handler_pop,
_pthread_handler_pop_all): Renamed cleanup push and pop routines
and made generic to handle destructors and atfork handlers as
well.
* create.c (_pthread_start_call): New function is a wrapper for
all new threads. It allows us to do some cleanup when the thread
returns, ie. that is otherwise only done if the thread is cancelled.
* exit.c (_pthread_vacuum): New function contains code from
pthread_exit() that we need in the new _pthread_start_call()
as well.
* implement.h: Various additions and minor changes.
* pthread.h: Various additions and minor changes.
Change cleanup handler macros to use generic handler push and pop
functions.
* attr.c: Minor mods to all functions.
(is_attr): Implemented missing function.
* create.c (pthread_create): More clean up.
* private.c (_pthread_find_thread_entry): Implement.
(_pthread_delete_thread_entry): Implement.
(_pthread_new_thread_entry): Implement.
These functions manipulate the implementations internal thread
table and are part of general code cleanup and modularisation.
They replace _pthread_getthreadindex() which was removed.
* exit.c (pthread_exit): Changed to use the new code above.
* pthread.h: Add cancelability constants. Update comments.
Diffstat (limited to 'attr.c')
-rw-r--r-- | attr.c | 41 |
1 files changed, 32 insertions, 9 deletions
@@ -8,6 +8,16 @@ #include "pthread.h" #include "implement.h" +static int +is_attr(pthread_attr_t *attr) +{ + /* Return 0 if the attr object is valid, 1 otherwise. */ + + return (attr == NULL || attr->valid != _PTHREAD_ATTR_VALID); +} + +#ifdef _POSIX_THREAD_ATTR_STACKSIZE + int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize) @@ -18,7 +28,7 @@ pthread_attr_setstacksize(pthread_attr_t *attr, return EINVAL; } - if (attr == NULL) + if (is_attr(attr) != 0) { return EINVAL; } @@ -32,7 +42,7 @@ int pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) { - if (attr == NULL) + if (is_attr(attr) != 0) { return EINVAL; } @@ -42,11 +52,15 @@ pthread_attr_getstacksize(const pthread_attr_t *attr, return 0; } +#endif /* _POSIX_THREAD_ATTR_STACKSIZE */ + +#ifdef _POSIX_THREAD_ATTR_STACKADDR + int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr) { - if (attr == NULL) + if (is_attr(attr) != 0) { return EINVAL; } @@ -59,7 +73,7 @@ int pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr) { - if (attr == NULL) + if (is_attr(attr) != 0) { return EINVAL; } @@ -68,6 +82,9 @@ pthread_attr_getstackaddr(const pthread_attr_t *attr, return ENOSYS; } +#endif /* _POSIX_THREAD_ATTR_STACKADDR */ + + int pthread_attr_init(pthread_attr_t *attr) { @@ -77,8 +94,12 @@ pthread_attr_init(pthread_attr_t *attr) return EINVAL; } - /* FIXME: Fill out the structure with default values. */ - attr->stacksize = 0; +#ifdef _POSIX_THREAD_ATTR_STACKSIZE + attr->stacksize = PTHREAD_STACK_MIN; +#endif + + attr->cancelability = _PTHREAD_CANCEL_DEFAULTS; + attr->valid = 0; return 0; } @@ -86,11 +107,13 @@ pthread_attr_init(pthread_attr_t *attr) int pthread_attr_destroy(pthread_attr_t *attr) { - if (attr == NULL) + if (is_attr(attr) != 0) { return EINVAL; } - - /* Nothing to do. */ + + /* Set the attribute object to a specific invalid value. */ + attr->valid = _PTHREAD_ATTR_INVALID; + return 0; } |