Changeset b8bdced1 in rtems


Ignore:
Timestamp:
Apr 18, 2016, 3:21:43 PM (4 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
bbe654af
Parents:
beba41b
git-author:
Sebastian Huber <sebastian.huber@…> (04/18/16 15:21:43)
git-committer:
Sebastian Huber <sebastian.huber@…> (04/21/16 05:29:39)
Message:

posix: Simplify _POSIX_Mutex_Get_interrupt_disable

Remove superfluous location parameter.

Location:
cpukit/posix
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • cpukit/posix/include/rtems/posix/muteximpl.h

    rbeba41b rb8bdced1  
    1616 */
    1717
     18#ifndef _RTEMS_POSIX_MUTEXIMPL_H
     19#define _RTEMS_POSIX_MUTEXIMPL_H
     20
    1821#include <rtems/posix/mutex.h>
    1922#include <rtems/score/coremuteximpl.h>
    2023
    2124#include <errno.h>
    22 
    23 #ifndef _RTEMS_POSIX_MUTEXIMPL_H
    24 #define _RTEMS_POSIX_MUTEXIMPL_H
     25#include <pthread.h>
    2526
    2627#ifdef __cplusplus
     
    140141 *  @note: This version of the method uses an interrupt critical section.
    141142 */
    142 POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
    143   pthread_mutex_t   *mutex,
    144   Objects_Locations *location,
    145   ISR_lock_Context  *lock_context
     143POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable(
     144  pthread_mutex_t  *mutex,
     145  ISR_lock_Context *lock_context
    146146);
    147147
  • cpukit/posix/src/mutexget.c

    rbeba41b rb8bdced1  
    6969}
    7070
    71 POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable (
    72   pthread_mutex_t   *mutex,
    73   Objects_Locations *location,
    74   ISR_lock_Context  *lock_context
     71POSIX_Mutex_Control *_POSIX_Mutex_Get_interrupt_disable(
     72  pthread_mutex_t  *mutex,
     73  ISR_lock_Context *lock_context
    7574)
    7675{
    77   if ( !_POSIX_Mutex_Check_id_and_auto_init( mutex, location ) ) {
     76  Objects_Locations location;
     77
     78  if ( !_POSIX_Mutex_Check_id_and_auto_init( mutex, &location ) ) {
    7879    return NULL;
    7980  }
     
    8283    &_POSIX_Mutex_Information,
    8384    (Objects_Id) *mutex,
    84     location,
     85    &location,
    8586    lock_context
    8687  );
  • cpukit/posix/src/mutexlocksupp.c

    rbeba41b rb8bdced1  
    1919#endif
    2020
    21 #include <errno.h>
    22 #include <pthread.h>
    23 
    24 #include <rtems/system.h>
    25 #include <rtems/score/coremuteximpl.h>
    26 #include <rtems/score/watchdog.h>
    27 #include <rtems/score/threadimpl.h>
    2821#include <rtems/posix/muteximpl.h>
    29 #include <rtems/posix/priorityimpl.h>
    3022
    3123THREAD_WAIT_QUEUE_OBJECT_ASSERT( POSIX_Mutex_Control, Mutex.Wait_queue );
    3224
    33 /*
    34  *  _POSIX_Mutex_Lock_support
    35  *
    36  *  A support routine which implements guts of the blocking, non-blocking, and
    37  *  timed wait version of mutex lock.
    38  */
    39 
    4025int _POSIX_Mutex_Lock_support(
    41   pthread_mutex_t           *mutex,
    42   bool                       blocking,
    43   Watchdog_Interval          timeout
     26  pthread_mutex_t   *mutex,
     27  bool               blocking,
     28  Watchdog_Interval  timeout
    4429)
    4530{
    46   POSIX_Mutex_Control          *the_mutex;
    47   Objects_Locations             location;
    48   ISR_lock_Context              lock_context;
    49   Thread_Control               *executing;
     31  POSIX_Mutex_Control *the_mutex;
     32  ISR_lock_Context     lock_context;
     33  Thread_Control      *executing;
    5034
    51   the_mutex = _POSIX_Mutex_Get_interrupt_disable(
    52     mutex,
    53     &location,
     35  the_mutex = _POSIX_Mutex_Get_interrupt_disable( mutex, &lock_context );
     36
     37  if ( the_mutex == NULL ) {
     38    return EINVAL;
     39  }
     40
     41  executing = _Thread_Executing;
     42  _CORE_mutex_Seize(
     43    &the_mutex->Mutex,
     44    executing,
     45    blocking,
     46    timeout,
    5447    &lock_context
    5548  );
    56   switch ( location ) {
    57 
    58     case OBJECTS_LOCAL:
    59       executing = _Thread_Executing;
    60       _CORE_mutex_Seize(
    61         &the_mutex->Mutex,
    62         executing,
    63         blocking,
    64         timeout,
    65         &lock_context
    66       );
    67       return _POSIX_Mutex_Translate_core_mutex_return_code(
    68         (CORE_mutex_Status) executing->Wait.return_code
    69       );
    70 
    71 #if defined(RTEMS_MULTIPROCESSING)
    72     case OBJECTS_REMOTE:
    73 #endif
    74     case OBJECTS_ERROR:
    75       break;
    76   }
    77 
    78   return EINVAL;
     49  return _POSIX_Mutex_Translate_core_mutex_return_code(
     50    (CORE_mutex_Status) executing->Wait.return_code
     51  );
    7952}
  • cpukit/posix/src/mutexsetprioceiling.c

    rbeba41b rb8bdced1  
    1919#endif
    2020
    21 #include <errno.h>
    22 #include <pthread.h>
    23 
    24 #include <rtems/system.h>
    25 #include <rtems/score/coremuteximpl.h>
    26 #include <rtems/score/watchdog.h>
    2721#include <rtems/posix/muteximpl.h>
    28 #include <rtems/posix/priorityimpl.h>
    2922
    3023/*
     
    3932{
    4033  register POSIX_Mutex_Control *the_mutex;
    41   Objects_Locations             location;
    4234  Priority_Control              the_priority;
    4335  ISR_lock_Context              lock_context;
     
    6557   *        bad Id case is handled by the switch.
    6658   */
    67   the_mutex = _POSIX_Mutex_Get_interrupt_disable(
    68     mutex,
    69     &location,
     59  the_mutex = _POSIX_Mutex_Get_interrupt_disable( mutex, &lock_context );
     60
     61  if ( the_mutex == NULL ) {
     62    return EINVAL;
     63  }
     64
     65  *old_ceiling = _POSIX_Priority_From_core(
     66    the_mutex->Mutex.Attributes.priority_ceiling
     67  );
     68  the_mutex->Mutex.Attributes.priority_ceiling = the_priority;
     69
     70  /*
     71   *  We are required to unlock the mutex before we return.
     72   */
     73  _CORE_mutex_Surrender(
     74    &the_mutex->Mutex,
     75    NULL,
     76    0,
    7077    &lock_context
    7178  );
    72   switch ( location ) {
    73 
    74     case OBJECTS_LOCAL:
    75       *old_ceiling = _POSIX_Priority_From_core(
    76         the_mutex->Mutex.Attributes.priority_ceiling
    77       );
    78       the_mutex->Mutex.Attributes.priority_ceiling = the_priority;
    79       /*
    80        *  We are required to unlock the mutex before we return.
    81        */
    82       _CORE_mutex_Surrender(
    83         &the_mutex->Mutex,
    84         NULL,
    85         0,
    86         &lock_context
    87       );
    88 
    89       return 0;
    90 
    91 #if defined(RTEMS_MULTIPROCESSING)
    92     case OBJECTS_REMOTE:  /* impossible to get here */
    93 #endif
    94     case OBJECTS_ERROR:
    95       break;
    96   }
    97 
    98   return EINVAL;
     79  return 0;
    9980}
  • cpukit/posix/src/mutexunlock.c

    rbeba41b rb8bdced1  
    1919#endif
    2020
    21 #include <errno.h>
    22 #include <pthread.h>
    23 
    24 #include <rtems/system.h>
    25 #include <rtems/score/coremuteximpl.h>
    26 #include <rtems/score/watchdog.h>
    2721#include <rtems/posix/muteximpl.h>
    28 #include <rtems/posix/priorityimpl.h>
    2922
    3023/*
     
    3831)
    3932{
    40   register POSIX_Mutex_Control *the_mutex;
    41   Objects_Locations             location;
    42   CORE_mutex_Status             status;
    43   ISR_lock_Context              lock_context;
     33  POSIX_Mutex_Control *the_mutex;
     34  CORE_mutex_Status    status;
     35  ISR_lock_Context     lock_context;
    4436
    45   the_mutex = _POSIX_Mutex_Get_interrupt_disable(
    46     mutex,
    47     &location,
     37  the_mutex = _POSIX_Mutex_Get_interrupt_disable( mutex, &lock_context );
     38
     39  if ( the_mutex == NULL ) {
     40    return EINVAL;
     41  }
     42
     43  status = _CORE_mutex_Surrender(
     44    &the_mutex->Mutex,
     45    NULL,
     46    0,
    4847    &lock_context
    4948  );
    50   switch ( location ) {
    51 
    52     case OBJECTS_LOCAL:
    53       status = _CORE_mutex_Surrender(
    54         &the_mutex->Mutex,
    55         NULL,
    56         0,
    57         &lock_context
    58       );
    59       return _POSIX_Mutex_Translate_core_mutex_return_code( status );
    60 
    61 #if defined(RTEMS_MULTIPROCESSING)
    62     case OBJECTS_REMOTE:
    63 #endif
    64     case OBJECTS_ERROR:
    65       break;
    66   }
    67 
    68   return EINVAL;
     49  return _POSIX_Mutex_Translate_core_mutex_return_code( status );
    6950}
Note: See TracChangeset for help on using the changeset viewer.