Mercurial > emacs
comparison src/sysdep.c @ 2439:b6c62e4abf59
Put interrupt input blocking in a separate file from xterm.h.
This isn't specific to X, and it allows us to avoid #including
xterm.h in files that don't really have anything to do with X.
* blockinput.h: New file.
* xterm.h (BLOCK_INPUT, UNBLOCK_INPUT, TOTALLY_UNBLOCK_INPUT,
UNBLOCK_INPUT_RESIGNAL): These are now in blockinput.h.
(x_input_blocked, x_pending_input): Deleted; there are analogs
in blockinput.h called interrupt_input_blocked and
interrupt_input_pending.
* keyboard.c (interrupt_input_blocked, interrupt_input_pending):
New variables, used by the macros in blockinput.h.
* xterm.c: #include blockinput.h.
(x_input_blocked, x_pending_input): Deleted.
(XTread_socket): Test and set interrupt_input_blocked and
interrupt_input_pending instead of the old variables.
* alloc.c, xfaces.c, xfns.c, xmenu.c, xselect.c, keymap.c:
#include blockinput.h.
* eval.c: #include blockinput.h instead of xterm.h.
* keyboard.c: #include blockinput.h.
(input_poll_signal): Just test
interrupt_input_blocked, instead of testing HAVE_X_WINDOWS and
x_input_blocked.
Block the processing of interrupt input while we're manipulating the
malloc heap.
* alloc.c: (xfree): New function, to make it easy to free things
safely.
(xmalloc, xrealloc): Block X input while doing the deed.
(VALIDATE_LISP_STORAGE, gc_sweep, compact_strings): Use xfree
instead of free.
(uninterrupt_malloc): New function, to install input-blocking
hooks into the GNU malloc routines.
* emacs.c [not SYSTEM_MALLOC] (main): Call uninterrupt_malloc
on startup.
* alloc.c: (make_interval, make_float, Fcons, Fmake_vector,
Fmake_symbol, Fmake_marker, make_uninit_string, Fgarbage_collect):
Use xmalloc instead of malloc; don't bother to check if out of
memory here.
(Fgarbage_collect): Call xrealloc instead of realloc.
* buffer.c: Use xmalloc and xfree instead of malloc and free;
don't bother to check if out of memory here.
(Fget_buffer_create): Put BLOCK_INPUT/UNBLOCK_INPUT pair around
calls to ralloc routines.
* insdel.c: Same.
* lisp.h (xfree): New extern declaration.
* xfaces.c (xfree): Don't #define this to be free; use the
definition in alloc.c.
* dispnew.c, doc.c, doprnt.c, fileio.c, lread.c, term.c, xfns.c,
xmenu.c, xterm.c: Use xfree instead of free.
* hftctl.c: Use xfree and xmalloc instead of free and malloc.
* keymap.c (current_minor_maps): BLOCK_INPUT while calling realloc
and malloc.
* search.c: Since the regexp routines can malloc, BLOCK_INPUT
while runing them. #include blockinput.h.
* sysdep.c: #include blockinput.h. Call xfree and xmalloc instead
of free and malloc. BLOCK_INPUT around routines which we know
will call malloc.
ymakefile (keyboard.o, keymap.o, search.o, sysdep.o, xfaces.o,
xfns.o, xmenu.o, xterm.o, xselect.o, alloc.o, eval.o): Note that
these depend on blockinput.h.
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Wed, 31 Mar 1993 10:55:33 +0000 |
parents | bc2f7dc78412 |
children | 5f41134610a6 |
comparison
equal
deleted
inserted
replaced
2438:b513de4de386 | 2439:b6c62e4abf59 |
---|---|
21 #include <signal.h> | 21 #include <signal.h> |
22 #include <setjmp.h> | 22 #include <setjmp.h> |
23 | 23 |
24 #include "config.h" | 24 #include "config.h" |
25 #include "lisp.h" | 25 #include "lisp.h" |
26 #include "blockinput.h" | |
26 #undef NULL | 27 #undef NULL |
27 | 28 |
28 #define min(x,y) ((x) > (y) ? (y) : (x)) | 29 #define min(x,y) ((x) > (y) ? (y) : (x)) |
29 | 30 |
30 /* In this file, open, read and write refer to the system calls, | 31 /* In this file, open, read and write refer to the system calls, |
485 parent_id = getppid (); | 486 parent_id = getppid (); |
486 } | 487 } |
487 else | 488 else |
488 parent_id = getppid (); | 489 parent_id = getppid (); |
489 | 490 |
490 free (fpid_string); /* On VMS, this was malloc'd */ | 491 xfree (fpid_string); /* On VMS, this was malloc'd */ |
491 | 492 |
492 if (parent_id && parent_id != 0xffffffff) | 493 if (parent_id && parent_id != 0xffffffff) |
493 { | 494 { |
494 SIGTYPE (*oldsig)() = (int) signal (SIGINT, SIG_IGN); | 495 SIGTYPE (*oldsig)() = (int) signal (SIGINT, SIG_IGN); |
495 int status = LIB$ATTACH (&parent_id) & 1; | 496 int status = LIB$ATTACH (&parent_id) & 1; |
2355 char *pathname; | 2356 char *pathname; |
2356 { | 2357 { |
2357 char *npath, *spath; | 2358 char *npath, *spath; |
2358 extern char *getcwd (); | 2359 extern char *getcwd (); |
2359 | 2360 |
2361 BLOCK_INPUT; /* getcwd uses malloc */ | |
2360 spath = npath = getcwd ((char *) 0, MAXPATHLEN); | 2362 spath = npath = getcwd ((char *) 0, MAXPATHLEN); |
2361 /* On Altos 3068, getcwd can return @hostname/dir, so discard | 2363 /* On Altos 3068, getcwd can return @hostname/dir, so discard |
2362 up to first slash. Should be harmless on other systems. */ | 2364 up to first slash. Should be harmless on other systems. */ |
2363 while (*npath && *npath != '/') | 2365 while (*npath && *npath != '/') |
2364 npath++; | 2366 npath++; |
2365 strcpy (pathname, npath); | 2367 strcpy (pathname, npath); |
2366 free (spath); /* getcwd uses malloc */ | 2368 free (spath); /* getcwd uses malloc */ |
2369 UNBLOCK_INPUT; | |
2367 return pathname; | 2370 return pathname; |
2368 } | 2371 } |
2369 | 2372 |
2370 #endif /* HAVE_GETWD */ | 2373 #endif /* HAVE_GETWD */ |
2371 | 2374 |
2611 int | 2614 int |
2612 closedir (dirp) | 2615 closedir (dirp) |
2613 register DIR *dirp; /* stream from opendir */ | 2616 register DIR *dirp; /* stream from opendir */ |
2614 { | 2617 { |
2615 sys_close (dirp->dd_fd); | 2618 sys_close (dirp->dd_fd); |
2616 free ((char *) dirp->dd_buf); /* directory block defined in <dirent.h> */ | 2619 xfree ((char *) dirp->dd_buf); /* directory block defined in <dirent.h> */ |
2617 free ((char *) dirp); | 2620 xfree ((char *) dirp); |
2618 } | 2621 } |
2619 #endif /* not AIX */ | 2622 #endif /* not AIX */ |
2620 #endif /* SYSV_SYSTEM_DIR */ | 2623 #endif /* SYSV_SYSTEM_DIR */ |
2621 | 2624 |
2622 #ifdef NONSYSTEM_DIR_LIBRARY | 2625 #ifdef NONSYSTEM_DIR_LIBRARY |
2631 | 2634 |
2632 fd = sys_open (filename, 0); | 2635 fd = sys_open (filename, 0); |
2633 if (fd < 0) | 2636 if (fd < 0) |
2634 return 0; | 2637 return 0; |
2635 | 2638 |
2639 BLOCK_INPUT; | |
2636 if (fstat (fd, &sbuf) < 0 | 2640 if (fstat (fd, &sbuf) < 0 |
2637 || (sbuf.st_mode & S_IFMT) != S_IFDIR | 2641 || (sbuf.st_mode & S_IFMT) != S_IFDIR |
2638 || (dirp = (DIR *) malloc (sizeof (DIR))) == 0) | 2642 || (dirp = (DIR *) malloc (sizeof (DIR))) == 0) |
2639 { | 2643 { |
2640 sys_close (fd); | 2644 sys_close (fd); |
2645 UNBLOCK_INPUT; | |
2641 return 0; /* bad luck today */ | 2646 return 0; /* bad luck today */ |
2642 } | 2647 } |
2648 UNBLOCK_INPUT; | |
2643 | 2649 |
2644 dirp->dd_fd = fd; | 2650 dirp->dd_fd = fd; |
2645 dirp->dd_loc = dirp->dd_size = 0; /* refill needed */ | 2651 dirp->dd_loc = dirp->dd_size = 0; /* refill needed */ |
2646 | 2652 |
2647 return dirp; | 2653 return dirp; |
2650 void | 2656 void |
2651 closedir (dirp) | 2657 closedir (dirp) |
2652 register DIR *dirp; /* stream from opendir */ | 2658 register DIR *dirp; /* stream from opendir */ |
2653 { | 2659 { |
2654 sys_close (dirp->dd_fd); | 2660 sys_close (dirp->dd_fd); |
2655 free ((char *) dirp); | 2661 xfree ((char *) dirp); |
2656 } | 2662 } |
2657 | 2663 |
2658 | 2664 |
2659 #ifndef VMS | 2665 #ifndef VMS |
2660 #define DIRSIZ 14 | 2666 #define DIRSIZ 14 |
3114 char *ptr; | 3120 char *ptr; |
3115 extern char *getcwd (); | 3121 extern char *getcwd (); |
3116 | 3122 |
3117 #define MAXPATHLEN 1024 | 3123 #define MAXPATHLEN 1024 |
3118 | 3124 |
3119 ptr = malloc (MAXPATHLEN); | 3125 ptr = xmalloc (MAXPATHLEN); |
3120 getcwd (ptr, MAXPATHLEN); | 3126 getcwd (ptr, MAXPATHLEN); |
3121 strcpy (pathname, ptr); | 3127 strcpy (pathname, ptr); |
3122 free (ptr); | 3128 xfree (ptr); |
3123 | 3129 |
3124 return pathname; | 3130 return pathname; |
3125 } | 3131 } |
3126 | 3132 |
3127 getppid () | 3133 getppid () |