summaryrefslogtreecommitdiffstats
path: root/cpukit/posix/src/condinit.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-26 07:49:17 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-10-05 14:29:02 +0200
commit5222488573e3ba8c2eceffe29f878a73a3a81694 (patch)
tree4b4ca72268b8f40da493ca252780c197bd23a5ef /cpukit/posix/src/condinit.c
parentposix: Implement self-contained POSIX rwlocks (diff)
downloadrtems-5222488573e3ba8c2eceffe29f878a73a3a81694.tar.bz2
posix: Implement self-contained POSIX condvar
POSIX condition variables are now available in all configurations and no longer depend on --enable-posix. Update #2514. Update #3113.
Diffstat (limited to '')
-rw-r--r--cpukit/posix/src/condinit.c62
1 files changed, 35 insertions, 27 deletions
diff --git a/cpukit/posix/src/condinit.c b/cpukit/posix/src/condinit.c
index 8d3aa8e244..aab26aa9f7 100644
--- a/cpukit/posix/src/condinit.c
+++ b/cpukit/posix/src/condinit.c
@@ -21,6 +21,29 @@
#include <rtems/posix/condimpl.h>
#include <rtems/posix/posixapi.h>
+RTEMS_STATIC_ASSERT(
+ offsetof( POSIX_Condition_variables_Control, flags )
+ == offsetof( pthread_cond_t, _flags ),
+ POSIX_CONDITION_VARIABLES_CONTROL_FLAGS
+);
+
+RTEMS_STATIC_ASSERT(
+ offsetof( POSIX_Condition_variables_Control, mutex )
+ == offsetof( pthread_cond_t, _mutex ),
+ POSIX_CONDITION_VARIABLES_CONTROL_COUNT
+);
+
+RTEMS_STATIC_ASSERT(
+ offsetof( POSIX_Condition_variables_Control, Queue )
+ == offsetof( pthread_cond_t, _Queue ),
+ POSIX_CONDITION_VARIABLES_CONTROL_QUEUE
+);
+
+RTEMS_STATIC_ASSERT(
+ sizeof( POSIX_Condition_variables_Control ) == sizeof( pthread_cond_t ),
+ POSIX_CONDITION_VARIABLES_CONTROL_SIZE
+);
+
/**
* 11.4.2 Initializing and Destroying a Condition Variable,
* P1003.1c/Draft 10, p. 87
@@ -30,41 +53,26 @@ int pthread_cond_init(
const pthread_condattr_t *attr
)
{
- POSIX_Condition_variables_Control *the_cond;
- const pthread_condattr_t *the_attr;
+ POSIX_Condition_variables_Control *the_cond;
- if ( attr ) the_attr = attr;
- else the_attr = &_POSIX_Condition_variables_Default_attributes;
-
- /*
- * Be careful about attributes when global!!!
- */
-
- if ( !the_attr->is_initialized )
- return EINVAL;
+ the_cond = _POSIX_Condition_variables_Get( cond );
- if ( !_POSIX_Is_valid_pshared( the_attr->process_shared ) ) {
+ if ( the_cond == NULL ) {
return EINVAL;
}
- the_cond = _POSIX_Condition_variables_Allocate();
-
- if ( !the_cond ) {
- _Objects_Allocator_unlock();
- return ENOMEM;
+ if ( attr == NULL ) {
+ attr = &_POSIX_Condition_variables_Default_attributes;
}
- _POSIX_Condition_variables_Initialize( the_cond, the_attr );
-
- _Objects_Open_u32(
- &_POSIX_Condition_variables_Information,
- &the_cond->Object,
- 0
- );
-
- *cond = the_cond->Object.id;
+ if ( !attr->is_initialized ) {
+ return EINVAL;
+ }
- _Objects_Allocator_unlock();
+ if ( !_POSIX_Is_valid_pshared( attr->process_shared ) ) {
+ return EINVAL;
+ }
+ _POSIX_Condition_variables_Initialize( the_cond, attr );
return 0;
}