From 9d051ffcdeef05ea06a0c7d9e24204792900779b Mon Sep 17 00:00:00 2001 From: Daniel Egger <egger@src.gnome.org> Date: Wed, 27 Sep 2000 17:36:52 +0000 Subject: [PATCH] Fix SPARC alignment problem. Fix by Jon Hazen. Bug #21269. Fix SPARC alignment problem. Fix by Jon Hazen. Bug #21269. --- ChangeLog | 5 +++ app/paint-funcs/paint-funcs.c | 66 +++++++++++++++++++++++++---------- app/paint_funcs.c | 66 +++++++++++++++++++++++++---------- 3 files changed, 101 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab336f8a7e..699b575928 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Sep 27 00:46:31 CEST 2000 Daniel Egger <egger@suse.de> + + * app/paint_funcs.c: Implemented suggested solution for + SPARC alignment problem by Jon Hazen. Fixes bug #21269. + Wed Sep 27 00:46:31 CEST 2000 Daniel Egger <egger@suse.de> * app/channel_ops.c: diff --git a/app/paint-funcs/paint-funcs.c b/app/paint-funcs/paint-funcs.c index e81a5addf7..f3b6faa217 100644 --- a/app/paint-funcs/paint-funcs.c +++ b/app/paint-funcs/paint-funcs.c @@ -477,9 +477,9 @@ paint_funcs_setup () } /* for (j = 0; j < 255; j++) */ -/* { //rows */ +/* { rows */ /* for (k = 0; k < 255; k++) */ -/* { //column */ +/* { column */ /* printf ("%d",add_lut[j][k]); */ /* printf(" "); */ /* } */ @@ -539,44 +539,74 @@ color_pixels (unsigned char *dest, Is this safe to assume? Lets find out. This is 4-7X as fast as the simple version. */ - register unsigned char c0, c1, c2; + register unsigned char c0, c1, c2, c3; + +#if !defined(sparc) && !defined(__sparc__) register guint32 *longd, longc; register guint16 *shortd, shortc; - +#endif /* !sparc && !__sparc__ */ + switch (bytes) { case 1: memset(dest, *color, w); break; + case 2: +#if defined(sparc) || defined(__sparc__) + c0 = color[0]; + c1 = color[1]; + while (w--) + { + dest[0] = c0; + dest[1] = c1; + dest += 2; + } +#else shortc = ((guint16 *)color)[0]; shortd = (guint16 *)dest; while (w--) - { - *shortd = shortc; - shortd++; - } + { + *shortd = shortc; + shortd++; + } +#endif /* sparc || __sparc__ */ break; case 3: c0 = color[0]; c1 = color[1]; c2 = color[2]; while (w--) - { - dest[0] = c0; - dest[1] = c1; - dest[2] = c2; - dest += 3; - } + { + dest[0] = c0; + dest[1] = c1; + dest[2] = c2; + dest += 3; + } break; case 4: +#if defined(sparc) || defined(__sparc__) + c0 = color[0]; + c1 = color[1]; + c2 = color[2]; + c3 = color[3]; + while (w--) + { + dest[0] = c0; + dest[1] = c1; + dest[2] = c2; + dest[3] = c3; + dest += 4; + } +#else longc = ((guint32 *)color)[0]; longd = (guint32 *)dest; while (w--) - { - *longd = longc; - longd++; - } + { + *longd = longc; + longd++; + } +#endif /* sparc || __sparc__ */ break; default: while (w--) diff --git a/app/paint_funcs.c b/app/paint_funcs.c index e81a5addf7..f3b6faa217 100644 --- a/app/paint_funcs.c +++ b/app/paint_funcs.c @@ -477,9 +477,9 @@ paint_funcs_setup () } /* for (j = 0; j < 255; j++) */ -/* { //rows */ +/* { rows */ /* for (k = 0; k < 255; k++) */ -/* { //column */ +/* { column */ /* printf ("%d",add_lut[j][k]); */ /* printf(" "); */ /* } */ @@ -539,44 +539,74 @@ color_pixels (unsigned char *dest, Is this safe to assume? Lets find out. This is 4-7X as fast as the simple version. */ - register unsigned char c0, c1, c2; + register unsigned char c0, c1, c2, c3; + +#if !defined(sparc) && !defined(__sparc__) register guint32 *longd, longc; register guint16 *shortd, shortc; - +#endif /* !sparc && !__sparc__ */ + switch (bytes) { case 1: memset(dest, *color, w); break; + case 2: +#if defined(sparc) || defined(__sparc__) + c0 = color[0]; + c1 = color[1]; + while (w--) + { + dest[0] = c0; + dest[1] = c1; + dest += 2; + } +#else shortc = ((guint16 *)color)[0]; shortd = (guint16 *)dest; while (w--) - { - *shortd = shortc; - shortd++; - } + { + *shortd = shortc; + shortd++; + } +#endif /* sparc || __sparc__ */ break; case 3: c0 = color[0]; c1 = color[1]; c2 = color[2]; while (w--) - { - dest[0] = c0; - dest[1] = c1; - dest[2] = c2; - dest += 3; - } + { + dest[0] = c0; + dest[1] = c1; + dest[2] = c2; + dest += 3; + } break; case 4: +#if defined(sparc) || defined(__sparc__) + c0 = color[0]; + c1 = color[1]; + c2 = color[2]; + c3 = color[3]; + while (w--) + { + dest[0] = c0; + dest[1] = c1; + dest[2] = c2; + dest[3] = c3; + dest += 4; + } +#else longc = ((guint32 *)color)[0]; longd = (guint32 *)dest; while (w--) - { - *longd = longc; - longd++; - } + { + *longd = longc; + longd++; + } +#endif /* sparc || __sparc__ */ break; default: while (w--)