X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fmainloop.h;h=6e8ffae6d3704bb3114ffb5c70ca7559c51a8e0e;hb=f6e91541c3d3818541f506d57d253f7d9afbeab3;hp=579876cc80a68a868b2dcfa70232681954aafa88;hpb=40ca748c78548c74e192827fd17284757163f7dc;p=libucw.git diff --git a/ucw/mainloop.h b/ucw/mainloop.h index 579876cc..6e8ffae6 100644 --- a/ucw/mainloop.h +++ b/ucw/mainloop.h @@ -15,6 +15,51 @@ #include +#ifdef CONFIG_UCW_CLEAN_ABI +#define block_io_add ucw_block_io_add +#define block_io_del ucw_block_io_del +#define block_io_read ucw_block_io_read +#define block_io_set_timeout ucw_block_io_set_timeout +#define block_io_write ucw_block_io_write +#define file_add ucw_file_add +#define file_chg ucw_file_chg +#define file_debug ucw_file_debug +#define file_del ucw_file_del +#define hook_add ucw_hook_add +#define hook_debug ucw_hook_debug +#define hook_del ucw_hook_del +#define main_cleanup ucw_main_cleanup +#define main_current ucw_main_current +#define main_debug_context ucw_main_debug_context +#define main_delete ucw_main_delete +#define main_destroy ucw_main_destroy +#define main_get_time ucw_main_get_time +#define main_init ucw_main_init +#define main_loop ucw_main_loop +#define main_new ucw_main_new +#define main_step ucw_main_step +#define main_switch_context ucw_main_switch_context +#define main_teardown ucw_main_teardown +#define process_add ucw_process_add +#define process_debug ucw_process_debug +#define process_del ucw_process_del +#define process_fork ucw_process_fork +#define rec_io_add ucw_rec_io_add +#define rec_io_del ucw_rec_io_del +#define rec_io_parse_line ucw_rec_io_parse_line +#define rec_io_set_timeout ucw_rec_io_set_timeout +#define rec_io_start_read ucw_rec_io_start_read +#define rec_io_stop_read ucw_rec_io_stop_read +#define rec_io_write ucw_rec_io_write +#define signal_add ucw_signal_add +#define signal_debug ucw_signal_debug +#define signal_del ucw_signal_del +#define timer_add ucw_timer_add +#define timer_add_rel ucw_timer_add_rel +#define timer_debug ucw_timer_debug +#define timer_del ucw_timer_del +#endif + /*** * [[basic]] * Basic operations @@ -27,21 +72,21 @@ struct main_context { timestamp_t now; /* [*] Current time in milliseconds since an unknown epoch. See main_get_time(). */ timestamp_t idle_time; /* [*] Total time in milliseconds spent by waiting for events. */ - uns shutdown; /* [*] Setting this to nonzero forces the main_loop() function to terminate. */ + uint shutdown; /* [*] Setting this to nonzero forces the main_loop() function to terminate. */ clist file_list; clist file_active_list; clist hook_list; clist hook_done_list; clist process_list; clist signal_list; - uns file_cnt; - uns single_step; + uint file_cnt; + uint single_step; #ifdef CONFIG_UCW_EPOLL int epoll_fd; /* File descriptor used for epoll */ struct epoll_event *epoll_events; clist file_recalc_list; #else - uns poll_table_obsolete; + uint poll_table_obsolete; struct pollfd *poll_table; struct main_file **poll_file_table; #endif @@ -115,8 +160,7 @@ static inline void main_shut_down(void) **/ void main_debug_context(struct main_context *m); -static inline void -main_debug(void) +static inline void main_debug(void) { main_debug_context(main_current()); } @@ -151,7 +195,7 @@ static inline timestamp_t main_get_now(void) struct main_timer { cnode n; timestamp_t expires; - uns index; + uint index; void (*handler)(struct main_timer *tm); /* [*] Function to be called when the timer expires. */ void *data; /* [*] Data for use by the handler */ }; @@ -307,9 +351,9 @@ struct main_file { int (*read_handler)(struct main_file *fi); /* [*] To be called when ready for reading/writing; must call file_chg() afterwards */ int (*write_handler)(struct main_file *fi); void *data; /* [*] Data for use by the handlers */ - uns events; + uint events; #ifdef CONFIG_UCW_EPOLL - uns last_want_events; + uint last_want_events; #else struct pollfd *pollfd; #endif @@ -377,9 +421,9 @@ void file_debug(struct main_file *fi); struct main_block_io { struct main_file file; byte *rbuf; /* Read/write pointers for use by file_read/write */ - uns rpos, rlen; + uint rpos, rlen; byte *wbuf; - uns wpos, wlen; + uint wpos, wlen; void (*read_done)(struct main_block_io *bio); /* [*] Called when file_read is finished; rpos < rlen if EOF */ void (*write_done)(struct main_block_io *bio); /* [*] Called when file_write is finished */ void (*error_handler)(struct main_block_io *bio, int cause); /* [*] Handler to call on errors */ @@ -418,7 +462,7 @@ enum block_io_err_cause { * You can use a call with zero @len to cancel the current read, but all read data * will be thrown away. **/ -void block_io_read(struct main_block_io *bio, void *buf, uns len); +void block_io_read(struct main_block_io *bio, void *buf, uint len); /** * Request that the main loop writes @len bytes of data from @buf to @bio. @@ -431,7 +475,7 @@ void block_io_read(struct main_block_io *bio, void *buf, uns len); * If you call it with zero @len, it will cancel the previous write, but note * that some data may already be written. **/ -void block_io_write(struct main_block_io *bio, void *buf, uns len); +void block_io_write(struct main_block_io *bio, void *buf, uint len); /** * Sets a timer for a file @bio. If the timer is not overwritten or disabled @@ -495,18 +539,18 @@ struct main_rec_io { struct main_file file; byte *read_buf; byte *read_rec_start; /* [*] Start of current record */ - uns read_avail; /* [*] How much data is available */ - uns read_prev_avail; /* [*] How much data was available in previous read_handler */ - uns read_buf_size; /* [*] Read buffer size allocated (can be set before rec_io_add()) */ - uns read_started; /* Reading requested by user */ - uns read_running; /* Reading really runs (read_started && not stopped by write_throttle_read) */ - uns read_rec_max; /* [*] Maximum record size (0=unlimited) */ + uint read_avail; /* [*] How much data is available */ + uint read_prev_avail; /* [*] How much data was available in previous read_handler */ + uint read_buf_size; /* [*] Read buffer size allocated (can be set before rec_io_add()) */ + uint read_started; /* Reading requested by user */ + uint read_running; /* Reading really runs (read_started && not stopped by write_throttle_read) */ + uint read_rec_max; /* [*] Maximum record size (0=unlimited) */ clist busy_write_buffers; clist idle_write_buffers; - uns write_buf_size; /* [*] Write buffer size allocated (can be set before rec_io_add()) */ - uns write_watermark; /* [*] How much data are waiting to be written */ - uns write_throttle_read; /* [*] If more than write_throttle_read bytes are buffered, stop reading; 0=no stopping */ - uns (*read_handler)(struct main_rec_io *rio); /* [*] Called whenever more bytes are read; returns 0 (want more) or number of bytes eaten */ + uint write_buf_size; /* [*] Write buffer size allocated (can be set before rec_io_add()) */ + uint write_watermark; /* [*] How much data are waiting to be written */ + uint write_throttle_read; /* [*] If more than write_throttle_read bytes are buffered, stop reading; 0=no stopping */ + uint (*read_handler)(struct main_rec_io *rio); /* [*] Called whenever more bytes are read; returns 0 (want more) or number of bytes eaten */ int (*notify_handler)(struct main_rec_io *rio, int status); /* [*] Called to notify about errors and other events */ /* Returns either HOOK_RETRY or HOOK_IDLE. */ struct main_timer timer; @@ -536,14 +580,14 @@ void rec_io_stop_read(struct main_rec_io *rio); /** Analogous to @block_io_set_timeout(). **/ void rec_io_set_timeout(struct main_rec_io *rio, timestamp_t expires_delta); -void rec_io_write(struct main_rec_io *rio, void *data, uns len); +void rec_io_write(struct main_rec_io *rio, void *data, uint len); /** * An auxiliary function used for parsing of lines. When called in the @read_handler, * it searches for the end of line character. When a complete line is found, the length * of the line (including the end of line character) is returned. Otherwise, it returns zero. **/ -uns rec_io_parse_line(struct main_rec_io *rio); +uint rec_io_parse_line(struct main_rec_io *rio); /** * Specifies what kind of error or other event happened, when the @notify_handler