Subject: GhostScript/FPE problems
To: None <port-mac68k@NetBSD.ORG>
From: None <ADAMGOOD@delphi.com>
List: port-mac68k
Date: 09/30/1997 07:45:47
From:	IN%"101564.312@compuserve.com"  "Norman Mackenzie" 30-SEP-1997 02:46:36.95
To:	IN%"ADAMGOOD@delphi.com"  "ADAMGOOD"
CC:	
Subj:	GhostScript/FPE problems

Return-path: <101564.312@compuserve.com>
 by delphi.com (PMDF V5.1-8 #23839)
 with ESMTP id <01IO8KRHS3M88YJEKQ@delphi.com> for ADAMGOOD@delphi.com; Tue,
 30 Sep 1997 02:43:34 EDT
 (8.8.6/8.8.6/2.5) id BAA10005 for ADAMGOOD@delphi.com; Tue,
 30 Sep 1997 01:55:14 -0400 (EDT)
Date: Tue, 30 Sep 1997 01:53:08 -0400
From: Norman Mackenzie <101564.312@compuserve.com>
Subject: GhostScript/FPE problems
To: ADAMGOOD <ADAMGOOD@delphi.com>
Message-id: <199709300155_MC2-2244-C9FA@compuserve.com>
MIME-version: 1.0
Content-type: text/plain; charset=us-ascii
Content-disposition: inline
Content-transfer-encoding: 7bit

Hi,

I've just seen your mails to the mac netbsd mailing list.  I don't
subscribe myself, I periodically download the archives, so you may already
have an answer.  Anyway...

I too have tried to get GhostScript running on an FPUless machine without
success.  The problem seems to be real.  I don't think the USE_FPU flag in
the makefile actually turns off FPU code generation, it just selects a
different routine for some multiplication stuff, so you'll have FPU code in
there anyway.  I tracked down one problem.  There is code to convert
between fixed and floating point numbers (in gxfixed.h?).  This calls for
multiplication by 4096 (really 1<<12), and this gets compiled into an
fscale (fscalel I think) instruction.  The emulation doesn't seem to work
so all your clip paths end up being 4096 times too small and being rounded
to zero size.  I fiddled a fix in one place by making the 4096 a variable
rather than a constant and got it to print lines OK, but no text. 
Presumably there are other places where similar things happen but I didn't
try to track them down.

Instead I tried to compile with the option -msoft-float to turn off FPU
code generation, but this required routines that aren't in the standard
libraries. I tracked down code for them, but they in turn required others
that I didn't seem to have, at which point I gave up.

The following innocent looking program (fscale.c) shows the problem on my
setup

#include <stdio.h>

int main(void)
{
  double f;
  long l;

  f = 1.0;
  l = 4096 * f;
  printf("%g %ld\n", f, l);

}

If I compile this with

    gcc fscale.c -o fscale

and run it, I get

    1 1

If I use

    gcc fscale.c -msoft-float -o fscalesoft

and run that, I get

    1 4096

as expected.

If you see the same problem with this program it is probably the reason why
GhostScript doesn't work for you.  The soft float method is probably more
promising if you can find the required libraries.  They're supposed to
exist for some embedded m68k targets.  Perhaps someone on the mailing list
could help you track them down.  Alternatively, maybe someone could look
into the emulation problem.

Good luck.

Norman