diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-01-23 22:57:43 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-01-23 22:57:43 +0000 |
commit | ce19f1fa3bd9f9760f680ef7839ca136a1c2478a (patch) | |
tree | aa2c0b50ec70dd5c9e8d970aaa7c8deba8fcf330 | |
parent | 2008-01-23 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-ce19f1fa3bd9f9760f680ef7839ca136a1c2478a.tar.bz2 |
2008-01-23 Joel Sherrill <joel.sherrill@oarcorp.com>
* itron/include/rtems/itron/object.h, itron/src/cre_tsk.c,
libblock/src/show_bdbuf.c, libmisc/capture/capture-cli.c,
libmisc/capture/capture.c, libmisc/monitor/mon-manager.c,
libmisc/stackchk/check.c, posix/src/condinit.c,
posix/src/keycreate.c, posix/src/mqueuecreatesupp.c,
posix/src/mqueuedeletesupp.c, posix/src/mqueuenametoid.c,
posix/src/mqueueopen.c, posix/src/mqueueunlink.c,
posix/src/mutexinit.c, posix/src/pbarrierinit.c,
posix/src/prwlockinit.c, posix/src/pspininit.c,
posix/src/pthreadcreate.c, posix/src/pthreadexit.c,
posix/src/semaphorecreatesupp.c, posix/src/semaphorenametoid.c,
posix/src/timercreate.c, rtems/src/barrierident.c,
rtems/src/dpmemident.c, rtems/src/msgqident.c, rtems/src/partident.c,
rtems/src/ratemonident.c, rtems/src/regionident.c,
rtems/src/semident.c, rtems/src/taskident.c, rtems/src/timerident.c,
sapi/src/extensionident.c, score/Makefile.am,
score/include/rtems/score/object.h,
score/inline/rtems/score/object.inl, score/src/apimutexallocate.c,
score/src/objectextendinformation.c,
score/src/objectgetnameasstring.c, score/src/objectmp.c,
score/src/objectnametoid.c: Convert the Objects_Name type from a
simple type to a union of an unsigned 32 bit integer and a pointer.
This should help eliminate weird casts between u32 and pointers in
various places. The APIs now have to explicitly call _u32 or _string
versions of helper routines. This should also simplify things and
eliminate the need for ugly casts in some cases.
* score/src/objectclearname.c, score/src/objectcomparenameraw.c,
score/src/objectcomparenamestring.c, score/src/objectcopynameraw.c,
score/src/objectcopynamestring.c: Removed.
47 files changed, 215 insertions, 458 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog index e3316c2935..b6e27d92ed 100644 --- a/cpukit/ChangeLog +++ b/cpukit/ChangeLog @@ -1,5 +1,37 @@ 2008-01-23 Joel Sherrill <joel.sherrill@oarcorp.com> + * itron/include/rtems/itron/object.h, itron/src/cre_tsk.c, + libblock/src/show_bdbuf.c, libmisc/capture/capture-cli.c, + libmisc/capture/capture.c, libmisc/monitor/mon-manager.c, + libmisc/stackchk/check.c, posix/src/condinit.c, + posix/src/keycreate.c, posix/src/mqueuecreatesupp.c, + posix/src/mqueuedeletesupp.c, posix/src/mqueuenametoid.c, + posix/src/mqueueopen.c, posix/src/mqueueunlink.c, + posix/src/mutexinit.c, posix/src/pbarrierinit.c, + posix/src/prwlockinit.c, posix/src/pspininit.c, + posix/src/pthreadcreate.c, posix/src/pthreadexit.c, + posix/src/semaphorecreatesupp.c, posix/src/semaphorenametoid.c, + posix/src/timercreate.c, rtems/src/barrierident.c, + rtems/src/dpmemident.c, rtems/src/msgqident.c, rtems/src/partident.c, + rtems/src/ratemonident.c, rtems/src/regionident.c, + rtems/src/semident.c, rtems/src/taskident.c, rtems/src/timerident.c, + sapi/src/extensionident.c, score/Makefile.am, + score/include/rtems/score/object.h, + score/inline/rtems/score/object.inl, score/src/apimutexallocate.c, + score/src/objectextendinformation.c, + score/src/objectgetnameasstring.c, score/src/objectmp.c, + score/src/objectnametoid.c: Convert the Objects_Name type from a + simple type to a union of an unsigned 32 bit integer and a pointer. + This should help eliminate weird casts between u32 and pointers in + various places. The APIs now have to explicitly call _u32 or _string + versions of helper routines. This should also simplify things and + eliminate the need for ugly casts in some cases. + * score/src/objectclearname.c, score/src/objectcomparenameraw.c, + score/src/objectcomparenamestring.c, score/src/objectcopynameraw.c, + score/src/objectcopynamestring.c: Removed. + +2008-01-23 Joel Sherrill <joel.sherrill@oarcorp.com> + * score/src/threadblockingoperationcancel.c: Clean up. * score/src/threadqextract.c: Restructure to eliminate dead code. diff --git a/cpukit/itron/include/rtems/itron/object.h b/cpukit/itron/include/rtems/itron/object.h index 6001651743..2f97002396 100644 --- a/cpukit/itron/include/rtems/itron/object.h +++ b/cpukit/itron/include/rtems/itron/object.h @@ -41,7 +41,7 @@ typedef Objects_Control ITRON_Objects_Control; */ #define _ITRON_Objects_Open( _the_information, _the_object ) \ - _Objects_Open( (_the_information), (_the_object), NULL ) + _Objects_Open_u32( (_the_information), (_the_object), 0 ) /* * _ITRON_Objects_Close diff --git a/cpukit/itron/src/cre_tsk.c b/cpukit/itron/src/cre_tsk.c index 85a24e52d9..5ae87c1675 100644 --- a/cpukit/itron/src/cre_tsk.c +++ b/cpukit/itron/src/cre_tsk.c @@ -36,6 +36,7 @@ ER cre_tsk( register Thread_Control *the_thread; boolean status; Priority_Control core_priority; + Objects_Name name; /* * Validate Parameters. @@ -81,6 +82,7 @@ ER cre_tsk( * Initialize the core thread for this task. */ + name.name_u32 = 0; core_priority = _ITRON_Task_Priority_to_Core( pk_ctsk->itskpri ); status = _Thread_Initialize( &_ITRON_Task_Information, @@ -97,7 +99,7 @@ ER cre_tsk( THREAD_CPU_BUDGET_ALGORITHM_EXHAUST_TIMESLICE, NULL, /* no budget algorithm callout */ 0, - NULL + name ); if ( !status ) { diff --git a/cpukit/libblock/src/show_bdbuf.c b/cpukit/libblock/src/show_bdbuf.c index cc1d7826d8..2827755981 100644 --- a/cpukit/libblock/src/show_bdbuf.c +++ b/cpukit/libblock/src/show_bdbuf.c @@ -566,7 +566,7 @@ rtems_status_code rtems_show_bdbuf_print_wait_chain thread_id = the_thread->Object.id; thread_name = the_thread->Object.name; - thread_name_nonstring = (uint32_t)thread_name; + thread_name_nonstring = (uint32_t)thread_name.name_u32; printf("%20s %3d (0x%08" PRIx32 ") %c%c%c%c\n", ((thread_cnt == 1) ? "Threads waiting:" : ""), thread_cnt,thread_id, diff --git a/cpukit/libmisc/capture/capture-cli.c b/cpukit/libmisc/capture/capture-cli.c index 42480df76b..d65bdb8dc5 100644 --- a/cpukit/libmisc/capture/capture-cli.c +++ b/cpukit/libmisc/capture/capture-cli.c @@ -659,12 +659,10 @@ rtems_capture_cli_get_name_id (char* arg, * @warning The extra assigns play with the byte order so do not * remove unless the score has been updated. */ - Objects_Name object_name; rtems_name rname; rname = rtems_build_name(arg[0], arg[1], arg[2], arg[3]); - object_name = (Objects_Name) rname; - *name = (rtems_name) object_name; + *name = rname; *valid_name = 1; } diff --git a/cpukit/libmisc/capture/capture.c b/cpukit/libmisc/capture/capture.c index e8c6396490..45bae26d95 100644 --- a/cpukit/libmisc/capture/capture.c +++ b/cpukit/libmisc/capture/capture.c @@ -412,13 +412,15 @@ rtems_capture_create_capture_task (rtems_tcb* new_task) /* * Check the type of name the object has. */ - if (_Objects_Get_API (new_task->Object.id) == OBJECTS_CLASSIC_API) - name = (rtems_name) new_task->Object.name; - else - name = rtems_build_name (((char*) new_task->Object.name)[0], - ((char*) new_task->Object.name)[1], - ((char*) new_task->Object.name)[2], - ((char*) new_task->Object.name)[3]); + + name = 0; + if ( _Objects_Get_API (new_task->Object.id) == OBJECTS_CLASSIC_API ) + name = new_task->Object.name.name_u32; + else if (new_task->Object.name.name_p) + name = rtems_build_name (new_task->Object.name.name_p[0], + new_task->Object.name.name_p[1], + new_task->Object.name.name_p[2], + new_task->Object.name.name_p[3]); rtems_capture_dup_name (&task->name, name); diff --git a/cpukit/libmisc/monitor/mon-manager.c b/cpukit/libmisc/monitor/mon-manager.c index b91de9b545..9e71addfae 100644 --- a/cpukit/libmisc/monitor/mon-manager.c +++ b/cpukit/libmisc/monitor/mon-manager.c @@ -45,10 +45,7 @@ rtems_monitor_manager_next( { copy = (rtems_monitor_generic_t *) canonical; copy->id = object->id; - if (table->is_string) - _Objects_Copy_name_raw(object->name, ©->name, sizeof(copy->name)); - else - _Objects_Copy_name_raw(&object->name, ©->name, sizeof(copy->name)); + copy->name = object->name.name_u32; } #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/libmisc/stackchk/check.c b/cpukit/libmisc/stackchk/check.c index a52928e1fc..c3e81f59ca 100644 --- a/cpukit/libmisc/stackchk/check.c +++ b/cpukit/libmisc/stackchk/check.c @@ -217,7 +217,7 @@ void Stack_check_report_blown_task( "id=0x%08" PRIx32 "; name=0x%08" PRIx32, running, running->Object.id, - (uint32_t) running->Object.name + running->Object.name.name_u32 ); #if defined(RTEMS_MULTIPROCESSING) diff --git a/cpukit/posix/src/condinit.c b/cpukit/posix/src/condinit.c index 023e135cb3..5e64efa7cd 100644 --- a/cpukit/posix/src/condinit.c +++ b/cpukit/posix/src/condinit.c @@ -72,7 +72,7 @@ int pthread_cond_init( ETIMEDOUT ); - _Objects_Open( + _Objects_Open_u32( &_POSIX_Condition_variables_Information, &the_cond->Object, 0 diff --git a/cpukit/posix/src/keycreate.c b/cpukit/posix/src/keycreate.c index faf2a75a35..b54a25812a 100644 --- a/cpukit/posix/src/keycreate.c +++ b/cpukit/posix/src/keycreate.c @@ -98,7 +98,7 @@ int pthread_key_create( the_key->is_active = TRUE; - _Objects_Open( &_POSIX_Keys_Information, &the_key->Object, 0 ); + _Objects_Open_u32( &_POSIX_Keys_Information, &the_key->Object, 0 ); *key = the_key->Object.id; diff --git a/cpukit/posix/src/mqueuecreatesupp.c b/cpukit/posix/src/mqueuecreatesupp.c index 2856832718..d6c45f09f4 100644 --- a/cpukit/posix/src/mqueuecreatesupp.c +++ b/cpukit/posix/src/mqueuecreatesupp.c @@ -142,10 +142,10 @@ int _POSIX_Message_queue_Create_support( rtems_set_errno_and_return_minus_one( ENOSPC ); } - _Objects_Open( + _Objects_Open_string( &_POSIX_Message_queue_Information, &the_mq->Object, - (char *) name + name ); *message_queue = the_mq; diff --git a/cpukit/posix/src/mqueuedeletesupp.c b/cpukit/posix/src/mqueuedeletesupp.c index 6d4cd3a908..2aec9c0898 100644 --- a/cpukit/posix/src/mqueuedeletesupp.c +++ b/cpukit/posix/src/mqueuedeletesupp.c @@ -51,10 +51,12 @@ void _POSIX_Message_queue_Delete( { if ( !the_mq->linked && !the_mq->open_count ) { /* the name memory may have been freed by unlink. */ - if ( the_mq->Object.name ) - _Workspace_Free( the_mq->Object.name ); + Objects_Control *the_object = &the_mq->Object; - _Objects_Close( &_POSIX_Message_queue_Information, &the_mq->Object ); + if ( the_object->name.name_p ) + _Workspace_Free( (void *)the_object->name.name_p ); + + _Objects_Close( &_POSIX_Message_queue_Information, the_object ); _CORE_message_queue_Close( &the_mq->Message_queue, diff --git a/cpukit/posix/src/mqueuenametoid.c b/cpukit/posix/src/mqueuenametoid.c index 942c754e36..bc74e7d182 100644 --- a/cpukit/posix/src/mqueuenametoid.c +++ b/cpukit/posix/src/mqueuenametoid.c @@ -63,8 +63,8 @@ int _POSIX_Message_queue_Name_to_id( if( strlen(name) > PATH_MAX ) return ENAMETOOLONG; - status = _Objects_Name_to_id( - &_POSIX_Message_queue_Information, (char *)name, 0, id ); + status = _Objects_Name_to_id_string( + &_POSIX_Message_queue_Information, name, 0, id ); if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL ) return 0; diff --git a/cpukit/posix/src/mqueueopen.c b/cpukit/posix/src/mqueueopen.c index e818298bac..1305d3fc65 100644 --- a/cpukit/posix/src/mqueueopen.c +++ b/cpukit/posix/src/mqueueopen.c @@ -119,7 +119,7 @@ mqd_t mq_open( the_mq = _POSIX_Message_queue_Get( the_mq_id, &location ); the_mq->open_count += 1; the_mq_fd->Queue = the_mq; - _Objects_Open( + _Objects_Open_string( &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object, NULL @@ -153,7 +153,7 @@ mqd_t mq_open( } the_mq_fd->Queue = the_mq; - _Objects_Open( + _Objects_Open_string( &_POSIX_Message_queue_Information_fds, &the_mq_fd->Object, NULL diff --git a/cpukit/posix/src/mqueueunlink.c b/cpukit/posix/src/mqueueunlink.c index 7805b1d99a..ff6aec86fe 100644 --- a/cpukit/posix/src/mqueueunlink.c +++ b/cpukit/posix/src/mqueueunlink.c @@ -67,7 +67,8 @@ int mq_unlink( ); the_mq->linked = FALSE; - _Workspace_Free( the_mq->Object.name ); + if ( the_mq->Object.name.name_p ) + _Workspace_Free( (void *)the_mq->Object.name.name_p ); _POSIX_Message_queue_Namespace_remove( the_mq ); _POSIX_Message_queue_Delete( the_mq ); diff --git a/cpukit/posix/src/mutexinit.c b/cpukit/posix/src/mutexinit.c index 1a30740633..da6af07c12 100644 --- a/cpukit/posix/src/mutexinit.c +++ b/cpukit/posix/src/mutexinit.c @@ -159,7 +159,7 @@ int pthread_mutex_init( CORE_MUTEX_UNLOCKED ); - _Objects_Open( &_POSIX_Mutex_Information, &the_mutex->Object, 0 ); + _Objects_Open_u32( &_POSIX_Mutex_Information, &the_mutex->Object, 0 ); *mutex = the_mutex->Object.id; diff --git a/cpukit/posix/src/pbarrierinit.c b/cpukit/posix/src/pbarrierinit.c index 816e695504..a2a77f83a5 100644 --- a/cpukit/posix/src/pbarrierinit.c +++ b/cpukit/posix/src/pbarrierinit.c @@ -101,7 +101,7 @@ int pthread_barrier_init( _CORE_barrier_Initialize( &the_barrier->Barrier, &the_attributes ); - _Objects_Open( + _Objects_Open_u32( &_POSIX_Barrier_Information, &the_barrier->Object, 0 diff --git a/cpukit/posix/src/prwlockinit.c b/cpukit/posix/src/prwlockinit.c index 7149a68e09..e769a9b031 100644 --- a/cpukit/posix/src/prwlockinit.c +++ b/cpukit/posix/src/prwlockinit.c @@ -95,7 +95,7 @@ int pthread_rwlock_init( _CORE_RWLock_Initialize( &the_rwlock->RWLock, &the_attributes ); - _Objects_Open( + _Objects_Open_u32( &_POSIX_RWLock_Information, &the_rwlock->Object, 0 diff --git a/cpukit/posix/src/pspininit.c b/cpukit/posix/src/pspininit.c index d7eb39a485..6a0f707609 100644 --- a/cpukit/posix/src/pspininit.c +++ b/cpukit/posix/src/pspininit.c @@ -67,11 +67,7 @@ int pthread_spin_init( _CORE_spinlock_Initialize( &the_spinlock->Spinlock, &attributes ); - _Objects_Open( - &_POSIX_Spinlock_Information, - &the_spinlock->Object, - 0 - ); + _Objects_Open_u32( &_POSIX_Spinlock_Information, &the_spinlock->Object, 0 ); *spinlock = the_spinlock->Object.id; diff --git a/cpukit/posix/src/pthreadcreate.c b/cpukit/posix/src/pthreadcreate.c index e5aff1ea78..c239036e1b 100644 --- a/cpukit/posix/src/pthreadcreate.c +++ b/cpukit/posix/src/pthreadcreate.c @@ -42,6 +42,7 @@ int pthread_create( POSIX_API_Control *api; int schedpolicy = SCHED_RR; struct sched_param schedparam; + Objects_Name name; the_attr = (attr) ? attr : &_POSIX_Threads_Default_attributes; @@ -175,6 +176,7 @@ int pthread_create( * Initialize the core thread for this task. */ + name.name_p = NULL; /* posix threads don't have a name by default */ status = _Thread_Initialize( &_POSIX_Threads_Information, the_thread, @@ -186,7 +188,7 @@ int pthread_create( budget_algorithm, budget_callout, 0, /* isr level */ - NULL /* posix threads don't have a name */ + name /* posix threads don't have a name */ ); if ( !status ) { diff --git a/cpukit/posix/src/pthreadexit.c b/cpukit/posix/src/pthreadexit.c index 8346f139b8..ef3b3302bd 100644 --- a/cpukit/posix/src/pthreadexit.c +++ b/cpukit/posix/src/pthreadexit.c @@ -33,9 +33,11 @@ void pthread_exit( the_information = _Objects_Get_information( _Thread_Executing->Object.id ); - /* This should never happen if _Thread_Get() works right */ - assert( the_information ); - + /* + * the_information has to be non-NULL. Otherwise, we couldn't be + * running in a thread of this API and class. + */ + _Thread_Disable_dispatch(); _Thread_Executing->Wait.return_argument = value_ptr; diff --git a/cpukit/posix/src/semaphorecreatesupp.c b/cpukit/posix/src/semaphorecreatesupp.c index fb87f0f8a6..0ee09f5fa6 100644 --- a/cpukit/posix/src/semaphorecreatesupp.c +++ b/cpukit/posix/src/semaphorecreatesupp.c @@ -106,7 +106,11 @@ int _POSIX_Semaphore_Create_support( * Make the semaphore available for use. */ - _Objects_Open(&_POSIX_Semaphore_Information, &the_semaphore->Object, name_p); + _Objects_Open_string( + &_POSIX_Semaphore_Information, + &the_semaphore->Object, + name_p + ); *the_sem = the_semaphore; diff --git a/cpukit/posix/src/semaphorenametoid.c b/cpukit/posix/src/semaphorenametoid.c index 2051cb07ca..071745c3d5 100644 --- a/cpukit/posix/src/semaphorenametoid.c +++ b/cpukit/posix/src/semaphorenametoid.c @@ -48,8 +48,8 @@ int _POSIX_Semaphore_Name_to_id( if ( !name[0] ) return EINVAL; - status = _Objects_Name_to_id( - &_POSIX_Semaphore_Information, (char *)name, 0, (Objects_Id*)id ); + status = _Objects_Name_to_id_string( + &_POSIX_Semaphore_Information, name, 0, (Objects_Id*)id ); if ( status == OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL ) return 0; diff --git a/cpukit/posix/src/timercreate.c b/cpukit/posix/src/timercreate.c index 90cb9b0f8b..da4fe3641c 100644 --- a/cpukit/posix/src/timercreate.c +++ b/cpukit/posix/src/timercreate.c @@ -89,7 +89,7 @@ int timer_create( ptimer->timer_data.it_interval.tv_nsec = 0; _Watchdog_Initialize( &ptimer->Timer, NULL, 0, NULL ); - _Objects_Open(&_POSIX_Timer_Information, &ptimer->Object, (Objects_Name) 0); + _Objects_Open_u32(&_POSIX_Timer_Information, &ptimer->Object, 0); *timerid = ptimer->Object.id; _Thread_Enable_dispatch(); diff --git a/cpukit/rtems/src/barrierident.c b/cpukit/rtems/src/barrierident.c index a860e08115..6b90dacf70 100644 --- a/cpukit/rtems/src/barrierident.c +++ b/cpukit/rtems/src/barrierident.c @@ -45,9 +45,9 @@ rtems_status_code rtems_barrier_ident( { Objects_Name_or_id_lookup_errors status; - status = _Objects_Name_to_id( + status = _Objects_Name_to_id_u32( &_Barrier_Information, - (Objects_Name) name, + name, OBJECTS_SEARCH_LOCAL_NODE, id ); diff --git a/cpukit/rtems/src/dpmemident.c b/cpukit/rtems/src/dpmemident.c index 7d24b3a70c..e9b4d4e288 100644 --- a/cpukit/rtems/src/dpmemident.c +++ b/cpukit/rtems/src/dpmemident.c @@ -48,9 +48,9 @@ rtems_status_code rtems_port_ident( { Objects_Name_or_id_lookup_errors status; - status = _Objects_Name_to_id( + status = _Objects_Name_to_id_u32( &_Dual_ported_memory_Information, - (Objects_Name) name, + name, OBJECTS_SEARCH_ALL_NODES, id ); diff --git a/cpukit/rtems/src/msgqident.c b/cpukit/rtems/src/msgqident.c index 41289a2996..435da557e5 100644 --- a/cpukit/rtems/src/msgqident.c +++ b/cpukit/rtems/src/msgqident.c @@ -60,9 +60,9 @@ rtems_status_code rtems_message_queue_ident( { Objects_Name_or_id_lookup_errors status; - status = _Objects_Name_to_id( + status = _Objects_Name_to_id_u32( &_Message_queue_Information, - (Objects_Name) name, + name, node, id ); diff --git a/cpukit/rtems/src/partident.c b/cpukit/rtems/src/partident.c index 157a634912..71159a5330 100644 --- a/cpukit/rtems/src/partident.c +++ b/cpukit/rtems/src/partident.c @@ -51,12 +51,7 @@ rtems_status_code rtems_partition_ident( { Objects_Name_or_id_lookup_errors status; - status = _Objects_Name_to_id( - &_Partition_Information, - (Objects_Name) name, - node, - id - ); + status = _Objects_Name_to_id_u32( &_Partition_Information, name, node, id ); return _Status_Object_name_errors_to_status[ status ]; } diff --git a/cpukit/rtems/src/ratemonident.c b/cpukit/rtems/src/ratemonident.c index bfe7ad4148..bd9bb3a83d 100644 --- a/cpukit/rtems/src/ratemonident.c +++ b/cpukit/rtems/src/ratemonident.c @@ -47,9 +47,9 @@ rtems_status_code rtems_rate_monotonic_ident( { Objects_Name_or_id_lookup_errors status; - status = _Objects_Name_to_id( + status = _Objects_Name_to_id_u32( &_Rate_monotonic_Information, - (Objects_Name) name, + name, OBJECTS_SEARCH_LOCAL_NODE, id ); diff --git a/cpukit/rtems/src/regionident.c b/cpukit/rtems/src/regionident.c index f60903c150..adeba9ffe7 100644 --- a/cpukit/rtems/src/regionident.c +++ b/cpukit/rtems/src/regionident.c @@ -50,9 +50,9 @@ rtems_status_code rtems_region_ident( { Objects_Name_or_id_lookup_errors status; - status = _Objects_Name_to_id( + status = _Objects_Name_to_id_u32( &_Region_Information, - (Objects_Name) name, + name, OBJECTS_SEARCH_LOCAL_NODE, id ); diff --git a/cpukit/rtems/src/semident.c b/cpukit/rtems/src/semident.c index 1e92823172..56f8856da7 100644 --- a/cpukit/rtems/src/semident.c +++ b/cpukit/rtems/src/semident.c @@ -75,12 +75,7 @@ rtems_status_code rtems_semaphore_ident( { Objects_Name_or_id_lookup_errors status; - status = _Objects_Name_to_id( - &_Semaphore_Information, - (Objects_Name) name, - node, - id - ); + status = _Objects_Name_to_id_u32( &_Semaphore_Information, name, node, id ); return _Status_Object_name_errors_to_status[ status ]; } diff --git a/cpukit/rtems/src/taskident.c b/cpukit/rtems/src/taskident.c index 2c9d7169a6..7e74edb9bf 100644 --- a/cpukit/rtems/src/taskident.c +++ b/cpukit/rtems/src/taskident.c @@ -66,12 +66,7 @@ rtems_status_code rtems_task_ident( return RTEMS_SUCCESSFUL; } - status = _Objects_Name_to_id( - &_RTEMS_tasks_Information, - (Objects_Name) name, - node, - id - ); + status = _Objects_Name_to_id_u32( &_RTEMS_tasks_Information, name, node, id ); return _Status_Object_name_errors_to_status[ status ]; } diff --git a/cpukit/rtems/src/timerident.c b/cpukit/rtems/src/timerident.c index 2996e05ada..af32943bc7 100644 --- a/cpukit/rtems/src/timerident.c +++ b/cpukit/rtems/src/timerident.c @@ -49,9 +49,9 @@ rtems_status_code rtems_timer_ident( { Objects_Name_or_id_lookup_errors status; - status = _Objects_Name_to_id( + status = _Objects_Name_to_id_u32( &_Timer_Information, - (Objects_Name) name, + name, OBJECTS_SEARCH_LOCAL_NODE, id ); diff --git a/cpukit/sapi/src/extensionident.c b/cpukit/sapi/src/extensionident.c index 79ba46f12f..767deee166 100644 --- a/cpukit/sapi/src/extensionident.c +++ b/cpukit/sapi/src/extensionident.c @@ -45,9 +45,9 @@ rtems_status_code rtems_extension_ident( { Objects_Name_or_id_lookup_errors status; - status = _Objects_Name_to_id( + status = _Objects_Name_to_id_u32( &_Extension_Information, - (Objects_Name) name, + name, OBJECTS_SEARCH_LOCAL_NODE, id ); diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 3440af7090..f5aae2d610 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -113,11 +113,9 @@ libscore_a_SOURCES += src/heap.c src/heapallocate.c src/heapextend.c \ ## OBJECT_C_FILES libscore_a_SOURCES += src/object.c src/objectallocate.c \ - src/objectclearname.c src/objectcomparenameraw.c \ - src/objectcomparenamestring.c src/objectcopynameraw.c \ - src/objectcopynamestring.c src/objectextendinformation.c \ - src/objectfree.c src/objectget.c src/objectgetisr.c src/objectgetnext.c \ - src/objectinitializeinformation.c src/objectnametoid.c \ + src/objectextendinformation.c src/objectfree.c src/objectget.c \ + src/objectgetisr.c src/objectgetnext.c src/objectinitializeinformation.c \ + src/objectnametoid.c src/objectnametoidstring.c \ src/objectshrinkinformation.c src/objectgetnoprotection.c \ src/objectidtoname.c src/objectgetnameasstring.c diff --git a/cpukit/score/include/rtems/score/object.h b/cpukit/score/include/rtems/score/object.h index 9b328a67a3..7ed0a8300b 100644 --- a/cpukit/score/include/rtems/score/object.h +++ b/cpukit/score/include/rtems/score/object.h @@ -33,7 +33,12 @@ extern "C" { * The following type defines the control block used to manage * object names. */ -typedef void * Objects_Name; +typedef union { + /** This is a pointer to a string name. */ + const char *name_p; + /** This is the actual 32-bit "raw" integer name. */ + uint32_t name_u32; +} Objects_Name; /** * Space for object names is allocated in multiples of this. @@ -337,7 +342,8 @@ typedef struct { /** This points to the table of local objects. */ Objects_Control **local_table; /** This points to the table of local object names. */ - Objects_Name *name_table; + /* XXX should be safe to remove this field */ + uint32_t **name_table; /** This is the chain of inactive control blocks. */ Chain_Control Inactive; /** This is the number of objects on the Inactive list. */ @@ -533,69 +539,6 @@ void _Objects_Free( ); /** - * This method zeroes out the name. - * - * @param[in] name points to the name to be zeroed out. - * @param[in] length is the length of the object name field. - */ -void _Objects_Clear_name( - void *name, - const size_t length -); - -/** - * This method copies a string style object name from source to destination. - * - * @param[in] source is the source name to copy. - * @param[in] destination is the destination of the copy. - * @param[in] length is the number of bytes to copy. - */ -void _Objects_Copy_name_string( - const void *source, - void *destination, - const size_t length -); - -/** - * This method copies a raw style object name from source to destination. - * - * @param[in] source is the source name to copy. - * @param[in] destination is the destination of the copy. - * @param[in] length is the number of bytes to copy. - */ -void _Objects_Copy_name_raw( - const void *source, - void *destination, - const size_t length -); - -/** - * This method compares two string style object names. - * - * @param[in] name_1 is the left hand name to compare. - * @param[in] name_2 is the right hand name to compare. - * @param[in] length is the length of the names to compare. - */ -boolean _Objects_Compare_name_string( - void *name_1, - void *name_2, - uint16_t length -); - -/** - * This method compares two raw style object names. - * - * @param[in] name_1 is the left hand name to compare. - * @param[in] name_2 is the right hand name to compare. - * @param[in] length is the length of the names to compare. - */ -boolean _Objects_Compare_name_raw( - void *name_1, - void *name_2, - uint16_t length -); - -/** * This function implements the common portion of the object * identification directives. This directive returns the object * id associated with name. If more than one object of this class @@ -637,9 +580,30 @@ typedef enum { * successful or failure. On success @a id will contain the Id of * the requested object. */ -Objects_Name_or_id_lookup_errors _Objects_Name_to_id( +Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32( + Objects_Information *information, + uint32_t name, + uint32_t node, + Objects_Id *id +); + +/** + * This method converts an object name to an Id. It performs a look up + * using the object information block for this object class. + * + * @param[in] information points to an object class information block. + * @param[in] name is the name of the object to find. + * @param[in] node is the set of nodes to search. + * @param[in] id will contain the Id if the search is successful. + * + * @return This method returns one of the values from the + * @ref Objects_Name_or_id_lookup_errors enumeration to indicate + * successful or failure. On success @a id will contain the Id of + * the requested object. + */ +Objects_Name_or_id_lookup_errors _Objects_Name_to_id_string( Objects_Information *information, - Objects_Name name, + const char *name, uint32_t node, Objects_Id *id ); diff --git a/cpukit/score/inline/rtems/score/object.inl b/cpukit/score/inline/rtems/score/object.inl index 32105ddba2..f541220270 100644 --- a/cpukit/score/inline/rtems/score/object.inl +++ b/cpukit/score/inline/rtems/score/object.inl @@ -289,12 +289,53 @@ RTEMS_INLINE_ROUTINE void _Objects_Open( index = _Objects_Get_index( the_object->id ); _Objects_Set_local_object( information, index, the_object ); - if ( information->is_string ) - /* _Objects_Copy_name_string( name, the_object->name ); */ - the_object->name = name; - else - /* _Objects_Copy_name_raw( name, the_object->name, information->name_length ); */ - the_object->name = name; + the_object->name = name; +} + +/** + * This function places the_object control pointer and object name + * in the Local Pointer and Local Name Tables, respectively. + * + * @param[in] information points to an Object Information Table + * @param[in] the_object is a pointer to an object + * @param[in] name is the name of the object to make accessible + */ +RTEMS_INLINE_ROUTINE void _Objects_Open_u32( + Objects_Information *information, + Objects_Control *the_object, + uint32_t name +) +{ + uint32_t index; + + index = _Objects_Get_index( the_object->id ); + _Objects_Set_local_object( information, index, the_object ); + + /* ASSERT: information->is_string == FALSE */ + the_object->name.name_u32 = name; +} + +/** + * This function places the_object control pointer and object name + * in the Local Pointer and Local Name Tables, respectively. + * + * @param[in] information points to an Object Information Table + * @param[in] the_object is a pointer to an object + * @param[in] name is the name of the object to make accessible + */ +RTEMS_INLINE_ROUTINE void _Objects_Open_string( + Objects_Information *information, + Objects_Control *the_object, + const char *name +) +{ + uint32_t index; + + index = _Objects_Get_index( the_object->id ); + _Objects_Set_local_object( information, index, the_object ); + + /* information->is_string */ + the_object->name.name_p = name; } /** @@ -309,12 +350,14 @@ RTEMS_INLINE_ROUTINE void _Objects_Close( Objects_Control *the_object ) { - uint32_t index; + _Objects_Set_local_object( + information, + _Objects_Get_index( the_object->id ), + NULL + ); - index = _Objects_Get_index( the_object->id ); - _Objects_Set_local_object( information, index, NULL ); - /* _Objects_Clear_name( the_object->name, information->name_length ); */ - the_object->name = 0; + the_object->name.name_u32 = 0; + the_object->name.name_p = NULL; } /** @@ -328,8 +371,11 @@ RTEMS_INLINE_ROUTINE void _Objects_Namespace_remove( Objects_Control *the_object ) { - /* _Objects_Clear_name( the_object->name, information->name_length ); */ - the_object->name = 0; + /* + * Clear out either format. + */ + the_object->name.name_p = NULL; + the_object->name.name_u32 = 0; } #endif diff --git a/cpukit/score/src/apimutexallocate.c b/cpukit/score/src/apimutexallocate.c index 627a33dae4..4d96868cb3 100644 --- a/cpukit/score/src/apimutexallocate.c +++ b/cpukit/score/src/apimutexallocate.c @@ -21,6 +21,7 @@ void _API_Mutex_Allocate( ) { API_Mutex_Control *mutex; + CORE_mutex_Attributes attr = { CORE_MUTEX_NESTING_IS_ERROR, FALSE, @@ -32,7 +33,7 @@ void _API_Mutex_Allocate( _CORE_mutex_Initialize( &mutex->Mutex, &attr, CORE_MUTEX_UNLOCKED ); - _Objects_Open( &_API_Mutex_Information, &mutex->Object, (Objects_Name) 1 ); + _Objects_Open_u32( &_API_Mutex_Information, &mutex->Object, 1 ); *the_mutex = mutex; } diff --git a/cpukit/score/src/objectclearname.c b/cpukit/score/src/objectclearname.c deleted file mode 100644 index f0845810ab..0000000000 --- a/cpukit/score/src/objectclearname.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Object Handler - * - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - * - * $Id$ - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/system.h> -#include <rtems/score/address.h> -#include <rtems/score/chain.h> -#include <rtems/score/object.h> -#if defined(RTEMS_MULTIPROCESSING) -#include <rtems/score/objectmp.h> -#endif -#include <rtems/score/thread.h> -#include <rtems/score/wkspace.h> -#include <rtems/score/sysstate.h> -#include <rtems/score/isr.h> - -/*PAGE - * - * _Objects_Clear_name - * - * This method clears the specified name so that no caller can do a name to - * ID/object lookup past this point. - */ - -void _Objects_Clear_name( - void *name, - const size_t length -) -{ - size_t index; - size_t maximum = length / OBJECTS_NAME_ALIGNMENT; - uint32_t *name_ptr = (uint32_t *) name; - - for ( index=0 ; index < maximum ; index++ ) - *name_ptr++ = 0; -} diff --git a/cpukit/score/src/objectcomparenameraw.c b/cpukit/score/src/objectcomparenameraw.c deleted file mode 100644 index 870d55d651..0000000000 --- a/cpukit/score/src/objectcomparenameraw.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Object Handler - * - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - * - * $Id$ - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/system.h> -#include <rtems/score/address.h> -#include <rtems/score/chain.h> -#include <rtems/score/object.h> -#if defined(RTEMS_MULTIPROCESSING) -#include <rtems/score/objectmp.h> -#endif -#include <rtems/score/thread.h> -#include <rtems/score/wkspace.h> -#include <rtems/score/sysstate.h> -#include <rtems/score/isr.h> - -/*PAGE - * - * _Objects_Compare_name_raw - * - * XXX - */ - -boolean _Objects_Compare_name_raw( - void *name_1, - void *name_2, - uint16_t length -) -{ -#if 0 - uint32_t *name_1_p = (uint32_t *) name_1; - uint32_t *name_2_p = (uint32_t *) name_2; - uint32_t tmp_length = length / OBJECTS_NAME_ALIGNMENT; -#endif - - if ( name_1 == name_2 ) - return TRUE; - return FALSE; - -#if 0 - while ( tmp_length-- ) - if ( *name_1_p++ != *name_2_p++ ) - return FALSE; - - return TRUE; -#endif -} diff --git a/cpukit/score/src/objectcomparenamestring.c b/cpukit/score/src/objectcomparenamestring.c deleted file mode 100644 index a9b3be1e7b..0000000000 --- a/cpukit/score/src/objectcomparenamestring.c +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Object Handler - * - * - * COPYRIGHT (c) 1989-2002. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - * - * $Id$ - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/system.h> -#include <rtems/score/address.h> -#include <rtems/score/chain.h> -#include <rtems/score/object.h> -#if defined(RTEMS_MULTIPROCESSING) -#include <rtems/score/objectmp.h> -#endif -#include <rtems/score/thread.h> -#include <rtems/score/wkspace.h> -#include <rtems/score/sysstate.h> -#include <rtems/score/isr.h> - -#include <string.h> - -/*PAGE - * - * _Objects_Compare_name_string - * - * This routine compares the name of an object with the specified string. - * - * Input parameters: - * name_1 - one name - * name_2 - other name - * length - maximum length to compare - * - * Output parameters: - * returns - TRUE on a match - */ - -boolean _Objects_Compare_name_string( - void *name_1, - void *name_2, - uint16_t length -) -{ - if ( !strncmp( name_1, name_2, length ) ) - return TRUE; - return FALSE; -} diff --git a/cpukit/score/src/objectcopynameraw.c b/cpukit/score/src/objectcopynameraw.c deleted file mode 100644 index 5534323a4c..0000000000 --- a/cpukit/score/src/objectcopynameraw.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Object Handler - * - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - * - * $Id$ - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/system.h> -#include <rtems/score/address.h> -#include <rtems/score/chain.h> -#include <rtems/score/object.h> -#if defined(RTEMS_MULTIPROCESSING) -#include <rtems/score/objectmp.h> -#endif -#include <rtems/score/thread.h> -#include <rtems/score/wkspace.h> -#include <rtems/score/sysstate.h> -#include <rtems/score/isr.h> - -/*PAGE - * - * _Objects_Copy_name_raw - * - * XXX - */ - -void _Objects_Copy_name_raw( - const void *source, - void *destination, - const size_t length -) -{ - uint32_t *source_p = (uint32_t *) source; - uint32_t *destination_p = (uint32_t *) destination; - size_t tmp_length = length / OBJECTS_NAME_ALIGNMENT; - - while ( tmp_length-- ) - *destination_p++ = *source_p++; -} diff --git a/cpukit/score/src/objectcopynamestring.c b/cpukit/score/src/objectcopynamestring.c deleted file mode 100644 index 764e9aa172..0000000000 --- a/cpukit/score/src/objectcopynamestring.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Object Handler - * - * - * COPYRIGHT (c) 1989-1999. - * On-Line Applications Research Corporation (OAR). - * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.com/license/LICENSE. - * - * $Id$ - */ - -#if HAVE_CONFIG_H -#include "config.h" -#endif - -#include <rtems/system.h> -#include <rtems/score/address.h> -#include <rtems/score/chain.h> -#include <rtems/score/object.h> -#if defined(RTEMS_MULTIPROCESSING) -#include <rtems/score/objectmp.h> -#endif -#include <rtems/score/thread.h> -#include <rtems/score/wkspace.h> -#include <rtems/score/sysstate.h> -#include <rtems/score/isr.h> - -/*PAGE - * - * _Objects_Copy_name_string - * - * XXX - */ - -void _Objects_Copy_name_string( - const void *source, - void *destination, - const size_t length -) -{ - uint8_t *source_p = (uint8_t *) source; - uint8_t *destination_p = (uint8_t *) destination; - - *destination_p = '\0'; - if ( source_p ) { - do { - *destination_p++ = *source_p; - } while ( *source_p++ ); - } -} diff --git a/cpukit/score/src/objectextendinformation.c b/cpukit/score/src/objectextendinformation.c index 538ab139bb..8db0bf5b9b 100644 --- a/cpukit/score/src/objectextendinformation.c +++ b/cpukit/score/src/objectextendinformation.c @@ -84,7 +84,7 @@ void _Objects_Extend_information( if (index_base >= information->maximum ) { ISR_Level level; void **object_blocks; - Objects_Name *name_table; + void **name_table; uint32_t *inactive_per_block; Objects_Control **local_table; uint32_t maximum; @@ -147,7 +147,7 @@ void _Objects_Extend_information( inactive_per_block = (uint32_t *) _Addresses_Add_offset( object_blocks, block_count * sizeof(void*) ); - name_table = (Objects_Name *) _Addresses_Add_offset( + name_table = (void *) _Addresses_Add_offset( inactive_per_block, block_count * sizeof(uint32_t ) ); local_table = (Objects_Control **) _Addresses_Add_offset( name_table, block_count * sizeof(Objects_Name *) ); @@ -195,7 +195,7 @@ void _Objects_Extend_information( object_blocks[block_count] = NULL; inactive_per_block[block_count] = 0; - name_table[block_count] = NULL; + // name_table[block_count] = NULL; for ( index=index_base ; index < ( information->allocation_size + index_base ); @@ -209,7 +209,7 @@ void _Objects_Extend_information( information->object_blocks = object_blocks; information->inactive_per_block = inactive_per_block; - information->name_table = name_table; + information->name_table = (void *)name_table; information->local_table = local_table; information->maximum = maximum; information->maximum_id = _Objects_Build_id( @@ -253,7 +253,7 @@ void _Objects_Extend_information( information->object_blocks[ block ], (information->allocation_size * information->size) ); - information->name_table[ block ] = name_area; + // information->name_table[ block ] = name_area; /* * Initialize objects .. add to a local chain first. @@ -281,9 +281,7 @@ void _Objects_Extend_information( index ); - the_object->name = (void *) name_area; - - name_area = _Addresses_Add_offset( name_area, information->name_length ); + name_area = (void *)_Addresses_Add_offset( name_area, information->name_length ); _Chain_Append( &information->Inactive, &the_object->Node ); diff --git a/cpukit/score/src/objectgetnameasstring.c b/cpukit/score/src/objectgetnameasstring.c index a8b72c9d98..e19059ffd8 100644 --- a/cpukit/score/src/objectgetnameasstring.c +++ b/cpukit/score/src/objectgetnameasstring.c @@ -35,7 +35,7 @@ char *_Objects_Get_name_as_string( ) { Objects_Information *information; - char *s; + const char *s; char *d; uint32_t i; char lname[5]; @@ -65,9 +65,9 @@ char *_Objects_Get_name_as_string( case OBJECTS_LOCAL: if ( information->is_string ) { - s = the_object->name; + s = the_object->name.name_p; } else { - uint32_t u32_name = (uint32_t) the_object->name; + uint32_t u32_name = (uint32_t) the_object->name.name_u32; lname[ 0 ] = (u32_name >> 24) & 0xff; lname[ 1 ] = (u32_name >> 16) & 0xff; diff --git a/cpukit/score/src/objectmp.c b/cpukit/score/src/objectmp.c index 1eb678557a..dae942cb63 100644 --- a/cpukit/score/src/objectmp.c +++ b/cpukit/score/src/objectmp.c @@ -192,7 +192,7 @@ Objects_Name_or_id_lookup_errors _Objects_MP_Global_name_search ( /* * NOTE: The local node was search (if necessary) by - * _Objects_Name_to_id before this was invoked. + * _Objects_Name_to_id_XXX before this was invoked. */ if ( !_Objects_Is_local_node( node_index ) ) { @@ -239,7 +239,7 @@ void _Objects_MP_Is_remote ( /* * NOTE: The local node was search (if necessary) by - * _Objects_Name_to_id before this was invoked. + * _Objects_Name_to_id_XXX before this was invoked. * * The NODE field of an object id cannot be 0 * because 0 is an invalid node number. diff --git a/cpukit/score/src/objectnametoid.c b/cpukit/score/src/objectnametoid.c index 03e9d1da28..cc523e17b9 100644 --- a/cpukit/score/src/objectnametoid.c +++ b/cpukit/score/src/objectnametoid.c @@ -2,7 +2,7 @@ * Object Handler * * - * COPYRIGHT (c) 1989-1999. + * COPYRIGHT (c) 1989-2008. * On-Line Applications Research Corporation (OAR). * * The license and distribution terms for this file may be @@ -30,7 +30,7 @@ /*PAGE * - * _Objects_Name_to_id + * _Objects_Name_to_id_u32 * * These kernel routines search the object table(s) for the given * object name and returns the associated object id. @@ -47,9 +47,9 @@ * error code - if unsuccessful */ -Objects_Name_or_id_lookup_errors _Objects_Name_to_id( +Objects_Name_or_id_lookup_errors _Objects_Name_to_id_u32( Objects_Information *information, - Objects_Name name, + uint32_t name, uint32_t node, Objects_Id *id ) @@ -58,7 +58,8 @@ Objects_Name_or_id_lookup_errors _Objects_Name_to_id( Objects_Control *the_object; uint32_t index; uint32_t name_length; - Objects_Name_comparators compare_them; + + /* ASSERT: information->is_string == FALSE */ if ( !id ) return OBJECTS_INVALID_ADDRESS; @@ -78,15 +79,12 @@ Objects_Name_or_id_lookup_errors _Objects_Name_to_id( if ( search_local_node ) { name_length = information->name_length; - if ( information->is_string ) compare_them = _Objects_Compare_name_string; - else compare_them = _Objects_Compare_name_raw; - for ( index = 1; index <= information->maximum; index++ ) { the_object = information->local_table[ index ]; - if ( !the_object || !the_object->name ) + if ( !the_object ) continue; - if ( (*compare_them)( name, the_object->name, name_length ) ) { + if ( name == the_object->name.name_u32 ) { *id = the_object->id; return OBJECTS_NAME_OR_ID_LOOKUP_SUCCESSFUL; } |