Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpthread add assertions



details:   https://anonhg.NetBSD.org/src/rev/f5a8cab3d02f
branches:  trunk
changeset: 785257:f5a8cab3d02f
user:      yamt <yamt%NetBSD.org@localhost>
date:      Wed Mar 06 11:30:56 2013 +0000

description:
add assertions

diffstat:

 lib/libpthread/pthread_specific.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r 4e472418dc09 -r f5a8cab3d02f lib/libpthread/pthread_specific.c
--- a/lib/libpthread/pthread_specific.c Wed Mar 06 11:29:01 2013 +0000
+++ b/lib/libpthread/pthread_specific.c Wed Mar 06 11:30:56 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pthread_specific.c,v 1.24 2012/11/21 19:19:24 christos Exp $   */
+/*     $NetBSD: pthread_specific.c,v 1.25 2013/03/06 11:30:56 yamt Exp $       */
 
 /*-
  * Copyright (c) 2001, 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: pthread_specific.c,v 1.24 2012/11/21 19:19:24 christos Exp $");
+__RCSID("$NetBSD: pthread_specific.c,v 1.25 2013/03/06 11:30:56 yamt Exp $");
 
 /* Functions and structures dealing with thread-specific data */
 
@@ -75,8 +75,12 @@
 unsigned int
 pthread_curcpu_np(void)
 {
+       const int curcpu = pthread__self()->pt_lwpctl->lc_curcpu;
 
-       return pthread__self()->pt_lwpctl->lc_curcpu;
+       pthread__assert(curcpu != LWPCTL_CPU_NONE);
+       pthread__assert(curcpu != LWPCTL_CPU_EXITED);
+       pthread__assert(curcpu >= 0);
+       return curcpu;
 }
 
 /*



Home | Main Index | Thread Index | Old Index