summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/libio_init.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-12-04 08:56:00 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-12-06 07:13:04 +0100
commitbc5b56ad4196eb52254e371aa8ce9caf42b1dec6 (patch)
tree216be99b18b7c5fb1885b5ae7910fb5e9adcf5a3 /cpukit/libcsupport/src/libio_init.c
parentdrvmgr: Use API mutex (diff)
downloadrtems-bc5b56ad4196eb52254e371aa8ce9caf42b1dec6.tar.bz2
libio: Use API mutex
Diffstat (limited to 'cpukit/libcsupport/src/libio_init.c')
-rw-r--r--cpukit/libcsupport/src/libio_init.c44
1 files changed, 14 insertions, 30 deletions
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 <rtems/libio_.h> /* libio_.h pulls in rtems */
-#include <rtems.h>
-#include <rtems/assoc.h> /* assoc.h not included by rtems.h */
+#include <rtems/libio_.h>
-#include <stdio.h> /* O_RDONLY, et.al. */
-#include <fcntl.h> /* O_RDONLY, et.al. */
-#include <errno.h>
+#include <pthread.h>
-#include <errno.h>
-#include <string.h> /* strcmp */
-#include <unistd.h>
-#include <stdlib.h> /* calloc() */
-
-#include <rtems/libio.h> /* libio.h not pulled in by rtems */
#include <rtems/sysinit.h>
+#include <rtems/score/apimutex.h>
/*
* 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(