2002-12-06 Vladimir Nesic <vnesic@dkts.co.yu>

* inline/rtems/posix/cond.inl, macros/rtems/posix/cond.inl:
	Implemented PTHREAD_COND_INITIALIZER support.  Vladimir implemented
	the inline version and Joel adapted it to the macro version.
This commit is contained in:
Joel Sherrill
2002-12-06 13:48:27 +00:00
parent baa8dd7cb0
commit 2837a5eace
3 changed files with 73 additions and 17 deletions

View File

@@ -1,3 +1,9 @@
2002-12-06 Vladimir Nesic <vnesic@dkts.co.yu>
* inline/rtems/posix/cond.inl, macros/rtems/posix/cond.inl:
Implemented PTHREAD_COND_INITIALIZER support. Vladimir implemented
the inline version and Joel adapted it to the macro version.
2002-12-02 Joel Sherrill <joel@OARcorp.com> 2002-12-02 Joel Sherrill <joel@OARcorp.com>
* include/rtems/posix/timer.h, src/keygetspecific.c, * include/rtems/posix/timer.h, src/keygetspecific.c,

View File

@@ -3,7 +3,7 @@
* This include file contains the static inline implementation of the private * This include file contains the static inline implementation of the private
* inlined routines for POSIX condition variables. * inlined routines for POSIX condition variables.
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2002.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -16,6 +16,8 @@
#ifndef __RTEMS_POSIX_CONDITION_VARIABLES_inl #ifndef __RTEMS_POSIX_CONDITION_VARIABLES_inl
#define __RTEMS_POSIX_CONDITION_VARIABLES_inl #define __RTEMS_POSIX_CONDITION_VARIABLES_inl
#include <pthread.h>
/*PAGE /*PAGE
* *
* _POSIX_Condition_variables_Allocate * _POSIX_Condition_variables_Allocate
@@ -48,18 +50,37 @@ RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Free (
* _POSIX_Condition_variables_Get * _POSIX_Condition_variables_Get
*/ */
RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get ( RTEMS_INLINE_ROUTINE POSIX_Condition_variables_Control
*_POSIX_Condition_variables_Get (
Objects_Id *id, Objects_Id *id,
Objects_Locations *location Objects_Locations *location
) )
{ {
/* XXX should support COND_INITIALIZER */ int status;
if ( id )
if ( !id ) {
*location = OBJECTS_ERROR;
return (POSIX_Condition_variables_Control *) 0;
}
if ( *id == PTHREAD_COND_INITIALIZER ) {
/*
* Do an "auto-create" here.
*/
status = pthread_cond_init( id, 0 );
if ( status ) {
*location = OBJECTS_ERROR;
return (POSIX_Condition_variables_Control *) 0;
}
}
/*
* Now call Objects_Get()
*/
return (POSIX_Condition_variables_Control *) return (POSIX_Condition_variables_Control *)
_Objects_Get( &_POSIX_Condition_variables_Information, *id, location ); _Objects_Get( &_POSIX_Condition_variables_Information, *id, location );
*location = OBJECTS_ERROR;
return NULL;
} }
/*PAGE /*PAGE

View File

@@ -3,7 +3,7 @@
* This include file contains the macro implementation of the private * This include file contains the macro implementation of the private
* inlined routines for POSIX condition variables. * inlined routines for POSIX condition variables.
* *
* COPYRIGHT (c) 1989-1999. * COPYRIGHT (c) 1989-2002.
* On-Line Applications Research Corporation (OAR). * On-Line Applications Research Corporation (OAR).
* *
* The license and distribution terms for this file may be * The license and distribution terms for this file may be
@@ -16,6 +16,8 @@
#ifndef __RTEMS_POSIX_CONDITION_VARIABLES_inl #ifndef __RTEMS_POSIX_CONDITION_VARIABLES_inl
#define __RTEMS_POSIX_CONDITION_VARIABLES_inl #define __RTEMS_POSIX_CONDITION_VARIABLES_inl
#include <pthread.h>
/*PAGE /*PAGE
* *
* _POSIX_Condition_variables_Allocate * _POSIX_Condition_variables_Allocate
@@ -28,6 +30,10 @@
/*PAGE /*PAGE
* *
* _POSIX_Condition_variables_Free * _POSIX_Condition_variables_Free
*
* NOTE: The support macro makes it possible for both to use exactly
* the same code to check for NULL id pointer and
* PTHREAD_COND_INITIALIZER without adding overhead.
*/ */
#define _POSIX_Condition_variables_Free( _the_condition_variable ) \ #define _POSIX_Condition_variables_Free( _the_condition_variable ) \
@@ -37,21 +43,44 @@
/*PAGE /*PAGE
* *
* _POSIX_Condition_variables_Get * _POSIX_Condition_variables_Get
*
* NOTE: The support macro makes it possible for both to use exactly
* the same code to check for NULL id pointer and
* PTHREAD_COND_INITIALIZER without adding overhead.
*/ */
/* XXX how to write this as a macro */ #define ___POSIX_Condition_variables_Get_support( _id, _location ) \
do { \
int _status; \
\
if ( !_id ) { \
*_location = OBJECTS_ERROR; \
return (POSIX_Condition_variables_Control *) 0; \
} \
\
if ( *_id == PTHREAD_COND_INITIALIZER ) { \
/* \
* Do an "auto-create" here. \
*/ \
\
_status = pthread_cond_init( _id, 0 ); \
if ( _status ) { \
*_location = OBJECTS_ERROR; \
return (POSIX_Condition_variables_Control *) 0; \
} \
} \
} while (0)
static POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get ( static POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get (
Objects_Id *id, Objects_Id *id,
Objects_Locations *location Objects_Locations *location
) )
{ {
/* XXX should support COND_INITIALIZER */ ___POSIX_Condition_variables_Get_support( id, location );
if ( id )
return (POSIX_Condition_variables_Control *) return (POSIX_Condition_variables_Control *)
_Objects_Get( &_POSIX_Condition_variables_Information, *id, location ); _Objects_Get( &_POSIX_Condition_variables_Information, *id, location );
*location = OBJECTS_ERROR;
return NULL;
} }
/*PAGE /*PAGE