summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libcsupport/src')
-rw-r--r--cpukit/libcsupport/src/libio.c23
-rw-r--r--cpukit/libcsupport/src/libio_init.c10
-rw-r--r--cpukit/libcsupport/src/resource_snapshot.c2
3 files changed, 23 insertions, 12 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();
}
diff --git a/cpukit/libcsupport/src/libio_init.c b/cpukit/libcsupport/src/libio_init.c
index 3fa9e0995f..9c24b146ea 100644
--- a/cpukit/libcsupport/src/libio_init.c
+++ b/cpukit/libcsupport/src/libio_init.c
@@ -38,8 +38,11 @@
* File descriptor Table Information
*/
-rtems_id rtems_libio_semaphore;
-rtems_libio_t *rtems_libio_iop_freelist;
+rtems_id rtems_libio_semaphore;
+
+void *rtems_libio_iop_free_head;
+
+void **rtems_libio_iop_free_tail = &rtems_libio_iop_free_head;
static void rtems_libio_init( void )
{
@@ -50,10 +53,11 @@ static void rtems_libio_init( void )
if (rtems_libio_number_iops > 0)
{
- iop = rtems_libio_iop_freelist = &rtems_libio_iops[0];
+ iop = rtems_libio_iop_free_head = &rtems_libio_iops[0];
for (i = 0 ; (i + 1) < rtems_libio_number_iops ; i++, iop++)
iop->data1 = iop + 1;
iop->data1 = NULL;
+ rtems_libio_iop_free_tail = &iop->data1;
}
/*
diff --git a/cpukit/libcsupport/src/resource_snapshot.c b/cpukit/libcsupport/src/resource_snapshot.c
index d0dda9f7ca..9e026ff222 100644
--- a/cpukit/libcsupport/src/resource_snapshot.c
+++ b/cpukit/libcsupport/src/resource_snapshot.c
@@ -87,7 +87,7 @@ static int open_files(void)
rtems_libio_lock();
- iop = rtems_libio_iop_freelist;
+ iop = rtems_libio_iop_free_head;
while (iop != NULL) {
++free_count;