Ignore:
Timestamp:
Jul 10, 2020, 2:21:47 PM (16 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast, new-ast-unique-expr
Children:
365e423
Parents:
fb98462
Message:

Added support for splice and tee in cfa io

File:
1 edited

Legend:

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

    rfb98462 r0a92c78  
    108108
    109109        extern ssize_t read (int fd, void *buf, size_t count);
     110
     111        extern ssize_t splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags);
     112        extern ssize_t tee(int fd_in, int fd_out, size_t len, unsigned int flags);
    110113}
    111114
     
    329332}
    330333
    331 
    332334ssize_t cfa_read(int fd, void *buf, size_t count) {
    333335        #if !defined(HAVE_LINUX_IO_URING_H) || !defined(IORING_OP_READ)
     
    349351
    350352                (*sqe){ IORING_OP_WRITE, fd, buf, count, 0 };
     353
     354                __submit_wait
     355        #endif
     356}
     357
     358ssize_t cfa_splice(int fd_in, loff_t *off_in, int fd_out, loff_t *off_out, size_t len, unsigned int flags) {
     359        #if !defined(HAVE_LINUX_IO_URING_H) || !defined(IORING_OP_SPLICE)
     360                return splice( fd_in, off_in, fd_out, off_out, len, flags );
     361        #else
     362                __submit_prelude
     363
     364                (*sqe){ IORING_OP_SPLICE, fd_out, 0p, len, off_out };
     365                sqe->splice_fd_in  = fd_in;
     366                sqe->splice_off_in = off_in;
     367                sqe->splice_flags  = flags;
     368
     369                __submit_wait
     370        #endif
     371}
     372
     373ssize_t cfa_tee(int fd_in, int fd_out, size_t len, unsigned int flags) {
     374        #if !defined(HAVE_LINUX_IO_URING_H) || !defined(IORING_OP_TEE)
     375                return tee( fd_in, fd_out, len, flags );
     376        #else
     377                __submit_prelude
     378
     379                (*sqe){ IORING_OP_TEE, fd_out, 0p, len, 0 };
     380                sqe->splice_fd_in = fd_in;
     381                sqe->splice_flags = flags;
    351382
    352383                __submit_wait
     
    453484                        #define _CFA_IO_FEATURE_IORING_OP_WRITE ,
    454485                        return IS_DEFINED(IORING_OP_WRITE);
     486
     487                if( /*func == (fptr_t)splice || */
     488                        func == (fptr_t)cfa_splice )
     489                        #define _CFA_IO_FEATURE_IORING_OP_SPLICE ,
     490                        return IS_DEFINED(IORING_OP_SPLICE);
     491
     492                if( /*func == (fptr_t)tee || */
     493                        func == (fptr_t)cfa_tee )
     494                        #define _CFA_IO_FEATURE_IORING_OP_TEE ,
     495                        return IS_DEFINED(IORING_OP_TEE);
    455496        #endif
    456497
Note: See TracChangeset for help on using the changeset viewer.