aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1992-01-13 22:04:23 +0000
committerJim Blandy1992-01-13 22:04:23 +0000
commit9889c728e0ac840005a175e736f9bacd1a45cd56 (patch)
tree565fd03a44a520f7af8538200d89824c4f1a762e /src
parent265a9e559da4ac72d154ecd638c51801b3e97847 (diff)
downloademacs-9889c728e0ac840005a175e736f9bacd1a45cd56.tar.gz
emacs-9889c728e0ac840005a175e736f9bacd1a45cd56.zip
Initial revision
Diffstat (limited to 'src')
-rw-r--r--src/cm.h169
-rw-r--r--src/gnu.h114
-rw-r--r--src/mem-limits.h102
-rw-r--r--src/sinkmask.h91
-rw-r--r--src/syntax.h92
-rw-r--r--src/termchar.h45
-rw-r--r--src/termopts.h40
-rw-r--r--src/unexencap.c116
-rw-r--r--src/unexmips.c305
-rw-r--r--src/unexsunos4.c288
-rw-r--r--src/x11term.h23
11 files changed, 1385 insertions, 0 deletions
diff --git a/src/cm.h b/src/cm.h
new file mode 100644
index 00000000000..eef86b93be4
--- /dev/null
+++ b/src/cm.h
@@ -0,0 +1,169 @@
1/* Cursor motion calculation definitions for GNU Emacs
2 Copyright (C) 1985, 1989 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20/* Holds the minimum and maximum costs for the parametrized capabilities. */
21struct parmcap
22 {
23 int mincost, maxcost;
24 };
25
26/* This structure holds everything needed to do cursor motion except the pad
27 character (PC) and the output speed of the terminal (ospeed), which
28 termcap wants in global variables. */
29
30struct cm
31 {
32 /* Cursor position. -1 in *both* variables means the cursor
33 position is unknown, in order to force absolute cursor motion. */
34
35 int cm_curY; /* Current row */
36 int cm_curX; /* Current column */
37
38 /* Capabilities from termcap */
39 char *cm_up; /* up (up) */
40 char *cm_down; /* down (do) */
41 char *cm_left; /* left (le) */
42 char *cm_right; /* right (nd) */
43 char *cm_home; /* home (ho) */
44 char *cm_cr; /* carriage return (cr) */
45 char *cm_ll; /* last line (ll) */
46 char *cm_tab; /* tab (ta) */
47 char *cm_backtab; /* backtab (bt) */
48 char *cm_abs; /* absolute (cm) */
49 char *cm_habs; /* horizontal absolute (ch) */
50 char *cm_vabs; /* vertical absolute (cv) */
51#if 0
52 char *cm_ds; /* "don't send" string (ds) */
53#endif
54 char *cm_multiup; /* multiple up (UP) */
55 char *cm_multidown; /* multiple down (DO) */
56 char *cm_multileft; /* multiple left (LE) */
57 char *cm_multiright; /* multiple right (RI) */
58 int cm_cols; /* number of cols on screen (co) */
59 int cm_rows; /* number of rows on screen (li) */
60 int cm_tabwidth; /* tab width (it) */
61 unsigned int cm_autowrap:1; /* autowrap flag (am) */
62 unsigned int cm_magicwrap:1; /* VT-100: cursor stays in last col but
63 will cm_wrap if next char is
64 printing (xn) */
65 unsigned int cm_usetabs:1; /* if set, use tabs */
66 unsigned int cm_losewrap:1; /* if reach right margin, forget cursor
67 location */
68 unsigned int cm_autolf:1; /* \r performs a \r\n (rn) */
69
70 /* Parametrized capabilities. This needs to be a struct since
71 the costs are accessed through pointers. */
72
73#if 0
74 struct parmcap cc_abs; /* absolute (cm) */
75 struct parmcap cc_habs; /* horizontal absolute (ch) */
76 struct parmcap cc_vabs; /* vertical absolute (cv) */
77 struct parmcap cc_multiup; /* multiple up (UP) */
78 struct parmcap cc_multidown; /* multiple down (DO) */
79 struct parmcap cc_multileft; /* multiple left (LE) */
80 struct parmcap cc_multiright; /* multiple right (RI) */
81#endif
82
83 /* Costs for the non-parametrized capabilities */
84 int cc_up; /* cost for up */
85 int cc_down; /* etc. */
86 int cc_left;
87 int cc_right;
88 int cc_home;
89 int cc_cr;
90 int cc_ll;
91 int cc_tab;
92 int cc_backtab;
93 /* These are temporary, until the code is installed to use the
94 struct parmcap fields above. */
95 int cc_abs;
96 int cc_habs;
97 int cc_vabs;
98 };
99
100extern struct cm Wcm; /* Terminal capabilities */
101extern char PC; /* Pad character */
102extern short ospeed; /* Output speed (from sg_ospeed) */
103
104/* Shorthand */
105#ifndef NoCMShortHand
106#define curY Wcm.cm_curY
107#define curX Wcm.cm_curX
108#define Up Wcm.cm_up
109#define Down Wcm.cm_down
110#define Left Wcm.cm_left
111#define Right Wcm.cm_right
112#define Tab Wcm.cm_tab
113#define BackTab Wcm.cm_backtab
114#define TabWidth Wcm.cm_tabwidth
115#define CR Wcm.cm_cr
116#define Home Wcm.cm_home
117#define LastLine Wcm.cm_ll
118#define AbsPosition Wcm.cm_abs
119#define ColPosition Wcm.cm_habs
120#define RowPosition Wcm.cm_vabs
121#define MultiUp Wcm.cm_multiup
122#define MultiDown Wcm.cm_multidown
123#define MultiLeft Wcm.cm_multileft
124#define MultiRight Wcm.cm_multiright
125#define AutoWrap Wcm.cm_autowrap
126#define MagicWrap Wcm.cm_magicwrap
127#define UseTabs Wcm.cm_usetabs
128#define ScreenRows Wcm.cm_rows
129#define ScreenCols Wcm.cm_cols
130
131#define UpCost Wcm.cc_up
132#define DownCost Wcm.cc_down
133#define LeftCost Wcm.cc_left
134#define RightCost Wcm.cc_right
135#define HomeCost Wcm.cc_home
136#define CRCost Wcm.cc_cr
137#define LastLineCost Wcm.cc_ll
138#define TabCost Wcm.cc_tab
139#define BackTabCost Wcm.cc_backtab
140#define AbsPositionCost Wcm.cc_abs
141#define ColPositionCost Wcm.cc_habs
142#define RowPositionCost Wcm.cc_vabs
143#define MultiUpCost Wcm.cc_multiup
144#define MultiDownCost Wcm.cc_multidown
145#define MultiLeftCost Wcm.cc_multileft
146#define MultiRightCost Wcm.cc_multiright
147#endif
148
149#define cmat(row,col) (curY = (row), curX = (col))
150#define cmplus(n) \
151 { \
152 if ((curX += (n)) >= ScreenCols && !MagicWrap) \
153 { \
154 if (Wcm.cm_losewrap) losecursor (); \
155 else if (AutoWrap) curX = 0, curY++; \
156 else curX--; \
157 } \
158 }
159
160#define losecursor() (curX = -1, curY = -1)
161
162extern int cost;
163extern int evalcost ();
164
165extern void cmputc ();
166extern int cmcostinit ();
167extern int cmgoto ();
168extern int Wcm_clear ();
169extern int Wcm_init ();
diff --git a/src/gnu.h b/src/gnu.h
new file mode 100644
index 00000000000..3985c406d2a
--- /dev/null
+++ b/src/gnu.h
@@ -0,0 +1,114 @@
1#ifdef HAVE_X11
2#define gnu_width 50
3#define gnu_height 50
4static char gnu_bits[] = {
5 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
6 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xef, 0xff, 0xff, 0xff, 0xff, 0xff,
7 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0xfe, 0xff, 0xff,
8 0xff, 0xff, 0xff, 0x7f, 0xfc, 0xff, 0xff, 0xf7, 0xff, 0xff, 0xff, 0xf1,
9 0xff, 0xff, 0xf3, 0xff, 0x8f, 0xff, 0xe1, 0xff, 0xff, 0xf9, 0x3f, 0x22,
10 0xfe, 0xcb, 0xff, 0xff, 0xf8, 0xc3, 0xf8, 0xfc, 0xcb, 0xff, 0x7f, 0xfc,
11 0xe0, 0xf9, 0xf9, 0xdb, 0xff, 0x7f, 0xfc, 0xf0, 0xfb, 0xf3, 0xd9, 0xff,
12 0x3f, 0x7e, 0xf8, 0xff, 0xf7, 0xcc, 0xff, 0x9f, 0x3e, 0x1c, 0x7f, 0x44,
13 0xce, 0xff, 0xcf, 0x1e, 0xcc, 0x01, 0x00, 0xe7, 0xff, 0xef, 0x0e, 0xce,
14 0x38, 0x1c, 0xe0, 0xff, 0xef, 0x0e, 0x27, 0xfe, 0xfa, 0xc3, 0xff, 0xef,
15 0x7c, 0x93, 0xff, 0xe5, 0xbf, 0xff, 0xef, 0x99, 0xc9, 0xab, 0x2a, 0x00,
16 0xff, 0xcf, 0xc3, 0x24, 0x54, 0xc5, 0xd5, 0xff, 0x9f, 0x7f, 0x16, 0xab,
17 0xca, 0xff, 0xff, 0x1f, 0x1f, 0x93, 0x46, 0x95, 0xff, 0xff, 0x7f, 0xc8,
18 0x49, 0x99, 0x8a, 0xff, 0xff, 0xff, 0xf0, 0x49, 0x4b, 0x95, 0xff, 0xff,
19 0xff, 0xf9, 0x4c, 0x88, 0x8a, 0xff, 0xff, 0xff, 0x1e, 0xe6, 0x58, 0x95,
20 0xff, 0xff, 0x3f, 0x00, 0xe6, 0xb7, 0x0a, 0xff, 0xff, 0xbf, 0x8a, 0xea,
21 0x50, 0x15, 0xff, 0xff, 0xff, 0x8f, 0xca, 0x99, 0x2a, 0xff, 0xff, 0xff,
22 0xa7, 0x95, 0x7f, 0x15, 0xff, 0xff, 0xff, 0x23, 0x55, 0x7f, 0x2a, 0xfe,
23 0xff, 0xff, 0x63, 0xd8, 0xfc, 0x14, 0xfe, 0xff, 0xff, 0x43, 0x9a, 0xfb,
24 0x2b, 0xfe, 0xff, 0xff, 0xc3, 0xaa, 0x12, 0x94, 0xfc, 0xff, 0xff, 0xc1,
25 0x32, 0xd5, 0xc1, 0xfd, 0xff, 0xff, 0x81, 0x46, 0xd5, 0x47, 0xfc, 0xff,
26 0xff, 0x83, 0x6c, 0xc2, 0x6e, 0xfc, 0xff, 0xff, 0x83, 0x89, 0x88, 0x69,
27 0xfe, 0xff, 0xff, 0x07, 0x92, 0x09, 0x3b, 0xfe, 0xff, 0xff, 0x07, 0x22,
28 0x01, 0x3c, 0xfe, 0xff, 0xff, 0x0f, 0x4e, 0x02, 0x03, 0xfe, 0xff, 0xff,
29 0x2f, 0xd0, 0x18, 0x3e, 0xff, 0xff, 0xff, 0x3f, 0xb0, 0x19, 0x9e, 0xff,
30 0xff, 0xff, 0x7f, 0x00, 0x09, 0x80, 0xff, 0xff, 0xff, 0x7f, 0x01, 0xe3,
31 0xc1, 0xff, 0xff, 0xff, 0xff, 0x05, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff,
32 0x07, 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x5f, 0xfd, 0xff, 0xff, 0xff,
33 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
34 0xff, 0xff};
35#else /* X10 */
36#define sink_width 48
37#define sink_height 48
38#define sink_mask_width 48
39#define sink_mask_height 48
40short sink_bits[] = {
41 0xffff, 0xffff, 0xffff, 0xffff,
42 0xffff, 0x9f80, 0xffff, 0xffff,
43 0x9f9f, 0xffff, 0xffff, 0x8000,
44 0xffff, 0x7fff, 0xbffe, 0xffff,
45 0x7fff, 0xa003, 0xffff, 0x7fff,
46 0xaffd, 0xffff, 0x3fff, 0xaff9,
47 0xffff, 0xffff, 0xafff, 0xffff,
48 0xffff, 0xaffc, 0xffff, 0x7fff,
49 0xaff8, 0xffff, 0xffff, 0xaffc,
50 0xffff, 0xffff, 0xafff, 0xffff,
51 0xbfff, 0xaff7, 0xffff, 0x3fff,
52 0xaff3, 0xffff, 0xffff, 0xaffc,
53 0x003f, 0x0000, 0x2000, 0x007f,
54 0x0000, 0xe000, 0xf8df, 0xffff,
55 0x07ff, 0xf9cf, 0xff0f, 0xe7ff,
56 0xf9cf, 0xfff7, 0xe7ff, 0xf9ff,
57 0x63f7, 0xe7fb, 0xf9ff, 0x5a37,
58 0xe7fb, 0xf9cf, 0x5af7, 0xe7fb,
59 0xf9cf, 0x5af7, 0xe7f9, 0xf9ef,
60 0xdb0f, 0xe7fa, 0xf9ff, 0xffff,
61 0xe7ff, 0xf9df, 0xffff, 0xe7ff,
62 0x19cf, 0xfffc, 0xe7ff, 0xd9cf,
63 0xffff, 0xe7ff, 0xd9ff, 0xce47,
64 0xe673, 0x19ff, 0xb5b6, 0xe7ad,
65 0xd9cf, 0xb5b7, 0xe67d, 0xd9c7,
66 0xb5b7, 0xe5ed, 0x19ef, 0x4db4,
67 0xe673, 0xf1ff, 0xffff, 0xe3ff,
68 0x03ff, 0x0380, 0xf000, 0x07ef,
69 0x0100, 0xf800, 0xffc7, 0xf93f,
70 0xffff, 0xffe7, 0xfd7f, 0xffe0,
71 0xffff, 0x7d7f, 0xffdf, 0xffff,
72 0xbd7f, 0xffb1, 0xffff, 0xbb7f,
73 0xffae, 0xffef, 0xdaff, 0xffae,
74 0xffc7, 0x66ff, 0xffaf, 0xffe7,
75 0xbdff, 0xffaf, 0xffff, 0xc3ff,
76 0xffaf, 0xffff, 0xffff, 0xffaf};
77short sink_mask_bits[] = {
78 0xffff, 0xffff, 0xffff, 0xffff,
79 0xffff, 0xffff, 0xffff, 0xffff,
80 0xffff, 0xffff, 0xffff, 0xffff,
81 0xffff, 0xffff, 0xffff, 0xffff,
82 0xffff, 0xffff, 0xffff, 0xffff,
83 0xffff, 0xffff, 0xffff, 0xffff,
84 0xffff, 0xffff, 0xffff, 0xffff,
85 0xffff, 0xffff, 0xffff, 0xffff,
86 0xffff, 0xffff, 0xffff, 0xffff,
87 0xffff, 0xffff, 0xffff, 0xffff,
88 0xffff, 0xffff, 0xffff, 0xffff,
89 0xffff, 0xffff, 0xffff, 0xffff,
90 0xffff, 0xffff, 0xffff, 0xffff,
91 0xffff, 0xffff, 0xffff, 0xffff,
92 0xffff, 0xffff, 0xffff, 0xffff,
93 0xffff, 0xffff, 0xffff, 0xffff,
94 0xffff, 0xffff, 0xffff, 0xffff,
95 0xffff, 0xffff, 0xffff, 0xffff,
96 0xffff, 0xffff, 0xffff, 0xffff,
97 0xffff, 0xffff, 0xffff, 0xffff,
98 0xffff, 0xffff, 0xffff, 0xffff,
99 0xffff, 0xffff, 0xffff, 0xffff,
100 0xffff, 0xffff, 0xffff, 0xffff,
101 0xffff, 0xffff, 0xffff, 0xffff,
102 0xffff, 0xffff, 0xffff, 0xffff,
103 0xffff, 0xffff, 0xffff, 0xffff,
104 0xffff, 0xffff, 0xffff, 0xffff,
105 0xffff, 0xffff, 0xffff, 0xffff,
106 0xffff, 0xffff, 0xffff, 0xffff,
107 0xffff, 0xffff, 0xffff, 0xffff,
108 0xffff, 0xffff, 0xffff, 0xffff,
109 0xffff, 0xffff, 0xffff, 0xffff,
110 0xffff, 0xffff, 0xffff, 0xffff,
111 0xffff, 0xffff, 0xffff, 0xffff,
112 0xffff, 0xffff, 0xffff, 0xffff,
113 0xffff, 0xffff, 0xffff, 0xffff};
114#endif /* X10 */
diff --git a/src/mem-limits.h b/src/mem-limits.h
new file mode 100644
index 00000000000..39200f99501
--- /dev/null
+++ b/src/mem-limits.h
@@ -0,0 +1,102 @@
1/* Includes for memory limit warnings.
2 Copyright (C) 1990 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20#ifndef BSD4_2
21#ifndef USG
22#include <sys/vlimit.h>
23#endif /* not USG */
24#else /* if BSD4_2 */
25#include <sys/time.h>
26#include <sys/resource.h>
27#endif /* BSD4_2 */
28
29#ifdef __STDC__
30typedef void *POINTER;
31#else
32typedef char *POINTER;
33#endif
34
35typedef unsigned long SIZE;
36
37#ifdef NULL
38#undef NULL
39#endif
40#define NULL ((POINTER) 0)
41
42#ifdef emacs
43extern POINTER start_of_data ();
44
45#ifdef BSD
46#ifndef DATA_SEG_BITS
47#define start_of_data() &etext
48#endif
49#endif
50
51#else /* Not emacs */
52#define start_of_data() &etext
53#endif /* Not emacs */
54
55
56
57/* start of data space; can be changed by calling malloc_init */
58static POINTER data_space_start;
59
60/* Number of bytes of writable memory we can expect to be able to get */
61static unsigned int lim_data;
62
63
64
65#ifdef USG
66
67get_lim_data ()
68{
69 extern long ulimit ();
70
71#ifdef ULIMIT_BREAK_VALUE
72 lim_data = ULIMIT_BREAK_VALUE;
73#else
74 lim_data = ulimit (3, 0);
75#endif
76
77 lim_data -= (long) data_space_start;
78}
79
80#else /* not USG */
81#ifndef BSD4_2
82
83get_lim_data ()
84{
85 lim_data = vlimit (LIM_DATA, -1);
86}
87
88#else /* BSD4_2 */
89
90get_lim_data ()
91{
92 struct rlimit XXrlimit;
93
94 getrlimit (RLIMIT_DATA, &XXrlimit);
95#ifdef RLIM_INFINITY
96 lim_data = XXrlimit.rlim_cur & RLIM_INFINITY; /* soft limit */
97#else
98 lim_data = XXrlimit.rlim_cur; /* soft limit */
99#endif
100}
101#endif /* BSD4_2 */
102#endif /* not USG */
diff --git a/src/sinkmask.h b/src/sinkmask.h
new file mode 100644
index 00000000000..1ad645df82f
--- /dev/null
+++ b/src/sinkmask.h
@@ -0,0 +1,91 @@
1#define sink_mask_width 48
2#define sink_mask_height 48
3#ifdef HAVE_X11
4static char sink_mask_bits[] = {
5 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
6 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
7 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
8 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
9 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
10 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
11 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
12 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
13 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
14 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
15 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
16 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
17 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
18 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
19 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
20 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
21 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
22 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
23 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
24 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
25 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
26 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
27 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
28 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
29 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
30 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
31 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
32 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
33 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
34 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
35 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
36 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
37 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
38 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
39 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
40 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
41 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
42 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
43 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
44 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
45 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
46 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
47 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
48 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
49 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
50 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
51 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
52 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
53#else
54short sink_mask_bits[] = {
55 0xffff, 0xffff, 0xffff, 0xffff,
56 0xffff, 0xffff, 0xffff, 0xffff,
57 0xffff, 0xffff, 0xffff, 0xffff,
58 0xffff, 0xffff, 0xffff, 0xffff,
59 0xffff, 0xffff, 0xffff, 0xffff,
60 0xffff, 0xffff, 0xffff, 0xffff,
61 0xffff, 0xffff, 0xffff, 0xffff,
62 0xffff, 0xffff, 0xffff, 0xffff,
63 0xffff, 0xffff, 0xffff, 0xffff,
64 0xffff, 0xffff, 0xffff, 0xffff,
65 0xffff, 0xffff, 0xffff, 0xffff,
66 0xffff, 0xffff, 0xffff, 0xffff,
67 0xffff, 0xffff, 0xffff, 0xffff,
68 0xffff, 0xffff, 0xffff, 0xffff,
69 0xffff, 0xffff, 0xffff, 0xffff,
70 0xffff, 0xffff, 0xffff, 0xffff,
71 0xffff, 0xffff, 0xffff, 0xffff,
72 0xffff, 0xffff, 0xffff, 0xffff,
73 0xffff, 0xffff, 0xffff, 0xffff,
74 0xffff, 0xffff, 0xffff, 0xffff,
75 0xffff, 0xffff, 0xffff, 0xffff,
76 0xffff, 0xffff, 0xffff, 0xffff,
77 0xffff, 0xffff, 0xffff, 0xffff,
78 0xffff, 0xffff, 0xffff, 0xffff,
79 0xffff, 0xffff, 0xffff, 0xffff,
80 0xffff, 0xffff, 0xffff, 0xffff,
81 0xffff, 0xffff, 0xffff, 0xffff,
82 0xffff, 0xffff, 0xffff, 0xffff,
83 0xffff, 0xffff, 0xffff, 0xffff,
84 0xffff, 0xffff, 0xffff, 0xffff,
85 0xffff, 0xffff, 0xffff, 0xffff,
86 0xffff, 0xffff, 0xffff, 0xffff,
87 0xffff, 0xffff, 0xffff, 0xffff,
88 0xffff, 0xffff, 0xffff, 0xffff,
89 0xffff, 0xffff, 0xffff, 0xffff,
90 0xffff, 0xffff, 0xffff, 0xffff};
91#endif /* HAVE_X11 */
diff --git a/src/syntax.h b/src/syntax.h
new file mode 100644
index 00000000000..6bd9757c3a8
--- /dev/null
+++ b/src/syntax.h
@@ -0,0 +1,92 @@
1/* Declarations having to do with GNU Emacs syntax tables.
2 Copyright (C) 1985 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21extern Lisp_Object Qsyntax_table_p;
22extern Lisp_Object Fsyntax_table_p (), Fsyntax_table (), Fset_syntax_table ();
23
24/* The standard syntax table is stored where it will automatically
25 be used in all new buffers. */
26#define Vstandard_syntax_table buffer_defaults.syntax_table
27
28/* A syntax table is a Lisp vector of length 0400, whose elements are integers.
29
30The low 8 bits of the integer is a code, as follows:
31*/
32
33enum syntaxcode
34 {
35 Swhitespace, /* for a whitespace character */
36 Spunct, /* for random punctuation characters */
37 Sword, /* for a word constituent */
38 Ssymbol, /* symbol constituent but not word constituent */
39 Sopen, /* for a beginning delimiter */
40 Sclose, /* for an ending delimiter */
41 Squote, /* for a prefix character like Lisp ' */
42 Sstring, /* for a string-grouping character like Lisp " */
43 Smath, /* for delimiters like $ in Tex. */
44 Sescape, /* for a character that begins a C-style escape */
45 Scharquote, /* for a character that quotes the following character */
46 Scomment, /* for a comment-starting character */
47 Sendcomment, /* for a comment-ending character */
48 Smax /* Upper bound on codes that are meaningful */
49 };
50
51#define SYNTAX(c) \
52 ((enum syntaxcode) (XINT (XVECTOR (current_buffer->syntax_table)->contents[c]) & 0377))
53
54/* The next 8 bits of the number is a character,
55 the matching delimiter in the case of Sopen or Sclose. */
56
57#define SYNTAX_MATCH(c) \
58 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[c]) >> 8) & 0377)
59
60/* Then there are five single-bit flags that have the following meanings:
61 1. This character is the first of a two-character comment-start sequence.
62 2. This character is the second of a two-character comment-start sequence.
63 3. This character is the first of a two-character comment-end sequence.
64 4. This character is the second of a two-character comment-end sequence.
65 5. This character is a prefix, for backward-prefix-chars.
66 Note that any two-character sequence whose first character has flag 1
67 and whose second character has flag 2 will be interpreted as a comment start. */
68
69#define SYNTAX_COMSTART_FIRST(c) \
70 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[c]) >> 16) & 1)
71
72#define SYNTAX_COMSTART_SECOND(c) \
73 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[c]) >> 17) & 1)
74
75#define SYNTAX_COMEND_FIRST(c) \
76 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[c]) >> 18) & 1)
77
78#define SYNTAX_COMEND_SECOND(c) \
79 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[c]) >> 19) & 1)
80
81#define SYNTAX_PREFIX(c) \
82 ((XINT (XVECTOR (current_buffer->syntax_table)->contents[c]) >> 20) & 1)
83
84/* This array, indexed by a character, contains the syntax code which that
85 character signifies (as a char). For example,
86 (enum syntaxcode) syntax_spec_code['w'] is Sword. */
87
88extern unsigned char syntax_spec_code[0400];
89
90/* Indexed by syntax code, give the letter that describes it. */
91
92extern char syntax_code_spec[13];
diff --git a/src/termchar.h b/src/termchar.h
new file mode 100644
index 00000000000..d82ccb0bad9
--- /dev/null
+++ b/src/termchar.h
@@ -0,0 +1,45 @@
1/* Flags and parameters describing terminal's characteristics.
2 Copyright (C) 1985, 1986 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21extern int baud_rate; /* Output speed in baud */
22extern int screen_width; /* Number of usable columns */
23extern int screen_height; /* Number of lines */
24extern int must_write_spaces; /* Nonzero means spaces in the text
25 must actually be output; can't just skip
26 over some columns to leave them blank. */
27extern int min_padding_speed; /* Speed below which no padding necessary */
28extern int fast_clear_end_of_line; /* Nonzero means terminal has
29 command for this */
30
31extern int line_ins_del_ok; /* Terminal can insert and delete lines */
32extern int char_ins_del_ok; /* Terminal can insert and delete chars */
33extern int scroll_region_ok; /* Terminal supports setting the scroll
34 window */
35extern int memory_below_screen; /* Terminal remembers lines scrolled
36 off bottom */
37extern int fast_clear_end_of_line; /* Terminal has a `ce' string */
38
39extern int dont_calculate_costs; /* Nonzero means don't bother computing
40 various cost tables; we won't use them. */
41
42/* Nonzero means no need to redraw the entire screen on resuming
43 a suspended Emacs. This is useful on terminals with multiple pages,
44 where one page is used for Emacs and another for all else. */
45extern int no_redraw_on_reenter;
diff --git a/src/termopts.h b/src/termopts.h
new file mode 100644
index 00000000000..0b4c6234c4c
--- /dev/null
+++ b/src/termopts.h
@@ -0,0 +1,40 @@
1/* Flags and paramaters describing user options for handling the terminal.
2 Copyright (C) 1985, 1986, 1990 Free Software Foundation, Inc.
3
4This file is part of GNU Emacs.
5
6GNU Emacs is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GNU Emacs is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20
21/* Nonzero means flash the screen instead of ringing the bell. */
22extern int visible_bell;
23
24/* Nonzero means invert white and black for the entire screen. */
25extern int inverse_video;
26
27/* Nonzero means use ^S/^Q as cretinous flow control. */
28extern int flow_control;
29
30/* Nonzero means use interrupt-driven input. */
31extern int interrupt_input;
32
33/* Nonzero while interrupts are temporarily deferred during redisplay. */
34extern int interrupts_deferred;
35
36/* Terminal has meta key */
37extern int meta_key;
38
39/* Nonzero means truncate lines in all windows less wide than the screen */
40extern int truncate_partial_width_windows;
diff --git a/src/unexencap.c b/src/unexencap.c
new file mode 100644
index 00000000000..4ffc41145a9
--- /dev/null
+++ b/src/unexencap.c
@@ -0,0 +1,116 @@
1/* Waiting for papers! */
2
3/*
4 * Do an unexec() for coff encapsulation. Uses the approach I took
5 * for AKCL, so don't be surprised if it doesn't look too much like
6 * the other unexec() routines. Assumes NO_REMAP. Should be easy to
7 * adapt to the emacs style unexec() if that is desired, but this works
8 * just fine for me with GCC/GAS/GLD under System V. - Jordan
9 */
10
11#include <sys/types.h>
12#include <sys/fcntl.h>
13#include <sys/file.h>
14#include <stdio.h>
15#include "/usr/gnu/lib/gcc/gcc-include/a.out.h"
16
17filecpy(to, from, n)
18FILE *to, *from;
19register int n;
20{
21 char buffer[BUFSIZ];
22
23 for (;;)
24 if (n > BUFSIZ) {
25 fread(buffer, BUFSIZ, 1, from);
26 fwrite(buffer, BUFSIZ, 1, to);
27 n -= BUFSIZ;
28 } else if (n > 0) {
29 fread(buffer, 1, n, from);
30 fwrite(buffer, 1, n, to);
31 break;
32 } else
33 break;
34}
35/* ****************************************************************
36 * unexec
37 *
38 * driving logic.
39 * ****************************************************************/
40unexec (new_name, a_name, data_start, bss_start, entry_address)
41char *new_name, *a_name;
42unsigned data_start, bss_start, entry_address;
43{
44 struct coffheader header1;
45 struct coffscn *tp, *dp, *bp;
46 struct exec header;
47 int stsize;
48 char *original_file = a_name;
49 char *save_file = new_name;
50
51 char *data_begin, *data_end;
52 int original_data;
53 FILE *original, *save;
54 register int n;
55 register char *p;
56 extern char *sbrk();
57 char stdin_buf[BUFSIZ], stdout_buf[BUFSIZ];
58
59
60 fclose(stdin);
61 original = fopen(original_file, "r");
62 if (stdin != original || original->_file != 0) {
63 fprintf(stderr, "unexec: Can't open the original file.\n");
64 exit(1);
65 }
66 setbuf(original, stdin_buf);
67 fclose(stdout);
68 unlink(save_file);
69 n = open(save_file, O_CREAT|O_WRONLY, 0777);
70 if (n != 1 || (save = fdopen(n, "w")) != stdout) {
71 fprintf(stderr, "unexec: Can't open the save file.\n");
72 exit(1);
73 }
74 setbuf(save, stdout_buf);
75
76 fread(&header1, sizeof(header1), 1, original);
77 tp = &header1.scns[0];
78 dp = &header1.scns[1];
79 bp = &header1.scns[2];
80 fread(&header, sizeof(header), 1, original);
81 data_begin=(char *)N_DATADDR(header);
82 data_end = sbrk(0);
83 original_data = header.a_data;
84 header.a_data = data_end - data_begin;
85 header.a_bss = 0;
86 dp->s_size = header.a_data;
87 bp->s_paddr = dp->s_vaddr + dp->s_size;
88 bp->s_vaddr = bp->s_paddr;
89 bp->s_size = 0;
90 header1.tsize = tp->s_size;
91 header1.dsize = dp->s_size;
92 header1.bsize = bp->s_size;
93 fwrite(&header1, sizeof(header1), 1, save);
94 fwrite(&header, sizeof(header), 1, save);
95
96 filecpy(save, original, header.a_text);
97
98 for (n = header.a_data, p = data_begin; ; n -= BUFSIZ, p += BUFSIZ)
99 if (n > BUFSIZ)
100 fwrite(p, BUFSIZ, 1, save);
101 else if (n > 0) {
102 fwrite(p, 1, n, save);
103 break;
104 } else
105 break;
106
107 fseek(original, original_data, 1);
108
109 filecpy(save, original, header.a_syms+header.a_trsize+header.a_drsize);
110 fread(&stsize, sizeof(stsize), 1, original);
111 fwrite(&stsize, sizeof(stsize), 1, save);
112 filecpy(save, original, stsize - sizeof(stsize));
113
114 fclose(original);
115 fclose(save);
116}
diff --git a/src/unexmips.c b/src/unexmips.c
new file mode 100644
index 00000000000..8cfdd401b40
--- /dev/null
+++ b/src/unexmips.c
@@ -0,0 +1,305 @@
1/* Unexec for MIPS (including IRIS4D).
2 Note that the GNU project considers support for MIPS operation
3 a peripheral activity which should not be allowed to divert effort
4 from development of the GNU system. Changes in this code will be
5 installed when users send them in, but aside from that
6 we don't plan to think about it, or about whether other Emacs
7 maintenance might break it.
8
9 Copyright (C) 1988 Free Software Foundation, Inc.
10
11This file is part of GNU Emacs.
12
13GNU Emacs is free software; you can redistribute it and/or modify
14it under the terms of the GNU General Public License as published by
15the Free Software Foundation; either version 1, or (at your option)
16any later version.
17
18GNU Emacs is distributed in the hope that it will be useful,
19but WITHOUT ANY WARRANTY; without even the implied warranty of
20MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21GNU General Public License for more details.
22
23You should have received a copy of the GNU General Public License
24along with GNU Emacs; see the file COPYING. If not, write to
25the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
26
27
28#include "config.h"
29#include <sys/types.h>
30#include <sys/file.h>
31#include <sys/stat.h>
32#include <stdio.h>
33#include <varargs.h>
34#include <filehdr.h>
35#include <aouthdr.h>
36#include <scnhdr.h>
37#include <sym.h>
38
39#ifdef IRIS_4D
40#include "getpagesize.h"
41#endif
42
43static void fatal_unexec ();
44
45#define READ(_fd, _buffer, _size, _error_message, _error_arg) \
46 errno = EEOF; \
47 if (read (_fd, _buffer, _size) != _size) \
48 fatal_unexec (_error_message, _error_arg);
49
50#define WRITE(_fd, _buffer, _size, _error_message, _error_arg) \
51 if (write (_fd, _buffer, _size) != _size) \
52 fatal_unexec (_error_message, _error_arg);
53
54#define SEEK(_fd, _position, _error_message, _error_arg) \
55 errno = EEOF; \
56 if (lseek (_fd, _position, L_SET) != _position) \
57 fatal_unexec (_error_message, _error_arg);
58
59extern int errno;
60extern int sys_nerr;
61extern char *sys_errlist[];
62#define EEOF -1
63
64static struct scnhdr *text_section;
65static struct scnhdr *init_section;
66static struct scnhdr *finit_section;
67static struct scnhdr *rdata_section;
68static struct scnhdr *data_section;
69static struct scnhdr *lit8_section;
70static struct scnhdr *lit4_section;
71static struct scnhdr *sdata_section;
72static struct scnhdr *sbss_section;
73static struct scnhdr *bss_section;
74
75struct headers {
76 struct filehdr fhdr;
77 struct aouthdr aout;
78 struct scnhdr section[10];
79};
80
81/* Define name of label for entry point for the dumped executable. */
82
83#ifndef DEFAULT_ENTRY_ADDRESS
84#define DEFAULT_ENTRY_ADDRESS __start
85#endif
86
87unexec (new_name, a_name, data_start, bss_start, entry_address)
88 char *new_name, *a_name;
89 unsigned data_start, bss_start, entry_address;
90{
91 int new, old;
92 int pagesize, brk;
93 int newsyms, symrel;
94 int nread;
95 struct headers hdr;
96 int i;
97 int vaddr, scnptr;
98#define BUFSIZE 8192
99 char buffer[BUFSIZE];
100
101 old = open (a_name, O_RDONLY, 0);
102 if (old < 0) fatal_unexec ("opening %s", a_name);
103
104 new = creat (new_name, 0666);
105 if (new < 0) fatal_unexec ("creating %s", new_name);
106
107 hdr = *((struct headers *)TEXT_START);
108#ifdef MIPS2
109 if (hdr.fhdr.f_magic != MIPSELMAGIC
110 && hdr.fhdr.f_magic != MIPSEBMAGIC
111 && hdr.fhdr.f_magic != (MIPSELMAGIC | 1)
112 && hdr.fhdr.f_magic != (MIPSEBMAGIC | 1))
113 {
114 fprintf(stderr,
115 "unexec: input file magic number is %x, not %x, %x, %x or %x.\n",
116 hdr.fhdr.f_magic,
117 MIPSELMAGIC, MIPSEBMAGIC,
118 MIPSELMAGIC | 1, MIPSEBMAGIC | 1);
119 exit(1);
120 }
121#else /* not MIPS2 */
122 if (hdr.fhdr.f_magic != MIPSELMAGIC
123 && hdr.fhdr.f_magic != MIPSEBMAGIC)
124 {
125 fprintf (stderr, "unexec: input file magic number is %x, not %x or %x.\n",
126 hdr.fhdr.f_magic, MIPSELMAGIC, MIPSEBMAGIC);
127 exit (1);
128 }
129#endif /* not MIPS2 */
130 if (hdr.fhdr.f_opthdr != sizeof (hdr.aout))
131 {
132 fprintf (stderr, "unexec: input a.out header is %d bytes, not %d.\n",
133 hdr.fhdr.f_opthdr, sizeof (hdr.aout));
134 exit (1);
135 }
136 if (hdr.aout.magic != ZMAGIC)
137 {
138 fprintf (stderr, "unexec: input file a.out magic number is %o, not %o.\n",
139 hdr.aout.magic, ZMAGIC);
140 exit (1);
141 }
142
143#define CHECK_SCNHDR(ptr, name, flags) \
144 if (strcmp (hdr.section[i].s_name, name) == 0) \
145 { \
146 if (hdr.section[i].s_flags != flags) \
147 fprintf (stderr, "unexec: %x flags (%x expected) in %s section.\n", \
148 hdr.section[i].s_flags, flags, name); \
149 ptr = hdr.section + i; \
150 i += 1; \
151 } \
152 else \
153 ptr = NULL;
154
155 i = 0;
156 CHECK_SCNHDR (text_section, _TEXT, STYP_TEXT);
157 CHECK_SCNHDR (init_section, _INIT, STYP_INIT);
158 CHECK_SCNHDR (rdata_section, _RDATA, STYP_RDATA);
159 CHECK_SCNHDR (data_section, _DATA, STYP_DATA);
160#ifdef _LIT8
161 CHECK_SCNHDR (lit8_section, _LIT8, STYP_LIT8);
162 CHECK_SCNHDR (lit4_section, _LIT4, STYP_LIT4);
163#endif /* _LIT8 */
164 CHECK_SCNHDR (sdata_section, _SDATA, STYP_SDATA);
165 CHECK_SCNHDR (sbss_section, _SBSS, STYP_SBSS);
166 CHECK_SCNHDR (bss_section, _BSS, STYP_BSS);
167 if (i != hdr.fhdr.f_nscns)
168 fprintf (stderr, "unexec: %d sections found instead of %d.\n",
169 i, hdr.fhdr.f_nscns);
170
171 pagesize = getpagesize ();
172 brk = (sbrk (0) + pagesize - 1) & (-pagesize);
173 hdr.aout.dsize = brk - DATA_START;
174 hdr.aout.bsize = 0;
175 if (entry_address == 0)
176 {
177 extern DEFAULT_ENTRY_ADDRESS ();
178 hdr.aout.entry = (unsigned)DEFAULT_ENTRY_ADDRESS;
179 }
180 else
181 hdr.aout.entry = entry_address;
182
183 hdr.aout.bss_start = hdr.aout.data_start + hdr.aout.dsize;
184 rdata_section->s_size = data_start - DATA_START;
185 data_section->s_vaddr = data_start;
186 data_section->s_paddr = data_start;
187 data_section->s_size = brk - DATA_START;
188 data_section->s_scnptr = rdata_section->s_scnptr + rdata_section->s_size;
189 vaddr = data_section->s_vaddr + data_section->s_size;
190 scnptr = data_section->s_scnptr + data_section->s_size;
191 if (lit8_section != NULL)
192 {
193 lit8_section->s_vaddr = vaddr;
194 lit8_section->s_paddr = vaddr;
195 lit8_section->s_size = 0;
196 lit8_section->s_scnptr = scnptr;
197 }
198 if (lit4_section != NULL)
199 {
200 lit4_section->s_vaddr = vaddr;
201 lit4_section->s_paddr = vaddr;
202 lit4_section->s_size = 0;
203 lit4_section->s_scnptr = scnptr;
204 }
205 if (sdata_section != NULL)
206 {
207 sdata_section->s_vaddr = vaddr;
208 sdata_section->s_paddr = vaddr;
209 sdata_section->s_size = 0;
210 sdata_section->s_scnptr = scnptr;
211 }
212 if (sbss_section != NULL)
213 {
214 sbss_section->s_vaddr = vaddr;
215 sbss_section->s_paddr = vaddr;
216 sbss_section->s_size = 0;
217 sbss_section->s_scnptr = scnptr;
218 }
219 if (bss_section != NULL)
220 {
221 bss_section->s_vaddr = vaddr;
222 bss_section->s_paddr = vaddr;
223 bss_section->s_size = 0;
224 bss_section->s_scnptr = scnptr;
225 }
226
227 WRITE (new, TEXT_START, hdr.aout.tsize,
228 "writing text section to %s", new_name);
229 WRITE (new, DATA_START, hdr.aout.dsize,
230 "writing text section to %s", new_name);
231
232 SEEK (old, hdr.fhdr.f_symptr, "seeking to start of symbols in %s", a_name);
233 errno = EEOF;
234 nread = read (old, buffer, BUFSIZE);
235 if (nread < sizeof (HDRR)) fatal_unexec ("reading symbols from %s", a_name);
236#define symhdr ((pHDRR)buffer)
237 newsyms = hdr.aout.tsize + hdr.aout.dsize;
238 symrel = newsyms - hdr.fhdr.f_symptr;
239 hdr.fhdr.f_symptr = newsyms;
240 symhdr->cbLineOffset += symrel;
241 symhdr->cbDnOffset += symrel;
242 symhdr->cbPdOffset += symrel;
243 symhdr->cbSymOffset += symrel;
244 symhdr->cbOptOffset += symrel;
245 symhdr->cbAuxOffset += symrel;
246 symhdr->cbSsOffset += symrel;
247 symhdr->cbSsExtOffset += symrel;
248 symhdr->cbFdOffset += symrel;
249 symhdr->cbRfdOffset += symrel;
250 symhdr->cbExtOffset += symrel;
251#undef symhdr
252 do
253 {
254 if (write (new, buffer, nread) != nread)
255 fatal_unexec ("writing symbols to %s", new_name);
256 nread = read (old, buffer, BUFSIZE);
257 if (nread < 0) fatal_unexec ("reading symbols from %s", a_name);
258#undef BUFSIZE
259 } while (nread != 0);
260
261 SEEK (new, 0, "seeking to start of header in %s", new_name);
262 WRITE (new, &hdr, sizeof (hdr),
263 "writing header of %s", new_name);
264
265 close (old);
266 close (new);
267 mark_x (new_name);
268}
269
270/*
271 * mark_x
272 *
273 * After succesfully building the new a.out, mark it executable
274 */
275
276static
277mark_x (name)
278 char *name;
279{
280 struct stat sbuf;
281 int um = umask (777);
282 umask (um);
283 if (stat (name, &sbuf) < 0)
284 fatal_unexec ("getting protection on %s", name);
285 sbuf.st_mode |= 0111 & ~um;
286 if (chmod (name, sbuf.st_mode) < 0)
287 fatal_unexec ("setting protection on %s", name);
288}
289
290static void
291fatal_unexec (s, va_alist)
292 va_dcl
293{
294 va_list ap;
295 if (errno == EEOF)
296 fputs ("unexec: unexpected end of file, ", stderr);
297 else if (errno < sys_nerr)
298 fprintf (stderr, "unexec: %s, ", sys_errlist[errno]);
299 else
300 fprintf (stderr, "unexec: error code %d, ", errno);
301 va_start (ap);
302 _doprnt (s, ap, stderr);
303 fputs (".\n", stderr);
304 exit (1);
305}
diff --git a/src/unexsunos4.c b/src/unexsunos4.c
new file mode 100644
index 00000000000..e95618ecc8a
--- /dev/null
+++ b/src/unexsunos4.c
@@ -0,0 +1,288 @@
1/*
2 * Unexec for Berkeley a.out format + SUNOS shared libraries
3 * The unexeced executable contains the __DYNAMIC area from the
4 * original text file, and then the rest of data + bss + malloced area of
5 * the current process. (The __DYNAMIC area is at the top of the process
6 * data segment, we use "data_start" defined externally to mark the start
7 * of the "real" data segment.)
8 *
9 * For programs that want to remap some of the data segment read only
10 * a run_time_remap is provided. This attempts to remap largest area starting
11 * and ending on page boundaries between "data_start" and "bndry"
12 * For this it to figure out where the text file is located. A path search
13 * is attempted after trying argv[0] and if all fails we simply do not remap
14 *
15 * One feature of run_time_remap () is mandatory: reseting the break.
16 *
17 * Note that we can no longer map data into the text segment, as this causes
18 * the __DYNAMIC struct to become read only, breaking the runtime loader.
19 * Thus we no longer need to mess with a private crt0.c, the standard one
20 * will do just fine, since environ can live in the writable area between
21 * __DYNAMIC and data_start, just make sure that pre-crt0.o (the name
22 * is somewhat abused here) is loaded first!
23 *
24 * $Log: unexsunos4.c,v $
25 * Revision 1.3 90/02/15 04:27:40 root
26 * Now it actually works.
27 *
28 * Revision 1.2 90/02/15 02:02:01 root
29 * Many comments, fixes, works not only with emacs.
30 *
31 * Revision 1.1 90/01/29 19:43:46 root
32 * Initial revision
33 *
34 */
35#ifdef emacs
36#include "config.h"
37#endif
38
39#include <sys/param.h>
40#include <sys/mman.h>
41#include <sys/file.h>
42#include <sys/stat.h>
43#include <string.h>
44#include <stdio.h>
45#include <a.out.h>
46
47/*
48 * for programs other than emacs
49 * define data_start + initialized here, and make sure
50 * this object is loaded first!
51 * emacs will define these elsewhere, and load the object containing
52 * data_start (pre-crt0.o or firstfile.o?) first!
53 * The custom crt0.o *must not* be loaded!
54 */
55#ifndef emacs
56 static int data_start = 0;
57 static int initialized = 0;
58#else
59 extern int initialized;
60 extern unsigned data_start;
61 extern int pureptr;
62#endif
63
64extern char *getenv ();
65static unsigned Brk;
66static struct exec nhdr;
67static int rd_only_len;
68static long cookie;
69
70
71unexec (new_name, a_name, bndry, bss_start, entry)
72 char *new_name, *a_name;
73 unsigned bndry, bss_start, entry;
74{
75 char buf[PAGSIZ];
76 int fd, new;
77 char *old;
78 struct exec ohdr; /* Allocate on the stack, not needed in the next life */
79 struct stat stat;
80
81#ifdef emacs
82 fprintf (stderr, "Used %d bytes of Pure Storage\n", pureptr);
83#endif
84
85 if ((fd = open (a_name, O_RDONLY)) < 0)
86 {
87 fprintf (stderr, "%s: open: ", a_name);
88 perror (a_name);
89 exit (1);
90 }
91 if ((new = open (new_name, O_WRONLY | O_CREAT, 0666)) == -1)
92 {
93 fprintf (stderr, "%s: open: ", a_name);
94 perror (new_name);
95 exit (1);
96 }
97
98 if ((fstat (fd, &stat) == -1))
99 {
100 fprintf (stderr, "%s: ", a_name);
101 perror ("fstat");
102 exit (1);
103 }
104
105 old = (char *)mmap (0, stat.st_size, PROT_READ, MAP_SHARED, fd, 0);
106 if (old == (char *)-1)
107 {
108 fprintf (stderr, "%s: ", a_name);
109 perror ("mmap");
110 exit (1);
111 }
112 close (fd);
113
114 nhdr = ohdr = (*(struct exec *)old);
115
116
117 /*
118 * Remeber a magic cookie so we know we've got the right binary
119 * when remaping.
120 */
121 cookie = time (0);
122
123 Brk = sbrk (0); /* Save the break, it is reset to &_end (by ld.so?) */
124
125 /*
126 * Round up data start to a page boundary (Lose if not a 2 power!)
127 */
128 data_start = ((((int)&data_start) - 1) & ~(N_PAGSIZ (nhdr) - 1)) + N_PAGSIZ (nhdr);
129
130 /*
131 * Round down read only pages to a multiple of the page size
132 */
133 if (bndry)
134 rd_only_len = ((int)bndry & ~(N_PAGSIZ (nhdr) - 1)) - data_start;
135
136#ifndef emacs
137 /* Have to do this some time before dumping the data */
138 initialized = 1;
139#endif
140
141 /*
142 * Handle new data and bss sizes and optional new entry point.
143 * No one actually uses bss_start and entry, but tradition compels
144 * one to support them.
145 * Could complain if bss_start > Brk, but the caller is *supposed* to know
146 * what she is doing.
147 */
148 nhdr.a_data = (bss_start ? bss_start : Brk) - N_DATADDR (nhdr);
149 nhdr.a_bss = bss_start ? Brk - bss_start : 0;
150 if (entry)
151 nhdr.a_entry = entry;
152
153 /*
154 * Write out the text segment with new header
155 * Dynamic executables are ZMAGIC with N_TXTOFF==0 and the header
156 * part of the text segment, but no need to rely on this.
157 * So write the TEXT first, then go back replace the header.
158 * Doing it in the other order is less general!
159 */
160 lseek (new, N_TXTOFF (nhdr), L_SET);
161 write (new, old + N_TXTOFF (ohdr), N_TXTOFF (ohdr) + ohdr.a_text);
162 lseek (new, 0L, L_SET);
163 write (new, &nhdr, sizeof (nhdr));
164
165 /*
166 * Write out the head of the old data segment from the file not
167 * from core, this has the unresolved __DYNAMIC relocation data
168 * we need to reload
169 */
170 lseek (new, N_DATOFF (nhdr), L_SET);
171 write (new, old + N_DATOFF (ohdr), (int)&data_start - N_DATADDR (ohdr));
172
173 /*
174 * Copy the rest of the data from core
175 */
176 write (new, &data_start, N_BSSADDR (nhdr) - (int)&data_start);
177
178 /*
179 * Copy the symbol table and line numbers
180 */
181 lseek (new, N_TRELOFF (nhdr), L_SET);
182 write (new, old + N_TRELOFF (ohdr), stat.st_size - N_TRELOFF (ohdr));
183
184 fchmod (new, 0755);
185}
186
187void
188run_time_remap (progname)
189 char *progname;
190{
191 char aout[MAXPATHLEN];
192 register char *path, *p;
193
194 /* Just in case */
195 if (!initialized)
196 return;
197
198 /* Restore the break */
199 brk (Brk);
200
201 /* If nothing to remap: we are done! */
202 if (rd_only_len == 0)
203 return;
204
205 /*
206 * Attempt to find the executable
207 * First try argv[0], will almost always succeed as shells tend to give
208 * the full path from the hash list rather than using execvp ()
209 */
210 if (is_it (progname))
211 return;
212
213 /*
214 * If argv[0] is a full path and does not exist, not much sense in
215 * searching further
216 */
217 if (strchr (progname, '/'))
218 return;
219
220 /*
221 * Try to search for argv[0] on the PATH
222 */
223 path = getenv ("PATH");
224 if (path == NULL)
225 return;
226
227 while (*path)
228 {
229 /* copy through ':' or end */
230 for (p = aout; *p = *path; ++p, ++path)
231 if (*p == ':')
232 {
233 ++path; /* move past ':' */
234 break;
235 }
236 *p++ = '/';
237 strcpy (p, progname);
238 /*
239 * aout is a candidate full path name
240 */
241 if (is_it (aout))
242 return;
243 }
244}
245
246is_it (path)
247 char *path;
248{
249 int fd;
250 long paths_cookie;
251 struct exec hdr;
252
253 /*
254 * Open an executable and check for a valid header!
255 * Can't bcmp() the header with what we had, it may have been stripped!
256 * so we may save looking at non executables with the same name, mostly
257 * directories.
258 */
259 fd = open (path, O_RDONLY);
260 if (fd != -1)
261 {
262 if (read (fd, &hdr, sizeof (hdr)) == sizeof (hdr)
263 && !N_BADMAG (hdr) && N_DATOFF (hdr) == N_DATOFF (nhdr)
264 && N_TRELOFF (hdr) == N_TRELOFF (nhdr))
265 {
266 /* compare cookies */
267 lseek (fd, N_DATOFF (hdr) + (int)&cookie - N_DATADDR (hdr), L_SET);
268 read (fd, &paths_cookie, sizeof (paths_cookie));
269 if (paths_cookie == cookie)
270 { /* Eureka */
271
272 /*
273 * Do the mapping
274 * The PROT_EXEC may not be needed, but it is safer this way.
275 * should the shared library decide to indirect through
276 * addresses in the data segment not part of __DYNAMIC
277 */
278 mmap (data_start, rd_only_len, PROT_READ | PROT_EXEC,
279 MAP_SHARED | MAP_FIXED, fd,
280 N_DATOFF (hdr) + data_start - N_DATADDR (hdr));
281 close (fd);
282 return 1;
283 }
284 }
285 close (fd);
286 }
287 return 0;
288}
diff --git a/src/x11term.h b/src/x11term.h
new file mode 100644
index 00000000000..c6f24ba91eb
--- /dev/null
+++ b/src/x11term.h
@@ -0,0 +1,23 @@
1#include <X11/Xlib.h>
2#include <X11/Xatom.h>
3#include <X11/keysym.h>
4#include <X11/cursorfont.h>
5#include <X11/Xutil.h>
6#include <X11/X10.h>
7
8#define XMOUSEBUFSIZE 64
9
10#ifndef sigmask
11#define sigmask(no) (1L << ((no) - 1))
12#endif
13
14#define BLOCK_INPUT_DECLARE() int BLOCK_INPUT_mask
15#ifdef SIGIO
16#define BLOCK_INPUT() BLOCK_INPUT_mask = sigblock (sigmask (SIGIO))
17#define UNBLOCK_INPUT() sigsetmask (BLOCK_INPUT_mask)
18#else /* not SIGIO */
19#define BLOCK_INPUT()
20#define UNBLOCK_INPUT()
21#endif /* SIGIO */
22
23#define CLASS "emacs" /* class id for GNU Emacs, used in .Xdefaults, etc. */