aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2014-04-16 16:27:28 +0300
committerEli Zaretskii2014-04-16 16:27:28 +0300
commitbf6b4923f7eedea193dee2130bf7fa597a5932d4 (patch)
tree62bd144e45df20c0fc1600eedb3f744dcfe959a2 /src
parent3a31cae4677c7c5e501dcf7e5c520e49db16f75e (diff)
downloademacs-bf6b4923f7eedea193dee2130bf7fa597a5932d4.tar.gz
emacs-bf6b4923f7eedea193dee2130bf7fa597a5932d4.zip
Fix the MSDOS build.
src/unexcoff.c [MSDOS]: Include libc/atexit.h. (copy_text_and_data): Zero out the atexit chain pointer before dumping Emacs. src/termhooks.h (encode_terminal_code): Update prototype. src/term.c (encode_terminal_code) [DOS_NT]: Make it externally visible for all DOS_NT ports, not just WINDOWSNT. (syms_of_term) [!MSDOS]: Don't define 'tty-menu-*' symbols on MSDOS. src/sysdep.c (emacs_sigaction_init, init_signals): Don't use SIGCHLD unless it is defined. (emacs_pipe) [MSDOS]: Redirect to 'pipe'. src/process.c (close_on_exec, accept4, process_socket): Move into the "ifdef subprocesses" part. (catch_child_signal): Condition by "ifdef subprocesses". (syms_of_process) <Qinternal_default_process_sentinel> <Qinternal_default_process_filter>: Condition by "ifdef subprocesses". src/msdos.h: Add prototypes for new functions. (EINPROGRESS): Define. (O_CLOEXEC): Define to zero. src/msdos.c (check_window_system): Remove unnecessary an incompatible duplicate function. (sys_opendir, readlinkat, faccessat, fstatat, unsetenv): New functions in support of new functionality. src/menu.c (single_menu_item): Add visual indication of submenu also for menus on MSDOS frames. (Fx_popup_menu) [!MSDOS]: Do not call tty_menu_show on MSDOS. src/lisp.h (CHECK_PROCESS) [!subprocesses]: Do not define when async subprocesses aren't supported. src/font.h (FONT_WIDTH) [MSDOS]: MSDOS-specific definition. src/emacs.c (close_output_streams): Zero out errno before calling close_stream. src/dired.c [MSDOS]: Include msdos.h. src/conf_post.h (opendir) [MSDOS]: Redirect to sys_opendir. (DATA_START) [MSDOS]: Define. (SYSTEM_PURESIZE_EXTRA) [MSDOS]: Enlarge by 25K. src/callproc.c (block_child_signal, unblock_child_signal) [MSDOS]: Ifdef away for MSDOS. (record_kill_process) [MSDOS]: Ifdef away the entire body for MSDOS. (call_process_cleanup) [MSDOS]: Ifdef away portions not relevant for MSDOS. (call_process) [MSDOS]: Fix call sequence of dostounix_filename. Use temporary file template that is compatible with mkostemp. Move vfork-related portions under #ifndef MSDOS. (syms_of_callproc): Unify templates of MSDOS and WINDOWSNT. lisp/term/pc-win.el (x-list-fonts, x-get-selection-value): Provide doc strings, as required by snarf-documentation. msdos/sedlisp.inp: msdos/sedlibmk.inp: msdos/sedleim.inp: msdos/sed3v2.inp: msdos/sed2v2.inp: msdos/sed1v2.inp: Update Sed scripts for Emacs 24.4. msdos/inttypes.h: Add PRIdMAX. msdos/INSTALL: Update for Emacs 24.4. msdos/sedadmin.inp: New file.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog59
-rw-r--r--src/callproc.c20
-rw-r--r--src/conf_post.h10
-rw-r--r--src/dired.c4
-rw-r--r--src/emacs.c7
-rw-r--r--src/font.h4
-rw-r--r--src/lisp.h3
-rw-r--r--src/menu.c5
-rw-r--r--src/msdos.c127
-rw-r--r--src/msdos.h17
-rw-r--r--src/process.c50
-rw-r--r--src/sysdep.c8
-rw-r--r--src/term.c4
-rw-r--r--src/termhooks.h2
-rw-r--r--src/unexcoff.c13
15 files changed, 283 insertions, 50 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 51861c6ca7d..1899edae349 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,62 @@
12014-04-16 Eli Zaretskii <eliz@gnu.org>
2
3 * unexcoff.c [MSDOS]: Include libc/atexit.h.
4 (copy_text_and_data): Zero out the atexit chain pointer before
5 dumping Emacs.
6
7 * termhooks.h (encode_terminal_code): Update prototype.
8
9 * term.c (encode_terminal_code) [DOS_NT]: Make it externally
10 visible for all DOS_NT ports, not just WINDOWSNT.
11 (syms_of_term) [!MSDOS]: Don't define 'tty-menu-*' symbols on MSDOS.
12
13 * sysdep.c (emacs_sigaction_init, init_signals): Don't use SIGCHLD
14 unless it is defined.
15 (emacs_pipe) [MSDOS]: Redirect to 'pipe'.
16
17 * process.c (close_on_exec, accept4, process_socket): Move into
18 the "ifdef subprocesses" part.
19 (catch_child_signal): Condition by "ifdef subprocesses".
20 (syms_of_process) <Qinternal_default_process_sentinel>
21 <Qinternal_default_process_filter>: Condition by "ifdef subprocesses".
22
23 * msdos.h: Add prototypes for new functions.
24 (EINPROGRESS): Define.
25 (O_CLOEXEC): Define to zero.
26
27 * msdos.c (check_window_system): Remove unnecessary an
28 incompatible duplicate function.
29 (sys_opendir, readlinkat, faccessat, fstatat, unsetenv): New
30 functions in support of new functionality.
31
32 * menu.c (single_menu_item): Add visual indication of submenu
33 also for menus on MSDOS frames.
34 (Fx_popup_menu) [!MSDOS]: Do not call tty_menu_show on MSDOS.
35
36 * lisp.h (CHECK_PROCESS) [!subprocesses]: Do not define
37 when async subprocesses aren't supported.
38
39 * font.h (FONT_WIDTH) [MSDOS]: MSDOS-specific definition.
40
41 * emacs.c (close_output_streams): Zero out errno before calling
42 close_stream.
43
44 * dired.c [MSDOS]: Include msdos.h.
45
46 * conf_post.h (opendir) [MSDOS]: Redirect to sys_opendir.
47 (DATA_START) [MSDOS]: Define.
48 (SYSTEM_PURESIZE_EXTRA) [MSDOS]: Enlarge by 25K.
49
50 * callproc.c (block_child_signal, unblock_child_signal) [MSDOS]:
51 Ifdef away for MSDOS.
52 (record_kill_process) [MSDOS]: Ifdef away the entire body for MSDOS.
53 (call_process_cleanup) [MSDOS]: Ifdef away portions not relevant
54 for MSDOS.
55 (call_process) [MSDOS]: Fix call sequence of dostounix_filename.
56 Use temporary file template that is compatible with mkostemp.
57 Move vfork-related portions under #ifndef MSDOS.
58 (syms_of_callproc): Unify templates of MSDOS and WINDOWSNT.
59
12014-04-15 Stefan Monnier <monnier@iro.umontreal.ca> 602014-04-15 Stefan Monnier <monnier@iro.umontreal.ca>
2 61
3 * buffer.c (Foverlays_at): Add argument `sorted'. 62 * buffer.c (Foverlays_at): Add argument `sorted'.
diff --git a/src/callproc.c b/src/callproc.c
index 2ce4a7dcc0d..9e60ba11bcf 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -105,6 +105,8 @@ enum
105 105
106static Lisp_Object call_process (ptrdiff_t, Lisp_Object *, int, ptrdiff_t); 106static Lisp_Object call_process (ptrdiff_t, Lisp_Object *, int, ptrdiff_t);
107 107
108
109#ifndef MSDOS
108/* Block SIGCHLD. */ 110/* Block SIGCHLD. */
109 111
110void 112void
@@ -124,6 +126,8 @@ unblock_child_signal (void)
124 pthread_sigmask (SIG_SETMASK, &empty_mask, 0); 126 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
125} 127}
126 128
129#endif /* !MSDOS */
130
127/* Return the current buffer's working directory, or the home 131/* Return the current buffer's working directory, or the home
128 directory if it's unreachable, as a string suitable for a system call. 132 directory if it's unreachable, as a string suitable for a system call.
129 Signal an error if the result would not be an accessible directory. */ 133 Signal an error if the result would not be an accessible directory. */
@@ -162,6 +166,7 @@ encode_current_directory (void)
162void 166void
163record_kill_process (struct Lisp_Process *p, Lisp_Object tempfile) 167record_kill_process (struct Lisp_Process *p, Lisp_Object tempfile)
164{ 168{
169#ifndef MSDOS
165 block_child_signal (); 170 block_child_signal ();
166 171
167 if (p->alive) 172 if (p->alive)
@@ -172,6 +177,7 @@ record_kill_process (struct Lisp_Process *p, Lisp_Object tempfile)
172 } 177 }
173 178
174 unblock_child_signal (); 179 unblock_child_signal ();
180#endif /* !MSDOS */
175} 181}
176 182
177/* Clean up files, file descriptors and processes created by Fcall_process. */ 183/* Clean up files, file descriptors and processes created by Fcall_process. */
@@ -211,6 +217,7 @@ call_process_cleanup (Lisp_Object buffer)
211{ 217{
212 Fset_buffer (buffer); 218 Fset_buffer (buffer);
213 219
220#ifndef MSDOS
214 if (synch_process_pid) 221 if (synch_process_pid)
215 { 222 {
216 kill (-synch_process_pid, SIGINT); 223 kill (-synch_process_pid, SIGINT);
@@ -222,6 +229,7 @@ call_process_cleanup (Lisp_Object buffer)
222 immediate_quit = 0; 229 immediate_quit = 0;
223 message1 ("Waiting for process to die...done"); 230 message1 ("Waiting for process to die...done");
224 } 231 }
232#endif /* !MSDOS */
225} 233}
226 234
227#ifdef DOS_NT 235#ifdef DOS_NT
@@ -518,10 +526,10 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
518 char const *outf = tmpdir ? tmpdir : ""; 526 char const *outf = tmpdir ? tmpdir : "";
519 tempfile = alloca (strlen (outf) + 20); 527 tempfile = alloca (strlen (outf) + 20);
520 strcpy (tempfile, outf); 528 strcpy (tempfile, outf);
521 dostounix_filename (tempfile, 0); 529 dostounix_filename (tempfile);
522 if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/') 530 if (*tempfile == '\0' || tempfile[strlen (tempfile) - 1] != '/')
523 strcat (tempfile, "/"); 531 strcat (tempfile, "/");
524 strcat (tempfile, "detmp.XXX"); 532 strcat (tempfile, "emXXXXXX");
525 mktemp (tempfile); 533 mktemp (tempfile);
526 if (!*tempfile) 534 if (!*tempfile)
527 report_file_error ("Opening process output file", Qnil); 535 report_file_error ("Opening process output file", Qnil);
@@ -710,8 +718,6 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
710 unblock_child_signal (); 718 unblock_child_signal ();
711 unblock_input (); 719 unblock_input ();
712 720
713#endif /* not MSDOS */
714
715 if (pid < 0) 721 if (pid < 0)
716 report_file_errno ("Doing vfork", Qnil, child_errno); 722 report_file_errno ("Doing vfork", Qnil, child_errno);
717 723
@@ -726,6 +732,8 @@ call_process (ptrdiff_t nargs, Lisp_Object *args, int filefd,
726 emacs_close (filefd); 732 emacs_close (filefd);
727 clear_unwind_protect (count - 1); 733 clear_unwind_protect (count - 1);
728 734
735#endif /* not MSDOS */
736
729 if (INTEGERP (buffer)) 737 if (INTEGERP (buffer))
730 return unbind_to (count, Qnil); 738 return unbind_to (count, Qnil);
731 739
@@ -1672,10 +1680,8 @@ syms_of_callproc (void)
1672{ 1680{
1673#ifndef DOS_NT 1681#ifndef DOS_NT
1674 Vtemp_file_name_pattern = build_string ("emacsXXXXXX"); 1682 Vtemp_file_name_pattern = build_string ("emacsXXXXXX");
1675#elif defined (WINDOWSNT) 1683#else /* DOS_NT */
1676 Vtemp_file_name_pattern = build_string ("emXXXXXX"); 1684 Vtemp_file_name_pattern = build_string ("emXXXXXX");
1677#else
1678 Vtemp_file_name_pattern = build_string ("detmp.XXX");
1679#endif 1685#endif
1680 staticpro (&Vtemp_file_name_pattern); 1686 staticpro (&Vtemp_file_name_pattern);
1681 1687
diff --git a/src/conf_post.h b/src/conf_post.h
index bb3be1bb1ea..8fabd60871b 100644
--- a/src/conf_post.h
+++ b/src/conf_post.h
@@ -121,6 +121,11 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
121#else 121#else
122# define lstat stat 122# define lstat stat
123#endif 123#endif
124
125/* We must intercept 'opendir' calls to stash away the directory name,
126 so we could reuse it in realinkat, see msdos.c. */
127#define opendir sys_opendir
128
124/* The "portable" definition of _GL_INLINE on config.h does not work 129/* The "portable" definition of _GL_INLINE on config.h does not work
125 with DJGPP GCC 3.4.4: it causes unresolved externals in sysdep.c, 130 with DJGPP GCC 3.4.4: it causes unresolved externals in sysdep.c,
126 although lib/execinfo.h is included and the inline functions there 131 although lib/execinfo.h is included and the inline functions there
@@ -132,6 +137,9 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
132 137
133#define emacs_raise(sig) msdos_fatal_signal (sig) 138#define emacs_raise(sig) msdos_fatal_signal (sig)
134 139
140/* DATA_START is needed by vm-limit.c and unexcoff.c. */
141#define DATA_START (&etext + 1)
142
135/* Define one of these for easier conditionals. */ 143/* Define one of these for easier conditionals. */
136#ifdef HAVE_X_WINDOWS 144#ifdef HAVE_X_WINDOWS
137/* We need a little extra space, see ../../lisp/loadup.el and the 145/* We need a little extra space, see ../../lisp/loadup.el and the
@@ -148,7 +156,7 @@ You lose; /* Emacs for DOS must be compiled with DJGPP */
148 directory tree). Given the unknown policy of different DPMI 156 directory tree). Given the unknown policy of different DPMI
149 hosts regarding loading of untouched pages, I'm not going to risk 157 hosts regarding loading of untouched pages, I'm not going to risk
150 enlarging Emacs footprint by another 100+ KBytes. */ 158 enlarging Emacs footprint by another 100+ KBytes. */
151#define SYSTEM_PURESIZE_EXTRA (-170000+65000) 159#define SYSTEM_PURESIZE_EXTRA (-170000+90000)
152#endif 160#endif
153#endif /* MSDOS */ 161#endif /* MSDOS */
154 162
diff --git a/src/dired.c b/src/dired.c
index 69d0ae0429c..55b2f6658c7 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -47,6 +47,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
47#include "regex.h" 47#include "regex.h"
48#include "blockinput.h" 48#include "blockinput.h"
49 49
50#ifdef MSDOS
51#include "msdos.h" /* for fstatat */
52#endif
53
50static Lisp_Object Qdirectory_files; 54static Lisp_Object Qdirectory_files;
51static Lisp_Object Qdirectory_files_and_attributes; 55static Lisp_Object Qdirectory_files_and_attributes;
52static Lisp_Object Qfile_name_completion; 56static Lisp_Object Qfile_name_completion;
diff --git a/src/emacs.c b/src/emacs.c
index fd93324de97..6a86dea9927 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -686,6 +686,11 @@ void (*__malloc_initialize_hook) (void) EXTERNALLY_VISIBLE = malloc_initialize_h
686static void 686static void
687close_output_streams (void) 687close_output_streams (void)
688{ 688{
689 int err = errno;
690
691 /* close_stream checks errno, so make sure it doesn't inherit some
692 random value. */
693 errno = 0;
689 if (close_stream (stdout) != 0) 694 if (close_stream (stdout) != 0)
690 { 695 {
691 emacs_perror ("Write error to standard output"); 696 emacs_perror ("Write error to standard output");
@@ -694,6 +699,8 @@ close_output_streams (void)
694 699
695 if (close_stream (stderr) != 0) 700 if (close_stream (stderr) != 0)
696 _exit (EXIT_FAILURE); 701 _exit (EXIT_FAILURE);
702
703 errno = err;
697} 704}
698 705
699/* ARGSUSED */ 706/* ARGSUSED */
diff --git a/src/font.h b/src/font.h
index 93d514fe665..e2e36460583 100644
--- a/src/font.h
+++ b/src/font.h
@@ -236,7 +236,11 @@ enum font_property_index
236#define FONT_SET_STYLE(font, prop, val) \ 236#define FONT_SET_STYLE(font, prop, val) \
237 ASET ((font), prop, make_number (font_style_to_value (prop, val, true))) 237 ASET ((font), prop, make_number (font_style_to_value (prop, val, true)))
238 238
239#ifndef MSDOS
239#define FONT_WIDTH(f) ((f)->max_width) 240#define FONT_WIDTH(f) ((f)->max_width)
241#else
242#define FONT_WIDTH(f) 1
243#endif
240#define FONT_HEIGHT(f) ((f)->height) 244#define FONT_HEIGHT(f) ((f)->height)
241#define FONT_BASE(f) ((f)->ascent) 245#define FONT_BASE(f) ((f)->ascent)
242#define FONT_DESCENT(f) ((f)->descent) 246#define FONT_DESCENT(f) ((f)->descent)
diff --git a/src/lisp.h b/src/lisp.h
index 6232c326c9a..edc442bb5ab 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2533,11 +2533,13 @@ CHECK_WINDOW (Lisp_Object x)
2533{ 2533{
2534 CHECK_TYPE (WINDOWP (x), Qwindowp, x); 2534 CHECK_TYPE (WINDOWP (x), Qwindowp, x);
2535} 2535}
2536#ifdef subprocesses
2536INLINE void 2537INLINE void
2537CHECK_PROCESS (Lisp_Object x) 2538CHECK_PROCESS (Lisp_Object x)
2538{ 2539{
2539 CHECK_TYPE (PROCESSP (x), Qprocessp, x); 2540 CHECK_TYPE (PROCESSP (x), Qprocessp, x);
2540} 2541}
2542#endif
2541INLINE void 2543INLINE void
2542CHECK_NATNUM (Lisp_Object x) 2544CHECK_NATNUM (Lisp_Object x)
2543{ 2545{
@@ -4142,7 +4144,6 @@ extern bool running_asynch_code;
4142 4144
4143/* Defined in process.c. */ 4145/* Defined in process.c. */
4144extern Lisp_Object QCtype, Qlocal; 4146extern Lisp_Object QCtype, Qlocal;
4145extern Lisp_Object Qprocessp;
4146extern void kill_buffer_processes (Lisp_Object); 4147extern void kill_buffer_processes (Lisp_Object);
4147extern bool wait_reading_process_output (intmax_t, int, int, bool, 4148extern bool wait_reading_process_output (intmax_t, int, int, bool,
4148 Lisp_Object, 4149 Lisp_Object,
diff --git a/src/menu.c b/src/menu.c
index 9c08ff17665..468f2814eb4 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -415,7 +415,8 @@ single_menu_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy, void *sk
415 item_string = concat2 (prefix, item_string); 415 item_string = concat2 (prefix, item_string);
416 } 416 }
417 417
418 if (FRAME_TERMCAP_P (XFRAME (Vmenu_updating_frame)) 418 if ((FRAME_TERMCAP_P (XFRAME (Vmenu_updating_frame))
419 || FRAME_MSDOS_P (XFRAME (Vmenu_updating_frame)))
419 && !NILP (map)) 420 && !NILP (map))
420 /* Indicate visually that this is a submenu. */ 421 /* Indicate visually that this is a submenu. */
421 item_string = concat2 (item_string, build_string (" >")); 422 item_string = concat2 (item_string, build_string (" >"));
@@ -1442,6 +1443,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
1442 keymaps, title, &error_name); 1443 keymaps, title, &error_name);
1443 else 1444 else
1444#endif 1445#endif
1446#ifndef MSDOS
1445 if (FRAME_TERMCAP_P (f)) 1447 if (FRAME_TERMCAP_P (f))
1446 { 1448 {
1447 ptrdiff_t count1 = SPECPDL_INDEX (); 1449 ptrdiff_t count1 = SPECPDL_INDEX ();
@@ -1453,6 +1455,7 @@ no quit occurs and `x-popup-menu' returns nil. */)
1453 kbd_menu_navigation, &error_name); 1455 kbd_menu_navigation, &error_name);
1454 unbind_to (count1, Qnil); 1456 unbind_to (count1, Qnil);
1455 } 1457 }
1458#endif
1456 1459
1457#ifdef HAVE_NS 1460#ifdef HAVE_NS
1458 unbind_to (specpdl_count, Qnil); 1461 unbind_to (specpdl_count, Qnil);
diff --git a/src/msdos.c b/src/msdos.c
index 1af66b391ad..010a0a3746c 100644
--- a/src/msdos.c
+++ b/src/msdos.c
@@ -50,6 +50,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
50#include <unistd.h> /* for chdir, dup, dup2, etc. */ 50#include <unistd.h> /* for chdir, dup, dup2, etc. */
51#include <dir.h> /* for getdisk */ 51#include <dir.h> /* for getdisk */
52#pragma pack(0) /* dir.h does a pack(4), which isn't GCC's default */ 52#pragma pack(0) /* dir.h does a pack(4), which isn't GCC's default */
53#undef opendir
54#include <dirent.h> /* for opendir */
53#include <fcntl.h> 55#include <fcntl.h>
54#include <io.h> /* for setmode */ 56#include <io.h> /* for setmode */
55#include <dpmi.h> /* for __dpmi_xxx stuff */ 57#include <dpmi.h> /* for __dpmi_xxx stuff */
@@ -1883,18 +1885,6 @@ dos_get_saved_screen (char **screen, int *rows, int *cols)
1883#endif 1885#endif
1884} 1886}
1885 1887
1886#ifndef HAVE_X_WINDOWS
1887
1888/* We are not X, but we can emulate it well enough for our needs... */
1889void
1890check_window_system (void)
1891{
1892 if (! FRAME_MSDOS_P (SELECTED_FRAME ()))
1893 error ("Not running under a window system");
1894}
1895
1896#endif
1897
1898 1888
1899/* ----------------------- Keyboard control ---------------------- 1889/* ----------------------- Keyboard control ----------------------
1900 * 1890 *
@@ -3875,6 +3865,9 @@ int setpgid (int pid, int pgid) { return 0; }
3875int setpriority (int x, int y, int z) { return 0; } 3865int setpriority (int x, int y, int z) { return 0; }
3876pid_t setsid (void) { return 0; } 3866pid_t setsid (void) { return 0; }
3877 3867
3868
3869/* Gnulib support and emulation. */
3870
3878#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 3871#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4
3879ssize_t 3872ssize_t
3880readlink (const char *name, char *dummy1, size_t dummy2) 3873readlink (const char *name, char *dummy1, size_t dummy2)
@@ -3886,6 +3879,38 @@ readlink (const char *name, char *dummy1, size_t dummy2)
3886} 3879}
3887#endif 3880#endif
3888 3881
3882/* dir_pathname is set by sys_opendir and used in readlinkat and in
3883 fstatat, when they get a special FD of zero, which means use the
3884 last directory opened by opendir. */
3885static char dir_pathname[MAXPATHLEN];
3886DIR *
3887sys_opendir (const char *dirname)
3888{
3889 _fixpath (dirname, dir_pathname);
3890 return opendir (dirname);
3891}
3892
3893ssize_t
3894readlinkat (int fd, char const *name, char *buffer, size_t buffer_size)
3895{
3896 /* Rely on a hack: an open directory is modeled as file descriptor 0,
3897 as in fstatat. FIXME: Add proper support for readlinkat. */
3898 char fullname[MAXPATHLEN];
3899
3900 if (fd != AT_FDCWD)
3901 {
3902 if (strlen (dir_pathname) + strlen (name) + 1 >= MAXPATHLEN)
3903 {
3904 errno = ENAMETOOLONG;
3905 return -1;
3906 }
3907 sprintf (fullname, "%s/%s", dir_pathname, name);
3908 name = fullname;
3909 }
3910
3911 return readlink (name, buffer, buffer_size);
3912}
3913
3889char * 3914char *
3890careadlinkat (int fd, char const *filename, 3915careadlinkat (int fd, char const *filename,
3891 char *buffer, size_t buffer_size, 3916 char *buffer, size_t buffer_size,
@@ -3913,6 +3938,82 @@ careadlinkat (int fd, char const *filename,
3913 return buffer; 3938 return buffer;
3914} 3939}
3915 3940
3941/* Emulate faccessat(2). */
3942int
3943faccessat (int dirfd, const char * path, int mode, int flags)
3944{
3945 /* We silently ignore FLAGS. */
3946 flags = flags;
3947
3948 if (dirfd != AT_FDCWD
3949 && !(IS_DIRECTORY_SEP (path[0])
3950 || IS_DEVICE_SEP (path[1])))
3951 {
3952 errno = EBADF;
3953 return -1;
3954 }
3955
3956 return access (path, mode);
3957}
3958
3959/* Emulate fstatat. */
3960int
3961fstatat (int fd, char const *name, struct stat *st, int flags)
3962{
3963 /* Rely on a hack: an open directory is modeled as file descriptor 0.
3964 This is good enough for the current usage in Emacs, but is fragile.
3965
3966 FIXME: Add proper support for fdopendir, fstatat, readlinkat.
3967 Gnulib does this and can serve as a model. */
3968 char fullname[MAXPATHLEN];
3969
3970 flags = flags;
3971
3972 if (fd != AT_FDCWD)
3973 {
3974 char lastc = dir_pathname[strlen (dir_pathname) - 1];
3975
3976 if (strlen (dir_pathname) + strlen (name) + IS_DIRECTORY_SEP (lastc)
3977 >= MAXPATHLEN)
3978 {
3979 errno = ENAMETOOLONG;
3980 return -1;
3981 }
3982
3983 sprintf (fullname, "%s%s%s",
3984 dir_pathname, IS_DIRECTORY_SEP (lastc) ? "" : "/", name);
3985 name = fullname;
3986 }
3987
3988#if __DJGPP__ > 2 || __DJGPP_MINOR__ > 3
3989 return (flags & AT_SYMLINK_NOFOLLOW) ? lstat (name, st) : stat (name, st);
3990#else
3991 return stat (name, st);
3992#endif
3993}
3994
3995#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4
3996/* Emulate the Posix unsetenv. DJGPP v2.04 has this in the library. */
3997int
3998unsetenv (const char *name)
3999{
4000 char *var;
4001 size_t name_len;
4002 int retval;
4003
4004 if (name == NULL || *name == '\0' || strchr (name, '=') != NULL)
4005 {
4006 errno = EINVAL;
4007 return -1;
4008 }
4009
4010 /* DJGPP's 'putenv' deletes the entry if it doesn't include '='. */
4011 putenv (name);
4012
4013 return 0;
4014}
4015#endif
4016
3916 4017
3917#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2 4018#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 2
3918 4019
@@ -4038,7 +4139,7 @@ dos_yield_time_slice (void)
4038/* We don't have to call timer_check here 4139/* We don't have to call timer_check here
4039 because wait_reading_process_output takes care of that. */ 4140 because wait_reading_process_output takes care of that. */
4040int 4141int
4041sys_select (int nfds, SELECT_TYPE *rfds, SELECT_TYPE *wfds, SELECT_TYPE *efds, 4142sys_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *efds,
4042 struct timespec *timeout, void *ignored) 4143 struct timespec *timeout, void *ignored)
4043{ 4144{
4044 int check_input; 4145 int check_input;
diff --git a/src/msdos.h b/src/msdos.h
index 5d5f5df091f..e863c7cea4e 100644
--- a/src/msdos.h
+++ b/src/msdos.h
@@ -41,9 +41,25 @@ void mouse_on (void);
41void mouse_off (void); 41void mouse_off (void);
42void mouse_moveto (int, int); 42void mouse_moveto (int, int);
43 43
44#include <sys/types.h>
45#include <sys/stat.h>
46
44#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4 47#if __DJGPP__ == 2 && __DJGPP_MINOR__ < 4
45int readlink (const char *, char *, size_t); 48int readlink (const char *, char *, size_t);
46#endif 49#endif
50ssize_t readlinkat (int, const char *, char *, size_t);
51int fstatat (int, char const *, struct stat *, int);
52int unsetenv (const char *);
53
54/* Constants. */
55#define EINPROGRESS 112
56/* Gnulib sets O_CLOEXEC to O_NOINHERIT, which gets in the way when we
57 need to redirect standard handles for subprocesses using temporary
58 files created by mkostemp, see callproc.c. */
59#ifdef O_CLOEXEC
60# undef O_CLOEXEC
61#endif
62#define O_CLOEXEC 0
47 63
48 64
49#ifndef HAVE_X_WINDOWS 65#ifndef HAVE_X_WINDOWS
@@ -83,7 +99,6 @@ extern void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
83#define XMenuSetAEQ (void) 99#define XMenuSetAEQ (void)
84#define XMenuSetFreeze (void) 100#define XMenuSetFreeze (void)
85#define XMenuRecompute (void) 101#define XMenuRecompute (void)
86#define FONT_WIDTH(foo) 1
87#define XM_FAILURE -1 102#define XM_FAILURE -1
88#define XM_SUCCESS 1 103#define XM_SUCCESS 1
89#define XM_NO_SELECT 2 104#define XM_NO_SELECT 2
diff --git a/src/process.c b/src/process.c
index fd34eb08d9d..2c66b9e976e 100644
--- a/src/process.c
+++ b/src/process.c
@@ -134,6 +134,29 @@ extern int sys_select (int, fd_set *, fd_set *, fd_set *,
134 struct timespec *, void *); 134 struct timespec *, void *);
135#endif 135#endif
136 136
137/* Work around GCC 4.7.0 bug with strict overflow checking; see
138 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
139 These lines can be removed once the GCC bug is fixed. */
140#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
141# pragma GCC diagnostic ignored "-Wstrict-overflow"
142#endif
143
144Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
145Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
146Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
147Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
148Lisp_Object QCname, QCtype;
149
150/* True if keyboard input is on hold, zero otherwise. */
151
152static bool kbd_is_on_hold;
153
154/* Nonzero means don't run process sentinels. This is used
155 when exiting. */
156bool inhibit_sentinels;
157
158#ifdef subprocesses
159
137#ifndef SOCK_CLOEXEC 160#ifndef SOCK_CLOEXEC
138# define SOCK_CLOEXEC 0 161# define SOCK_CLOEXEC 0
139#endif 162#endif
@@ -165,29 +188,6 @@ process_socket (int domain, int type, int protocol)
165# define socket(domain, type, protocol) process_socket (domain, type, protocol) 188# define socket(domain, type, protocol) process_socket (domain, type, protocol)
166#endif 189#endif
167 190
168/* Work around GCC 4.7.0 bug with strict overflow checking; see
169 <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52904>.
170 These lines can be removed once the GCC bug is fixed. */
171#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
172# pragma GCC diagnostic ignored "-Wstrict-overflow"
173#endif
174
175Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
176Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
177Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
178Lisp_Object Quser, Qgroup, Qetime, Qpcpu, Qpmem, Qtime, Qctime;
179Lisp_Object QCname, QCtype;
180
181/* True if keyboard input is on hold, zero otherwise. */
182
183static bool kbd_is_on_hold;
184
185/* Nonzero means don't run process sentinels. This is used
186 when exiting. */
187bool inhibit_sentinels;
188
189#ifdef subprocesses
190
191Lisp_Object Qprocessp; 191Lisp_Object Qprocessp;
192static Lisp_Object Qrun, Qstop, Qsignal; 192static Lisp_Object Qrun, Qstop, Qsignal;
193static Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten; 193static Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten;
@@ -7058,6 +7058,7 @@ integer or floating point values.
7058 return system_process_attributes (pid); 7058 return system_process_attributes (pid);
7059} 7059}
7060 7060
7061#ifdef subprocesses
7061/* Arrange to catch SIGCHLD if this hasn't already been arranged. 7062/* Arrange to catch SIGCHLD if this hasn't already been arranged.
7062 Invoke this after init_process_emacs, and after glib and/or GNUstep 7063 Invoke this after init_process_emacs, and after glib and/or GNUstep
7063 futz with the SIGCHLD handler, but before Emacs forks any children. 7064 futz with the SIGCHLD handler, but before Emacs forks any children.
@@ -7082,6 +7083,7 @@ catch_child_signal (void)
7082 : old_action.sa_handler); 7083 : old_action.sa_handler);
7083 unblock_child_signal (); 7084 unblock_child_signal ();
7084} 7085}
7086#endif /* subprocesses */
7085 7087
7086 7088
7087/* This is not called "init_process" because that is the name of a 7089/* This is not called "init_process" because that is the name of a
@@ -7288,10 +7290,12 @@ syms_of_process (void)
7288 DEFSYM (Qcutime, "cutime"); 7290 DEFSYM (Qcutime, "cutime");
7289 DEFSYM (Qcstime, "cstime"); 7291 DEFSYM (Qcstime, "cstime");
7290 DEFSYM (Qctime, "ctime"); 7292 DEFSYM (Qctime, "ctime");
7293#ifdef subprocesses
7291 DEFSYM (Qinternal_default_process_sentinel, 7294 DEFSYM (Qinternal_default_process_sentinel,
7292 "internal-default-process-sentinel"); 7295 "internal-default-process-sentinel");
7293 DEFSYM (Qinternal_default_process_filter, 7296 DEFSYM (Qinternal_default_process_filter,
7294 "internal-default-process-filter"); 7297 "internal-default-process-filter");
7298#endif
7295 DEFSYM (Qpri, "pri"); 7299 DEFSYM (Qpri, "pri");
7296 DEFSYM (Qnice, "nice"); 7300 DEFSYM (Qnice, "nice");
7297 DEFSYM (Qthcount, "thcount"); 7301 DEFSYM (Qthcount, "thcount");
diff --git a/src/sysdep.c b/src/sysdep.c
index 6ec8eecb287..4e86dc903dc 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1506,7 +1506,9 @@ emacs_sigaction_init (struct sigaction *action, signal_handler_t handler)
1506 /* When handling a signal, block nonfatal system signals that are caught 1506 /* When handling a signal, block nonfatal system signals that are caught
1507 by Emacs. This makes race conditions less likely. */ 1507 by Emacs. This makes race conditions less likely. */
1508 sigaddset (&action->sa_mask, SIGALRM); 1508 sigaddset (&action->sa_mask, SIGALRM);
1509#ifdef SIGCHLD
1509 sigaddset (&action->sa_mask, SIGCHLD); 1510 sigaddset (&action->sa_mask, SIGCHLD);
1511#endif
1510#ifdef SIGDANGER 1512#ifdef SIGDANGER
1511 sigaddset (&action->sa_mask, SIGDANGER); 1513 sigaddset (&action->sa_mask, SIGDANGER);
1512#endif 1514#endif
@@ -1711,7 +1713,9 @@ init_signals (bool dumping)
1711# ifdef SIGBUS 1713# ifdef SIGBUS
1712 sys_siglist[SIGBUS] = "Bus error"; 1714 sys_siglist[SIGBUS] = "Bus error";
1713# endif 1715# endif
1716# ifdef SIGCHLD
1714 sys_siglist[SIGCHLD] = "Child status changed"; 1717 sys_siglist[SIGCHLD] = "Child status changed";
1718# endif
1715# ifdef SIGCONT 1719# ifdef SIGCONT
1716 sys_siglist[SIGCONT] = "Continued"; 1720 sys_siglist[SIGCONT] = "Continued";
1717# endif 1721# endif
@@ -2182,6 +2186,9 @@ emacs_fopen (char const *file, char const *mode)
2182int 2186int
2183emacs_pipe (int fd[2]) 2187emacs_pipe (int fd[2])
2184{ 2188{
2189#ifdef MSDOS
2190 return pipe (fd);
2191#else /* !MSDOS */
2185 int result = pipe2 (fd, O_CLOEXEC); 2192 int result = pipe2 (fd, O_CLOEXEC);
2186 if (! O_CLOEXEC && result == 0) 2193 if (! O_CLOEXEC && result == 0)
2187 { 2194 {
@@ -2189,6 +2196,7 @@ emacs_pipe (int fd[2])
2189 fcntl (fd[1], F_SETFD, FD_CLOEXEC); 2196 fcntl (fd[1], F_SETFD, FD_CLOEXEC);
2190 } 2197 }
2191 return result; 2198 return result;
2199#endif /* !MSDOS */
2192} 2200}
2193 2201
2194/* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs. 2202/* Approximate posix_close and POSIX_CLOSE_RESTART well enough for Emacs.
diff --git a/src/term.c b/src/term.c
index 773e85faabc..9e6cfe2f41d 100644
--- a/src/term.c
+++ b/src/term.c
@@ -500,7 +500,7 @@ static ptrdiff_t encode_terminal_dst_size;
500 Set CODING->produced to the byte-length of the resulting byte 500 Set CODING->produced to the byte-length of the resulting byte
501 sequence, and return a pointer to that byte sequence. */ 501 sequence, and return a pointer to that byte sequence. */
502 502
503#ifndef WINDOWSNT 503#ifndef DOS_NT
504static 504static
505#endif 505#endif
506unsigned char * 506unsigned char *
@@ -4557,6 +4557,7 @@ bigger, or it may make it blink, or it may do nothing at all. */);
4557 encode_terminal_src = NULL; 4557 encode_terminal_src = NULL;
4558 encode_terminal_dst = NULL; 4558 encode_terminal_dst = NULL;
4559 4559
4560#ifndef MSDOS
4560 DEFSYM (Qtty_menu_next_item, "tty-menu-next-item"); 4561 DEFSYM (Qtty_menu_next_item, "tty-menu-next-item");
4561 DEFSYM (Qtty_menu_prev_item, "tty-menu-prev-item"); 4562 DEFSYM (Qtty_menu_prev_item, "tty-menu-prev-item");
4562 DEFSYM (Qtty_menu_next_menu, "tty-menu-next-menu"); 4563 DEFSYM (Qtty_menu_next_menu, "tty-menu-next-menu");
@@ -4566,4 +4567,5 @@ bigger, or it may make it blink, or it may do nothing at all. */);
4566 DEFSYM (Qtty_menu_exit, "tty-menu-exit"); 4567 DEFSYM (Qtty_menu_exit, "tty-menu-exit");
4567 DEFSYM (Qtty_menu_mouse_movement, "tty-menu-mouse-movement"); 4568 DEFSYM (Qtty_menu_mouse_movement, "tty-menu-mouse-movement");
4568 DEFSYM (Qtty_menu_navigation_map, "tty-menu-navigation-map"); 4569 DEFSYM (Qtty_menu_navigation_map, "tty-menu-navigation-map");
4570#endif
4569} 4571}
diff --git a/src/termhooks.h b/src/termhooks.h
index 961b321891d..708351da83d 100644
--- a/src/termhooks.h
+++ b/src/termhooks.h
@@ -643,7 +643,7 @@ extern void delete_terminal (struct terminal *);
643/* The initial terminal device, created by initial_term_init. */ 643/* The initial terminal device, created by initial_term_init. */
644extern struct terminal *initial_terminal; 644extern struct terminal *initial_terminal;
645 645
646#ifdef WINDOWSNT 646#ifdef DOS_NT
647extern unsigned char *encode_terminal_code (struct glyph *, int, 647extern unsigned char *encode_terminal_code (struct glyph *, int,
648 struct coding_system *); 648 struct coding_system *);
649#endif 649#endif
diff --git a/src/unexcoff.c b/src/unexcoff.c
index 5710ac04570..043f3348d16 100644
--- a/src/unexcoff.c
+++ b/src/unexcoff.c
@@ -65,6 +65,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
65#include <crt0.h> /* for _crt0_startup_flags and its bits */ 65#include <crt0.h> /* for _crt0_startup_flags and its bits */
66#include <sys/exceptn.h> 66#include <sys/exceptn.h>
67static int save_djgpp_startup_flags; 67static int save_djgpp_startup_flags;
68#include <libc/atexit.h>
69static struct __atexit *save_atexit_ptr;
68#define filehdr external_filehdr 70#define filehdr external_filehdr
69#define scnhdr external_scnhdr 71#define scnhdr external_scnhdr
70#define syment external_syment 72#define syment external_syment
@@ -82,7 +84,7 @@ struct aouthdr
82 unsigned long text_start;/* base of text used for this file */ 84 unsigned long text_start;/* base of text used for this file */
83 unsigned long data_start;/* base of data used for this file */ 85 unsigned long data_start;/* base of data used for this file */
84}; 86};
85#endif /* not MSDOS */ 87#endif /* MSDOS */
86#else /* not HAVE_COFF_H */ 88#else /* not HAVE_COFF_H */
87#include <a.out.h> 89#include <a.out.h>
88#endif /* not HAVE_COFF_H */ 90#endif /* not HAVE_COFF_H */
@@ -368,6 +370,12 @@ copy_text_and_data (int new, int a_out)
368 and which might change the way that dumped Emacs works. */ 370 and which might change the way that dumped Emacs works. */
369 save_djgpp_startup_flags = _crt0_startup_flags; 371 save_djgpp_startup_flags = _crt0_startup_flags;
370 _crt0_startup_flags &= ~(_CRT0_FLAG_NO_LFN | _CRT0_FLAG_NEARPTR); 372 _crt0_startup_flags &= ~(_CRT0_FLAG_NO_LFN | _CRT0_FLAG_NEARPTR);
373
374 /* Zero out the 'atexit' chain in the dumped executable, to avoid
375 calling the atexit functions twice. (emacs.c:main installs an
376 atexit function.) */
377 save_atexit_ptr = __atexit_ptr;
378 __atexit_ptr = NULL;
371#endif 379#endif
372 380
373 lseek (new, (long) text_scnptr, 0); 381 lseek (new, (long) text_scnptr, 0);
@@ -386,6 +394,9 @@ copy_text_and_data (int new, int a_out)
386 394
387 /* Restore the startup flags. */ 395 /* Restore the startup flags. */
388 _crt0_startup_flags = save_djgpp_startup_flags; 396 _crt0_startup_flags = save_djgpp_startup_flags;
397
398 /* Restore the atexit chain. */
399 __atexit_ptr = save_atexit_ptr;
389#endif 400#endif
390 401
391 402