diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-09-14 15:21:14 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2017-09-15 10:55:38 +0200 |
commit | ac741625b0926a0329627beca52174edd69e587b (patch) | |
tree | f8f186efe3118359ae32a4a2eeedbe79e38c340e /cpukit/libcsupport/src/libio.c | |
parent | libio: Add hold/drop iop reference (diff) | |
download | rtems-ac741625b0926a0329627beca52174edd69e587b.tar.bz2 |
libio: Use FIFO for iop free list
Update #3136.
Diffstat (limited to 'cpukit/libcsupport/src/libio.c')
-rw-r--r-- | cpukit/libcsupport/src/libio.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c index 26fa7b2f67..0abb082a66 100644 --- a/cpukit/libcsupport/src/libio.c +++ b/cpukit/libcsupport/src/libio.c @@ -108,14 +108,21 @@ int rtems_libio_to_fcntl_flags( unsigned int flags ) rtems_libio_t *rtems_libio_allocate( void ) { - rtems_libio_t *iop = NULL; + rtems_libio_t *iop; rtems_libio_lock(); - if (rtems_libio_iop_freelist) { - iop = rtems_libio_iop_freelist; - rtems_libio_iop_freelist = iop->data1; - memset( iop, 0, sizeof(*iop) ); + iop = rtems_libio_iop_free_head; + + if ( iop != NULL ) { + void *next; + + next = iop->data1; + rtems_libio_iop_free_head = next; + + if ( next == NULL ) { + rtems_libio_iop_free_tail = &rtems_libio_iop_free_head; + } } rtems_libio_unlock(); @@ -131,9 +138,9 @@ void rtems_libio_free( rtems_libio_lock(); - iop->flags = 0; - iop->data1 = rtems_libio_iop_freelist; - rtems_libio_iop_freelist = iop; + iop = memset( iop, 0, sizeof( *iop ) ); + *rtems_libio_iop_free_tail = iop; + rtems_libio_iop_free_tail = &iop->data1; rtems_libio_unlock(); } |