jkp@SAUNA.HUT.FI (Jyrki Kuoppala) (04/23/89)
Here are some diffs which might be useful to you folks running the
Excelan tcp/ip software and/or trying to use all the GNU stuff
compiled with gcc.
By the way, emacs compiled with gcc is about 80k smaller than a
cc-compiled emacs on our altoses.
Have fun,
//Jyrki
Author: Jyrki Kuoppala (jkp@cs.hut.fi)
Last modified: Sun Apr 23 15:43:59 1989
Here are context diffs to emacs 18.53 to add some features. The following is added or fixed:
- the function open-network-stream for Excelan TCP/IP
- fixes to make unexec work with gcc / coff encapsulation
on an USG system
- the function emacs-ppid for emacs parent process id
- a small fix for Altos 3068
Some comments:
The way I did the unexec.c changed needed for coff unecapsulation is
quite ugly; it doesn't use a.out.gnu.h because of name clashes with
a.out.h.
#define alloca __builtin_alloca for GCC should probably be put in a file that
is used with all machines, not m-*.h
I hope that at least the Excelan socket stuff could be included in a
future emacs version.
GNU malloc didn't work with gcc, so I put #define SYSTEM_MALLOC in
config.h. I hear this will be fixed in 18.54.
diff -cr /tupu/u/gnu/dist-18.53/src/Makefile /u2/gnu/emacs-18.53/src/Makefile
*** /tupu/u/gnu/dist-18.53/src/Makefile Wed Aug 17 18:34:20 1988
--- /u2/gnu/emacs-18.53/src/Makefile Sun Apr 23 13:36:32 1989
***************
*** 1,4 ****
! CPP = cc -E
MAKE = make # BSD doesn't have it as a default.
#Note: an alternative is CPP = /lib/cpp
--- 1,4 ----
! CPP = gcc -E
MAKE = make # BSD doesn't have it as a default.
#Note: an alternative is CPP = /lib/cpp
diff -cr /tupu/u/gnu/dist-18.53/src/lread.c /u2/gnu/emacs-18.53/src/lread.c
*** /tupu/u/gnu/dist-18.53/src/lread.c Tue Aug 2 05:43:43 1988
--- /u2/gnu/emacs-18.53/src/lread.c Sun Apr 23 12:58:24 1989
***************
*** 246,251 ****
--- 246,254 ----
{
register unsigned char *s = XSTRING (pathname)->data;
return (*s == '~' || *s == '/'
+ #ifdef ALTOS
+ || *s == '@'
+ #endif
#ifdef VMS
|| index (s, ':')
#endif /* VMS */
diff -cr /tupu/u/gnu/dist-18.53/src/m-altos.h /u2/gnu/emacs-18.53/src/m-altos.h
*** /tupu/u/gnu/dist-18.53/src/m-altos.h Sat Dec 5 05:58:26 1987
--- /u2/gnu/emacs-18.53/src/m-altos.h Sun Apr 23 13:19:52 1989
***************
*** 45,59 ****
#define NO_UNION_TYPE
#define LIB_STANDARD -lc
#define C_ALLOCA /* we have -lPW and alloca but it's broken!
<vsedev!ron> */
#define SWITCH_ENUM_BUG
#define NO_REMAP
#define STACK_DIRECTION -1
! #define TERMINFO
#undef CANNOT_DUMP
#undef SHORTNAMES
! #undef TERMCAP
--- 45,78 ----
#define NO_UNION_TYPE
#define LIB_STANDARD -lc
+ #ifdef __GNUC__
+ #define alloca __builtin_alloca
+ #define HAVE_ALLOCA
+ #else
#define C_ALLOCA /* we have -lPW and alloca but it's broken!
<vsedev!ron> */
+ #endif
#define SWITCH_ENUM_BUG
#define NO_REMAP
#define STACK_DIRECTION -1
! #undef TERMINFO
#undef CANNOT_DUMP
#undef SHORTNAMES
! #define TERMCAP
!
! #define LIBS_TERMCAP -ltermlib
! #define PURESIZE 220000
! #define ALTOS
! /*
! * Following three lines added by jkp@cs.hut.fi 10 May 1988
! * Omit these if you don't have the Excelan tcp/ip software
! */
! #define HAVE_SOCKETS
! #define EXCELAN
! #define LIBS_MACHINE -lsocket
! #ifdef __GNUC__
! #define COFF_ENCAPSULATE
! #endif
diff -cr /tupu/u/gnu/dist-18.53/src/process.c /u2/gnu/emacs-18.53/src/process.c
*** /tupu/u/gnu/dist-18.53/src/process.c Sat Aug 20 21:27:41 1988
--- /u2/gnu/emacs-18.53/src/process.c Sun Apr 23 12:58:49 1989
***************
*** 34,42 ****
--- 34,50 ----
#include <sys/stat.h>
#ifdef HAVE_SOCKETS /* TCP connection support, if kernel can do it */
+ #ifdef EXCELAN
+ #include <enet/misc.h>
+ #include <enet/socket.h>
+ #include <enet/in.h>
+ #include <enet/soioctl.h>
+ long rhost();
+ #else
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
+ #endif /* EXCELAN */
#endif /* HAVE_SOCKETS */
#if defined(BSD) || defined(STRIDE)
***************
*** 72,79 ****
--- 80,90 ----
#ifdef SYSV_PTYS
#include <sys/tty.h>
+ /* We use a public-domain pty driver and don't have pty.h */
+ #ifndef ALTOS
#include <sys/pty.h>
#endif
+ #endif
#undef NULL
#include "lisp.h"
***************
*** 1083,1090 ****
--- 1094,1107 ----
Lisp_Object proc;
register int i;
struct sockaddr_in address;
+ #ifdef EXCELAN
+ struct sockaddr_in mysoc;
+ long host_addr;
+ char *host_tmp_name;
+ #else
struct servent *svc_info;
struct hostent *host_info;
+ #endif /* EXCELAN */
int s, outch, inch;
char errstring[80];
int port;
***************
*** 1096,1117 ****
--- 1113,1156 ----
else
{
CHECK_STRING (service, 0);
+ #ifdef EXCELAN
+ error ("Can't find services by name");
+ #else
svc_info = getservbyname (XSTRING (service)->data, "tcp");
if (svc_info == 0)
error ("Unknown service \"%s\"", XSTRING (service)->data);
port = svc_info->s_port;
+ #endif /* EXCELAN */
}
+ #ifdef EXCELAN
+ host_tmp_name = (char *) XSTRING (host)->data;
+ if ((host_addr = rhost (&host_tmp_name)) == -1)
+ #else
host_info = gethostbyname (XSTRING (host)->data);
if (host_info == 0)
+ #endif /* EXCELAN */
error ("Unknown host \"%s\"", XSTRING(host)->data);
bzero (&address, sizeof address);
+ #ifdef EXCELAN
+ bzero (&mysoc, sizeof mysoc);
+ mysoc.sin_family = AF_INET;
+ mysoc.sin_port = INADDR_ANY;
+ mysoc.sin_addr.s_addr = INADDR_ANY;
+ address.sin_family = AF_INET;
+ address.sin_addr.s_addr = host_addr;
+ #else
bcopy (host_info->h_addr, (char *) &address.sin_addr, host_info->h_length);
address.sin_family = host_info->h_addrtype;
+ #endif /* EXCELAN */
address.sin_port = port;
+ #ifdef EXCELAN
+ s = socket (SOCK_STREAM, (struct sockproto *) 0, &mysoc, SO_KEEPALIVE | SO_REUSEADDR);
+ #else
s = socket (host_info->h_addrtype, SOCK_STREAM, 0);
+ #endif /* EXCELAN */
if (s < 0)
report_file_error ("error creating socket", Fcons (name, Qnil));
***************
*** 1132,1137 ****
--- 1171,1179 ----
#ifdef O_NDELAY
fcntl (inch, F_SETFL, O_NDELAY);
#endif
+ #ifdef EXCELAN
+ (void) ioctl (inch, FIONBIO, 1);
+ #endif
XPROCESS (proc)->childp = host;
XPROCESS (proc)->command_channel_p = Qnil;
***************
*** 1158,1163 ****
--- 1200,1216 ----
inchannel = XFASTINT (p->infd);
outchannel = XFASTINT (p->outfd);
+ #ifdef HAVE_SOCKETS
+ #ifdef EXCELAN
+ if (NETCONN_P (proc)) {
+ /* Make the socket blocking and do a shutdown on it */
+ (void) ioctl (inchannel, FIONBIO, 0);
+ (void) ioctl (inchannel, FIONBIO, 0);
+ (void) ioctl (outchannel, SIOCDONE, 2);
+ (void) ioctl (outchannel, SIOCDONE, 2);
+ }
+ #endif /* EXCELAN */
+ #endif /* HAVE_SOCKETS */
if (inchannel)
{
/* Beware SIGCHLD hereabouts. */
***************
*** 2111,2116 ****
--- 2164,2181 ----
p->sentinel = sentinel;
}
+ DEFUN ("emacs-ppid", Femacs_ppid, Semacs_ppid,
+ 0, 0, 0,
+ "Returns process identifier of the parent process.")
+ ()
+ {
+ register Lisp_Object val;
+ register int ppid = getppid();
+
+ XSET (val, Lisp_Int, ppid);
+ return val;
+ }
+
init_process ()
{
register int i;
***************
*** 2183,2188 ****
--- 2248,2254 ----
defsubr (&Scontinue_process);
defsubr (&Sprocess_send_eof);
defsubr (&Swaiting_for_user_input_p);
+ defsubr (&Semacs_ppid);
}
#endif subprocesses
diff -cr /tupu/u/gnu/dist-18.53/src/sysdep.c /u2/gnu/emacs-18.53/src/sysdep.c
*** /tupu/u/gnu/dist-18.53/src/sysdep.c Thu Feb 9 14:49:17 1989
--- /u2/gnu/emacs-18.53/src/sysdep.c Sun Apr 23 12:58:58 1989
***************
*** 1492,1497 ****
--- 1492,1512 ----
avail = read (fd, &buf, 1);
if (avail > 0)
proc_buffered_char[fd] = buf;
+ /*
+ * Following code added by jkp@cs.hut.fi to make this work equivalent to BSD
+ * with Excelan EXOS sockets, where read returns 0 if nonblocking
+ * io is used and the socket is closed by peer
+ */
+ #ifdef HAVE_SOCKETS
+ #ifdef EXCELAN
+ if (avail == 0) {
+ struct termio tty;
+ errno = 0;
+ (void) ioctl (fd, TCGETA, &tty);
+ if (errno == 45) avail = 1;
+ }
+ #endif /* EXCELAN */
+ #endif /* HAVE_SOCKETS */
}
#endif /* no FIONREAD */
}
***************
*** 2042,2048 ****
--- 2057,2065 ----
while (*npath && *npath != '/')
npath++;
strcpy (pathname, npath);
+ #ifndef ALTOS
free (spath); /* getcwd uses malloc */
+ #endif /* Like hell it does */
return pathname;
}
diff -cr /tupu/u/gnu/dist-18.53/src/unexec.c /u2/gnu/emacs-18.53/src/unexec.c
*** /tupu/u/gnu/dist-18.53/src/unexec.c Sat Aug 20 20:22:33 1988
--- /u2/gnu/emacs-18.53/src/unexec.c Sun Apr 23 14:21:04 1989
***************
*** 286,291 ****
--- 286,306 ----
static long text_scnptr;
static long data_scnptr;
+ #ifdef COFF_ENCAPSULATE
+ /* This is copied from a.out.gnu.h, should find another way to do it */
+ struct gnuexec
+ {
+ unsigned long gnu_info; /* Use macros N_MAGIC, etc for access */
+ unsigned gnu_text; /* length of text, in bytes */
+ unsigned gnu_data; /* length of data, in bytes */
+ unsigned gnu_bss; /* length of uninitialized data area for file, in bytes */
+ unsigned gnu_syms; /* length of symbol table data in file, in bytes */
+ unsigned gnu_entry; /* start address */
+ unsigned gnu_trsize; /* length of relocation info for text, in bytes */
+ unsigned gnu_drsize; /* length of relocation info for data, in bytes */
+ };
+ struct gnuexec gnuexec;
+ #endif /* COFF_ENCAPSULATE */
#else /* not COFF */
extern char *sbrk ();
***************
*** 524,529 ****
--- 539,550 ----
f_bhdr = scntemp;
}
}
+ #ifdef COFF_ENCAPSULATE
+ if (read (a_out, &gnuexec, sizeof (gnuexec)) != sizeof (gnuexec))
+ {
+ PERROR (a_name);
+ }
+ #endif
}
else
{
***************
*** 545,552 ****
--- 566,577 ----
f_ohdr.dsize = bss_start - f_ohdr.data_start;
f_ohdr.bsize = bss_end - bss_start;
f_thdr.s_size = f_ohdr.tsize;
+ #ifdef COFF_ENCAPSULATE
+ f_thdr.s_scnptr = f_ohdr.text_start;
+ #else
f_thdr.s_scnptr = sizeof (f_hdr) + sizeof (f_ohdr);
f_thdr.s_scnptr += (f_hdr.f_nscns) * (sizeof (f_thdr));
+ #endif /* COFF_ENCAPSULATE */
lnnoptr = f_thdr.s_lnnoptr;
#ifdef SECTION_ALIGNMENT
/* Some systems require special alignment
***************
*** 616,621 ****
--- 641,654 ----
{
PERROR (new_name);
}
+ #ifdef COFF_ENCAPSULATE
+ gnuexec.gnu_bss = bss_end - bss_start;
+ gnuexec.gnu_data = bss_start - data_start;
+ if (write (new, &gnuexec, sizeof (gnuexec)) != sizeof (gnuexec))
+ {
+ PERROR (new_name);
+ }
+ #endif
return (0);
#else /* if not COFF */
diff -cr /tupu/u/gnu/dist-18.53/src/ymakefile /u2/gnu/emacs-18.53/src/ymakefile
*** /tupu/u/gnu/dist-18.53/src/ymakefile Tue Aug 16 07:03:31 1988
--- /u2/gnu/emacs-18.53/src/ymakefile Sun Apr 23 13:21:23 1989
***************
*** 19,24 ****
--- 19,26 ----
and this notice must be preserved on all copies. */
+ CC = gcc -O
+
dot = .
/* on Xenix, replace double-dot below with $(dot)$(dot) */
lispdir = ../lisp/
***************
*** 55,61 ****
/* Some s- files define this to request special switches in ld. */
#ifndef LD_SWITCH_SYSTEM
! #if defined (BSD) && !defined (COFF)
#define LD_SWITCH_SYSTEM -X
#else
#define LD_SWITCH_SYSTEM
--- 57,63 ----
/* Some s- files define this to request special switches in ld. */
#ifndef LD_SWITCH_SYSTEM
! #if defined(COFF_ENCAPSULATE) || (defined (BSD) && !defined (COFF))
#define LD_SWITCH_SYSTEM -X
#else
#define LD_SWITCH_SYSTEM
***************
*** 78,84 ****
--- 80,90 ----
#ifndef START_FILES
#ifdef NO_REMAP
+ #ifdef COFF_ENCAPSULATE
+ #define START_FILES pre-crt0.o /usr/local/lib/gcc-crt0.o
+ #else
#define START_FILES pre-crt0.o /lib/crt0.o
+ #endif
#else
#define START_FILES crt0.o
#endif
***************
*** 108,114 ****
STARTFLAGS = -T LD_TEXT_START_ADDR -e __start
#endif
! LD=ld
LDFLAGS = LD_SWITCH_SYSTEM LD_SWITCH_MACHINE
/* Figure out whether the system cpp can handle long names.
--- 114,120 ----
STARTFLAGS = -T LD_TEXT_START_ADDR -e __start
#endif
! LD=gnu ld
LDFLAGS = LD_SWITCH_SYSTEM LD_SWITCH_MACHINE
/* Figure out whether the system cpp can handle long names.