summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.in1226
-rw-r--r--src/XTests.c179
-rw-r--r--src/XTests.h7
-rw-r--r--src/convexos.h10
-rw-r--r--src/environ.c316
-rw-r--r--src/m/dos386.h115
-rw-r--r--src/mach2.h48
-rw-r--r--src/old-ralloc.c1069
-rw-r--r--src/sol2-2.h18
-rw-r--r--src/unexelf1.c952
-rw-r--r--src/unexsgi.c900
-rw-r--r--src/x11term.h24
-rw-r--r--src/xscrollbar.h123
-rw-r--r--src/xselect.c.old950
14 files changed, 0 insertions, 5937 deletions
diff --git a/src/Makefile.in b/src/Makefile.in
deleted file mode 100644
index 03faaae332b..00000000000
--- a/src/Makefile.in
+++ /dev/null
@@ -1,1226 +0,0 @@
-# Makefile for GNU Emacs.
-# Copyright (C) 1985, 87, 88, 93, 94, 95, 99, 2000, 2001
-# Free Software Foundation, Inc.
-
-# This file is part of GNU Emacs.
-
-# GNU Emacs is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# GNU Emacs is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with GNU Emacs; see the file COPYING. If not, write to
-# the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-
-# Note that this file is edited by msdos/sed1v2.inp for MSDOS. That
-# script may need modifying in sync with changes made here. Try to
-# avoid shell-ism because the DOS build has to use the DOS shell.
-
-# Don't try to replace the ccp processing using autoconf facilities,
-# says rms.
-
-# Here are the things that we expect ../configure to edit.
-# We use $(srcdir) explicitly in dependencies so as not to depend on VPATH.
-srcdir=@srcdir@
-VPATH=@srcdir@
-CC=@CC@
-CPP=@CPP@
-CFLAGS=@CFLAGS@
-CPPFLAGS=@CPPFLAGS@
-LDFLAGS=@LDFLAGS@
-LN_S=@LN_S@
-# Substitute an assignment for the MAKE variable, because
-# BSD doesn't have it as a default.
-@SET_MAKE@
-# Don't use LIBS. configure puts stuff in it that either shouldn't be
-# linked with Emacs or is duplicated by the cpp stuff below.
-# LIBS = @LIBS@
-LIBOBJS = @LIBOBJS@
-
-# On Xenix and the IBM RS6000, double-dot gets screwed up.
-dot = .
-dotdot = ${dot}${dot}
-lispsource = ${srcdir}/$(dot)$(dot)/lisp/
-libsrc = $(dot)$(dot)/lib-src/
-etc = $(dot)$(dot)/etc/
-oldXMenudir = $(dot)$(dot)/oldXMenu/
-lwlibdir = $(dot)$(dot)/lwlib/
-
-# Configuration files for .o files to depend on.
-M_FILE = ${srcdir}/@machfile@
-S_FILE = ${srcdir}/@opsysfile@
-config_h = config.h $(M_FILE) $(S_FILE)
-
-# ========================== start of cpp stuff =======================
-/* From here on, comments must be done in C syntax. */
-
-C_SWITCH_SYSTEM=
-
-/* just to be sure the sh is used */
-SHELL=/bin/sh
-
-#define THIS_IS_MAKEFILE
-#define NO_SHORTNAMES
-#define NOT_C_CODE
-#include "config.h"
-
-/* We won't really call alloca;
- don't let the file name alloca.c get messed up. */
-#ifdef alloca
-#undef alloca
-#endif
-
-/* Don't let the file name mktime.c get messed up. */
-#ifdef mktime
-#undef mktime
-#endif
-
-/* Use HAVE_X11 as an alias for X11 in this file
- to avoid problems with X11 as a subdirectory name
- in -I and other such options which pass through this file. */
-
-#ifdef X11
-#define HAVE_X11
-#undef X11
-#endif
-
-/* On some machines #define register is done in config;
- don't let it interfere with this file. */
-#undef register
-
-/* On some systems we may not be able to use the system make command. */
-#ifdef MAKE_COMMAND
-MAKE = MAKE_COMMAND
-#endif
-
-#ifdef C_COMPILER
-CC = C_COMPILER
-#endif
-
-/* GNU libc requires ORDINARY_LINK so that its own crt0 is used.
- Linux is an exception because it uses a funny variant of GNU libc. */
-#ifdef __GNU_LIBRARY__
-#ifndef LINUX
-#define ORDINARY_LINK
-#endif
-#endif
-
-/* Some machines don't find the standard C libraries in the usual place. */
-#ifndef ORDINARY_LINK
-#ifndef LIB_STANDARD
-#define LIB_STANDARD -lc
-#endif
-#else
-#ifndef LIB_STANDARD
-#define LIB_STANDARD
-#endif
-#endif
-
-/* Unless inhibited or changed, use -lg to link for debugging. */
-#ifndef LIBS_DEBUG
-#define LIBS_DEBUG -lg
-#endif
-
-/* Some s/SYSTEM.h files define this to request special libraries. */
-#ifndef LIBS_SYSTEM
-#define LIBS_SYSTEM
-#endif
-
-/* Some m/MACHINE.h files define this to request special libraries. */
-#ifndef LIBS_MACHINE
-#define LIBS_MACHINE
-#endif
-
-#ifndef LIB_MATH
-# define LIB_MATH -lm
-#endif /* LIB_MATH */
-
-/* Some s/SYSTEM.h files define this to request special switches in ld. */
-#ifndef LD_SWITCH_SYSTEM
-#if !defined (__GNUC__) && (defined(COFF_ENCAPSULATE) || (defined (BSD_SYSTEM) && !defined (COFF)))
-#define LD_SWITCH_SYSTEM -X
-#else /* ! defined(COFF_ENCAPSULATE) || (defined (BSD_SYSTEM) && !defined (COFF)) */
-#define LD_SWITCH_SYSTEM
-#endif /* ! defined(COFF_ENCAPSULATE) || (defined (BSD_SYSTEM) && !defined (COFF)) */
-#endif /* LD_SWITCH_SYSTEM */
-
-/* This holds special options for linking temacs
- that should be used for linking anything else. */
-#ifndef LD_SWITCH_SYSTEM_TEMACS
-#define LD_SWITCH_SYSTEM_TEMACS
-#endif
-
-/* Some m/MACHINE.h files define this to request special switches in ld. */
-#ifndef LD_SWITCH_MACHINE
-#define LD_SWITCH_MACHINE
-#endif
-
-/* This holds special options for linking temacs
- that should be used for linking anything else. */
-#ifndef LD_SWITCH_MACHINE_TEMACS
-#define LD_SWITCH_MACHINE_TEMACS
-#endif
-
-/* Some m/MACHINE.h files define this to request special switches in cc. */
-#ifndef C_SWITCH_MACHINE
-#define C_SWITCH_MACHINE
-#endif
-
-/* Some s/SYSTEM.h files define this to request special switches in cc. */
-#ifndef C_SWITCH_SYSTEM
-#define C_SWITCH_SYSTEM
-#endif
-
-/* These macros are for switches specifically related to X Windows. */
-#ifndef C_SWITCH_X_MACHINE
-#define C_SWITCH_X_MACHINE
-#endif
-
-#ifndef C_SWITCH_X_SYSTEM
-#define C_SWITCH_X_SYSTEM
-#endif
-
-#ifndef C_SWITCH_X_SITE
-#define C_SWITCH_X_SITE
-#endif
-
-#ifndef LD_SWITCH_X_SITE
-#define LD_SWITCH_X_SITE
-#endif
-
-#ifndef LD_SWITCH_X_DEFAULT
-#define LD_SWITCH_X_DEFAULT
-#endif
-
-/* These can be passed in from config.h to define special load and
- compile switches needed by individual sites */
-#ifndef LD_SWITCH_SITE
-#define LD_SWITCH_SITE
-#endif
-
-#ifndef C_SWITCH_SITE
-#define C_SWITCH_SITE
-#endif
-
-#ifndef ORDINARY_LINK
-
-#ifndef CRT0_COMPILE
-#define CRT0_COMPILE $(CC) -c $(ALL_CFLAGS) C_SWITCH_ASM
-#endif
-
-#ifndef START_FILES
-#ifdef NO_REMAP
-#ifdef COFF_ENCAPSULATE
-#define START_FILES pre-crt0.o /usr/local/lib/gcc-crt0.o
-#else /* ! defined (COFF_ENCAPSULATE) */
-#define START_FILES pre-crt0.o /lib/crt0.o
-#endif /* ! defined (COFF_ENCAPSULATE) */
-#else /* ! defined (NO_REMAP) */
-#define START_FILES ecrt0.o
-#endif /* ! defined (NO_REMAP) */
-#endif /* START_FILES */
-STARTFILES = START_FILES
-
-#else /* ORDINARY_LINK */
-
-/* config.h might want to force START_FILES anyway */
-#ifdef START_FILES
-STARTFILES = START_FILES
-#endif /* START_FILES */
-
-#endif /* not ORDINARY_LINK */
-
-
-/* cc switches needed to make `asm' keyword work.
- Nothing special needed on most machines. */
-#ifndef C_SWITCH_ASM
-#define C_SWITCH_ASM
-#endif
-
-#ifdef USE_X_TOOLKIT
-#define USE_@X_TOOLKIT_TYPE@
-TOOLKIT_DEFINES = -DUSE_@X_TOOLKIT_TYPE@
-#else
-TOOLKIT_DEFINES =
-#endif
-
-/* DO NOT use -R. There is a special hack described in lastfile.c
- which is used instead. Some initialized data areas are modified
- at initial startup, then labeled as part of the text area when
- Emacs is dumped for the first time, and never changed again. */
-
-/* -Demacs is needed to make some files produce the correct version
- for use in Emacs.
-
- -DHAVE_CONFIG_H is needed for some other files to take advantage of
- the information in `config.h'. */
-
-/* C_SWITCH_X_SITE must come before C_SWITCH_X_MACHINE and C_SWITCH_X_SYSTEM
- since it may have -I options that should override those two. */
-ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(TOOLKIT_DEFINES) $(MYCPPFLAG) -I. -I${srcdir} C_SWITCH_MACHINE C_SWITCH_SYSTEM C_SWITCH_SITE C_SWITCH_X_SITE C_SWITCH_X_MACHINE C_SWITCH_X_SYSTEM ${CFLAGS}
-.c.o:
- $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
-
-#ifndef LIBX10_MACHINE
-#define LIBX10_MACHINE
-#endif
-
-#ifndef LIBX11_MACHINE
-#define LIBX11_MACHINE
-#endif
-
-#ifndef LIBX10_SYSTEM
-#define LIBX10_SYSTEM
-#endif
-
-#ifndef LIBX11_SYSTEM
-#define LIBX11_SYSTEM
-#endif
-
-#ifndef LIB_X11_LIB
-#define LIB_X11_LIB -lX11
-#endif
-
-#ifdef HAVE_X_WINDOWS
-#ifdef HAVE_MENUS
-
-/* Include xmenu.o in the list of X object files. */
-XOBJ= xterm.o xfns.o xselect.o xrdb.o fontset.o
-
-/* The X Menu stuff is present in the X10 distribution, but missing
- from X11. If we have X10, just use the installed library;
- otherwise, use our own copy. */
-#ifdef HAVE_X11
-#ifdef USE_X_TOOLKIT
-OLDXMENU=${lwlibdir}liblw.a
-LIBXMENU= $(OLDXMENU)
-#else /* not USE_X_TOOLKIT */
-OLDXMENU= ${oldXMenudir}libXMenu11.a
-LIBXMENU= $(OLDXMENU)
-#endif /* not USE_X_TOOLKIT */
-#else /* not HAVE_X11 */
-LIBXMENU= -lXMenu
-#endif /* not HAVE_X11 */
-
-#else /* not HAVE_MENUS */
-
-/* Otherwise, omit xmenu.o from the list of X object files, and
- don't worry about the menu library at all. */
-XOBJ= xterm.o xfns.o xselect.o xrdb.o fontset.o
-LIBXMENU=
-#endif /* not HAVE_MENUS */
-
-#ifdef USE_X_TOOLKIT
-#define @X_TOOLKIT_TYPE@
-#if defined (LUCID) || defined (ATHENA)
-#if HAVE_XAW3D
-LIBW= -lXaw3d
-#else
-LIBW= -lXaw
-#endif
-#endif
-#ifdef MOTIF
-#if defined (HAVE_MOTIF_2_1) && defined (HAVE_LIBXP)
-#define LIB_MOTIF_EXTRA -lXp
-#else
-#define LIB_MOTIF_EXTRA
-#endif
-#ifdef LIB_MOTIF
-LIBW= LIB_MOTIF LIB_MOTIF_EXTRA
-#else
-LIBW= -lXm LIB_MOTIF_EXTRA
-#endif
-#endif
-#ifdef OPEN_LOOK
-LIBW= -lXol
-#endif
-
-#ifdef HAVE_X11XTR6
-#ifdef NEED_LIBW
-LIBXTR6 = -lSM -lICE -lw
-#else
-LIBXTR6 = -lSM -lICE
-#endif
-#endif
-
-#ifndef LIBXMU
-#define LIBXMU -lXmu
-#endif
-
-#ifdef LIBXT_STATIC
-/* We assume the config files have defined STATIC_OPTION
- since that might depend on the operating system.
- (Don't forget you need different definitions with and without __GNUC__.) */
-LIBXT= STATIC_OPTION $(LIBW) LIBXMU -lXt $(LIBXTR6) -lXext DYNAMIC_OPTION
-#else /* not LIBXT_STATIC */
-LIBXT= $(LIBW) LIBXMU -lXt $(LIBXTR6) -lXext
-#endif /* not LIBXT_STATIC */
-
-#else /* not USE_X_TOOLKIT */
-LIBXT=
-#endif /* not USE_X_TOOLKIT */
-
-#if HAVE_XPM
-#ifndef LIBXPM
-#define LIBXPM -lXpm
-#endif /* not defined LIBXPM */
-#else /* not HAVE_XPM */
-#define LIBXPM
-#endif /* not HAVE_XPM */
-
-#if HAVE_JPEG
-#ifndef LIBJPEG
-#define LIBJPEG -ljpeg
-#endif /* not defined LIBJPEG */
-#else /* not HAVE_JPEG */
-#define LIBJPEG
-#endif /* not HAVE_JPEG */
-
-#if HAVE_PNG
-#ifndef LIBPNG
-#define LIBPNG -lpng -lz -lm
-#endif /* not defined LIBPNG */
-#else /* not HAVE_PNG */
-#define LIBPNG
-#endif /* not HAVE_PNG */
-
-#if HAVE_TIFF
-#ifndef LIBTIFF
-#define LIBTIFF -ltiff
-#endif /* not defined LIBTIFF */
-#else /* not HAVE_TIFF */
-#define LIBTIFF
-#endif /* not HAVE_TIFF */
-
-#if HAVE_GIF
-#ifndef LIBGIF
-#define LIBGIF -lungif
-#endif /* not defined LIBGIF */
-#else /* not HAVE_GIF */
-#define LIBGIF
-#endif /* not HAVE_GIF */
-
-#ifdef HAVE_X11
-/* LD_SWITCH_X_DEFAULT comes after everything else that specifies
- options for where to find X libraries, but before those libraries. */
-X11_LDFLAGS = LD_SWITCH_X_SITE LD_SWITCH_X_DEFAULT
-LIBX= $(LIBXMENU) $(X11_LDFLAGS) $(LIBXT) LIBTIFF LIBJPEG LIBPNG LIBGIF LIBXPM LIB_X11_LIB LIBX11_MACHINE LIBX11_SYSTEM
-#else /* not HAVE_X11 */
-LIBX= $(LIBXMENU) LD_SWITCH_X_SITE -lX10 LIBX10_MACHINE LIBX10_SYSTEM
-#endif /* not HAVE_X11 */
-#endif /* not HAVE_X_WINDOWS */
-
-LIBSOUND= @LIBSOUND@
-
-#ifndef ORDINARY_LINK
-/* Fix linking if compiled with GCC. */
-#ifdef __GNUC__
-
-#if __GNUC__ > 1
-
-#ifdef LINKER
-#define LINKER_WAS_SPECIFIED
-#endif
-
-/* Versions of GCC >= 2.0 put their library, libgcc.a, in obscure
- places that are difficult to figure out at make time. Fortunately,
- these same versions allow you to pass arbitrary flags on to the
- linker, so there's no reason not to use it as a linker.
-
- Well, it's not quite perfect. The `-nostdlib' keeps GCC from
- searching for libraries in its internal directories, so we have to
- ask GCC explicitly where to find libgcc.a. */
-
-#ifndef LINKER
-#define LINKER $(CC) -nostdlib
-#endif
-
-#ifndef LIB_GCC
-/* Ask GCC where to find libgcc.a. */
-#define LIB_GCC `$(CC) -print-libgcc-file-name`
-#endif /* not LIB_GCC */
-
-GNULIB_VAR = LIB_GCC
-
-#ifndef LINKER_WAS_SPECIFIED
-/* GCC passes any argument prefixed with -Xlinker directly to the
- linker. See prefix-args.c for an explanation of why we don't do
- this with the shell's `for' construct.
- Note that some people don't have '.' in their paths, so we must
- use ./prefix-args. */
-#define YMF_PASS_LDFLAGS(flags) `./prefix-args -Xlinker flags`
-#else
-#define YMF_PASS_LDFLAGS(flags) flags
-#endif
-
-#else /* __GNUC__ < 2 */
-
-#ifndef LIB_GCC
-#define LIB_GCC /usr/local/lib/gcc-gnulib
-#endif /* not LIB_GCC */
-GNULIB_VAR = `if [ -f LIB_GCC ] ; then echo LIB_GCC; else echo; fi`
-#endif /* __GNUC__ < 2 */
-#else /* not __GNUC__ */
-GNULIB_VAR =
-
-#endif /* not __GNUC__ */
-#endif /* not ORDINARY_LINK */
-
-/* Specify address for ld to start loading at,
- if requested by configuration. */
-#ifdef LD_TEXT_START_ADDR
-STARTFLAGS = -T LD_TEXT_START_ADDR -e __start
-#endif
-
-#ifdef ORDINARY_LINK
-LD = $(CC)
-#else
-#ifdef COFF_ENCAPSULATE
-LD=$(CC) -nostdlib
-#else /* not ORDINARY_LINK */
-#ifdef LINKER
-LD=LINKER
-#else /* not LINKER */
-LD=ld
-#endif /* not LINKER */
-#endif /* not COFF_ENCAPSULATE */
-#endif /* not ORDINARY_LINK */
-
-ALL_LDFLAGS = LD_SWITCH_SYSTEM LD_SWITCH_SYSTEM_TEMACS LD_SWITCH_MACHINE \
- LD_SWITCH_MACHINE_TEMACS LD_SWITCH_SITE $(LDFLAGS)
-
-/* A macro which other sections of Makefile can redefine to munge the
- flags before they're passed to LD. This is helpful if you have
- redefined LD to something odd, like "gcc".
- (The YMF prefix is a holdover from the old name "ymakefile".)
- */
-#ifndef YMF_PASS_LDFLAGS
-#define YMF_PASS_LDFLAGS(flags) flags
-#endif
-
-/* Allow config.h to specify a replacement file for unexec.c. */
-#ifndef UNEXEC
-#define UNEXEC unexec.o
-#endif
-#ifndef UNEXEC_SRC
-#define UNEXEC_SRC unexec.c
-#endif
-
-INTERVAL_SRC = intervals.h composite.h
-
-GETLOADAVG_LIBS = @GETLOADAVG_LIBS@
-
-#ifdef MSDOS
-#ifdef HAVE_X_WINDOWS
-MSDOS_OBJ = dosfns.o msdos.o
-#else
-MSDOS_OBJ = dosfns.o msdos.o w16select.o
-#endif
-#endif
-
-
-/* lastfile must follow all files
- whose initialized data areas should be dumped as pure by dump-emacs. */
-obj= dispnew.o frame.o scroll.o xdisp.o xmenu.o window.o \
- charset.o coding.o category.o ccl.o\
- cm.o term.o xfaces.o $(XOBJ) \
- emacs.o keyboard.o macros.o keymap.o sysdep.o \
- buffer.o filelock.o insdel.o marker.o \
- minibuf.o fileio.o dired.o filemode.o \
- cmds.o casetab.o casefiddle.o indent.o search.o regex.o undo.o \
- alloc.o data.o doc.o editfns.o callint.o \
- eval.o floatfns.o fns.o print.o lread.o \
- abbrev.o syntax.o UNEXEC mocklisp.o bytecode.o \
- process.o callproc.o \
- region-cache.o sound.o atimer.o \
- doprnt.o strftime.o intervals.o textprop.o composite.o md5.o \
- $(MSDOS_OBJ)
-
-/* Object files used on some machine or other.
- These go in the DOC file on all machines
- in case they are needed there. */
-SOME_MACHINE_OBJECTS = sunfns.o dosfns.o msdos.o \
- xterm.o xfns.o xmenu.o xselect.o xrdb.o
-
-
-#ifdef TERMINFO
-/* Used to be -ltermcap here. If your machine needs that,
- define LIBS_TERMCAP in the m/MACHINE.h file. */
-#ifndef LIBS_TERMCAP
-#define LIBS_TERMCAP -lcurses
-#endif /* LIBS_TERMCAP */
-termcapobj = terminfo.o
-#else /* ! defined (TERMINFO) */
-#ifndef LIBS_TERMCAP
-#define LIBS_TERMCAP
-termcapobj = termcap.o tparam.o
-#else /* LIBS_TERMCAP */
-termcapobj = tparam.o
-#endif /* LIBS_TERMCAP */
-#endif /* ! defined (TERMINFO) */
-
-
-#ifndef SYSTEM_MALLOC
-
-#ifdef DOUG_LEA_MALLOC
-#ifdef REL_ALLOC
-mallocobj = ralloc.o vm-limit.o
-#else /* ! defined (REL_ALLOC) */
-mallocobj = vm-limit.o
-#endif /* ! defined (REL_ALLOC) */
-#else /* ! defined (DOUG_LEA_MALLOC) */
-#ifdef REL_ALLOC
-mallocobj = gmalloc.o ralloc.o vm-limit.o
-#else /* ! defined (REL_ALLOC) */
-mallocobj = gmalloc.o vm-limit.o
-#endif /* ! defined (REL_ALLOC) */
-#endif /* ! defined (DOUG_LEA_MALLOC) */
-
-#endif /* SYSTEM_MALLOC */
-
-
-#ifndef HAVE_ALLOCA
-allocaobj = alloca.o
-#else
-allocaobj =
-#endif
-
-#ifdef USE_X_TOOLKIT
-widgetobj= widget.o
-#else /* not USE_X_TOOLKIT */
-widgetobj=
-#endif /* not USE_X_TOOLKIT */
-
-
-/* define otherobj as list of object files that make-docfile
- should not be told about. */
-otherobj= $(termcapobj) lastfile.o $(mallocobj) $(allocaobj) $(widgetobj) $(LIBOBJS)
-
-#ifdef HAVE_MOUSE
-#define MOUSE_SUPPORT ${lispsource}mouse.elc \
- ${lispsource}select.elc ${lispsource}scroll-bar.elc
-#else
-#define MOUSE_SUPPORT
-#endif
-
-#ifdef VMS
-#define VMS_SUPPORT ${lispsource}vmsproc.elc ${lispsource}vms-patch.elc
-#else
-#define VMS_SUPPORT
-#endif
-
-#ifdef MSDOS
-#define MSDOS_SUPPORT ${lispsource}ls-lisp.elc ${lispsource}disp-table.elc \
- ${lispsource}dos-fns.elc ${lispsource}dos-w32.elc ${lispsource}dos-vars.elc \
- ${lispsource}international/ccl.elc ${lispsource}international/codepage.elc
-
-#else
-#define MSDOS_SUPPORT
-#endif
-
-#ifdef WINDOWSNT
-#define WINNT_SUPPORT ${lispsource}ls-lisp.elc ${lispsource}w32-fns.elc \
- ${lispsource}dos-w32.elc
-#else
-#define WINNT_SUPPORT
-#endif
-
-/* List of Lisp files loaded into the dumped Emacs. It's arranged
- like this because it's easier to generate it semi-mechanically from
- loadup.el this way.
-
- Note that this list should not include lisp files which might not
- be present, like site-load.el and site-init.el; this makefile
- expects them all to be either present or buildable.
-
- Files which are loaded unconditionally should be in shortlisp as well.
- Files included conditionally here should be included (unconditionally)
- in SOME_MACHINE_LISP. */
-
-lisp= \
- ${lispsource}abbrev.elc \
- ${lispsource}buff-menu.elc \
- ${lispsource}byte-run.elc \
- ${lispsource}cus-start.el \
- ${lispsource}custom.elc \
- ${lispsource}emacs-lisp/lisp-mode.elc \
- ${lispsource}emacs-lisp/lisp.elc \
- ${lispsource}env.elc \
- ${lispsource}faces.elc \
- ${lispsource}files.elc \
- ${lispsource}format.elc \
- ${lispsource}facemenu.elc \
- MOUSE_SUPPORT \
- ${lispsource}float-sup.elc \
- ${lispsource}frame.elc\
- ${lispsource}help.elc \
- ${lispsource}indent.elc \
- ${lispsource}isearch.elc \
- ${lispsource}loadup.el \
- ${lispsource}loaddefs.el \
- ${lispsource}bindings.el \
- ${lispsource}map-ynp.elc \
- ${lispsource}menu-bar.elc \
- ${lispsource}international/mule.elc \
- ${lispsource}international/mule-conf.el \
- ${lispsource}international/mule-cmds.elc \
- ${lispsource}international/characters.elc \
- ${lispsource}international/utf-8.elc \
- ${lispsource}case-table.elc \
- ${lispsource}language/chinese.elc \
- ${lispsource}language/cyrillic.elc \
- ${lispsource}language/indian.elc \
- ${lispsource}language/devanagari.elc \
- ${lispsource}language/english.elc \
- ${lispsource}language/ethiopic.elc \
- ${lispsource}language/european.elc \
- ${lispsource}language/czech.elc \
- ${lispsource}language/slovak.elc \
- ${lispsource}language/romanian.elc \
- ${lispsource}language/greek.elc \
- ${lispsource}language/hebrew.elc \
- ${lispsource}language/japanese.elc \
- ${lispsource}language/korean.elc \
- ${lispsource}language/lao.elc \
- ${lispsource}language/thai.elc \
- ${lispsource}language/tibetan.elc \
- ${lispsource}language/vietnamese.elc \
- ${lispsource}language/misc-lang.elc \
- ${lispsource}paths.el \
- ${lispsource}register.elc \
- ${lispsource}replace.elc \
- ${lispsource}simple.elc \
- ${lispsource}startup.elc \
- ${lispsource}subr.elc \
- ${lispsource}term/tty-colors.elc \
- ${lispsource}textmodes/fill.elc \
- ${lispsource}textmodes/page.elc \
- ${lispsource}textmodes/paragraphs.elc \
- ${lispsource}textmodes/text-mode.elc \
- ${lispsource}vc-hooks.elc \
- ${lispsource}ediff-hook.elc \
- VMS_SUPPORT \
- MSDOS_SUPPORT \
- WINNT_SUPPORT \
- ${lispsource}widget.elc \
- ${lispsource}window.elc \
- ${lispsource}version.el
-
-/* These are relative file names for the Lisp files
- that are loaded unconditionally. This is used in make-docfile.
- It need not contain the files that are loaded conditionally
- because SOME_MACHINE_LISP has those. */
-shortlisp= \
- ../lisp/abbrev.elc \
- ../lisp/buff-menu.elc \
- ../lisp/byte-run.elc \
- ../lisp/cus-start.el \
- ../lisp/custom.elc \
- ../lisp/emacs-lisp/lisp-mode.elc \
- ../lisp/emacs-lisp/lisp.elc \
- ../lisp/facemenu.elc \
- ../lisp/faces.elc \
- ../lisp/files.elc \
- ../lisp/float-sup.elc \
- ../lisp/format.elc \
- ../lisp/frame.elc \
- ../lisp/help.elc \
- ../lisp/indent.elc \
- ../lisp/isearch.elc \
- ../lisp/loadup.el \
- ../lisp/loaddefs.el \
- ../lisp/bindings.el \
- ../lisp/map-ynp.elc \
- ../lisp/international/mule.elc \
- ../lisp/international/mule-conf.el \
- ../lisp/international/mule-cmds.elc \
- ../lisp/international/characters.elc \
- ../lisp/case-table.elc \
- ../lisp/language/chinese.elc \
- ../lisp/language/cyrillic.elc \
- ../lisp/language/indian.elc \
- ../lisp/language/devanagari.elc \
- ../lisp/language/english.elc \
- ../lisp/language/ethiopic.elc \
- ../lisp/language/european.elc \
- ../lisp/language/czech.elc \
- ../lisp/language/slovak.elc \
- ../lisp/language/romanian.elc \
- ../lisp/language/greek.elc \
- ../lisp/language/hebrew.elc \
- ../lisp/language/japanese.elc \
- ../lisp/language/korean.elc \
- ../lisp/language/lao.elc \
- ../lisp/language/thai.elc \
- ../lisp/language/tibetan.elc \
- ../lisp/language/vietnamese.elc \
- ../lisp/language/misc-lang.elc \
- ../lisp/paths.el \
- ../lisp/register.elc \
- ../lisp/replace.elc \
- ../lisp/simple.elc \
- ../lisp/startup.elc \
- ../lisp/subr.elc \
- ../lisp/term/tty-colors.elc \
- ../lisp/textmodes/fill.elc \
- ../lisp/textmodes/page.elc \
- ../lisp/textmodes/paragraphs.elc \
- ../lisp/textmodes/text-mode.elc \
- ../lisp/vc-hooks.elc \
- ../lisp/ediff-hook.elc \
- ../lisp/widget.elc \
- ../lisp/window.elc \
- ../lisp/version.el
-
-/* Lisp files that may or may not be used.
- We must unconditionally put them in the DOC file.
- We use ../lisp/ to start the file names
- to reduce the size of the argument list for make-docfile
- for the sake of systems which can't handle large ones. */
-SOME_MACHINE_LISP = ${dotdot}/lisp/menu-bar.elc ${dotdot}/lisp/mouse.elc \
- ${dotdot}/lisp/select.elc ${dotdot}/lisp/scroll-bar.elc \
- ${dotdot}/lisp/vmsproc.elc ${dotdot}/lisp/vms-patch.elc \
- ${dotdot}/lisp/ls-lisp.elc ${dotdot}/lisp/dos-fns.elc \
- ${dotdot}/lisp/w32-fns.elc ${dotdot}/lisp/dos-w32.elc \
- ${dotdot}/lisp/disp-table.elc ${dotdot}/lisp/dos-vars.elc \
- ${dotdot}/lisp/international/ccl.elc \
- ${dotdot}/lisp/international/codepage.elc
-
-/* Construct full set of libraries to be linked.
- Note that SunOS needs -lm to come before -lc; otherwise, you get
- duplicated symbols. If the standard libraries were compiled
- with GCC, we might need gnulib again after them. */
-LIBES = $(LOADLIBES) $(LIBS) $(LIBX) $(LIBSOUND) \
- LIBS_SYSTEM LIBS_MACHINE LIBS_TERMCAP \
- LIBS_DEBUG $(GETLOADAVG_LIBS) $(GNULIB_VAR) LIB_MATH LIB_STANDARD \
- $(GNULIB_VAR)
-
-/* Enable recompilation of certain other files depending on system type. */
-
-#ifndef OTHER_FILES
-#define OTHER_FILES
-#endif
-
-#ifndef OBJECTS_MACHINE
-#define OBJECTS_MACHINE
-#endif
-
-all: emacs OTHER_FILES
-
-emacs: temacs ${etc}DOC ${lisp}
-#ifdef CANNOT_DUMP
- rm -f emacs
- ln temacs emacs
-#else
-#ifdef HAVE_SHM
- LC_ALL=C ./temacs -nl -batch -l loadup dump
-#else /* ! defined (HAVE_SHM) */
- LC_ALL=C ./temacs -batch -l loadup dump
-#endif /* ! defined (HAVE_SHM) */
-#endif /* ! defined (CANNOT_DUMP) */
- -./emacs -q -batch -f list-load-path-shadows
-
-/* We run make-docfile twice because the command line may get too long
- on some systems. */
-/* ${SOME_MACHINE_OBJECTS} comes before ${obj} because some files may
- or may not be included in ${obj}, but they are always included in
- ${SOME_MACHINE_OBJECTS}. Since a file is processed when it is mentioned
- for the first time, this prevents any variation between configurations
- in the contents of the DOC file.
- Likewise for ${SOME_MACHINE_LISP}. */
-${etc}DOC: ${libsrc}make-docfile ${obj} ${shortlisp} ${SOME_MACHINE_LISP}
- -rm -f ${etc}DOC
- ${libsrc}make-docfile -d ${srcdir} ${SOME_MACHINE_OBJECTS} ${obj} > ${etc}DOC
- ${libsrc}make-docfile -a ${etc}DOC -d ${srcdir} ${SOME_MACHINE_LISP} ${shortlisp}
-
-${libsrc}make-docfile:
- cd ${libsrc}; ${MAKE} ${MFLAGS} make-docfile
-
-/* Some systems define this to cause parallel Make-ing. */
-#ifndef MAKE_PARALLEL
-#define MAKE_PARALLEL
-#endif
-
-temacs: MAKE_PARALLEL $(LOCALCPP) $(STARTFILES) stamp-oldxmenu ${obj} ${otherobj} OBJECTS_MACHINE prefix-args
- $(LD) YMF_PASS_LDFLAGS (${STARTFLAGS} ${ALL_LDFLAGS}) \
- -o temacs ${STARTFILES} ${obj} ${otherobj} \
- OBJECTS_MACHINE ${LIBES}
-
-/* We don't use ALL_LDFLAGS because LD_SWITCH_SYSTEM and LD_SWITCH_MACHINE
- often contain options that have to do with using Emacs's crt0,
- which are only good with temacs. */
-prefix-args: prefix-args.c $(config_h)
- $(CC) $(ALL_CFLAGS) $(LDFLAGS) ${srcdir}/prefix-args.c -o prefix-args
-
-/* Don't lose if this was not defined. */
-#ifndef OLDXMENU_OPTIONS
-#define OLDXMENU_OPTIONS
-#endif
-
-/* Don't lose if this was not defined. */
-#ifndef LWLIB_OPTIONS
-#define LWLIB_OPTIONS
-#endif
-
-#if defined (HAVE_X_WINDOWS) && defined (HAVE_X11) && defined (HAVE_MENUS)
-
-/* We use stamp-xmenu with these two deps
- to both ensure that lwlib gets remade based on its dependencies
- in its own makefile,
- and remake temacs if lwlib gets changed by this. */
-stamp-oldxmenu: ${OLDXMENU} ../src/$(OLDXMENU)
- touch stamp-oldxmenu
-/* Supply an ordering for parallel make. */
-../src/$(OLDXMENU): ${OLDXMENU}
-
-#ifdef USE_X_TOOLKIT
-$(OLDXMENU): really-lwlib
-
-/* Encode the values of these two macros in Make variables,
- so we can use $(...) to substitute their values within "...". */
-C_SWITCH_MACHINE_1 = C_SWITCH_MACHINE
-C_SWITCH_SYSTEM_1 = C_SWITCH_SYSTEM
-C_SWITCH_SITE_1 = C_SWITCH_SITE
-C_SWITCH_X_SITE_1 = C_SWITCH_X_SITE
-C_SWITCH_X_MACHINE_1 = C_SWITCH_X_MACHINE
-C_SWITCH_X_SYSTEM_1 = C_SWITCH_X_SYSTEM
-really-lwlib:
- cd ${lwlibdir}; ${MAKE} ${MFLAGS} LWLIB_OPTIONS \
- CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}' \
- "C_SWITCH_X_SITE=$(C_SWITCH_X_SITE_1)" \
- "C_SWITCH_X_MACHINE=$(C_SWITCH_X_MACHINE_1)" \
- "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)" \
- "C_SWITCH_SITE=$(C_SWITCH_SITE_1)" \
- "C_SWITCH_MACHINE=$(C_SWITCH_MACHINE_1)" \
- "C_SWITCH_SYSTEM=$(C_SWITCH_SYSTEM_1)"
- @true /* make -t should not create really-lwlib. */
-.PHONY: really-lwlib
-#else /* not USE_X_TOOLKIT */
-$(OLDXMENU): really-oldXMenu
-
-/* Encode the values of these two macros in Make variables,
- so we can use $(...) to substitute their values within "...". */
-C_SWITCH_MACHINE_1 = C_SWITCH_MACHINE
-C_SWITCH_SYSTEM_1 = C_SWITCH_SYSTEM
-C_SWITCH_SITE_1 = C_SWITCH_SITE
-C_SWITCH_X_SITE_1 = C_SWITCH_X_SITE
-C_SWITCH_X_MACHINE_1 = C_SWITCH_X_MACHINE
-C_SWITCH_X_SYSTEM_1 = C_SWITCH_X_SYSTEM
-really-oldXMenu:
- cd ${oldXMenudir}; ${MAKE} ${MFLAGS} OLDXMENU_OPTIONS \
- CC='${CC}' CFLAGS='${CFLAGS}' MAKE='${MAKE}' \
- "C_SWITCH_X_SITE=$(C_SWITCH_X_SITE_1)" \
- "C_SWITCH_X_MACHINE=$(C_SWITCH_X_MACHINE_1)" \
- "C_SWITCH_X_SYSTEM=$(C_SWITCH_X_SYSTEM_1)" \
- "C_SWITCH_SITE=$(C_SWITCH_SITE_1)" \
- "C_SWITCH_MACHINE=$(C_SWITCH_MACHINE_1)" \
- "C_SWITCH_SYSTEM=$(C_SWITCH_SYSTEM_1)"
- @true /* make -t should not create really-oldXMenu. */
-.PHONY: really-oldXMenu
-#endif /* not USE_X_TOOLKIT */
-#else /* not (HAVE_X_WINDOWS && HAVE_X11 && HAVE_MENUS) */
-
-/* We don't really need this, but satisfy the dependency. */
-stamp-oldxmenu:
- touch stamp-oldxmenu
-#endif /* not (HAVE_X_WINDOWS && HAVE_X11 && HAVE_MENUS) */
-
-../config.status:: epaths.in
- @echo "The file epaths.h needs to be set up from epaths.in."
- @echo "Please run the `configure' script again."
- exit 1
-
-../config.status:: config.in
- @echo "The file config.h needs to be set up from config.in."
- @echo "Please run the `configure' script again."
- exit 1
-
-/* Some machines have alloca built-in.
- They should define HAVE_ALLOCA, or may just let alloca.s
- be used but generate no code.
- Some have it written in assembler in alloca.s.
- Some use the C version in alloca.c (these define C_ALLOCA in config.h).
- */
-
-#ifdef C_ALLOCA
-/* We could put something in alloca.c to #define free and malloc
- whenever emacs was #defined, but that's not appropriate for all
- users of alloca in Emacs. Check out ../lib-src/getopt.c. */
-alloca.o : alloca.c
- $(CC) -c $(CPPFLAGS) -DEMACS_FREE=xfree \
- $(ALL_CFLAGS) ${srcdir}/alloca.c
-#else
-#ifndef HAVE_ALLOCA
-alloca.o : alloca.s $(config_h)
-/* $(CPP) is cc -E, which may get confused by filenames
- that do not end in .c. So copy file to a safe name. */
- -rm -f allocatem.c
- cp ${srcdir}/alloca.s allocatem.c
-/* Remove any ^L, blank lines, and preprocessor comments,
- since some assemblers barf on them. Use a different basename for the
- output file, since some stupid compilers (Green Hill's) use that
- name for the intermediate assembler file. */
- $(CPP) $(CPPFLAGS) $(ALL_CFLAGS) allocatem.c | \
- sed -e 's/ //' -e 's/^#.*//' | \
- sed -n -e '/^..*$$/p' > allocax.s
- -rm -f alloca.o
-/* Xenix, in particular, needs to run assembler via cc. */
- $(CC) -c allocax.s
- mv allocax.o alloca.o
- -rm -f allocax.s allocatem.c
-#endif /* HAVE_ALLOCA */
-#endif /* ! defined (C_ALLOCA) */
-
-/* Nearly all the following files depend on lisp.h,
- but it is not included as a dependency because
- it is so often changed in ways that do not require any recompilation
- and so rarely changed in ways that do require any. */
-
-abbrev.o: abbrev.c buffer.h window.h dispextern.h commands.h charset.h \
- $(config_h)
-buffer.o: buffer.c buffer.h region-cache.h commands.h window.h \
- dispextern.h $(INTERVAL_SRC) blockinput.h atimer.h systime.h charset.h \
- $(config_h)
-callint.o: callint.c window.h commands.h buffer.h mocklisp.h \
- keyboard.h dispextern.h $(config_h)
-callproc.o: callproc.c epaths.h buffer.h commands.h $(config_h) \
- process.h systty.h syssignal.h charset.h coding.h ccl.h msdos.h \
- composite.h
-casefiddle.o: casefiddle.c syntax.h commands.h buffer.h composite.h $(config_h)
-casetab.o: casetab.c buffer.h $(config_h)
-category.o: category.c category.h buffer.h charset.h $(config_h)
-ccl.o: ccl.c ccl.h charset.h coding.h $(config_h)
-charset.o: charset.c charset.h buffer.h coding.h composite.h disptab.h \
- $(config_h)
-coding.o: coding.c coding.h ccl.h buffer.h charset.h $(config_h)
-cm.o: cm.c cm.h termhooks.h $(config_h)
-cmds.o: cmds.c syntax.h buffer.h charset.h commands.h window.h $(config_h) \
- msdos.h dispextern.h
-pre-crt0.o: pre-crt0.c
-ecrt0.o: ecrt0.c $(config_h)
- CRT0_COMPILE ${srcdir}/ecrt0.c
-dired.o: dired.c commands.h buffer.h $(config_h) charset.h coding.h regex.h \
- systime.h
-dispnew.o: dispnew.c commands.h frame.h window.h buffer.h dispextern.h \
- termchar.h termopts.h termhooks.h cm.h disptab.h systty.h systime.h \
- xterm.h blockinput.h atimer.h charset.h msdos.h composite.h keyboard.h \
- $(config_h)
-doc.o: doc.c $(config_h) epaths.h buffer.h keyboard.h charset.h
-doprnt.o: doprnt.c charset.h $(config_h)
-dosfns.o: buffer.h termchar.h termhooks.h frame.h msdos.h dosfns.h $(config_h)
-editfns.o: editfns.c window.h buffer.h systime.h $(INTERVAL_SRC) charset.h \
- coding.h dispextern.h $(config_h)
-emacs.o: emacs.c commands.h systty.h syssignal.h blockinput.h process.h \
- termhooks.h buffer.h atimer.h systime.h $(INTERVAL_SRC) $(config_h)
-fileio.o: fileio.c window.h buffer.h systime.h $(INTERVAL_SRC) charset.h \
- coding.h ccl.h msdos.h dispextern.h $(config_h)
-filelock.o: filelock.c buffer.h systime.h epaths.h $(config_h)
-filemode.o: filemode.c $(config_h)
-frame.o: frame.c xterm.h window.h frame.h termhooks.h commands.h keyboard.h \
- buffer.h charset.h fontset.h msdos.h dosfns.h dispextern.h $(config_h)
-fontset.o: dispextern.h fontset.h fontset.c ccl.h charset.h frame.h \
- keyboard.h $(config_h)
-getloadavg.o: getloadavg.c $(config_h)
-indent.o: indent.c frame.h window.h indent.h buffer.h $(config_h) termchar.h \
- termopts.h disptab.h region-cache.h charset.h composite.h dispextern.h \
- keyboard.h
-insdel.o: insdel.c window.h buffer.h $(INTERVAL_SRC) blockinput.h charset.h\
- dispextern.h atimer.h systime.h $(config_h)
-keyboard.o: keyboard.c termchar.h termhooks.h termopts.h buffer.h charset.h \
- commands.h frame.h window.h macros.h disptab.h keyboard.h syssignal.h \
- systty.h systime.h dispextern.h syntax.h $(INTERVAL_SRC) blockinput.h \
- atimer.h xterm.h puresize.h msdos.h $(config_h)
-keymap.o: keymap.c buffer.h commands.h keyboard.h termhooks.h blockinput.h \
- atimer.h systime.h puresize.h charset.h intervals.h $(config_h)
-lastfile.o: lastfile.c $(config_h)
-macros.o: macros.c window.h buffer.h commands.h macros.h keyboard.h \
- dispextern.h $(config_h)
-malloc.o: malloc.c $(config_h)
-gmalloc.o: gmalloc.c $(config_h)
-ralloc.o: ralloc.c $(config_h)
-vm-limit.o: vm-limit.c mem-limits.h $(config_h)
-marker.o: marker.c buffer.h charset.h $(config_h)
-minibuf.o: minibuf.c syntax.h dispextern.h frame.h window.h keyboard.h \
- buffer.h commands.h charset.h msdos.h $(config_h)
-mktime.o: mktime.c $(config_h)
-mocklisp.o: mocklisp.c buffer.h $(config_h)
-msdos.o: msdos.c msdos.h dosfns.h systime.h termhooks.h dispextern.h frame.h \
- termopts.h termchar.h charset.h coding.h ccl.h disptab.h window.h \
- keyboard.h $(config_h)
-process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \
- commands.h syssignal.h systime.h systty.h syswait.h frame.h dispextern.h \
- blockinput.h atimer.h charset.h coding.h ccl.h msdos.h composite.h \
- keyboard.h $(config_h)
-regex.o: regex.c syntax.h buffer.h $(config_h) regex.h category.h charset.h
-region-cache.o: region-cache.c buffer.h region-cache.h
-scroll.o: scroll.c termchar.h dispextern.h frame.h msdos.h keyboard.h \
- $(config_h)
-search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \
- blockinput.h atimer.h systime.h category.h charset.h composite.h $(config_h)
-strftime.o: strftime.c $(config_h)
-syntax.o: syntax.c syntax.h buffer.h commands.h category.h charset.h \
- composite.h $(config_h)
-sysdep.o: sysdep.c $(config_h) dispextern.h termhooks.h termchar.h termopts.h \
- frame.h syssignal.h systty.h systime.h syswait.h blockinput.h atimer.h \
- window.h msdos.h dosfns.h keyboard.h
-term.o: term.c termchar.h termhooks.h termopts.h $(config_h) cm.h frame.h \
- disptab.h dispextern.h keyboard.h charset.h coding.h ccl.h msdos.h
-termcap.o: termcap.c $(config_h)
-terminfo.o: terminfo.c $(config_h)
-tparam.o: tparam.c $(config_h)
-undo.o: undo.c buffer.h commands.h $(config_h)
-/* This hack is to discard any space that cpp might put at the beginning
- of UNEXEC when substituting it in. */
-UNEXEC_ALIAS=UNEXEC
-$(UNEXEC_ALIAS): UNEXEC_SRC $(config_h)
-w16select.o: w16select.c dispextern.h frame.h blockinput.h atimer.h systime.h \
- msdos.h $(config_h)
-widget.o: widget.c xterm.h frame.h dispextern.h widgetprv.h \
- $(srcdir)/../lwlib/lwlib.h $(config_h)
-window.o: window.c indent.h commands.h frame.h window.h buffer.h termchar.h \
- termhooks.h disptab.h keyboard.h dispextern.h msdos.h composite.h \
- $(config_h)
-xdisp.o: xdisp.c macros.h commands.h indent.h buffer.h dispextern.h coding.h \
- termchar.h frame.h window.h disptab.h termhooks.h charset.h $(config_h) \
- msdos.h composite.h fontset.h
-xfaces.o: xfaces.c dispextern.h frame.h xterm.h buffer.h blockinput.h \
- window.h charset.h msdos.h dosfns.h composite.h atimer.h systime.h $(config_h)
-xfns.o: xfns.c buffer.h frame.h window.h keyboard.h xterm.h dispextern.h \
- $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h epaths.h \
- charset.h $(config_h)
-xmenu.o: xmenu.c xterm.h termhooks.h window.h dispextern.h frame.h keyboard.h \
- $(srcdir)/../lwlib/lwlib.h blockinput.h atimer.h systime.h msdos.h \
- $(config_h)
-xterm.o: xterm.c xterm.h termhooks.h termopts.h termchar.h window.h \
- dispextern.h frame.h disptab.h blockinput.h atimer.h systime.h syssignal.h \
- keyboard.h gnu.h sink.h sinkmask.h charset.h ccl.h fontset.h composite.h \
- coding.h $(config_h)
-xselect.o: xselect.c dispextern.h frame.h xterm.h blockinput.h charset.h \
- coding.h ccl.h buffer.h atimer.h systime.h $(config_h)
-xrdb.o: xrdb.c $(config_h) epaths.h
-hftctl.o: hftctl.c $(config_h)
-sound.o: sound.c dispextern.h $(config_h)
-atimer.o: atimer.c atimer.h systime.h $(config_h)
-
-/* The files of Lisp proper */
-
-alloc.o: alloc.c frame.h window.h buffer.h puresize.h syssignal.h keyboard.h \
- blockinput.h atimer.h systime.h charset.h dispextern.h $(config_h) $(INTERVAL_SRC)
-bytecode.o: bytecode.c buffer.h syntax.h charset.h $(config_h)
-data.o: data.c buffer.h puresize.h charset.h syssignal.h keyboard.h $(config_h)
-eval.o: eval.c commands.h keyboard.h blockinput.h atimer.h systime.h \
- $(config_h)
-floatfns.o: floatfns.c $(config_h)
-fns.o: fns.c commands.h $(config_h) frame.h buffer.h charset.h keyboard.h \
- frame.h window.h dispextern.h $(INTERVAL_SRC)
-print.o: print.c process.h frame.h window.h buffer.h keyboard.h charset.h\
- $(config_h) dispextern.h msdos.h composite.h
-lread.o: lread.c commands.h keyboard.h buffer.h epaths.h charset.h $(config_h) \
- termhooks.h msdos.h
-
-/* Text properties support */
-textprop.o: textprop.c buffer.h window.h dispextern.h $(INTERVAL_SRC) \
- $(config_h)
-intervals.o: intervals.c buffer.h $(INTERVAL_SRC) keyboard.h puresize.h $(config_h)
-composite.o: composite.c buffer.h charset.h $(INTERVAL_SRC) $(config_h)
-
-/* System-specific programs to be made.
- OTHER_FILES and OBJECTS_MACHINE
- select which of these should be compiled. */
-
-sunfns.o: sunfns.c buffer.h window.h dispextern.h $(config_h)
-
-${libsrc}emacstool: ${libsrc}emacstool.c
- cd ${libsrc}; ${MAKE} ${MFLAGS} emacstool
-mostlyclean:
- rm -f temacs prefix-args core *.core \#* *.o libXMenu11.a liblw.a
- rm -f ../etc/DOC
-clean: mostlyclean
- rm -f emacs-* emacs bootstrap-emacs
-/**/# This is used in making a distribution.
-/**/# Do not use it on development directories!
-distclean: clean
- rm -f epaths.h config.h Makefile Makefile.c config.stamp stamp-oldxmenu ../etc/DOC-*
-maintainer-clean: distclean
- @echo "This command is intended for maintainers to use;"
- @echo "it deletes files that may require special tools to rebuild."
- rm -f TAGS
-versionclean:
- -rm -f emacs emacs-* ../etc/DOC*
-extraclean: distclean
- -rm -f *~ \#* m/?*~ s/?*~
-
-/* The rule for the [sm] files has to be written a little funny to
- avoid looking like a C comment to CPP. */
-SOURCES = *.[ch] [sm]/?* COPYING Makefile.in \
- config.in epaths.in README COPYING ChangeLog vms.pp-trans
-unlock:
- chmod u+w $(SOURCES)
-
-relock:
- chmod -w $(SOURCES)
- chmod +w epaths.h
-
-/* Arrange to make a tags table TAGS-LISP for ../lisp,
- plus TAGS for the C files, which includes ../lisp/TAGS by reference. */
-
-ctagsfiles1 = [xyzXYZ]*.[hc]
-ctagsfiles2 = [a-wA-W]*.[hc]
-
-TAGS: $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2)
- ../lib-src/etags --include=TAGS-LISP --include=${lwlibdir}/TAGS \
- --regex='/[ ]*DEFVAR_[A-Z_ (]+"\([^"]+\)"/' \
- $(srcdir)/$(ctagsfiles1) $(srcdir)/$(ctagsfiles2)
-frc:
-TAGS-LISP: frc
- $(MAKE) -f ${lispsource}Makefile TAGS-LISP ETAGS=../lib-src/etags
-
-$(lwlibdir)TAGS:
- (cd $(lwlibdir); $(MAKE) -f $(lwlibdir)Makefile tags ETAGS=../lib-src/etags)
-
-tags: TAGS TAGS-LISP $(lwlibdir)TAGS
-.PHONY: tags
-
-
-/* Bootstrapping. */
-
-bootstrap: bootstrap-emacs
-
-/* Build a temacs with a sufficiently large PURESIZE to load the
- Lisp files from loadup.el in source form. */
-
-bootstrap-temacs:
- LC_ALL=C $(MAKE) $(MFLAGS) temacs ALL_CFLAGS="$(ALL_CFLAGS) -DPURESIZE=5000000 -I../src"
-
-/* Build a DOC file. */
-
-bootstrap-doc: ${libsrc}make-docfile
- -rm -f ${etc}DOC
- els=`echo ${shortlisp} ${SOME_MACHINE_LISP} \
- | sed -e "s/\\.elc/.el/g"`; \
- ${libsrc}make-docfile -d ${srcdir} $$els ${obj} > ${etc}DOC
-
-/* Dump an Emacs executable named bootstrap-emacs containing the
- files from loadup.el in source form. */
-
-bootstrap-emacs: bootstrap-temacs bootstrap-doc
-#ifdef CANNOT_DUMP
- ln temacs bootstrap-emacs
-#else
-#ifdef HAVE_SHM
- ./temacs -nl -batch -l loadup bootstrap
-#else /* ! defined (HAVE_SHM) */
- ./temacs --batch --load loadup bootstrap
-#endif /* ! defined (HAVE_SHM) */
-#endif /* ! defined (CANNOT_DUMP) */
- mv -f emacs bootstrap-emacs
- rm -f temacs
-
diff --git a/src/XTests.c b/src/XTests.c
deleted file mode 100644
index 4147ecd35d6..00000000000
--- a/src/XTests.c
+++ /dev/null
@@ -1,179 +0,0 @@
-#include <X11/Xlib.h>
-#include <X11/X.h>
-#include <X11/Xutil.h>
-#include <X11/Xresource.h>
-#include "XTests.h"
-#include <stdio.h>
-
-static Display *dpy;
-
-static void
-quit (dpy)
- Display *dpy;
-{
- XCloseDisplay (dpy);
- exit (0);
-}
-
-static Colormap screen_colormap;
-
-static unsigned long
-obtain_color (color)
- char *color;
-{
- int exists;
- XColor color_def;
-
- if (!screen_colormap)
- screen_colormap = DefaultColormap (dpy, DefaultScreen (dpy));
-
- exists = XParseColor (dpy, screen_colormap, color, &color_def)
- && XAllocColor (dpy, screen_colormap, &color_def);
- if (exists)
- return color_def.pixel;
-
- fprintf (stderr, "Can't get color; using black.");
- return BlackPixel (dpy, DefaultScreen (dpy));
-}
-
-static char *visual_strings[] =
-{
- "StaticGray ",
- "GrayScale ",
- "StaticColor",
- "PseudoColor",
- "TrueColor ",
- "DirectColor"
-};
-
-main (argc,argv)
- int argc;
- char *argv[];
-{
- char *dpy_string;
- int n;
- long mask;
- Visual *my_visual;
- XVisualInfo *vinfo, visual_template;
- XEvent event;
- Window window;
- Screen *scr;
- XGCValues gc_values;
- GC fill_gc, pix_gc, line_xor_gc, line_xor_inv_gc;
- int i;
- int x, y, width, height, geometry, gravity;
- char *geo;
- char default_geo[] = "80x40+0+0";
- int depth;
- Pixmap pix;
- char *string = "Kill the head and the body will die.";
- char dash_list[] = {4, 4};
- int dashes = 2;
-
- if (argc < 2)
- dpy_string = "localhost:0.0";
- else
- dpy_string = argv[1];
-
- if (argc >= 3)
- {
- XSizeHints hints;
-
- printf ("Geometry: %s\t(default: %s)\n", argv[2], default_geo);
- geo = argv[2];
- XWMGeometry (dpy, DefaultScreen (dpy), geo, default_geo,
- 3, &hints, &x, &y, &width, &height, &gravity);
- }
-
- dpy = XOpenDisplay (dpy_string);
- if (!dpy)
- {
- printf ("Can' open display %s\n", dpy_string);
- exit (1);
- }
-
- window = XCreateSimpleWindow (dpy, DefaultRootWindow (dpy),
- 300, 300, 300, 300, 1,
- BlackPixel (dpy, DefaultScreen (dpy)),
- WhitePixel (dpy, DefaultScreen (dpy)));
- XSelectInput (dpy, window, ButtonPressMask | KeyPressMask
- | EnterWindowMask | LeaveWindowMask);
-
- gc_values.foreground = obtain_color ("blue");
- gc_values.background = WhitePixel (dpy, DefaultScreen (dpy));
- fill_gc = XCreateGC (dpy, window, GCForeground | GCBackground,
- &gc_values);
-
- gc_values.foreground = obtain_color ("red");
- gc_values.line_width = 3;
- gc_values.line_style = LineOnOffDash;
- gc_values.cap_style = CapRound;
- gc_values.join_style = JoinRound;
- line_xor_gc = XCreateGC (dpy, window,
- GCForeground | GCBackground | GCLineStyle
- | GCJoinStyle | GCCapStyle | GCLineWidth,
- &gc_values);
- XSetDashes (dpy, line_xor_gc, 0, dash_list, dashes);
-
- line_xor_inv_gc = XCreateGC (dpy, window,
- GCForeground | GCBackground | GCLineWidth,
- &gc_values);
-
- depth = DefaultDepthOfScreen (ScreenOfDisplay (dpy, DefaultScreen (dpy)));
- pix = XCreateBitmapFromData (dpy, window, page_glyf_bits,
- page_glyf_width, page_glyf_height);
-
- XMapWindow (dpy, window);
- XFlush (dpy);
-
- while (1)
- {
- XNextEvent (dpy, &event);
- switch (event.type)
- {
- case ButtonPress:
- switch (event.xbutton.button)
- {
- case Button1:
- XDrawLine (dpy, window, line_xor_gc, 25, 75, 300, 75);
- break;
-
- case Button2:
- XDrawLine (dpy, window, line_xor_inv_gc, 25, 25, 300, 25);
- break;
-
- case Button3:
- XDrawLine (dpy, window, line_xor_gc, 25, 25, 25, 125);
- break;
- }
- break;
-
- case KeyPress:
- {
- char buf[20];
- int n;
- XComposeStatus status;
- KeySym keysym;
-
- n = XLookupString (&event, buf, 20, &keysym,
- (XComposeStatus *) &status);
-
- if (n == 1 && buf[0] == 'q')
- quit (dpy);
- }
- break;
-
- case EnterNotify:
- XCopyPlane (dpy, pix, window, fill_gc, 0, 0,
- page_glyf_width, page_glyf_height, 100, 100, 1L);
- XFillRectangle (dpy, window, fill_gc, 50, 50, 50, 50);
- break;
-
- case LeaveNotify:
- XClearWindow (dpy, window);
- break;
- }
-
- XFlush (dpy);
- }
-}
diff --git a/src/XTests.h b/src/XTests.h
deleted file mode 100644
index e91445af7ef..00000000000
--- a/src/XTests.h
+++ /dev/null
@@ -1,7 +0,0 @@
-#define page_glyf_width 30
-#define page_glyf_height 10
-static char page_glyf_bits[] = {
- 0xf0, 0xff, 0xff, 0x03, 0x08, 0x00, 0x00, 0x04, 0xc4, 0x19, 0xf3, 0x08,
- 0x42, 0xa5, 0x14, 0x10, 0xc1, 0xa5, 0x70, 0x20, 0x41, 0xbc, 0x16, 0x20,
- 0x42, 0xa4, 0x14, 0x10, 0x44, 0x24, 0xf3, 0x08, 0x08, 0x00, 0x00, 0x04,
- 0xf0, 0xff, 0xff, 0x03};
diff --git a/src/convexos.h b/src/convexos.h
deleted file mode 100644
index 94cdbf68346..00000000000
--- a/src/convexos.h
+++ /dev/null
@@ -1,10 +0,0 @@
-/* Definitions file for GNU Emacs running on ConvexOS. */
-
-#include "bsd4-3.h"
-
-/* First pty name is /dev/pty?0. We have to search for it. */
-#undef FIRST_PTY_LETTER
-#define FIRST_PTY_LETTER first_pty_letter
-
-/* getpgrp requires no arguments. */
-#define GETPGRP_NO_ARG
diff --git a/src/environ.c b/src/environ.c
deleted file mode 100644
index 863f40ccd2a..00000000000
--- a/src/environ.c
+++ /dev/null
@@ -1,316 +0,0 @@
-/* Environment-hacking for GNU Emacs subprocess
- Copyright (C) 1986 Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
-#include "config.h"
-#include "lisp.h"
-
-#ifdef MAINTAIN_ENVIRONMENT
-
-#ifdef VMS
-you lose -- this is un*x-only
-#endif
-
-/* alist of (name-string . value-string) */
-Lisp_Object Venvironment_alist;
-extern char **environ;
-
-void
-set_environment_alist (str, val)
- register Lisp_Object str, val;
-{
- register Lisp_Object tem;
-
- tem = Fassoc (str, Venvironment_alist);
- if (NULL (tem))
- if (NULL (val))
- ;
- else
- Venvironment_alist = Fcons (Fcons (str, val), Venvironment_alist);
- else
- if (NULL (val))
- Venvironment_alist = Fdelq (tem, Venvironment_alist);
- else
- XCONS (tem)->cdr = val;
-}
-
-
-
-static void
-initialize_environment_alist ()
-{
- register unsigned char **e, *s;
- extern char *index ();
-
- for (e = (unsigned char **) environ; *e; e++)
- {
- s = (unsigned char *) index (*e, '=');
- if (s)
- set_environment_alist (make_string (*e, s - *e),
- build_string (s + 1));
- }
-}
-
-
-unsigned char *
-getenv_1 (str, ephemeral)
- register unsigned char *str;
- int ephemeral; /* if ephmeral, don't need to gc-proof */
-{
- register Lisp_Object env;
- int len = strlen (str);
-
- for (env = Venvironment_alist; CONSP (env); env = XCONS (env)->cdr)
- {
- register Lisp_Object car = XCONS (env)->car;
- register Lisp_Object tem = XCONS (car)->car;
-
- if ((len == XSTRING (tem)->size) &&
- (!bcmp (str, XSTRING (tem)->data, len)))
- {
- /* Found it in the lisp environment */
- tem = XCONS (car)->cdr;
- if (ephemeral)
- /* Caller promises that gc won't make him lose */
- return XSTRING (tem)->data;
- else
- {
- register unsigned char **e;
- unsigned char *s;
- int ll = XSTRING (tem)->size;
-
- /* Look for element in the original unix environment */
- for (e = (unsigned char **) environ; *e; e++)
- if (!bcmp (str, *e, len) && *(*e + len) == '=')
- {
- s = *e + len + 1;
- if (strlen (s) >= ll)
- /* User hasn't either hasn't munged it or has set it
- to something shorter -- we don't have to cons */
- goto copy;
- else
- goto cons;
- };
- cons:
- /* User has setenv'ed it to a diferent value, and our caller
- isn't guaranteeing that he won't stash it away somewhere.
- We can't just return a pointer to the lisp string, as that
- will be corrupted when gc happens. So, we cons (in such
- a way that it can't be freed -- though this isn't such a
- problem since the only callers of getenv (as opposed to
- those of egetenv) are very early, before the user -could-
- have frobbed the environment. */
- s = (unsigned char *) xmalloc (ll + 1);
- copy:
- bcopy (XSTRING (tem)->data, s, ll + 1);
- return (s);
- }
- }
- }
- return ((unsigned char *) 0);
-}
-
-/* unsigned -- stupid delcaration in lisp.h */ char *
-getenv (str)
- register unsigned char *str;
-{
- return ((char *) getenv_1 (str, 0));
-}
-
-unsigned char *
-egetenv (str)
- register unsigned char *str;
-{
- return (getenv_1 (str, 1));
-}
-
-
-#if (1 == 1) /* use caller-alloca versions, rather than callee-malloc */
-int
-size_of_current_environ ()
-{
- register int size;
- Lisp_Object tem;
-
- tem = Flength (Venvironment_alist);
-
- size = (XINT (tem) + 1) * sizeof (unsigned char *);
- /* + 1 for environment-terminating 0 */
-
- for (tem = Venvironment_alist; !NULL (tem); tem = XCONS (tem)->cdr)
- {
- register Lisp_Object str, val;
-
- str = XCONS (XCONS (tem)->car)->car;
- val = XCONS (XCONS (tem)->car)->cdr;
-
- size += (XSTRING (str)->size +
- XSTRING (val)->size +
- 2); /* 1 for '=', 1 for '\000' */
- }
- return size;
-}
-
-void
-get_current_environ (memory_block)
- unsigned char **memory_block;
-{
- register unsigned char **e, *s;
- register int len;
- register Lisp_Object tem;
-
- e = memory_block;
-
- tem = Flength (Venvironment_alist);
-
- s = (unsigned char *) memory_block
- + (XINT (tem) + 1) * sizeof (unsigned char *);
-
- for (tem = Venvironment_alist; !NULL (tem); tem = XCONS (tem)->cdr)
- {
- register Lisp_Object str, val;
-
- str = XCONS (XCONS (tem)->car)->car;
- val = XCONS (XCONS (tem)->car)->cdr;
-
- *e++ = s;
- len = XSTRING (str)->size;
- bcopy (XSTRING (str)->data, s, len);
- s += len;
- *s++ = '=';
- len = XSTRING (val)->size;
- bcopy (XSTRING (val)->data, s, len);
- s += len;
- *s++ = '\000';
- }
- *e = 0;
-}
-
-#else
-/* dead code (this function mallocs, caller frees) superseded by above (which allows caller to use alloca) */
-unsigned char **
-current_environ ()
-{
- unsigned char **env;
- register unsigned char **e, *s;
- register int len, env_len;
- Lisp_Object tem;
- Lisp_Object str, val;
-
- tem = Flength (Venvironment_alist);
-
- env_len = (XINT (tem) + 1) * sizeof (char *);
- /* + 1 for terminating 0 */
-
- len = 0;
- for (tem = Venvironment_alist; !NULL (tem); tem = XCONS (tem)->cdr)
- {
- str = XCONS (XCONS (tem)->car)->car;
- val = XCONS (XCONS (tem)->car)->cdr;
-
- len += (XSTRING (str)->size +
- XSTRING (val)->size +
- 2);
- }
-
- e = env = (unsigned char **) xmalloc (env_len + len);
- s = (unsigned char *) env + env_len;
-
- for (tem = Venvironment_alist; !NULL (tem); tem = XCONS (tem)->cdr)
- {
- str = XCONS (XCONS (tem)->car)->car;
- val = XCONS (XCONS (tem)->car)->cdr;
-
- *e++ = s;
- len = XSTRING (str)->size;
- bcopy (XSTRING (str)->data, s, len);
- s += len;
- *s++ = '=';
- len = XSTRING (val)->size;
- bcopy (XSTRING (val)->data, s, len);
- s += len;
- *s++ = '\000';
- }
- *e = 0;
-
- return env;
-}
-
-#endif /* dead code */
-
-
-DEFUN ("getenv", Fgetenv, Sgetenv, 1, 2, "sEnvironment variable: \np",
- "Return the value of environment variable VAR, as a string.\n\
-When invoked interactively, print the value in the echo area.\n\
-VAR is a string, the name of the variable,\n\
- or the symbol t, meaning to return an alist representing the\n\
- current environment.")
- (str, interactivep)
- Lisp_Object str, interactivep;
-{
- Lisp_Object val;
-
- if (str == Qt) /* If arg is t, return whole environment */
- return (Fcopy_alist (Venvironment_alist));
-
- CHECK_STRING (str, 0);
- val = Fcdr (Fassoc (str, Venvironment_alist));
- if (!NULL (interactivep))
- {
- if (NULL (val))
- message ("%s not defined in environment", XSTRING (str)->data);
- else
- message ("\"%s\"", XSTRING (val)->data);
- }
- return val;
-}
-
-DEFUN ("setenv", Fsetenv, Ssetenv, 1, 2,
- "sEnvironment variable: \nsSet %s to value: ",
- "Set the value of environment variable VAR to VALUE.\n\
-Both args must be strings. Returns VALUE.")
- (str, val)
- Lisp_Object str;
- Lisp_Object val;
-{
- Lisp_Object tem;
-
- CHECK_STRING (str, 0);
- if (!NULL (val))
- CHECK_STRING (val, 0);
-
- set_environment_alist (str, val);
- return val;
-}
-
-
-syms_of_environ ()
-{
- staticpro (&Venvironment_alist);
- defsubr (&Ssetenv);
- defsubr (&Sgetenv);
-}
-
-init_environ ()
-{
- Venvironment_alist = Qnil;
- initialize_environment_alist ();
-}
-
-#endif /* MAINTAIN_ENVIRONMENT */
diff --git a/src/m/dos386.h b/src/m/dos386.h
deleted file mode 100644
index 1fb38da656f..00000000000
--- a/src/m/dos386.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* Machine description file for MS-DOS
-
- Copyright (C) 1993 Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* Note: lots of stuff here was taken from m-dos386.h in demacs. */
-
-
-/* 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 */
-
-/* Define BIG_ENDIAN iff lowest-numbered byte in a word
- is the most significant byte. */
-
-/* #define BIG_ENDIAN */
-
-/* Define NO_ARG_ARRAY if you cannot take the address of the first of a
- * group of arguments and treat it as an array of the arguments. */
-
-/* #define NO_ARG_ARRAY */
-
-/* Define WORD_MACHINE if addresses and such have
- * to be corrected before they can be used as byte counts. */
-
-/* #define WORD_MACHINE */
-
-/* Define how to take a char and sign-extend into an int.
- On machines where char is signed, this is a no-op. */
-
-#define SIGN_EXTEND_CHAR(c) (c)
-
-/* Now define a symbol for the cpu type, if your compiler
- does not define it automatically:
- Ones defined so far include vax, m68000, ns16000, pyramid,
- orion, tahoe, APOLLO and many others */
-
-#define INTEL386
-
-/* Use type int rather than a union, to represent Lisp_Object */
-/* This is desirable for most machines. */
-
-#define NO_UNION_TYPE
-
-/* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend
- the 24-bit bit field into an int. In other words, if bit fields
- are always unsigned.
-
- If you use NO_UNION_TYPE, this flag does not matter. */
-
-#define EXPLICIT_SIGN_EXTEND
-
-/* 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 */
-
-/* #define LOAD_AVE_CVT(x) (int) (((double) (x)) * 100.0 / FSCALE) */
-
-/* Define CANNOT_DUMP on machines where unexec does not work.
- Then the function dump-emacs will not be defined
- and temacs will do (load "loadup") automatically unless told otherwise. */
-
-/* #define CANNOT_DUMP */
-
-/* Define VIRT_ADDR_VARIES if the virtual addresses of
- pure and impure space as loaded can vary, and even their
- relative order cannot be relied on.
-
- Otherwise Emacs assumes that text space precedes data space,
- numerically. */
-
-/* #define VIRT_ADDR_VARIES */
-
-/* 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 HAVE_ALLOCA
-#define alloca(x) __builtin_alloca(x)
-
-/* Define NO_REMAP if memory segmentation makes it not work well
- to change the boundary between the text section and data section
- when Emacs is dumped. If you define this, the preloaded Lisp
- code will not be sharable; but that's better than failing completely. */
-
-#define NO_REMAP
-
-/* We need a little extra space, see ../../lisp/loadup.el */
-#define PURESIZE 240000
-
-/* We have (the code to control) a mouse. */
-#define HAVE_MOUSE
diff --git a/src/mach2.h b/src/mach2.h
deleted file mode 100644
index c941c5ff2cf..00000000000
--- a/src/mach2.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Definitions for Emacs running on Mach version 2 (non-kernelized system).
- Copyright (C) 1990 Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "bsd4-3.h"
-
-/* SYSTEM_TYPE should indicate the kind of system you are using.
- It sets the Lisp variable system-type. We'll need to undo the bsd one. */
-
-#undef SYSTEM_TYPE
-#define SYSTEM_TYPE "next-mach"
-
-#define LD_SWITCH_SYSTEM -X -noseglinkedit
-
-/* Don't use -lc on the NeXT. */
-#define LIB_STANDARD -lsys_s
-#define LIB_MATH -lm
-
-#define environ _environ
-
-#define START_FILES pre-crt0.o
-#define UNEXEC unexnext.o
-
-/* start_of_text isn't actually used, so make it compile without error. */
-#define TEXT_START 0
-/* This seems to be right for end_of_text, but it may not be used anyway. */
-#define TEXT_END get_etext ()
-/* This seems to be right for end_of_data, but it may not be used anyway. */
-#define DATA_END get_edata ()
-
-/* Defining KERNEL_FILE causes lossage because sys/file.h
- stupidly gets confused by it. */
-#undef KERNEL_FILE
diff --git a/src/old-ralloc.c b/src/old-ralloc.c
deleted file mode 100644
index 28562994e9a..00000000000
--- a/src/old-ralloc.c
+++ /dev/null
@@ -1,1069 +0,0 @@
-/* Block-relocating memory allocator.
- Copyright (C) 1990 Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* This package works by allocating blocks from a zone of memory
- above that used by malloc (). When malloc needs more space that
- would enter our zone, we relocate blocks upward. The bottom of
- our zone is kept in the variable `virtual_break_value'. The top
- of our zone is indicated by `real_break_value'.
-
- As blocks are freed, a free list is maintained and we attempt
- to satisfy further requests for space using a first-fit policy.
- If there are holes, but none fit, memory is compacted and a new
- block is obtained at the top of the zone.
-
- NOTE that our blocks are always rounded to page boundaries. */
-
-/*
- NOTES:
-
- Once this is stable, I can speed things up by intially leaving a large
- gap between real_break_value and true_break_value, or maybe making
- a large hole before the first block.
-
- If we also kept track of size_wanted, we could gain some
- extra space upon compactification.
-
- Perhaps we should just note a hole when malloc does doing sbrk(-n)?
-
- Relocating downward upon freeing the first block would simplify
- other things.
-
- When r_alloc places a block in a hole, we could easily check if there's
- much more than required, and leave a hole.
- */
-
-#include "mem_limits.h"
-
-static POINTER r_alloc_sbrk ();
-static POINTER sbrk ();
-static POINTER brk ();
-
-/* Variable `malloc' uses for the function which gets more space
- from the system. */
-extern POINTER (*__morecore) ();
-
-/* List of variables which point into the associated data block. */
-struct other_pointer
-{
- POINTER *location;
- struct other_pointer *next;
-};
-
-/* List describing all the user's pointers to relocatable blocks. */
-typedef struct rel_pointers
-{
- struct rel_pointers *next;
- struct rel_pointers *prev;
- struct other_pointer *others; /* Other variables which use this block. */
- POINTER *location; /* Location of the block's pointer. */
- POINTER block; /* Address of the actual data. */
- int size; /* The size of the block. */
-} relocatable_pointer;
-
-#define REL_NIL ((struct rel_pointers *) 0)
-
-static relocatable_pointer *pointer_list;
-static relocatable_pointer *last_pointer;
-
-#define MAX_HOLES 2
-
-/* Vector of available holes among allocated blocks. This can include
- a hole at the beginning of the list, but never the end. */
-typedef struct
-{
- POINTER address;
- unsigned int size;
-} hole_descriptor;
-
-static hole_descriptor r_alloc_holes[MAX_HOLES];
-
-/* Number of holes currently available. */
-static int holes;
-
-/* The process break value (i.e., curbrk) */
-static POINTER real_break_value;
-
-/* The REAL (i.e., page aligned) break value. */
-static POINTER true_break_value;
-
-/* Address of start of data space in use by relocatable blocks.
- This is what `malloc' thinks is the process break value. */
-static POINTER virtual_break_value;
-
-/* Nonzero if we have told `malloc' to start using `r_alloc_sbrk'
- instead of calling `sbrk' directly. */
-int r_alloc_in_use;
-
-#define PAGE (getpagesize ())
-#define ALIGNED(addr) (((unsigned int) (addr) & (PAGE - 1)) == 0)
-#define ROUNDUP(size) (((unsigned int) (size) + PAGE) & ~(PAGE - 1))
-
-/*
- Level number of warnings already issued.
- 0 -- no warnings issued.
- 1 -- 75% warning already issued.
- 2 -- 85% warning already issued.
-*/
-static int warnlevel;
-
-/* Function to call to issue a warning;
- 0 means don't issue them. */
-static void (*warnfunction) ();
-
-/* Call this to start things off. It determines the current process
- break value, as well as the `true' break value--because the system
- allocates memory in page increments, if the break value is not page
- aligned it means that space up to the next page boundary is actually
- available. */
-
-void
-malloc_init (start, warn_func)
- POINTER start;
- void (*warn_func) ();
-{
- r_alloc_in_use = 1;
- __morecore = r_alloc_sbrk;
-
- virtual_break_value = real_break_value = sbrk (0);
- if (ALIGNED (real_break_value))
- true_break_value = real_break_value;
- else
- true_break_value = (POINTER) ROUNDUP (real_break_value);
-
- if (start)
- data_space_start = start;
- lim_data = 0;
- warnlevel = 0;
- warnfunction = warn_func;
-
- get_lim_data ();
-}
-
-/* Get more space for us to use. Return a pointer to SIZE more
- bytes of space. SIZE is internally rounded up to a page boundary,
- and requests for integral pages prefetch an extra page. */
-
-static POINTER
-get_more_space (size)
- unsigned int size;
-{
- unsigned int margin = true_break_value - real_break_value;
- unsigned int get;
- POINTER old_break = real_break_value;
-
- if (size == 0)
- return real_break_value;
-
- if (size <= margin)
- {
- real_break_value += size;
- return old_break;
- }
-
- get = ROUNDUP (size - margin);
- if (sbrk (get) < (POINTER) 0)
- return NULL;
-
- true_break_value += get;
- real_break_value = (old_break + size);
-
- return old_break;
-}
-
-/* Relinquish size bytes of space to the system. Space is only returned
- in page increments. If successful, return real_break_value. */
-
-static POINTER
-return_space (size)
- unsigned int size;
-{
- unsigned int margin = (true_break_value - real_break_value) + size;
- unsigned int to_return = (margin / PAGE) * PAGE;
- unsigned new_margin = margin % PAGE;
-
- true_break_value -= to_return;
- if (! brk (true_break_value))
- return NULL;
-
- real_break_value = true_break_value - new_margin;
- return real_break_value;
-}
-
-/* Record a new hole in memory beginning at ADDRESS of size SIZE.
- Holes are ordered by location. Adjacent holes are merged.
- Holes are zero filled before being noted. */
-
-static void
-note_hole (address, size)
- POINTER address;
- int size;
-{
- register int this_hole = holes - 1; /* Start at the last hole. */
- register POINTER end = address + size; /* End of the hole. */
- register int i;
-
- if (holes)
- {
- /* Find the hole which should precede this new one. */
- while (this_hole >= 0 && r_alloc_holes[this_hole].address > address)
- this_hole--;
-
- /* Can we merge with preceding? */
- if (this_hole >= 0
- && r_alloc_holes[this_hole].address + r_alloc_holes[this_hole].size
- == address)
- {
- r_alloc_holes[this_hole].size += size;
-
- if (this_hole == holes - 1)
- return;
-
- /* Can we also merge with following? */
- if (end == r_alloc_holes[this_hole + 1].address)
- {
- r_alloc_holes[this_hole].size
- += r_alloc_holes[this_hole + 1].size;
-
- for (i = this_hole + 1; i < holes - 1; i++)
- r_alloc_holes[i] = r_alloc_holes[i + 1];
- holes--;
- }
-
- return;
- }
-
- if (this_hole < holes - 1) /* there are following holes */
- {
- register int next_hole = this_hole + 1;
-
- /* Can we merge with the next hole? */
- if (end == r_alloc_holes[next_hole].address)
- {
- r_alloc_holes[next_hole].address = address;
- r_alloc_holes[next_hole].size += size;
- return;
- }
-
- /* Can't merge, so insert. */
- for (i = holes; i > next_hole; i--)
- r_alloc_holes[i] = r_alloc_holes[i - 1];
- r_alloc_holes[next_hole].address = address;
- r_alloc_holes[next_hole].size = size;
- holes++;
-
- return;
- }
- else /* Simply add this hole at the end. */
- {
- r_alloc_holes[holes].address = address;
- r_alloc_holes[holes].size = size;
- holes++;
-
- return;
- }
-
- abort ();
- }
- else /* Make the first hole. */
- {
- holes = 1;
- r_alloc_holes[0].address = address;
- r_alloc_holes[0].size = size;
- }
-}
-
-/* Mark hole HOLE as no longer available by re-organizing the vector.
- HOLE is the Nth hole, beginning with 0. This doesn *not* affect memory
- organization. */
-
-static void
-delete_hole (hole)
- int hole;
-{
- register int i;
-
- for (i = hole; i < holes - 1; i++)
- r_alloc_holes[i] = r_alloc_holes[i + 1];
-
- holes--;
-}
-
-/* Insert a newly allocated pointer, NEW_PTR, at the appropriate
- place in our list. */
-
-static void
-insert (new_ptr)
- register relocatable_pointer *new_ptr;
-{
- register relocatable_pointer *this_ptr = pointer_list;
-
- while (this_ptr != REL_NIL && this_ptr->block < new_ptr->block)
- this_ptr = this_ptr->next;
-
- if (this_ptr == REL_NIL)
- abort (); /* Use `attach' for appending. */
-
- new_ptr->next = this_ptr;
- new_ptr->prev = this_ptr->prev;
- this_ptr->prev = new_ptr;
-
- if (this_ptr == pointer_list)
- pointer_list = new_ptr;
- else
- new_ptr->prev->next = new_ptr;
-}
-
-/* Attach a newly allocated pointer, NEW_PTR, to the end of our list. */
-
-static void
-attach (new_ptr)
- relocatable_pointer *new_ptr;
-{
- if (pointer_list == REL_NIL)
- {
- pointer_list = new_ptr;
- last_pointer = new_ptr;
- new_ptr->next = new_ptr->prev = REL_NIL;
- }
- else
- {
- new_ptr->next = REL_NIL;
- last_pointer->next = new_ptr;
- new_ptr->prev = last_pointer;
- last_pointer = new_ptr;
- }
-}
-
-static relocatable_pointer *
-find_block (block)
- POINTER block;
-{
- register relocatable_pointer *this_ptr = pointer_list;
-
- while (this_ptr != REL_NIL && this_ptr->block != block)
- this_ptr = this_ptr->next;
-
- return this_ptr;
-}
-
-static relocatable_pointer *
-find_location (address)
- POINTER *address;
-{
- register relocatable_pointer *this_ptr = pointer_list;
-
- while (this_ptr != REL_NIL && this_ptr->location != address)
- {
- struct other_pointer *op = this_ptr->others;
-
- while (op != (struct other_pointer *) 0)
- {
- if (op->location == address)
- return this_ptr;
-
- op = op->next;
- }
-
- this_ptr = this_ptr->next;
- }
-
- return this_ptr;
-}
-
-
-static void compactify ();
-
-/* Record of last new block allocated. */
-static relocatable_pointer *last_record;
-
-/* Allocate a block of size SIZE and record that PTR points to it.
- If successful, store the address of the block in *PTR and return
- it as well. Otherwise return NULL. */
-
-POINTER
-r_alloc (ptr, size)
- POINTER *ptr;
- int size;
-{
- register relocatable_pointer *record
- = (relocatable_pointer *) malloc (sizeof (relocatable_pointer));
- register POINTER block;
-
- /* If we can't get space to record this pointer, fail. */
- if (record == 0)
- return NULL;
-
- last_record = record;
-
- if (holes) /* Search for a hole the right size. */
- {
- int i;
-
- for (i = 0; i < holes; i++)
- if (r_alloc_holes[i].size >= size)
- {
- record->location = ptr;
- record->others = (struct other_pointer *) 0;
- record->block = *ptr = r_alloc_holes[i].address;
- if (r_alloc_holes[i].size > ROUNDUP (size))
- {
- record->size = ROUNDUP (size);
- r_alloc_holes[i].size -= ROUNDUP (size);
- r_alloc_holes[i].address += ROUNDUP (size);
- }
- else
- {
- record->size = r_alloc_holes[i].size;
- delete_hole (i);
- }
- insert (record);
-
- *ptr = record->block;
- return record->block;
- }
-
- /* No holes large enough. Burp. */
- compactify ();
- }
-
- /* No holes: grow the process. */
- block = get_more_space (size);
- if (block == NULL)
- {
- free (record);
- return NULL;
- }
-
- /* Return the address of the block. */
- *ptr = block;
-
- /* Record and append this pointer to our list. */
- record->location = ptr;
- record->others = (struct other_pointer *) 0;
- record->block = block;
- record->size = size;
- attach (record);
-
- return block;
-}
-
-/* Declare VAR to be a pointer which points into the block of r_alloc'd
- memory at BLOCK.
-
- If VAR is already delcared for this block, simply return.
- If VAR currently points to some other block, remove that declaration
- of it, then install the new one.
-
- Return 0 if successful, -1 otherwise. */
-
-int
-r_alloc_declare (var, block)
- POINTER *var;
- register POINTER block;
-{
- register relocatable_pointer *block_ptr = find_block (block);
- relocatable_pointer *var_ptr = find_location (var);
- register struct other_pointer *other;
-
- if (block_ptr == REL_NIL)
- abort ();
-
- if (var_ptr != REL_NIL) /* Var already declared somewhere. */
- {
- register struct other_pointer *po;
-
- if (var_ptr == block_ptr) /* Var already points to this block. */
- return 0;
-
- po = (struct other_pointer *) 0;
- other = var_ptr->others;
- while (other && other->location != var)
- {
- po = other;
- other = other->next;
- }
-
- if (!other) /* This only happens if the location is */
- abort (); /* the main pointer and not an `other' */
-
- if (po) /* In the chain */
- {
- po->next = other->next;
- free (other);
- }
- else /* Only element of the chain */
- {
- free (var_ptr->others);
- var_ptr->others = (struct other_pointer *) 0;
- }
- }
-
- /* Install this variable as an `other' element */
-
- other = (struct other_pointer *) malloc (sizeof (struct other_pointer));
-
- if (other == 0)
- return -1;
-
- /* If the malloc relocated this data block, adjust this variable. */
- if (block != block_ptr->block)
- {
- int offset = block_ptr->block - block;
-
- *var += offset;
- }
-
- other->location = var;
- other->next = (struct other_pointer *) 0;
-
- if (block_ptr->others == (struct other_pointer *) 0)
- block_ptr->others = other;
- else
- {
- register struct other_pointer *op = block_ptr->others;
-
- while (op->next != (struct other_pointer *) 0)
- op = op->next;
- op->next = other;
- }
-
- return 0;
-}
-
-/* Recursively free the linked list of `other' pointers to a block. */
-
-static void
-free_others (another)
- struct other_pointer *another;
-{
- if (another == (struct other_pointer *) 0)
- return;
-
- free_others (another->next);
- free (another);
-}
-
-/* Remove the element pointed to by PTR from the doubly linked list.
- Record the newly freed space in `holes', unless it was at the end,
- in which case return that space to the system. Return 0 if successful,
- -1 otherwise. */
-
-int
-r_alloc_free (ptr)
- register POINTER *ptr;
-{
- register relocatable_pointer *this_ptr = find_block (*ptr);
-
- if (this_ptr == REL_NIL)
- return -1;
- else
- {
- register relocatable_pointer *prev = this_ptr->prev;
- register relocatable_pointer *next = this_ptr->next;
- if (next && prev) /* Somewhere in the middle */
- {
- next->prev = prev;
- prev->next = next;
- }
- else if (prev) /* Last block */
- {
- prev->next = REL_NIL;
- last_pointer = prev;
- return_space (this_ptr->size);
- free_others (this_ptr->others);
- free (this_ptr);
-
- return 0;
- }
- else if (next) /* First block */
- {
- next->prev = REL_NIL;
- pointer_list = next;
- }
- else if (this_ptr = pointer_list) /* ONLY block */
- {
- pointer_list = REL_NIL;
- last_pointer = REL_NIL;
- if (holes) /* A hole precedes this block. */
- {
- holes = 0;
- return_space (real_break_value - virtual_break_value);
- }
- else
- return_space (this_ptr->size);
-
- if (real_break_value != virtual_break_value)
- abort ();
-
- free_others (this_ptr->others);
- free (this_ptr);
- /* Turn off r_alloc_in_use? */
-
- return 0;
- }
- else
- abort (); /* Weird shit */
-
- free_others (this_ptr->others);
- free (this_ptr);
- bzero (this_ptr->block, this_ptr->size);
- note_hole (this_ptr->block, this_ptr->size);
-
- if (holes == MAX_HOLES)
- compactify ();
- }
-
- return 0;
-}
-
-/* Change the size of the block pointed to by the thing in PTR.
- If neccessary, r_alloc a new block and copy the data there.
- Return a pointer to the block if successfull, NULL otherwise.
-
- Note that if the size requested is less than the actual bloc size,
- nothing is done and the pointer is simply returned. */
-
-POINTER
-r_re_alloc (ptr, size)
- POINTER *ptr;
- int size;
-{
- register relocatable_pointer *this_ptr = find_block (*ptr);
- POINTER block;
-
- if (! this_ptr)
- return NULL;
-
- if (this_ptr->size >= size) /* Already have enough space. */
- return *ptr;
-
- /* Here we could try relocating the blocks just above... */
- block = r_alloc (ptr, size);
- if (block)
- {
- bcopy (this_ptr->block, block, this_ptr->size);
- if (this_ptr->others)
- last_record->others = this_ptr->others;
-
- if (! r_alloc_free (this_ptr->block))
- abort ();
-
- *ptr = block;
- return block;
- }
-
- return NULL;
-}
-
-
-/* Move and relocate all blocks from FIRST_PTR to LAST_PTR, inclusive,
- downwards to space starting at ADDRESS. */
-
-static int
-move_blocks_downward (first_ptr, last_ptr, address)
- relocatable_pointer *first_ptr, *last_ptr;
- POINTER address;
-{
- int size = (last_ptr->block + last_ptr->size) - first_ptr->block;
- register relocatable_pointer *this_ptr = first_ptr;
- register offset = first_ptr->block - address;
- register struct other_pointer *op;
-
- /* Move all the data. */
- bcopy (first_ptr->block, address, size);
-
- /* Now relocate all the pointers to those blocks. */
- while (1)
- {
- this_ptr->block -= offset;
- *this_ptr->location = this_ptr->block;
-
- op = this_ptr->others;
- while (op != (struct other_pointer *) 0)
- {
- *op->location -= offset;
- op = op->next;
- }
-
- if (this_ptr == last_ptr)
- return;
- else
- this_ptr = this_ptr->next;
- }
-
- return size;
-}
-
-/* Burp our memory zone. */
-
-static void
-compactify ()
-{
- register relocatable_pointer *this_ptr = pointer_list;
- relocatable_pointer *first_to_move;
- register relocatable_pointer *last_to_move;
- hole_descriptor *this_hole = &r_alloc_holes[0];
- register hole_descriptor *next_hole;
- register POINTER end; /* First address after hole */
- unsigned int space_regained = 0;
-
- while (holes) /* While there are holes */
- {
- /* Find the first block after this hole. */
- end = this_hole->address + this_hole->size;
- while (this_ptr && this_ptr->block != end)
- this_ptr = this_ptr->next;
-
- if (! this_ptr)
- abort ();
-
- next_hole = this_hole + 1;
- last_to_move = first_to_move = this_ptr;
- this_ptr = this_ptr->next;
-
- /* Note all blocks located before the next hole. */
- while (this_ptr && this_ptr->block < next_hole->address)
- {
- last_to_move = this_ptr;
- this_ptr = this_ptr->next;
- }
- space_regained +=
- move_blocks_downward (first_to_move, last_to_move, this_hole->address);
-
- holes--;
- this_hole = next_hole;
- }
-
- return_space (space_regained);
-}
-
-/* Relocate the list elements from the beginning of the list up to and
- including UP_TO_THIS_PTR to the area beginning at FREE_SPACE, which is
- after all current blocks.
-
- First copy all the data, then adjust the pointers and reorganize
- the list. NOTE that this *only* works for contiguous blocks. */
-
-static unsigned int
-relocate_to_end (up_to_this_ptr, free_space)
- register relocatable_pointer *up_to_this_ptr;
- POINTER free_space;
-{
- register relocatable_pointer *this_ptr;
- POINTER block_start = pointer_list->block;
- POINTER block_end = up_to_this_ptr->block + up_to_this_ptr->size;
- unsigned int total_size = block_end - block_start;
- unsigned int offset = (int) (free_space - block_start);
-
- bcopy (block_start, free_space, total_size);
- for (this_ptr = up_to_this_ptr; this_ptr; this_ptr = this_ptr->prev)
- {
- struct other_pointer *op = this_ptr->others;
-
- *this_ptr->location += offset;
- this_ptr->block += offset;
-
- while (op != (struct other_pointer *) 0)
- {
- *op->location += offset;
- op = op->next;
- }
- }
-
- /* Connect the head to the tail. */
- last_pointer->next = pointer_list;
- pointer_list->prev = last_pointer;
-
- /* Disconnect */
- up_to_this_ptr->next->prev = REL_NIL;
- pointer_list = up_to_this_ptr->next;
- up_to_this_ptr->next = REL_NIL;
- last_pointer = up_to_this_ptr;
-
- return total_size; /* of space relocated. */
-}
-
-/* Relocate the list elements from FROM_THIS_PTR to (and including)
- the last to the zone beginning at FREE_SPACE, which is located
- before any blocks.
-
- First copy all the data, then adjust the pointers and reorganize
- the list. NOTE that this *only* works for contiguous blocks. */
-
-static unsigned int
-relocate_to_beginning (from_this_ptr, free_space)
- register relocatable_pointer *from_this_ptr;
- POINTER free_space;
-{
- POINTER block_start = from_this_ptr->block;
- POINTER block_end = last_pointer->block + last_pointer->size;
- unsigned int total_size = (int) (block_end - block_start);
- unsigned int offset = (int) (from_this_ptr->block - free_space);
- register relocatable_pointer *this_ptr;
-
- bcopy (block_start, free_space, total_size);
- for (this_ptr = from_this_ptr; this_ptr; this_ptr = this_ptr->next)
- {
- struct other_pointer *op = this_ptr->others;
-
- *this_ptr->location -= offset;
- this_ptr->block -= offset;
-
- while (op != (struct other_pointer *) 0)
- {
- *op->location -= offset;
- op = op->next;
- }
- }
-
- /* Connect the end to the beginning. */
- last_pointer->next = pointer_list;
- pointer_list->prev = last_pointer;
-
- /* Disconnect and reset first and last. */
- from_this_ptr->prev->next = REL_NIL;
- last_pointer = from_this_ptr->prev;
- pointer_list = from_this_ptr;
- pointer_list->prev = REL_NIL;
-
- return total_size; /* of space moved. */
-}
-
-/* Relocate any blocks neccessary, either upwards or downwards,
- to obtain a space of SIZE bytes. Assumes we have at least one block. */
-
-static unsigned int
-relocate (size)
- register int size;
-{
- register relocatable_pointer *ptr;
- register int got = 0;
-
- if (size > 0) /* Up: Relocate enough blocs to get SIZE. */
- {
- register POINTER new_space;
-
- for (ptr = pointer_list; got < size && ptr; ptr = ptr->next)
- got += ptr->size;
-
- if (ptr == REL_NIL)
- ptr = last_pointer;
-
- new_space = get_more_space (size);
- if (!new_space)
- return 0;
-
- return (relocate_to_end (ptr, pointer_list->block + size));
- }
-
- if (size < 0) /* Down: relocate as many blocs as will
- fit in SIZE bytes of space. */
- {
- register POINTER to_zone;
- unsigned int moved;
-
- for (ptr = last_pointer; got >= size && ptr; ptr = ptr->prev)
- got -= ptr->size;
-
- if (ptr == REL_NIL)
- ptr = pointer_list;
- else
- {
- /* Back off one block to be <= size */
- got += ptr->size;
- ptr = ptr->next;
- }
-
- if (got >= size)
- {
- to_zone = virtual_break_value - size + got;
- moved = relocate_to_beginning (ptr, to_zone);
- if (moved)
- return_space (moved);
-
- return moved;
- }
-
- return 0;
- }
-
- abort ();
-}
-
-/* This function encapsulates `sbrk' to preserve the relocatable blocks.
- It is called just like `sbrk'. When relocatable blocks are in use,
- `malloc' must use this function instead of `sbrk'. */
-
-POINTER
-r_alloc_sbrk (size)
- unsigned int size;
-{
- POINTER new_zone; /* Start of the zone we will return. */
-
-#if 0
- if (! r_alloc_in_use)
- return (POINTER) sbrk (size);
-#endif
-
- if (size == 0)
- return virtual_break_value;
-
- if (size > 0) /* Get more space */
- {
- register unsigned int space;
-
- if (pointer_list == REL_NIL)
- {
- POINTER space = get_more_space (size);
-
- virtual_break_value = real_break_value;
- return space;
- }
-
- new_zone = virtual_break_value;
-
- /* Check if there is a hole just before the buffer zone. */
- if (holes && r_alloc_holes[0].address == virtual_break_value)
- {
- if (r_alloc_holes[0].size > size)
- {
- /* Adjust the hole size. */
- r_alloc_holes[0].size -= size;
- r_alloc_holes[0].address += size;
- virtual_break_value += size;
-
- return new_zone;
- }
-
- if (r_alloc_holes[0].size == size)
- {
- virtual_break_value += size;
- delete_hole (0);
-
- return new_zone;
- }
-
- /* Adjust the size requested by space
- already available in this hole. */
- size -= r_alloc_holes[0].size;
- virtual_break_value += r_alloc_holes[0].size;
- delete_hole (0);
- }
-
- space = relocate (size);
- if (!space)
- return (POINTER) -1;
-
-#ifdef REL_ALLOC_SAVE_SPACE
- move_blocks_downward
-#else
- bzero (new_zone, space);
- if (space > size)
- note_hole (new_zone + size, space - size);
-#endif /* REL_ALLOC_SAVE_SPACE */
-
- virtual_break_value += size;
- return new_zone;
- }
- else /* Return space to system */
- {
- int moved;
- int left_over;
- POINTER old_break_value;
-
- if (pointer_list == REL_NIL)
- {
- POINTER space = return_space (-size);
- virtual_break_value = real_break_value;
-
- return space;
- }
-
- if (holes && r_alloc_holes[0].address == virtual_break_value)
- {
- size -= r_alloc_holes[0].size;
- delete_hole (0);
- }
-
- moved = relocate (size);
- old_break_value = virtual_break_value;
-
- if (!moved)
- return (POINTER) -1;
-
- left_over = moved + size;
- virtual_break_value += size;
-
- if (left_over)
- {
-#ifdef REL_ALLOC_SAVE_SPACE
- move_blocks_downward
-#else
- bzero (virtual_break_value, left_over);
- note_hole (virtual_break_value, left_over);
-#endif /* not REL_ALLOC_SAVE_SPACE */
- }
-
- return old_break_value;
- }
-}
-
-/* For debugging */
-
-#include <stdio.h>
-
-void
-memory_trace ()
-{
- relocatable_pointer *ptr;
- int i;
-
- fprintf (stderr, "virtual: 0x%x\n real: 0x%x\n true: 0x%x\n\n",
- virtual_break_value, real_break_value, true_break_value);
- fprintf (stderr, "Blocks:\n");
- for (ptr = pointer_list; ptr; ptr = ptr->next)
- {
- fprintf (stderr, " address: 0x%x\n", ptr->block);
- fprintf (stderr, " size: 0x%x\n", ptr->size);
- if (ptr->others)
- {
- struct other_pointer *op = ptr->others;
- fprintf (stderr, " others:", ptr->size);
- while (op)
- {
- fprintf (stderr, " 0x%x", op->location);
- op = op->next;
- }
- fprintf (stderr, "\n");
- }
- }
-
- if (holes)
- {
- fprintf (stderr, "\nHoles:\n");
- for (i = 0; i < holes; i++)
- {
- fprintf (stderr, " address: 0x%x\n", r_alloc_holes[i].address);
- fprintf (stderr, " size: 0x%x\n", r_alloc_holes[i].size);
- }
- }
-
- fprintf (stderr, "\n\n");
-}
diff --git a/src/sol2-2.h b/src/sol2-2.h
deleted file mode 100644
index 016f75e488a..00000000000
--- a/src/sol2-2.h
+++ /dev/null
@@ -1,18 +0,0 @@
-/* casper@fwi.uva.nl says this file is not needed
- and sol2.h should work. */
-
-#include "sol2.h"
-
-/* Take care of libucb.a as well as X Windows. */
-#undef LD_SWITCH_SYSTEM
-#ifndef __GNUC__
-#define LD_SWITCH_SYSTEM -R/usr/openwin/lib:/usr/ucblib
-#else /* GCC */
-#define LD_SWITCH_SYSTEM -Xlinker -R/usr/openwin/lib:/usr/ucblib
-#endif /* GCC */
-
-/* Link with libucb.a. */
-#ifdef LIB_STANDARD
-#undef LIB_STANDARD
-#define LIB_STANDARD -lc -L/usr/ucblib -lucb
-#endif
diff --git a/src/unexelf1.c b/src/unexelf1.c
deleted file mode 100644
index a832755167e..00000000000
--- a/src/unexelf1.c
+++ /dev/null
@@ -1,952 +0,0 @@
-/* Copyright (C) 1985, 1986, 1987, 1988, 1990, 1992
- Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-
-In other words, you are welcome to use, share and improve this program.
-You are forbidden to forbid anyone else to use, share and improve
-what you give them. Help stamp out software-hoarding! */
-
-
-/*
- * unexec.c - Convert a running program into an a.out file.
- *
- * Author: Spencer W. Thomas
- * Computer Science Dept.
- * University of Utah
- * Date: Tue Mar 2 1982
- * Modified heavily since then.
- *
- * Synopsis:
- * unexec (new_name, a_name, data_start, bss_start, entry_address)
- * char *new_name, *a_name;
- * unsigned data_start, bss_start, entry_address;
- *
- * Takes a snapshot of the program and makes an a.out format file in the
- * file named by the string argument new_name.
- * If a_name is non-NULL, the symbol table will be taken from the given file.
- * On some machines, an existing a_name file is required.
- *
- * The boundaries within the a.out file may be adjusted with the data_start
- * and bss_start arguments. Either or both may be given as 0 for defaults.
- *
- * Data_start gives the boundary between the text segment and the data
- * segment of the program. The text segment can contain shared, read-only
- * program code and literal data, while the data segment is always unshared
- * and unprotected. Data_start gives the lowest unprotected address.
- * The value you specify may be rounded down to a suitable boundary
- * as required by the machine you are using.
- *
- * Specifying zero for data_start means the boundary between text and data
- * should not be the same as when the program was loaded.
- * If NO_REMAP is defined, the argument data_start is ignored and the
- * segment boundaries are never changed.
- *
- * Bss_start indicates how much of the data segment is to be saved in the
- * a.out file and restored when the program is executed. It gives the lowest
- * unsaved address, and is rounded up to a page boundary. The default when 0
- * is given assumes that the entire data segment is to be stored, including
- * the previous data and bss as well as any additional storage allocated with
- * break (2).
- *
- * The new file is set up to start at entry_address.
- *
- * If you make improvements I'd like to get them too.
- * harpo!utah-cs!thomas, thomas@Utah-20
- *
- */
-
-/* Even more heavily modified by james@bigtex.cactus.org of Dell Computer Co.
- * ELF support added.
- *
- * Basic theory: the data space of the running process needs to be
- * dumped to the output file. Normally we would just enlarge the size
- * of .data, scooting everything down. But we can't do that in ELF,
- * because there is often something between the .data space and the
- * .bss space.
- *
- * In the temacs dump below, notice that the Global Offset Table
- * (.got) and the Dynamic link data (.dynamic) come between .data1 and
- * .bss. It does not work to overlap .data with these fields.
- *
- * The solution is to create a new .data segment. This segment is
- * filled with data from the current process. Since the contents of
- * various sections refer to sections by index, the new .data segment
- * is made the last in the table to avoid changing any existing index.
-
- * This is an example of how the section headers are changed. "Addr"
- * is a process virtual address. "Offset" is a file offset.
-
-raid:/nfs/raid/src/dist-18.56/src> dump -h temacs
-
-temacs:
-
- **** SECTION HEADER TABLE ****
-[No] Type Flags Addr Offset Size Name
- Link Info Adralgn Entsize
-
-[1] 1 2 0x80480d4 0xd4 0x13 .interp
- 0 0 0x1 0
-
-[2] 5 2 0x80480e8 0xe8 0x388 .hash
- 3 0 0x4 0x4
-
-[3] 11 2 0x8048470 0x470 0x7f0 .dynsym
- 4 1 0x4 0x10
-
-[4] 3 2 0x8048c60 0xc60 0x3ad .dynstr
- 0 0 0x1 0
-
-[5] 9 2 0x8049010 0x1010 0x338 .rel.plt
- 3 7 0x4 0x8
-
-[6] 1 6 0x8049348 0x1348 0x3 .init
- 0 0 0x4 0
-
-[7] 1 6 0x804934c 0x134c 0x680 .plt
- 0 0 0x4 0x4
-
-[8] 1 6 0x80499cc 0x19cc 0x3c56f .text
- 0 0 0x4 0
-
-[9] 1 6 0x8085f3c 0x3df3c 0x3 .fini
- 0 0 0x4 0
-
-[10] 1 2 0x8085f40 0x3df40 0x69c .rodata
- 0 0 0x4 0
-
-[11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1
- 0 0 0x4 0
-
-[12] 1 3 0x8088330 0x3f330 0x20afc .data
- 0 0 0x4 0
-
-[13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1
- 0 0 0x4 0
-
-[14] 1 3 0x80a96cc 0x606cc 0x1a8 .got
- 0 0 0x4 0x4
-
-[15] 6 3 0x80a9874 0x60874 0x80 .dynamic
- 4 0 0x4 0x8
-
-[16] 8 3 0x80a98f4 0x608f4 0x449c .bss
- 0 0 0x4 0
-
-[17] 2 0 0 0x608f4 0x9b90 .symtab
- 18 371 0x4 0x10
-
-[18] 3 0 0 0x6a484 0x8526 .strtab
- 0 0 0x1 0
-
-[19] 3 0 0 0x729aa 0x93 .shstrtab
- 0 0 0x1 0
-
-[20] 1 0 0 0x72a3d 0x68b7 .comment
- 0 0 0x1 0
-
-raid:/nfs/raid/src/dist-18.56/src> dump -h xemacs
-
-xemacs:
-
- **** SECTION HEADER TABLE ****
-[No] Type Flags Addr Offset Size Name
- Link Info Adralgn Entsize
-
-[1] 1 2 0x80480d4 0xd4 0x13 .interp
- 0 0 0x1 0
-
-[2] 5 2 0x80480e8 0xe8 0x388 .hash
- 3 0 0x4 0x4
-
-[3] 11 2 0x8048470 0x470 0x7f0 .dynsym
- 4 1 0x4 0x10
-
-[4] 3 2 0x8048c60 0xc60 0x3ad .dynstr
- 0 0 0x1 0
-
-[5] 9 2 0x8049010 0x1010 0x338 .rel.plt
- 3 7 0x4 0x8
-
-[6] 1 6 0x8049348 0x1348 0x3 .init
- 0 0 0x4 0
-
-[7] 1 6 0x804934c 0x134c 0x680 .plt
- 0 0 0x4 0x4
-
-[8] 1 6 0x80499cc 0x19cc 0x3c56f .text
- 0 0 0x4 0
-
-[9] 1 6 0x8085f3c 0x3df3c 0x3 .fini
- 0 0 0x4 0
-
-[10] 1 2 0x8085f40 0x3df40 0x69c .rodata
- 0 0 0x4 0
-
-[11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1
- 0 0 0x4 0
-
-[12] 1 3 0x8088330 0x3f330 0x20afc .data
- 0 0 0x4 0
-
-[13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1
- 0 0 0x4 0
-
-[14] 1 3 0x80a96cc 0x606cc 0x1a8 .got
- 0 0 0x4 0x4
-
-[15] 6 3 0x80a9874 0x60874 0x80 .dynamic
- 4 0 0x4 0x8
-
-[16] 8 3 0x80c6800 0x7d800 0 .bss
- 0 0 0x4 0
-
-[17] 2 0 0 0x7d800 0x9b90 .symtab
- 18 371 0x4 0x10
-
-[18] 3 0 0 0x87390 0x8526 .strtab
- 0 0 0x1 0
-
-[19] 3 0 0 0x8f8b6 0x93 .shstrtab
- 0 0 0x1 0
-
-[20] 1 0 0 0x8f949 0x68b7 .comment
- 0 0 0x1 0
-
-[21] 1 3 0x80a98f4 0x608f4 0x1cf0c .data
- 0 0 0x4 0
-
- * This is an example of how the file header is changed. "Shoff" is
- * the section header offset within the file. Since that table is
- * after the new .data section, it is moved. "Shnum" is the number of
- * sections, which we increment.
- *
- * "Phoff" is the file offset to the program header. "Phentsize" and
- * "Shentsz" are the program and section header entries sizes respectively.
- * These can be larger than the apparent struct sizes.
-
-raid:/nfs/raid/src/dist-18.56/src> dump -f temacs
-
-temacs:
-
- **** ELF HEADER ****
-Class Data Type Machine Version
-Entry Phoff Shoff Flags Ehsize
-Phentsize Phnum Shentsz Shnum Shstrndx
-
-1 1 2 3 1
-0x80499cc 0x34 0x792f4 0 0x34
-0x20 5 0x28 21 19
-
-raid:/nfs/raid/src/dist-18.56/src> dump -f xemacs
-
-xemacs:
-
- **** ELF HEADER ****
-Class Data Type Machine Version
-Entry Phoff Shoff Flags Ehsize
-Phentsize Phnum Shentsz Shnum Shstrndx
-
-1 1 2 3 1
-0x80499cc 0x34 0x96200 0 0x34
-0x20 5 0x28 22 19
-
- * These are the program headers. "Offset" is the file offset to the
- * segment. "Vaddr" is the memory load address. "Filesz" is the
- * segment size as it appears in the file, and "Memsz" is the size in
- * memory. Below, the third segment is the code and the fourth is the
- * data: the difference between Filesz and Memsz is .bss
-
-raid:/nfs/raid/src/dist-18.56/src> dump -o temacs
-
-temacs:
- ***** PROGRAM EXECUTION HEADER *****
-Type Offset Vaddr Paddr
-Filesz Memsz Flags Align
-
-6 0x34 0x8048034 0
-0xa0 0xa0 5 0
-
-3 0xd4 0 0
-0x13 0 4 0
-
-1 0x34 0x8048034 0
-0x3f2f9 0x3f2f9 5 0x1000
-
-1 0x3f330 0x8088330 0
-0x215c4 0x25a60 7 0x1000
-
-2 0x60874 0x80a9874 0
-0x80 0 7 0
-
-raid:/nfs/raid/src/dist-18.56/src> dump -o xemacs
-
-xemacs:
- ***** PROGRAM EXECUTION HEADER *****
-Type Offset Vaddr Paddr
-Filesz Memsz Flags Align
-
-6 0x34 0x8048034 0
-0xa0 0xa0 5 0
-
-3 0xd4 0 0
-0x13 0 4 0
-
-1 0x34 0x8048034 0
-0x3f2f9 0x3f2f9 5 0x1000
-
-1 0x3f330 0x8088330 0
-0x3e4d0 0x3e4d0 7 0x1000
-
-2 0x60874 0x80a9874 0
-0x80 0 7 0
-
-
- */
-
-/* Modified by wtien@urbana.mcd.mot.com of Motorola Inc.
- *
- * The above mechanism does not work if the unexeced ELF file is being
- * re-layout by other applications (such as `strip'). All the applications
- * that re-layout the internal of ELF will layout all sections in ascending
- * order of their file offsets. After the re-layout, the data2 section will
- * still be the LAST section in the section header vector, but its file offset
- * is now being pushed far away down, and causes part of it not to be mapped
- * in (ie. not covered by the load segment entry in PHDR vector), therefore
- * causes the new binary to fail.
- *
- * The solution is to modify the unexec algorithm to insert the new data2
- * section header right before the new bss section header, so their file
- * offsets will be in the ascending order. Since some of the section's (all
- * sections AFTER the bss section) indexes are now changed, we also need to
- * modify some fields to make them point to the right sections. This is done
- * by macro PATCH_INDEX. All the fields that need to be patched are:
- *
- * 1. ELF header e_shstrndx field.
- * 2. section header sh_link and sh_info field.
- * 3. symbol table entry st_shndx field.
- *
- * The above example now should look like:
-
- **** SECTION HEADER TABLE ****
-[No] Type Flags Addr Offset Size Name
- Link Info Adralgn Entsize
-
-[1] 1 2 0x80480d4 0xd4 0x13 .interp
- 0 0 0x1 0
-
-[2] 5 2 0x80480e8 0xe8 0x388 .hash
- 3 0 0x4 0x4
-
-[3] 11 2 0x8048470 0x470 0x7f0 .dynsym
- 4 1 0x4 0x10
-
-[4] 3 2 0x8048c60 0xc60 0x3ad .dynstr
- 0 0 0x1 0
-
-[5] 9 2 0x8049010 0x1010 0x338 .rel.plt
- 3 7 0x4 0x8
-
-[6] 1 6 0x8049348 0x1348 0x3 .init
- 0 0 0x4 0
-
-[7] 1 6 0x804934c 0x134c 0x680 .plt
- 0 0 0x4 0x4
-
-[8] 1 6 0x80499cc 0x19cc 0x3c56f .text
- 0 0 0x4 0
-
-[9] 1 6 0x8085f3c 0x3df3c 0x3 .fini
- 0 0 0x4 0
-
-[10] 1 2 0x8085f40 0x3df40 0x69c .rodata
- 0 0 0x4 0
-
-[11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1
- 0 0 0x4 0
-
-[12] 1 3 0x8088330 0x3f330 0x20afc .data
- 0 0 0x4 0
-
-[13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1
- 0 0 0x4 0
-
-[14] 1 3 0x80a96cc 0x606cc 0x1a8 .got
- 0 0 0x4 0x4
-
-[15] 6 3 0x80a9874 0x60874 0x80 .dynamic
- 4 0 0x4 0x8
-
-[16] 1 3 0x80a98f4 0x608f4 0x1cf0c .data
- 0 0 0x4 0
-
-[17] 8 3 0x80c6800 0x7d800 0 .bss
- 0 0 0x4 0
-
-[18] 2 0 0 0x7d800 0x9b90 .symtab
- 19 371 0x4 0x10
-
-[19] 3 0 0 0x87390 0x8526 .strtab
- 0 0 0x1 0
-
-[20] 3 0 0 0x8f8b6 0x93 .shstrtab
- 0 0 0x1 0
-
-[21] 1 0 0 0x8f949 0x68b7 .comment
- 0 0 0x1 0
-
- */
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <memory.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <elf.h>
-#include <sys/mman.h>
-
-#ifdef __alpha__
-# include <sym.h> /* get COFF debugging symbol table declaration */
-#endif
-
-#if __GNU_LIBRARY__ - 0 >= 6
-# include <link.h> /* get ElfW etc */
-#endif
-
-#ifndef ElfW
-# ifdef __STDC__
-# define ElfW(type) Elf32_##type
-# else
-# define ElfW(type) Elf32_/**/type
-# endif
-#endif
-
-#ifndef emacs
-#define fatal(a, b, c) fprintf (stderr, a, b, c), exit (1)
-#else
-#include <config.h>
-extern void fatal (char *, ...);
-#endif
-
-#ifndef ELF_BSS_SECTION_NAME
-#define ELF_BSS_SECTION_NAME ".bss"
-#endif
-
-/* Get the address of a particular section or program header entry,
- * accounting for the size of the entries.
- */
-/*
- On PPC Reference Platform running Solaris 2.5.1
- the plt section is also of type NOBI like the bss section.
- (not really stored) and therefore sections after the bss
- section start at the plt offset. The plt section is always
- the one just before the bss section.
- Thus, we modify the test from
- if (NEW_SECTION_H (nn).sh_offset >= new_data2_offset)
- to
- if (NEW_SECTION_H (nn).sh_offset >=
- OLD_SECTION_H (old_bss_index-1).sh_offset)
- This is just a hack. We should put the new data section
- before the .plt section.
- And we should not have this routine at all but use
- the libelf library to read the old file and create the new
- file.
- The changed code is minimal and depends on prep set in m/prep.h
- Erik Deumens
- Quantum Theory Project
- University of Florida
- deumens@qtp.ufl.edu
- Apr 23, 1996
- */
-
-#define OLD_SECTION_H(n) \
- (*(ElfW(Shdr) *) ((byte *) old_section_h + old_file_h->e_shentsize * (n)))
-#define NEW_SECTION_H(n) \
- (*(ElfW(Shdr) *) ((byte *) new_section_h + new_file_h->e_shentsize * (n)))
-#define OLD_PROGRAM_H(n) \
- (*(ElfW(Phdr) *) ((byte *) old_program_h + old_file_h->e_phentsize * (n)))
-#define NEW_PROGRAM_H(n) \
- (*(ElfW(Phdr) *) ((byte *) new_program_h + new_file_h->e_phentsize * (n)))
-
-#define PATCH_INDEX(n) \
- do { \
- if ((int) (n) >= old_bss_index) \
- (n)++; } while (0)
-typedef unsigned char byte;
-
-/* Round X up to a multiple of Y. */
-
-int
-round_up (x, y)
- int x, y;
-{
- int rem = x % y;
- if (rem == 0)
- return x;
- return x - rem + y;
-}
-
-/* ****************************************************************
- * unexec
- *
- * driving logic.
- *
- * In ELF, this works by replacing the old .bss section with a new
- * .data section, and inserting an empty .bss immediately afterwards.
- *
- */
-void
-unexec (new_name, old_name, data_start, bss_start, entry_address)
- char *new_name, *old_name;
- unsigned data_start, bss_start, entry_address;
-{
- int new_file, old_file, new_file_size;
-
- /* Pointers to the base of the image of the two files. */
- caddr_t old_base, new_base;
-
- /* Pointers to the file, program and section headers for the old and new
- * files.
- */
- ElfW(Ehdr) *old_file_h, *new_file_h;
- ElfW(Phdr) *old_program_h, *new_program_h;
- ElfW(Shdr) *old_section_h, *new_section_h;
-
- /* Point to the section name table in the old file */
- char *old_section_names;
-
- ElfW(Addr) old_bss_addr, new_bss_addr;
- ElfW(Word) old_bss_size, new_data2_size;
- ElfW(Off) new_data2_offset;
- ElfW(Addr) new_data2_addr;
-
- int n, nn, old_bss_index, old_data_index, new_data2_index;
- struct stat stat_buf;
-
- /* Open the old file & map it into the address space. */
-
- old_file = open (old_name, O_RDONLY);
-
- if (old_file < 0)
- fatal ("Can't open %s for reading: errno %d\n", old_name, errno);
-
- if (fstat (old_file, &stat_buf) == -1)
- fatal ("Can't fstat (%s): errno %d\n", old_name, errno);
-
- old_base = mmap (0, stat_buf.st_size, PROT_READ, MAP_SHARED, old_file, 0);
-
- if (old_base == (caddr_t) -1)
- fatal ("Can't mmap (%s): errno %d\n", old_name, errno);
-
-#ifdef DEBUG
- fprintf (stderr, "mmap (%s, %x) -> %x\n", old_name, stat_buf.st_size,
- old_base);
-#endif
-
- /* Get pointers to headers & section names */
-
- old_file_h = (ElfW(Ehdr) *) old_base;
- old_program_h = (ElfW(Phdr) *) ((byte *) old_base + old_file_h->e_phoff);
- old_section_h = (ElfW(Shdr) *) ((byte *) old_base + old_file_h->e_shoff);
- old_section_names = (char *) old_base
- + OLD_SECTION_H (old_file_h->e_shstrndx).sh_offset;
-
- /* Find the old .bss section. Figure out parameters of the new
- * data2 and bss sections.
- */
-
- for (old_bss_index = 1; old_bss_index < (int) old_file_h->e_shnum;
- old_bss_index++)
- {
-#ifdef DEBUG
- fprintf (stderr, "Looking for .bss - found %s\n",
- old_section_names + OLD_SECTION_H (old_bss_index).sh_name);
-#endif
- if (!strcmp (old_section_names + OLD_SECTION_H (old_bss_index).sh_name,
- ELF_BSS_SECTION_NAME))
- break;
- }
- if (old_bss_index == old_file_h->e_shnum)
- fatal ("Can't find .bss in %s.\n", old_name, 0);
-
- old_bss_addr = OLD_SECTION_H (old_bss_index).sh_addr;
- old_bss_size = OLD_SECTION_H (old_bss_index).sh_size;
-#if defined(emacs) || !defined(DEBUG)
- new_bss_addr = (ElfW(Addr)) sbrk (0);
-#else
- new_bss_addr = old_bss_addr + old_bss_size + 0x1234;
-#endif
- new_data2_addr = old_bss_addr;
- new_data2_size = new_bss_addr - old_bss_addr;
- new_data2_offset = OLD_SECTION_H (old_bss_index).sh_offset;
-
-#ifdef DEBUG
- fprintf (stderr, "old_bss_index %d\n", old_bss_index);
- fprintf (stderr, "old_bss_addr %x\n", old_bss_addr);
- fprintf (stderr, "old_bss_size %x\n", old_bss_size);
- fprintf (stderr, "new_bss_addr %x\n", new_bss_addr);
- fprintf (stderr, "new_data2_addr %x\n", new_data2_addr);
- fprintf (stderr, "new_data2_size %x\n", new_data2_size);
- fprintf (stderr, "new_data2_offset %x\n", new_data2_offset);
-#endif
-
- if ((unsigned) new_bss_addr < (unsigned) old_bss_addr + old_bss_size)
- fatal (".bss shrank when undumping???\n", 0, 0);
-
- /* Set the output file to the right size and mmap it. Set
- * pointers to various interesting objects. stat_buf still has
- * old_file data.
- */
-
- new_file = open (new_name, O_RDWR | O_CREAT, 0666);
- if (new_file < 0)
- fatal ("Can't creat (%s): errno %d\n", new_name, errno);
-
- new_file_size = stat_buf.st_size + old_file_h->e_shentsize + new_data2_size;
-
- if (ftruncate (new_file, new_file_size))
- fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno);
-
-#ifdef UNEXEC_USE_MAP_PRIVATE
- new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_PRIVATE,
- new_file, 0);
-#else
- new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_SHARED,
- new_file, 0);
-#endif
-
- if (new_base == (caddr_t) -1)
- fatal ("Can't mmap (%s): errno %d\n", new_name, errno);
-
- new_file_h = (ElfW(Ehdr) *) new_base;
- new_program_h = (ElfW(Phdr) *) ((byte *) new_base + old_file_h->e_phoff);
- new_section_h = (ElfW(Shdr) *)
- ((byte *) new_base + old_file_h->e_shoff + new_data2_size);
-
- /* Make our new file, program and section headers as copies of the
- * originals.
- */
-
- memcpy (new_file_h, old_file_h, old_file_h->e_ehsize);
- memcpy (new_program_h, old_program_h,
- old_file_h->e_phnum * old_file_h->e_phentsize);
-
- /* Modify the e_shstrndx if necessary. */
- PATCH_INDEX (new_file_h->e_shstrndx);
-
- /* Fix up file header. We'll add one section. Section header is
- * further away now.
- */
-
- new_file_h->e_shoff += new_data2_size;
- new_file_h->e_shnum += 1;
-
-#ifdef DEBUG
- fprintf (stderr, "Old section offset %x\n", old_file_h->e_shoff);
- fprintf (stderr, "Old section count %d\n", old_file_h->e_shnum);
- fprintf (stderr, "New section offset %x\n", new_file_h->e_shoff);
- fprintf (stderr, "New section count %d\n", new_file_h->e_shnum);
-#endif
-
- /* Fix up a new program header. Extend the writable data segment so
- * that the bss area is covered too. Find that segment by looking
- * for a segment that ends just before the .bss area. Make sure
- * that no segments are above the new .data2. Put a loop at the end
- * to adjust the offset and address of any segment that is above
- * data2, just in case we decide to allow this later.
- */
-
- for (n = new_file_h->e_phnum - 1; n >= 0; n--)
- {
- /* Compute maximum of all requirements for alignment of section. */
- int alignment = (NEW_PROGRAM_H (n)).p_align;
- if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment)
- alignment = OLD_SECTION_H (old_bss_index).sh_addralign;
-
- if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz > old_bss_addr)
- fatal ("Program segment above .bss in %s\n", old_name, 0);
-
- if (NEW_PROGRAM_H (n).p_type == PT_LOAD
- && (round_up ((NEW_PROGRAM_H (n)).p_vaddr
- + (NEW_PROGRAM_H (n)).p_filesz,
- alignment)
- == round_up (old_bss_addr, alignment)))
- break;
- }
- if (n < 0)
- fatal ("Couldn't find segment next to .bss in %s\n", old_name, 0);
-
- NEW_PROGRAM_H (n).p_filesz += new_data2_size;
- NEW_PROGRAM_H (n).p_memsz = NEW_PROGRAM_H (n).p_filesz;
-
-#if 0 /* Maybe allow section after data2 - does this ever happen? */
- for (n = new_file_h->e_phnum - 1; n >= 0; n--)
- {
- if (NEW_PROGRAM_H (n).p_vaddr
- && NEW_PROGRAM_H (n).p_vaddr >= new_data2_addr)
- NEW_PROGRAM_H (n).p_vaddr += new_data2_size - old_bss_size;
-
- if (NEW_PROGRAM_H (n).p_offset >= new_data2_offset)
- NEW_PROGRAM_H (n).p_offset += new_data2_size;
- }
-#endif
-
- /* Fix up section headers based on new .data2 section. Any section
- * whose offset or virtual address is after the new .data2 section
- * gets its value adjusted. .bss size becomes zero and new address
- * is set. data2 section header gets added by copying the existing
- * .data header and modifying the offset, address and size.
- */
- for (old_data_index = 1; old_data_index < (int) old_file_h->e_shnum;
- old_data_index++)
- if (!strcmp (old_section_names + OLD_SECTION_H (old_data_index).sh_name,
- ".data"))
- break;
- if (old_data_index == old_file_h->e_shnum)
- fatal ("Can't find .data in %s.\n", old_name, 0);
-
- /* Walk through all section headers, insert the new data2 section right
- before the new bss section. */
- for (n = 1, nn = 1; n < (int) old_file_h->e_shnum; n++, nn++)
- {
- caddr_t src;
- /* If it is bss section, insert the new data2 section before it. */
- if (n == old_bss_index)
- {
- /* Steal the data section header for this data2 section. */
- memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (old_data_index),
- new_file_h->e_shentsize);
-
- NEW_SECTION_H (nn).sh_addr = new_data2_addr;
- NEW_SECTION_H (nn).sh_offset = new_data2_offset;
- NEW_SECTION_H (nn).sh_size = new_data2_size;
- /* Use the bss section's alignment. This will assure that the
- new data2 section always be placed in the same spot as the old
- bss section by any other application. */
- NEW_SECTION_H (nn).sh_addralign = OLD_SECTION_H (n).sh_addralign;
-
- /* Now copy over what we have in the memory now. */
- memcpy (NEW_SECTION_H (nn).sh_offset + new_base,
- (caddr_t) OLD_SECTION_H (n).sh_addr,
- new_data2_size);
- nn++;
- }
-
- memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n),
- old_file_h->e_shentsize);
-
- /* The new bss section's size is zero, and its file offset and virtual
- address should be off by NEW_DATA2_SIZE. */
- if (n == old_bss_index)
- {
- /* NN should be `old_bss_index + 1' at this point. */
- NEW_SECTION_H (nn).sh_offset += new_data2_size;
- NEW_SECTION_H (nn).sh_addr += new_data2_size;
- /* Let the new bss section address alignment be the same as the
- section address alignment followed the old bss section, so
- this section will be placed in exactly the same place. */
- NEW_SECTION_H (nn).sh_addralign = OLD_SECTION_H (nn).sh_addralign;
- NEW_SECTION_H (nn).sh_size = 0;
- }
- else
- {
- /* Any section that was original placed AFTER the bss
- section should now be off by NEW_DATA2_SIZE. */
-#ifdef SOLARIS_POWERPC
- /* On PPC Reference Platform running Solaris 2.5.1
- the plt section is also of type NOBI like the bss section.
- (not really stored) and therefore sections after the bss
- section start at the plt offset. The plt section is always
- the one just before the bss section.
- It would be better to put the new data section before
- the .plt section, or use libelf instead.
- Erik Deumens, deumens@qtp.ufl.edu. */
- if (NEW_SECTION_H (nn).sh_offset
- >= OLD_SECTION_H (old_bss_index-1).sh_offset)
- NEW_SECTION_H (nn).sh_offset += new_data2_size;
-#else
- if (round_up (NEW_SECTION_H (nn).sh_offset,
- OLD_SECTION_H (old_bss_index).sh_addralign)
- >= new_data2_offset)
- NEW_SECTION_H (nn).sh_offset += new_data2_size;
-#endif
- /* Any section that was originally placed after the section
- header table should now be off by the size of one section
- header table entry. */
- if (NEW_SECTION_H (nn).sh_offset > new_file_h->e_shoff)
- NEW_SECTION_H (nn).sh_offset += new_file_h->e_shentsize;
- }
-
- /* If any section hdr refers to the section after the new .data
- section, make it refer to next one because we have inserted
- a new section in between. */
-
- PATCH_INDEX (NEW_SECTION_H (nn).sh_link);
- /* For symbol tables, info is a symbol table index,
- so don't change it. */
- if (NEW_SECTION_H (nn).sh_type != SHT_SYMTAB
- && NEW_SECTION_H (nn).sh_type != SHT_DYNSYM)
- PATCH_INDEX (NEW_SECTION_H (nn).sh_info);
-
- /* Now, start to copy the content of sections. */
- if (NEW_SECTION_H (nn).sh_type == SHT_NULL
- || NEW_SECTION_H (nn).sh_type == SHT_NOBITS)
- continue;
-
- /* Write out the sections. .data and .data1 (and data2, called
- ".data" in the strings table) get copied from the current process
- instead of the old file. */
- if (!strcmp (old_section_names + NEW_SECTION_H (n).sh_name, ".data")
- || !strcmp ((old_section_names + NEW_SECTION_H (n).sh_name),
- ".data1"))
- src = (caddr_t) OLD_SECTION_H (n).sh_addr;
- else
- src = old_base + OLD_SECTION_H (n).sh_offset;
-
- memcpy (NEW_SECTION_H (nn).sh_offset + new_base, src,
- NEW_SECTION_H (nn).sh_size);
-
-#ifdef __alpha__
- /* Update Alpha COFF symbol table: */
- if (strcmp (old_section_names + OLD_SECTION_H (n).sh_name, ".mdebug")
- == 0)
- {
- pHDRR symhdr = (pHDRR) (NEW_SECTION_H (nn).sh_offset + new_base);
-
- symhdr->cbLineOffset += new_data2_size;
- symhdr->cbDnOffset += new_data2_size;
- symhdr->cbPdOffset += new_data2_size;
- symhdr->cbSymOffset += new_data2_size;
- symhdr->cbOptOffset += new_data2_size;
- symhdr->cbAuxOffset += new_data2_size;
- symhdr->cbSsOffset += new_data2_size;
- symhdr->cbSsExtOffset += new_data2_size;
- symhdr->cbFdOffset += new_data2_size;
- symhdr->cbRfdOffset += new_data2_size;
- symhdr->cbExtOffset += new_data2_size;
- }
-#endif /* __alpha__ */
-
- /* If it is the symbol table, its st_shndx field needs to be patched. */
- if (NEW_SECTION_H (nn).sh_type == SHT_SYMTAB
- || NEW_SECTION_H (nn).sh_type == SHT_DYNSYM)
- {
- ElfW(Shdr) *spt = &NEW_SECTION_H (nn);
- unsigned int num = spt->sh_size / spt->sh_entsize;
- ElfW(Sym) * sym = (ElfW(Sym) *) (NEW_SECTION_H (nn).sh_offset +
- new_base);
- for (; num--; sym++)
- {
- if ((sym->st_shndx == SHN_UNDEF)
- || (sym->st_shndx == SHN_ABS)
- || (sym->st_shndx == SHN_COMMON))
- continue;
-
- PATCH_INDEX (sym->st_shndx);
- }
- }
- }
-
- /* Update the symbol values of _edata and _end. */
- for (n = new_file_h->e_shnum - 1; n; n--)
- {
- byte *symnames;
- ElfW(Sym) *symp, *symendp;
-
- if (NEW_SECTION_H (n).sh_type != SHT_DYNSYM
- && NEW_SECTION_H (n).sh_type != SHT_SYMTAB)
- continue;
-
- symnames = ((byte *) new_base
- + NEW_SECTION_H (NEW_SECTION_H (n).sh_link).sh_offset);
- symp = (ElfW(Sym) *) (NEW_SECTION_H (n).sh_offset + new_base);
- symendp = (ElfW(Sym) *) ((byte *)symp + NEW_SECTION_H (n).sh_size);
-
- for (; symp < symendp; symp ++)
- if (strcmp ((char *) (symnames + symp->st_name), "_end") == 0
- || strcmp ((char *) (symnames + symp->st_name), "_edata") == 0)
- memcpy (&symp->st_value, &new_bss_addr, sizeof (new_bss_addr));
- }
-
- /* This loop seeks out relocation sections for the data section, so
- that it can undo relocations performed by the runtime linker. */
- for (n = new_file_h->e_shnum - 1; n; n--)
- {
- ElfW(Shdr) section = NEW_SECTION_H (n);
- switch (section.sh_type) {
- default:
- break;
- case SHT_REL:
- case SHT_RELA:
- /* This code handles two different size structs, but there should
- be no harm in that provided that r_offset is always the first
- member. */
- nn = section.sh_info;
- if (!strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".data")
- || !strcmp ((old_section_names + NEW_SECTION_H (nn).sh_name),
- ".data1"))
- {
- ElfW(Addr) offset = NEW_SECTION_H (nn).sh_addr -
- NEW_SECTION_H (nn).sh_offset;
- caddr_t reloc = old_base + section.sh_offset, end;
- for (end = reloc + section.sh_size; reloc < end;
- reloc += section.sh_entsize)
- {
- ElfW(Addr) addr = ((ElfW(Rel) *) reloc)->r_offset - offset;
-#ifdef __alpha__
- /* The Alpha ELF binutils currently have a bug that
- sometimes results in relocs that contain all
- zeroes. Work around this for now... */
- if (((ElfW(Rel) *) reloc)->r_offset == 0)
- continue;
-#endif
- memcpy (new_base + addr, old_base + addr, sizeof(ElfW(Addr)));
- }
- }
- break;
- }
- }
-
-#ifdef UNEXEC_USE_MAP_PRIVATE
- if (lseek (new_file, 0, SEEK_SET) == -1)
- fatal ("Can't rewind (%s): errno %d\n", new_name, errno);
-
- if (write (new_file, new_base, new_file_size) != new_file_size)
- fatal ("Can't write (%s): errno %d\n", new_name, errno);
-#endif
-
- /* Close the files and make the new file executable. */
-
- if (close (old_file))
- fatal ("Can't close (%s): errno %d\n", old_name, errno);
-
- if (close (new_file))
- fatal ("Can't close (%s): errno %d\n", new_name, errno);
-
- if (stat (new_name, &stat_buf) == -1)
- fatal ("Can't stat (%s): errno %d\n", new_name, errno);
-
- n = umask (777);
- umask (n);
- stat_buf.st_mode |= 0111 & ~n;
- if (chmod (new_name, stat_buf.st_mode) == -1)
- fatal ("Can't chmod (%s): errno %d\n", new_name, errno);
-}
diff --git a/src/unexsgi.c b/src/unexsgi.c
deleted file mode 100644
index cd0067f08d9..00000000000
--- a/src/unexsgi.c
+++ /dev/null
@@ -1,900 +0,0 @@
-/* Copyright (C) 1985, 1986, 1987, 1988, 1990, 1992
- Free Software Foundation, Inc.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.
-
-In other words, you are welcome to use, share and improve this program.
-You are forbidden to forbid anyone else to use, share and improve
-what you give them. Help stamp out software-hoarding! */
-
-
-/*
- * unexec.c - Convert a running program into an a.out file.
- *
- * Author: Spencer W. Thomas
- * Computer Science Dept.
- * University of Utah
- * Date: Tue Mar 2 1982
- * Modified heavily since then.
- *
- * Synopsis:
- * unexec (new_name, a_name, data_start, bss_start, entry_address)
- * char *new_name, *a_name;
- * unsigned data_start, bss_start, entry_address;
- *
- * Takes a snapshot of the program and makes an a.out format file in the
- * file named by the string argument new_name.
- * If a_name is non-NULL, the symbol table will be taken from the given file.
- * On some machines, an existing a_name file is required.
- *
- * The boundaries within the a.out file may be adjusted with the data_start
- * and bss_start arguments. Either or both may be given as 0 for defaults.
- *
- * Data_start gives the boundary between the text segment and the data
- * segment of the program. The text segment can contain shared, read-only
- * program code and literal data, while the data segment is always unshared
- * and unprotected. Data_start gives the lowest unprotected address.
- * The value you specify may be rounded down to a suitable boundary
- * as required by the machine you are using.
- *
- * Specifying zero for data_start means the boundary between text and data
- * should not be the same as when the program was loaded.
- * If NO_REMAP is defined, the argument data_start is ignored and the
- * segment boundaries are never changed.
- *
- * Bss_start indicates how much of the data segment is to be saved in the
- * a.out file and restored when the program is executed. It gives the lowest
- * unsaved address, and is rounded up to a page boundary. The default when 0
- * is given assumes that the entire data segment is to be stored, including
- * the previous data and bss as well as any additional storage allocated with
- * break (2).
- *
- * The new file is set up to start at entry_address.
- *
- * If you make improvements I'd like to get them too.
- * harpo!utah-cs!thomas, thomas@Utah-20
- *
- */
-
-/* Even more heavily modified by james@bigtex.cactus.org of Dell Computer Co.
- * ELF support added.
- *
- * Basic theory: the data space of the running process needs to be
- * dumped to the output file. Normally we would just enlarge the size
- * of .data, scooting everything down. But we can't do that in ELF,
- * because there is often something between the .data space and the
- * .bss space.
- *
- * In the temacs dump below, notice that the Global Offset Table
- * (.got) and the Dynamic link data (.dynamic) come between .data1 and
- * .bss. It does not work to overlap .data with these fields.
- *
- * The solution is to create a new .data segment. This segment is
- * filled with data from the current process. Since the contents of
- * various sections refer to sections by index, the new .data segment
- * is made the last in the table to avoid changing any existing index.
-
- * This is an example of how the section headers are changed. "Addr"
- * is a process virtual address. "Offset" is a file offset.
-
-raid:/nfs/raid/src/dist-18.56/src> dump -h temacs
-
-temacs:
-
- **** SECTION HEADER TABLE ****
-[No] Type Flags Addr Offset Size Name
- Link Info Adralgn Entsize
-
-[1] 1 2 0x80480d4 0xd4 0x13 .interp
- 0 0 0x1 0
-
-[2] 5 2 0x80480e8 0xe8 0x388 .hash
- 3 0 0x4 0x4
-
-[3] 11 2 0x8048470 0x470 0x7f0 .dynsym
- 4 1 0x4 0x10
-
-[4] 3 2 0x8048c60 0xc60 0x3ad .dynstr
- 0 0 0x1 0
-
-[5] 9 2 0x8049010 0x1010 0x338 .rel.plt
- 3 7 0x4 0x8
-
-[6] 1 6 0x8049348 0x1348 0x3 .init
- 0 0 0x4 0
-
-[7] 1 6 0x804934c 0x134c 0x680 .plt
- 0 0 0x4 0x4
-
-[8] 1 6 0x80499cc 0x19cc 0x3c56f .text
- 0 0 0x4 0
-
-[9] 1 6 0x8085f3c 0x3df3c 0x3 .fini
- 0 0 0x4 0
-
-[10] 1 2 0x8085f40 0x3df40 0x69c .rodata
- 0 0 0x4 0
-
-[11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1
- 0 0 0x4 0
-
-[12] 1 3 0x8088330 0x3f330 0x20afc .data
- 0 0 0x4 0
-
-[13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1
- 0 0 0x4 0
-
-[14] 1 3 0x80a96cc 0x606cc 0x1a8 .got
- 0 0 0x4 0x4
-
-[15] 6 3 0x80a9874 0x60874 0x80 .dynamic
- 4 0 0x4 0x8
-
-[16] 8 3 0x80a98f4 0x608f4 0x449c .bss
- 0 0 0x4 0
-
-[17] 2 0 0 0x608f4 0x9b90 .symtab
- 18 371 0x4 0x10
-
-[18] 3 0 0 0x6a484 0x8526 .strtab
- 0 0 0x1 0
-
-[19] 3 0 0 0x729aa 0x93 .shstrtab
- 0 0 0x1 0
-
-[20] 1 0 0 0x72a3d 0x68b7 .comment
- 0 0 0x1 0
-
-raid:/nfs/raid/src/dist-18.56/src> dump -h xemacs
-
-xemacs:
-
- **** SECTION HEADER TABLE ****
-[No] Type Flags Addr Offset Size Name
- Link Info Adralgn Entsize
-
-[1] 1 2 0x80480d4 0xd4 0x13 .interp
- 0 0 0x1 0
-
-[2] 5 2 0x80480e8 0xe8 0x388 .hash
- 3 0 0x4 0x4
-
-[3] 11 2 0x8048470 0x470 0x7f0 .dynsym
- 4 1 0x4 0x10
-
-[4] 3 2 0x8048c60 0xc60 0x3ad .dynstr
- 0 0 0x1 0
-
-[5] 9 2 0x8049010 0x1010 0x338 .rel.plt
- 3 7 0x4 0x8
-
-[6] 1 6 0x8049348 0x1348 0x3 .init
- 0 0 0x4 0
-
-[7] 1 6 0x804934c 0x134c 0x680 .plt
- 0 0 0x4 0x4
-
-[8] 1 6 0x80499cc 0x19cc 0x3c56f .text
- 0 0 0x4 0
-
-[9] 1 6 0x8085f3c 0x3df3c 0x3 .fini
- 0 0 0x4 0
-
-[10] 1 2 0x8085f40 0x3df40 0x69c .rodata
- 0 0 0x4 0
-
-[11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1
- 0 0 0x4 0
-
-[12] 1 3 0x8088330 0x3f330 0x20afc .data
- 0 0 0x4 0
-
-[13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1
- 0 0 0x4 0
-
-[14] 1 3 0x80a96cc 0x606cc 0x1a8 .got
- 0 0 0x4 0x4
-
-[15] 6 3 0x80a9874 0x60874 0x80 .dynamic
- 4 0 0x4 0x8
-
-[16] 8 3 0x80c6800 0x7d800 0 .bss
- 0 0 0x4 0
-
-[17] 2 0 0 0x7d800 0x9b90 .symtab
- 18 371 0x4 0x10
-
-[18] 3 0 0 0x87390 0x8526 .strtab
- 0 0 0x1 0
-
-[19] 3 0 0 0x8f8b6 0x93 .shstrtab
- 0 0 0x1 0
-
-[20] 1 0 0 0x8f949 0x68b7 .comment
- 0 0 0x1 0
-
-[21] 1 3 0x80a98f4 0x608f4 0x1cf0c .data
- 0 0 0x4 0
-
- * This is an example of how the file header is changed. "Shoff" is
- * the section header offset within the file. Since that table is
- * after the new .data section, it is moved. "Shnum" is the number of
- * sections, which we increment.
- *
- * "Phoff" is the file offset to the program header. "Phentsize" and
- * "Shentsz" are the program and section header entries sizes respectively.
- * These can be larger than the apparent struct sizes.
-
-raid:/nfs/raid/src/dist-18.56/src> dump -f temacs
-
-temacs:
-
- **** ELF HEADER ****
-Class Data Type Machine Version
-Entry Phoff Shoff Flags Ehsize
-Phentsize Phnum Shentsz Shnum Shstrndx
-
-1 1 2 3 1
-0x80499cc 0x34 0x792f4 0 0x34
-0x20 5 0x28 21 19
-
-raid:/nfs/raid/src/dist-18.56/src> dump -f xemacs
-
-xemacs:
-
- **** ELF HEADER ****
-Class Data Type Machine Version
-Entry Phoff Shoff Flags Ehsize
-Phentsize Phnum Shentsz Shnum Shstrndx
-
-1 1 2 3 1
-0x80499cc 0x34 0x96200 0 0x34
-0x20 5 0x28 22 19
-
- * These are the program headers. "Offset" is the file offset to the
- * segment. "Vaddr" is the memory load address. "Filesz" is the
- * segment size as it appears in the file, and "Memsz" is the size in
- * memory. Below, the third segment is the code and the fourth is the
- * data: the difference between Filesz and Memsz is .bss
-
-raid:/nfs/raid/src/dist-18.56/src> dump -o temacs
-
-temacs:
- ***** PROGRAM EXECUTION HEADER *****
-Type Offset Vaddr Paddr
-Filesz Memsz Flags Align
-
-6 0x34 0x8048034 0
-0xa0 0xa0 5 0
-
-3 0xd4 0 0
-0x13 0 4 0
-
-1 0x34 0x8048034 0
-0x3f2f9 0x3f2f9 5 0x1000
-
-1 0x3f330 0x8088330 0
-0x215c4 0x25a60 7 0x1000
-
-2 0x60874 0x80a9874 0
-0x80 0 7 0
-
-raid:/nfs/raid/src/dist-18.56/src> dump -o xemacs
-
-xemacs:
- ***** PROGRAM EXECUTION HEADER *****
-Type Offset Vaddr Paddr
-Filesz Memsz Flags Align
-
-6 0x34 0x8048034 0
-0xa0 0xa0 5 0
-
-3 0xd4 0 0
-0x13 0 4 0
-
-1 0x34 0x8048034 0
-0x3f2f9 0x3f2f9 5 0x1000
-
-1 0x3f330 0x8088330 0
-0x3e4d0 0x3e4d0 7 0x1000
-
-2 0x60874 0x80a9874 0
-0x80 0 7 0
-
-
- */
-
-/* Modified by wtien@urbana.mcd.mot.com of Motorola Inc.
- *
- * The above mechanism does not work if the unexeced ELF file is being
- * re-layout by other applications (such as `strip'). All the applications
- * that re-layout the internal of ELF will layout all sections in ascending
- * order of their file offsets. After the re-layout, the data2 section will
- * still be the LAST section in the section header vector, but its file offset
- * is now being pushed far away down, and causes part of it not to be mapped
- * in (ie. not covered by the load segment entry in PHDR vector), therefore
- * causes the new binary to fail.
- *
- * The solution is to modify the unexec algorithm to insert the new data2
- * section header right before the new bss section header, so their file
- * offsets will be in the ascending order. Since some of the section's (all
- * sections AFTER the bss section) indexes are now changed, we also need to
- * modify some fields to make them point to the right sections. This is done
- * by macro PATCH_INDEX. All the fields that need to be patched are:
- *
- * 1. ELF header e_shstrndx field.
- * 2. section header sh_link and sh_info field.
- * 3. symbol table entry st_shndx field.
- *
- * The above example now should look like:
-
- **** SECTION HEADER TABLE ****
-[No] Type Flags Addr Offset Size Name
- Link Info Adralgn Entsize
-
-[1] 1 2 0x80480d4 0xd4 0x13 .interp
- 0 0 0x1 0
-
-[2] 5 2 0x80480e8 0xe8 0x388 .hash
- 3 0 0x4 0x4
-
-[3] 11 2 0x8048470 0x470 0x7f0 .dynsym
- 4 1 0x4 0x10
-
-[4] 3 2 0x8048c60 0xc60 0x3ad .dynstr
- 0 0 0x1 0
-
-[5] 9 2 0x8049010 0x1010 0x338 .rel.plt
- 3 7 0x4 0x8
-
-[6] 1 6 0x8049348 0x1348 0x3 .init
- 0 0 0x4 0
-
-[7] 1 6 0x804934c 0x134c 0x680 .plt
- 0 0 0x4 0x4
-
-[8] 1 6 0x80499cc 0x19cc 0x3c56f .text
- 0 0 0x4 0
-
-[9] 1 6 0x8085f3c 0x3df3c 0x3 .fini
- 0 0 0x4 0
-
-[10] 1 2 0x8085f40 0x3df40 0x69c .rodata
- 0 0 0x4 0
-
-[11] 1 2 0x80865dc 0x3e5dc 0xd51 .rodata1
- 0 0 0x4 0
-
-[12] 1 3 0x8088330 0x3f330 0x20afc .data
- 0 0 0x4 0
-
-[13] 1 3 0x80a8e2c 0x5fe2c 0x89d .data1
- 0 0 0x4 0
-
-[14] 1 3 0x80a96cc 0x606cc 0x1a8 .got
- 0 0 0x4 0x4
-
-[15] 6 3 0x80a9874 0x60874 0x80 .dynamic
- 4 0 0x4 0x8
-
-[16] 1 3 0x80a98f4 0x608f4 0x1cf0c .data
- 0 0 0x4 0
-
-[17] 8 3 0x80c6800 0x7d800 0 .bss
- 0 0 0x4 0
-
-[18] 2 0 0 0x7d800 0x9b90 .symtab
- 19 371 0x4 0x10
-
-[19] 3 0 0 0x87390 0x8526 .strtab
- 0 0 0x1 0
-
-[20] 3 0 0 0x8f8b6 0x93 .shstrtab
- 0 0 0x1 0
-
-[21] 1 0 0 0x8f949 0x68b7 .comment
- 0 0 0x1 0
-
- */
-
-#include <config.h>
-#include <sys/types.h>
-#include <stdio.h>
-#include <sys/stat.h>
-#include <memory.h>
-#include <string.h>
-#include <errno.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <elf.h>
-#include <syms.h> /* for HDRR declaration */
-#include <sys/mman.h>
-
-#ifndef emacs
-#define fatal(a, b, c) fprintf(stderr, a, b, c), exit(1)
-#else
-extern void fatal(char *, ...);
-#endif
-
-/* Get the address of a particular section or program header entry,
- * accounting for the size of the entries.
- */
-
-#define OLD_SECTION_H(n) \
- (*(Elf32_Shdr *) ((byte *) old_section_h + old_file_h->e_shentsize * (n)))
-#define NEW_SECTION_H(n) \
- (*(Elf32_Shdr *) ((byte *) new_section_h + new_file_h->e_shentsize * (n)))
-#define OLD_PROGRAM_H(n) \
- (*(Elf32_Phdr *) ((byte *) old_program_h + old_file_h->e_phentsize * (n)))
-#define NEW_PROGRAM_H(n) \
- (*(Elf32_Phdr *) ((byte *) new_program_h + new_file_h->e_phentsize * (n)))
-
-#define PATCH_INDEX(n) \
- do { \
- if ((n) >= old_bss_index) \
- (n)++; } while (0)
-typedef unsigned char byte;
-
-/* Round X up to a multiple of Y. */
-
-int
-round_up (x, y)
- int x, y;
-{
- int rem = x % y;
- if (rem == 0)
- return x;
- return x - rem + y;
-}
-
-/* Return the index of the section named NAME.
- SECTION_NAMES, FILE_NAME and FILE_H give information
- about the file we are looking in.
-
- If we don't find the section NAME, that is a fatal error
- if NOERROR is 0; we return -1 if NOERROR is nonzero. */
-
-static int
-find_section (name, section_names, file_name, old_file_h, old_section_h, noerror)
- char *name;
- char *section_names;
- char *file_name;
- Elf32_Ehdr *old_file_h;
- Elf32_Shdr *old_section_h;
- int noerror;
-{
- int idx;
-
- for (idx = 1; idx < old_file_h->e_shnum; idx++)
- {
-#ifdef DEBUG
- fprintf (stderr, "Looking for %s - found %s\n", name,
- section_names + OLD_SECTION_H (idx).sh_name);
-#endif
- if (!strcmp (section_names + OLD_SECTION_H (idx).sh_name,
- name))
- break;
- }
- if (idx == old_file_h->e_shnum)
- {
- if (noerror)
- return -1;
- else
- fatal ("Can't find .bss in %s.\n", file_name, 0);
- }
-
- return idx;
-}
-
-/* ****************************************************************
- * unexec
- *
- * driving logic.
- *
- * In ELF, this works by replacing the old .bss section with a new
- * .data section, and inserting an empty .bss immediately afterwards.
- *
- */
-void
-unexec (new_name, old_name, data_start, bss_start, entry_address)
- char *new_name, *old_name;
- unsigned data_start, bss_start, entry_address;
-{
- extern unsigned int bss_end;
- int new_file, old_file, new_file_size;
-
- /* Pointers to the base of the image of the two files. */
- caddr_t old_base, new_base;
-
- /* Pointers to the file, program and section headers for the old and new
- files. */
- Elf32_Ehdr *old_file_h, *new_file_h;
- Elf32_Phdr *old_program_h, *new_program_h;
- Elf32_Shdr *old_section_h, *new_section_h;
-
- /* Point to the section name table in the old file. */
- char *old_section_names;
-
- Elf32_Addr old_bss_addr, new_bss_addr;
- Elf32_Word old_bss_size, new_data2_size;
- Elf32_Off new_data2_offset;
- Elf32_Addr new_data2_addr;
- Elf32_Addr new_offsets_shift;
-
- int n, nn, old_bss_index, old_data_index, new_data2_index;
- int old_mdebug_index;
- struct stat stat_buf;
-
- /* Open the old file & map it into the address space. */
-
- old_file = open (old_name, O_RDONLY);
-
- if (old_file < 0)
- fatal ("Can't open %s for reading: errno %d\n", old_name, errno);
-
- if (fstat (old_file, &stat_buf) == -1)
- fatal ("Can't fstat(%s): errno %d\n", old_name, errno);
-
- old_base = mmap (0, stat_buf.st_size, PROT_READ, MAP_SHARED, old_file, 0);
-
- if (old_base == (caddr_t) -1)
- fatal ("Can't mmap(%s): errno %d\n", old_name, errno);
-
-#ifdef DEBUG
- fprintf (stderr, "mmap(%s, %x) -> %x\n", old_name, stat_buf.st_size,
- old_base);
-#endif
-
- /* Get pointers to headers & section names. */
-
- old_file_h = (Elf32_Ehdr *) old_base;
- old_program_h = (Elf32_Phdr *) ((byte *) old_base + old_file_h->e_phoff);
- old_section_h = (Elf32_Shdr *) ((byte *) old_base + old_file_h->e_shoff);
- old_section_names
- = (char *) old_base + OLD_SECTION_H (old_file_h->e_shstrndx).sh_offset;
-
- /* Find the mdebug section, if any. */
-
- old_mdebug_index = find_section (".mdebug", old_section_names,
- old_name, old_file_h, old_section_h, 1);
-
- /* Find the old .bss section. */
-
- old_bss_index = find_section (".bss", old_section_names,
- old_name, old_file_h, old_section_h, 0);
-
- /* Find the old .data section. Figure out parameters of
- the new data2 and bss sections. */
-
- old_data_index = find_section (".data", old_section_names,
- old_name, old_file_h, old_section_h, 0);
-
- old_bss_addr = OLD_SECTION_H (old_bss_index).sh_addr;
- old_bss_size = OLD_SECTION_H (old_bss_index).sh_size;
-#if defined(emacs) || !defined(DEBUG)
- bss_end = (unsigned int) sbrk (0);
- new_bss_addr = (Elf32_Addr) bss_end;
-#else
- new_bss_addr = old_bss_addr + old_bss_size + 0x1234;
-#endif
- new_data2_addr = old_bss_addr;
- new_data2_size = new_bss_addr - old_bss_addr;
- new_data2_offset = OLD_SECTION_H (old_data_index).sh_offset +
- (new_data2_addr - OLD_SECTION_H (old_data_index).sh_addr);
- new_offsets_shift = new_bss_addr -
- ((old_bss_addr & ~0xfff) + ((old_bss_addr & 0xfff) ? 0x1000 : 0));
-
-#ifdef DEBUG
- fprintf (stderr, "old_bss_index %d\n", old_bss_index);
- fprintf (stderr, "old_bss_addr %x\n", old_bss_addr);
- fprintf (stderr, "old_bss_size %x\n", old_bss_size);
- fprintf (stderr, "new_bss_addr %x\n", new_bss_addr);
- fprintf (stderr, "new_data2_addr %x\n", new_data2_addr);
- fprintf (stderr, "new_data2_size %x\n", new_data2_size);
- fprintf (stderr, "new_data2_offset %x\n", new_data2_offset);
- fprintf (stderr, "new_offsets_shift %x\n", new_offsets_shift);
-#endif
-
- if ((unsigned) new_bss_addr < (unsigned) old_bss_addr + old_bss_size)
- fatal (".bss shrank when undumping???\n", 0, 0);
-
- /* Set the output file to the right size and mmap it. Set
- pointers to various interesting objects. stat_buf still has
- old_file data. */
-
- new_file = open (new_name, O_RDWR | O_CREAT, 0666);
- if (new_file < 0)
- fatal ("Can't creat (%s): errno %d\n", new_name, errno);
-
- new_file_size = stat_buf.st_size + old_file_h->e_shentsize + new_offsets_shift;
-
- if (ftruncate (new_file, new_file_size))
- fatal ("Can't ftruncate (%s): errno %d\n", new_name, errno);
-
- new_base = mmap (0, new_file_size, PROT_READ | PROT_WRITE, MAP_SHARED,
- new_file, 0);
-
- if (new_base == (caddr_t) -1)
- fatal ("Can't mmap (%s): errno %d\n", new_name, errno);
-
- new_file_h = (Elf32_Ehdr *) new_base;
- new_program_h = (Elf32_Phdr *) ((byte *) new_base + old_file_h->e_phoff);
- new_section_h
- = (Elf32_Shdr *) ((byte *) new_base + old_file_h->e_shoff
- + new_offsets_shift);
-
- /* Make our new file, program and section headers as copies of the
- originals. */
-
- memcpy (new_file_h, old_file_h, old_file_h->e_ehsize);
- memcpy (new_program_h, old_program_h,
- old_file_h->e_phnum * old_file_h->e_phentsize);
-
- /* Modify the e_shstrndx if necessary. */
- PATCH_INDEX (new_file_h->e_shstrndx);
-
- /* Fix up file header. We'll add one section. Section header is
- further away now. */
-
- new_file_h->e_shoff += new_offsets_shift;
- new_file_h->e_shnum += 1;
-
-#ifdef DEBUG
- fprintf (stderr, "Old section offset %x\n", old_file_h->e_shoff);
- fprintf (stderr, "Old section count %d\n", old_file_h->e_shnum);
- fprintf (stderr, "New section offset %x\n", new_file_h->e_shoff);
- fprintf (stderr, "New section count %d\n", new_file_h->e_shnum);
-#endif
-
- /* Fix up a new program header. Extend the writable data segment so
- that the bss area is covered too. Find that segment by looking
- for a segment that ends just before the .bss area. Make sure
- that no segments are above the new .data2. Put a loop at the end
- to adjust the offset and address of any segment that is above
- data2, just in case we decide to allow this later. */
-
- for (n = new_file_h->e_phnum - 1; n >= 0; n--)
- {
- /* Compute maximum of all requirements for alignment of section. */
- int alignment = (NEW_PROGRAM_H (n)).p_align;
- if ((OLD_SECTION_H (old_bss_index)).sh_addralign > alignment)
- alignment = OLD_SECTION_H (old_bss_index).sh_addralign;
-
- /* Supposedly this condition is okay for the SGI. */
-#if 0
- if (NEW_PROGRAM_H (n).p_vaddr + NEW_PROGRAM_H (n).p_filesz > old_bss_addr)
- fatal ("Program segment above .bss in %s\n", old_name, 0);
-#endif
-
- if (NEW_PROGRAM_H (n).p_type == PT_LOAD
- && (round_up ((NEW_PROGRAM_H (n)).p_vaddr
- + (NEW_PROGRAM_H (n)).p_filesz,
- alignment)
- == round_up (old_bss_addr, alignment)))
- break;
- }
- if (n < 0)
- fatal ("Couldn't find segment next to .bss in %s\n", old_name, 0);
-
- NEW_PROGRAM_H (n).p_filesz += new_offsets_shift;
- NEW_PROGRAM_H (n).p_memsz = NEW_PROGRAM_H (n).p_filesz;
-
-#if 1 /* Maybe allow section after data2 - does this ever happen? */
- for (n = new_file_h->e_phnum - 1; n >= 0; n--)
- {
- if (NEW_PROGRAM_H (n).p_vaddr
- && NEW_PROGRAM_H (n).p_vaddr >= new_data2_addr)
- NEW_PROGRAM_H (n).p_vaddr += new_offsets_shift - old_bss_size;
-
- if (NEW_PROGRAM_H (n).p_offset >= new_data2_offset)
- NEW_PROGRAM_H (n).p_offset += new_offsets_shift;
- }
-#endif
-
- /* Fix up section headers based on new .data2 section. Any section
- whose offset or virtual address is after the new .data2 section
- gets its value adjusted. .bss size becomes zero and new address
- is set. data2 section header gets added by copying the existing
- .data header and modifying the offset, address and size. */
- for (old_data_index = 1; old_data_index < old_file_h->e_shnum;
- old_data_index++)
- if (!strcmp (old_section_names + OLD_SECTION_H (old_data_index).sh_name,
- ".data"))
- break;
- if (old_data_index == old_file_h->e_shnum)
- fatal ("Can't find .data in %s.\n", old_name, 0);
-
- /* Walk through all section headers, insert the new data2 section right
- before the new bss section. */
- for (n = 1, nn = 1; n < old_file_h->e_shnum; n++, nn++)
- {
- caddr_t src;
-
- /* If it is bss section, insert the new data2 section before it. */
- if (n == old_bss_index)
- {
- /* Steal the data section header for this data2 section. */
- memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (old_data_index),
- new_file_h->e_shentsize);
-
- NEW_SECTION_H (nn).sh_addr = new_data2_addr;
- NEW_SECTION_H (nn).sh_offset = new_data2_offset;
- NEW_SECTION_H (nn).sh_size = new_data2_size;
- /* Use the bss section's alignment. This will assure that the
- new data2 section always be placed in the same spot as the old
- bss section by any other application. */
- NEW_SECTION_H (nn).sh_addralign = OLD_SECTION_H (n).sh_addralign;
-
- /* Now copy over what we have in the memory now. */
- memcpy (NEW_SECTION_H (nn).sh_offset + new_base,
- (caddr_t) OLD_SECTION_H (n).sh_addr,
- new_data2_size);
- nn++;
- memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n),
- old_file_h->e_shentsize);
-
- /* The new bss section's size is zero, and its file offset and virtual
- address should be off by NEW_OFFSETS_SHIFT. */
- NEW_SECTION_H (nn).sh_offset += new_offsets_shift;
- NEW_SECTION_H (nn).sh_addr = new_bss_addr;
- /* Let the new bss section address alignment be the same as the
- section address alignment followed the old bss section, so
- this section will be placed in exactly the same place. */
- NEW_SECTION_H (nn).sh_addralign = OLD_SECTION_H (nn).sh_addralign;
- NEW_SECTION_H (nn).sh_size = 0;
- }
- else
- {
- memcpy (&NEW_SECTION_H (nn), &OLD_SECTION_H (n),
- old_file_h->e_shentsize);
-
- /* Any section that was original placed AFTER the bss
- section must now be adjusted by NEW_OFFSETS_SHIFT. */
-
- if (NEW_SECTION_H (nn).sh_offset >= new_data2_offset)
- NEW_SECTION_H (nn).sh_offset += new_offsets_shift;
- }
-
- /* If any section hdr refers to the section after the new .data
- section, make it refer to next one because we have inserted
- a new section in between. */
-
- PATCH_INDEX (NEW_SECTION_H (nn).sh_link);
- /* For symbol tables, info is a symbol table index,
- so don't change it. */
- if (NEW_SECTION_H (nn).sh_type != SHT_SYMTAB
- && NEW_SECTION_H (nn).sh_type != SHT_DYNSYM)
- PATCH_INDEX (NEW_SECTION_H (nn).sh_info);
-
- /* Now, start to copy the content of sections. */
- if (NEW_SECTION_H (nn).sh_type == SHT_NULL
- || NEW_SECTION_H (nn).sh_type == SHT_NOBITS)
- continue;
-
- /* Write out the sections. .data and .data1 (and data2, called
- ".data" in the strings table) get copied from the current process
- instead of the old file. */
- if (!strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".data")
- || !strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".data1")
-#ifdef IRIX6_5
- /* Under IRIX 6.5 gcc places objects with adresses relative to
- shared symbols in the section .rodata, which are adjusted at
- startup time. Unfortunately they aren't adjusted after unexec,
- so with this configuration we must get .rodata also from memory.
- Do any other configurations need this, too?
- <Wolfgang.Glas@hfm.tu-graz.ac.at> 1999-06-08. */
- || !strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".rodata")
-#endif
- || !strcmp (old_section_names + NEW_SECTION_H (nn).sh_name, ".got"))
- src = (caddr_t) OLD_SECTION_H (n).sh_addr;
- else
- src = old_base + OLD_SECTION_H (n).sh_offset;
-
- memcpy (NEW_SECTION_H (nn).sh_offset + new_base, src,
- NEW_SECTION_H (nn).sh_size);
-
- /* Adjust the HDRR offsets in .mdebug and copy the
- line data if it's in its usual 'hole' in the object.
- Makes the new file debuggable with dbx.
- patches up two problems: the absolute file offsets
- in the HDRR record of .mdebug (see /usr/include/syms.h), and
- the ld bug that gets the line table in a hole in the
- elf file rather than in the .mdebug section proper.
- David Anderson. davea@sgi.com Jan 16,1994. */
- if (n == old_mdebug_index)
- {
-#define MDEBUGADJUST(__ct,__fileaddr) \
- if (n_phdrr->__ct > 0) \
- { \
- n_phdrr->__fileaddr += movement; \
- }
-
- HDRR * o_phdrr = (HDRR *)((byte *)old_base + OLD_SECTION_H (n).sh_offset);
- HDRR * n_phdrr = (HDRR *)((byte *)new_base + NEW_SECTION_H (nn).sh_offset);
- unsigned movement = new_offsets_shift;
-
- MDEBUGADJUST (idnMax, cbDnOffset);
- MDEBUGADJUST (ipdMax, cbPdOffset);
- MDEBUGADJUST (isymMax, cbSymOffset);
- MDEBUGADJUST (ioptMax, cbOptOffset);
- MDEBUGADJUST (iauxMax, cbAuxOffset);
- MDEBUGADJUST (issMax, cbSsOffset);
- MDEBUGADJUST (issExtMax, cbSsExtOffset);
- MDEBUGADJUST (ifdMax, cbFdOffset);
- MDEBUGADJUST (crfd, cbRfdOffset);
- MDEBUGADJUST (iextMax, cbExtOffset);
- /* The Line Section, being possible off in a hole of the object,
- requires special handling. */
- if (n_phdrr->cbLine > 0)
- {
- if (o_phdrr->cbLineOffset > (OLD_SECTION_H (n).sh_offset
- + OLD_SECTION_H (n).sh_size))
- {
- /* line data is in a hole in elf. do special copy and adjust
- for this ld mistake.
- */
- n_phdrr->cbLineOffset += movement;
-
- memcpy (n_phdrr->cbLineOffset + new_base,
- o_phdrr->cbLineOffset + old_base, n_phdrr->cbLine);
- }
- else
- {
- /* somehow line data is in .mdebug as it is supposed to be. */
- MDEBUGADJUST (cbLine, cbLineOffset);
- }
- }
- }
-
- /* If it is the symbol table, its st_shndx field needs to be patched. */
- if (NEW_SECTION_H (nn).sh_type == SHT_SYMTAB
- || NEW_SECTION_H (nn).sh_type == SHT_DYNSYM)
- {
- Elf32_Shdr *spt = &NEW_SECTION_H (nn);
- unsigned int num = spt->sh_size / spt->sh_entsize;
- Elf32_Sym * sym = (Elf32_Sym *) (NEW_SECTION_H (nn).sh_offset
- + new_base);
- for (; num--; sym++)
- {
- /* don't patch special section indices. */
- if (sym->st_shndx == SHN_UNDEF
- || sym->st_shndx >= SHN_LORESERVE)
- continue;
-
- PATCH_INDEX (sym->st_shndx);
- }
- }
- }
-
- /* Close the files and make the new file executable. */
-
- if (close (old_file))
- fatal ("Can't close (%s): errno %d\n", old_name, errno);
-
- if (close (new_file))
- fatal ("Can't close (%s): errno %d\n", new_name, errno);
-
- if (stat (new_name, &stat_buf) == -1)
- fatal ("Can't stat (%s): errno %d\n", new_name, errno);
-
- n = umask (777);
- umask (n);
- stat_buf.st_mode |= 0111 & ~n;
- if (chmod (new_name, stat_buf.st_mode) == -1)
- fatal ("Can't chmod (%s): errno %d\n", new_name, errno);
-}
diff --git a/src/x11term.h b/src/x11term.h
deleted file mode 100644
index 367eeaacc95..00000000000
--- a/src/x11term.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#include <X11/Xlib.h>
-#include <X11/Xatom.h>
-#include <X11/keysym.h>
-#include <X11/cursorfont.h>
-#include <X11/Xutil.h>
-#include <X11/X10.h>
-
-#define XMOUSEBUFSIZE 64
-
-#ifndef sigmask
-#define sigmask(no) (1L << ((no) - 1))
-#endif
-
-#define BLOCK_INPUT_DECLARE() int BLOCK_INPUT_mask
-#ifdef SIGIO
-#define BLOCK_INPUT() EMACS_SIGBLOCKX (SIGIO, BLOCK_INPUT_mask)
-#define UNBLOCK_INPUT() \
- do { int _dummy; EMACS_SIGSETMASK (BLOCK_INPUT_mask, _dummy); } while (0)
-#else /* not SIGIO */
-#define BLOCK_INPUT()
-#define UNBLOCK_INPUT()
-#endif /* SIGIO */
-
-#define CLASS "Emacs" /* class id for GNU Emacs, used in .Xdefaults, etc. */
diff --git a/src/xscrollbar.h b/src/xscrollbar.h
deleted file mode 100644
index e1a3f45d247..00000000000
--- a/src/xscrollbar.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Bitmaps and things for scrollbars.
- Copyright (C) 1989 Free Software Foundation.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 1, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-
-static void install_vertical_scrollbar ();
-static void install_horizontal_scrollbar ();
-static void x_set_horizontal_scrollbar ();
-static void x_set_vertical_scrollbar ();
-
-/* Prefix-characters for scroll bar commands in Vglobal_mouse_map.
- Choice of prefix depends on which region of the scroll bar. */
-
-enum scroll_bar_prefix
- { VSCROLL_BAR_PREFIX = 050, VSCROLL_SLIDER_PREFIX /* unused */,
- VSCROLL_THUMBUP_PREFIX, VSCROLL_THUMBDOWN_PREFIX,
- HSCROLL_BAR_PREFIX, HSCROLL_SLIDER_PREFIX /* unused */,
- HSCROLL_THUMBLEFT_PREFIX, HSCROLL_THUMBRIGHT_PREFIX };
-
-#define CROSS_WIDTH 16
-#define CROSS_HEIGHT 16
-
-#define CROSS_MASK_WIDTH 16
-#define CROSS_MASK_HEIGHT 16
-
-/* Vertical and Horizontal scroll bar widths. */
-#define VSCROLL_WIDTH 18
-#define HSCROLL_HEIGHT 18
-
-#ifdef HAVE_X11
-
-/* Arrow cursors for scroll bars. */
-
-Cursor up_arrow_cursor, down_arrow_cursor, v_double_arrow_cursor;
-Cursor left_arrow_cursor, right_arrow_cursor, h_double_arrow_cursor;
-
-static char cross_bits[] =
- {
- 0x00, 0x00, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
- 0x80, 0x01, 0xfe, 0x7f, 0xfe, 0x7f, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
- 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x00, 0x00
- };
-
-static char gray_bits[] =
- {
- 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
- 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
- 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
- 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa
- };
-
-static char up_arrow_bits[] =
- {
- 0x00, 0x00, 0x80, 0x01, 0xc0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xf8, 0x1f,
- 0xfc, 0x3f, 0xfe, 0x7f, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
- 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0xff, 0xff
- };
-
-static char down_arrow_bits[] =
- {
- 0xff, 0xff, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01, 0x80, 0x01,
- 0x80, 0x01, 0x80, 0x01, 0xfe, 0x7f, 0xfc, 0x3f, 0xf8, 0x1f, 0xf0, 0x0f,
- 0xe0, 0x07, 0xc0, 0x03, 0x80, 0x01, 0x00, 0x00
- };
-
-static char left_arrow_bits[] =
- {
- 0x00, 0x80, 0x80, 0x80, 0xc0, 0x80, 0xe0, 0x80, 0xf0, 0x80, 0xf8, 0x80,
- 0xfc, 0x80, 0xfe, 0xff, 0xfe, 0xff, 0xfc, 0x80, 0xf8, 0x80, 0xf0, 0x80,
- 0xe0, 0x80, 0xc0, 0x80, 0x80, 0x80, 0x00, 0x80
- };
-
-static char right_arrow_bits[] =
- {
- 0x01, 0x00, 0x01, 0x01, 0x01, 0x03, 0x01, 0x07, 0x01, 0x0f, 0x01, 0x1f,
- 0x01, 0x3f, 0xff, 0x7f, 0xff, 0x7f, 0x01, 0x3f, 0x01, 0x1f, 0x01, 0x0f,
- 0x01, 0x07, 0x01, 0x03, 0x01, 0x01, 0x01, 0x00
- };
-
-static char cross_mask_bits[] =
- {
- 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc0, 0x03, 0xc0, 0x03,
- 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x03
- };
-#else /* not HAVE_X11 */
-static short cross_bits[] =
- {
- 0x0000, 0x0180, 0x0180, 0x0180,
- 0x0180, 0x0180, 0x0180, 0x7ffe,
- 0x7ffe, 0x0180, 0x0180, 0x0180,
- 0x0180, 0x0180, 0x0180, 0x0000,
- };
-
-static short gray_bits[] = {
- 0xaaaa, 0x5555, 0xaaaa, 0x5555,
- 0xaaaa, 0x5555, 0xaaaa, 0x5555,
- 0xaaaa, 0x5555, 0xaaaa, 0x5555,
- 0xaaaa, 0x5555, 0xaaaa, 0x5555};
-
-static short cross_mask_bits[] =
- {
- 0x03c0, 0x03c0, 0x03c0, 0x03c0,
- 0x03c0, 0x03c0, 0xffff, 0xffff,
- 0xffff, 0xffff, 0x03c0, 0x03c0,
- 0x03c0, 0x03c0, 0x03c0, 0x03c0,
- };
-#endif /* X10 */
diff --git a/src/xselect.c.old b/src/xselect.c.old
deleted file mode 100644
index 8a3e0443270..00000000000
--- a/src/xselect.c.old
+++ /dev/null
@@ -1,950 +0,0 @@
-/* X Selection processing for emacs
- Copyright (C) 1990, 1992, 1993 Free Software Foundation.
-
-This file is part of GNU Emacs.
-
-GNU Emacs is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Emacs is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Emacs; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#include "config.h"
-#include "lisp.h"
-#include "xterm.h"
-#include "buffer.h"
-#include "frame.h"
-
-#ifdef HAVE_X11
-
-/* Macros for X Selections */
-#define MAX_SELECTION(dpy) (((dpy)->max_request_size << 2) - 100)
-#define SELECTION_LENGTH(len,format) ((len) * ((format) >> 2))
-
-/* The timestamp of the last input event we received from the X server. */
-unsigned long last_event_timestamp;
-
-/* t if a mouse button is depressed. */
-extern Lisp_Object Vmouse_grabbed;
-
-/* When emacs became the PRIMARY selection owner. */
-Time x_begin_selection_own;
-
-/* When emacs became the SECONDARY selection owner. */
-Time x_begin_secondary_selection_own;
-
-/* When emacs became the CLIPBOARD selection owner. */
-Time x_begin_clipboard_own;
-
-/* The value of the current CLIPBOARD selection. */
-Lisp_Object Vx_clipboard_value;
-
-/* The value of the current PRIMARY selection. */
-Lisp_Object Vx_selection_value;
-
-/* The value of the current SECONDARY selection. */
-Lisp_Object Vx_secondary_selection_value;
-
-/* Types of selections we may make. */
-Lisp_Object Qprimary, Qsecondary, Qclipboard;
-
-/* Emacs' selection property identifiers. */
-Atom Xatom_emacs_selection;
-Atom Xatom_emacs_secondary_selection;
-
-/* Clipboard selection atom. */
-Atom Xatom_clipboard_selection;
-
-/* Clipboard atom. */
-Atom Xatom_clipboard;
-
-/* Atom for indicating incremental selection transfer. */
-Atom Xatom_incremental;
-
-/* Atom for indicating multiple selection request list */
-Atom Xatom_multiple;
-
-/* Atom for what targets emacs handles. */
-Atom Xatom_targets;
-
-/* Atom for indicating timstamp selection request */
-Atom Xatom_timestamp;
-
-/* Atom requesting we delete our selection. */
-Atom Xatom_delete;
-
-/* Selection magic. */
-Atom Xatom_insert_selection;
-
-/* Type of property for INSERT_SELECTION. */
-Atom Xatom_pair;
-
-/* More selection magic. */
-Atom Xatom_insert_property;
-
-/* Atom for indicating property type TEXT */
-Atom Xatom_text;
-
-/* Kinds of protocol things we may receive. */
-Atom Xatom_wm_take_focus;
-Atom Xatom_wm_save_yourself;
-Atom Xatom_wm_delete_window;
-
-/* Communication with window managers. */
-Atom Xatom_wm_protocols;
-
-/* These are to handle incremental selection transfer. */
-Window incr_requestor;
-Atom incr_property;
-int incr_nbytes;
-unsigned char *incr_value;
-unsigned char *incr_ptr;
-
-/* Declarations for handling cut buffers.
-
- Whenever we set a cut buffer or read a cut buffer's value, we cache
- it in cut_buffer_value. We look for PropertyNotify events about
- the CUT_BUFFER properties, and invalidate our cache accordingly.
- We ignore PropertyNotify events that we suspect were caused by our
- own changes to the cut buffers, so we can keep the cache valid
- longer.
-
- IS ALL THIS HAIR WORTH IT? Well, these functions get called every
- time an element goes into or is retrieved from the kill ring, and
- those ought to be quick. It's not fun in time or space to wait for
- 50k cut buffers to fly back and forth across the net. */
-
-/* The number of CUT_BUFFER properties defined under X. */
-#define NUM_CUT_BUFFERS (8)
-
-/* cut_buffer_atom[n] is the atom naming the nth cut buffer. */
-static Atom cut_buffer_atom[NUM_CUT_BUFFERS] = {
- XA_CUT_BUFFER0, XA_CUT_BUFFER1, XA_CUT_BUFFER2, XA_CUT_BUFFER3,
- XA_CUT_BUFFER4, XA_CUT_BUFFER5, XA_CUT_BUFFER6, XA_CUT_BUFFER7
-};
-
-/* cut_buffer_value is an eight-element vector;
- (aref cut_buffer_value n) is the cached value of cut buffer n, or
- Qnil if cut buffer n is unset. */
-static Lisp_Object cut_buffer_value;
-
-/* Bit N of cut_buffer_cached is true if (aref cut_buffer_value n) is
- known to be valid. This is cleared by PropertyNotify events
- handled by x_invalidate_cut_buffer_cache. It would be wonderful if
- that routine could just set the appropriate element of
- cut_buffer_value to some special value meaning "uncached", but that
- would lose if a GC happened to be in progress.
-
- Bit N of cut_buffer_just_set is true if cut buffer N has been set since
- the last PropertyNotify event; since we get an event even when we set
- the property ourselves, we should ignore one event after setting
- a cut buffer, so we don't have to throw away our cache. */
-#ifdef __STDC__
-volatile
-#endif
-static cut_buffer_cached, cut_buffer_just_set;
-
-
-/* Acquiring ownership of a selection. */
-
-
-/* Request selection ownership if we do not already have it. */
-
-static int
-own_selection (selection_type, time)
- Atom selection_type;
- Time time;
-{
- Window owner_window, selecting_window;
-
- if ((selection_type == XA_PRIMARY
- && !NILP (Vx_selection_value))
- || (selection_type == XA_SECONDARY
- && !NILP (Vx_secondary_selection_value))
- || (selection_type == Xatom_clipboard
- && !NILP (Vx_clipboard_value)))
- return 1;
-
- selecting_window = FRAME_X_WINDOW (selected_frame);
- XSetSelectionOwner (x_current_display, selection_type,
- selecting_window, time);
- owner_window = XGetSelectionOwner (x_current_display, selection_type);
-
- if (owner_window != selecting_window)
- return 0;
-
- return 1;
-}
-
-/* Become the selection owner and make our data the selection value.
- If we are already the owner, merely change data and timestamp values.
- This avoids generating SelectionClear events for ourselves. */
-
-DEFUN ("x-set-selection", Fx_set_selection, Sx_set_selection,
- 2, 2, "",
- "Set the value of SELECTION to STRING.\n\
-SELECTION may be `primary', `secondary', or `clipboard'.\n\
-\n\
-Selections are a mechanism for cutting and pasting information between\n\
-X Windows clients. Emacs's kill ring commands set the `primary'\n\
-selection to the top string of the kill ring, making it available to\n\
-other clients, like xterm. Those commands also use the `primary'\n\
-selection to retrieve information from other clients.\n\
-\n\
-According to the Inter-Client Communications Conventions Manual:\n\
-\n\
-The `primary' selection \"... is used for all commands that take only a\n\
- single argument and is the principal means of communication between\n\
- clients that use the selection mechanism.\" In Emacs, this means\n\
- that the kill ring commands set the primary selection to the text\n\
- put in the kill ring.\n\
-\n\
-The `secondary' selection \"... is used as the second argument to\n\
- commands taking two arguments (for example, `exchange primary and\n\
- secondary selections'), and as a means of obtaining data when there\n\
- is a primary selection and the user does not want to disturb it.\"\n\
- I am not sure how Emacs should use the secondary selection; if you\n\
- come up with ideas, this function will at least let you get at it.\n\
-\n\
-The `clipboard' selection \"... is used to hold data that is being\n\
- transferred between clients, that is, data that usually is being\n\
- cut or copied, and then pasted.\" It seems that the `clipboard'\n\
- selection is for the most part equivalent to the `primary'\n\
- selection, so Emacs sets them both.\n\
-\n\
-Also see `x-selection', and the `interprogram-cut-function' variable.")
- (selection, string)
- register Lisp_Object selection, string;
-{
- Atom selection_type;
- Lisp_Object val;
- Time event_time = last_event_timestamp;
- CHECK_STRING (string, 0);
-
- val = Qnil;
-
- if (NILP (selection) || EQ (selection, Qprimary))
- {
- BLOCK_INPUT;
- if (own_selection (XA_PRIMARY, event_time))
- {
- x_begin_selection_own = event_time;
- val = Vx_selection_value = string;
- }
- UNBLOCK_INPUT;
- }
- else if (EQ (selection, Qsecondary))
- {
- BLOCK_INPUT;
- if (own_selection (XA_SECONDARY, event_time))
- {
- x_begin_secondary_selection_own = event_time;
- val = Vx_secondary_selection_value = string;
- }
- UNBLOCK_INPUT;
- }
- else if (EQ (selection, Qclipboard))
- {
- BLOCK_INPUT;
- if (own_selection (Xatom_clipboard, event_time))
- {
- x_begin_clipboard_own = event_time;
- val = Vx_clipboard_value = string;
- }
- UNBLOCK_INPUT;
- }
- else
- error ("Invalid X selection type");
-
- return val;
-}
-
-/* Clear our selection ownership data, as some other client has
- become the owner. */
-
-void
-x_disown_selection (old_owner, selection, changed_owner_time)
- Window *old_owner;
- Atom selection;
- Time changed_owner_time;
-{
- struct frame *s = x_window_to_frame (old_owner);
-
- if (s) /* We are the owner */
- {
- if (selection == XA_PRIMARY)
- {
- x_begin_selection_own = 0;
- Vx_selection_value = Qnil;
- }
- else if (selection == XA_SECONDARY)
- {
- x_begin_secondary_selection_own = 0;
- Vx_secondary_selection_value = Qnil;
- }
- else if (selection == Xatom_clipboard)
- {
- x_begin_clipboard_own = 0;
- Vx_clipboard_value = Qnil;
- }
- else
- abort ();
- }
- else
- abort (); /* Inconsistent state. */
-}
-
-
-/* Answering selection requests. */
-
-int x_selection_alloc_error;
-int x_converting_selection;
-
-/* Reply to some client's request for our selection data.
- Data is placed in a property supplied by the requesting window.
-
- If the data exceeds the maximum amount the server can send,
- then prepare to send it incrementally, and reply to the client with
- the total size of the data.
-
- But first, check for all the other crufty stuff we could get. */
-
-void
-x_answer_selection_request (event)
- XSelectionRequestEvent event;
-{
- Time emacs_own_time;
- Lisp_Object selection_value;
- XSelectionEvent evt;
- int format = 8; /* We have only byte sized (text) data. */
-
- evt.type = SelectionNotify; /* Construct reply event */
- evt.display = event.display;
- evt.requestor = event.requestor;
- evt.selection = event.selection;
- evt.time = event.time;
- evt.target = event.target;
-
- if (event.selection == XA_PRIMARY)
- {
- emacs_own_time = x_begin_selection_own;
- selection_value = Vx_selection_value;
- }
- else if (event.selection == XA_SECONDARY)
- {
- emacs_own_time = x_begin_secondary_selection_own;
- selection_value = Vx_secondary_selection_value;
- }
- else if (event.selection == Xatom_clipboard)
- {
- emacs_own_time = x_begin_clipboard_own;
- selection_value = Vx_clipboard_value;
- }
- else
- abort ();
-
- if (event.time != CurrentTime
- && event.time < emacs_own_time)
- evt.property = None;
- else
- {
- if (event.property == None) /* obsolete client */
- evt.property = event.target;
- else
- evt.property = event.property;
- }
-
- if (event.target == Xatom_targets) /* Send List of target atoms */
- {
- }
- else if (event.target == Xatom_multiple) /* Recvd list: <target, prop> */
- {
- Atom type;
- int return_format;
- unsigned long items, bytes_left;
- unsigned char *data;
- int result, i;
-
- if (event.property == 0 /* 0 == NILP */
- || event.property == None)
- return;
-
- result = XGetWindowProperty (event.display, event.requestor,
- event.property, 0L, 10000000L,
- True, Xatom_pair, &type, &return_format,
- &items, &bytes_left, &data);
-
- if (result == Success && type == Xatom_pair)
- for (i = items; i > 0; i--)
- {
- /* Convert each element of the list. */
- }
-
- (void) XSendEvent (x_current_display, evt.requestor, False,
- 0L, (XEvent *) &evt);
- return;
- }
- else if (event.target == Xatom_timestamp) /* Send ownership timestamp */
- {
- if (! emacs_own_time)
- abort ();
-
- format = 32;
- XChangeProperty (evt.display, evt.requestor, evt.property,
- evt.target, format, PropModeReplace,
- (unsigned char *) &emacs_own_time, 1);
- return;
- }
- else if (event.target == Xatom_delete) /* Delete our selection. */
- {
- if (EQ (Qnil, selection_value))
- abort ();
-
- x_disown_selection (event.owner, event.selection, event.time);
-
- /* Now return property of type NILP, length 0. */
- XChangeProperty (event.display, event.requestor, event.property,
- 0, format, PropModeReplace, (unsigned char *) 0, 0);
- return;
- }
- else if (event.target == Xatom_insert_selection)
- {
- Atom type;
- int return_format;
- unsigned long items, bytes_left;
- unsigned char *data;
- int result = XGetWindowProperty (event.display, event.requestor,
- event.property, 0L, 10000000L,
- True, Xatom_pair, &type, &return_format,
- &items, &bytes_left, &data);
- if (result == Success && type == Xatom_pair)
- {
- /* Convert the first atom to (a selection) to the target
- indicated by the second atom. */
- }
- }
- else if (event.target == Xatom_insert_property)
- {
- Atom type;
- int return_format;
- unsigned long items, bytes_left;
- unsigned char *data;
- int result = XGetWindowProperty (event.display, event.requestor,
- event.property, 0L, 10000000L,
- True, XA_STRING, &type, &return_format,
- &items, &bytes_left, &data);
-
- if (result == Success && type == XA_STRING && return_format == 8)
- {
- if (event.selection == Xatom_emacs_selection)
- Vx_selection_value = make_string (data);
- else if (event.selection == Xatom_emacs_secondary_selection)
- Vx_secondary_selection_value = make_string (data);
- else if (event.selection == Xatom_clipboard_selection)
- Vx_clipboard_value = make_string (data);
- else
- abort ();
- }
-
- return;
- }
- else if ((event.target == Xatom_text
- || event.target == XA_STRING))
- {
- int size = XSTRING (selection_value)->size;
- unsigned char *data = XSTRING (selection_value)->data;
-
- if (EQ (Qnil, selection_value))
- abort ();
-
- /* Place data on requestor window's property. */
- if (SELECTION_LENGTH (size, format)
- <= MAX_SELECTION (x_current_display))
- {
- x_converting_selection = 1;
- XChangeProperty (evt.display, evt.requestor, evt.property,
- evt.target, format, PropModeReplace,
- data, size);
- if (x_selection_alloc_error)
- {
- x_selection_alloc_error = 0;
- abort ();
- }
- x_converting_selection = 0;
- }
- else /* Send incrementally */
- {
- evt.target = Xatom_incremental;
- incr_requestor = evt.requestor;
- incr_property = evt.property;
- x_converting_selection = 1;
-
- /* Need to handle Alloc errors on these requests. */
- XChangeProperty (evt.display, incr_requestor, incr_property,
- Xatom_incremental, 32,
- PropModeReplace,
- (unsigned char *) &size, 1);
- if (x_selection_alloc_error)
- {
- x_selection_alloc_error = 0;
- x_converting_selection = 0;
- abort ();
- /* Now abort the send. */
- }
-
- incr_nbytes = size;
- incr_value = data;
- incr_ptr = data;
-
- /* Ask for notification when requestor deletes property. */
- XSelectInput (x_current_display, incr_requestor, PropertyChangeMask);
-
- /* If we're sending incrementally, perhaps block here
- until all sent? */
- }
- }
- else
- evt.property = None;
-
- /* Don't do this if there was an Alloc error: abort the transfer
- by sending None. */
- (void) XSendEvent (x_current_display, evt.requestor, False,
- 0L, (XEvent *) &evt);
-}
-
-/* Send an increment of selection data in response to a PropertyNotify event.
- The increment is placed in a property on the requestor's window.
- When the requestor has processed the increment, it deletes the property,
- which sends us another PropertyNotify event.
-
- When there is no more data to send, we send a zero-length increment. */
-
-void
-x_send_incremental (event)
- XPropertyEvent event;
-{
- if (incr_requestor
- && incr_requestor == event.window
- && incr_property == event.atom
- && event.state == PropertyDelete)
- {
- int format = 8;
- int length = MAX_SELECTION (x_current_display);
- int bytes_left = (incr_nbytes - (incr_ptr - incr_value));
-
- if (length > bytes_left) /* Also sends 0 len when finished. */
- length = bytes_left;
- XChangeProperty (x_current_display, incr_requestor,
- incr_property, XA_STRING, format,
- PropModeAppend, incr_ptr, length);
- if (x_selection_alloc_error)
- {
- x_selection_alloc_error = 0;
- x_converting_selection = 0;
- /* Abandon the transmission. */
- abort ();
- }
- if (length > 0)
- incr_ptr += length;
- else
- { /* Everything's sent */
- XSelectInput (x_current_display, incr_requestor, 0L);
- incr_requestor = (Window) 0;
- incr_property = (Atom) 0;
- incr_nbytes = 0;
- incr_value = (unsigned char *) 0;
- incr_ptr = (unsigned char *) 0;
- x_converting_selection = 0;
- }
- }
-}
-
-
-/* Requesting the value of a selection. */
-
-static Lisp_Object x_selection_arrival ();
-
-/* Predicate function used to match a requested event. */
-
-Bool
-XCheckSelectionEvent (dpy, event, window)
- Display *dpy;
- XEvent *event;
- char *window;
-{
- if (event->type == SelectionNotify)
- if (event->xselection.requestor == (Window) window)
- return True;
-
- return False;
-}
-
-/* Request a selection value from its owner. This will block until
- all the data is arrived. */
-
-static Lisp_Object
-get_selection_value (type)
- Atom type;
-{
- XEvent event;
- Lisp_Object val;
- Time requestor_time; /* Timestamp of selection request. */
- Window requestor_window;
-
- BLOCK_INPUT;
- requestor_time = last_event_timestamp;
- requestor_window = FRAME_X_WINDOW (selected_frame);
- XConvertSelection (x_current_display, type, XA_STRING,
- Xatom_emacs_selection, requestor_window, requestor_time);
- XIfEvent (x_current_display,
- &event,
- XCheckSelectionEvent,
- (char *) requestor_window);
- val = x_selection_arrival (&event, requestor_window, requestor_time);
- UNBLOCK_INPUT;
-
- return val;
-}
-
-/* Request a selection value from the owner. If we are the owner,
- simply return our selection value. If we are not the owner, this
- will block until all of the data has arrived. */
-
-DEFUN ("x-selection", Fx_selection, Sx_selection,
- 1, 1, "",
- "Return the value of SELECTION.\n\
-SELECTION is one of `primary', `secondary', or `clipboard'.\n\
-\n\
-Selections are a mechanism for cutting and pasting information between\n\
-X Windows clients. When the user selects text in an X application,\n\
-the application should set the primary selection to that text; Emacs's\n\
-kill ring commands will then check the value of the `primary'\n\
-selection, and return it as the most recent kill.\n\
-The documentation for `x-set-selection' gives more information on how\n\
-the different selection types are intended to be used.\n\
-Also see the `interprogram-paste-function' variable.")
- (selection)
- register Lisp_Object selection;
-{
- Atom selection_type;
-
- if (NILP (selection) || EQ (selection, Qprimary))
- {
- if (!NILP (Vx_selection_value))
- return Vx_selection_value;
-
- return get_selection_value (XA_PRIMARY);
- }
- else if (EQ (selection, Qsecondary))
- {
- if (!NILP (Vx_secondary_selection_value))
- return Vx_secondary_selection_value;
-
- return get_selection_value (XA_SECONDARY);
- }
- else if (EQ (selection, Qclipboard))
- {
- if (!NILP (Vx_clipboard_value))
- return Vx_clipboard_value;
-
- return get_selection_value (Xatom_clipboard);
- }
- else
- error ("Invalid X selection type");
-}
-
-static Lisp_Object
-x_selection_arrival (event, requestor_window, requestor_time)
- register XSelectionEvent *event;
- Window requestor_window;
- Time requestor_time;
-{
- int result;
- Atom type, selection;
- int format;
- unsigned long items;
- unsigned long bytes_left;
- unsigned char *data = 0;
- int offset = 0;
-
- if (event->selection == XA_PRIMARY)
- selection = Xatom_emacs_selection;
- else if (event->selection == XA_SECONDARY)
- selection = Xatom_emacs_secondary_selection;
- else if (event->selection == Xatom_clipboard)
- selection = Xatom_clipboard_selection;
- else
- abort ();
-
- if (event->requestor == requestor_window
- && event->time == requestor_time
- && event->property != None)
- if (event->target != Xatom_incremental)
- {
- unsigned char *return_string =
- (unsigned char *) alloca (MAX_SELECTION (x_current_display));
-
- do
- {
- result = XGetWindowProperty (x_current_display, requestor_window,
- event->property, 0L,
- 10000000L, True, XA_STRING,
- &type, &format, &items,
- &bytes_left, &data);
- if (result == Success && type == XA_STRING && format == 8
- && offset < MAX_SELECTION (x_current_display))
- {
- bcopy (data, return_string + offset, items);
- offset += items;
- }
- XFree ((char *) data);
- }
- while (bytes_left);
-
- return make_string (return_string, offset);
- }
- else /* Prepare incremental transfer. */
- {
- unsigned char *increment_value;
- unsigned char *increment_ptr;
- int total_size;
- int *increment_nbytes = 0;
-
- result = XGetWindowProperty (x_current_display, requestor_window,
- selection, 0L, 10000000L, False,
- event->property, &type, &format,
- &items, &bytes_left,
- (unsigned char **) &increment_nbytes);
- if (result == Success)
- {
- XPropertyEvent property_event;
-
- total_size = *increment_nbytes;
- increment_value = (unsigned char *) alloca (total_size);
- increment_ptr = increment_value;
-
- XDeleteProperty (x_current_display, event->requestor,
- event->property);
- XFlush (x_current_display);
- XFree ((char *) increment_nbytes);
-
- do
- { /* NOTE: this blocks. */
- XWindowEvent (x_current_display, requestor_window,
- PropertyChangeMask,
- (XEvent *) &property_event);
-
- if (property_event.atom == selection
- && property_event.state == PropertyNewValue)
- do
- {
- result = XGetWindowProperty (x_current_display,
- requestor_window,
- selection, 0L,
- 10000000L, True,
- AnyPropertyType,
- &type, &format,
- &items, &bytes_left,
- &data);
- if (result == Success && type == XA_STRING
- && format == 8)
- {
- bcopy (data, increment_ptr, items);
- increment_ptr += items;
- }
- }
- while (bytes_left);
-
- }
- while (increment_ptr < (increment_value + total_size));
-
- return make_string (increment_value,
- (increment_ptr - increment_value));
- }
- }
-
- return Qnil;
-}
-
-
-/* Cut buffer management. */
-
-DEFUN ("x-get-cut-buffer", Fx_get_cut_buffer, Sx_get_cut_buffer, 0, 1, "",
- "Return the value of cut buffer N, or nil if it is unset.\n\
-If N is omitted, it defaults to zero.\n\
-Note that cut buffers have some problems that selections don't; try to\n\
-write your code to use cut buffers only for backward compatibility,\n\
-and use selections for the serious work.")
- (n)
- Lisp_Object n;
-{
- int buf_num;
-
- if (NILP (n))
- buf_num = 0;
- else
- {
- CHECK_NUMBER (n, 0);
- buf_num = XINT (n);
- }
-
- if (buf_num < 0 || buf_num >= NUM_CUT_BUFFERS)
- error ("cut buffer numbers must be from zero to seven");
-
- {
- Lisp_Object value;
-
- /* Note that no PropertyNotify events will be processed while
- input is blocked. */
- BLOCK_INPUT;
-
- if (cut_buffer_cached & (1 << buf_num))
- value = XVECTOR (cut_buffer_value)->contents[buf_num];
- else
- {
- /* Our cache is invalid; retrieve the property's value from
- the server. */
- int buf_len;
- char *buf = XFetchBuffer (x_current_display, &buf_len, buf_num);
-
- if (buf_len == 0)
- value = Qnil;
- else
- value = make_string (buf, buf_len);
-
- XVECTOR (cut_buffer_value)->contents[buf_num] = value;
- cut_buffer_cached |= (1 << buf_num);
-
- XFree (buf);
- }
-
- UNBLOCK_INPUT;
-
- return value;
- }
-}
-
-DEFUN ("x-set-cut-buffer", Fx_set_cut_buffer, Sx_set_cut_buffer, 2, 2, "",
- "Set the value of cut buffer N to STRING.\n\
-Note that cut buffers have some problems that selections don't; try to\n\
-write your code to use cut buffers only for backward compatibility,\n\
-and use selections for the serious work.")
- (n, string)
- Lisp_Object n, string;
-{
- int buf_num;
-
- CHECK_NUMBER (n, 0);
- CHECK_STRING (string, 1);
-
- buf_num = XINT (n);
-
- if (buf_num < 0 || buf_num >= NUM_CUT_BUFFERS)
- error ("cut buffer numbers must be from zero to seven");
-
- BLOCK_INPUT;
-
- /* DECwindows and some other servers don't seem to like setting
- properties to values larger than about 20k. For very large
- values, they signal an error, but for intermediate values they
- just seem to hang.
-
- We could just truncate the request, but it's better to let the
- user know that the strategy he/she's using isn't going to work
- than to have it work partially, but incorrectly. */
-
- if (XSTRING (string)->size == 0
- || XSTRING (string)->size > MAX_SELECTION (x_current_display))
- {
- XStoreBuffer (x_current_display, (char *) 0, 0, buf_num);
- string = Qnil;
- }
- else
- {
- XStoreBuffer (x_current_display,
- (char *) XSTRING (string)->data, XSTRING (string)->size,
- buf_num);
- }
-
- XVECTOR (cut_buffer_value)->contents[buf_num] = string;
- cut_buffer_cached |= (1 << buf_num);
- cut_buffer_just_set |= (1 << buf_num);
-
- UNBLOCK_INPUT;
-
- return string;
-}
-
-/* Ask the server to send us an event if any cut buffer is modified. */
-
-void
-x_watch_cut_buffer_cache ()
-{
- XSelectInput (x_current_display, ROOT_WINDOW, PropertyChangeMask);
-}
-
-/* The server has told us that a cut buffer has been modified; deal with that.
- Note that this function is called at interrupt level. */
-void
-x_invalidate_cut_buffer_cache (XPropertyEvent *event)
-{
- int i;
-
- /* See which cut buffer this is about, if any. */
- for (i = 0; i < NUM_CUT_BUFFERS; i++)
- if (event->atom == cut_buffer_atom[i])
- {
- int mask = (1 << i);
-
- if (cut_buffer_just_set & mask)
- cut_buffer_just_set &= ~mask;
- else
- cut_buffer_cached &= ~mask;
-
- break;
- }
-}
-
-
-/* Bureaucracy. */
-
-void
-syms_of_xselect ()
-{
- DEFVAR_LISP ("x-selection-value", &Vx_selection_value,
- "The value of emacs' last cut-string.");
- Vx_selection_value = Qnil;
-
- DEFVAR_LISP ("x-secondary-selection-value", &Vx_secondary_selection_value,
- "The value of emacs' last secondary cut-string.");
- Vx_secondary_selection_value = Qnil;
-
- DEFVAR_LISP ("x-clipboard-value", &Vx_clipboard_value,
- "The string emacs last sent to the clipboard.");
- Vx_clipboard_value = Qnil;
-
- Qprimary = intern ("primary");
- staticpro (&Qprimary);
- Qsecondary = intern ("secondary");
- staticpro (&Qsecondary);
- Qclipboard = intern ("clipboard");
- staticpro (&Qclipboard);
-
- defsubr (&Sx_set_selection);
- defsubr (&Sx_selection);
-
- cut_buffer_value = Fmake_vector (make_number (NUM_CUT_BUFFERS), Qnil);
- staticpro (&cut_buffer_value);
-
- defsubr (&Sx_get_cut_buffer);
- defsubr (&Sx_set_cut_buffer);
-}
-#endif /* X11 */