Changeset 7038271 in rtems for cpukit


Ignore:
Timestamp:
Oct 25, 2018, 10:05:53 AM (10 months ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
55b69ed
Parents:
5090a71b
git-author:
Sebastian Huber <sebastian.huber@…> (10/25/18 10:05:53)
git-committer:
Sebastian Huber <sebastian.huber@…> (10/29/18 09:33:33)
Message:

Remove RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES

Enable support for string objects names unconditionally. Add const
qualifier throughout. Split _Objects_Namespace_remove() into
_Objects_Namespace_remove_u32() and _Objects_Namespace_remove_string()
to avoid an unnecessary dependency on _Workspace_Free().

Update #2514.

Location:
cpukit
Files:
14 edited

Legend:

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

    r5090a71b r7038271  
    157157)
    158158{
    159   _Objects_Namespace_remove(
    160     &_POSIX_Message_queue_Information, &the_mq->Object );
     159  _Objects_Namespace_remove_string(
     160    &_POSIX_Message_queue_Information,
     161    &the_mq->Object
     162  );
    161163}
    162164
  • cpukit/include/rtems/posix/semaphoreimpl.h

    r5090a71b r7038271  
    108108)
    109109{
    110   _Objects_Namespace_remove(
    111     &_POSIX_Semaphore_Information, &the_semaphore->Object );
     110  _Objects_Namespace_remove_string(
     111    &_POSIX_Semaphore_Information,
     112    &the_semaphore->Object
     113  );
    112114}
    113115
  • cpukit/include/rtems/score/object.h

    r5090a71b r7038271  
    3737/**@{*/
    3838
    39 #if defined(RTEMS_POSIX_API)
    40   /**
    41    *  This macro is defined when an API is enabled that requires the
    42    *  use of strings for object names.  Since the Classic API uses
    43    *  32-bit unsigned integers and not strings, this allows us to
    44    *  disable this in the smallest RTEMS configuratinos.
    45    */
    46   #define RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES
    47 #endif
    48 
    4939/**
    5040 * @defgroup ScoreCPU CPU Architecture Support
     
    6858 */
    6959typedef union {
    70   #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    71     /** This is a pointer to a string name. */
    72     const char *name_p;
    73   #endif
     60  /** This is a pointer to a string name. */
     61  const char *name_p;
    7462  /** This is the actual 32-bit "raw" integer name. */
    7563  uint32_t    name_u32;
  • cpukit/include/rtems/score/objectimpl.h

    r5090a71b r7038271  
    131131  /** This is the maximum number of objects in this class. */
    132132  Objects_Maximum   maximum;
     133  /** This is true if names are strings. */
     134  bool              is_string;
    133135  /** This is the true if unlimited objects in this class. */
    134136  bool              auto_extend;
     
    147149  /** This is a table to the chain of inactive object memory blocks. */
    148150  void            **object_blocks;
    149   #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    150     /** This is true if names are strings. */
    151     bool              is_string;
    152   #endif
    153151  /** This is the maximum length of names. */
    154152  uint16_t          name_length;
     
    686684 */
    687685bool _Objects_Set_name(
    688   Objects_Information *information,
    689   Objects_Control     *the_object,
    690   const char          *name
    691 );
    692 
    693 /**
    694  *  @brief Removes object from namespace.
    695  *
    696  *  This function removes @a the_object from the namespace.
    697  *
    698  *  @param[in] information points to an Object Information Table.
    699  *  @param[in] the_object is a pointer to an object.
    700  */
    701 void _Objects_Namespace_remove(
    702   Objects_Information  *information,
    703   Objects_Control      *the_object
     686  const Objects_Information *information,
     687  Objects_Control           *the_object,
     688  const char                *name
     689);
     690
     691/**
     692 * @brief Removes object with a 32-bit integer name from its namespace.
     693 *
     694 * @param[in] information The corresponding object information table.
     695 * @param[in] the_object The object.
     696 */
     697void _Objects_Namespace_remove_u32(
     698  const Objects_Information *information,
     699  Objects_Control           *the_object
     700);
     701
     702/**
     703 * @brief Removes object with a string name from its namespace.
     704 *
     705 * @param[in] information The corresponding object information table.
     706 * @param[in] the_object The object.
     707 */
     708void _Objects_Namespace_remove_string(
     709  const Objects_Information *information,
     710  Objects_Control           *the_object
    704711);
    705712
     
    714721 */
    715722void _Objects_Close(
    716   Objects_Information *information,
    717   Objects_Control      *the_object
     723  const Objects_Information *information,
     724  Objects_Control           *the_object
    718725);
    719726
     
    829836
    830837RTEMS_INLINE_ROUTINE void _Objects_Set_local_object(
    831   Objects_Information *information,
    832   uint32_t             index,
    833   Objects_Control     *the_object
     838  const Objects_Information *information,
     839  uint32_t                   index,
     840  Objects_Control           *the_object
    834841)
    835842{
     
    839846   *  occur in normal situations.
    840847   */
    841   #if defined(RTEMS_DEBUG)
    842     if ( index > information->maximum )
    843       return;
    844   #endif
     848  _Assert( index <= information->maximum );
    845849
    846850  information->local_table[ index ] = the_object;
     
    862866
    863867RTEMS_INLINE_ROUTINE void _Objects_Invalidate_Id(
    864   Objects_Information *information,
    865   Objects_Control      *the_object
     868  const Objects_Information *information,
     869  Objects_Control           *the_object
    866870)
    867871{
     
    911915 */
    912916RTEMS_INLINE_ROUTINE void _Objects_Open_u32(
    913   Objects_Information *information,
    914   Objects_Control     *the_object,
    915   uint32_t             name
     917  const Objects_Information *information,
     918  Objects_Control           *the_object,
     919  uint32_t                   name
    916920)
    917921{
    918   /* ASSERT: information->is_string == false */
     922  _Assert( !information->is_string );
    919923  the_object->name.name_u32 = name;
    920924
     
    935939 */
    936940RTEMS_INLINE_ROUTINE void _Objects_Open_string(
    937   Objects_Information *information,
    938   Objects_Control     *the_object,
    939   const char          *name
     941  const Objects_Information *information,
     942  Objects_Control           *the_object,
     943  const char                *name
    940944)
    941945{
    942   #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    943     /* ASSERT: information->is_string */
    944     the_object->name.name_p = name;
    945   #endif
     946  _Assert( information->is_string );
     947  the_object->name.name_p = name;
    946948
    947949  _Objects_Set_local_object(
  • cpukit/posix/src/key.c

    r5090a71b r7038271  
    143143    sizeof( POSIX_Keys_Control ),
    144144                                /* size of this object's control block */
    145     true,                       /* true if names for this object are strings */
    146     _POSIX_PATH_MAX,            /* maximum length of each object's name */
     145    false,                      /* true if names for this object are strings */
     146    0,                          /* maximum length of each object's name */
    147147    NULL                        /* Proxy extraction support callout */
    148148  );
  • cpukit/posix/src/ptimer.c

    r5090a71b r7038271  
    6767    sizeof( POSIX_Timer_Control ),
    6868                                /* size of this object's control block */
    69     true,                       /* true if names for this object are strings */
    70     _POSIX_PATH_MAX,            /* maximum length of each object's name */
     69    false,                      /* true if names for this object are strings */
     70    0,                          /* maximum length of each object's name */
    7171    NULL                        /* Proxy extraction support callout */
    7272  );
  • cpukit/posix/src/semaphoredeletesupp.c

    r5090a71b r7038271  
    2424{
    2525  if ( !the_semaphore->linked && !the_semaphore->open_count ) {
    26     _Objects_Close( &_POSIX_Semaphore_Information, &the_semaphore->Object );
     26    _Objects_Invalidate_Id( &_POSIX_Semaphore_Information, &the_semaphore->Object );
    2727    _POSIX_Semaphore_Destroy( &the_semaphore->Semaphore );
    2828    _POSIX_Semaphore_Free( the_semaphore );
  • cpukit/score/src/objectclose.c

    r5090a71b r7038271  
    2222
    2323void _Objects_Close(
    24   Objects_Information *information,
    25   Objects_Control      *the_object
     24  const Objects_Information *information,
     25  Objects_Control           *the_object
    2626)
    2727{
    2828  _Objects_Invalidate_Id( information, the_object );
    2929
    30   _Objects_Namespace_remove( information, the_object );
     30  _Objects_Namespace_remove_u32( information, the_object );
    3131}
  • cpukit/score/src/objectgetnameasstring.c

    r5090a71b r7038271  
    4646  size_t      i;
    4747
    48 #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    4948  if ( is_string ) {
    5049    s = name.name_p;
    51   } else
    52 #endif
    53   {
     50  } else {
    5451    lname[ 0 ] = (name.name_u32 >> 24) & 0xff;
    5552    lname[ 1 ] = (name.name_u32 >> 16) & 0xff;
     
    9491)
    9592{
    96   Objects_Information  *information;
    97   Objects_Control       *the_object;
    98   ISR_lock_Context       lock_context;
    99   Objects_Id             tmpId;
     93  const Objects_Information *information;
     94  const Objects_Control     *the_object;
     95  ISR_lock_Context           lock_context;
     96  Objects_Id                 tmpId;
    10097
    10198  if ( length == 0 )
     
    118115  _Objects_Name_to_string(
    119116    the_object->name,
    120 #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    121117    information->is_string,
    122 #else
    123     false,
    124 #endif
    125118    name,
    126119    length
  • cpukit/score/src/objectidtoname.c

    r5090a71b r7038271  
    4141    return OBJECTS_INVALID_ID;
    4242
    43   #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    44     if ( information->is_string )
    45       return OBJECTS_INVALID_ID;
    46   #endif
     43  if ( information->is_string )
     44    return OBJECTS_INVALID_ID;
    4745
    4846  the_object = _Objects_Get(
  • cpukit/score/src/objectinitializeinformation.c

    r5090a71b r7038271  
    5050  information->object_blocks      = 0;
    5151  information->inactive           = 0;
    52   #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    53     information->is_string        = is_string;
    54   #endif
     52  information->is_string          = is_string;
    5553
    5654  /*
  • cpukit/score/src/objectnamespaceremove.c

    r5090a71b r7038271  
    2323#include <rtems/score/wkspace.h>
    2424
    25 void _Objects_Namespace_remove(
    26   Objects_Information *information,
    27   Objects_Control      *the_object
     25void _Objects_Namespace_remove_u32(
     26  const Objects_Information *information,
     27  Objects_Control           *the_object
    2828)
    2929{
    30   #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    31     /*
    32      *  If this is a string format name, then free the memory.
    33      */
    34     if ( information->is_string )
    35        _Workspace_Free( (void *)the_object->name.name_p );
    36   #endif
    37 
    38   /*
    39    * Clear out either format.
    40    */
    41   #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    42     the_object->name.name_p   = NULL;
    43   #endif
     30  _Assert( !information->is_string );
    4431  the_object->name.name_u32 = 0;
    4532}
     33
     34void _Objects_Namespace_remove_string(
     35  const Objects_Information *information,
     36  Objects_Control           *the_object
     37)
     38{
     39  char *name;
     40
     41  _Assert( information->is_string );
     42  name = RTEMS_DECONST( char *, the_object->name.name_p );
     43  the_object->name.name_p = NULL;
     44  _Workspace_Free( name );
     45}
  • cpukit/score/src/objectnametoidstring.c

    r5090a71b r7038271  
    2323#include <string.h>
    2424
    25 #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    2625Objects_Control *_Objects_Get_by_name(
    2726  const Objects_Information *information,
     
    7372  return NULL;
    7473}
    75 #endif
  • cpukit/score/src/objectsetname.c

    r5090a71b r7038271  
    2525
    2626bool _Objects_Set_name(
    27   Objects_Information *information,
    28   Objects_Control     *the_object,
    29   const char          *name
     27  const Objects_Information *information,
     28  Objects_Control           *the_object,
     29  const char                *name
    3030)
    3131{
     
    3636  length = strnlen( name, information->name_length );
    3737
    38 #if defined(RTEMS_SCORE_OBJECT_ENABLE_STRING_NAMES)
    3938  if ( information->is_string ) {
    4039    char *d;
     
    5049    d[length] = '\0';
    5150    the_object->name.name_p = d;
    52   } else
    53 #endif
    54   {
     51  } else {
    5552    the_object->name.name_u32 =  _Objects_Build_name(
    5653      ((length)     ? s[ 0 ] : ' '),
     
    5956      ((length > 3) ? s[ 3 ] : ' ')
    6057    );
    61 
    6258  }
    6359
Note: See TracChangeset for help on using the changeset viewer.