Ignore:
Timestamp:
Jan 12, 2021, 12:57:59 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
35285fd
Parents:
58f99b3
Message:

clean-up handling of epoll so it's limited to one file

Location:
libcfa/src/concurrency/io
Files:
2 edited

Legend:

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

    r58f99b3 rd48b174  
    190190                                        __cfaabi_tls.this_stats = io_ctx->self.curr_cluster->stats;
    191191                                #endif
     192
     193                                eventfd_t v;
     194                                eventfd_read(io_ctx->ring->efd, &v);
     195
    192196                                post( io_ctx->sem );
    193197                        }
     
    494498// I/O Context Sleep
    495499//=============================================================================================
    496 
    497         void __ioctx_register($io_ctx_thread & ctx, struct epoll_event & ev) {
    498                 ev.events = EPOLLIN | EPOLLET | EPOLLONESHOT;
     500        #define IOEVENTS EPOLLIN | EPOLLONESHOT
     501
     502        static inline void __ioctx_epoll_ctl($io_ctx_thread & ctx, int op, const char * error) {
     503                struct epoll_event ev;
     504                ev.events = IOEVENTS;
    499505                ev.data.u64 = (__u64)&ctx;
    500                 int ret = epoll_ctl(iopoll.epollfd, EPOLL_CTL_ADD, ctx.ring->efd, &ev);
     506                int ret = epoll_ctl(iopoll.epollfd, op, ctx.ring->efd, &ev);
    501507                if (ret < 0) {
    502                         abort( "KERNEL ERROR: EPOLL ADD - (%d) %s\n", (int)errno, strerror(errno) );
    503                 }
    504         }
    505 
    506         void __ioctx_prepare_block($io_ctx_thread & ctx, struct epoll_event & ev) {
     508                        abort( "KERNEL ERROR: EPOLL %s - (%d) %s\n", error, (int)errno, strerror(errno) );
     509                }
     510        }
     511
     512        void __ioctx_register($io_ctx_thread & ctx) {
     513                __ioctx_epoll_ctl(ctx, EPOLL_CTL_ADD, "ADD");
     514        }
     515
     516        void __ioctx_prepare_block($io_ctx_thread & ctx) {
    507517                __cfadbg_print_safe(io_core, "Kernel I/O - epoll : Re-arming io poller %d (%p)\n", ctx.ring->fd, &ctx);
    508                 int ret = epoll_ctl(iopoll.epollfd, EPOLL_CTL_MOD, ctx.ring->efd, &ev);
    509                 if (ret < 0) {
    510                         abort( "KERNEL ERROR: EPOLL REARM - (%d) %s\n", (int)errno, strerror(errno) );
    511                 }
     518                __ioctx_epoll_ctl(ctx, EPOLL_CTL_MOD, "REARM");
    512519        }
    513520
  • libcfa/src/concurrency/io/types.hfa

    r58f99b3 rd48b174  
    131131        #endif
    132132
    133         struct epoll_event;
    134133        struct $io_ctx_thread;
    135         void __ioctx_register($io_ctx_thread & ctx, struct epoll_event & ev);
    136         void __ioctx_prepare_block($io_ctx_thread & ctx, struct epoll_event & ev);
     134        void __ioctx_register($io_ctx_thread & ctx);
     135        void __ioctx_prepare_block($io_ctx_thread & ctx);
    137136#endif
    138137
Note: See TracChangeset for help on using the changeset viewer.