From 694e946dbd64c94343aeb289edd80a60759f7b26 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Wed, 6 Sep 2017 07:31:48 +0200 Subject: libio: Remove special-case reference count The top-level IO library structures should contain no special-case data. Update #2859. --- cpukit/posix/src/munmap.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) (limited to 'cpukit/posix/src/munmap.c') diff --git a/cpukit/posix/src/munmap.c b/cpukit/posix/src/munmap.c index fb9bb872e0..5348be7a51 100644 --- a/cpukit/posix/src/munmap.c +++ b/cpukit/posix/src/munmap.c @@ -16,23 +16,14 @@ #include #include -#include +#include #include -static void shm_munmap( rtems_libio_t *iop ) -{ - POSIX_Shm_Control *shm = iop_to_shm( iop ); - - /* decrement mmap's shm reference_count and maybe delete the object */ - POSIX_Shm_Attempt_delete(shm); -} - int munmap(void *addr, size_t len) { - mmap_mapping *mapping; - rtems_chain_node *node; - uint32_t refcnt; - + mmap_mapping *mapping; + rtems_chain_node *node; + /* * Clear errno. */ @@ -60,17 +51,13 @@ int munmap(void *addr, size_t len) if ( ( addr >= mapping->addr ) && ( addr < ( mapping->addr + mapping->len )) ) { rtems_chain_extract_unprotected( node ); + /* FIXME: generally need a way to clean-up the backing object, but * currently it only matters for MAP_SHARED shm objects. */ - if ( mapping->is_shared_shm == true ) { - shm_munmap(mapping->iop); - } - if ( mapping->iop != NULL ) { - refcnt = rtems_libio_decrement_mapping_refcnt(mapping->iop); - if ( refcnt == 0 ) { - rtems_libio_check_deferred_free(mapping->iop); - } + if ( mapping->shm != NULL ) { + POSIX_Shm_Attempt_delete(mapping->shm); } + /* only free the mapping address for non-fixed mapping */ if (( mapping->flags & MAP_FIXED ) != MAP_FIXED ) { /* only free the mapping address for non-shared mapping, because we -- cgit v1.2.3