diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-20 07:01:03 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2016-05-20 16:16:26 +0200 |
commit | 05f9b02e3c0927e69f96bafaac359a53c7f92322 (patch) | |
tree | cd888a5621379b636bf18b5aab6647ca7e18908a /cpukit/posix/include | |
parent | score: Use _RBTree_Insert_inline() (diff) | |
download | rtems-05f9b02e3c0927e69f96bafaac359a53c7f92322.tar.bz2 |
posix: Add and use _POSIX_Get_object_body()
Diffstat (limited to 'cpukit/posix/include')
-rw-r--r-- | cpukit/posix/include/rtems/posix/posixapi.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cpukit/posix/include/rtems/posix/posixapi.h b/cpukit/posix/include/rtems/posix/posixapi.h index 0348e28e16..f2378c184a 100644 --- a/cpukit/posix/include/rtems/posix/posixapi.h +++ b/cpukit/posix/include/rtems/posix/posixapi.h @@ -21,6 +21,7 @@ #include <rtems/config.h> #include <rtems/score/assert.h> +#include <rtems/score/apimutex.h> #include <rtems/score/objectimpl.h> /** @@ -59,6 +60,37 @@ RTEMS_INLINE_ROUTINE int _POSIX_Get_by_name_error( return _POSIX_Get_by_name_error_table[ error ]; } +/** + * @brief Macro to generate a function body to get a POSIX object by + * identifier. + * + * Generates a function body to get the object for the specified indentifier. + * Performs automatic initialization if requested and necessary. This is an + * ugly macro, since C lacks support for templates. + */ +#define _POSIX_Get_object_body( \ + type, \ + id, \ + lock_context, \ + info, \ + initializer, \ + init \ +) \ + Objects_Control *the_object; \ + if ( id == NULL ) { \ + return NULL; \ + } \ + the_object = _Objects_Get_local( (Objects_Id) *id, lock_context, info ); \ + if ( the_object == NULL ) { \ + _Once_Lock(); \ + if ( *id == initializer ) { \ + init( id, NULL ); \ + } \ + _Once_Unlock(); \ + the_object = _Objects_Get_local( (Objects_Id) *id, lock_context, info ); \ + } \ + return (type *) the_object + /** @} */ #endif |