[rtems commit] libio: Add rtems_libio_iop_flags()

Sebastian Huber sebh at rtems.org
Fri Sep 15 09:00:00 UTC 2017


Module:    rtems
Branch:    master
Commit:    e2b1db231196e0c395d0e19d9b35c0d7da2a5d3e
Changeset: http://git.rtems.org/rtems/commit/?id=e2b1db231196e0c395d0e19d9b35c0d7da2a5d3e

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Sep 13 13:30:30 2017 +0200

libio: Add rtems_libio_iop_flags()

Update #3132.

---

 cpukit/libcsupport/include/rtems/libio.h   |  5 +++++
 cpukit/libcsupport/src/fcntl.c             | 10 +++++-----
 cpukit/libfs/src/pipe/fifo.c               |  2 +-
 cpukit/libnetworking/rtems/rtems_syscall.c |  2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index 99d1565..96d0c29 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -1374,6 +1374,11 @@ typedef struct {
 
 /** @} */
 
+static inline uint32_t rtems_libio_iop_flags( const rtems_libio_t *iop )
+{
+  return iop->flags;
+}
+
 /**
  * @name External I/O Handlers
  */
diff --git a/cpukit/libcsupport/src/fcntl.c b/cpukit/libcsupport/src/fcntl.c
index 8205201..d44d4a0 100644
--- a/cpukit/libcsupport/src/fcntl.c
+++ b/cpukit/libcsupport/src/fcntl.c
@@ -30,7 +30,7 @@ static int duplicate_iop( rtems_libio_t *iop )
   int            oflag;
   rtems_libio_t *diop;
 
-  oflag = rtems_libio_to_fcntl_flags( iop->flags );
+  oflag = rtems_libio_to_fcntl_flags( rtems_libio_iop_flags( iop ) );
   diop = rtems_libio_allocate();
 
   if (diop != NULL) {
@@ -72,12 +72,12 @@ static int duplicate2_iop( rtems_libio_t *iop, int fd2 )
   {
     int oflag;
 
-    if ((iop2->flags & LIBIO_FLAGS_OPEN) != 0) {
+    if ((rtems_libio_iop_flags( iop2 ) & LIBIO_FLAGS_OPEN) != 0) {
       rv = (*iop2->pathinfo.handlers->close_h)( iop2 );
     }
 
     if (rv == 0) {
-      oflag = rtems_libio_to_fcntl_flags( iop->flags );
+      oflag = rtems_libio_to_fcntl_flags( rtems_libio_iop_flags( iop ) );
       rtems_libio_iop_flags_set( iop2, rtems_libio_fcntl_flags( oflag ) );
 
       rtems_filesystem_instance_lock( &iop->pathinfo );
@@ -135,7 +135,7 @@ static int vfcntl(
       break;
 
     case F_GETFD:        /* get f_flags */
-      ret = ((iop->flags & LIBIO_FLAGS_CLOSE_ON_EXEC) != 0);
+      ret = ((rtems_libio_iop_flags(iop) & LIBIO_FLAGS_CLOSE_ON_EXEC) != 0);
       break;
 
     case F_SETFD:        /* set f_flags */
@@ -154,7 +154,7 @@ static int vfcntl(
       break;
 
     case F_GETFL:        /* more flags (cloexec) */
-      ret = rtems_libio_to_fcntl_flags( iop->flags );
+      ret = rtems_libio_to_fcntl_flags( rtems_libio_iop_flags( iop ) );
       break;
 
     case F_SETFL:
diff --git a/cpukit/libfs/src/pipe/fifo.c b/cpukit/libfs/src/pipe/fifo.c
index 15fb0d5..78e02ef 100644
--- a/cpukit/libfs/src/pipe/fifo.c
+++ b/cpukit/libfs/src/pipe/fifo.c
@@ -31,7 +31,7 @@
 
 #include "pipe.h"
 
-#define LIBIO_ACCMODE(_iop) ((_iop)->flags & LIBIO_FLAGS_READ_WRITE)
+#define LIBIO_ACCMODE(_iop) (rtems_libio_iop_flags(_iop) & LIBIO_FLAGS_READ_WRITE)
 #define LIBIO_NODELAY(_iop) ((_iop)->flags & LIBIO_FLAGS_NO_DELAY)
 
 static rtems_id pipe_semaphore = RTEMS_ID_NONE;
diff --git a/cpukit/libnetworking/rtems/rtems_syscall.c b/cpukit/libnetworking/rtems/rtems_syscall.c
index e180320..f1b7a32 100644
--- a/cpukit/libnetworking/rtems/rtems_syscall.c
+++ b/cpukit/libnetworking/rtems/rtems_syscall.c
@@ -52,7 +52,7 @@ rtems_bsdnet_fdToSocket (int fd)
   iop = rtems_libio_iop(fd);
 
   /* same as rtems_libio_check_is_open(iop) but different return */
-  if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) {
+  if ((rtems_libio_iop_flags(iop) & LIBIO_FLAGS_OPEN) == 0) {
     errno = EBADF;
     return NULL;
   }




More information about the vc mailing list