[comp.realtime] Xlib on VxWorks

lewin@batman.uucp (Stu Lewin) (01/09/90)

Has anyone out there tried (and succeeded) in getting Xlib from X11 up
and running under VxWorks? I tried a quick compile and link of the
hello_world program, and have several unresolved symbols from the UNIX
standard IO library. I figured before I spent any more time on this
I'd see if anyone could point me in the right direction from the
start. Thanks!
--
Stu Lewin                                        Sanders Associates, Inc.
Member, Technical Staff                          PO Box 2034, MER24-1583C
Digital Signal Processing Center of Technology   Nashua, NH 03061-2034
                                                 603/885-0179

                 e-mail:
                      @uunet.uu.net:lewin@rocket.uucp
                 (or) ..!uunet!rocket!lewin
                 (or) ..!decvax!savax!rocket!lewin

bob@jupiter.UUCP (Bob Schulman) (01/11/90)

From article <LEWIN.90Jan9103553@batman.uucp>, by lewin@batman.uucp (Stu Lewin):
> Has anyone out there tried (and succeeded) in getting Xlib from X11 up
> and running under VxWorks?

I have just sent sources for such a beast to the vxWorks archives maintained
at NCAR. I hope that the sources will be available soon. You find out what's
available at the NCAR archives by sending mail to netlib@thor.ucar.edu
with the body of the messaage consisting the text "send index". If
you suspenct your mail path to be convoluted, include, on a separate
line, the word "path" followed by the path from thor.ucar.edu back to you.

If you are in a Big Rush, you can contact me, and I'll send the sources
to you.

I've enclosed a -me format blurb about the software.

Be aware that this does NOT include any toolkits or the intrinsics. Just
the Xlib.

bob schulman
Jupiter Systems
(415) 523-9000
uunet!jupiter!bob -or- bob@jupiter.com

-----snip snip---
\"   	@(#)vxWorksXlib.me	1.2  11/20/89
.ll +3
.ba +3
.ce 1
.b
.sz +2
Notes for Jupiter's Xlib for VxWorks
.sz -2
.sp
.ce 1
.i
Jupiter Systems
.r
.sp
.ce 1
Revision 1.2 11/20/89
.sp 2
.pp
This document explains the installation and use of the
X library (Xlib) for use under VxWorks.
.sp 2
.fo "''- % -'Rev 1.2'"
.sh 1 "Installation of the X Library"
.pp
The tape is in tar format and contains the contents of the
directory
.i X.V11R3/lib/X
plus revisions to make the code run under VxWorks.
This source code is based on the original core distribution as patched by
patches 1 through 9 (all publicly available).
.(f
Jupiter is a registered trademark of Jupiter Systems.
The X Window System is a registered trademark of MIT.
Unix is a registered trademark of AT&T.
Copyright \(co 1989 Jupiter Systems, Inc.
.)f
You should replace the contents of your X.V11R3/lib/X directory with these
files (you may first wish to save a copy of your files).
To read the tape:
.sp
.ti +4
% cd \fIwhatever\fP/X.V11R3/lib/X
.ti +4
% tar xvb 126
.br
.pp
The tape will add one more file to this directory: stdio.h.
.pp
To compile the files, you must edit the Imakefile.
You may configure the Imakefile to produce object code suitable for use
on a Unix system, or you may configure the Imakefile to produce code
suitable for use in VxWorks.
.pp
If you wish to produce code for use under Unix, use the following
definitions of
.b DEFINES
and
.b INCLUDES
in Imakefile:
.sp
.ti +4
INCLUDES = -I. -I$(TOP) -I$(INCLUDESRC)
.ti +4
DEFINES = ConnectionFlags
.pp
If you wish to produce code for use under VxWorks, use the following
definitions of
.b DEFINES,
.b INCLUDES,
and
.b CC:
.sp
.ti +4
CC = cc -sun3
.ti +4
DEFINES = ConnectionFlags -UUNIXCONN -Dwrs -Uunix
.ti +4
INCLUDES = -I. -I$(TOP) -I$(INCLUDESRC) -I$(VWSRC)/h
.sp
You may need to modify the
.b CC
line.
The 
.b -sun3
option tells the code generator under SunOS 4.0, to produce 680X0 code.
You may also need to add the definition of
.b VWSRC
to your Imakefile.
VWSRC must be a path name of the head of the VxWorks development
tree, typically /usr/vw.
.pp
After setting up the Imakefile, you should now make the Makefile.
You
.i may
be able to do this by:
.sp
.ti +4
% mv Makefile x
.ti +4
% make -f x Makefile
.sp
After making the Makefile, do:
.sp
.ti +4
% make depend
.ti +4
% make
.sp
You now have either an X library for Unix or VxWorks.
.pp
If you have an X lib for VxWorks, you may find it convenient to package it into
one file:
.sp
.ti +4
% ld -X -r -o \fIxlib.vxworks\fP *.o
.sp
You can call the result something besides xlib.vxworks if you wish.
.sh 1 "Use of VxWorks X lib"
.pp
The enclosed X library is reentrant.
You need only load the library once, and all clients can share its
code space.
The data space for each is task is automatically created by the code
in X lib.
There currently are no mechanisms for tasks to "share" the X lib
data \- certainly not difficult to do.
.pp
The library talks to all servers using sockets; shared memory
is not used.
.pp
To set the
.b DISPLAY
variable, do, before starting a client, under vxWorks
.ti +4
.sp
putenv("DISPLAY=server:0");
.sp
.br
where
.i server:0
names the machine you wish to talk to ("server") and its display
number ("0").
If the server is on the same CPU as the X lib, use "localhost" as the
name of the server.
The default value for "DISPLAY" is "localhost:0".
.pp
For the X library to load correctly
in a VxWorks environment,
the variables
.i sys_errlist
and
.i sys_nerr
need to be defined before (or while) the library is loaded.
You can force the definitions of these variables in the VxWorks
kernel by adding the sequence
.ti +4
.b "-u _sys_errlist -u _sys_nerr"
.br
to the
.b EXTRA_MODULES
string in the Makefile for your VxWorks kernel.
.pp
The library uses two semaphores to maintain consistency in a reentrant
environment.
It is possible for an X client to "take" one (or both) of these semaphores,
and then to exit() without "give"ing the semaphore back.
This is bad.
After this happens, no other clients may proceed.
When writing code,
you should be aware of this potential problem.
The macros which "give" the semaphores are defined in Xlibos.h
as
.i UnlockMutex
and
.i UnlockDisplay.
The macros which "take" the semaphores are defined in Xlibos.h as
.i LockDisplay
and
.i LockMutex.
.pp
There is some interesting VxWorks related routines in XOpenDis.c.
You may wish to look there if you are interested in how the data space
is set up under VxWorks.
Files which use the compile-time constant "wrs" are also of interest
to those who wish to understand the differences between the Unix X lib and
the VxWorks X lib.