Changeset 98041b68 in rtems


Ignore:
Timestamp:
Sep 13, 2017, 1:19:14 PM (2 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
baef823c
Parents:
9012db8
git-author:
Sebastian Huber <sebastian.huber@…> (09/13/17 13:19:14)
git-committer:
Sebastian Huber <sebastian.huber@…> (09/15/17 08:27:13)
Message:

libio: Unify readv() and writev()

Update #3132.

Location:
cpukit/libcsupport
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/include/rtems/libio_.h

    r9012db8 r98041b68  
    922922}
    923923
     924typedef ssize_t ( *rtems_libio_iovec_adapter )(
     925  rtems_libio_t      *iop,
     926  const struct iovec *iov,
     927  int                 iovcnt,
     928  ssize_t             total
     929);
     930
    924931static inline ssize_t rtems_libio_iovec_eval(
    925   int fd,
    926   const struct iovec *iov,
    927   int iovcnt,
    928   uint32_t flags,
    929   rtems_libio_t **iopp
     932  int                        fd,
     933  const struct iovec        *iov,
     934  int                        iovcnt,
     935  uint32_t                   flags,
     936  rtems_libio_iovec_adapter  adapter
    930937)
    931938{
     
    967974
    968975  LIBIO_GET_IOP_WITH_ACCESS( fd, iop, flags, EBADF );
    969   *iopp = iop;
     976
     977  if ( total > 0 ) {
     978    total = ( *adapter )( iop, iov, iovcnt, total );
     979  }
    970980
    971981  return total;
  • cpukit/libcsupport/src/readv.c

    r9012db8 r98041b68  
    2323#include <rtems/libio_.h>
    2424
     25static ssize_t readv_adapter(
     26  rtems_libio_t      *iop,
     27  const struct iovec *iov,
     28  int                 iovcnt,
     29  ssize_t             total
     30)
     31{
     32  return ( *iop->pathinfo.handlers->readv_h )( iop, iov, iovcnt, total );
     33}
     34
    2535/**
    2636 *  readv() - POSIX 1003.1 - Read a Vector
     
    3646)
    3747{
    38   ssize_t        total;
    39   rtems_libio_t *iop;
    40 
    41   total = rtems_libio_iovec_eval( fd, iov, iovcnt, LIBIO_FLAGS_READ, &iop );
    42 
    43   if ( total > 0 ) {
    44     total = ( *iop->pathinfo.handlers->readv_h )( iop, iov, iovcnt, total );
    45   }
    46 
    47   return total;
     48  return rtems_libio_iovec_eval(
     49    fd,
     50    iov,
     51    iovcnt,
     52    LIBIO_FLAGS_READ,
     53    readv_adapter
     54  );
    4855}
  • cpukit/libcsupport/src/writev.c

    r9012db8 r98041b68  
    2222#include <rtems/libio_.h>
    2323
     24static ssize_t writev_adapter(
     25  rtems_libio_t      *iop,
     26  const struct iovec *iov,
     27  int                 iovcnt,
     28  ssize_t             total
     29)
     30{
     31  return ( *iop->pathinfo.handlers->writev_h )( iop, iov, iovcnt, total );
     32}
     33
    2434ssize_t writev(
    2535  int                 fd,
     
    2838)
    2939{
    30   ssize_t        total;
    31   rtems_libio_t *iop;
    32 
    33   total = rtems_libio_iovec_eval( fd, iov, iovcnt, LIBIO_FLAGS_WRITE, &iop );
    34 
    35   if ( total > 0 ) {
    36     total = ( *iop->pathinfo.handlers->writev_h )( iop, iov, iovcnt, total );
    37   }
    38 
    39   return total;
     40  return rtems_libio_iovec_eval(
     41    fd,
     42    iov,
     43    iovcnt,
     44    LIBIO_FLAGS_WRITE,
     45    writev_adapter
     46  );
    4047}
Note: See TracChangeset for help on using the changeset viewer.