Sun Mar 15 21:29:15 2009 UTC ()
ansify function definitions


(cegger)
diff -r1.10 -r1.11 src/sys/dev/rasops/rasops_bitops.h

cvs diff -r1.10 -r1.11 src/sys/dev/rasops/rasops_bitops.h (switch to unified diff)

--- src/sys/dev/rasops/rasops_bitops.h 2008/04/28 20:23:56 1.10
+++ src/sys/dev/rasops/rasops_bitops.h 2009/03/15 21:29:15 1.11
@@ -1,314 +1,308 @@ @@ -1,314 +1,308 @@
1/* $NetBSD: rasops_bitops.h,v 1.10 2008/04/28 20:23:56 martin Exp $ */ 1/* $NetBSD: rasops_bitops.h,v 1.11 2009/03/15 21:29:15 cegger Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1999 The NetBSD Foundation, Inc. 4 * Copyright (c) 1999 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#ifndef _RASOPS_BITOPS_H_ 32#ifndef _RASOPS_BITOPS_H_
33#define _RASOPS_BITOPS_H_ 1 33#define _RASOPS_BITOPS_H_ 1
34 34
35/* 35/*
36 * Erase columns. 36 * Erase columns.
37 */ 37 */
38static void 38static void
39NAME(erasecols)(cookie, row, col, num, attr) 39NAME(erasecols)(void *cookie, int row, int col, int num, long attr)
40 void *cookie; 
41 int row, col, num; 
42 long attr; 
43{ 40{
44 int lmask, rmask, lclr, rclr, clr; 41 int lmask, rmask, lclr, rclr, clr;
45 struct rasops_info *ri; 42 struct rasops_info *ri;
46 int32_t *dp, *rp; 43 int32_t *dp, *rp;
47 int height, cnt; 44 int height, cnt;
48 45
49 ri = (struct rasops_info *)cookie; 46 ri = (struct rasops_info *)cookie;
50 47
51#ifdef RASOPS_CLIPPING 48#ifdef RASOPS_CLIPPING
52 if ((unsigned)row >= (unsigned)ri->ri_rows) 49 if ((unsigned)row >= (unsigned)ri->ri_rows)
53 return; 50 return;
54 51
55 if (col < 0) { 52 if (col < 0) {
56 num += col; 53 num += col;
57 col = 0; 54 col = 0;
58 } 55 }
59 56
60 if ((col + num) > ri->ri_cols) 57 if ((col + num) > ri->ri_cols)
61 num = ri->ri_cols - col; 58 num = ri->ri_cols - col;
62 59
63 if (num <= 0) 60 if (num <= 0)
64 return; 61 return;
65#endif 62#endif
66 col *= ri->ri_font->fontwidth << PIXEL_SHIFT; 63 col *= ri->ri_font->fontwidth << PIXEL_SHIFT;
67 num *= ri->ri_font->fontwidth << PIXEL_SHIFT; 64 num *= ri->ri_font->fontwidth << PIXEL_SHIFT;
68 height = ri->ri_font->fontheight; 65 height = ri->ri_font->fontheight;
69 clr = ri->ri_devcmap[(attr >> 16) & 0xf]; 66 clr = ri->ri_devcmap[(attr >> 16) & 0xf];
70 rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3)); 67 rp = (int32_t *)(ri->ri_bits + row*ri->ri_yscale + ((col >> 3) & ~3));
71 68
72 if ((col & 31) + num <= 32) { 69 if ((col & 31) + num <= 32) {
73 lmask = ~rasops_pmask[col & 31][num]; 70 lmask = ~rasops_pmask[col & 31][num];
74 lclr = clr & ~lmask; 71 lclr = clr & ~lmask;
75 72
76 while (height--) { 73 while (height--) {
77 dp = rp; 74 dp = rp;
78 DELTA(rp, ri->ri_stride, int32_t *); 75 DELTA(rp, ri->ri_stride, int32_t *);
79 76
80 *dp = (*dp & lmask) | lclr; 77 *dp = (*dp & lmask) | lclr;
81 } 78 }
82 } else { 79 } else {
83 lmask = rasops_rmask[col & 31]; 80 lmask = rasops_rmask[col & 31];
84 rmask = rasops_lmask[(col + num) & 31]; 81 rmask = rasops_lmask[(col + num) & 31];
85 82
86 if (lmask) 83 if (lmask)
87 num = (num - (32 - (col & 31))) >> 5; 84 num = (num - (32 - (col & 31))) >> 5;
88 else 85 else
89 num = num >> 5; 86 num = num >> 5;
90 87
91 lclr = clr & ~lmask; 88 lclr = clr & ~lmask;
92 rclr = clr & ~rmask; 89 rclr = clr & ~rmask;
93 90
94 while (height--) { 91 while (height--) {
95 dp = rp; 92 dp = rp;
96 DELTA(rp, ri->ri_stride, int32_t *); 93 DELTA(rp, ri->ri_stride, int32_t *);
97 94
98 if (lmask) { 95 if (lmask) {
99 *dp = (*dp & lmask) | lclr; 96 *dp = (*dp & lmask) | lclr;
100 dp++; 97 dp++;
101 } 98 }
102 99
103 for (cnt = num; cnt > 0; cnt--) 100 for (cnt = num; cnt > 0; cnt--)
104 *dp++ = clr; 101 *dp++ = clr;
105 102
106 if (rmask) 103 if (rmask)
107 *dp = (*dp & rmask) | rclr; 104 *dp = (*dp & rmask) | rclr;
108 } 105 }
109 } 106 }
110} 107}
111 108
112/* 109/*
113 * Actually paint the cursor. 110 * Actually paint the cursor.
114 */ 111 */
115static void 112static void
116NAME(do_cursor)(ri) 113NAME(do_cursor)(struct rasops_info *ri)
117 struct rasops_info *ri; 
118{ 114{
119 int lmask, rmask, height, row, col, num; 115 int lmask, rmask, height, row, col, num;
120 int32_t *dp, *rp; 116 int32_t *dp, *rp;
121 117
122 row = ri->ri_crow; 118 row = ri->ri_crow;
123 col = ri->ri_ccol * ri->ri_font->fontwidth << PIXEL_SHIFT; 119 col = ri->ri_ccol * ri->ri_font->fontwidth << PIXEL_SHIFT;
124 height = ri->ri_font->fontheight; 120 height = ri->ri_font->fontheight;
125 num = ri->ri_font->fontwidth << PIXEL_SHIFT; 121 num = ri->ri_font->fontwidth << PIXEL_SHIFT;
126 rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3)); 122 rp = (int32_t *)(ri->ri_bits + row * ri->ri_yscale + ((col >> 3) & ~3));
127 123
128 if ((col & 31) + num <= 32) { 124 if ((col & 31) + num <= 32) {
129 lmask = rasops_pmask[col & 31][num]; 125 lmask = rasops_pmask[col & 31][num];
130 126
131 while (height--) { 127 while (height--) {
132 dp = rp; 128 dp = rp;
133 DELTA(rp, ri->ri_stride, int32_t *); 129 DELTA(rp, ri->ri_stride, int32_t *);
134 *dp ^= lmask; 130 *dp ^= lmask;
135 } 131 }
136 } else { 132 } else {
137 lmask = ~rasops_rmask[col & 31]; 133 lmask = ~rasops_rmask[col & 31];
138 rmask = ~rasops_lmask[(col + num) & 31]; 134 rmask = ~rasops_lmask[(col + num) & 31];
139 135
140 while (height--) { 136 while (height--) {
141 dp = rp; 137 dp = rp;
142 DELTA(rp, ri->ri_stride, int32_t *); 138 DELTA(rp, ri->ri_stride, int32_t *);
143 139
144 if (lmask != -1) 140 if (lmask != -1)
145 *dp++ ^= lmask; 141 *dp++ ^= lmask;
146 142
147 if (rmask != -1) 143 if (rmask != -1)
148 *dp ^= rmask; 144 *dp ^= rmask;
149 } 145 }
150 } 146 }
151} 147}
152 148
153/* 149/*
154 * Copy columns. Ick! 150 * Copy columns. Ick!
155 */ 151 */
156static void 152static void
157NAME(copycols)(cookie, row, src, dst, num) 153NAME(copycols)(void *cookie, int row, int src, int dst, int num)
158 void *cookie; 
159 int row, src, dst, num; 
160{ 154{
161 int tmp, lmask, rmask, height, lnum, rnum, sb, db, cnt, full; 155 int tmp, lmask, rmask, height, lnum, rnum, sb, db, cnt, full;
162 int32_t *sp, *dp, *srp, *drp; 156 int32_t *sp, *dp, *srp, *drp;
163 struct rasops_info *ri; 157 struct rasops_info *ri;
164 158
165 sp = NULL; /* XXX gcc */ 159 sp = NULL; /* XXX gcc */
166 160
167 ri = (struct rasops_info *)cookie; 161 ri = (struct rasops_info *)cookie;
168 162
169#ifdef RASOPS_CLIPPING 163#ifdef RASOPS_CLIPPING
170 if (dst == src) 164 if (dst == src)
171 return; 165 return;
172 166
173 /* Catches < 0 case too */ 167 /* Catches < 0 case too */
174 if ((unsigned)row >= (unsigned)ri->ri_rows) 168 if ((unsigned)row >= (unsigned)ri->ri_rows)
175 return; 169 return;
176 170
177 if (src < 0) { 171 if (src < 0) {
178 num += src; 172 num += src;
179 src = 0; 173 src = 0;
180 } 174 }
181 175
182 if ((src + num) > ri->ri_cols) 176 if ((src + num) > ri->ri_cols)
183 num = ri->ri_cols - src; 177 num = ri->ri_cols - src;
184 178
185 if (dst < 0) { 179 if (dst < 0) {
186 num += dst; 180 num += dst;
187 dst = 0; 181 dst = 0;
188 } 182 }
189 183
190 if ((dst + num) > ri->ri_cols) 184 if ((dst + num) > ri->ri_cols)
191 num = ri->ri_cols - dst; 185 num = ri->ri_cols - dst;
192 186
193 if (num <= 0) 187 if (num <= 0)
194 return; 188 return;
195#endif 189#endif
196 190
197 cnt = ri->ri_font->fontwidth << PIXEL_SHIFT; 191 cnt = ri->ri_font->fontwidth << PIXEL_SHIFT;
198 src *= cnt; 192 src *= cnt;
199 dst *= cnt; 193 dst *= cnt;
200 num *= cnt; 194 num *= cnt;
201 row *= ri->ri_yscale; 195 row *= ri->ri_yscale;
202 height = ri->ri_font->fontheight; 196 height = ri->ri_font->fontheight;
203 db = dst & 31; 197 db = dst & 31;
204 198
205 if (db + num <= 32) { 199 if (db + num <= 32) {
206 /* Destination is contained within a single word */ 200 /* Destination is contained within a single word */
207 srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3)); 201 srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
208 drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3)); 202 drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
209 sb = src & 31; 203 sb = src & 31;
210 204
211 while (height--) { 205 while (height--) {
212 GETBITS(srp, sb, num, tmp); 206 GETBITS(srp, sb, num, tmp);
213 PUTBITS(tmp, db, num, drp); 207 PUTBITS(tmp, db, num, drp);
214 DELTA(srp, ri->ri_stride, int32_t *); 208 DELTA(srp, ri->ri_stride, int32_t *);
215 DELTA(drp, ri->ri_stride, int32_t *); 209 DELTA(drp, ri->ri_stride, int32_t *);
216 } 210 }
217 211
218 return; 212 return;
219 } 213 }
220 214
221 lmask = rasops_rmask[db]; 215 lmask = rasops_rmask[db];
222 rmask = rasops_lmask[(dst + num) & 31]; 216 rmask = rasops_lmask[(dst + num) & 31];
223 lnum = (32 - db) & 31; 217 lnum = (32 - db) & 31;
224 rnum = (dst + num) & 31; 218 rnum = (dst + num) & 31;
225 219
226 if (lmask) 220 if (lmask)
227 full = (num - (32 - (dst & 31))) >> 5; 221 full = (num - (32 - (dst & 31))) >> 5;
228 else 222 else
229 full = num >> 5; 223 full = num >> 5;
230 224
231 if (src < dst && src + num > dst) { 225 if (src < dst && src + num > dst) {
232 /* Copy right-to-left */ 226 /* Copy right-to-left */
233 sb = src & 31; 227 sb = src & 31;
234 src = src + num; 228 src = src + num;
235 dst = dst + num; 229 dst = dst + num;
236 srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3)); 230 srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
237 drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3)); 231 drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
238 232
239 src = src & 31; 233 src = src & 31;
240 rnum = 32 - lnum; 234 rnum = 32 - lnum;
241 db = dst & 31; 235 db = dst & 31;
242 236
243 if ((src -= db) < 0) { 237 if ((src -= db) < 0) {
244 sp--; 238 sp--;
245 src += 32; 239 src += 32;
246 } 240 }
247 241
248 while (height--) { 242 while (height--) {
249 sp = srp; 243 sp = srp;
250 dp = drp; 244 dp = drp;
251 DELTA(srp, ri->ri_stride, int32_t *); 245 DELTA(srp, ri->ri_stride, int32_t *);
252 DELTA(drp, ri->ri_stride, int32_t *); 246 DELTA(drp, ri->ri_stride, int32_t *);
253 247
254 if (db) { 248 if (db) {
255 GETBITS(sp, src, db, tmp); 249 GETBITS(sp, src, db, tmp);
256 PUTBITS(tmp, 0, db, dp); 250 PUTBITS(tmp, 0, db, dp);
257 dp--; 251 dp--;
258 sp--; 252 sp--;
259 } 253 }
260 254
261 /* Now aligned to 32-bits wrt dp */ 255 /* Now aligned to 32-bits wrt dp */
262 for (cnt = full; cnt; cnt--, sp--) { 256 for (cnt = full; cnt; cnt--, sp--) {
263 GETBITS(sp, src, 32, tmp); 257 GETBITS(sp, src, 32, tmp);
264 *dp-- = tmp; 258 *dp-- = tmp;
265 } 259 }
266 260
267 if (lmask) { 261 if (lmask) {
268#if 0 262#if 0
269 if (src > sb) 263 if (src > sb)
270 sp++; 264 sp++;
271#endif 265#endif
272 GETBITS(sp, sb, lnum, tmp); 266 GETBITS(sp, sb, lnum, tmp);
273 PUTBITS(tmp, rnum, lnum, dp); 267 PUTBITS(tmp, rnum, lnum, dp);
274 } 268 }
275 } 269 }
276 } else { 270 } else {
277 /* Copy left-to-right */ 271 /* Copy left-to-right */
278 srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3)); 272 srp = (int32_t *)(ri->ri_bits + row + ((src >> 3) & ~3));
279 drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3)); 273 drp = (int32_t *)(ri->ri_bits + row + ((dst >> 3) & ~3));
280 db = dst & 31; 274 db = dst & 31;
281 275
282 while (height--) { 276 while (height--) {
283 sb = src & 31; 277 sb = src & 31;
284 sp = srp; 278 sp = srp;
285 dp = drp; 279 dp = drp;
286 DELTA(srp, ri->ri_stride, int32_t *); 280 DELTA(srp, ri->ri_stride, int32_t *);
287 DELTA(drp, ri->ri_stride, int32_t *); 281 DELTA(drp, ri->ri_stride, int32_t *);
288 282
289 if (lmask) { 283 if (lmask) {
290 GETBITS(sp, sb, lnum, tmp); 284 GETBITS(sp, sb, lnum, tmp);
291 PUTBITS(tmp, db, lnum, dp); 285 PUTBITS(tmp, db, lnum, dp);
292 dp++; 286 dp++;
293 287
294 if ((sb += lnum) > 31) { 288 if ((sb += lnum) > 31) {
295 sp++; 289 sp++;
296 sb -= 32; 290 sb -= 32;
297 } 291 }
298 } 292 }
299 293
300 /* Now aligned to 32-bits wrt dp */ 294 /* Now aligned to 32-bits wrt dp */
301 for (cnt = full; cnt; cnt--, sp++) { 295 for (cnt = full; cnt; cnt--, sp++) {
302 GETBITS(sp, sb, 32, tmp); 296 GETBITS(sp, sb, 32, tmp);
303 *dp++ = tmp; 297 *dp++ = tmp;
304 } 298 }
305 299
306 if (rmask) { 300 if (rmask) {
307 GETBITS(sp, sb, rnum, tmp); 301 GETBITS(sp, sb, rnum, tmp);
308 PUTBITS(tmp, 0, rnum, dp); 302 PUTBITS(tmp, 0, rnum, dp);
309 } 303 }
310 } 304 }
311 } 305 }
312} 306}
313 307
314#endif /* _RASOPS_BITOPS_H_ */ 308#endif /* _RASOPS_BITOPS_H_ */