summaryrefslogtreecommitdiff
path: root/cpukit/libcsupport/src/libio.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libcsupport/src/libio.c')
-rw-r--r--cpukit/libcsupport/src/libio.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c
index 879cd8134c..b225b57f6f 100644
--- a/cpukit/libcsupport/src/libio.c
+++ b/cpukit/libcsupport/src/libio.c
@@ -149,23 +149,25 @@ rtems_libio_t *rtems_libio_allocate( void )
{
rtems_libio_t *iop, *next;
rtems_status_code rc;
+ rtems_id sema;
rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
if (rtems_libio_iop_freelist) {
- iop = rtems_libio_iop_freelist;
- next = iop->data1;
- (void) memset( iop, 0, sizeof(rtems_libio_t) );
- iop->flags = LIBIO_FLAGS_OPEN;
rc = rtems_semaphore_create(
- RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops),
+ RTEMS_LIBIO_IOP_SEM(rtems_libio_iop_freelist - rtems_libio_iops),
1,
RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
RTEMS_NO_PRIORITY,
- &iop->sem
+ &sema
);
if (rc != RTEMS_SUCCESSFUL)
goto failed;
+ iop = rtems_libio_iop_freelist;
+ next = iop->data1;
+ (void) memset( iop, 0, sizeof(rtems_libio_t) );
+ iop->flags = LIBIO_FLAGS_OPEN;
+ iop->sem = sema;
rtems_libio_iop_freelist = next;
goto done;
}