trq@moose.cita.utoronto.ca (Tom Quinn) (10/18/88)
The following code compiles incorrectly with the "-O
-finline-functions" flags. This is gcc version 1.30 on a Sun 3/50
running SunOS 3.5.
Tom Quinn Canadian Institute for Theoretical Astrophysics
trq@moose.cita.utoronto.ca
UUCP - decvax!utgpu!moose!trq
BITNET - quinn@utorphys.bitnet
ARPA - trq%moose.cita.toronto.edu@relay.cs.net
The offending assembler:
LBB6:
.stabd 68,0,54
fmoves fp0,d0
.stabd 68,0,56
fcmps d2,fp0 # d2 is never set before this point !!
fjnlt L95
movel d2,d0
jra L96
L95:
fmoves d0,fp2
fcmps d3,fp2 # same with d3 !!
fjngt L97
movel d3,d0
The compile:
gcc -g -v -S -O -finline-functions -c Scroll.c
gcc version 1.30
/usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 Scroll.c /tmp/cca02017.cpp
GNU CPP version 1.30
/usr/local/lib/gcc-cc1 /tmp/cca02017.cpp -quiet -dumpbase Scroll.c -finline-functions -g -O -version -o Scroll.s
GNU C version 1.30 (68k, MIT syntax) compiled by GNU C version 1.30.
The code:
------------------------------------------------------------------------
typedef struct {
struct _XDisplay *display;
} Screen;
typedef struct _XDisplay {
int fd;
} Display;
typedef struct {
int type;
int x, y;
} XKeyEvent;
typedef struct {
int type;
int x, y;
} XButtonEvent;
typedef struct {
int type;
int x, y;
} XMotionEvent;
typedef struct {
int type;
int x, y;
} XCrossingEvent;
typedef union _XEvent {
int type;
XKeyEvent xkey;
XButtonEvent xbutton;
XMotionEvent xmotion;
XCrossingEvent xcrossing;
} XEvent;
typedef struct _WidgetRec *Widget;
typedef char Boolean;
typedef int Position;
typedef unsigned int Dimension;
typedef struct _CorePart {
Screen *screen;
Position x, y;
Dimension width, height;
} CorePart;
typedef struct _WidgetRec {
CorePart core;
} WidgetRec;
typedef enum {XtorientHorizontal, XtorientVertical} XtOrientation;
typedef struct _ScrollbarRec *ScrollbarWidget;
typedef struct {
XtOrientation orientation;
float top;
char direction;
} ScrollbarPart;
typedef struct _ScrollbarRec {
CorePart core;
ScrollbarPart scrollbar;
} ScrollbarRec;
static float FloatInRange(num, small, big)
float num, small, big;
{
return (num < small) ? small : ((num > big) ? big : num);
}
static float FractionLoc(w, x, y)
ScrollbarWidget w;
int x, y;
{
float result;
result = ((w->scrollbar.orientation == XtorientHorizontal) ? (float) x/w->core.width :
(float) y/w->core.height) ;
return FloatInRange(result, 0.0, 1.0);
}
static void ExtractPosition( event, x, y )
XEvent *event;
int *x, *y;
{
switch( event->type ) {
case 6 :
*x = event->xmotion.x; *y = event->xmotion.y; break;
case 4 :
case 5 :
*x = event->xbutton.x; *y = event->xbutton.y; break;
case 2 :
case 3 :
*x = event->xkey.x; *y = event->xkey.y; break;
case 7 :
case 8 :
*x = event->xcrossing.x; *y = event->xcrossing.y; break;
default:
*x = 0; *y = 0;
}
}
void MoveThumb( gw, event, params, num_params )
Widget gw;
XEvent *event;
{
ScrollbarWidget w = (ScrollbarWidget) gw;
Position x, y;
if (w->scrollbar.direction == 0) return;
ExtractPosition( event, &x, &y );
w->scrollbar.top = FractionLoc(w, x, y);
PaintThumb(w);
XFlush(((w)->core.screen->display) );
}trq@moose.cita.utoronto.ca (Tom Quinn) (10/19/88)
The following code prints "65135" instead of the expected "401" when
compiled with the "-O" flag. The problem is at line 72: the shorts
are not signed extended before subtracting and stored in the int "adx".
This gcc version 1.30 on a Sun 3/50 running SunOS 3.5.
Tom Quinn Canadian Institute for Theoretical Astrophysics
trq@moose.cita.utoronto.ca
UUCP - decvax!utgpu!moose!trq
BITNET - quinn@utorphys.bitnet
ARPA - trq%moose.cita.toronto.edu@relay.cs.net
The compile:
gcc -g -v -O -c mfbline.c
gcc version 1.30
/usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 mfbline.c /tmp/cca02948.cpp
GNU CPP version 1.30
/usr/local/lib/gcc-cc1 /tmp/cca02948.cpp -quiet -dumpbase mfbline.c -g -O -version -o /tmp/cca02948.s
GNU C version 1.30 (68k, MIT syntax) compiled by GNU C version 1.30.
as -mc68020 /tmp/cca02948.s -o mfbline.o
gcc -v mfbline.o
gcc version 1.30
ld /lib/crt0.o /lib/Mcrt1.o mfbline.o /usr/local/lib/gcc-gnulib -lc
150}a.out
65135
The code:
------------------------------------------------------------------------
typedef struct _DDXPoint *DDXPointPtr;
typedef struct _Box *BoxPtr;
typedef struct _DDXPoint {
short x, y;
} DDXPointRec;
typedef struct _Box {
short x1, y1, x2, y2;
} BoxRec;
main()
{
DDXPointPtr ptinit;
ptinit = (DDXPointPtr) malloc(2*sizeof(DDXPointRec));
ptinit[0].x = -1;
ptinit[1].x = 400;
ptinit[0].y = 400;
ptinit[1].y = 900;
mfbLineSS(0, 2, ptinit);
}
mfbLineSS( mode, npt, pptInit)
int mode;
int npt;
DDXPointPtr pptInit;
{
int nboxInit;
register int nbox;
BoxPtr pboxInit;
register BoxPtr pbox;
int nptTmp;
DDXPointPtr ppt;
DDXPointRec pt1;
DDXPointRec pt2;
int xorg, yorg;
int adx;
int ady;
int signdx;
int signdy;
int e, e1, e2;
int axis;
DDXPointRec pt1Orig;
DDXPointRec pt2Orig;
xorg = yorg = 0;
ppt = pptInit;
nptTmp = npt;
if (mode == 0 )
{
while(nptTmp--)
{
ppt->x += xorg;
ppt++->y += yorg;
}
}
else
{
ppt->x += xorg;
ppt->y += yorg;
nptTmp--;
while(nptTmp--)
{
ppt++;
ppt->x += (ppt-1)->x;
ppt->y += (ppt-1)->y;
}
}
ppt = pptInit;
while(--npt)
{
nbox = nboxInit;
pbox = pboxInit;
pt1 = *ppt++;
pt2 = *ppt;
{
adx = pt2.x - pt1.x;
ady = pt2.y - pt1.y;
signdx = ((adx) < 0 ? -1 : ((adx) > 0 ? 1 : 0)) ;
signdy = ((ady) < 0 ? -1 : ((ady) > 0 ? 1 : 0)) ;
adx = ((adx) > 0 ? (adx) : -(adx)) ;
ady = ((ady) > 0 ? (ady) : -(ady)) ;
if (adx > ady)
{
axis = 0 ;
e1 = ady*2;
e2 = e1 - 2*adx;
e = e1 - adx;
}
else
{
axis = 1 ;
e1 = adx*2;
e2 = e1 - 2*ady;
e = e1 - ady;
}
pt1Orig = pt1;
pt2Orig = pt2;
printf("%d\n", adx);
}
}
}trq@moose.cita.utoronto.ca (Tom Quinn) (11/04/88)
The following code is compiled in correctly with the "-O
-fstrength-reduce" flags. This is gcc version 1.30 on a Sun 3/50
running SunOS 3.5.
The offending assembler is setting up a for loop:
L28:
.stabd 68,0,135
movel a6,d1
addl #-304,d1
movel d1,a6@(-316)
movel a6,d1
addl #-288,d1
movel d1,a6@(-320)
movel a6,d1
addl #-256,d1
movel d1,a6@(-324)
moveq #-32,d1
addl a6,d1
movel d1,a6@(-328)
moveq #-16,d1
addl a6,d1
movel d1,a6@(-332)
movel a6@(32),d4
negl d4
movel a6@(28),d3
negl d3
moveq #-64,d5
addl a6,d5
moveq #16,d1
addl d5,d1
movel d1,a6@(-336)
moveq #16,d6
lea a5@(16),a3
mulsl d6,d7 # d7 is not set before it is used here!!!!
movel d7,a6@(-340)
clrl d1
addl d1,a6@(-340)
jra L34
Tom Quinn Canadian Institute for Theoretical Astrophysics
trq@moose.cita.utoronto.ca
UUCP - decvax!utgpu!moose!trq
BITNET - quinn@utorphys.bitnet
ARPA - trq%moose.cita.toronto.edu@relay.cs.net
The compile:
gcc -S -g -v -O -fstrength-reduce -c milines.c
gcc version 1.30
/usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 milines.c /tmp/cca06828.cpp
GNU CPP version 1.30
/usr/local/lib/gcc-cc1 /tmp/cca06828.cpp -quiet -dumpbase milines.c -fstrength-reduce -g -O -version -o milines.s
GNU C version 1.30 (68k, MIT syntax) compiled by GNU C version 1.30.
The code:
------------------------------------------------------------------------
typedef struct _DrawInfo *DrawablePtr;
typedef struct _DrawInfo {
short type;
int depth;
unsigned long serialNumber;
} DrawableRec;
typedef struct _GC *GCPtr;
typedef struct _GC{
int lineWidth;
int lineStyle;
int capStyle;
int joinStyle;
} GC;
typedef struct _SppPoint {
double x, y;
} SppPointRec, *SppPointPtr;
extern SppPointRec miExtendSegment();
extern void miGetPts(), miRoundCap(), miOneSegWide();
static SppPointRec IntersectLines();
void
miMiter (pDraw, pGC, caps, npt, pPts, xOrg, yOrg)
DrawablePtr pDraw;
GCPtr pGC;
int caps;
int npt;
SppPointPtr pPts;
int xOrg, yOrg;
{
int width = (pGC->lineWidth ? pGC->lineWidth : 1);
SppPointRec PolyPoints[4], FirstEdge[3], Wedge[4];
SppPointRec p1, p2, p3, p4, p5, p6, p7, p8;
int edges_match, i,
capStyle = pGC->capStyle;
if(npt <= 2)
{
miOneSegWide(pDraw, pGC, npt, pPts, caps, xOrg, yOrg);
return;
}
miGetPts(pPts[0], pPts[1], &p1, &p2, &p3, &p4, width);
if ((((((pPts[0].x) - ( pPts[npt-1].x)) > 0.0 ? ((pPts[0].x) - ( pPts[npt-1].x)) : -((pPts[0].x) - ( pPts[npt-1].x))) <= 0.000001 ) && ((((pPts[0].y) - ( pPts[npt-1].y)) > 0.0 ? ((pPts[0].y) - ( pPts[npt-1].y)) : -((pPts[0].y) - ( pPts[npt-1].y))) <= 0.000001 ) ) )
{
edges_match = 1;
miGetPts(pPts[npt-2], pPts[npt-1], &p5, &p6, &p7, &p8, width);
PolyPoints[2] = IntersectLines(p3, p4, p7, p8);
PolyPoints[3] = IntersectLines(p6, p5, p1, p2);
if ((((PolyPoints[2]).x-( PolyPoints[3]).x)*((PolyPoints[2]).x-( PolyPoints[3]).x)+((PolyPoints[2]).y-( PolyPoints[3]).y)*((PolyPoints[2]).y-( PolyPoints[3]).y)) >
108.856472512142 * width * width)
{
if ((((p5).x-( pPts[0]).x)*((p5).x-( pPts[0]).x)+((p5).y-( pPts[0]).y)*((p5).y-( pPts[0]).y)) - (((PolyPoints[3]).x-( pPts[0]).x)*((PolyPoints[3]).x-( pPts[0]).x)+((PolyPoints[3]).y-( pPts[0]).y)*((PolyPoints[3]).y-( pPts[0]).y))
< 0.000001 )
{
FirstEdge[2] = pPts[0];
if ((((( pPts[0]).x - ( pPts[npt-2]).x) * (( pPts[1] ).y - ( pPts[0]).y) - (( pPts[1] ).x - ( pPts[0]).x) * (( pPts[0]).y - ( pPts[npt-2]).y)) > 0) )
{
FirstEdge[0] = p4;
FirstEdge[1] = p7;
miFillSppPoly(pDraw, pGC, 3, FirstEdge, -xOrg, -yOrg, 0.0, 0.0);
FirstEdge[0] = p6;
} else {
FirstEdge[0] = p6;
FirstEdge[1] = p1;
miFillSppPoly(pDraw, pGC, 3, FirstEdge, -xOrg, -yOrg, 0.0, 0.0);
FirstEdge[1] = p7;
}
PolyPoints[2] = p4;
PolyPoints[3] = p1;
} else {
if ((((( pPts[0]).x - ( pPts[npt-2]).x) * (( pPts[1] ).y - ( pPts[0]).y) - (( pPts[1] ).x - ( pPts[0]).x) * (( pPts[0]).y - ( pPts[npt-2]).y)) > 0) )
{
FirstEdge[0] = PolyPoints[3];
FirstEdge[1] = p7;
FirstEdge[2] = p4;
PolyPoints[2] = p4;
} else {
FirstEdge[0] = p6;
FirstEdge[1] = PolyPoints[2];
FirstEdge[2] = p1;
PolyPoints[3] = p1;
}
miFillSppPoly(pDraw, pGC, 3, FirstEdge, -xOrg, -yOrg, 0.0, 0.0);
}
} else {
if ((((p5).x-( pPts[0]).x)*((p5).x-( pPts[0]).x)+((p5).y-( pPts[0]).y)*((p5).y-( pPts[0]).y)) - (((PolyPoints[3]).x-( pPts[0]).x)*((PolyPoints[3]).x-( pPts[0]).x)+((PolyPoints[3]).y-( pPts[0]).y)*((PolyPoints[3]).y-( pPts[0]).y))
< 0.000001 )
{
if ((((((PolyPoints[3].x) - ( p5.x)) > 0.0 ? ((PolyPoints[3].x) - ( p5.x)) : -((PolyPoints[3].x) - ( p5.x))) <= 0.000001 ) && ((((PolyPoints[3].y) - ( p5.y)) > 0.0 ? ((PolyPoints[3].y) - ( p5.y)) : -((PolyPoints[3].y) - ( p5.y))) <= 0.000001 ) ) )
{
FirstEdge[0] = p6;
FirstEdge[1] = p7;
PolyPoints[3] = p1;
} else {
if ((((( pPts[0]).x - ( pPts[npt-2]).x) * (( pPts[1] ).y - ( pPts[0]).y) - (( pPts[1] ).x - ( pPts[0]).x) * (( pPts[0]).y - ( pPts[npt-2]).y)) > 0) )
{
Wedge[0] = p4;
Wedge[2] = p7;
Wedge[3] = PolyPoints[2];
} else {
Wedge[0] = p6;
Wedge[2] = p1;
Wedge[3] = PolyPoints[3];
}
Wedge[1] = pPts[0];
miFillSppPoly(pDraw, pGC, 4, Wedge, -xOrg, -yOrg, 0.0, 0.0);
FirstEdge[1] = p7;
FirstEdge[0] = p6;
PolyPoints[3] = p1;
PolyPoints[2] = p4;
}
} else {
FirstEdge[0] = PolyPoints[3];
FirstEdge[1] = PolyPoints[2];
}
}
}
else
{
edges_match = 0;
if (caps && capStyle == 3 )
{
pPts[0] = miExtendSegment(pPts[0], pPts[1], width/2);
miGetPts(pPts[0], pPts[1], &p1, &p2, &p3, &p4, width);
pPts[npt-1] = miExtendSegment(pPts[npt-1], pPts[npt-2], width/2);
}
else if (caps && capStyle == 2 )
{
miRoundCap(pDraw, pGC, pPts[0], pPts[1], p4, p1, 1 ,
xOrg, yOrg, 0.0, 0.0);
miGetPts(pPts[npt-1], pPts[npt-2], &p5, &p6, &p7, &p8, width);
miRoundCap(pDraw, pGC, pPts[npt-1], pPts[npt-2], p8, p5, 1 ,
xOrg, yOrg, 0.0, 0.0);
}
PolyPoints[3] = p1;
PolyPoints[2] = p4;
}
for (i = 1; i < (npt - 1); i++)
{
miGetPts(pPts[i], pPts[i+1], &p5, &p6, &p7, &p8, width);
PolyPoints[0] = PolyPoints[3];
PolyPoints[1] = PolyPoints[2];
PolyPoints[2] = IntersectLines(p4, p3, p7, p8);
PolyPoints[3] = IntersectLines(p2, p1, p5, p6);
if ((((PolyPoints[2]).x-( PolyPoints[3]).x)*((PolyPoints[2]).x-( PolyPoints[3]).x)+((PolyPoints[2]).y-( PolyPoints[3]).y)*((PolyPoints[2]).y-( PolyPoints[3]).y)) >
108.856472512142 * width * width)
{
if ((((p1).x-( pPts[i]).x)*((p1).x-( pPts[i]).x)+((p1).y-( pPts[i]).y)*((p1).y-( pPts[i]).y)) - (((PolyPoints[3]).x-( pPts[i]).x)*((PolyPoints[3]).x-( pPts[i]).x)+((PolyPoints[3]).y-( pPts[i]).y)*((PolyPoints[3]).y-( pPts[i]).y))
< 0.000001 )
{
PolyPoints[2] = p3;
PolyPoints[3] = p2;
miFillSppPoly(pDraw, pGC, 4, PolyPoints, -xOrg, -yOrg, 0.0, 0.0);
if ((((( pPts[i]).x - ( pPts[i-1]).x) * (( pPts[i+1] ).y - ( pPts[i]).y) - (( pPts[i+1] ).x - ( pPts[i]).x) * (( pPts[i]).y - ( pPts[i-1]).y)) > 0) )
{
PolyPoints[1] = p8;
PolyPoints[3] = pPts[i];
miFillSppPoly(pDraw, pGC, 3, &PolyPoints[1], -xOrg, -yOrg, 0.0, 0.0);
} else {
PolyPoints[1] = p5;
PolyPoints[2] = pPts[i];
miFillSppPoly(pDraw, pGC, 3, &PolyPoints[1], -xOrg, -yOrg, 0.0, 0.0);
}
PolyPoints[2] = p8;
PolyPoints[3] = p5;
} else {
if ((((( pPts[i]).x - ( pPts[i-1]).x) * (( pPts[i+1] ).y - ( pPts[i]).y) - (( pPts[i+1] ).x - ( pPts[i]).x) * (( pPts[i]).y - ( pPts[i-1]).y)) > 0) )
{
PolyPoints[2] = p3;
miFillSppPoly(pDraw, pGC, 4, PolyPoints, -xOrg, -yOrg, 0.0, 0.0);
PolyPoints[1] = p8;
miFillSppPoly(pDraw, pGC, 3, &PolyPoints[1], -xOrg, -yOrg, 0.0, 0.0);
PolyPoints[2] = p8;
} else {
PolyPoints[3] = p2;
miFillSppPoly(pDraw, pGC, 4, PolyPoints, -xOrg, -yOrg, 0.0, 0.0);
PolyPoints[1] = p5;
miFillSppPoly(pDraw, pGC, 3, &PolyPoints[1], -xOrg, -yOrg, 0.0, 0.0);
PolyPoints[3] = p5;
}
}
} else {
if ((((p1).x-( pPts[i]).x)*((p1).x-( pPts[i]).x)+((p1).y-( pPts[i]).y)*((p1).y-( pPts[i]).y)) - (((PolyPoints[3]).x-( pPts[i]).x)*((PolyPoints[3]).x-( pPts[i]).x)+((PolyPoints[3]).y-( pPts[i]).y)*((PolyPoints[3]).y-( pPts[i]).y))
< 0.000001 )
{
if ((((((PolyPoints[3].x) - ( p1.x)) > 0.0 ? ((PolyPoints[3].x) - ( p1.x)) : -((PolyPoints[3].x) - ( p1.x))) <= 0.000001 ) && ((((PolyPoints[3].y) - ( p1.y)) > 0.0 ? ((PolyPoints[3].y) - ( p1.y)) : -((PolyPoints[3].y) - ( p1.y))) <= 0.000001 ) ) )
{
PolyPoints[3] = p2;
miFillSppPoly(pDraw, pGC, 4, PolyPoints, -xOrg, -yOrg, 0.0, 0.0);
PolyPoints[3] = p5;
PolyPoints[2] = p8;
} else {
if ((((( pPts[i]).x - ( pPts[i-1]).x) * (( pPts[i+1] ).y - ( pPts[i]).y) - (( pPts[i+1] ).x - ( pPts[i]).x) * (( pPts[i]).y - ( pPts[i-1]).y)) > 0) )
{
Wedge[0] = p8;
Wedge[2] = p3;
Wedge[3] = PolyPoints[2];
} else {
Wedge[0] = p2;
Wedge[2] = p5;
Wedge[3] = PolyPoints[3];
}
Wedge[1] = pPts[i];
miFillSppPoly(pDraw, pGC, 4, Wedge, -xOrg, -yOrg, 0.0, 0.0);
PolyPoints[2] = p3;
PolyPoints[3] = p2;
miFillSppPoly(pDraw, pGC, 4, PolyPoints, -xOrg, -yOrg, 0.0, 0.0);
PolyPoints[3] = p5;
PolyPoints[2] = p8;
}
} else
miFillSppPoly(pDraw, pGC, 4, PolyPoints, -xOrg, -yOrg, 0.0, 0.0);
}
p1 = p5; p2 = p6; p3 = p7; p4 = p8;
}
PolyPoints[0] = PolyPoints[3];
PolyPoints[1] = PolyPoints[2];
if (edges_match)
{
PolyPoints[2] = FirstEdge[1];
PolyPoints[3] = FirstEdge[0];
}
else
{
miGetPts(pPts[npt-2], pPts[npt-1], &p5, &p6, &p7, &p8, width);
PolyPoints[2] = p7;
PolyPoints[3] = p6;
}
miFillSppPoly(pDraw, pGC, 4, PolyPoints, -xOrg, -yOrg, 0.0, 0.0);
}trq@moose.cita.utoronto.ca (Tom Quinn) (11/07/88)
The following code causes gcc to get a fatal signal when compiled with
the -O option. This is gcc v1.30 on a Sun 3/50 running SunOs 3.5.
Tom Quinn Canadian Institute for Theoretical Astrophysics
trq@moose.cita.utoronto.ca
UUCP - decvax!utgpu!moose!trq
BITNET - quinn@utorphys.bitnet
ARPA - trq%moose.cita.toronto.edu@relay.cs.net
The compile:
gcc -g -v -O -c mifpolycon.c
gcc version 1.30
/usr/local/lib/gcc-cpp -v -undef -D__GNU__ -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 mifpolycon.c /tmp/cca08664.cpp
GNU CPP version 1.30
/usr/local/lib/gcc-cc1 /tmp/cca08664.cpp -quiet -dumpbase mifpolycon.c -g -O -version -o /tmp/cca08664.s
GNU C version 1.30 (68k, MIT syntax) compiled by GNU C version 1.30.
gcc: Program cc1 got fatal signal 6.
The code:
------------------------------------------------------------------------
typedef struct _GC *GCPtr;
char *alloca();
typedef struct _DDXPoint *DDXPointPtr;
typedef struct _DDXPoint {
short x, y;
} DDXPointRec;
typedef struct _DrawInfo *DrawablePtr;
typedef struct _GC{
int miTranslate:1;
void (* FillSpans)();
} GC;
typedef struct _Window *WindowPtr;
typedef struct _DrawInfo {
short type;
} DrawableRec;
typedef struct _Window {
DDXPointRec absCorner;
} WindowRec;
typedef struct _SppPoint {
double x, y;
} SppPointRec, *SppPointPtr;
static int GetFPolyYBounds();
void
miFillSppPoly(dst, pgc, count, ptsIn, xTrans, yTrans, xFtrans, yFtrans)
DrawablePtr dst;
GCPtr pgc;
int count;
SppPointPtr ptsIn;
int xTrans, yTrans;
double xFtrans, yFtrans;
{
double xl, xr, ml, mr, dy, i;
int y, j, imin, ymin, ymax, *width, *FirstWidth, *Marked;
register int left, right, nextleft, nextright;
DDXPointPtr ptsOut,
FirstPoint;
if (pgc->miTranslate && (dst->type == 0 ) )
{
xTrans += ((WindowPtr)dst)->absCorner.x;
yTrans += ((WindowPtr)dst)->absCorner.y;
}
imin = GetFPolyYBounds(ptsIn, count, yFtrans, &ymin, &ymax);
y = ymax - ymin + 1;
ptsOut = FirstPoint = (DDXPointPtr)alloca((int)(sizeof(DDXPointRec) * y)) ;
width = FirstWidth = (int *) alloca((int)(sizeof(int) * y)) ;
Marked = (int *) alloca((int)(sizeof(int) * count)) ;
if(!ptsOut || !width || !Marked || (count < 3) || (y <= 0))
{
;
;
;
return;
}
for(j = 0; j < count; j++)
Marked[j] = 0;
nextleft = nextright = imin;
Marked[imin] = -1;
y = (int) ({ double __value, __arg = (ptsIn[nextleft].y + yFtrans); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; }) ;
do
{
if ((y > (ptsIn[nextleft].y + yFtrans) ||
((((y) - ( ptsIn[nextleft].y + yFtrans)) > 0.0 ? ((y) - ( ptsIn[nextleft].y + yFtrans)) : -((y) - ( ptsIn[nextleft].y + yFtrans))) <= 0.000001 ) ) &&
Marked[nextleft] != 1)
{
Marked[nextleft]++;
left = nextleft++;
if (nextleft >= count)
nextleft = 0;
dy = ptsIn[nextleft].y - ptsIn[left].y;
if (dy != 0.0)
{
ml = (ptsIn[nextleft].x - ptsIn[left].x) / dy;
dy = y - (ptsIn[left].y + yFtrans);
xl = (ptsIn[left].x + xFtrans) + ml * (((dy) > ( 0)) ? (dy) : ( 0)) ;
}
}
if ((y > ptsIn[nextright].y + yFtrans) ||
((((y) - ( ptsIn[nextright].y + yFtrans)) > 0.0 ? ((y) - ( ptsIn[nextright].y + yFtrans)) : -((y) - ( ptsIn[nextright].y + yFtrans))) <= 0.000001 )
&& Marked[nextright] != 1)
{
Marked[nextright]++;
right = nextright--;
if (nextright < 0)
nextright = count - 1;
dy = ptsIn[nextright].y - ptsIn[right].y;
if (dy != 0.0)
{
mr = (ptsIn[nextright].x - ptsIn[right].x) / dy;
dy = y - (ptsIn[right].y + yFtrans);
xr = (ptsIn[right].x + xFtrans) + mr * (((dy) > ( 0)) ? (dy) : ( 0)) ;
}
}
i = ((((ptsIn[nextleft].y) < ( ptsIn[nextright].y)) ? (ptsIn[nextleft].y) : ( ptsIn[nextright].y)) + yFtrans) - y;
if (i < 0.000001 )
{
if(Marked[nextleft] && Marked[nextright])
{
break;
}
continue;
}
else
{
j = (int) i;
if(!j)
j++;
}
while (j > 0)
{
ptsOut->y = (y) + yTrans;
if (xl < xr)
{
*(width++) = ({ double __value, __arg = (xr); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; }) - ({ double __value, __arg = (xl); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; }) ;
(ptsOut++)->x = ({ double __value, __arg = (xl); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; }) + xTrans;
}
else
{
*(width++) = ({ double __value, __arg = (xl); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; }) - ({ double __value, __arg = (xr); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; }) ;
(ptsOut++)->x = ({ double __value, __arg = (xr); int __fpcr; asm ("fmovel fpcr, %0": "=dm" (__fpcr)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" ((__fpcr & 0xffffffcf) | 0x30)); asm ("fintx %1, %0": "=f" (__value): "f" (__arg)); asm volatile ("fmovel %1, fpcr": "=m" (*(char *)0): "dm" (__fpcr)); __value; }) + xTrans;
}
y++;
xl += ml;
xr += mr;
j--;
}
} while (y <= ymax);
(*pgc->FillSpans)(dst, pgc,
ptsOut-FirstPoint, FirstPoint, FirstWidth, 1);
}