summaryrefslogtreecommitdiff
path: root/lib/libpthread
diff options
context:
space:
mode:
authorad <ad@NetBSD.org>2007-11-27 20:58:26 +0000
committerad <ad@NetBSD.org>2007-11-27 20:58:26 +0000
commit4084ca7f3fe50b29ad22fa4aa4049e62cd065573 (patch)
tree1ac442f21ae2bf1a27714f839e8a7809791273fd /lib/libpthread
parentd5e9b90716f622207f1403ab0be58282fdb2f2b6 (diff)
Add thr_curcpu(), pthread_curcpu_np().
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/pthread.h6
-rw-r--r--lib/libpthread/pthread_specific.c15
2 files changed, 18 insertions, 3 deletions
diff --git a/lib/libpthread/pthread.h b/lib/libpthread/pthread.h
index f4309a3f7ff..296b74d61c3 100644
--- a/lib/libpthread/pthread.h
+++ b/lib/libpthread/pthread.h
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread.h,v 1.22 2007/11/14 19:28:24 drochner Exp $ */
+/* $NetBSD: pthread.h,v 1.23 2007/11/27 20:58:26 ad Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -137,6 +137,8 @@ int pthread_attr_setcreatesuspend_np(pthread_attr_t *);
int pthread_suspend_np(pthread_t);
int pthread_resume_np(pthread_t);
+unsigned int pthread_curcpu_np(void);
+
struct pthread_cleanup_store {
void *pad[4];
};
@@ -347,6 +349,7 @@ pthread_t __libc_thr_self(void);
void __libc_thr_exit(void *) __attribute__((__noreturn__));
int __libc_thr_setcancelstate(int, int *);
int __libc_thr_equal(pthread_t, pthread_t);
+unsigned int __libc_thr_curcpu(void);
__END_DECLS
#define pthread_once __libc_thr_once
@@ -354,6 +357,7 @@ __END_DECLS
#define pthread_exit __libc_thr_exit
#define pthread_setcancelstate __libc_thr_setcancelstate
#define pthread_equal __libc_thr_equal
+#define pthread_curcpu_np __libc_thr_curcpu
#endif /* __LIBPTHREAD_SOURCE__ */
diff --git a/lib/libpthread/pthread_specific.c b/lib/libpthread/pthread_specific.c
index d13ee9027ad..1fe148e4ff8 100644
--- a/lib/libpthread/pthread_specific.c
+++ b/lib/libpthread/pthread_specific.c
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_specific.c,v 1.12 2007/11/13 01:21:32 ad Exp $ */
+/* $NetBSD: pthread_specific.c,v 1.13 2007/11/27 20:58:26 ad Exp $ */
/*-
* Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -37,15 +37,18 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_specific.c,v 1.12 2007/11/13 01:21:32 ad Exp $");
+__RCSID("$NetBSD: pthread_specific.c,v 1.13 2007/11/27 20:58:26 ad Exp $");
/* Functions and structures dealing with thread-specific data */
#include "pthread.h"
#include "pthread_int.h"
+#include <sys/lwpctl.h>
+
__strong_alias(__libc_thr_setspecific,pthread_setspecific)
__strong_alias(__libc_thr_getspecific,pthread_getspecific)
+__strong_alias(__libc_thr_curcpu,pthread_curcpu_np)
int
pthread_setspecific(pthread_key_t key, const void *value)
@@ -69,5 +72,13 @@ pthread_setspecific(pthread_key_t key, const void *value)
void *
pthread_getspecific(pthread_key_t key)
{
+
return pthread__self()->pt_specific[key];
}
+
+unsigned int
+pthread_curcpu_np(void)
+{
+
+ return pthread__self()->pt_lwpctl->lc_curcpu;
+}