summaryrefslogtreecommitdiff
path: root/sys/dev/rasops/rasops.c
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-09-05 14:09:36 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-09-05 14:09:36 +0000
commitfe97057f16fd1cffc35ca63c0ad5df12f2a7b2df (patch)
tree6bcedac194b240651540f3015081e5826a73f2dd /sys/dev/rasops/rasops.c
parentcdcddd879b0146dd3a452f32dc53867fce692d9b (diff)
Change the wsdisplay_emulops return types from void to int; emulops will now
return zero on success and nonzero on failure. This commit only performs mechanical changes for the existing emulops to always return zero.
Diffstat (limited to 'sys/dev/rasops/rasops.c')
-rw-r--r--sys/dev/rasops/rasops.c135
1 files changed, 88 insertions, 47 deletions
diff --git a/sys/dev/rasops/rasops.c b/sys/dev/rasops/rasops.c
index 719aa91142f..3e12b2f5fb5 100644
--- a/sys/dev/rasops/rasops.c
+++ b/sys/dev/rasops/rasops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rasops.c,v 1.19 2008/08/20 18:49:12 miod Exp $ */
+/* $OpenBSD: rasops.c,v 1.20 2009/09/05 14:09:35 miod Exp $ */
/* $NetBSD: rasops.c,v 1.35 2001/02/02 06:01:01 marcus Exp $ */
/*-
@@ -131,13 +131,13 @@ const u_char rasops_isgray[16] = {
};
/* Generic functions */
-void rasops_copycols(void *, int, int, int, int);
-void rasops_copyrows(void *, int, int, int);
+int rasops_copycols(void *, int, int, int, int);
+int rasops_copyrows(void *, int, int, int);
int rasops_mapchar(void *, int, u_int *);
-void rasops_cursor(void *, int, int, int);
+int rasops_cursor(void *, int, int, int);
int rasops_alloc_cattr(void *, int, int, int, long *);
int rasops_alloc_mattr(void *, int, int, int, long *);
-void rasops_do_cursor(struct rasops_info *);
+int rasops_do_cursor(struct rasops_info *);
void rasops_init_devcmap(struct rasops_info *);
void rasops_unpack_attr(void *, long, int *, int *, int *);
#if NRASOPS_BSWAP > 0
@@ -145,11 +145,11 @@ static void slow_ovbcopy(void *, void *, size_t);
#endif
#if NRASOPS_ROTATION > 0
void rasops_copychar(void *, int, int, int, int);
-void rasops_copycols_rotated(void *, int, int, int, int);
-void rasops_copyrows_rotated(void *, int, int, int);
-void rasops_erasecols_rotated(void *, int, int, int, long);
-void rasops_eraserows_rotated(void *, int, int, long);
-void rasops_putchar_rotated(void *, int, int, u_int, long);
+int rasops_copycols_rotated(void *, int, int, int, int);
+int rasops_copyrows_rotated(void *, int, int, int);
+int rasops_erasecols_rotated(void *, int, int, int, long);
+int rasops_eraserows_rotated(void *, int, int, long);
+int rasops_putchar_rotated(void *, int, int, u_int, long);
void rasops_rotate_font(int *);
/*
@@ -531,7 +531,7 @@ rasops_alloc_mattr(cookie, fg, bg, flg, attr)
/*
* Copy rows.
*/
-void
+int
rasops_copyrows(cookie, src, dst, num)
void *cookie;
int src, dst, num;
@@ -544,7 +544,7 @@ rasops_copyrows(cookie, src, dst, num)
#ifdef RASOPS_CLIPPING
if (dst == src)
- return;
+ return 0;
if (src < 0) {
num += src;
@@ -563,7 +563,7 @@ rasops_copyrows(cookie, src, dst, num)
num = ri->ri_rows - dst;
if (num <= 0)
- return;
+ return 0;
#endif
num *= ri->ri_font->fontheight;
@@ -604,6 +604,8 @@ rasops_copyrows(cookie, src, dst, num)
for (cnt = n1; cnt; cnt--)
*dp++ = *sp++;
}
+
+ return 0;
}
/*
@@ -612,7 +614,7 @@ rasops_copyrows(cookie, src, dst, num)
* We simply cop-out here and use ovbcopy(), since it handles all of
* these cases anyway.
*/
-void
+int
rasops_copycols(cookie, row, src, dst, num)
void *cookie;
int row, src, dst, num;
@@ -625,11 +627,11 @@ rasops_copycols(cookie, row, src, dst, num)
#ifdef RASOPS_CLIPPING
if (dst == src)
- return;
+ return 0;
/* Catches < 0 case too */
if ((unsigned)row >= (unsigned)ri->ri_rows)
- return;
+ return 0;
if (src < 0) {
num += src;
@@ -648,7 +650,7 @@ rasops_copycols(cookie, row, src, dst, num)
num = ri->ri_cols - dst;
if (num <= 0)
- return;
+ return 0;
#endif
num *= ri->ri_xscale;
@@ -674,26 +676,32 @@ rasops_copycols(cookie, row, src, dst, num)
sp += ri->ri_stride;
}
}
+
+ return 0;
}
/*
* Turn cursor off/on.
*/
-void
+int
rasops_cursor(cookie, on, row, col)
void *cookie;
int on, row, col;
{
struct rasops_info *ri;
+ int rc;
ri = (struct rasops_info *)cookie;
/* Turn old cursor off */
- if ((ri->ri_flg & RI_CURSOR) != 0)
+ if ((ri->ri_flg & RI_CURSOR) != 0) {
#ifdef RASOPS_CLIPPING
if ((ri->ri_flg & RI_CURSORCLIP) == 0)
#endif
- ri->ri_do_cursor(ri);
+ if ((rc = ri->ri_do_cursor(ri)) != 0)
+ return rc;
+ ri->ri_flg &= ~RI_CURSOR;
+ }
/* Select new cursor */
#ifdef RASOPS_CLIPPING
@@ -711,13 +719,15 @@ rasops_cursor(cookie, on, row, col)
ri->ri_updatecursor(ri);
if (on) {
- ri->ri_flg |= RI_CURSOR;
#ifdef RASOPS_CLIPPING
if ((ri->ri_flg & RI_CURSORCLIP) == 0)
#endif
- ri->ri_do_cursor(ri);
- } else
- ri->ri_flg &= ~RI_CURSOR;
+ if ((rc = ri->ri_do_cursor(ri)) != 0)
+ return rc;
+ ri->ri_flg |= RI_CURSOR;
+ }
+
+ return 0;
}
/*
@@ -834,7 +844,7 @@ rasops_unpack_attr(cookie, attr, fg, bg, underline)
/*
* Erase rows
*/
-void
+int
rasops_eraserows(cookie, row, num, attr)
void *cookie;
int row, num;
@@ -856,7 +866,7 @@ rasops_eraserows(cookie, row, num, attr)
num = ri->ri_rows - row;
if (num <= 0)
- return;
+ return 0;
#endif
clr = ri->ri_devcmap[(attr >> 16) & 0xf];
@@ -901,13 +911,15 @@ rasops_eraserows(cookie, row, num, attr)
DELTA(dp, delta, int32_t *);
}
+
+ return 0;
}
/*
* Actually turn the cursor on or off. This does the dirty work for
* rasops_cursor().
*/
-void
+int
rasops_do_cursor(ri)
struct rasops_info *ri;
{
@@ -973,12 +985,14 @@ rasops_do_cursor(ri)
*(int16_t *)dp ^= ~0;
}
}
+
+ return 0;
}
/*
* Erase columns.
*/
-void
+int
rasops_erasecols(cookie, row, col, num, attr)
void *cookie;
int row, col, num;
@@ -992,7 +1006,7 @@ rasops_erasecols(cookie, row, col, num, attr)
#ifdef RASOPS_CLIPPING
if ((unsigned)row >= (unsigned)ri->ri_rows)
- return;
+ return 0;
if (col < 0) {
num += col;
@@ -1003,7 +1017,7 @@ rasops_erasecols(cookie, row, col, num, attr)
num = ri->ri_cols - col;
if (num <= 0)
- return;
+ return 0;
#endif
num = num * ri->ri_xscale;
@@ -1052,7 +1066,7 @@ rasops_erasecols(cookie, row, col, num, attr)
}
}
- return;
+ return 0;
}
slop1 = (4 - ((long)rp & 3)) & 3;
@@ -1102,6 +1116,8 @@ rasops_erasecols(cookie, row, col, num, attr)
if (slop2 & 2)
*(int16_t *)dp = clr;
}
+
+ return 0;
}
#if NRASOPS_ROTATION > 0
@@ -1186,7 +1202,7 @@ rasops_copychar(cookie, srcrow, dstrow, srccol, dstcol)
}
}
-void
+int
rasops_putchar_rotated(cookie, row, col, uc, attr)
void *cookie;
int row, col;
@@ -1196,12 +1212,15 @@ rasops_putchar_rotated(cookie, row, col, uc, attr)
struct rasops_info *ri;
u_char *rp;
int height;
+ int rc;
ri = (struct rasops_info *)cookie;
/* Do rotated char sans (side)underline */
- ri->ri_real_ops.putchar(cookie, col, ri->ri_rows - row - 1, uc,
+ rc = ri->ri_real_ops.putchar(cookie, col, ri->ri_rows - row - 1, uc,
attr & ~1);
+ if (rc != 0)
+ return rc;
/* Do rotated underline */
rp = ri->ri_bits + col * ri->ri_yscale + (ri->ri_rows - row - 1) *
@@ -1217,9 +1236,11 @@ rasops_putchar_rotated(cookie, row, col, uc, attr)
rp += ri->ri_stride;
}
}
+
+ return 0;
}
-void
+int
rasops_erasecols_rotated(cookie, row, col, num, attr)
void *cookie;
int row, col, num;
@@ -1227,15 +1248,21 @@ rasops_erasecols_rotated(cookie, row, col, num, attr)
{
struct rasops_info *ri;
int i;
+ int rc;
ri = (struct rasops_info *)cookie;
- for (i = col; i < col + num; i++)
- ri->ri_ops.putchar(cookie, row, i, ' ', attr);
+ for (i = col; i < col + num; i++) {
+ rc = ri->ri_ops.putchar(cookie, row, i, ' ', attr);
+ if (rc != 0)
+ return rc;
+ }
+
+ return 0;
}
/* XXX: these could likely be optimised somewhat. */
-void
+int
rasops_copyrows_rotated(cookie, src, dst, num)
void *cookie;
int src, dst, num;
@@ -1243,34 +1270,42 @@ rasops_copyrows_rotated(cookie, src, dst, num)
struct rasops_info *ri = (struct rasops_info *)cookie;
int col, roff;
- if (src > dst)
+ if (src > dst) {
for (roff = 0; roff < num; roff++)
for (col = 0; col < ri->ri_cols; col++)
rasops_copychar(cookie, src + roff, dst + roff,
col, col);
- else
+ } else {
for (roff = num - 1; roff >= 0; roff--)
for (col = 0; col < ri->ri_cols; col++)
rasops_copychar(cookie, src + roff, dst + roff,
col, col);
+ }
+
+ return 0;
}
-void
+int
rasops_copycols_rotated(cookie, row, src, dst, num)
void *cookie;
int row, src, dst, num;
{
int coff;
- if (src > dst)
+ if (src > dst) {
for (coff = 0; coff < num; coff++)
- rasops_copychar(cookie, row, row, src + coff, dst + coff);
- else
+ rasops_copychar(cookie, row, row, src + coff,
+ dst + coff);
+ } else {
for (coff = num - 1; coff >= 0; coff--)
- rasops_copychar(cookie, row, row, src + coff, dst + coff);
+ rasops_copychar(cookie, row, row, src + coff,
+ dst + coff);
+ }
+
+ return 0;
}
-void
+int
rasops_eraserows_rotated(cookie, row, num, attr)
void *cookie;
int row, num;
@@ -1278,12 +1313,18 @@ rasops_eraserows_rotated(cookie, row, num, attr)
{
struct rasops_info *ri;
int col, rn;
+ int rc;
ri = (struct rasops_info *)cookie;
for (rn = row; rn < row + num; rn++)
- for (col = 0; col < ri->ri_cols; col++)
- ri->ri_ops.putchar(cookie, rn, col, ' ', attr);
+ for (col = 0; col < ri->ri_cols; col++) {
+ rc = ri->ri_ops.putchar(cookie, rn, col, ' ', attr);
+ if (rc != 0)
+ return rc;
+ }
+
+ return 0;
}
#endif /* NRASOPS_ROTATION */