Ignore:
Timestamp:
Aug 20, 2020, 11:48:15 PM (5 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
d685cb0
Parents:
67ca73e (diff), 013b028 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

fix conflicts

File:
1 edited

Legend:

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

    r67ca73e re67a82d  
    3232        #include "io/types.hfa"
    3333
    34         extern [* struct io_uring_sqe, uint32_t] __submit_alloc( struct __io_data & ring, uint64_t data );
    35         extern void __submit( struct io_context * ctx, uint32_t idx ) __attribute__((nonnull (1)));
    36 
    37         static inline void ?{}(struct io_uring_sqe & this, uint8_t opcode, int fd) {
     34        extern [* struct io_uring_sqe, __u32] __submit_alloc( struct __io_data & ring, __u64 data );
     35        extern void __submit( struct io_context * ctx, __u32 idx ) __attribute__((nonnull (1)));
     36
     37        static inline void ?{}(struct io_uring_sqe & this, __u8 opcode, int fd) {
    3838                this.opcode = opcode;
    3939                #if !defined(IOSQE_ASYNC)
     
    5151        }
    5252
    53         static inline void ?{}(struct io_uring_sqe & this, uint8_t opcode, int fd, void * addr, uint32_t len, uint64_t off ) {
     53        static inline void ?{}(struct io_uring_sqe & this, __u8 opcode, int fd, void * addr, __u32 len, __u64 off ) {
    5454                (this){ opcode, fd };
    5555                this.off = off;
    56                 this.addr = (uint64_t)(uintptr_t)addr;
     56                this.addr = (__u64)(uintptr_t)addr;
    5757                this.len = len;
    5858        }
     
    101101        #endif
    102102
    103 
    104103        #define __submit_prelude \
    105104                if( 0 != (submit_flags & LINK_FLAGS) ) { errno = ENOTSUP; return -1; } \
    106105                (void)timeout; (void)cancellation; \
    107106                if( !context ) context = __get_io_context(); \
    108                 __io_user_data_t data = { 0, active_thread() }; \
     107                __io_user_data_t data = { 0 }; \
    109108                struct __io_data & ring = *context->thrd.ring; \
    110109                struct io_uring_sqe * sqe; \
    111                 uint32_t idx; \
    112                 [sqe, idx] = __submit_alloc( ring, (uint64_t)(uintptr_t)&data ); \
    113                 sqe->flags = REGULAR_FLAGS & submit_flags;
     110                __u32 idx; \
     111                __u8 sflags = REGULAR_FLAGS & submit_flags; \
     112                [sqe, idx] = __submit_alloc( ring, (__u64)(uintptr_t)&data ); \
     113                sqe->flags = sflags;
    114114
    115115        #define __submit_wait \
    116116                /*__cfaabi_bits_print_safe( STDERR_FILENO, "Preparing user data %p for %p\n", &data, data.thrd );*/ \
    117                 verify( sqe->user_data == (uint64_t)(uintptr_t)&data ); \
     117                verify( sqe->user_data == (__u64)(uintptr_t)&data ); \
    118118                __submit( context, idx ); \
    119                 park( __cfaabi_dbg_ctx ); \
     119                wait( data.sem ); \
    120120                if( data.result < 0 ) { \
    121121                        errno = -data.result; \
     
    149149
    150150        extern int fsync(int fd);
    151         extern int sync_file_range(int fd, int64_t offset, int64_t nbytes, unsigned int flags);
     151
     152        #if __OFF_T_MATCHES_OFF64_T
     153                typedef __off64_t off_t;
     154        #else
     155                typedef __off_t off_t;
     156        #endif
     157        typedef __off64_t off64_t;
     158        extern int sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags);
    152159
    153160        struct msghdr;
     
    160167        extern int connect(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
    161168
    162         extern int fallocate(int fd, int mode, uint64_t offset, uint64_t len);
    163         extern int posix_fadvise(int fd, uint64_t offset, uint64_t len, int advice);
     169        extern int fallocate(int fd, int mode, off_t offset, off_t len);
     170        extern int posix_fadvise(int fd, off_t offset, off_t len, int advice);
    164171        extern int madvise(void *addr, size_t length, int advice);
    165172
     
    186193                        __submit_prelude
    187194
    188                         (*sqe){ IORING_OP_READV, fd, iov, iovcnt, offset };
     195                        sqe->opcode = IORING_OP_READV;
     196                        sqe->ioprio = 0;
     197                        sqe->fd = fd;
     198                        sqe->off = offset;
     199                        sqe->addr = (__u64)iov;
     200                        sqe->len = iovcnt;
     201                        sqe->rw_flags = 0;
     202                        sqe->__pad2[0] = sqe->__pad2[1] = sqe->__pad2[2] = 0;
    189203
    190204                        __submit_wait
     
    200214                        __submit_prelude
    201215
    202                         (*sqe){ IORING_OP_WRITEV, fd, iov, iovcnt, offset };
     216                        sqe->opcode = IORING_OP_WRITEV;
     217                        sqe->ioprio = 0;
     218                        sqe->fd = fd;
     219                        sqe->off = offset;
     220                        sqe->addr = (__u64)iov;
     221                        sqe->len = iovcnt;
     222                        sqe->rw_flags = 0;
     223                        sqe->__pad2[0] = sqe->__pad2[1] = sqe->__pad2[2] = 0;
    203224
    204225                        __submit_wait
     
    213234                __submit_prelude
    214235
    215                 (*sqe){ IORING_OP_FSYNC, fd };
    216 
    217                 __submit_wait
    218         #endif
    219 }
    220 
    221 int cfa_sync_file_range(int fd, int64_t offset, int64_t nbytes, unsigned int flags, int submit_flags, Duration timeout, io_cancellation * cancellation, io_context * context) {
     236                sqe->opcode = IORING_OP_FSYNC;
     237                sqe->ioprio = 0;
     238                sqe->fd = fd;
     239                sqe->off = 0;
     240                sqe->addr = 0;
     241                sqe->len = 0;
     242                sqe->rw_flags = 0;
     243                sqe->__pad2[0] = sqe->__pad2[1] = sqe->__pad2[2] = 0;
     244
     245                __submit_wait
     246        #endif
     247}
     248
     249int cfa_sync_file_range(int fd, off64_t offset, off64_t nbytes, unsigned int flags, int submit_flags, Duration timeout, io_cancellation * cancellation, io_context * context) {
    222250        #if !defined(CFA_HAVE_LINUX_IO_URING_H) || !defined(CFA_HAVE_IORING_OP_SYNC_FILE_RANGE)
    223251                return sync_file_range(fd, offset, nbytes, flags);
     
    268296
    269297                (*sqe){ IORING_OP_SEND, sockfd };
    270                 sqe->addr = (uint64_t)buf;
     298                sqe->addr = (__u64)buf;
    271299                sqe->len = len;
    272300                sqe->msg_flags = flags;
     
    283311
    284312                (*sqe){ IORING_OP_RECV, sockfd };
    285                 sqe->addr = (uint64_t)buf;
     313                sqe->addr = (__u64)buf;
    286314                sqe->len = len;
    287315                sqe->msg_flags = flags;
     
    298326
    299327                (*sqe){ IORING_OP_ACCEPT, sockfd };
    300                 sqe->addr = (uint64_t)(uintptr_t)addr;
    301                 sqe->addr2 = (uint64_t)(uintptr_t)addrlen;
     328                sqe->addr  = (__u64)addr;
     329                sqe->addr2 = (__u64)addrlen;
    302330                sqe->accept_flags = flags;
    303331
     
    313341
    314342                (*sqe){ IORING_OP_CONNECT, sockfd };
    315                 sqe->addr = (uint64_t)(uintptr_t)addr;
    316                 sqe->off  = (uint64_t)(uintptr_t)addrlen;
    317 
    318                 __submit_wait
    319         #endif
    320 }
    321 
    322 int cfa_fallocate(int fd, int mode, uint64_t offset, uint64_t len, int submit_flags, Duration timeout, io_cancellation * cancellation, io_context * context) {
     343                sqe->addr = (__u64)addr;
     344                sqe->off  = (__u64)addrlen;
     345
     346                __submit_wait
     347        #endif
     348}
     349
     350int cfa_fallocate(int fd, int mode, off_t offset, off_t len, int submit_flags, Duration timeout, io_cancellation * cancellation, io_context * context) {
    323351        #if !defined(CFA_HAVE_LINUX_IO_URING_H) || !defined(CFA_HAVE_IORING_OP_FALLOCATE)
    324352                return fallocate( fd, mode, offset, len );
     
    337365}
    338366
    339 int cfa_fadvise(int fd, uint64_t offset, uint64_t len, int advice, int submit_flags, Duration timeout, io_cancellation * cancellation, io_context * context) {
     367int cfa_fadvise(int fd, off_t offset, off_t len, int advice, int submit_flags, Duration timeout, io_cancellation * cancellation, io_context * context) {
    340368        #if !defined(CFA_HAVE_LINUX_IO_URING_H) || !defined(CFA_HAVE_IORING_OP_FADVISE)
    341369                return posix_fadvise( fd, offset, len, advice );
     
    344372
    345373                (*sqe){ IORING_OP_FADVISE, fd };
    346                 sqe->off = (uint64_t)offset;
     374                sqe->off = (__u64)offset;
    347375                sqe->len = len;
    348376                sqe->fadvise_advice = advice;
     
    359387
    360388                (*sqe){ IORING_OP_MADVISE, 0 };
    361                 sqe->addr = (uint64_t)addr;
     389                sqe->addr = (__u64)addr;
    362390                sqe->len = length;
    363391                sqe->fadvise_advice = advice;
     
    374402
    375403                (*sqe){ IORING_OP_OPENAT, dirfd };
    376                 sqe->addr = (uint64_t)pathname;
     404                sqe->addr = (__u64)pathname;
    377405                sqe->open_flags = flags;
    378406                sqe->len = mode;
     
    407435                __submit_prelude
    408436
    409                 (*sqe){ IORING_OP_STATX, dirfd, pathname, mask, (uint64_t)statxbuf };
     437                (*sqe){ IORING_OP_STATX, dirfd, pathname, mask, (__u64)statxbuf };
    410438                sqe->statx_flags = flags;
    411439
     
    449477                }
    450478                else {
    451                         sqe->off = (uint64_t)-1;
     479                        sqe->off = (__u64)-1;
    452480                }
    453481                sqe->len = len;
     
    457485                }
    458486                else {
    459                         sqe->splice_off_in = (uint64_t)-1;
     487                        sqe->splice_off_in = (__u64)-1;
    460488                }
    461489                sqe->splice_flags  = flags | (SPLICE_FLAGS & submit_flags);
Note: See TracChangeset for help on using the changeset viewer.