summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/include/rtems/posix/posixapi.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-20 07:01:03 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2016-05-20 16:16:26 +0200
commit05f9b02e3c0927e69f96bafaac359a53c7f92322 (patch)
treecd888a5621379b636bf18b5aab6647ca7e18908a /cpukit/posix/include/rtems/posix/posixapi.h
parentscore: Use _RBTree_Insert_inline() (diff)
downloadrtems-05f9b02e3c0927e69f96bafaac359a53c7f92322.tar.bz2
posix: Add and use _POSIX_Get_object_body()
Diffstat (limited to '')
-rw-r--r--cpukit/posix/include/rtems/posix/posixapi.h32
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