Changeset a5385b1 in rtems


Ignore:
Timestamp:
Mar 20, 2014, 8:22:00 AM (6 years ago)
Author:
Christian Mauderer <Christian.Mauderer@…>
Branches:
4.11, master
Children:
8cc7084
Parents:
9486566
git-author:
Christian Mauderer <Christian.Mauderer@…> (03/20/14 08:22:00)
git-committer:
Sebastian Huber <sebastian.huber@…> (03/21/14 10:21:49)
Message:

score: Unify pthread and gxx_wrapper once and move to score.

Location:
cpukit
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/gxx_wrappers.c

    r9486566 ra5385b1  
    3030
    3131#include <rtems/gxx_wrappers.h>
     32#include <rtems/score/onceimpl.h>
    3233
    3334#include <stdlib.h>
     
    4445  #endif
    4546
    46   if ( *(volatile __gthread_once_t *)once == 0 ) {
    47     rtems_mode saveMode;
    48     __gthread_once_t o;
    49 
    50     rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &saveMode);
    51     if ( (o = *(volatile __gthread_once_t *)once) == 0 ) {
    52       *(volatile __gthread_once_t *)once = 1;
    53     }
    54     rtems_task_mode(saveMode, RTEMS_PREEMPT_MASK, &saveMode);
    55     if ( o == 0 )
    56       (*func)();
    57   }
    58   return 0;
     47  return _Once( once, func );
    5948}
    6049
  • cpukit/posix/src/pthreadonce.c

    r9486566 ra5385b1  
    2424#include <errno.h>
    2525
    26 #include <rtems/score/apimutex.h>
    27 
    28 #define PTHREAD_ONCE_INIT_NOT_RUN  0
    29 #define PTHREAD_ONCE_INIT_RUNNING  1
    30 #define PTHREAD_ONCE_INIT_COMPLETE 2
     26#include <rtems/score/onceimpl.h>
    3127
    3228int pthread_once(
     
    3531)
    3632{
    37   int r = 0;
    38 
    3933  if ( !once_control || !init_routine )
    4034    return EINVAL;
     
    4337    return EINVAL;
    4438
    45   if ( once_control->init_executed != PTHREAD_ONCE_INIT_COMPLETE ) {
    46     _Once_Lock();
    47 
    48     /*
    49      * Getting to here means the once_control is locked so we have:
    50      *  1. The init has not run and the state is PTHREAD_ONCE_INIT_NOT_RUN.
    51      *  2. The init has finished and the state is PTHREAD_ONCE_INIT_RUN.
    52      *  3. The init is being run by this thread and the state
    53      *     PTHREAD_ONCE_INIT_RUNNING so we are nesting. This is an error.
    54      */
    55 
    56     switch ( once_control->init_executed ) {
    57       case PTHREAD_ONCE_INIT_NOT_RUN:
    58         once_control->init_executed = PTHREAD_ONCE_INIT_RUNNING;
    59         (*init_routine)();
    60         once_control->init_executed = PTHREAD_ONCE_INIT_COMPLETE;
    61         break;
    62       case PTHREAD_ONCE_INIT_RUNNING:
    63         r = EINVAL;
    64         break;
    65       default:
    66         break;
    67     }
    68 
    69     _Once_Unlock();
    70   }
    71 
    72   return r;
     39  return _Once( &once_control->init_executed, init_routine );
    7340}
  • cpukit/score/Makefile.am

    r9486566 ra5385b1  
    4242include_rtems_score_HEADERS += include/rtems/score/object.h
    4343include_rtems_score_HEADERS += include/rtems/score/objectimpl.h
     44include_rtems_score_HEADERS += include/rtems/score/onceimpl.h
    4445include_rtems_score_HEADERS += include/rtems/score/percpu.h
    4546include_rtems_score_HEADERS += include/rtems/score/priority.h
     
    336337libscore_a_SOURCES += src/debugisownerofallocator.c
    337338libscore_a_SOURCES += src/profilingisrentryexit.c
     339libscore_a_SOURCES += src/once.c
    338340
    339341EXTRA_DIST = src/Unlimited.txt
  • cpukit/score/preinstall.am

    r9486566 ra5385b1  
    147147        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/objectimpl.h
    148148PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/objectimpl.h
     149
     150$(PROJECT_INCLUDE)/rtems/score/onceimpl.h: include/rtems/score/onceimpl.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
     151        $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/score/onceimpl.h
     152PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/score/onceimpl.h
    149153
    150154$(PROJECT_INCLUDE)/rtems/score/percpu.h: include/rtems/score/percpu.h $(PROJECT_INCLUDE)/rtems/score/$(dirstamp)
Note: See TracChangeset for help on using the changeset viewer.