diff options
| -rw-r--r-- | ChangeLog | 16 | ||||
| -rw-r--r-- | attr.c | 24 | ||||
| -rw-r--r-- | implement.h | 8 | ||||
| -rw-r--r-- | mutex.c | 29 | ||||
| -rw-r--r-- | pthread.h | 4 | 
5 files changed, 30 insertions, 51 deletions
| @@ -1,6 +1,22 @@  1998-07-22  Ben Elliston  <bje@cygnus.com> +	* 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. @@ -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 */ @@ -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)  { @@ -27,6 +27,10 @@ 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 };    /* Signal and broadcast event HANDLEs. */ | 
