svn commit: r227999 - head/lib/libc/gen
David Chisnall
theraven at FreeBSD.org
Sat Nov 26 15:57:10 UTC 2011
Author: theraven
Date: Sat Nov 26 15:57:09 2011
New Revision: 227999
URL: http://svn.freebsd.org/changeset/base/227999
Log:
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)
Modified:
head/lib/libc/gen/_pthread_stubs.c
Modified: head/lib/libc/gen/_pthread_stubs.c
==============================================================================
--- head/lib/libc/gen/_pthread_stubs.c Sat Nov 26 14:26:37 2011 (r227998)
+++ head/lib/libc/gen/_pthread_stubs.c Sat Nov 26 15:57:09 2011 (r227999)
@@ -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_MA
{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_MA
{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);
More information about the svn-src-head
mailing list