diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-05-15 20:16:16 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2007-05-15 20:16:16 +0000 |
commit | e1bce866cf503c34f2914b76c9978bc598096013 (patch) | |
tree | d2419a46c38bc4d0eed2eaee219ec946de075596 /cpukit/score | |
parent | 2007-05-15 Ray Xu <rayx@gmail.com> (diff) | |
download | rtems-e1bce866cf503c34f2914b76c9978bc598096013.tar.bz2 |
2007-05-15 Joel Sherrill <joel.sherrill@oarcorp.com>
* Makefile.am, preinstall.am, libmisc/Makefile.am, rtems/Makefile.am,
rtems/include/rtems.h, rtems/include/rtems/rtems/ratemon.h,
rtems/inline/rtems/rtems/ratemon.inl, rtems/src/ratemoncancel.c,
rtems/src/ratemoncreate.c, rtems/src/ratemondelete.c,
rtems/src/ratemongetstatus.c, rtems/src/ratemonident.c,
rtems/src/ratemonperiod.c, rtems/src/ratemontimeout.c,
score/Makefile.am, score/include/rtems/score/object.h,
score/src/threadhandler.c, wrapup/Makefile.am: Integrate Rate
Monotonic Statistics and Period Usage into Rate Monotonic Manager.
Added the following directives: rtems_rate_monotonic_get_statistics,
rtems_rate_monotonic_reset_statistics,
rtems_rate_montonic_reset_all_statistics,
rtems_rate_montonic_report_statistics, and rtems_object_get_name.
Obsoleted the rtems/rtmonuse.h file as a public interface.
* rtems/src/ratemongetstatistics.c,
rtems/src/ratemonreportstatistics.c, rtems/src/ratemonresetall.c,
rtems/src/ratemonresetstatistics.c, rtems/src/rtemsobjectgetname.c,
score/src/objectgetnameasstring.c: New files.
* libmisc/rtmonuse/rtmonuse.c, libmisc/rtmonuse/rtmonuse.h: Removed.
Diffstat (limited to 'cpukit/score')
-rw-r--r-- | cpukit/score/Makefile.am | 2 | ||||
-rw-r--r-- | cpukit/score/include/rtems/score/object.h | 18 | ||||
-rw-r--r-- | cpukit/score/src/objectgetnameasstring.c | 96 | ||||
-rw-r--r-- | cpukit/score/src/threadhandler.c | 7 |
4 files changed, 121 insertions, 2 deletions
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am index 9c9fd67919..3699743ce9 100644 --- a/cpukit/score/Makefile.am +++ b/cpukit/score/Makefile.am @@ -114,7 +114,7 @@ libscore_a_SOURCES += src/object.c src/objectallocate.c \ src/objectgetisr.c src/objectgetbyindex.c src/objectgetnext.c \ src/objectinitializeinformation.c src/objectnametoid.c \ src/objectshrinkinformation.c src/objectgetnoprotection.c \ - src/objectidtoname.c + src/objectidtoname.c src/objectgetnameasstring.c ## PROTECTED_HEAP_C_FILES libscore_a_SOURCES += src/pheapallocatealigned.c src/pheapallocate.c \ diff --git a/cpukit/score/include/rtems/score/object.h b/cpukit/score/include/rtems/score/object.h index 3e03213dd1..c6592ee8bf 100644 --- a/cpukit/score/include/rtems/score/object.h +++ b/cpukit/score/include/rtems/score/object.h @@ -798,6 +798,24 @@ Objects_Control *_Objects_Get_next( Objects_Id *next_id_p ); +/** + * This method objects the name of an object and returns its name + * in the form of a C string. It attempts to be careful about + * overflowing the user's string and about returning unprintable characters. + * + * @param[in] id is the object to obtain the name of + * @param[in] length indicates the length of the caller's buffer + * @param[inout] name is a string which will be filled in. + * + * @return This method returns @a name or NULL on error. + */ + +char *_Objects_Get_name_as_string( + Objects_Id id, + size_t length, + char *name +); + /* * Pieces of object.inl are promoted out to the user */ diff --git a/cpukit/score/src/objectgetnameasstring.c b/cpukit/score/src/objectgetnameasstring.c new file mode 100644 index 0000000000..ec962e32a3 --- /dev/null +++ b/cpukit/score/src/objectgetnameasstring.c @@ -0,0 +1,96 @@ +/* + * COPYRIGHT (c) 1989-2007. + * 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$ + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems/system.h> +#include <rtems/score/object.h> +#include <rtems/score/thread.h> +#include <stdlib.h> +#include <stdio.h> +#include <ctype.h> +#include <inttypes.h> + + +/* + * This method objects the name of an object and returns its name + * in the form of a C string. It attempts to be careful about + * overflowing the user's string and about returning unprintable characters. + */ + +char *_Objects_Get_name_as_string( + Objects_Id id, + size_t length, + char *name +) +{ + #ifdef RTEMS_POSIX_API + Objects_Information *information; + #endif + char *s; + char *d; + uint32_t i; + char lname[5]; + Objects_Control *the_object; + Objects_Locations location; + + if ( length == 0 ) + return NULL; + + if ( name == NULL ) + return NULL; + + information = _Objects_Get_information( id ); + if ( !information ) + return NULL; + + the_object = _Objects_Get( information, id, &location ); + switch ( location ) { + + case OBJECTS_REMOTE: + /* not supported */ + case OBJECTS_ERROR: + return NULL; + + case OBJECTS_LOCAL: + + /* + * Neither the Classic nor ITRON APIs use string names. + */ + #ifdef RTEMS_POSIX_API + + if ( information->is_string ) { + s = the_object->name; + } else + #endif + { + uint32_t u32_name = (uint32_t) the_object->name; + + lname[ 0 ] = (u32_name >> 24) & 0xff; + lname[ 1 ] = (u32_name >> 16) & 0xff; + lname[ 2 ] = (u32_name >> 8) & 0xff; + lname[ 3 ] = (u32_name >> 0) & 0xff; + lname[ 4 ] = '\0'; + s = lname; + } + + for ( i=0, d=name ; i<(length-1) && *s ; i++, s++, d++ ) { + *d = (!isprint(*s)) ? '*' : *s; + } + *d = '\0'; + + _Thread_Enable_dispatch(); + return name; + } + return NULL; /* unreachable path */ +} diff --git a/cpukit/score/src/threadhandler.c b/cpukit/score/src/threadhandler.c index b7708e2b03..c11a8b34b5 100644 --- a/cpukit/score/src/threadhandler.c +++ b/cpukit/score/src/threadhandler.c @@ -112,7 +112,12 @@ void _Thread_Handler( void ) _Thread_Enable_dispatch(); #if defined(__USE_INIT_FINI__) - if (!doneCons && (volatile void *)_init) + /* + * _init could be a weak symbol and we SHOULD test it but it isn't + * in any configuration I know of and it generates a warning on every + * RTEMS target configuration. --joel (12 May 2007) + */ + if (!doneCons) /* && (volatile void *)_init) */ _init (); #endif #if defined(__USE__MAIN__) |