diff options
author | theraven <theraven@FreeBSD.org> | 2011-11-26 15:57:09 +0000 |
---|---|---|
committer | theraven <theraven@FreeBSD.org> | 2011-11-26 15:57:09 +0000 |
commit | 49d3428b08ba0d9c1f9103cbbe53c7a73c2dedda (patch) | |
tree | 0a5c3a8c4ae5bda58567333010a17fd23cfd1a69 /lib/libc/gen/_pthread_stubs.c | |
parent | 06e8068f727d20085e56d3ea79913edf5b1dce44 (diff) | |
download | FreeBSD-src-49d3428b08ba0d9c1f9103cbbe53c7a73c2dedda.zip FreeBSD-src-49d3428b08ba0d9c1f9103cbbe53c7a73c2dedda.tar.gz |
Return not-implemented from pthread_once and pthread_key_create, rather
than silently failing and returning success.
Without this, code calls pthread_once(), receives a return value of
success, and thinks that the passed function has been called.
Approved by: dim (mentor)
Diffstat (limited to 'lib/libc/gen/_pthread_stubs.c')
-rw-r--r-- | lib/libc/gen/_pthread_stubs.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/libc/gen/_pthread_stubs.c b/lib/libc/gen/_pthread_stubs.c index 355b904..98830ea 100644 --- a/lib/libc/gen/_pthread_stubs.c +++ b/lib/libc/gen/_pthread_stubs.c @@ -30,6 +30,7 @@ __FBSDID("$FreeBSD$"); #include <signal.h> #include <pthread.h> #include <stdlib.h> +#include <errno.h> #include "libc_private.h" @@ -53,6 +54,7 @@ static int stub_main(void); static void *stub_null(void); static struct pthread *stub_self(void); static int stub_zero(void); +static int stub_fail(void); static int stub_true(void); static void stub_exit(void); @@ -93,7 +95,7 @@ pthread_func_entry_t __thr_jtable[PJT_MAX] = { {PJT_DUAL_ENTRY(stub_exit)}, /* PJT_EXIT */ {PJT_DUAL_ENTRY(stub_null)}, /* PJT_GETSPECIFIC */ {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_JOIN */ - {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_KEY_CREATE */ + {PJT_DUAL_ENTRY(stub_fail)}, /* PJT_KEY_CREATE */ {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_KEY_DELETE */ {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_KILL */ {PJT_DUAL_ENTRY(stub_main)}, /* PJT_MAIN_NP */ @@ -105,7 +107,7 @@ pthread_func_entry_t __thr_jtable[PJT_MAX] = { {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_MUTEX_LOCK */ {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_MUTEX_TRYLOCK */ {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_MUTEX_UNLOCK */ - {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_ONCE */ + {PJT_DUAL_ENTRY(stub_fail)}, /* PJT_ONCE */ {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_RWLOCK_DESTROY */ {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_RWLOCK_INIT */ {PJT_DUAL_ENTRY(stub_zero)}, /* PJT_RWLOCK_RDLOCK */ @@ -293,6 +295,12 @@ stub_self(void) } static int +stub_fail(void) +{ + return ENOSYS; +} + +static int stub_main(void) { return (-1); |