~mysql/mysql-server/mysql-6.0

« back to all changes in this revision

Viewing changes to mit-pthreads/include/pthread/fd.h

  • Committer: bk at mysql
  • Date: 2000-07-31 19:29:14 UTC
  • Revision ID: sp1r-bk@work.mysql.com-20000731192914-08846
Import changeset

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ==== fd.h ============================================================
 
2
 * Copyright (c) 1993, 1994 by Chris Provenzano, proven@mit.edu
 
3
 * All rights reserved.
 
4
 *
 
5
 * Redistribution and use in source and binary forms, with or without
 
6
 * modification, are permitted provided that the following conditions
 
7
 * are met:
 
8
 * 1. Redistributions of source code must retain the above copyright
 
9
 *    notice, this list of conditions and the following disclaimer.
 
10
 * 2. Redistributions in binary form must reproduce the above copyright
 
11
 *    notice, this list of conditions and the following disclaimer in the
 
12
 *    documentation and/or other materials provided with the distribution.
 
13
 * 3. All advertising materials mentioning features or use of this software
 
14
 *    must display the following acknowledgement:
 
15
 *  This product includes software developed by Chris Provenzano.
 
16
 * 4. The name of Chris Provenzano may not be used to endorse or promote 
 
17
 *        products derived from this software without specific prior written
 
18
 *        permission.
 
19
 *
 
20
 * THIS SOFTWARE IS PROVIDED BY CHRIS PROVENZANO ``AS IS'' AND
 
21
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 
22
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 
23
 * ARE DISCLAIMED.  IN NO EVENT SHALL CHRIS PROVENZANO BE LIABLE FOR ANY 
 
24
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 
25
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
 
26
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
27
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
 
28
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
29
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
 
30
 * SUCH DAMAGE.
 
31
 *
 
32
 * $Id$
 
33
 *
 
34
 * Description : Basic fd header.
 
35
 *
 
36
 *  1.00 93/08/14 proven
 
37
 *      -Started coding this file.
 
38
 *
 
39
 *      1.01 93/11/13 proven
 
40
 *              -The functions readv() and writev() added
 
41
 */
 
42
 
 
43
/*
 
44
 * New pthread types.
 
45
 */
 
46
enum fd_type {
 
47
        FD_NT,                                  /* Not tested */
 
48
        FD_NIU,                                 /* Known to be not in use */
 
49
        FD_HALF_DUPLEX,                 /* Files, and seeking devices */
 
50
        FD_FULL_DUPLEX,                 /* pipes, sockets, drivers, ... */
 
51
        FD_TEST_HALF_DUPLEX,    /* Redo machdep_sys_fcntl */
 
52
        FD_TEST_FULL_DUPLEX     /* Redo machdep_sys_fcntl */
 
53
};
 
54
 
 
55
 
 
56
#define FD_READ                         0x1
 
57
#define FD_WRITE                        0x2
 
58
#define FD_RDWR                         (FD_READ | FD_WRITE)
 
59
 
 
60
union fd_data {
 
61
        void                                    *ptr;
 
62
        int                                             i;
 
63
};
 
64
 
 
65
struct timespec;
 
66
struct iovec;
 
67
struct fd_ops {
 
68
        pthread_ssize_t                 (*write) __P_((union fd_data, int, const void *,
 
69
                                                                                  size_t, struct timespec *));
 
70
        pthread_ssize_t                 (*read) __P_((union fd_data, int, void *, size_t,
 
71
                                                                                 struct timespec *));
 
72
        int                                             (*close)();
 
73
        int                                             (*fcntl)();
 
74
        int                                             (*writev) __P_((union fd_data, int,
 
75
                                                                                   const struct iovec *,
 
76
                                                                                   int, struct timespec *));
 
77
        int                                             (*readv) __P_((union fd_data, int,
 
78
                                                                                  const struct iovec *,
 
79
                                                                                  int, struct timespec *));
 
80
        off_t                                   (*seek)();
 
81
        int                                             use_kfds;
 
82
};
 
83
 
 
84
struct fd_table_entry {
 
85
        struct pthread_queue    r_queue;
 
86
        struct pthread_queue    w_queue;
 
87
        struct pthread                  *r_owner;
 
88
        struct pthread                  *w_owner;
 
89
        pthread_mutex_t                 mutex;
 
90
        struct fd_table_entry   *next;
 
91
        struct fd_ops                   *ops;
 
92
        enum fd_type                    type;
 
93
        int                                             r_lockcount;            /* Count for FILE read locks */
 
94
        int                                             w_lockcount;            /* Count for FILE write locks */
 
95
        int                                             count;
 
96
 
 
97
        /* data that needs to be passed to the type dependent fd */
 
98
        int                                             flags;
 
99
        union fd_data                   fd;
 
100
};
 
101
 
 
102
/*
 
103
 * Globals
 
104
 */
 
105
#if defined(PTHREAD_KERNEL)
 
106
 
 
107
extern struct fd_table_entry **fd_table;
 
108
extern int dtablesize;
 
109
 
 
110
#endif
 
111
 
 
112
/*
 
113
 * New functions
 
114
 */
 
115
 
 
116
__BEGIN_DECLS
 
117
 
 
118
#if defined(PTHREAD_KERNEL)
 
119
 
 
120
#endif
 
121
 
 
122
__END_DECLS