Article View: gnu.emacs.bug
Article #99236Emacs notes for the Cetia
From: Stephen Gildea
Date: Tue, 16 Oct 1990 00:55
Date: Tue, 16 Oct 1990 00:55
310 lines
9881 bytes
9881 bytes
To build Emacs 18.55 on the Cetia UniGraph (a French workstation
running something that looks mostly like SysV.2.2), I had to make
several modifications to the source. Some were details for the
Cetia's variation of System V.2.2, but some were changes that will
probably make Emacs easier to port to other machines, too.
Here are my notes. In most cases it was just a matter of tweaking
ifdefs and includes, so I'm not including diffs.
In x11term.c, include sys/time.h instead of time.h (l.74)
In process.c (~l.66), a different algorithm from x11term.c is used to
determine whether to include <sys/time.h> or <time.h>. It also fails
for the Cetia.
keyboard.c undefs SIGIO if FIONREAD is undefined, and
dispnew.c undefs FIONREAD if BROKEN_FIONREAD is defined.
Both files should do both. x11term.c does it right.
x11fns.c should have the same logic as x11term.c to unset SIGIO before
including x11term.h, which assumes that sigblock and sigpause exist
iff SIGIO exists. But the Cetia has SIGIO and not sigblock or
sigpause.
On the Cetia, FIONREAD is defined in <sys/ioctl.h> (BSD style)
instead of <fcntl.h> (Sys V style). Changed keyboard.c, dispnew.c,
process.c, sysdep.c. The Stride and MIPS seem (from the
code) to have the same property, so perhaps another #define to
represent this behavior is necessary. Actually, there is probably no
harm in including sys/ioctl.h unconditionally. Further, from a small
survey, it would appear that *everyone* defines FIONREAD in
<sys/ioctl.h>, so Emacs should just always look for it there.
(Then I discovered that we can't use it because also need sigblock and
sigpause in keyboard.c.)
In ymakefile, the LIBS_SYSTEM and LIBS_MACHINE are searched before
$(LIBX). The X stuff should be loaded first. As it is now, to be
sure my local libraries are loaded, I must set both LIBS_MACHINE and
LIBX11_MACHINE.
The X library calls select() with a NULL timeout, so I enhanced the
select() emulator routine to handle this. Here is my code from sysdep.c:
/* Only rfds are checked. */
/* Modified by gildea to allow timeout to be NULL */
int
select (nfds, rfds, wfds, efds, timeout)
int nfds;
int *rfds, *wfds, *efds, *timeout;
{
int ravail = 0, orfds = 0, old_alarm;
int timeoutval = timeout ? *timeout : 100000;
int *local_timeout = &timeoutval;
extern int kbd_count;
extern int proc_buffered_char[];
#ifndef subprocesses
int child_changed = 0;
#else
extern int child_changed;
#endif
int (*old_trap) ();
char buf;
if (rfds)
{
orfds = *rfds;
*rfds = 0;
}
if (wfds)
*wfds = 0;
if (efds)
*efds = 0;
/* If we are looking only for the terminal, with no timeout,
just read it and wait -- that's more efficient. */
if (orfds == 1 && (!timeout || *timeout == 100000) && !child_changed)
{
if (!kbd_count)
read_input_waiting ();
*rfds = 1;
return 1;
}
/* Once a second, till the timer expires, check all the flagged read
* descriptors to see if any input is available. If there is some then
* set the corresponding bit in the return copy of rfds.
*/
while (1)
{
register int to_check, bit, fd;
if (rfds)
{
for (to_check = nfds, bit = 1, fd = 0; --to_check >= 0; bit <<= 1, fd++)
{
if (orfds & bit)
{
int avail = 0, status = 0;
if (bit == 1)
avail = detect_input_pending(); /* Special keyboard handler */
else
{
#ifdef FIONREAD
status = ioctl (fd, FIONREAD, &avail);
#else /* no FIONREAD */
/* Hoping it will return -1 if nothing available
or 0 if all 0 chars requested are read. */
if (proc_buffered_char[fd] >= 0)
avail = 1;
else
{
avail = read (fd, &buf, 1);
if (avail > 0)
proc_buffered_char[fd] = buf;
}
#endif /* no FIONREAD */
}
if (status >= 0 && avail > 0)
{
(*rfds) |= bit;
ravail++;
}
}
}
}
if (local_timeout == 0 || ravail != 0 || child_changed)
break;
old_alarm = alarm (0);
old_trap = (int (*)()) signal (SIGALRM, select_alarm);
select_alarmed = 0;
alarm (SELECT_PAUSE);
/* Wait for a SIGALRM (or maybe a SIGTINT) */
while (select_alarmed == 0 && *local_timeout != 0 && child_changed == 0)
{
/* If we are interested in terminal input,
wait by reading the terminal.
That makes instant wakeup for terminal input at least. */
if (orfds & 1)
{
read_input_waiting ();
if (kbd_count)
select_alarmed = 1;
}
else
pause();
}
(*local_timeout) -= SELECT_PAUSE;
/* Reset the old alarm if there was one */
alarm (0);
signal (SIGALRM, old_trap);
if (old_alarm != 0)
{
/* Reset or forge an interrupt for the original handler. */
old_alarm -= SELECT_PAUSE;
if (old_alarm <= 0)
kill (getpid (), SIGALRM); /* Fake an alarm with the orig' handler */
else
alarm (old_alarm);
}
if (*local_timeout == 0) /* Stop on timer being cleared */
break;
}
return ravail;
}
And here is the m-cetia.h file I wrote:
/* m- file for Cetia 3.1.0 which claims to be "V.2+NFS". CPU is M68030.
GNU Emacs is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY. No author or distributor
accepts responsibility to anyone for the consequences of using it
or for whether it serves any particular purpose or works at all,
unless he says so in writing. Refer to the GNU Emacs General Public
License for full details.
Everyone is granted permission to copy, modify and redistribute
GNU Emacs, but only under the conditions described in the
GNU Emacs General Public License. A copy of this license is
supposed to have been given to you along with GNU Emacs so you
can know your rights and responsibilities. It should be in a
file named COPYING. Among other things, the copyright notice
and this notice must be preserved on all copies. */
/* Note: Compiling with -g overflows ld on our Cetia.
You have to raise your file size limit.
"ulimit -f 3000" should do it. */
/* The following three symbols give information on
the size of various data types. */
#define SHORTBITS 16 /* Number of bits in a short */
#define INTBITS 32 /* Number of bits in an int */
#define LONGBITS 32 /* Number of bits in a long */
/* 68000 has lowest-numbered byte as most significant */
#define BIG_ENDIAN
/* m68k, not m68000, for crt0.c (Cetia compiler already defines it) */
#ifndef m68k
#define m68k
#endif
#ifndef cetia
#define cetia
#endif
/* Use type int rather than a union, to represent Lisp_Object */
#define NO_UNION_TYPE
/* Data type of load average, as read out of kmem. */
#define LOAD_AVE_TYPE long
/* Convert that into an integer that is 100 for a load average of 1.0
FSCALE is defined <sys/param.h>, but loadst.c and fns.c don't include it */
#define LOAD_AVE_CVT(x) ((int) ((x) * 100.0 / 256.0))
/* Define C_ALLOCA if this machine does not support a true alloca
and the one written in C should be used instead.
Define HAVE_ALLOCA to say that the system provides a properly
working alloca function and it should be used.
Define neither one if an assembler-language alloca
in the file alloca.s should be used. */
#define C_ALLOCA
#define STACK_DIRECTION -1 /* tell alloca stack grows down */
/* Stuff below is additions to s-usg5-2-2.h for Cetia's BSD enhancements. */
/*
* Define HAVE_TIMEVAL if the system supports the BSD style clock values.
* Look in <sys/time.h> for a timeval structure.
*/
#define HAVE_TIMEVAL
/*
* Define HAVE_PTYS if the system supports pty devices.
*/
#define HAVE_PTYS
#define SYSV_PTYS
/* Define HAVE_SOCKETS if system supports 4.2-compatible sockets. */
#define HAVE_SOCKETS
/* Define this symbol if your system has the functions bcopy, etc. */
#define BSTRING
#define LIBS_MACHINE -lbsd /* to define bcopy, index, and friends */
#define LIBX11_MACHINE -lbsd /* to define index and friends */
/* BSDCOMPAT makes readdir() and stat() work like BSD. */
#define C_SWITCH_MACHINE -DBSDCOMPAT
#undef NONSYSTEM_DIR_LIBRARY /* so don't want this from s-usg5-2-2.h */
/* Keep unexec from moving stuff around since it doesn't work here. */
#define NO_REMAP
/* FIONREAD does exist, it's defined in <sys/ioctl.h>, but
sigblock and sigpause, which the FIONREAD code also use,
don't exist. */
#define BROKEN_FIONREAD
After making these changes, I would put the following comment in etc/MACHINES:
Cetia (m-cetia.h; s-usg5-2-2.h)
Mostly works in 18.??. Compiling with -O may not work for search.c
and crt0.c. Subprocesses don't work if you define HAVE_SELECT, even
though the Cetia does have select(). The fchown() system call is
missing, so you can't enable CLASH_DETECTION, because the code uses
it. If ld fails, try raising your file size ulimit.
< Stephen Bolt Beranek and Newman Inc.
gildea@bbn.com Cambridge, Massachusetts
Technical Details
Message-ID:
<9010160056.AA28707@life.ai.mit.edu>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!ALEXANDER.BBN.COM!gildeaShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,308310b1c314dd84,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-10-15 17:55:57 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!ALEXANDER.BBN.COM!gildea From: gildea@ALEXANDER.BBN.COM (Stephen Gildea) Newsgroups: gnu.emacs.bug Subject: Emacs notes for the Cetia Message-ID: <9010160056.AA28707@life.ai.mit.edu> Date: 16 Oct 90 00:55:57 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 310 Approved: bug-gnu-emacs@prep.ai.mit.edu Posted: Tue Oct 16 01:55:57 1990