Fri Jan 22 23:38:45 2016 UTC ()
Needs struct timespec.


(dholland)
diff -r1.32 -r1.33 src/sys/sys/pipe.h

cvs diff -r1.32 -r1.33 src/sys/sys/pipe.h (switch to unified diff)

--- src/sys/sys/pipe.h 2009/12/20 09:36:06 1.32
+++ src/sys/sys/pipe.h 2016/01/22 23:38:45 1.33
@@ -1,148 +1,149 @@ @@ -1,148 +1,149 @@
1/* $NetBSD: pipe.h,v 1.32 2009/12/20 09:36:06 dsl Exp $ */ 1/* $NetBSD: pipe.h,v 1.33 2016/01/22 23:38:45 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996 John S. Dyson 4 * Copyright (c) 1996 John S. Dyson
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice immediately at the beginning of the file, without modification, 11 * notice immediately at the beginning of the file, without modification,
12 * this list of conditions, and the following disclaimer. 12 * this list of conditions, and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution. 15 * documentation and/or other materials provided with the distribution.
16 * 3. Absolutely no warranty of function or purpose is made by the author 16 * 3. Absolutely no warranty of function or purpose is made by the author
17 * John S. Dyson. 17 * John S. Dyson.
18 * 4. This work was done expressly for inclusion into FreeBSD. Other use 18 * 4. This work was done expressly for inclusion into FreeBSD. Other use
19 * is allowed if this notation is included. 19 * is allowed if this notation is included.
20 * 5. Modifications may be freely made to this file if the above conditions 20 * 5. Modifications may be freely made to this file if the above conditions
21 * are met. 21 * are met.
22 * 22 *
23 * $FreeBSD: src/sys/sys/pipe.h,v 1.18 2002/02/27 07:35:59 alfred Exp $ 23 * $FreeBSD: src/sys/sys/pipe.h,v 1.18 2002/02/27 07:35:59 alfred Exp $
24 */ 24 */
25 25
26#ifndef _SYS_PIPE_H_ 26#ifndef _SYS_PIPE_H_
27#define _SYS_PIPE_H_ 27#define _SYS_PIPE_H_
28 28
29#include <sys/selinfo.h> /* for struct selinfo */ 29#include <sys/selinfo.h> /* for struct selinfo */
 30#include <sys/time.h> /* for struct timespec */
30 31
31#include <uvm/uvm_extern.h> 32#include <uvm/uvm_extern.h>
32 33
33/* 34/*
34 * Pipe buffer size, keep moderate in value, pipes take kva space. 35 * Pipe buffer size, keep moderate in value, pipes take kva space.
35 */ 36 */
36#ifndef PIPE_SIZE 37#ifndef PIPE_SIZE
37#define PIPE_SIZE 16384 38#define PIPE_SIZE 16384
38#endif 39#endif
39 40
40#ifndef BIG_PIPE_SIZE 41#ifndef BIG_PIPE_SIZE
41#define BIG_PIPE_SIZE (4*PIPE_SIZE) 42#define BIG_PIPE_SIZE (4*PIPE_SIZE)
42#endif 43#endif
43 44
44/* 45/*
45 * Maximum size of kva for direct write transfer. If the amount 46 * Maximum size of kva for direct write transfer. If the amount
46 * of data in buffer is larger, it would be transferred in chunks of this 47 * of data in buffer is larger, it would be transferred in chunks of this
47 * size. This kva memory is freed after use if amount of pipe kva memory 48 * size. This kva memory is freed after use if amount of pipe kva memory
48 * is bigger than limitpipekva. 49 * is bigger than limitpipekva.
49 */ 50 */
50#ifndef PIPE_DIRECT_CHUNK 51#ifndef PIPE_DIRECT_CHUNK
51#define PIPE_DIRECT_CHUNK (1*1024*1024) 52#define PIPE_DIRECT_CHUNK (1*1024*1024)
52#endif 53#endif
53 54
54/* 55/*
55 * PIPE_MINDIRECT MUST be smaller than PIPE_SIZE and MUST be bigger 56 * PIPE_MINDIRECT MUST be smaller than PIPE_SIZE and MUST be bigger
56 * than PIPE_BUF. 57 * than PIPE_BUF.
57 */ 58 */
58#ifndef PIPE_MINDIRECT 59#ifndef PIPE_MINDIRECT
59#define PIPE_MINDIRECT 8192 60#define PIPE_MINDIRECT 8192
60#endif 61#endif
61 62
62/* 63/*
63 * Pipe buffer information. 64 * Pipe buffer information.
64 * Separate in, out, cnt are used to simplify calculations. 65 * Separate in, out, cnt are used to simplify calculations.
65 * Buffered write is active when the buffer.cnt field is set. 66 * Buffered write is active when the buffer.cnt field is set.
66 */ 67 */
67struct pipebuf { 68struct pipebuf {
68 size_t cnt; /* number of chars currently in buffer */ 69 size_t cnt; /* number of chars currently in buffer */
69 u_int in; /* in pointer */ 70 u_int in; /* in pointer */
70 u_int out; /* out pointer */ 71 u_int out; /* out pointer */
71 size_t size; /* size of buffer */ 72 size_t size; /* size of buffer */
72 void * buffer; /* kva of buffer */ 73 void * buffer; /* kva of buffer */
73}; 74};
74 75
75/* 76/*
76 * Information to support direct transfers between processes for pipes. 77 * Information to support direct transfers between processes for pipes.
77 */ 78 */
78struct pipemapping { 79struct pipemapping {
79 vaddr_t kva; /* kernel virtual address */ 80 vaddr_t kva; /* kernel virtual address */
80 vsize_t cnt; /* number of chars in buffer */ 81 vsize_t cnt; /* number of chars in buffer */
81 voff_t pos; /* current position within page */ 82 voff_t pos; /* current position within page */
82 int npages; /* how many pages allocated */ 83 int npages; /* how many pages allocated */
83 struct vm_page **pgs; /* pointers to the pages */ 84 struct vm_page **pgs; /* pointers to the pages */
84 u_int egen; /* emap generation number */ 85 u_int egen; /* emap generation number */
85}; 86};
86 87
87/* 88/*
88 * Bits in pipe_state. 89 * Bits in pipe_state.
89 */ 90 */
90#define PIPE_ASYNC 0x001 /* Async I/O */ 91#define PIPE_ASYNC 0x001 /* Async I/O */
91#define PIPE_EOF 0x010 /* Pipe is in EOF condition */ 92#define PIPE_EOF 0x010 /* Pipe is in EOF condition */
92#define PIPE_SIGNALR 0x020 /* Do selwakeup() on read(2) */ 93#define PIPE_SIGNALR 0x020 /* Do selwakeup() on read(2) */
93#define PIPE_DIRECTW 0x040 /* Pipe in direct write mode setup */ 94#define PIPE_DIRECTW 0x040 /* Pipe in direct write mode setup */
94#define PIPE_DIRECTR 0x080 /* Pipe direct read request (setup complete) */ 95#define PIPE_DIRECTR 0x080 /* Pipe direct read request (setup complete) */
95#define PIPE_LOCKFL 0x100 /* Process has exclusive access to 96#define PIPE_LOCKFL 0x100 /* Process has exclusive access to
96 pointers/data. */ 97 pointers/data. */
97#define PIPE_LWANT 0x200 /* Process wants exclusive access to 98#define PIPE_LWANT 0x200 /* Process wants exclusive access to
98 pointers/data. */ 99 pointers/data. */
99#define PIPE_RESTART 0x400 /* Return ERESTART to blocked syscalls */ 100#define PIPE_RESTART 0x400 /* Return ERESTART to blocked syscalls */
100 101
101/* 102/*
102 * Per-pipe data structure. 103 * Per-pipe data structure.
103 * Two of these are linked together to produce bi-directional pipes. 104 * Two of these are linked together to produce bi-directional pipes.
104 */ 105 */
105struct pipe { 106struct pipe {
106 kmutex_t *pipe_lock; /* pipe mutex */ 107 kmutex_t *pipe_lock; /* pipe mutex */
107 kcondvar_t pipe_rcv; /* cv for readers */ 108 kcondvar_t pipe_rcv; /* cv for readers */
108 kcondvar_t pipe_wcv; /* cv for writers */ 109 kcondvar_t pipe_wcv; /* cv for writers */
109 kcondvar_t pipe_draincv; /* cv for close */ 110 kcondvar_t pipe_draincv; /* cv for close */
110 kcondvar_t pipe_lkcv; /* locking */ 111 kcondvar_t pipe_lkcv; /* locking */
111 struct pipebuf pipe_buffer; /* data storage */ 112 struct pipebuf pipe_buffer; /* data storage */
112 struct pipemapping pipe_map; /* pipe mapping for direct I/O */ 113 struct pipemapping pipe_map; /* pipe mapping for direct I/O */
113 struct selinfo pipe_sel; /* for compat with select */ 114 struct selinfo pipe_sel; /* for compat with select */
114 struct timespec pipe_atime; /* time of last access */ 115 struct timespec pipe_atime; /* time of last access */
115 struct timespec pipe_mtime; /* time of last modify */ 116 struct timespec pipe_mtime; /* time of last modify */
116 struct timespec pipe_btime; /* time of creation */ 117 struct timespec pipe_btime; /* time of creation */
117 pid_t pipe_pgid; /* process group for sigio */ 118 pid_t pipe_pgid; /* process group for sigio */
118 struct pipe *pipe_peer; /* link with other direction */ 119 struct pipe *pipe_peer; /* link with other direction */
119 u_int pipe_state; /* pipe status info */ 120 u_int pipe_state; /* pipe status info */
120 int pipe_busy; /* busy flag, to handle rundown */ 121 int pipe_busy; /* busy flag, to handle rundown */
121 vaddr_t pipe_kmem; /* preallocated PIPE_SIZE buffer */ 122 vaddr_t pipe_kmem; /* preallocated PIPE_SIZE buffer */
122}; 123};
123 124
124/* 125/*
125 * KERN_PIPE subtypes 126 * KERN_PIPE subtypes
126 */ 127 */
127#define KERN_PIPE_MAXKVASZ 1 /* maximum kva size */ 128#define KERN_PIPE_MAXKVASZ 1 /* maximum kva size */
128#define KERN_PIPE_LIMITKVA 2 /* */ 129#define KERN_PIPE_LIMITKVA 2 /* */
129#define KERN_PIPE_MAXBIGPIPES 3 /* maximum # of "big" pipes */ 130#define KERN_PIPE_MAXBIGPIPES 3 /* maximum # of "big" pipes */
130#define KERN_PIPE_NBIGPIPES 4 /* current number of "big" p. */ 131#define KERN_PIPE_NBIGPIPES 4 /* current number of "big" p. */
131#define KERN_PIPE_KVASIZE 5 /* current pipe kva size */ 132#define KERN_PIPE_KVASIZE 5 /* current pipe kva size */
132#define KERN_PIPE_MAXID 6 133#define KERN_PIPE_MAXID 6
133 134
134#define CTL_PIPE_NAMES { \ 135#define CTL_PIPE_NAMES { \
135 { 0, 0 }, \ 136 { 0, 0 }, \
136 { "maxkvasz", CTLTYPE_INT }, \ 137 { "maxkvasz", CTLTYPE_INT }, \
137 { "maxloankvasz", CTLTYPE_INT }, \ 138 { "maxloankvasz", CTLTYPE_INT }, \
138 { "maxbigpipes", CTLTYPE_INT }, \ 139 { "maxbigpipes", CTLTYPE_INT }, \
139 { "nbigpipes", CTLTYPE_INT }, \ 140 { "nbigpipes", CTLTYPE_INT }, \
140 { "kvasize", CTLTYPE_INT }, \ 141 { "kvasize", CTLTYPE_INT }, \
141} 142}
142 143
143#ifdef _KERNEL 144#ifdef _KERNEL
144int sysctl_dopipe(int *, u_int, void *, size_t *, void *, size_t); 145int sysctl_dopipe(int *, u_int, void *, size_t *, void *, size_t);
145void pipe_init(void); 146void pipe_init(void);
146#endif /* _KERNEL */ 147#endif /* _KERNEL */
147 148
148#endif /* !_SYS_PIPE_H_ */ 149#endif /* !_SYS_PIPE_H_ */