Article View: gnu.ghostscript.bug
Article #438Re: Unaligned access errors in mem_get_bits()
From: L. Peter Deutsch
Date: Mon, 28 Sep 1992 17:09
Date: Mon, 28 Sep 1992 17:09
45 lines
2212 bytes
2212 bytes
Re <9209280153.AA03358@cookie-crisp>
<BRIAN.92Sep25145844@kokom.mit.edu>:
> I am getting "unaligned access errors" from gs. I have traced the
> problem to the function mem_get_bits().
> [... a correct analysis of the problem, with the ln03 driver...]
>
> I do not get the errors if I specify the laserjet driver, or use an X
> window for display. However, I don't see anything in
> gdev_prn_copy_scan_lines() that allows it to change behavior (pad the
> bytes_per_line) based on the output device.
You're right. Drivers that copy more than one scan line at a time,
on machines that can't do unaligned accesses, will get unaligned
access errors.
The simplest thing to do is rewrite memswab2 so it only does byte
accesses. This will slow it down, but eliminate the problem.
void
memswab2(const byte *src, byte *dest, int count)
{ register const byte *sptr = src;
register byte *dptr = dest;
register int x;
for ( x = count >> 1; --x >= 0; sptr += 2, dptr += 2 )
{ register byte t = sptr[0];
dptr[0] = sptr[1];
dptr[1] = t;
}
}
You can obviously speed this routine up by unrolling the loop.
As it happens, the next release of Ghostscript will eliminate the
need for byte swapping entirely.
> As far as I can recall, gs2.4.1 did not exhibit this problem, and
> gs2.5 did.
Sigh. I don't remember getting a bug report about this from 2.5,
since if I had, it would have been fixed by 2.5.2.
L. Peter Deutsch :: Aladdin Enterprises :: P.O. box 60264, Palo Alto, CA 94306
ghost@aladdin.com, ...decwrl!aladdin!ghost ; voice 415-322-0103 ; fax 322-1734
"Implementation is the sincerest form of flattery." new--->^^^^^^^^^^^^
Technical Details
Message-ID:
<9209281009.1.UUL1.3#5127@aladdin.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!aladdin.COM!ghostReferences:
ghost@aladdin.COM (L. Peter Deutsch)Show Full Headers
Complete Article Headers
Newsgroups: gnu.ghostscript.bug Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!aladdin.COM!ghost From: ghost@aladdin.COM (L. Peter Deutsch) Subject: Re: Unaligned access errors in mem_get_bits() Message-ID: <9209281009.1.UUL1.3#5127@aladdin.com> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet References: ghost@aladdin.COM (L. Peter Deutsch) Distribution: gnu Date: Mon, 28 Sep 1992 17:09:36 GMT Approved: bug-ghostscript@prep.ai.mit.edu Lines: 49