From 49155d9325425744ca9fdff8781c1681a63a7a83 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Fri, 1 Mar 2002 17:45:33 +0000 Subject: 2002-03-01 Eric Norum * libc/gxx_wrappers.c: Task is not preemptable while running a pthread_once init function. This is slightly less heavy handed than disabling dispatching and seems better than consuming a mutex. --- c/src/exec/libcsupport/src/gxx_wrappers.c | 19 +++++++++---------- c/src/lib/ChangeLog | 6 ++++++ c/src/lib/libc/gxx_wrappers.c | 19 +++++++++---------- cpukit/libcsupport/src/gxx_wrappers.c | 19 +++++++++---------- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/c/src/exec/libcsupport/src/gxx_wrappers.c b/c/src/exec/libcsupport/src/gxx_wrappers.c index bf3d41cde1..48f91aff19 100644 --- a/c/src/exec/libcsupport/src/gxx_wrappers.c +++ b/c/src/exec/libcsupport/src/gxx_wrappers.c @@ -63,17 +63,16 @@ int rtems_gxx_once(__gthread_once_t *once, void (*func) ()) #ifdef DEBUG_GXX_WRAPPERS printk( "gxx_wrappers: once=%x, func=%x\n", *once, func ); #endif - if( *once == 0 ) + if( *(volatile __gthread_once_t *)once == 0 ) { - /* - * NOTE: could not use the call to disable "preemption", it causes - * one exception. Somebody might want to investiage it further - * sometime later. - */ - _Thread_Disable_dispatch(); - *once = 1; - (*func)(); - _Thread_Enable_dispatch(); + rtems_mode saveMode; + rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &saveMode); + if( *(volatile __gthread_once_t *)once == 0 ) + { + *(volatile __gthread_once_t *)once = 1; + (*func)(); + } + rtems_task_mode(saveMode, RTEMS_PREEMPT_MASK, &saveMode); } return 0; } diff --git a/c/src/lib/ChangeLog b/c/src/lib/ChangeLog index 06da663a58..0be8ed83b3 100644 --- a/c/src/lib/ChangeLog +++ b/c/src/lib/ChangeLog @@ -1,3 +1,9 @@ +2002-03-01 Eric Norum + + * libc/gxx_wrappers.c: Task is not preemptable while running a + pthread_once init function. This is slightly less heavy handed + than disabling dispatching and seems better than consuming a mutex. + 2001-01-31 Mike Siers * Nice Update of PPPD support which eliminates the diff --git a/c/src/lib/libc/gxx_wrappers.c b/c/src/lib/libc/gxx_wrappers.c index bf3d41cde1..48f91aff19 100644 --- a/c/src/lib/libc/gxx_wrappers.c +++ b/c/src/lib/libc/gxx_wrappers.c @@ -63,17 +63,16 @@ int rtems_gxx_once(__gthread_once_t *once, void (*func) ()) #ifdef DEBUG_GXX_WRAPPERS printk( "gxx_wrappers: once=%x, func=%x\n", *once, func ); #endif - if( *once == 0 ) + if( *(volatile __gthread_once_t *)once == 0 ) { - /* - * NOTE: could not use the call to disable "preemption", it causes - * one exception. Somebody might want to investiage it further - * sometime later. - */ - _Thread_Disable_dispatch(); - *once = 1; - (*func)(); - _Thread_Enable_dispatch(); + rtems_mode saveMode; + rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &saveMode); + if( *(volatile __gthread_once_t *)once == 0 ) + { + *(volatile __gthread_once_t *)once = 1; + (*func)(); + } + rtems_task_mode(saveMode, RTEMS_PREEMPT_MASK, &saveMode); } return 0; } diff --git a/cpukit/libcsupport/src/gxx_wrappers.c b/cpukit/libcsupport/src/gxx_wrappers.c index bf3d41cde1..48f91aff19 100644 --- a/cpukit/libcsupport/src/gxx_wrappers.c +++ b/cpukit/libcsupport/src/gxx_wrappers.c @@ -63,17 +63,16 @@ int rtems_gxx_once(__gthread_once_t *once, void (*func) ()) #ifdef DEBUG_GXX_WRAPPERS printk( "gxx_wrappers: once=%x, func=%x\n", *once, func ); #endif - if( *once == 0 ) + if( *(volatile __gthread_once_t *)once == 0 ) { - /* - * NOTE: could not use the call to disable "preemption", it causes - * one exception. Somebody might want to investiage it further - * sometime later. - */ - _Thread_Disable_dispatch(); - *once = 1; - (*func)(); - _Thread_Enable_dispatch(); + rtems_mode saveMode; + rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &saveMode); + if( *(volatile __gthread_once_t *)once == 0 ) + { + *(volatile __gthread_once_t *)once = 1; + (*func)(); + } + rtems_task_mode(saveMode, RTEMS_PREEMPT_MASK, &saveMode); } return 0; } -- cgit v1.2.3