james@bigtex.cactus.org (James Van Artsdalen) (01/04/90)
Several people have asked about using SysVr3 shared libraries with emacs. These diffs are against 18.53. They make shared libraries work, make X work on i386, and do one or two other things. The only thing I am unsure of is the moving of setpgrp(2) in process.c below: I can't remember why I did that or if it worked. config.h assumes an i386: remove the inline asms if not. /usr/local/lib/emacs/src> rcsdiff -c -r1.1 RCS/* RCS file: RCS/Makefile,v retrieving revision 1.1 diff -c -r1.1 Makefile *** /tmp/,RCSt1a25061 Wed Jan 3 21:11:34 1990 --- Makefile Wed Jan 3 21:08:42 1990 *************** *** 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 = $(CC) -E MAKE = make # BSD doesn't have it as a default. #Note: an alternative is CPP = /lib/cpp =================================================================== RCS file: RCS/alloc.c,v retrieving revision 1.1 diff -c -r1.1 alloc.c *** /tmp/,RCSt1a25061 Wed Jan 3 21:11:37 1990 --- alloc.c Wed Jan 3 21:08:43 1990 *************** *** 668,674 **** --- 668,679 ---- int staticidx = 0; + #ifdef __GNUC__ + Lisp_Object *staticvec[NSTATICS] = {0}; + #else + char staticvec1[NSTATICS * sizeof (Lisp_Object *)] = {0}; #define staticvec ((Lisp_Object **) staticvec1) + #endif /* Put an entry in staticvec, pointing at the variable whose address is given */ =================================================================== RCS file: RCS/buffer.c,v retrieving revision 1.1 diff -c -r1.1 buffer.c =================================================================== RCS file: RCS/config.h,v retrieving revision 1.1 diff -c -r1.1 config.h *** /tmp/,RCSt1a25061 Wed Jan 3 21:11:43 1990 --- config.h Wed Jan 3 21:08:33 1990 *************** *** 18,30 **** file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. */ - /* Include here a s- file that describes the system type you are using. See the file ../etc/MACHINES for a list of systems and the names of the s- files to use for them. See s-template.h for documentation on writing s- files. */ ! #include "s-bsd4-2.h" /* Include here a m- file that describes the machine and system you use. See the file ../etc/MACHINES for a list of machines and --- 18,30 ---- file named COPYING. Among other things, the copyright notice and this notice must be preserved on all copies. */ + #define HBTCP /* Include here a s- file that describes the system type you are using. See the file ../etc/MACHINES for a list of systems and the names of the s- files to use for them. See s-template.h for documentation on writing s- files. */ ! #include "s-usg5-3.h" /* Include here a m- file that describes the machine and system you use. See the file ../etc/MACHINES for a list of machines and *************** *** 31,37 **** the names of the m- files to use for them. See m-template.h for info on what m- files should define. */ ! #include "m-vax.h" /* Load in the conversion definitions if this system needs them and the source file being compiled has not --- 31,37 ---- the names of the m- files to use for them. See m-template.h for info on what m- files should define. */ ! #include "m-intel386.h" /* Load in the conversion definitions if this system needs them and the source file being compiled has not *************** *** 114,116 **** --- 114,205 ---- its priority. */ /* #define HIGHPRI */ + + #define HAVE_SELECT + #define HAVE_PTYS + #define SYSV_PTYS + #define HAVE_SOCKETS + + #define USG_SHARED_LIBRARIES -lc_s + + #if defined(__GNUC__) && !defined(alloca) + #define alloca(n) __builtin_alloca(n) + #endif + + #ifdef __GNUC__ + #define GNULIB /usr/local/lib/gcc-gnulib + #else + #define GNULIB + #endif + + #ifdef __GNUC__ + #define C_DEBUG_SWITCH -O -finline-functions -fstrength-reduce -fcombine-regs + #endif + + #undef LIB_STANDARD + #ifdef USG_SHARED_LIBRARIES + #ifdef X11 + #define LIB_X11_LIB -lX11_s + #endif /* X11 */ + #define START_FILES pre-crt0.o /lib/crt1.o + #define LIB_STANDARD -linet USG_SHARED_LIBRARIES GNULIB -lPW -lc \ + /lib/crtn.o + #else /* USG_SHARED_LIBRARIES */ + #define LIB_STANDARD -linet -lPW -lc GNULIB + #endif /* USG_SHARED_LIBRARIES */ + + #define HAVE_TIMEVAL + #define HAVE_GETTIMEOFDAY + #define USE_UTIME + #define FIOCLEX TIOCEXCL + + #define BSTRING + #define bcopy(src, dest, len) memcpy(dest, src, len) + #define bzero(dest, len) memset(dest, '\0', len) + #define bcmp(b1, b2, len) memcmp(b1, b2, len) + + #define TABS_OK(dummy) 0 + + #if defined(__GNUC__) && !defined(MAKEFILE) && !defined(NO_INLINE) + #undef static + + #define strlen(s) __inline_strlen(s) + static inline int + __inline_strlen(void *s) + { + int ret, dummy; + + asm("repnz;scasb" + : "=c" (ret), + "=D" (dummy) + : "1" (s), + "a" (0), + "0" (-1)); + return ~ret - 1; + } + + #undef bcopy + #define bcopy(src, dest, len) memcpy(dest, src, len) + #define memcpy(dest, src, len) __inline_memcpy(dest, src, len) + static inline void * + __inline_memcpy(void *dest, void *src, int len) + { + int tmp, dummy_si, dummy_di, dummy_cx; + + asm volatile("shrd%L3 $2,%1,%0;" + "shr%L3 $2,%1;" + "rep;movsl;" + "shld%L3 $2,%0,%1;" + "rep;movsb" + : "=r" (tmp), + "=c" (dummy_cx), + "=S" (dummy_si), + "=D" (dummy_di) + : "2" (src), + "3" (dest), + "1" (len)); + return dest; + } + + #define static + #endif /* __GNUC__ && !MAKEFILE */ =================================================================== RCS file: RCS/emacs.c,v retrieving revision 1.1 diff -c -r1.1 emacs.c *** /tmp/,RCSt1a25061 Wed Jan 3 21:11:49 1990 --- emacs.c Wed Jan 3 21:08:51 1990 *************** *** 81,86 **** --- 81,88 ---- int xargc; #endif /* HAVE_X_WINDOWS */ + unsigned int bss_end = 0; + /* Nonzero means running Emacs without interactive terminal. */ int noninteractive; *************** *** 202,207 **** --- 204,214 ---- #endif /* SHAREABLE_LIB_BUG */ #endif /* LINK_CRTL_SHARE */ #endif /* VMS */ + + #ifdef USG_SHARED_LIBRARIES + if (bss_end) + brk(bss_end); + #endif clearerr (stdin); =================================================================== RCS file: RCS/filelock.c,v retrieving revision 1.1 diff -c -r1.1 filelock.c *** /tmp/,RCSt1a25061 Wed Jan 3 21:11:52 1990 --- filelock.c Wed Jan 3 21:08:51 1990 *************** *** 148,154 **** --- 148,158 ---- if ((fd = open (lfname, mode, 0666)) >= 0) { + #ifndef USG fchmod (fd, 0666); + #else + chmod(lfname, 0666); + #endif sprintf (buf, "%d ", getpid ()); write (fd, buf, strlen (buf)); close (fd); *************** *** 251,257 **** --- 255,265 ---- } if (fd >= 0) { + #ifndef USG fchmod (fd, 0666); + #else + chmod(PATH_SUPERLOCK, 0666); + #endif write (fd, lfname, strlen (lfname)); close (fd); } =================================================================== RCS file: RCS/process.c,v retrieving revision 1.1 diff -c -r1.1 process.c *** /tmp/,RCSt1a25061 Wed Jan 3 21:12:03 1990 --- process.c Wed Jan 3 21:08:54 1990 *************** *** 57,63 **** #else /* not IRIS, not UNIPLUS */ #ifdef HAVE_TIMEVAL #if defined(USG) && !defined(IBMRTAIX) ! #include <time.h> #else /* IBMRTAIX or not USG */ #include <sys/time.h> #endif /* IBMRTAIX or not USG */ --- 57,63 ---- #else /* not IRIS, not UNIPLUS */ #ifdef HAVE_TIMEVAL #if defined(USG) && !defined(IBMRTAIX) ! /* #include <time.h> */ #else /* IBMRTAIX or not USG */ #include <sys/time.h> #endif /* IBMRTAIX or not USG */ *************** *** 72,79 **** #ifdef SYSV_PTYS #include <sys/tty.h> #include <sys/pty.h> ! #endif #undef NULL #include "lisp.h" --- 72,85 ---- #ifdef SYSV_PTYS #include <sys/tty.h> + #ifdef USG + #ifdef TIOCGETC + #undef TIOCGWINSZ + #undef TIOCSWINSZ #include <sys/pty.h> ! #endif /* TIOCGETC */ ! #endif /* USG */ ! #endif /* SYSV_PTYS */ #undef NULL #include "lisp.h" *************** *** 986,991 **** --- 992,1000 ---- { int xforkin = forkin; int xforkout = forkout; + #ifdef USG + setpgrp (); + #endif #ifdef HAVE_PTYS #ifdef TIOCNOTTY /* In 4.3BSD, the TIOCSPGRP bug has been fixed, and now you *************** *** 998,1008 **** int j = open ("/dev/tty", O_RDWR, 0); ioctl (j, TIOCNOTTY, 0); close (j); ! #if !defined (RTU) && !defined(UNIPLUS) - #ifdef USG - setpgrp (); - #endif /* I wonder if close (open (ptyname, ...)) would work? */ if (xforkin >= 0) close (xforkin); --- 1007,1016 ---- int j = open ("/dev/tty", O_RDWR, 0); ioctl (j, TIOCNOTTY, 0); close (j); ! } ! #endif /* TIOCNOTTY */ ! if (ptyname) { #if !defined (RTU) && !defined(UNIPLUS) /* I wonder if close (open (ptyname, ...)) would work? */ if (xforkin >= 0) close (xforkin); *************** *** 1012,1018 **** abort (); #endif /* not UNIPLUS and not RTU */ } - #endif /* TIOCNOTTY */ #endif /* HAVE_PTYS */ child_setup_tty (xforkout); child_setup (xforkin, xforkout, xforkout, new_argv, env); --- 1020,1025 ---- =================================================================== RCS file: RCS/regex.c,v retrieving revision 1.1 diff -c -r1.1 regex.c *** /tmp/,RCSt1a25061 Wed Jan 3 21:12:11 1990 --- regex.c Wed Jan 3 21:08:56 1990 *************** *** 337,342 **** --- 337,343 ---- while (p != pend) { + /* while (b - bufp->buffer > bufp->allocated - 10) */ if (b - bufp->buffer > bufp->allocated - 10) /* Note that EXTEND_BUFFER clobbers c */ EXTEND_BUFFER; =================================================================== RCS file: RCS/sysdep.c,v retrieving revision 1.1 diff -c -r1.1 sysdep.c *** /tmp/,RCSt1a25061 Wed Jan 3 21:12:23 1990 --- sysdep.c Wed Jan 3 21:08:58 1990 *************** *** 19,24 **** --- 19,29 ---- and this notice must be preserved on all copies. */ + #ifdef USG + #include <memory.h> + #include <string.h> + #endif + #include <signal.h> #include <setjmp.h> *************** *** 117,123 **** --- 122,130 ---- #define TERMINAL struct termio #define OSPEED(str) (str.c_cflag & CBAUD) #define SETOSPEED(str,new) (str.c_cflag = (str.c_cflag & ~CBAUD) | (new)) + #ifndef TABS_OK #define TABS_OK(str) ((str.c_oflag & TABDLY) != TAB3) + #endif #endif /* HAVE_TERMIO */ #ifdef XENIX *************** *** 124,129 **** --- 131,143 ---- #undef TIOCGETC /* Avoid confusing some conditionals that test this. */ #endif + #ifdef USG + #ifdef TIOCGETC + #undef TIOCGETC + #include <sys/sioctl.h> + #endif + #endif + #ifndef HAVE_TERMIO #ifndef VMS #include <sgtty.h> *************** *** 130,136 **** --- 144,152 ---- #define TERMINAL struct sgttyb #define OSPEED(str) str.sg_ospeed #define SETOSPEED(str,new) (str.sg_ospeed = (new)) + #ifndef TABS_OK #define TABS_OK(str) ((str.sg_flags & XTABS) != XTABS) + #endif #undef TCSETAW #define TCSETAW TIOCSETN #endif /* not VMS */ *************** *** 138,145 **** #ifdef USG #include <sys/utsname.h> - #include <memory.h> - #include <string.h> #ifdef HAVE_TIMEVAL #ifdef HPUX #include <time.h> --- 154,159 ---- *************** *** 232,238 **** --- 246,254 ---- } sensemode_iosb; #define TERMINAL struct sensemode #define OSPEED(str) (str.xmit_baud) + #ifndef TABS_OK #define TABS_OK(str) ((str.tt_char & TT$M_MECHTAB) != 0) + #endif #endif /* VMS */ discard_tty_input () =================================================================== RCS file: RCS/unexec.c,v retrieving revision 1.1 diff -c -r1.1 unexec.c *** /tmp/,RCSt1a25061 Wed Jan 3 21:12:30 1990 --- unexec.c Wed Jan 3 21:08:58 1990 *************** *** 400,406 **** } if (make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) < 0 ! || copy_text_and_data (new) < 0 || copy_sym (new, a_out, a_name, new_name) < 0 #ifdef COFF || adjust_lnnoptrs (new, a_out, new_name) < 0 --- 400,406 ---- } if (make_hdr (new, a_out, data_start, bss_start, entry_address, a_name, new_name) < 0 ! || copy_sections (new, a_out) < 0 || copy_sym (new, a_out, a_name, new_name) < 0 #ifdef COFF || adjust_lnnoptrs (new, a_out, new_name) < 0 *************** *** 440,446 **** auto struct scnhdr scntemp; /* Temporary section header */ register int scns; #endif /* COFF */ ! unsigned int bss_end; pagemask = getpagesize () - 1; --- 440,446 ---- auto struct scnhdr scntemp; /* Temporary section header */ register int scns; #endif /* COFF */ ! extern unsigned int bss_end; pagemask = getpagesize () - 1; *************** *** 533,538 **** --- 533,541 ---- /* Now we alter the contents of all the f_*hdr variables to correspond to what we want to dump. */ + bias = (bss_start - f_ohdr.data_start) + (bss_end - bss_start) - + f_dhdr.s_size; + f_hdr.f_flags |= (F_RELFLG | F_EXEC); #ifdef EXEC_MAGIC f_ohdr.magic = EXEC_MAGIC; *************** *** 576,582 **** f_bhdr.s_vaddr = f_ohdr.data_start + f_ohdr.dsize; f_bhdr.s_size = f_ohdr.bsize; f_bhdr.s_scnptr = 0L; - bias = f_dhdr.s_scnptr + f_dhdr.s_size - block_copy_start; if (f_hdr.f_symptr > 0L) { --- 579,584 ---- *************** *** 602,621 **** PERROR (new_name); } ! if (write (new, &f_thdr, sizeof (f_thdr)) != sizeof (f_thdr)) ! { ! PERROR (new_name); ! } ! if (write (new, &f_dhdr, sizeof (f_dhdr)) != sizeof (f_dhdr)) ! { ! PERROR (new_name); ! } - if (write (new, &f_bhdr, sizeof (f_bhdr)) != sizeof (f_bhdr)) - { - PERROR (new_name); - } return (0); #else /* if not COFF */ --- 604,632 ---- PERROR (new_name); } ! lseek(a_out, sizeof f_hdr + sizeof f_ohdr, 0); ! for (scns = f_hdr.f_nscns; scns > 0; scns--) { ! if (read (a_out, &scntemp, sizeof (scntemp)) != sizeof (scntemp)) ! PERROR (a_name); ! ! if (!strcmp(scntemp.s_name, f_thdr.s_name)) { ! if (write (new, &f_thdr, sizeof (f_thdr)) != sizeof (f_thdr)) ! PERROR (new_name); ! } else if (!strcmp(scntemp.s_name, f_dhdr.s_name)) { ! if (write (new, &f_dhdr, sizeof (f_dhdr)) != sizeof (f_dhdr)) ! PERROR (new_name); ! } else if (!strcmp(scntemp.s_name, f_bhdr.s_name)) { ! if (write (new, &f_bhdr, sizeof (f_bhdr)) != sizeof (f_bhdr)) ! PERROR (new_name); ! } else { ! if (scntemp.s_scnptr) ! scntemp.s_scnptr += bias; ! if (write (new, &scntemp, sizeof (scntemp)) != sizeof (scntemp)) ! PERROR (new_name); ! } ! } return (0); #else /* if not COFF */ *************** *** 680,706 **** } /* **************************************************************** ! * copy_text_and_data * ! * Copy the text and data segments from memory to the new a.out */ static int ! copy_text_and_data (new) ! int new; { register char *end; register char *ptr; #ifdef COFF ! lseek (new, (long) text_scnptr, 0); ! ptr = (char *) f_ohdr.text_start; ! end = ptr + f_ohdr.tsize; ! write_segment (new, ptr, end); ! lseek (new, (long) data_scnptr, 0); ! ptr = (char *) f_ohdr.data_start; ! end = ptr + f_ohdr.dsize; ! write_segment (new, ptr, end); #else /* if not COFF */ --- 691,743 ---- } /* **************************************************************** ! * copy_sections * ! * Copy all sections to the new a.out */ static int ! copy_sections (new, a_out) ! int new, a_out; { register char *end; register char *ptr; + register int scns; + auto struct scnhdr scntemp; /* Temporary section header */ #ifdef COFF ! ! lseek(a_out, sizeof(struct filehdr) + sizeof(struct aouthdr), 0); ! for (scns = f_hdr.f_nscns; scns > 0; scns--) { ! if (read (a_out, &scntemp, sizeof (scntemp)) != sizeof (scntemp)) ! PERROR ("temacs"); ! ! if (!strcmp(scntemp.s_name, ".text")) { ! lseek (new, (long) text_scnptr, 0); ! ptr = (char *) f_ohdr.text_start; ! end = ptr + f_ohdr.tsize; ! write_segment (new, ptr, end); ! } else if (!strcmp(scntemp.s_name, ".data")) { ! lseek (new, (long) data_scnptr, 0); ! ptr = (char *) f_ohdr.data_start; ! end = ptr + f_ohdr.dsize; ! write_segment (new, ptr, end); ! } else if (!scntemp.s_scnptr) ! ; /* do nothing - no data for this section */ ! else { ! char page[BUFSIZ]; ! int size, n; ! int old_a_out_ptr = lseek(a_out, 0, 1); ! ! lseek(a_out, scntemp.s_scnptr, 0); ! for (size = scntemp.s_size; size > 0; size -= sizeof page) { ! n = size > sizeof page ? sizeof page : size; ! if (read(a_out, page, n) != n || write(new, page, n) != n) ! PERROR ("xemacs"); ! } ! lseek(a_out, old_a_out_ptr, 0); ! } ! } #else /* if not COFF */ =================================================================== RCS file: RCS/x11term.c,v retrieving revision 1.1 diff -c -r1.1 x11term.c *** /tmp/,RCSt1a25061 Wed Jan 3 21:12:41 1990 --- x11term.c Wed Jan 3 21:09:01 1990 *************** *** 26,36 **** * $Source: /usr/local/lib/emacs/src/RCS/x11term.c,v $ * $Author: james $ * $Locker: $ ! * $Header: /usr/local/lib/emacs/src/RCS/x11term.c,v 1.1 89/03/07 01:36:23 james Exp $ */ #ifndef lint ! static char *rcsid_xterm_c = "$Header: /usr/local/lib/emacs/src/RCS/x11term.c,v 1.1 89/03/07 01:36:23 james Exp $"; #endif lint /* On 4.3 this loses if it comes after x11term.h. --- 26,36 ---- * $Source: /usr/local/lib/emacs/src/RCS/x11term.c,v $ * $Author: james $ * $Locker: $ ! * $Header: /usr/local/lib/emacs/src/RCS/x11term.c,v 1.2 89/03/07 01:56:50 james Exp $ */ #ifndef lint ! static char *rcsid_xterm_c = "$Header: /usr/local/lib/emacs/src/RCS/x11term.c,v 1.2 89/03/07 01:56:50 james Exp $"; #endif lint /* On 4.3 this loses if it comes after x11term.h. *************** *** 38,50 **** #include <signal.h> #include <sys/ioctl.h> /* Load sys/types.h if not already loaded. In some systems loading it twice is suicidal. */ #ifndef makedev #include <sys/types.h> #endif ! ! #include "config.h" #ifdef HAVE_X_WINDOWS --- 38,52 ---- #include <signal.h> #include <sys/ioctl.h> + #include "config.h" + /* Load sys/types.h if not already loaded. In some systems loading it twice is suicidal. */ #ifndef makedev + #ifndef USG #include <sys/types.h> #endif ! #endif #ifdef HAVE_X_WINDOWS *************** *** 71,77 **** #include "x11term.h" #ifdef USG ! #include <time.h> #else #include <sys/time.h> #endif --- 73,79 ---- #include "x11term.h" #ifdef USG ! /* #include <time.h> */ #else #include <sys/time.h> #endif =================================================================== RCS file: RCS/ymakefile,v retrieving revision 1.1 diff -c -r1.1 ymakefile *** /tmp/,RCSt1a25061 Wed Jan 3 21:12:45 1990 --- ymakefile Wed Jan 3 21:09:03 1990 *************** *** 27,34 **** --- 27,39 ---- cppdir = ../cpp/ #define NO_SHORTNAMES + #define MAKEFILE #include "config.h" + #ifndef LIB_X11_LIB + #define LIB_X11_LIB -lX11 + #endif + /* On some machines #define register is done in config; don't let it interfere with this file. */ #undef register *************** *** 164,173 **** #ifdef X11 #ifdef HAVE_X_MENU XOBJ = x11term.o x11fns.o xmenu.o ! LIBX = -lXMenu -loldX -lX11 LIBX11_MACHINE LIBX11_SYSTEM #else XOBJ = x11term.o x11fns.o ! LIBX = -lX11 LIBX11_MACHINE LIBX11_SYSTEM #endif #else /* not X11 */ #ifdef HAVE_X_MENU --- 169,178 ---- #ifdef X11 #ifdef HAVE_X_MENU XOBJ = x11term.o x11fns.o xmenu.o ! LIBX = -lXMenu -loldX LIB_X11_LIB LIBX11_MACHINE LIBX11_SYSTEM #else XOBJ = x11term.o x11fns.o ! LIBX = LIB_X11_LIB LIBX11_MACHINE LIBX11_SYSTEM #endif #else /* not X11 */ #ifdef HAVE_X_MENU /usr/local/lib/emacs/src> -- James R. Van Artsdalen james@bigtex.cactus.org "Live Free or Die" Dell Computer Co 9505 Arboretum Blvd Austin TX 78759 512-338-8789