[PATCH] posix: Optimize pthread_once_t
Sebastian Huber
sebastian.huber at embedded-brains.de
Tue Sep 19 13:04:23 UTC 2017
Reduce size of pthread_once_t and make it zero-initialized.
Update #3142.
---
cpukit/libcsupport/src/gxx_wrappers.c | 2 +-
cpukit/posix/src/pthreadonce.c | 5 +----
cpukit/score/include/rtems/score/onceimpl.h | 2 +-
cpukit/score/src/once.c | 2 +-
4 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/cpukit/libcsupport/src/gxx_wrappers.c b/cpukit/libcsupport/src/gxx_wrappers.c
index d30b57037e..3a1b0f1991 100644
--- a/cpukit/libcsupport/src/gxx_wrappers.c
+++ b/cpukit/libcsupport/src/gxx_wrappers.c
@@ -46,7 +46,7 @@ int rtems_gxx_once(__gthread_once_t *once, void (*func) (void))
printk( "gxx_wrappers: once=%x, func=%x\n", *once, func );
#endif
- return _Once( once, func );
+ return _Once( (unsigned char *) once, func );
}
int rtems_gxx_key_create (__gthread_key_t *key, void (*dtor) (void *))
diff --git a/cpukit/posix/src/pthreadonce.c b/cpukit/posix/src/pthreadonce.c
index dc8a449a87..c92acf8642 100644
--- a/cpukit/posix/src/pthreadonce.c
+++ b/cpukit/posix/src/pthreadonce.c
@@ -33,8 +33,5 @@ int pthread_once(
if ( !once_control || !init_routine )
return EINVAL;
- if ( once_control->is_initialized != 1 )
- return EINVAL;
-
- return _Once( &once_control->init_executed, init_routine );
+ return _Once( &once_control->_flags, init_routine );
}
diff --git a/cpukit/score/include/rtems/score/onceimpl.h b/cpukit/score/include/rtems/score/onceimpl.h
index d81f1d0b31..21e9edade5 100644
--- a/cpukit/score/include/rtems/score/onceimpl.h
+++ b/cpukit/score/include/rtems/score/onceimpl.h
@@ -37,7 +37,7 @@ extern "C" {
* @{
*/
-int _Once( int *once_state, void (*init_routine)(void) );
+int _Once( unsigned char *once_state, void (*init_routine)(void) );
/** @} */
diff --git a/cpukit/score/src/once.c b/cpukit/score/src/once.c
index 60ae7a78c4..427659e173 100644
--- a/cpukit/score/src/once.c
+++ b/cpukit/score/src/once.c
@@ -20,7 +20,7 @@
#define ONCE_STATE_RUNNING 1
#define ONCE_STATE_COMPLETE 2
-int _Once( int *once_state, void ( *init_routine )( void ) )
+int _Once( unsigned char *once_state, void ( *init_routine )( void ) )
{
int eno = 0;
--
2.12.3
More information about the devel
mailing list