diff options
author | rpj <rpj> | 2001-02-09 06:51:30 +0000 |
---|---|---|
committer | rpj <rpj> | 2001-02-09 06:51:30 +0000 |
commit | 1648c7a97f27d10ad302c6141562ece01065e1d7 (patch) | |
tree | c16f939acf7ac98db38039d747f5804d04c33fe1 /nonportable.c | |
parent | 2b3eede0b834a82c7dce5ec328f3929c0effc536 (diff) |
Remodeled mutex routines again to eliminate critical sections.
Diffstat (limited to 'nonportable.c')
-rw-r--r-- | nonportable.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/nonportable.c b/nonportable.c index 17cbc60..27b67df 100644 --- a/nonportable.c +++ b/nonportable.c @@ -248,3 +248,59 @@ pthread_win32_thread_detach_np () return TRUE; } + + +/* + * pthread_mutex_setdefaulttype_np -- + * + * Sets the default type to be given to all + * POSIX mutexes initialised after the function + * is called. Any of the following type values + * can be made the default type: + * + * PTHREAD_MUTEX_NORMAL + * PTHREAD_MUTEX_ERRORCHECK + * PTHREAD_MUTEX_RECURSIVE + * PTHREAD_MUTEX_DEFAULT + * + * Any mutex initialised with type PTHREAD_MUTEX_DEFAULT + * will be set to the mapped type instead. Previously + * initialised mutexes are not changed. + * + * When set to PTHREAD_MUTEX_DEFAULT (the initial + * value), mutexes will behave as for the + * PTHREAD_MUTEX_RECURSIVE type. + * + * If 'oldtype' is a non-NULL pointer, the previous type is + * returned through it. + * To get the previous type without setting a new type, + * use -1 as the 'newtype' value. Of course, the following: + * + * pthread_mutex_setdefaulttype_np(-1, NULL); + * + * is then an extravagant equivalent to the value 0 (zero). + */ +int +pthread_mutex_setdefaulttype_np (int newtype, int * oldtype) +{ + int result = 0; + + if (oldtype != NULL) + { + *oldType = ptw32_mutex_mapped_default; + } + + switch (newtype) + { + case PTHREAD_MUTEX_DEFAULT: + case PTHREAD_MUTEX_NORMAL: + case PTHREAD_MUTEX_ERRORCHECK: + case PTHREAD_MUTEX_RECURSIVE: + ptw32_mutex_mapped_default = newtype; + break; + default: + result = EINVAL; + } + + return result; +} |