From bc5b56ad4196eb52254e371aa8ce9caf42b1dec6 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 4 Dec 2017 08:56:00 +0100 Subject: libio: Use API mutex --- cpukit/libcsupport/src/libio_init.c | 44 ++++++++++++------------------------- 1 file changed, 14 insertions(+), 30 deletions(-) (limited to 'cpukit/libcsupport/src/libio_init.c') diff --git a/cpukit/libcsupport/src/libio_init.c b/cpukit/libcsupport/src/libio_init.c index 9c24b146ea..5b951ef2be 100644 --- a/cpukit/libcsupport/src/libio_init.c +++ b/cpukit/libcsupport/src/libio_init.c @@ -18,27 +18,28 @@ #include "config.h" #endif -#include /* libio_.h pulls in rtems */ -#include -#include /* assoc.h not included by rtems.h */ +#include -#include /* O_RDONLY, et.al. */ -#include /* O_RDONLY, et.al. */ -#include +#include -#include -#include /* strcmp */ -#include -#include /* calloc() */ - -#include /* libio.h not pulled in by rtems */ #include +#include /* * File descriptor Table Information */ -rtems_id rtems_libio_semaphore; +static API_Mutex_Control rtems_libio_mutex = API_MUTEX_INITIALIZER( "_Libio" ); + +void rtems_libio_lock( void ) +{ + _API_Mutex_Lock( &rtems_libio_mutex ); +} + +void rtems_libio_unlock( void ) +{ + _API_Mutex_Unlock( &rtems_libio_mutex ); +} void *rtems_libio_iop_free_head; @@ -46,7 +47,6 @@ void **rtems_libio_iop_free_tail = &rtems_libio_iop_free_head; static void rtems_libio_init( void ) { - rtems_status_code rc; uint32_t i; rtems_libio_t *iop; int eno; @@ -70,22 +70,6 @@ static void rtems_libio_init( void ) if (eno != 0) { _Internal_error( INTERNAL_ERROR_LIBIO_USER_ENV_KEY_CREATE_FAILED ); } - - /* - * Create the binary semaphore used to provide mutual exclusion - * on the IOP Table. - */ - - rc = rtems_semaphore_create( - RTEMS_LIBIO_SEM, - 1, - RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, - RTEMS_NO_PRIORITY, - &rtems_libio_semaphore - ); - if ( rc != RTEMS_SUCCESSFUL ) { - _Internal_error( INTERNAL_ERROR_LIBIO_SEM_CREATE_FAILED ); - } } RTEMS_SYSINIT_ITEM( -- cgit v1.2.3