aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJim Blandy1992-05-01 06:20:46 +0000
committerJim Blandy1992-05-01 06:20:46 +0000
commit32676c085ce177af1e1e8ab61360c68772450af0 (patch)
tree6c8e9d6bc310b894409ae82fe957d1cd518c8e4d /src
parentd9a0f717d7057092d81b6cfc9acf06e3afcd13bd (diff)
downloademacs-32676c085ce177af1e1e8ab61360c68772450af0.tar.gz
emacs-32676c085ce177af1e1e8ab61360c68772450af0.zip
*** empty log message ***
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c5
-rw-r--r--src/callproc.c20
-rw-r--r--src/data.c6
-rw-r--r--src/emacs.c3
-rw-r--r--src/filelock.c108
-rw-r--r--src/floatfns.c6
-rw-r--r--src/keyboard.c5
-rw-r--r--src/process.c48
-rw-r--r--src/s/aix3-1.h2
-rw-r--r--src/syntax.c13
-rw-r--r--src/sysdep.c12
-rw-r--r--src/syssignal.h73
12 files changed, 207 insertions, 94 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 3f40ea47e50..b4637970dd7 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -551,8 +551,9 @@ DEFUN ("make-marker", Fmake_marker, Smake_marker, 0, 0, 0,
551 register struct Lisp_Marker *p; 551 register struct Lisp_Marker *p;
552 /* Detact the bug that seems to have caused this to be called from 552 /* Detact the bug that seems to have caused this to be called from
553 a signal handler. */ 553 a signal handler. */
554 int mask = sigsetmask (-1); 554 int mask, dummy;
555 sigsetmask (mask); 555 EMACS_SIGSETMASK (-1, mask);
556 EMACS_SIGSETMASK (mask, dummy);
556 if (mask != 0) 557 if (mask != 0)
557 abort (); 558 abort ();
558 559
diff --git a/src/callproc.c b/src/callproc.c
index 68b447d401d..1a564ad7ccc 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -224,7 +224,11 @@ If you quit, the process is killed with SIGKILL.")
224 /* Tell SIGCHLD handler to look for this pid. */ 224 /* Tell SIGCHLD handler to look for this pid. */
225 synch_process_pid = pid; 225 synch_process_pid = pid;
226 /* Now let SIGCHLD come through. */ 226 /* Now let SIGCHLD come through. */
227 sigsetmask (mask); 227 {
228 int dummy;
229
230 EMACS_SIGSETMASK (mask, dummy);
231 }
228#endif 232#endif
229 233
230 environ = save_environ; 234 environ = save_environ;
@@ -530,11 +534,17 @@ init_callproc ()
530 register char **envp; 534 register char **envp;
531 Lisp_Object tempdir; 535 Lisp_Object tempdir;
532 536
533 Vdata_directory = Ffile_name_as_directory (build_string (PATH_DATA)); 537 {
538 char *data_dir = egetenv ("EMACSDATA");
539
540 Vdata_directory =
541 Ffile_name_as_directory
542 (build_string (data_dir ? data_dir : PATH_DATA));
543 }
534 544
535 /* Turn PATH_EXEC into a path. `==' is just a string which we know 545 /* Check the EMACSPATH environment variable, defaulting to the
536 will not be the name of an environment variable. */ 546 PATH_EXEC path from paths.h. */
537 Vexec_path = decode_env_path ("==", PATH_EXEC); 547 Vexec_path = decode_env_path ("EMACSPATH", PATH_EXEC);
538 Vexec_directory = Ffile_name_as_directory (Fcar (Vexec_path)); 548 Vexec_directory = Ffile_name_as_directory (Fcar (Vexec_path));
539 Vexec_path = nconc2 (decode_env_path ("PATH", ""), Vexec_path); 549 Vexec_path = nconc2 (decode_env_path ("PATH", ""), Vexec_path);
540 550
diff --git a/src/data.c b/src/data.c
index 4e95494d593..48af4ec9149 100644
--- a/src/data.c
+++ b/src/data.c
@@ -1959,7 +1959,11 @@ arith_error (signo)
1959#ifdef BSD4_1 1959#ifdef BSD4_1
1960 sigrelse (SIGFPE); 1960 sigrelse (SIGFPE);
1961#else /* not BSD4_1 */ 1961#else /* not BSD4_1 */
1962 sigsetmask (SIGEMPTYMASK); 1962 {
1963 int dummy;
1964
1965 EMACS_SIGSETMASK (SIGEMPTYMASK, dummy);
1966 }
1963#endif /* not BSD4_1 */ 1967#endif /* not BSD4_1 */
1964 1968
1965 Fsignal (Qarith_error, Qnil); 1969 Fsignal (Qarith_error, Qnil);
diff --git a/src/emacs.c b/src/emacs.c
index c530eca103f..90a86b26723 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -442,6 +442,9 @@ main (argc, argv, envp)
442 init_vmsfns (); 442 init_vmsfns ();
443#endif /* VMS */ 443#endif /* VMS */
444 init_process (); 444 init_process ();
445#ifdef CLASH_DETECTION
446 init_filelock ();
447#endif /* CLASH_DETECTION */
445 448
446/* Intern the names of all standard functions and variables; define standard keys */ 449/* Intern the names of all standard functions and variables; define standard keys */
447 450
diff --git a/src/filelock.c b/src/filelock.c
index a2c7941fced..7a473753e58 100644
--- a/src/filelock.c
+++ b/src/filelock.c
@@ -1,10 +1,10 @@
1/* Copyright (C) 1985, 1986, 1987 Free Software Foundation, Inc. 1/* Copyright (C) 1985, 1986, 1987, 1992 Free Software Foundation, Inc.
2 2
3This file is part of GNU Emacs. 3This file is part of GNU Emacs.
4 4
5GNU Emacs is free software; you can redistribute it and/or modify 5GNU Emacs is free software; you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by 6it under the terms of the GNU General Public License as published by
7the Free Software Foundation; either version 1, or (at your option) 7the Free Software Foundation; either version 2, or (at your option)
8any later version. 8any later version.
9 9
10GNU Emacs is distributed in the hope that it will be useful, 10GNU Emacs is distributed in the hope that it will be useful,
@@ -39,6 +39,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
39 39
40extern int errno; 40extern int errno;
41 41
42extern char *egetenv ();
43
42#ifdef CLASH_DETECTION 44#ifdef CLASH_DETECTION
43 45
44/* If system does not have symbolic links, it does not have lstat. 46/* If system does not have symbolic links, it does not have lstat.
@@ -48,6 +50,44 @@ extern int errno;
48#define lstat stat 50#define lstat stat
49#endif 51#endif
50 52
53
54/* The name of the directory in which we keep lock files, with a '/'
55 appended. */
56char *lock_path;
57
58/* The name of the file in the lock directory which is used to
59 arbitrate access to the entire directory. */
60#define SUPERLOCK_NAME "!!!SuperLock!!!"
61
62/* The path to the superlock file. This is SUPERLOCK_NAME appended to
63 lock_path. */
64char *superlock_path;
65
66/* Set LOCK to the name of the lock file for the filename FILE.
67 char *LOCK; Lisp_Object FILE; */
68#define MAKE_LOCK_PATH (lock, file) \
69 (lock = (char *) alloca (XSTRING (file)->size + strlen (lock_path) + 1), \
70 fill_in_lock_file_name (lock, (file)))
71
72fill_in_lock_file_name (lockfile, fn)
73 register char *lockfile;
74 register Lisp_Object fn;
75{
76 register char *p;
77
78 strcpy (lockfile, lock_path);
79
80 p = lockfile + strlen (lockfile);
81
82 strcpy (p, XSTRING (fn)->data);
83
84 for (; *p; p++)
85 {
86 if (*p == '/')
87 *p = '!';
88 }
89}
90
51static Lisp_Object 91static Lisp_Object
52lock_file_owner_name (lfname) 92lock_file_owner_name (lfname)
53 char *lfname; 93 char *lfname;
@@ -90,11 +130,10 @@ lock_file (fn)
90 register Lisp_Object attack; 130 register Lisp_Object attack;
91 register char *lfname; 131 register char *lfname;
92 132
93 /* Create the name of the lock-file for file fn */ 133 MAKE_LOCK_PATH (lfname, fn);
94 lfname = (char *) alloca (XSTRING (fn)->size + strlen (PATH_LOCK) + 1);
95 fill_in_lock_file_name (lfname, fn);
96 134
97 /* See if this file is visited and has changed on disk since it was visited. */ 135 /* See if this file is visited and has changed on disk since it was
136 visited. */
98 { 137 {
99 register Lisp_Object subject_buf = Fget_file_buffer (fn); 138 register Lisp_Object subject_buf = Fget_file_buffer (fn);
100 if (!NILP (subject_buf) 139 if (!NILP (subject_buf)
@@ -116,31 +155,12 @@ lock_file (fn)
116 { 155 {
117 lock_superlock (lfname); 156 lock_superlock (lfname);
118 lock_file_1 (lfname, O_WRONLY) ; 157 lock_file_1 (lfname, O_WRONLY) ;
119 unlink (PATH_SUPERLOCK); 158 unlink (superlock_path);
120 return; 159 return;
121 } 160 }
122 /* User says ignore the lock */ 161 /* User says ignore the lock */
123} 162}
124 163
125fill_in_lock_file_name (lockfile, fn)
126 register char *lockfile;
127 register Lisp_Object fn;
128{
129 register char *p;
130
131 strcpy (lockfile, PATH_LOCK);
132
133 p = lockfile + strlen (lockfile);
134
135 strcpy (p, XSTRING (fn)->data);
136
137 for (; *p; p++)
138 {
139 if (*p == '/')
140 *p = '!';
141 }
142}
143
144/* Lock the lock file named LFNAME. 164/* Lock the lock file named LFNAME.
145 If MODE is O_WRONLY, we do so even if it is already locked. 165 If MODE is O_WRONLY, we do so even if it is already locked.
146 If MODE is O_WRONLY | O_EXCL | O_CREAT, we do so only if it is free. 166 If MODE is O_WRONLY | O_EXCL | O_CREAT, we do so only if it is free.
@@ -236,15 +256,14 @@ unlock_file (fn)
236{ 256{
237 register char *lfname; 257 register char *lfname;
238 258
239 lfname = (char *) alloca (XSTRING (fn)->size + strlen (PATH_LOCK) + 1); 259 MAKE_LOCK_PATH (lfname, fn);
240 fill_in_lock_file_name (lfname, fn);
241 260
242 lock_superlock (lfname); 261 lock_superlock (lfname);
243 262
244 if (current_lock_owner_1 (lfname) == getpid ()) 263 if (current_lock_owner_1 (lfname) == getpid ())
245 unlink (lfname); 264 unlink (lfname);
246 265
247 unlink (PATH_SUPERLOCK); 266 unlink (superlock_path);
248} 267}
249 268
250lock_superlock (lfname) 269lock_superlock (lfname)
@@ -252,7 +271,7 @@ lock_superlock (lfname)
252{ 271{
253 register int i, fd; 272 register int i, fd;
254 273
255 for (i = -20; i < 0 && (fd = open (PATH_SUPERLOCK, 274 for (i = -20; i < 0 && (fd = open (superlock_path,
256 O_WRONLY | O_EXCL | O_CREAT, 0666)) < 0; 275 O_WRONLY | O_EXCL | O_CREAT, 0666)) < 0;
257 i++) 276 i++)
258 { 277 {
@@ -263,7 +282,7 @@ lock_superlock (lfname)
263 if (fd >= 0) 282 if (fd >= 0)
264 { 283 {
265#ifdef USG 284#ifdef USG
266 chmod (PATH_SUPERLOCK, 0666); 285 chmod (superlock_path, 0666);
267#else 286#else
268 fchmod (fd, 0666); 287 fchmod (fd, 0666);
269#endif 288#endif
@@ -341,9 +360,7 @@ t if it is locked by you, else a string of the name of the locker.")
341 360
342 fn = Fexpand_file_name (fn, Qnil); 361 fn = Fexpand_file_name (fn, Qnil);
343 362
344 /* Create the name of the lock-file for file filename */ 363 MAKE_LOCK_PATH (lfname, fn);
345 lfname = (char *) alloca (XSTRING (fn)->size + strlen (PATH_LOCK) + 1);
346 fill_in_lock_file_name (lfname, fn);
347 364
348 owner = current_lock_owner (lfname); 365 owner = current_lock_owner (lfname);
349 if (owner <= 0) 366 if (owner <= 0)
@@ -354,6 +371,29 @@ t if it is locked by you, else a string of the name of the locker.")
354 return (lock_file_owner_name (lfname)); 371 return (lock_file_owner_name (lfname));
355} 372}
356 373
374
375/* Initialization functions. */
376
377init_filelock ()
378{
379 lock_path = egetenv ("EMACSLOCKDIR");
380 if (! lock_path)
381 lock_path = PATH_LOCK;
382
383 /* Make sure it ends with a slash. */
384 if (lock_path[strlen (lock_path) - 1] != '/')
385 {
386 lock_path = strcpy ((char *) xmalloc (strlen (lock_path) + 2),
387 lock_path);
388 strcat (lock_path, "/");
389 }
390
391 superlock_path = (char *) xmalloc ((strlen (lock_path)
392 + sizeof (SUPERLOCK_NAME)));
393 strcpy (superlock_path, lock_path);
394 strcat (superlock_path, SUPERLOCK_NAME);
395}
396
357syms_of_filelock () 397syms_of_filelock ()
358{ 398{
359 defsubr (&Sunlock_buffer); 399 defsubr (&Sunlock_buffer);
diff --git a/src/floatfns.c b/src/floatfns.c
index ed94c9ebafe..c99ba487e71 100644
--- a/src/floatfns.c
+++ b/src/floatfns.c
@@ -509,7 +509,11 @@ float_error (signo)
509#ifdef BSD4_1 509#ifdef BSD4_1
510 sigrelse (SIGILL); 510 sigrelse (SIGILL);
511#else /* not BSD4_1 */ 511#else /* not BSD4_1 */
512 sigsetmask (0); 512 {
513 int dummy;
514
515 EMACS_SIGSETMASK (0, dummy);
516 }
513#endif /* not BSD4_1 */ 517#endif /* not BSD4_1 */
514#else 518#else
515 /* Must reestablish handler each time it is called. */ 519 /* Must reestablish handler each time it is called. */
diff --git a/src/keyboard.c b/src/keyboard.c
index c0f9ae4424b..122fa247c39 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2104,9 +2104,10 @@ gobble_input (expected)
2104#ifdef SIGIO 2104#ifdef SIGIO
2105 if (interrupt_input) 2105 if (interrupt_input)
2106 { 2106 {
2107 SIGMASKTYPE mask = sigblockx (SIGIO); 2107 SIGMASKTYPE mask;
2108 EMACS_SIGBLOCKX (SIGIO, mask);
2108 read_avail_input (expected); 2109 read_avail_input (expected);
2109 sigsetmask (mask); 2110 EMACS_SIGSETMASK (mask, mask);
2110 } 2111 }
2111 else 2112 else
2112#endif 2113#endif
diff --git a/src/process.c b/src/process.c
index 442cae6d159..d9e2734957f 100644
--- a/src/process.c
+++ b/src/process.c
@@ -108,8 +108,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
108#include "termhooks.h" 108#include "termhooks.h"
109#include "termopts.h" 109#include "termopts.h"
110#include "commands.h" 110#include "commands.h"
111 111#include "dispextern.h"
112extern int screen_garbaged;
113 112
114Lisp_Object Qrun, Qstop, Qsignal, Qopen, Qclosed; 113Lisp_Object Qrun, Qstop, Qsignal, Qopen, Qclosed;
115/* Qexit is declared and initialized in eval.c. */ 114/* Qexit is declared and initialized in eval.c. */
@@ -419,6 +418,13 @@ allocate_pty ()
419 register c, i; 418 register c, i;
420 int fd; 419 int fd;
421 420
421 /* Some systems name their pseudoterminals so that there are gaps in
422 the usual sequence - for example, on HP9000/S700 systems, there
423 are no pseudoterminals with names ending in 'f'. So we wait for
424 three failures in a row before deciding that we've reached the
425 end of the ptys. */
426 int failed_count = 0;
427
422#ifdef PTY_ITERATION 428#ifdef PTY_ITERATION
423 PTY_ITERATION 429 PTY_ITERATION
424#else 430#else
@@ -440,20 +446,27 @@ allocate_pty ()
440#endif /* not HPUX */ 446#endif /* not HPUX */
441#endif /* no PTY_NAME_SPRINTF */ 447#endif /* no PTY_NAME_SPRINTF */
442 448
443#ifndef IRIS 449#ifdef IRIS
444 if (stat (pty_name, &stb) < 0) 450 /* Unusual IRIS code */
451 *ptyv = open ("/dev/ptc", O_RDWR | O_NDELAY, 0);
452 if (fd < 0)
453 return -1;
454 if (fstat (fd, &stb) < 0)
445 return -1; 455 return -1;
456#else
457 if (stat (pty_name, &stb) < 0)
458 {
459 failed_count++;
460 if (failed_count >= 3)
461 return -1;
462 }
463 else
464 failed_count = 0;
446#ifdef O_NONBLOCK 465#ifdef O_NONBLOCK
447 fd = open (pty_name, O_RDWR | O_NONBLOCK, 0); 466 fd = open (pty_name, O_RDWR | O_NONBLOCK, 0);
448#else 467#else
449 fd = open (pty_name, O_RDWR | O_NDELAY, 0); 468 fd = open (pty_name, O_RDWR | O_NDELAY, 0);
450#endif 469#endif
451#else /* Unusual IRIS code */
452 *ptyv = open ("/dev/ptc", O_RDWR | O_NDELAY, 0);
453 if (fd < 0)
454 return -1;
455 if (fstat (fd, &stb) < 0)
456 return -1;
457#endif /* IRIS */ 470#endif /* IRIS */
458 471
459 if (fd >= 0) 472 if (fd >= 0)
@@ -1742,11 +1755,6 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1742 if (!read_kbd) 1755 if (!read_kbd)
1743 FD_CLR (0, &Available); 1756 FD_CLR (0, &Available);
1744 1757
1745 /* If a screen has been newly mapped and needs updating,
1746 reprocess its display stuff. */
1747 if (screen_garbaged)
1748 redisplay_preserve_echo_area ();
1749
1750 if (read_kbd && detect_input_pending ()) 1758 if (read_kbd && detect_input_pending ())
1751 nfds = 0; 1759 nfds = 0;
1752 else 1760 else
@@ -1829,6 +1837,16 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
1829 if (! wait_proc) 1837 if (! wait_proc)
1830 got_some_input |= nfds > 0; 1838 got_some_input |= nfds > 0;
1831 1839
1840 /* If checking input just got us a size-change event from X,
1841 obey it now if we should. */
1842 if (read_kbd)
1843 do_pending_window_change ();
1844
1845 /* If screen size has changed, redisplay now
1846 for either sit-for or keyboard input. */
1847 if (read_kbd && screen_garbaged)
1848 redisplay_preserve_echo_area ();
1849
1832 /* Check for data from a process or a command channel */ 1850 /* Check for data from a process or a command channel */
1833 for (channel = FIRST_PROC_DESC; channel < MAXDESC; channel++) 1851 for (channel = FIRST_PROC_DESC; channel < MAXDESC; channel++)
1834 { 1852 {
diff --git a/src/s/aix3-1.h b/src/s/aix3-1.h
index 366ef832ed9..5b15772b16b 100644
--- a/src/s/aix3-1.h
+++ b/src/s/aix3-1.h
@@ -208,7 +208,7 @@ and this notice must be preserved on all copies. */
208 208
209/* #define ADDR_CORRECT(x) (x) */ 209/* #define ADDR_CORRECT(x) (x) */
210 210
211#define LD_CMD cc 211#define LINKER cc
212 212
213/* Prevent -lg from being used for debugging. Not needed. */ 213/* Prevent -lg from being used for debugging. Not needed. */
214 214
diff --git a/src/syntax.c b/src/syntax.c
index 4f203caf8f8..483526ebc35 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -158,12 +158,13 @@ DEFUN ("modify-syntax-entry", foo, bar, 0, 0, 0,
158The syntax is changed only for table TABLE, which defaults to\n\ 158The syntax is changed only for table TABLE, which defaults to\n\
159 the current buffer's syntax table.\n\ 159 the current buffer's syntax table.\n\
160The first character of S should be one of the following:\n\ 160The first character of S should be one of the following:\n\
161 Space whitespace syntax. w word constituent.\n\ 161 Space or - whitespace syntax. w word constituent.\n\
162 _ symbol constituent. . punctuation.\n\ 162 _ symbol constituent. . punctuation.\n\
163 ( open-parenthesis. ) close-parenthesis.\n\ 163 ( open-parenthesis. ) close-parenthesis.\n\
164 \" string quote. \\ character-quote.\n\ 164 \" string quote. \\ escape.\n\
165 $ paired delimiter. ' expression quote or prefix operator.\n\ 165 $ paired delimiter. ' expression quote or prefix operator.\n\
166 < comment starter. > comment ender.\n\ 166 < comment starter. > comment ender.\n\
167 / character-quote.\n\
167Only single-character comment start and end sequences are represented thus.\n\ 168Only single-character comment start and end sequences are represented thus.\n\
168Two-character sequences are represented as described below.\n\ 169Two-character sequences are represented as described below.\n\
169The second character of S is the matching parenthesis,\n\ 170The second character of S is the matching parenthesis,\n\
diff --git a/src/sysdep.c b/src/sysdep.c
index 03614f98cce..62980380a68 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -638,7 +638,11 @@ reset_sigio ()
638request_sigio () 638request_sigio ()
639{ 639{
640#ifdef SIGWINCH 640#ifdef SIGWINCH
641 sigunblock (sigmask (SIGWINCH)); 641 {
642 int dummy;
643
644 EMACS_SIGUNBLOCKX (SIGWINCH, dummy);
645 }
642#endif 646#endif
643 fcntl (0, F_SETFL, old_fcntl_flags | FASYNC); 647 fcntl (0, F_SETFL, old_fcntl_flags | FASYNC);
644 648
@@ -648,7 +652,11 @@ request_sigio ()
648unrequest_sigio () 652unrequest_sigio ()
649{ 653{
650#ifdef SIGWINCH 654#ifdef SIGWINCH
651 sigblock (sigmask (SIGWINCH)); 655 {
656 int dummy;
657
658 EMACS_SIGBLOCK (SIGWINCH, dummy);
659 }
652#endif 660#endif
653 fcntl (0, F_SETFL, old_fcntl_flags); 661 fcntl (0, F_SETFL, old_fcntl_flags);
654 interrupts_deferred = 1; 662 interrupts_deferred = 1;
diff --git a/src/syssignal.h b/src/syssignal.h
index 81d52c8f758..cf5914458f2 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
17along with GNU Emacs; see the file COPYING. If not, write to 17along with GNU Emacs; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ 18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
19 19
20
20#ifdef POSIX_SIGNALS 21#ifdef POSIX_SIGNALS
21#define SIGMASKTYPE sigset_t 22#define SIGMASKTYPE sigset_t
22 23
@@ -27,14 +28,19 @@ extern sigset_t empty_mask, full_mask, temp_mask;
27#define sigmask(SIG) \ 28#define sigmask(SIG) \
28(sigemptyset (&temp_mask), sigaddset (&temp_mask, SIG), temp_mask) 29(sigemptyset (&temp_mask), sigaddset (&temp_mask, SIG), temp_mask)
29 30
30/* May need a local mask. There could be problems if code using any 31/* The below routines may need a local mask. There could be problems
31 of the 3 macros below could be reentered due to a signal occurring. 32 if code using any of the 3 macros below could be reentered due to a
32 This can't happen in Emacs 18.57, so we don't worry. - DJB 33 signal occurring. This can't happen in Emacs 18.57, so we don't
33 These macros also require GCC. */ 34 worry. - DJB */
34#define sigpause(SIG) ({ sigset_t _mask; sys_sigpause(SIG); }) 35
35#define sigblock(SIG) ({ sigset_t _mask; sys_sigblock(SIG); }) 36#define EMACS_SIGPAUSE(sigset) \
36#define sigunblock(SIG) ({ sigset_t _mask; sys_sigunblock(SIG); }) 37 do { sigset_t _mask; sys_sigpause (sigset); } while (0)
37#define sigsetmask(SIG) ({ sigset_t _mask; sys_sigsetmask(SIG); }) 38#define EMACS_SIGBLOCK(new_sig, old_sig) \
39 do { sigset_t _mask; (old_sig) = sys_sigblock (new_sig); } while (0)
40#define EMACS_SIGUNBLOCK(new_sig, old_sig) \
41 do { sigset_t _mask; (old_sig) = sys_sigunblock (new_sig); } while (0)
42#define EMACS_SIGSETMASK(new_sig, old_sig) \
43 do { sigset_t _mask; (old_sig) = sys_sigsetmask (new_sig); } while (0)
38#define sighold(SIG) ONLY_USED_IN_BSD_4_1 44#define sighold(SIG) ONLY_USED_IN_BSD_4_1
39#define sigrelse(SIG) ONLY_USED_IN_BSD_4_1 45#define sigrelse(SIG) ONLY_USED_IN_BSD_4_1
40 46
@@ -46,12 +52,12 @@ sigset_t sys_sigsetmask (sigset_t new_mask);
46 52
47#define sys_sigdel(MASK,SIG) sigdelset(&MASK,SIG) 53#define sys_sigdel(MASK,SIG) sigdelset(&MASK,SIG)
48 54
49#else /* not POSIX_SIGNALS */ 55#else /* ! defined (POSIX_SIGNALS) */
50 56
51#define sigunblock(SIG) \ 57#define sigunblock(SIG) \
52{ SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); } 58{ SIGMASKTYPE omask = sigblock (SIGEMPTYMASK); sigsetmask (omask & ~SIG); }
53 59
54#endif /* not POSIX_SIGNALS */ 60#endif /* ! defined (POSIX_SIGNALS) */
55 61
56#ifndef SIGMASKTYPE 62#ifndef SIGMASKTYPE
57#define SIGMASKTYPE int 63#define SIGMASKTYPE int
@@ -65,21 +71,38 @@ sigset_t sys_sigsetmask (sigset_t new_mask);
65#define sigmask(no) (1L << ((no) - 1)) 71#define sigmask(no) (1L << ((no) - 1))
66#endif 72#endif
67 73
68#ifndef BSD4_1
69#define sigfree() sigsetmask (SIGEMPTYMASK)
70#define sigholdx(sig) sigsetmask (sigmask (sig))
71#define sigblockx(sig) sigblock (sigmask (sig))
72#define sigunblockx(sig) sigblock (SIGEMPTYMASK)
73#define sigpausex(sig) sigpause (0)
74#endif /* not BSD4_1 */
75
76#ifdef BSD4_1 74#ifdef BSD4_1
77#define SIGIO SIGTINT 75#define SIGIO SIGTINT
78/* sigfree and sigholdx are in sysdep.c */ 76/* sigfree and sigholdx are in sysdep.c */
79#define sigblockx(sig) sighold (sig) 77#define EMACS_SIGFREE () sigfree ()
80#define sigunblockx(sig) sigrelse (sig) 78
81#define sigpausex(sig) sigpause (sig) 79/* We define the following macros to expand into statements rather
82#endif /* BSD4_1 */ 80 than expressions, because the POSIX macros above do the same, and
81 we don't want people on BSD4_1 systems accidentally using the
82 macros in a way that will break the other systems. */
83#define EMACS_SIGHOLDX(new_sig, old_sig) \
84 do { (old_sig) = sigholdx (new_sig); } while (0)
85#define EMACS_SIGBLOCKX(new_sig, old_sig) \
86 do { (old_sig) = sighold (new_sig); } while (0)
87#define EMACS_SIGUNBLOCKX(new_sig, old_sig) \
88 do { (old_sig) = sigrelse (new_sig); } while (0)
89#define EMACS_SIGPAUSEX(sig) \
90 EMACS_SIGPAUSE (new_sig);
91
92#else /* ! defined (BSD4_1) */
93
94#define EMACS_SIGFREE() \
95 do { SIGMASKTYPE _dummy; EMACS_SIGSETMASK (SIGEMPTYMASK, _dummy); } while (0)
96#define EMACS_SIGHOLDX(new_sig, old_sig) \
97 EMACS_SIGSETMASK (sigmask (new_sig), old_sig)
98#define EMACS_SIGBLOCKX(new_sig, old_sig) \
99 EMACS_SIGBLOCK (sigmask (new_sig), old_sig)
100#define EMACS_SIGUNBLOCKX(new_sig, old_sig) \
101 EMACS_SIGUNBLOCK (sigmask (new_sig), old_sig)
102#define EMACS_SIGPAUSEX(sig) \
103 EMACS_SIGPAUSE (0)
104
105#endif /* ! defined (BSD4_1) */
83 106
84/* On bsd, [man says] kill does not accept a negative number to kill a pgrp. 107/* On bsd, [man says] kill does not accept a negative number to kill a pgrp.
85 Must do that using the killpg call. */ 108 Must do that using the killpg call. */
@@ -96,6 +119,6 @@ sigset_t sys_sigsetmask (sigset_t new_mask);
96#ifdef SIGCLD 119#ifdef SIGCLD
97#ifndef SIGCHLD 120#ifndef SIGCHLD
98#define SIGCHLD SIGCLD 121#define SIGCHLD SIGCLD
99#endif /* not SIGCHLD */ 122#endif /* SIGCHLD */
100#endif /* SIGCLD */ 123#endif /* ! defined (SIGCLD) */
101#endif /* not VMS */ 124#endif /* VMS */