Print this page
remove support for non-ANSI compilation
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/swap.h
+++ new/usr/src/uts/common/sys/swap.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
↓ open down ↓ |
11 lines elided |
↑ open up ↑ |
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 + * Copyright 2014 Garrett D'Amore <garrett@damore.org>
22 23 * Copyright (c) 1987, 2010, Oracle and/or its affiliates. All rights reserved.
23 24 */
24 25
25 26 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
26 27 /* All Rights Reserved */
27 28
28 29 /*
29 30 * University Copyright- Copyright (c) 1982, 1986, 1988
30 31 * The Regents of the University of California
31 32 * All Rights Reserved
32 33 *
33 34 * University Acknowledgment- Portions of this document are derived from
34 35 * software developed by the University of California, Berkeley, and its
35 36 * contributors.
36 37 */
37 38
38 39 #ifndef _SYS_SWAP_H
39 40 #define _SYS_SWAP_H
40 41
41 42 #include <sys/isa_defs.h>
42 43 #include <sys/feature_tests.h>
43 44 #include <vm/anon.h>
44 45 #include <sys/fs/swapnode.h>
45 46
46 47 #ifdef __cplusplus
47 48 extern "C" {
48 49 #endif
49 50
50 51 #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
51 52 #error "Cannot use swapctl in the large files compilation environment"
52 53 #endif
53 54
54 55 /* The following are for the swapctl system call */
55 56
56 57 #define SC_ADD 1 /* add a specified resource for swapping */
57 58 #define SC_LIST 2 /* list all the swapping resources */
58 59 #define SC_REMOVE 3 /* remove the specified swapping resource */
59 60 #define SC_GETNSWP 4 /* get number of swap resources configured */
60 61 #define SC_AINFO 5 /* get anonymous memory resource information */
61 62
62 63 typedef struct swapres {
63 64 char *sr_name; /* pathname of the resource specified */
64 65 off_t sr_start; /* starting offset of the swapping resource */
65 66 off_t sr_length; /* length of the swap area */
66 67 } swapres_t;
67 68
68 69 typedef struct swapent {
69 70 char *ste_path; /* get the name of the swap file */
70 71 off_t ste_start; /* starting block for swapping */
71 72 off_t ste_length; /* length of swap area */
72 73 long ste_pages; /* numbers of pages for swapping */
73 74 long ste_free; /* numbers of ste_pages free */
74 75 int ste_flags; /* see below */
75 76 } swapent_t;
76 77
77 78 typedef struct swaptable {
78 79 int swt_n; /* number of swapents following */
79 80 struct swapent swt_ent[1]; /* array of swt_n swapents */
80 81 } swaptbl_t;
81 82
82 83
83 84 #if defined(_SYSCALL32)
84 85
85 86 /* Kernel's view of user ILP32 swapres and swapent structures */
86 87
87 88 typedef struct swapres32 {
88 89 caddr32_t sr_name; /* pathname of the resource specified */
89 90 off32_t sr_start; /* starting offset of the swapping resource */
90 91 off32_t sr_length; /* length of the swap area */
91 92 } swapres32_t;
92 93
93 94 typedef struct swapent32 {
94 95 caddr32_t ste_path; /* get the name of the swap file */
95 96 off32_t ste_start; /* starting block for swapping */
96 97 off32_t ste_length; /* length of swap area */
97 98 int32_t ste_pages; /* numbers of pages for swapping */
98 99 int32_t ste_free; /* numbers of ste_pages free */
99 100 int32_t ste_flags; /* see below */
100 101 } swapent32_t;
101 102
102 103 typedef struct swaptable32 {
103 104 int32_t swt_n; /* number of swapents following */
104 105 struct swapent32 swt_ent[1]; /* array of swt_n swapents */
↓ open down ↓ |
73 lines elided |
↑ open up ↑ |
105 106 } swaptbl32_t;
106 107
107 108 #endif /* _SYSCALL32 */
108 109
109 110 #if defined(_KERNEL)
110 111 extern int swapctl(int, void *, int *);
111 112 #if defined(_LP64) && defined(_SYSCALL32)
112 113 extern int swapctl32(int, void *, int *);
113 114 #endif /* _LP64 && _SYSCALL32 */
114 115 #else /* !_KERNEL */
115 -#if defined(__STDC__)
116 116 extern int swapctl(int, void *);
117 -#else
118 -extern int swapctl();
119 -#endif
120 117 #endif /* _KERNEL */
121 118
122 119
123 120 /* ste_flags values */
124 121
125 122 #define ST_INDEL 0x01 /* Deletion of file is in progress. */
126 123 /* Prevents others from deleting or */
127 124 /* allocating from it */
128 125 #define ST_DOINGDEL 0x02 /* Set during deletion of file */
129 126 /* Clearing during deletion signals */
130 127 /* that you want to add the file back */
131 128 /* again, and will eventually cause */
132 129 /* it to be added back */
133 130
134 131 /*
135 132 * VM - virtual swap device.
136 133 */
137 134 struct swapinfo {
138 135 ulong_t si_soff; /* starting offset (bytes) of file */
139 136 ulong_t si_eoff; /* ending offset (bytes) of file */
140 137 struct vnode *si_vp; /* vnode (commonvp if device) */
141 138 struct swapinfo *si_next; /* next swap area */
142 139 int si_allocs; /* # of conseq. allocs from this area */
143 140 short si_flags; /* flags defined below */
144 141 pgcnt_t si_npgs; /* number of pages of swap space */
145 142 pgcnt_t si_nfpgs; /* number of free pages of swap space */
146 143 int si_pnamelen; /* swap file name length + 1 */
147 144 char *si_pname; /* swap file name */
148 145 ssize_t si_mapsize; /* # bytes allocated for bitmap */
149 146 uint_t *si_swapslots; /* bitmap of slots, unset == free */
150 147 pgcnt_t si_hint; /* first page to check if free */
151 148 ssize_t si_checkcnt; /* # of checks to find freeslot */
152 149 ssize_t si_alloccnt; /* used to find ave checks */
153 150 };
154 151
155 152 /*
156 153 * Stuff to convert an anon slot pointer to a page name.
157 154 * Because the address of the slot (ap) is a unique identifier, we
158 155 * use it to generate a unique (vp,off), as shown in the comment for
159 156 * swap_alloc().
160 157 *
161 158 * The off bits are shifted PAGESHIFT to directly form a page aligned
162 159 * offset; the vp index bits map 1-1 to a vnode.
163 160 *
164 161 */
165 162 #define MAX_SWAP_VNODES_LOG2 11 /* log2(MAX_SWAP_VNODES) */
166 163 #define MAX_SWAP_VNODES (1U << MAX_SWAP_VNODES_LOG2) /* max # swap vnodes */
167 164 #define AN_VPMASK (MAX_SWAP_VNODES - 1) /* vp index mask */
168 165 #define AN_VPSHIFT MAX_SWAP_VNODES_LOG2
169 166 /*
170 167 * Convert from an anon slot to associated vnode and offset.
171 168 */
172 169 #define swap_xlate(AP, VPP, OFFP) \
173 170 { \
174 171 *(VPP) = (AP)->an_vp; \
175 172 *(OFFP) = (AP)->an_off; \
176 173 }
177 174 #define swap_xlate_nopanic swap_xlate
178 175
179 176 /*
180 177 * Get a vnode name for an anon slot.
181 178 * The vnum, offset are derived from anon struct address which is
182 179 * 16 bytes aligned. anon structs may be kmem_cache_alloc'd concurrently by
183 180 * multiple threads and come from a small range of addresses (same slab), in
184 181 * which case high order AP bits do not vary much, so choose vnum from low
185 182 * order bits which vary the most. Different threads will thus get different
186 183 * vnums and vnodes, which avoids vph_mutex_contention on the subsequent
187 184 * page_hashin().
188 185 *
189 186 * +-----------...-------------------+-----------------------+----+
190 187 * | swap offset | vnum |0000|
191 188 * +-----------...-------------------+-----------------------+----+
192 189 * 63 15 14 4 3 0
193 190 */
194 191 #define swap_alloc(AP) \
195 192 { \
196 193 (AP)->an_vp = swapfs_getvp(((uintptr_t)(AP) >> AN_CACHE_ALIGN_LOG2) \
197 194 & AN_VPMASK); \
198 195 (AP)->an_off = (anoff_t)((((uintptr_t)(AP)) >> \
199 196 AN_VPSHIFT + AN_CACHE_ALIGN_LOG2) << PAGESHIFT); \
200 197 }
201 198
202 199 /*
203 200 * Free the page name for the specified anon slot.
204 201 * For now there's nothing to do.
205 202 */
206 203 #define swap_free(AP)
207 204
208 205 /* Flags for swap_phys_alloc */
209 206 #define SA_NOT 0x01 /* Must have slot from swap dev other than input one */
210 207
211 208 /* Special error codes for swap_newphysname() */
212 209 #define SE_NOSWAP -1 /* No physical swap slots available */
213 210 #define SE_NOANON -2 /* No anon slot for swap slot */
214 211
215 212 #ifdef _KERNEL
216 213 extern struct anon *swap_anon(struct vnode *vp, u_offset_t off);
217 214 extern int swap_phys_alloc(struct vnode **vpp, u_offset_t *offp, size_t *lenp,
218 215 uint_t flags);
219 216 extern void swap_phys_free(struct vnode *vp, u_offset_t off, size_t len);
220 217 extern int swap_getphysname(struct vnode *vp, u_offset_t off,
221 218 struct vnode **pvpp, u_offset_t *poffp);
222 219 extern int swap_newphysname(struct vnode *vp, u_offset_t offset,
223 220 u_offset_t *offp, size_t *lenp, struct vnode **pvpp, u_offset_t *poffp);
224 221
225 222 extern struct swapinfo *swapinfo;
226 223 extern int swap_debug;
227 224 #endif /* _KERNEL */
228 225
229 226 #ifdef SWAP_DEBUG
230 227 #define SW_RENAME 0x01
231 228 #define SW_RESV 0x02
232 229 #define SW_ALLOC 0x04
233 230 #define SW_CTL 0x08
234 231 #define SWAP_PRINT(f, s, x1, x2, x3, x4, x5) \
235 232 if (swap_debug & f) \
236 233 printf(s, x1, x2, x3, x4, x5);
237 234 #else /* SWAP_DEBUG */
238 235 #define SWAP_PRINT(f, s, x1, x2, x3, x4, x5)
239 236 #endif /* SWAP_DEBUG */
240 237
241 238 #ifdef __cplusplus
242 239 }
243 240 #endif
244 241
245 242 #endif /* _SYS_SWAP_H */
↓ open down ↓ |
116 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX