diff options
author | Gedare Bloom <gedare@rtems.org> | 2017-03-15 14:31:00 -0400 |
---|---|---|
committer | Gedare Bloom <gedare@rtems.org> | 2017-05-05 10:34:08 -0400 |
commit | 87de70a2984cece87db94f4b445589c4e24e5c77 (patch) | |
tree | 945d211b09e3b7714a2bba6d06ceae7a601d4116 /cpukit/libcsupport/include | |
parent | posix: Add mmap/unmap support for mapping files. (diff) | |
download | rtems-87de70a2984cece87db94f4b445589c4e24e5c77.tar.bz2 |
posix/mman: add mmap support for shm objects
Update #2859.
Diffstat (limited to 'cpukit/libcsupport/include')
-rw-r--r-- | cpukit/libcsupport/include/rtems/libio.h | 1 | ||||
-rw-r--r-- | cpukit/libcsupport/include/rtems/libio_.h | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h index a87031ca91..d0824b4e85 100644 --- a/cpukit/libcsupport/include/rtems/libio.h +++ b/cpukit/libcsupport/include/rtems/libio.h @@ -1282,6 +1282,7 @@ struct rtems_libio_tt { rtems_driver_name_t *driver; off_t offset; /* current offset into file */ uint32_t flags; + uint32_t mapping_refcnt; /* current mappings */ rtems_filesystem_location_info_t pathinfo; uint32_t data0; /* private to "driver" */ void *data1; /* ... */ diff --git a/cpukit/libcsupport/include/rtems/libio_.h b/cpukit/libcsupport/include/rtems/libio_.h index c2fb975bf7..695a4c45a5 100644 --- a/cpukit/libcsupport/include/rtems/libio_.h +++ b/cpukit/libcsupport/include/rtems/libio_.h @@ -304,6 +304,47 @@ void rtems_libio_free( rtems_libio_t *iop ); +/** + * Garbage collects the free libio in case it was previously freed but there + * were still references to it. + */ +void rtems_libio_check_deferred_free( rtems_libio_t *iop ); + +/** + * Increment the reference count tracking number of mmap mappings of a file. + * Returns the updated reference count value. + */ +static inline uint32_t rtems_libio_increment_mapping_refcnt(rtems_libio_t *iop) +{ + uint32_t refcnt; + rtems_libio_lock(); + refcnt = ++iop->mapping_refcnt; + rtems_libio_unlock(); + return refcnt; +} + +/** + * Decrement the reference count tracking number of mmap mappings of a file. + * Returns the updated reference count value. + */ +static inline uint32_t rtems_libio_decrement_mapping_refcnt(rtems_libio_t *iop) +{ + uint32_t refcnt; + rtems_libio_lock(); + refcnt = --iop->mapping_refcnt; + rtems_libio_unlock(); + return refcnt; +} + +static inline bool rtems_libio_is_mapped(rtems_libio_t *iop) +{ + bool is_mapped; + rtems_libio_lock(); + is_mapped = iop->mapping_refcnt != 0; + rtems_libio_unlock(); + return is_mapped; +} + /* * File System Routine Prototypes */ |