[comp.windows.x] Porting X windows to Pyramid

marquez@stdoil.uucp (Manlio D. Marquez) (08/10/87)

Symptom:
When trying to install X windows V10R4 on a Pyramid 98x, programs that should
draw boxes instead draw garbage lines.

Cause:
X saves the vertices for line drawing in arrays of the structure Vertex

	 typedef struct _Vertex {
		 short x, y;
		 unsigned short flags;
	 } Vertex;

The Pyramid forces each array member to start on an integer (4 byte)
boundary with a 2 bytes filler between each element.  X uses a bcopy to
pack the data to be send to the server.  This causes the vertex array to
become skewed at the server end with filler bytes (zeros) being
interpreted as data.

Cure:
The routines that use Vertices (XDraw.c, XDrawDashed.c, XDrawFilled.c,
XDrawPatternd.c, XDrawTiled.c) should be changed to use a new routine
PackVert instead of PackData as follows:

(patch is for XDraw.c, others are similar)

25a26
> #ifndef PYRAMID
27a29,31
> #else
> 	PackVert(dpy, vlist, vcount);
> #endif

Change Xlib/XlibInternal.h as follows:

87c87,89
< 
---
> #ifndef PYRAMID
> #define PackVert	PackData
> #endif


Change Xlib/XlibInternal.c as follows:

397a398,417
> 
> #ifdef PYRAMID
> PackVert(dpy,vert,vcount)
> Display *dpy;
> Vertex *vert;
> int vcount;
> {
> 	register int j;
> 	register unsigned short *s = (unsigned short *)dpy->bufptr;
> 
> 	for(j = 0; j < vcount; j++) {
> 		*s++ = vert[j].x;
> 		*s++ = vert[j].y;
> 		*s++ = vert[j].flags;
> 	}
> 	dpy->bufptr = (char *)s;
> 	dpy->bufptr += 3;		/* pad */
> 	dpy->bufptr = (char *)((int)dpy->bufptr & ~3);
> }
> #endif

Make sure that PYRAMID is defined somewhere in the programs.

Similar changes may have to be made for version 11 of X windows.

Manlio D. Marquez
Standard Oil Production Company
(214)701-4027

(convex, texsun, smu, jlsoft)!stdoil!marquez

chris@pyrps5 (Chris Guthrie) (08/13/87)

I'm working on X for Pyramid so I thought I'd give some information
and a quick note about my solution to the XDraw bug.  

I've spent the last week bringing up most of the X10R4 stuff under
Pyramid's OSx 4.0 system.  I hope to have an unsupported release ready
in about a week which will contain most of the main X sources and
some contributed software.  This will be for the Pyramid client end.
It won't include code for any of the servers (although I'm using a
Sun 3/50).  For more information about the release you should
give me a call.  My phone number is below.

I'd also like to set up a mailing list here for sites running X on
their Pyramids.  I hope this can allow some discussions about problems
and directions for X10 and X11 on the Pyramids.  Please drop me a line
if you want to be added.  See below for my net address.

Finally some information about porting X to the Pyramid.  The standard
C compiler pads structures which contain shorts and chars so that it
remains on a four-byte boundary.  This causes problems with the X
protocol since vertices are three shorts and four get sent.

The solution I arrived at was to compile all the X source using the
'-q' flag which prevents the extra padding.  This seems to have worked
for everything but xterm.  In xterm's main.c there is an ioctl to grab
the current tty chars (TIOCGETC).  Unfortunately, the tchar structure
is padded in libc and the kernel, but not in xterm when the -q flag is
used.  I seem to have gotten around this by compiling main.o without
the -q flag and everything else with it.  So far I haven't found
any other problems.  This seems to be the simplest way to compile it
without changing code.

	 Chris

Chris Guthrie  {allegra,cmcl2,decwrl,hplabs,ut-sally,utzoo}!pyramid!chris
Pyramid Technology Corp, Mountain View, CA  +1 415 965 7200

bejc@pyrltd.UUCP (Brian Clark) (08/14/87)

Summary:

Expires:

Sender:

Followup-To:

Distribution:


To followup on the recent messages about structure alignment on the Pyramid.
As has been noted all structures are aligned to a four byte boundary and are
padded out to 32 bits. Where code is used of the form :

        j= sizeof(structure);

then use of the value returned in j can give unexpected results. One way around
this is to always give the exact value for j.

The second way that has been suggested is to use the "-q" option to the C
compiler. This enforces a more Vax-like packing of structures and functions
such as "sizeof" will return the correct value.

The first trade-off in using this option is a loss in performance - word
aligned structures are far easier and quicker to fetch.  The second trade-off
is that none of the standard libraries have been compiled with the "-q"
options and so calls that pass structures are potentially going to fail.  It
is necessary to remake the whole system with the different libraries and from
that point on use only the "-q" option.  This path has been taken, and has
worked successfully at a Pyramid site in the UK, where a huge amount of code
had to be ported.  If only a single program or set of programs is involved it
is perhaps worth taking the time to convert those parts where the structure
boundary/size is giving problems.
-- 
      -m-------  Brian E.J. Clark	Phone : +44 276 63474
    ---mmm-----  Pyramid Technology Ltd Fax   : +44 276 685189
  -----mmmmm---                         Telex : 859056 PYRUK G
-------mmmmmmm-  			UUCP  : <england>!pyrltd!bejc