From 4db830052d941d9c6de281bc9a2f6ac212c59ad8 Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Wed, 25 Nov 2009 16:53:02 +0200 Subject: libtf: minor changes and new test case for network i/o fixup the internals a bit. --- include/libtf/fiber.h | 19 ++++++++++++++----- include/libtf/io.h | 6 ++++-- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'include/libtf') diff --git a/include/libtf/fiber.h b/include/libtf/fiber.h index 36c2812..c3d87c6 100644 --- a/include/libtf/fiber.h +++ b/include/libtf/fiber.h @@ -23,10 +23,10 @@ /* Fiber wakeup reasons */ #define TF_WAKEUP_NONE 0 -#define TF_WAKEUP_IMMEDIATE EAGAIN -#define TF_WAKEUP_KILL EINTR -#define TF_WAKEUP_TIMEOUT ETIMEDOUT -#define TF_WAKEUP_FD EIO +#define TF_WAKEUP_IMMEDIATE -EAGAIN +#define TF_WAKEUP_KILL -EINTR +#define TF_WAKEUP_TIMEOUT -ETIMEDOUT +#define TF_WAKEUP_FD -EIO /* Special timeouts for tf_schedule() */ #define TF_NO_TIMEOUT -1 @@ -50,6 +50,11 @@ struct tf_scheduler { }; +struct tf_main_ctx { + int argc; + char ** argv; +}; + static inline struct tf_scheduler *tf_get_scheduler(void) { @@ -71,7 +76,11 @@ tf_mtime_t tf_mtime(void) /* Fiber creation */ typedef void (*tf_fiber_proc)(void *fiber); -int tf_main(tf_fiber_proc fiber_main); +int tf_main_args(tf_fiber_proc fiber_main, int argc, char **argv); +static inline int tf_main(tf_fiber_proc fiber_main) +{ + return tf_main_args(fiber_main, 0, NULL); +} void *tf_fiber_create(tf_fiber_proc fiber_main, int private_size); void *tf_fiber_get(void *data); diff --git a/include/libtf/io.h b/include/libtf/io.h index 8f5b54d..38dd541 100644 --- a/include/libtf/io.h +++ b/include/libtf/io.h @@ -52,8 +52,10 @@ void tf_poll_close(void); int tf_open_fd(struct tf_fd *fd, int kfd, int flags); int tf_open(struct tf_fd *fd, const char *pathname, int flags); int tf_close(struct tf_fd *fd); -int tf_read(struct tf_fd *fd, void *buf, size_t count, tf_mtime_diff_t timeout); -int tf_write(struct tf_fd *fd, const void *buf, size_t count, tf_mtime_diff_t timeout); +ssize_t tf_read(struct tf_fd *fd, void *buf, size_t count, tf_mtime_diff_t timeout); +ssize_t tf_write(struct tf_fd *fd, const void *buf, size_t count, tf_mtime_diff_t timeout); +int tf_read_fully(struct tf_fd *fd, void *buf, size_t count, tf_mtime_diff_t timeout); +int tf_write_fully(struct tf_fd *fd, const void *buf, size_t count, tf_mtime_diff_t timeout); int tf_socket(struct tf_fd *fd, int domain, int type, int protocol); int tf_bind(struct tf_fd *fd, const struct tf_sockaddr *addr); -- cgit v1.2.3