Ignore:
Timestamp:
May 5, 2020, 4:23:46 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
4385e8b, c66f6cb
Parents:
d3ab183
Message:

Added automatic detection of support for preadv2 and pwritev2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/io.cfa

    rd3ab183 r08a994e  
    544544        #include <sys/socket.h>
    545545        #include <sys/syscall.h>
     546
     547#if defined(HAVE_PREADV2)
    546548        struct iovec;
    547549        extern ssize_t preadv2 (int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags);
     550#endif
     551#if defined(HAVE_PWRITEV2)
     552        struct iovec;
    548553        extern ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags);
     554#endif
    549555
    550556        extern int fsync(int fd);
     
    572578//-----------------------------------------------------------------------------
    573579// Asynchronous operations
    574 ssize_t cfa_preadv2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) {
    575         #if !defined(HAVE_LINUX_IO_URING_H) || !defined(IORING_OP_READV)
    576                 return preadv2(fd, iov, iovcnt, offset, flags);
    577         #else
    578                 __submit_prelude
    579 
    580                 (*sqe){ IORING_OP_READV, fd, iov, iovcnt, offset };
    581 
    582                 __submit_wait
    583         #endif
    584 }
    585 
    586 ssize_t cfa_pwritev2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) {
    587         #if !defined(HAVE_LINUX_IO_URING_H) || !defined(IORING_OP_WRITEV)
    588                 return pwritev2(fd, iov, iovcnt, offset, flags);
    589         #else
    590                 __submit_prelude
    591 
    592                 (*sqe){ IORING_OP_WRITEV, fd, iov, iovcnt, offset };
    593 
    594                 __submit_wait
    595         #endif
    596 }
     580#if defined(HAVE_PREADV2)
     581        ssize_t cfa_preadv2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) {
     582                #if !defined(HAVE_LINUX_IO_URING_H) || !defined(IORING_OP_READV)
     583                        return preadv2(fd, iov, iovcnt, offset, flags);
     584                #else
     585                        __submit_prelude
     586
     587                        (*sqe){ IORING_OP_READV, fd, iov, iovcnt, offset };
     588
     589                        __submit_wait
     590                #endif
     591        }
     592#endif
     593
     594#if defined(HAVE_PWRITEV2)
     595        ssize_t cfa_pwritev2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags) {
     596                #if !defined(HAVE_LINUX_IO_URING_H) || !defined(IORING_OP_WRITEV)
     597                        return pwritev2(fd, iov, iovcnt, offset, flags);
     598                #else
     599                        __submit_prelude
     600
     601                        (*sqe){ IORING_OP_WRITEV, fd, iov, iovcnt, offset };
     602
     603                        __submit_wait
     604                #endif
     605        }
     606#endif
    597607
    598608int cfa_fsync(int fd) {
     
    822832                        return IS_DEFINED(IORING_OP_READV);
    823833
    824                 if( /*func == (fptr_t)pwritev2 || */
    825                         func == (fptr_t)cfa_pwritev2 )
    826                         #define _CFA_IO_FEATURE_IORING_OP_WRITEV ,
    827                         return IS_DEFINED(IORING_OP_WRITEV);
    828 
    829                 if( /*func == (fptr_t)fsync || */
    830                         func == (fptr_t)cfa_fsync )
    831                         #define _CFA_IO_FEATURE_IORING_OP_FSYNC ,
    832                         return IS_DEFINED(IORING_OP_FSYNC);
     834                #if defined(HAVE_PREADV2)
     835                        if( /*func == (fptr_t)pwritev2 || */
     836                                func == (fptr_t)cfa_pwritev2 )
     837                                #define _CFA_IO_FEATURE_IORING_OP_WRITEV ,
     838                                return IS_DEFINED(IORING_OP_WRITEV);
     839                #endif
     840
     841                #if defined(HAVE_PWRITEV2)
     842                        if( /*func == (fptr_t)fsync || */
     843                                func == (fptr_t)cfa_fsync )
     844                                #define _CFA_IO_FEATURE_IORING_OP_FSYNC ,
     845                                return IS_DEFINED(IORING_OP_FSYNC);
     846                #endif
    833847
    834848                if( /*func == (fptr_t)ync_file_range || */
Note: See TracChangeset for help on using the changeset viewer.