aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMiles Bader2007-01-30 22:22:43 +0000
committerMiles Bader2007-01-30 22:22:43 +0000
commitbb5b9e9dbe671b0525692acf1337efa271b33fb6 (patch)
tree810c31e2c5f1bc8e79df0cc4b121a25a9d4b8642 /src
parentf3df78db7218a084cbd58dc9a3cb5b9909b02d4d (diff)
parent41e49ce63ee2f9945ff99a19b00752ea887ef506 (diff)
downloademacs-bb5b9e9dbe671b0525692acf1337efa271b33fb6.tar.gz
emacs-bb5b9e9dbe671b0525692acf1337efa271b33fb6.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 615-621) - Update from CVS - Merge from gnus--rel--5.10 * gnus--rel--5.10 (patch 197-199) - Merge from emacs--devo--0 - Update from CVS Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-166
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog43
-rw-r--r--src/Makefile.in8
-rw-r--r--src/alloc.c4
-rw-r--r--src/blockinput.h2
-rw-r--r--src/config.in3
-rw-r--r--src/gtkutil.c5
-rw-r--r--src/keyboard.c10
-rw-r--r--src/m/hp800.h77
-rw-r--r--src/m/sr2k.h160
-rw-r--r--src/minibuf.c181
-rw-r--r--src/syssignal.h2
-rw-r--r--src/unexhp9k800.c322
12 files changed, 166 insertions, 651 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 208084ff12a..7b1ba672583 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,46 @@
12007-01-29 Chong Yidong <cyd@stupidchicken.com>
2
3 * m/hp800.h: Restore, removing HP-UX support.
4
52007-01-29 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
6
7 * Makefile.in: Use a variable, XFT_LIBS, instead #define LIB_X11_LIB.
8
92007-01-28 Richard Stallman <rms@gnu.org>
10
11 * minibuf.c (Ftry_completion, Fall_completions)
12 (Fcompleting_read, Ftest_completion):
13 Rename arg ALIST or TABLE to COLLECTION.
14
152007-01-27 Chong Yidong <cyd@stupidchicken.com>
16
17 * unexhp9k800.c: Remove due to lack of legal papers.
18
19 * m/sr2k.h, m/hp800.h: Remove due to dependence on above.
20
212007-01-27 Eli Zaretskii <eliz@gnu.org>
22
23 * keyboard.c (Fthis_command_keys, Fthis_command_keys_vector): Doc fix.
24
25 * minibuf.c (Fcompleting_read): Doc fix.
26
272007-01-26 Jan Dj,Ad(Brv <jan.h.d@swipnet.se>
28
29 * gtkutil.c (xg_initialize): Call XftInit if HAVE_XFT.
30
31 * Makefile.in: Use XFT_LIBS if defined.
32
332007-01-26 YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
34
35 * alloc.c (BLOCK_INPUT_ALLOC, UNBLOCK_INPUT_ALLOC): Use
36 BLOCK_INPUT/UNBLOCK_INPUT.
37
38 * blockinput.h (interrupt_input_blocked): Declare volatile.
39
40 * keyboard.c (interrupt_input_blocked): Declare volatile.
41
42 * syssignal.h (SIGNAL_THREAD_CHECK): Use pthread_equal.
43
12007-01-24 Kim F. Storm <storm@cua.dk> 442007-01-24 Kim F. Storm <storm@cua.dk>
2 45
3 * keymap.c (describe_map): Don't consider prefix keys to be shadowed. 46 * keymap.c (describe_map): Don't consider prefix keys to be shadowed.
diff --git a/src/Makefile.in b/src/Makefile.in
index 3e6d39246f6..95de3fbd61f 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -408,6 +408,12 @@ LIBXT=$(LIBW)
408#define LIB_X11_LIB @XFT_LIBS@ 408#define LIB_X11_LIB @XFT_LIBS@
409#endif /* HAVE_XFT */ 409#endif /* HAVE_XFT */
410 410
411#if HAVE_XFT
412#undef LIB_X11_LIB /* XFT_LIBS includes -lX11 */
413#define LIB_X11_LIB
414XFT_LIBS=@XFT_LIBS@
415#endif /* HAVE_XFT */
416
411#if HAVE_XPM 417#if HAVE_XPM
412#ifndef LIBXPM 418#ifndef LIBXPM
413#define LIBXPM -lXpm 419#define LIBXPM -lXpm
@@ -452,7 +458,7 @@ LIBXT=$(LIBW)
452/* LD_SWITCH_X_DEFAULT comes after everything else that specifies 458/* LD_SWITCH_X_DEFAULT comes after everything else that specifies
453 options for where to find X libraries, but before those libraries. */ 459 options for where to find X libraries, but before those libraries. */
454X11_LDFLAGS = LD_SWITCH_X_SITE LD_SWITCH_X_DEFAULT 460X11_LDFLAGS = LD_SWITCH_X_SITE LD_SWITCH_X_DEFAULT
455LIBX= $(LIBXMENU) $(X11_LDFLAGS) $(LIBXT) LIBTIFF LIBJPEG LIBPNG LIBGIF LIBXPM LIB_X11_LIB LIBX11_MACHINE LIBX11_SYSTEM 461LIBX= $(LIBXMENU) $(X11_LDFLAGS) $(LIBXT) LIBTIFF LIBJPEG LIBPNG LIBGIF LIBXPM LIB_X11_LIB LIBX11_MACHINE LIBX11_SYSTEM $(XFT_LIBS)
456#else /* not HAVE_X11 */ 462#else /* not HAVE_X11 */
457LIBX= $(LIBXMENU) LD_SWITCH_X_SITE -lX10 LIBX10_MACHINE LIBX10_SYSTEM 463LIBX= $(LIBXMENU) LD_SWITCH_X_SITE -lX10 LIBX10_MACHINE LIBX10_SYSTEM
458#endif /* not HAVE_X11 */ 464#endif /* not HAVE_X11 */
diff --git a/src/alloc.c b/src/alloc.c
index b6ad5545f34..c8a5a38e592 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -131,7 +131,7 @@ static pthread_mutex_t alloc_mutex;
131 do \ 131 do \
132 { \ 132 { \
133 if (pthread_equal (pthread_self (), main_thread)) \ 133 if (pthread_equal (pthread_self (), main_thread)) \
134 sigblock (sigmask (SIGIO)); \ 134 BLOCK_INPUT; \
135 pthread_mutex_lock (&alloc_mutex); \ 135 pthread_mutex_lock (&alloc_mutex); \
136 } \ 136 } \
137 while (0) 137 while (0)
@@ -140,7 +140,7 @@ static pthread_mutex_t alloc_mutex;
140 { \ 140 { \
141 pthread_mutex_unlock (&alloc_mutex); \ 141 pthread_mutex_unlock (&alloc_mutex); \
142 if (pthread_equal (pthread_self (), main_thread)) \ 142 if (pthread_equal (pthread_self (), main_thread)) \
143 sigunblock (sigmask (SIGIO)); \ 143 UNBLOCK_INPUT; \
144 } \ 144 } \
145 while (0) 145 while (0)
146 146
diff --git a/src/blockinput.h b/src/blockinput.h
index fcaa64723bc..468f0e0c762 100644
--- a/src/blockinput.h
+++ b/src/blockinput.h
@@ -49,7 +49,7 @@ Boston, MA 02110-1301, USA. */
49 interrupt_input_pending to a non-zero value. If that flag is set 49 interrupt_input_pending to a non-zero value. If that flag is set
50 when input becomes unblocked, UNBLOCK_INPUT will send a new SIGIO. */ 50 when input becomes unblocked, UNBLOCK_INPUT will send a new SIGIO. */
51 51
52extern int interrupt_input_blocked; 52extern volatile int interrupt_input_blocked;
53 53
54/* Nonzero means an input interrupt has arrived 54/* Nonzero means an input interrupt has arrived
55 during the current critical section. */ 55 during the current critical section. */
diff --git a/src/config.in b/src/config.in
index 7c94952463b..e4535b605cd 100644
--- a/src/config.in
+++ b/src/config.in
@@ -722,6 +722,9 @@ Boston, MA 02110-1301, USA. */
722/* Define to 1 if you have the Xft library. */ 722/* Define to 1 if you have the Xft library. */
723#undef HAVE_XFT 723#undef HAVE_XFT
724 724
725/* Define to 1 if you have the Xft library. */
726#undef HAVE_XFT
727
725/* Define to 1 if XIM is available */ 728/* Define to 1 if XIM is available */
726#undef HAVE_XIM 729#undef HAVE_XIM
727 730
diff --git a/src/gtkutil.c b/src/gtkutil.c
index dc81f016509..fe1eb6cdfdb 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -3937,6 +3937,11 @@ xg_initialize ()
3937{ 3937{
3938 GtkBindingSet *binding_set; 3938 GtkBindingSet *binding_set;
3939 3939
3940#if HAVE_XFT
3941 /* Work around a bug with corrupted data if libXft gets unloaded. This way
3942 we keep it permanently linked in. */
3943 XftInit (0);
3944#endif
3940 xg_ignore_gtk_scrollbar = 0; 3945 xg_ignore_gtk_scrollbar = 0;
3941 xg_detached_menus = 0; 3946 xg_detached_menus = 0;
3942 xg_menu_cb_list.prev = xg_menu_cb_list.next = 3947 xg_menu_cb_list.prev = xg_menu_cb_list.next =
diff --git a/src/keyboard.c b/src/keyboard.c
index 572b3096c06..c7d25088313 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -90,7 +90,7 @@ extern int errno;
90/* Variables for blockinput.h: */ 90/* Variables for blockinput.h: */
91 91
92/* Non-zero if interrupt input is blocked right now. */ 92/* Non-zero if interrupt input is blocked right now. */
93int interrupt_input_blocked; 93volatile int interrupt_input_blocked;
94 94
95/* Nonzero means an input interrupt has arrived 95/* Nonzero means an input interrupt has arrived
96 during the current critical section. */ 96 during the current critical section. */
@@ -10296,7 +10296,9 @@ DEFUN ("this-command-keys", Fthis_command_keys, Sthis_command_keys, 0, 0, 0,
10296 doc: /* Return the key sequence that invoked this command. 10296 doc: /* Return the key sequence that invoked this command.
10297However, if the command has called `read-key-sequence', it returns 10297However, if the command has called `read-key-sequence', it returns
10298the last key sequence that has been read. 10298the last key sequence that has been read.
10299The value is a string or a vector. */) 10299The value is a string or a vector.
10300
10301See also `this-command-keys-vector'. */)
10300 () 10302 ()
10301{ 10303{
10302 return make_event_array (this_command_key_count, 10304 return make_event_array (this_command_key_count,
@@ -10306,7 +10308,9 @@ The value is a string or a vector. */)
10306DEFUN ("this-command-keys-vector", Fthis_command_keys_vector, Sthis_command_keys_vector, 0, 0, 0, 10308DEFUN ("this-command-keys-vector", Fthis_command_keys_vector, Sthis_command_keys_vector, 0, 0, 0,
10307 doc: /* Return the key sequence that invoked this command, as a vector. 10309 doc: /* Return the key sequence that invoked this command, as a vector.
10308However, if the command has called `read-key-sequence', it returns 10310However, if the command has called `read-key-sequence', it returns
10309the last key sequence that has been read. */) 10311the last key sequence that has been read.
10312
10313See also `this-command-keys'. */)
10310 () 10314 ()
10311{ 10315{
10312 return Fvector (this_command_key_count, 10316 return Fvector (this_command_key_count,
diff --git a/src/m/hp800.h b/src/m/hp800.h
index f48f4c8152e..eed53183569 100644
--- a/src/m/hp800.h
+++ b/src/m/hp800.h
@@ -69,9 +69,10 @@ Boston, MA 02110-1301, USA. */
69#define XSET(var, type, ptr) \ 69#define XSET(var, type, ptr) \
70 ((var) = ((int)(type) << VALBITS) + (((unsigned) (ptr) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS)) 70 ((var) = ((int)(type) << VALBITS) + (((unsigned) (ptr) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS))
71 71
72/* Common definitions for HPUX and GNU/Linux. */ 72/* Definitions for GNU/Linux. (HP/UX is unsupported because of the
73 removal of unexhp9k800.c due to lack of legal papers.) */
73 74
74#if defined (__hpux) || defined (GNU_LINUX) 75#ifdef GNU_LINUX
75/* Now define a symbol for the cpu type, if your compiler 76/* Now define a symbol for the cpu type, if your compiler
76 does not define it automatically: 77 does not define it automatically:
77 Ones defined so far include vax, m68000, ns16000, pyramid, 78 Ones defined so far include vax, m68000, ns16000, pyramid,
@@ -93,12 +94,6 @@ Boston, MA 02110-1301, USA. */
93 94
94#define NO_REMAP 95#define NO_REMAP
95 96
96#endif /* __hpux or GNU_LINUX */
97
98/* Stuff for just GNU/Linux. */
99
100#ifdef GNU_LINUX
101
102/* Data type of load average, as read out of kmem. */ 97/* Data type of load average, as read out of kmem. */
103 98
104#define LOAD_AVE_TYPE long 99#define LOAD_AVE_TYPE long
@@ -109,72 +104,6 @@ Boston, MA 02110-1301, USA. */
109 104
110#endif /* GNU_LINUX */ 105#endif /* GNU_LINUX */
111 106
112/* Stuff for just HPUX. */
113
114#ifdef __hpux
115
116/* Define VIRT_ADDR_VARIES if the virtual addresses of
117 pure and impure space as loaded can vary, and even their
118 relative order cannot be relied on.
119
120 Otherwise Emacs assumes that text space precedes data space,
121 numerically. */
122
123#define VIRT_ADDR_VARIES
124
125/* the data segment on this machine always starts at address 0x40000000. */
126
127#define DATA_SEG_BITS 0x40000000
128
129#define DATA_START 0x40000000
130#define TEXT_START 0x00000000
131
132/* This machine requires completely different unexec code
133 which lives in a separate file. Specify the file name. */
134
135#define UNEXEC unexhp9k800.o
136
137#define LIBS_MACHINE
138#define LIBS_DEBUG
139
140/* Include the file bsdtty.h, since this machine has job control. */
141#define NEED_BSDTTY
142
143/* Data type of load average, as read out of kmem. */
144
145#define LOAD_AVE_TYPE double
146
147/* Convert that into an integer that is 100 for a load average of 1.0 */
148
149#define LOAD_AVE_CVT(x) ((int) (x * 100.0))
150
151/* The symbol in the kernel where the load average is found
152 is named _avenrun. At this time there are two major flavors
153 of hp-ux (there is the s800 and s300 (s200) flavors). The
154 differences are thusly moved to the corresponding machine description file.
155*/
156
157/* no underscore please */
158#define LDAV_SYMBOL "avenrun"
159
160#if 0 /* Supposedly no longer true. */
161/* In hpux, for unknown reasons, S_IFLNK is defined even though
162 symbolic links do not exist.
163 Make sure our conditionals based on S_IFLNK are not confused.
164
165 Here we assume that stat.h is included before config.h
166 so that we can override it here. */
167
168#undef S_IFLNK
169#endif
170
171/* On USG systems these have different names. */
172
173#define index strchr
174#define rindex strrchr
175
176#endif /* __hpux */
177
178/* Systems with GCC don't need to lose. */ 107/* Systems with GCC don't need to lose. */
179#ifdef __NetBSD__ 108#ifdef __NetBSD__
180# ifdef __GNUC__ 109# ifdef __GNUC__
diff --git a/src/m/sr2k.h b/src/m/sr2k.h
deleted file mode 100644
index 2342bf8ef20..00000000000
--- a/src/m/sr2k.h
+++ /dev/null
@@ -1,160 +0,0 @@
1/* machine description file for Hitachi SR2001/SR2201 machines.
2 Copyright (C) 1996, 2001, 2002, 2003, 2004, 2005,
3 2006, 2007 Free Software Foundation, Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 2, or (at your option)
10any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs; see the file COPYING. If not, write to
19the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20Boston, MA 02110-1301, USA. */
21
22
23/* The following line tells the configuration script what sort of
24 operating system this machine is likely to run.
25 USUAL-OPSYS="hpux" */
26
27/* Define WORDS_BIG_ENDIAN iff lowest-numbered byte in a word
28 is the most significant byte. */
29
30#define WORDS_BIG_ENDIAN
31
32/* Define NO_ARG_ARRAY if you cannot take the address of the first of a
33 * group of arguments and treat it as an array of the arguments. */
34
35#define NO_ARG_ARRAY
36
37/* Define WORD_MACHINE if addresses and such have
38 * to be corrected before they can be used as byte counts. */
39
40#undef WORD_MACHINE
41
42/* Now define a symbol for the cpu type, if your compiler
43 does not define it automatically:
44 Ones defined so far include vax, m68000, ns16000, pyramid,
45 orion, tahoe, APOLLO and many others */
46#ifndef hp9000s800
47# define hp9000s800
48#endif
49
50/* Use type int rather than a union, to represent Lisp_Object */
51/* This is desirable for most machines. */
52
53#define NO_UNION_TYPE
54
55/* Define EXPLICIT_SIGN_EXTEND if XINT must explicitly sign-extend
56 the bit field into an int. In other words, if bit fields
57 are always unsigned.
58
59 If you use NO_UNION_TYPE, this flag does not matter. */
60
61#define EXPLICIT_SIGN_EXTEND
62
63/* The standard definitions of these macros would work ok,
64 but these are faster because the constants are short. */
65
66
67#define XUINT(a) (((unsigned)(a) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS)
68
69#define XSET(var, type, ptr) \
70 ((var) = ((int)(type) << VALBITS) + (((unsigned) (ptr) << BITS_PER_INT-VALBITS) >> BITS_PER_INT-VALBITS))
71
72/* #ifdef __hpux */
73/* Now define a symbol for the cpu type, if your compiler
74 does not define it automatically:
75 Ones defined so far include vax, m68000, ns16000, pyramid,
76 orion, tahoe, APOLLO and many others */
77
78#ifndef hp9000s800
79# define hp9000s800
80#endif
81
82
83/* Data type of load average, as read out of kmem. */
84
85#define LOAD_AVE_TYPE double
86
87/* Convert that into an integer that is 100 for a load average of 1.0 */
88
89#define LOAD_AVE_CVT(x) ((int) (x * 100.0))
90
91
92/* Define CANNOT_DUMP on machines where unexec does not work.
93 Then the function dump-emacs will not be defined
94 and temacs will do (load "loadup") automatically unless told otherwise. */
95
96#undef CANNOT_DUMP
97
98/* Define VIRT_ADDR_VARIES if the virtual addresses of
99 pure and impure space as loaded can vary, and even their
100 relative order cannot be relied on.
101
102 Otherwise Emacs assumes that text space precedes data space,
103 numerically. */
104
105#define VIRT_ADDR_VARIES
106
107/* the data segment on this machine always starts at address 0x40000000. */
108
109#define DATA_SEG_BITS 0x40000000
110
111#define DATA_START 0x40000000
112#define TEXT_START 0x00000000
113
114/* Define NO_REMAP if memory segmentation makes it not work well
115 to change the boundary between the text section and data section
116 when Emacs is dumped. If you define this, the preloaded Lisp
117 code will not be sharable; but that's better than failing completely. */
118
119#define NO_REMAP
120
121/* This machine requires completely different unexec code
122 which lives in a separate file. Specify the file name. */
123
124#define UNEXEC unexhp9k800.o
125
126#define LIBS_MACHINE
127#define LIBS_DEBUG
128
129/* Include the file bsdtty.h, since this machine has job control. */
130/* #define NEED_BSDTTY */
131
132/* The symbol in the kernel where the load average is found
133 is named _avenrun. At this time there are two major flavors
134 of hp-ux (there is the s800 and s300 (s200) flavors). The
135 differences are thusly moved to the corresponding machine description file.
136*/
137
138/* no underscore please */
139#define LDAV_SYMBOL "avenrun"
140
141#if 0 /* Supposedly no longer true. */
142/* In hpux, for unknown reasons, S_IFLNK is defined even though
143 symbolic links do not exist.
144 Make sure our conditionals based on S_IFLNK are not confused.
145
146 Here we assume that stat.h is included before config.h
147 so that we can override it here. */
148
149#undef S_IFLNK
150#endif
151
152/* On USG systems these have different names. */
153
154#define index strchr
155#define rindex strrchr
156
157/* #endif */
158
159/* arch-tag: 4ced5b51-ffe6-4be1-9954-eb40657023a5
160 (do not change this comment) */
diff --git a/src/minibuf.c b/src/minibuf.c
index 58bcf1ef1a4..874d3f24e0a 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1230,22 +1230,25 @@ minibuf_conform_representation (string, basis)
1230} 1230}
1231 1231
1232DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0, 1232DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0,
1233 doc: /* Return common substring of all completions of STRING in ALIST. 1233 doc: /* Return common substring of all completions of STRING in COLLECTION.
1234Each car of each element of ALIST (or each element if it is not a cons cell) 1234Test each possible completion specified by COLLECTION
1235is tested to see if it begins with STRING. The possible matches may be 1235to see if it begins with STRING. The possible completions may be
1236strings or symbols. Symbols are converted to strings before testing, 1236strings or symbols. Symbols are converted to strings before testing,
1237see `symbol-name'. 1237see `symbol-name'.
1238All that match are compared together; the longest initial sequence 1238All that match STRING are compared together; the longest initial sequence
1239common to all matches is returned as a string. 1239common to all these matches is the return value.
1240If there is no match at all, nil is returned. 1240If there is no match at all, the return value is nil.
1241For a unique match which is exact, t is returned. 1241For a unique match which is exact, the return value is t.
1242 1242
1243If ALIST is a hash-table, all the string and symbol keys are the 1243If COLLECTION is an alist, the keys (cars of elements) are the
1244possible matches. 1244possible completions. If an element is not a cons cell, then the
1245If ALIST is an obarray, the names of all symbols in the obarray 1245element itself is the possible completion.
1246are the possible matches. 1246If COLLECTION is a hash-table, all the keys that are strings or symbols
1247 1247are the possible completions.
1248ALIST can also be a function to do the completion itself. 1248If COLLECTION is an obarray, the names of all symbols in the obarray
1249are the possible completions.
1250
1251COLLECTION can also be a function to do the completion itself.
1249It receives three arguments: the values STRING, PREDICATE and nil. 1252It receives three arguments: the values STRING, PREDICATE and nil.
1250Whatever it returns becomes the value of `try-completion'. 1253Whatever it returns becomes the value of `try-completion'.
1251 1254
@@ -1253,23 +1256,23 @@ If optional third argument PREDICATE is non-nil,
1253it is used to test each possible match. 1256it is used to test each possible match.
1254The match is a candidate only if PREDICATE returns non-nil. 1257The match is a candidate only if PREDICATE returns non-nil.
1255The argument given to PREDICATE is the alist element 1258The argument given to PREDICATE is the alist element
1256or the symbol from the obarray. If ALIST is a hash-table, 1259or the symbol from the obarray. If COLLECTION is a hash-table,
1257predicate is called with two arguments: the key and the value. 1260predicate is called with two arguments: the key and the value.
1258Additionally to this predicate, `completion-regexp-list' 1261Additionally to this predicate, `completion-regexp-list'
1259is used to further constrain the set of candidates. */) 1262is used to further constrain the set of candidates. */)
1260 (string, alist, predicate) 1263 (string, collection, predicate)
1261 Lisp_Object string, alist, predicate; 1264 Lisp_Object string, collection, predicate;
1262{ 1265{
1263 Lisp_Object bestmatch, tail, elt, eltstring; 1266 Lisp_Object bestmatch, tail, elt, eltstring;
1264 /* Size in bytes of BESTMATCH. */ 1267 /* Size in bytes of BESTMATCH. */
1265 int bestmatchsize = 0; 1268 int bestmatchsize = 0;
1266 /* These are in bytes, too. */ 1269 /* These are in bytes, too. */
1267 int compare, matchsize; 1270 int compare, matchsize;
1268 int type = (HASH_TABLE_P (alist) ? 3 1271 int type = (HASH_TABLE_P (collection) ? 3
1269 : VECTORP (alist) ? 2 1272 : VECTORP (collection) ? 2
1270 : NILP (alist) || (CONSP (alist) 1273 : NILP (collection) || (CONSP (collection)
1271 && (!SYMBOLP (XCAR (alist)) 1274 && (!SYMBOLP (XCAR (collection))
1272 || NILP (XCAR (alist))))); 1275 || NILP (XCAR (collection)))));
1273 int index = 0, obsize = 0; 1276 int index = 0, obsize = 0;
1274 int matchcount = 0; 1277 int matchcount = 0;
1275 int bindcount = -1; 1278 int bindcount = -1;
@@ -1278,18 +1281,18 @@ is used to further constrain the set of candidates. */)
1278 1281
1279 CHECK_STRING (string); 1282 CHECK_STRING (string);
1280 if (type == 0) 1283 if (type == 0)
1281 return call3 (alist, string, predicate, Qnil); 1284 return call3 (collection, string, predicate, Qnil);
1282 1285
1283 bestmatch = bucket = Qnil; 1286 bestmatch = bucket = Qnil;
1284 zero = make_number (0); 1287 zero = make_number (0);
1285 1288
1286 /* If ALIST is not a list, set TAIL just for gc pro. */ 1289 /* If COLLECTION is not a list, set TAIL just for gc pro. */
1287 tail = alist; 1290 tail = collection;
1288 if (type == 2) 1291 if (type == 2)
1289 { 1292 {
1290 alist = check_obarray (alist); 1293 collection = check_obarray (collection);
1291 obsize = XVECTOR (alist)->size; 1294 obsize = XVECTOR (collection)->size;
1292 bucket = XVECTOR (alist)->contents[index]; 1295 bucket = XVECTOR (collection)->contents[index];
1293 } 1296 }
1294 1297
1295 while (1) 1298 while (1)
@@ -1324,19 +1327,19 @@ is used to further constrain the set of candidates. */)
1324 break; 1327 break;
1325 else 1328 else
1326 { 1329 {
1327 bucket = XVECTOR (alist)->contents[index]; 1330 bucket = XVECTOR (collection)->contents[index];
1328 continue; 1331 continue;
1329 } 1332 }
1330 } 1333 }
1331 else /* if (type == 3) */ 1334 else /* if (type == 3) */
1332 { 1335 {
1333 while (index < HASH_TABLE_SIZE (XHASH_TABLE (alist)) 1336 while (index < HASH_TABLE_SIZE (XHASH_TABLE (collection))
1334 && NILP (HASH_HASH (XHASH_TABLE (alist), index))) 1337 && NILP (HASH_HASH (XHASH_TABLE (collection), index)))
1335 index++; 1338 index++;
1336 if (index >= HASH_TABLE_SIZE (XHASH_TABLE (alist))) 1339 if (index >= HASH_TABLE_SIZE (XHASH_TABLE (collection)))
1337 break; 1340 break;
1338 else 1341 else
1339 elt = eltstring = HASH_KEY (XHASH_TABLE (alist), index++); 1342 elt = eltstring = HASH_KEY (XHASH_TABLE (collection), index++);
1340 } 1343 }
1341 1344
1342 /* Is this element a possible completion? */ 1345 /* Is this element a possible completion? */
@@ -1389,7 +1392,7 @@ is used to further constrain the set of candidates. */)
1389 GCPRO4 (tail, string, eltstring, bestmatch); 1392 GCPRO4 (tail, string, eltstring, bestmatch);
1390 tem = type == 3 1393 tem = type == 3
1391 ? call2 (predicate, elt, 1394 ? call2 (predicate, elt,
1392 HASH_VALUE (XHASH_TABLE (alist), index - 1)) 1395 HASH_VALUE (XHASH_TABLE (collection), index - 1))
1393 : call1 (predicate, elt); 1396 : call1 (predicate, elt);
1394 UNGCPRO; 1397 UNGCPRO;
1395 } 1398 }
@@ -1498,19 +1501,22 @@ is used to further constrain the set of candidates. */)
1498} 1501}
1499 1502
1500DEFUN ("all-completions", Fall_completions, Sall_completions, 2, 4, 0, 1503DEFUN ("all-completions", Fall_completions, Sall_completions, 2, 4, 0,
1501 doc: /* Search for partial matches to STRING in ALIST. 1504 doc: /* Search for partial matches to STRING in COLLECTION.
1502Each car of each element of ALIST (or each element if it is not a cons cell) 1505Test each of the possible completions specified by COLLECTION
1503is tested to see if it begins with STRING. The possible matches may be 1506to see if it begins with STRING. The possible completions may be
1504strings or symbols. Symbols are converted to strings before testing, 1507strings or symbols. Symbols are converted to strings before testing,
1505see `symbol-name'. 1508see `symbol-name'.
1506The value is a list of all the strings from ALIST that match. 1509The value is a list of all the possible completions that match STRING.
1507 1510
1508If ALIST is a hash-table, all the string and symbol keys are the 1511If COLLECTION is an alist, the keys (cars of elements) are the
1509possible matches. 1512possible completions. If an element is not a cons cell, then the
1510If ALIST is an obarray, the names of all symbols in the obarray 1513element itself is the possible completion.
1511are the possible matches. 1514If COLLECTION is a hash-table, all the keys that are strings or symbols
1515are the possible completions.
1516If COLLECTION is an obarray, the names of all symbols in the obarray
1517are the possible completions.
1512 1518
1513ALIST can also be a function to do the completion itself. 1519COLLECTION can also be a function to do the completion itself.
1514It receives three arguments: the values STRING, PREDICATE and t. 1520It receives three arguments: the values STRING, PREDICATE and t.
1515Whatever it returns becomes the value of `all-completions'. 1521Whatever it returns becomes the value of `all-completions'.
1516 1522
@@ -1518,24 +1524,24 @@ If optional third argument PREDICATE is non-nil,
1518it is used to test each possible match. 1524it is used to test each possible match.
1519The match is a candidate only if PREDICATE returns non-nil. 1525The match is a candidate only if PREDICATE returns non-nil.
1520The argument given to PREDICATE is the alist element 1526The argument given to PREDICATE is the alist element
1521or the symbol from the obarray. If ALIST is a hash-table, 1527or the symbol from the obarray. If COLLECTION is a hash-table,
1522predicate is called with two arguments: the key and the value. 1528predicate is called with two arguments: the key and the value.
1523Additionally to this predicate, `completion-regexp-list' 1529Additionally to this predicate, `completion-regexp-list'
1524is used to further constrain the set of candidates. 1530is used to further constrain the set of candidates.
1525 1531
1526If the optional fourth argument HIDE-SPACES is non-nil, 1532If the optional fourth argument HIDE-SPACES is non-nil,
1527strings in ALIST that start with a space 1533strings in COLLECTION that start with a space
1528are ignored unless STRING itself starts with a space. */) 1534are ignored unless STRING itself starts with a space. */)
1529 (string, alist, predicate, hide_spaces) 1535 (string, collection, predicate, hide_spaces)
1530 Lisp_Object string, alist, predicate, hide_spaces; 1536 Lisp_Object string, collection, predicate, hide_spaces;
1531{ 1537{
1532 Lisp_Object tail, elt, eltstring; 1538 Lisp_Object tail, elt, eltstring;
1533 Lisp_Object allmatches; 1539 Lisp_Object allmatches;
1534 int type = HASH_TABLE_P (alist) ? 3 1540 int type = HASH_TABLE_P (collection) ? 3
1535 : VECTORP (alist) ? 2 1541 : VECTORP (collection) ? 2
1536 : NILP (alist) || (CONSP (alist) 1542 : NILP (collection) || (CONSP (collection)
1537 && (!SYMBOLP (XCAR (alist)) 1543 && (!SYMBOLP (XCAR (collection))
1538 || NILP (XCAR (alist)))); 1544 || NILP (XCAR (collection))));
1539 int index = 0, obsize = 0; 1545 int index = 0, obsize = 0;
1540 int bindcount = -1; 1546 int bindcount = -1;
1541 Lisp_Object bucket, tem, zero; 1547 Lisp_Object bucket, tem, zero;
@@ -1543,16 +1549,16 @@ are ignored unless STRING itself starts with a space. */)
1543 1549
1544 CHECK_STRING (string); 1550 CHECK_STRING (string);
1545 if (type == 0) 1551 if (type == 0)
1546 return call3 (alist, string, predicate, Qt); 1552 return call3 (collection, string, predicate, Qt);
1547 allmatches = bucket = Qnil; 1553 allmatches = bucket = Qnil;
1548 zero = make_number (0); 1554 zero = make_number (0);
1549 1555
1550 /* If ALIST is not a list, set TAIL just for gc pro. */ 1556 /* If COLLECTION is not a list, set TAIL just for gc pro. */
1551 tail = alist; 1557 tail = collection;
1552 if (type == 2) 1558 if (type == 2)
1553 { 1559 {
1554 obsize = XVECTOR (alist)->size; 1560 obsize = XVECTOR (collection)->size;
1555 bucket = XVECTOR (alist)->contents[index]; 1561 bucket = XVECTOR (collection)->contents[index];
1556 } 1562 }
1557 1563
1558 while (1) 1564 while (1)
@@ -1585,19 +1591,19 @@ are ignored unless STRING itself starts with a space. */)
1585 break; 1591 break;
1586 else 1592 else
1587 { 1593 {
1588 bucket = XVECTOR (alist)->contents[index]; 1594 bucket = XVECTOR (collection)->contents[index];
1589 continue; 1595 continue;
1590 } 1596 }
1591 } 1597 }
1592 else /* if (type == 3) */ 1598 else /* if (type == 3) */
1593 { 1599 {
1594 while (index < HASH_TABLE_SIZE (XHASH_TABLE (alist)) 1600 while (index < HASH_TABLE_SIZE (XHASH_TABLE (collection))
1595 && NILP (HASH_HASH (XHASH_TABLE (alist), index))) 1601 && NILP (HASH_HASH (XHASH_TABLE (collection), index)))
1596 index++; 1602 index++;
1597 if (index >= HASH_TABLE_SIZE (XHASH_TABLE (alist))) 1603 if (index >= HASH_TABLE_SIZE (XHASH_TABLE (collection)))
1598 break; 1604 break;
1599 else 1605 else
1600 elt = eltstring = HASH_KEY (XHASH_TABLE (alist), index++); 1606 elt = eltstring = HASH_KEY (XHASH_TABLE (collection), index++);
1601 } 1607 }
1602 1608
1603 /* Is this element a possible completion? */ 1609 /* Is this element a possible completion? */
@@ -1659,7 +1665,7 @@ are ignored unless STRING itself starts with a space. */)
1659 GCPRO4 (tail, eltstring, allmatches, string); 1665 GCPRO4 (tail, eltstring, allmatches, string);
1660 tem = type == 3 1666 tem = type == 3
1661 ? call2 (predicate, elt, 1667 ? call2 (predicate, elt,
1662 HASH_VALUE (XHASH_TABLE (alist), index - 1)) 1668 HASH_VALUE (XHASH_TABLE (collection), index - 1))
1663 : call1 (predicate, elt); 1669 : call1 (predicate, elt);
1664 UNGCPRO; 1670 UNGCPRO;
1665 } 1671 }
@@ -1686,14 +1692,14 @@ Lisp_Object Vminibuffer_completing_file_name;
1686DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0, 1692DEFUN ("completing-read", Fcompleting_read, Scompleting_read, 2, 8, 0,
1687 doc: /* Read a string in the minibuffer, with completion. 1693 doc: /* Read a string in the minibuffer, with completion.
1688PROMPT is a string to prompt with; normally it ends in a colon and a space. 1694PROMPT is a string to prompt with; normally it ends in a colon and a space.
1689TABLE can be a list of strings, an alist, an obarray or a hash table. 1695COLLECTION can be a list of strings, an alist, an obarray or a hash table.
1690TABLE can also be a function to do the completion itself. 1696COLLECTION can also be a function to do the completion itself.
1691PREDICATE limits completion to a subset of TABLE. 1697PREDICATE limits completion to a subset of COLLECTION.
1692See `try-completion' and `all-completions' for more details 1698See `try-completion' and `all-completions' for more details
1693 on completion, TABLE, and PREDICATE. 1699 on completion, COLLECTION, and PREDICATE.
1694 1700
1695If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless 1701If REQUIRE-MATCH is non-nil, the user is not allowed to exit unless
1696 the input is (or completes to) an element of TABLE or is null. 1702 the input is (or completes to) an element of COLLECTION or is null.
1697 If it is also not t, typing RET does not exit if it does non-null completion. 1703 If it is also not t, typing RET does not exit if it does non-null completion.
1698If the input is null, `completing-read' returns DEF, or an empty string 1704If the input is null, `completing-read' returns DEF, or an empty string
1699 if DEF is nil, regardless of the value of REQUIRE-MATCH. 1705 if DEF is nil, regardless of the value of REQUIRE-MATCH.
@@ -1727,8 +1733,8 @@ If INHERIT-INPUT-METHOD is non-nil, the minibuffer inherits
1727 1733
1728Completion ignores case if the ambient value of 1734Completion ignores case if the ambient value of
1729 `completion-ignore-case' is non-nil. */) 1735 `completion-ignore-case' is non-nil. */)
1730 (prompt, table, predicate, require_match, initial_input, hist, def, inherit_input_method) 1736 (prompt, collection, predicate, require_match, initial_input, hist, def, inherit_input_method)
1731 Lisp_Object prompt, table, predicate, require_match, initial_input; 1737 Lisp_Object prompt, collection, predicate, require_match, initial_input;
1732 Lisp_Object hist, def, inherit_input_method; 1738 Lisp_Object hist, def, inherit_input_method;
1733{ 1739{
1734 Lisp_Object val, histvar, histpos, position; 1740 Lisp_Object val, histvar, histpos, position;
@@ -1740,7 +1746,7 @@ Completion ignores case if the ambient value of
1740 init = initial_input; 1746 init = initial_input;
1741 GCPRO1 (def); 1747 GCPRO1 (def);
1742 1748
1743 specbind (Qminibuffer_completion_table, table); 1749 specbind (Qminibuffer_completion_table, collection);
1744 specbind (Qminibuffer_completion_predicate, predicate); 1750 specbind (Qminibuffer_completion_predicate, predicate);
1745 specbind (Qminibuffer_completion_confirm, 1751 specbind (Qminibuffer_completion_confirm,
1746 EQ (require_match, Qt) ? Qnil : require_match); 1752 EQ (require_match, Qt) ? Qnil : require_match);
@@ -1802,27 +1808,28 @@ Lisp_Object Fassoc_string ();
1802DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0, 1808DEFUN ("test-completion", Ftest_completion, Stest_completion, 2, 3, 0,
1803 doc: /* Return non-nil if STRING is a valid completion. 1809 doc: /* Return non-nil if STRING is a valid completion.
1804Takes the same arguments as `all-completions' and `try-completion'. 1810Takes the same arguments as `all-completions' and `try-completion'.
1805If ALIST is a function, it is called with three arguments: 1811If COLLECTION is a function, it is called with three arguments:
1806the values STRING, PREDICATE and `lambda'. */) 1812the values STRING, PREDICATE and `lambda'. */)
1807 (string, alist, predicate) 1813 (string, collection, predicate)
1808 Lisp_Object string, alist, predicate; 1814 Lisp_Object string, collection, predicate;
1809{ 1815{
1810 Lisp_Object regexps, tail, tem = Qnil; 1816 Lisp_Object regexps, tail, tem = Qnil;
1811 int i = 0; 1817 int i = 0;
1812 1818
1813 CHECK_STRING (string); 1819 CHECK_STRING (string);
1814 1820
1815 if ((CONSP (alist) && (!SYMBOLP (XCAR (alist)) || NILP (XCAR (alist)))) 1821 if ((CONSP (collection)
1816 || NILP (alist)) 1822 && (!SYMBOLP (XCAR (collection)) || NILP (XCAR (collection))))
1823 || NILP (collection))
1817 { 1824 {
1818 tem = Fassoc_string (string, alist, completion_ignore_case ? Qt : Qnil); 1825 tem = Fassoc_string (string, collection, completion_ignore_case ? Qt : Qnil);
1819 if (NILP (tem)) 1826 if (NILP (tem))
1820 return Qnil; 1827 return Qnil;
1821 } 1828 }
1822 else if (VECTORP (alist)) 1829 else if (VECTORP (collection))
1823 { 1830 {
1824 /* Bypass intern-soft as that loses for nil. */ 1831 /* Bypass intern-soft as that loses for nil. */
1825 tem = oblookup (alist, 1832 tem = oblookup (collection,
1826 SDATA (string), 1833 SDATA (string),
1827 SCHARS (string), 1834 SCHARS (string),
1828 SBYTES (string)); 1835 SBYTES (string));
@@ -1833,7 +1840,7 @@ the values STRING, PREDICATE and `lambda'. */)
1833 else 1840 else
1834 string = Fstring_make_multibyte (string); 1841 string = Fstring_make_multibyte (string);
1835 1842
1836 tem = oblookup (alist, 1843 tem = oblookup (collection,
1837 SDATA (string), 1844 SDATA (string),
1838 SCHARS (string), 1845 SCHARS (string),
1839 SBYTES (string)); 1846 SBYTES (string));
@@ -1841,9 +1848,9 @@ the values STRING, PREDICATE and `lambda'. */)
1841 1848
1842 if (completion_ignore_case && !SYMBOLP (tem)) 1849 if (completion_ignore_case && !SYMBOLP (tem))
1843 { 1850 {
1844 for (i = XVECTOR (alist)->size - 1; i >= 0; i--) 1851 for (i = XVECTOR (collection)->size - 1; i >= 0; i--)
1845 { 1852 {
1846 tail = XVECTOR (alist)->contents[i]; 1853 tail = XVECTOR (collection)->contents[i];
1847 if (SYMBOLP (tail)) 1854 if (SYMBOLP (tail))
1848 while (1) 1855 while (1)
1849 { 1856 {
@@ -1865,9 +1872,9 @@ the values STRING, PREDICATE and `lambda'. */)
1865 if (!SYMBOLP (tem)) 1872 if (!SYMBOLP (tem))
1866 return Qnil; 1873 return Qnil;
1867 } 1874 }
1868 else if (HASH_TABLE_P (alist)) 1875 else if (HASH_TABLE_P (collection))
1869 { 1876 {
1870 struct Lisp_Hash_Table *h = XHASH_TABLE (alist); 1877 struct Lisp_Hash_Table *h = XHASH_TABLE (collection);
1871 i = hash_lookup (h, string, NULL); 1878 i = hash_lookup (h, string, NULL);
1872 if (i >= 0) 1879 if (i >= 0)
1873 tem = HASH_KEY (h, i); 1880 tem = HASH_KEY (h, i);
@@ -1886,7 +1893,7 @@ the values STRING, PREDICATE and `lambda'. */)
1886 return Qnil; 1893 return Qnil;
1887 } 1894 }
1888 else 1895 else
1889 return call3 (alist, string, predicate, Qlambda); 1896 return call3 (collection, string, predicate, Qlambda);
1890 1897
1891 /* Reject this element if it fails to match all the regexps. */ 1898 /* Reject this element if it fails to match all the regexps. */
1892 if (CONSP (Vcompletion_regexp_list)) 1899 if (CONSP (Vcompletion_regexp_list))
@@ -1907,8 +1914,8 @@ the values STRING, PREDICATE and `lambda'. */)
1907 /* Finally, check the predicate. */ 1914 /* Finally, check the predicate. */
1908 if (!NILP (predicate)) 1915 if (!NILP (predicate))
1909 { 1916 {
1910 return HASH_TABLE_P (alist) 1917 return HASH_TABLE_P (collection)
1911 ? call2 (predicate, tem, HASH_VALUE (XHASH_TABLE (alist), i)) 1918 ? call2 (predicate, tem, HASH_VALUE (XHASH_TABLE (collection), i))
1912 : call1 (predicate, tem); 1919 : call1 (predicate, tem);
1913 } 1920 }
1914 else 1921 else
diff --git a/src/syssignal.h b/src/syssignal.h
index a4e3fcb3e1b..36292670bc6 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -210,7 +210,7 @@ char *strsignal ();
210#ifdef HAVE_GTK_AND_PTHREAD 210#ifdef HAVE_GTK_AND_PTHREAD
211#define SIGNAL_THREAD_CHECK(signo) \ 211#define SIGNAL_THREAD_CHECK(signo) \
212 do { \ 212 do { \
213 if (pthread_self () != main_thread) \ 213 if (!pthread_equal (pthread_self (), main_thread)) \
214 { \ 214 { \
215 /* POSIX says any thread can receive the signal. On GNU/Linux \ 215 /* POSIX says any thread can receive the signal. On GNU/Linux \
216 that is not true, but for other systems (FreeBSD at least) \ 216 that is not true, but for other systems (FreeBSD at least) \
diff --git a/src/unexhp9k800.c b/src/unexhp9k800.c
deleted file mode 100644
index 146cc5707da..00000000000
--- a/src/unexhp9k800.c
+++ /dev/null
@@ -1,322 +0,0 @@
1/* Unexec for HP 9000 Series 800 machines.
2 Bob Desinger <hpsemc!bd@hplabs.hp.com>
3
4 Note that the GNU project considers support for HP operation a
5 peripheral activity which should not be allowed to divert effort
6 from development of the GNU system. Changes in this code will be
7 installed when users send them in, but aside from that we don't
8 plan to think about it, or about whether other Emacs maintenance
9 might break it.
10
11
12 Unexec creates a copy of the old a.out file, and replaces the old data
13 area with the current data area. When the new file is executed, the
14 process will see the same data structures and data values that the
15 original process had when unexec was called.
16
17 Unlike other versions of unexec, this one copies symbol table and
18 debug information to the new a.out file. Thus, the new a.out file
19 may be debugged with symbolic debuggers.
20
21 If you fix any bugs in this, I'd like to incorporate your fixes.
22 Send them to uunet!hpda!hpsemc!jmorris or jmorris%hpsemc@hplabs.HP.COM.
23
24 CAVEATS:
25 This routine saves the current value of all static and external
26 variables. This means that any data structure that needs to be
27 initialized must be explicitly reset. Variables will not have their
28 expected default values.
29
30 Unfortunately, the HP-UX signal handler has internal initialization
31 flags which are not explicitly reset. Thus, for signals to work in
32 conjunction with this routine, the following code must executed when
33 the new process starts up.
34
35 void _sigreturn ();
36 ...
37 sigsetreturn (_sigreturn);
38*/
39
40#ifdef emacs
41#include <config.h>
42#endif
43
44#include <stdio.h>
45#include <fcntl.h>
46#include <errno.h>
47
48#include <a.out.h>
49
50#ifdef HPUX_USE_SHLIBS
51#include <dl.h>
52#endif
53
54/* brk value to restore, stored as a global.
55 This is really used only if we used shared libraries. */
56static long brk_on_dump = 0;
57
58/* Called from main, if we use shared libraries. */
59int
60run_time_remap (ignored)
61 char *ignored;
62{
63 brk ((char *) brk_on_dump);
64}
65
66#undef roundup
67#define roundup(x,n) (((x) + ((n) - 1)) & ~((n) - 1)) /* n is power of 2 */
68#define min(x,y) (((x) < (y)) ? (x) : (y))
69
70
71/* Create a new a.out file, same as old but with current data space */
72
73unexec (new_name, old_name, new_end_of_text, dummy1, dummy2)
74 char new_name[]; /* name of the new a.out file to be created */
75 char old_name[]; /* name of the old a.out file */
76 char *new_end_of_text; /* ptr to new edata/etext; NOT USED YET */
77 int dummy1, dummy2; /* not used by emacs */
78{
79 int old, new;
80 int old_size, new_size;
81 struct header hdr;
82 struct som_exec_auxhdr auxhdr;
83 long i;
84
85 /* For the greatest flexibility, should create a temporary file in
86 the same directory as the new file. When everything is complete,
87 rename the temp file to the new name.
88 This way, a program could update its own a.out file even while
89 it is still executing. If problems occur, everything is still
90 intact. NOT implemented. */
91
92 /* Open the input and output a.out files */
93 old = open (old_name, O_RDONLY);
94 if (old < 0)
95 { perror (old_name); exit (1); }
96 new = open (new_name, O_CREAT|O_RDWR|O_TRUNC, 0777);
97 if (new < 0)
98 { perror (new_name); exit (1); }
99
100 /* Read the old headers */
101 read_header (old, &hdr, &auxhdr);
102
103 brk_on_dump = (long) sbrk (0);
104
105 /* Decide how large the new and old data areas are */
106 old_size = auxhdr.exec_dsize;
107 /* I suspect these two statements are separate
108 to avoid a compiler bug in hpux version 8. */
109 i = (long) sbrk (0);
110 new_size = i - auxhdr.exec_dmem;
111
112 /* Copy the old file to the new, up to the data space */
113 lseek (old, 0, 0);
114 copy_file (old, new, auxhdr.exec_dfile);
115
116 /* Skip the old data segment and write a new one */
117 lseek (old, old_size, 1);
118 save_data_space (new, &hdr, &auxhdr, new_size);
119
120 /* Copy the rest of the file */
121 copy_rest (old, new);
122
123 /* Update file pointers since we probably changed size of data area */
124 update_file_ptrs (new, &hdr, &auxhdr, auxhdr.exec_dfile, new_size-old_size);
125
126 /* Save the modified header */
127 write_header (new, &hdr, &auxhdr);
128
129 /* Close the binary file */
130 close (old);
131 close (new);
132 return 0;
133}
134
135/* Save current data space in the file, update header. */
136
137save_data_space (file, hdr, auxhdr, size)
138 int file;
139 struct header *hdr;
140 struct som_exec_auxhdr *auxhdr;
141 int size;
142{
143 /* Write the entire data space out to the file */
144 if (write (file, auxhdr->exec_dmem, size) != size)
145 { perror ("Can't save new data space"); exit (1); }
146
147 /* Update the header to reflect the new data size */
148 auxhdr->exec_dsize = size;
149 auxhdr->exec_bsize = 0;
150}
151
152/* Update the values of file pointers when something is inserted. */
153
154update_file_ptrs (file, hdr, auxhdr, location, offset)
155 int file;
156 struct header *hdr;
157 struct som_exec_auxhdr *auxhdr;
158 unsigned int location;
159 int offset;
160{
161 struct subspace_dictionary_record subspace;
162 int i;
163
164 /* Increase the overall size of the module */
165 hdr->som_length += offset;
166
167 /* Update the various file pointers in the header */
168#define update(ptr) if (ptr > location) ptr = ptr + offset
169 update (hdr->aux_header_location);
170 update (hdr->space_strings_location);
171 update (hdr->init_array_location);
172 update (hdr->compiler_location);
173 update (hdr->symbol_location);
174 update (hdr->fixup_request_location);
175 update (hdr->symbol_strings_location);
176 update (hdr->unloadable_sp_location);
177 update (auxhdr->exec_tfile);
178 update (auxhdr->exec_dfile);
179
180 /* Do for each subspace dictionary entry */
181 lseek (file, hdr->subspace_location, 0);
182 for (i = 0; i < hdr->subspace_total; i++)
183 {
184 if (read (file, &subspace, sizeof (subspace)) != sizeof (subspace))
185 { perror ("Can't read subspace record"); exit (1); }
186
187 /* If subspace has a file location, update it */
188 if (subspace.initialization_length > 0
189 && subspace.file_loc_init_value > location)
190 {
191 subspace.file_loc_init_value += offset;
192 lseek (file, -sizeof (subspace), 1);
193 if (write (file, &subspace, sizeof (subspace)) != sizeof (subspace))
194 { perror ("Can't update subspace record"); exit (1); }
195 }
196 }
197
198 /* Do for each initialization pointer record */
199 /* (I don't think it applies to executable files, only relocatables) */
200#undef update
201}
202
203/* Read in the header records from an a.out file. */
204
205read_header (file, hdr, auxhdr)
206 int file;
207 struct header *hdr;
208 struct som_exec_auxhdr *auxhdr;
209{
210
211 /* Read the header in */
212 lseek (file, 0, 0);
213 if (read (file, hdr, sizeof (*hdr)) != sizeof (*hdr))
214 { perror ("Couldn't read header from a.out file"); exit (1); }
215
216 if (hdr->a_magic != EXEC_MAGIC && hdr->a_magic != SHARE_MAGIC
217 && hdr->a_magic != DEMAND_MAGIC)
218 {
219 fprintf (stderr, "a.out file doesn't have legal magic number\n");
220 exit (1);
221 }
222
223 lseek (file, hdr->aux_header_location, 0);
224 if (read (file, auxhdr, sizeof (*auxhdr)) != sizeof (*auxhdr))
225 {
226 perror ("Couldn't read auxiliary header from a.out file");
227 exit (1);
228 }
229}
230
231/* Write out the header records into an a.out file. */
232
233write_header (file, hdr, auxhdr)
234 int file;
235 struct header *hdr;
236 struct som_exec_auxhdr *auxhdr;
237{
238 /* Update the checksum */
239 hdr->checksum = calculate_checksum (hdr);
240
241 /* Write the header back into the a.out file */
242 lseek (file, 0, 0);
243 if (write (file, hdr, sizeof (*hdr)) != sizeof (*hdr))
244 { perror ("Couldn't write header to a.out file"); exit (1); }
245 lseek (file, hdr->aux_header_location, 0);
246 if (write (file, auxhdr, sizeof (*auxhdr)) != sizeof (*auxhdr))
247 { perror ("Couldn't write auxiliary header to a.out file"); exit (1); }
248}
249
250/* Calculate the checksum of a SOM header record. */
251
252calculate_checksum (hdr)
253 struct header *hdr;
254{
255 int checksum, i, *ptr;
256
257 checksum = 0; ptr = (int *) hdr;
258
259 for (i = 0; i < sizeof (*hdr) / sizeof (int) - 1; i++)
260 checksum ^= ptr[i];
261
262 return (checksum);
263}
264
265/* Copy size bytes from the old file to the new one. */
266
267copy_file (old, new, size)
268 int new, old;
269 int size;
270{
271 int len;
272 int buffer[8192]; /* word aligned will be faster */
273
274 for (; size > 0; size -= len)
275 {
276 len = min (size, sizeof (buffer));
277 if (read (old, buffer, len) != len)
278 { perror ("Read failure on a.out file"); exit (1); }
279 if (write (new, buffer, len) != len)
280 { perror ("Write failure in a.out file"); exit (1); }
281 }
282}
283
284/* Copy the rest of the file, up to EOF. */
285
286copy_rest (old, new)
287 int new, old;
288{
289 int buffer[4096];
290 int len;
291
292 /* Copy bytes until end of file or error */
293 while ((len = read (old, buffer, sizeof (buffer))) > 0)
294 if (write (new, buffer, len) != len) break;
295
296 if (len != 0)
297 { perror ("Unable to copy the rest of the file"); exit (1); }
298}
299
300#ifdef DEBUG
301display_header (hdr, auxhdr)
302 struct header *hdr;
303 struct som_exec_auxhdr *auxhdr;
304{
305 /* Display the header information (debug) */
306 printf ("\n\nFILE HEADER\n");
307 printf ("magic number %d \n", hdr->a_magic);
308 printf ("text loc %.8x size %d \n", auxhdr->exec_tmem, auxhdr->exec_tsize);
309 printf ("data loc %.8x size %d \n", auxhdr->exec_dmem, auxhdr->exec_dsize);
310 printf ("entry %x \n", auxhdr->exec_entry);
311 printf ("Bss segment size %u\n", auxhdr->exec_bsize);
312 printf ("\n");
313 printf ("data file loc %d size %d\n",
314 auxhdr->exec_dfile, auxhdr->exec_dsize);
315 printf ("som_length %d\n", hdr->som_length);
316 printf ("unloadable sploc %d size %d\n",
317 hdr->unloadable_sp_location, hdr->unloadable_sp_size);
318}
319#endif /* DEBUG */
320
321/* arch-tag: d55a09ac-9427-4ec4-8496-cb9d7710774f
322 (do not change this comment) */