Project

General

Profile

Statistics
| Revision:

root / lab4 / .minix-src / include / sys / asynchio.h @ 14

History | View | Annotate | Download (1.5 KB)

1 13 up20180614
/*        asynchio.h - Asynchronous I/O                        Author: Kees J. Bot
2
 *                                                                7 Jul 1997
3
 * Minix-vmd compatible asynchio(3) using BSD select(2).
4
 */
5
#ifndef _SYS__ASYNCHIO_H
6
#define _SYS__ASYNCHIO_H
7
8
#include <sys/select.h>                        /* for FD_SETSIZE */
9
10
#define SEL_READ        0                /* Code for a read. */
11
#define SEL_WRITE        1                /* Code for a write. */
12
#define SEL_EXCEPT        2                /* Code for some exception. */
13
#define SEL_NR                3                /* Number of codes. */
14
15
struct _asynfd {
16
        int                afd_seen;        /* Set if we manage this descriptor. */
17
        int                afd_flags;        /* File flags by fcntl(fd, F_GETFL). */
18
        int                afd_state[SEL_NR];  /* Operation state. */
19
};
20
21
typedef struct {
22
        int                asyn_more;        /* Set if more to do before blocking. */
23
        struct _asynfd        asyn_afd[FD_SETSIZE];
24
        fd_set                asyn_fdset[SEL_NR];        /* Select() fd sets. */
25
} asynchio_t;
26
27
#define ASYN_INPROGRESS        EAGAIN                /* Errno code telling "nothing yet." */
28
#define ASYN_NONBLOCK        0x01                /* If asyn_wait() mustn't block. */
29
30
struct timeval;
31
32
void asyn_init(asynchio_t *_asyn);
33
ssize_t asyn_read(asynchio_t *_asyn, int _fd, void *_buf, size_t _len);
34
ssize_t asyn_write(asynchio_t *_asyn, int _fd, const void *_buf, size_t _len);
35
int asyn_special(asynchio_t *_asyn, int _fd, int _op);
36
int asyn_result(asynchio_t *_asyn, int _fd, int _op, int _result);
37
int asyn_wait(asynchio_t *_asyn, int _flags, struct timeval *to);
38
int asyn_cancel(asynchio_t *_asyn, int _fd, int _op);
39
int asyn_pending(asynchio_t *_asyn, int _fd, int _op);
40
int asyn_synch(asynchio_t *_asyn, int _fd);
41
int asyn_close(asynchio_t *_asyn, int _fd);
42
43
#endif /* _SYS__ASYNCHIO_H */