Mercurial > hg > xemacs-beta
view src/systty.h @ 5169:6c6d78781d59
cleanup of code related to xfree(), better KKCC backtrace capabilities, document XD_INLINE_LISP_OBJECT_BLOCK_PTR, fix some memory leaks, other code cleanup
-------------------- ChangeLog entries follow: --------------------
src/ChangeLog addition:
2010-03-24 Ben Wing <ben@xemacs.org>
* array.h:
* array.h (XD_LISP_DYNARR_DESC):
* dumper.c (pdump_register_sub):
* dumper.c (pdump_store_new_pointer_offsets):
* dumper.c (pdump_reloc_one_mc):
* elhash.c:
* gc.c (lispdesc_one_description_line_size):
* gc.c (kkcc_marking):
* lrecord.h:
* lrecord.h (IF_NEW_GC):
* lrecord.h (enum memory_description_type):
* lrecord.h (enum data_description_entry_flags):
* lrecord.h (struct opaque_convert_functions):
Rename XD_LISP_OBJECT_BLOCK_PTR to XD_INLINE_LISP_OBJECT_BLOCK_PTR
and document it in lrecord.h.
* data.c:
* data.c (finish_marking_weak_lists):
* data.c (continue_marking_ephemerons):
* data.c (finish_marking_ephemerons):
* elhash.c (MARK_OBJ):
* gc.c:
* gc.c (lispdesc_indirect_count_1):
* gc.c (struct):
* gc.c (kkcc_bt_push):
* gc.c (kkcc_gc_stack_push):
* gc.c (kkcc_gc_stack_push_lisp_object):
* gc.c (kkcc_gc_stack_repush_dirty_object):
* gc.c (KKCC_DO_CHECK_FREE):
* gc.c (mark_object_maybe_checking_free):
* gc.c (mark_struct_contents):
* gc.c (mark_lisp_object_block_contents):
* gc.c (register_for_finalization):
* gc.c (mark_object):
* gc.h:
* lisp.h:
* profile.c:
* profile.c (mark_profiling_info_maphash):
Clean up KKCC code related to DEBUG_XEMACS. Rename
kkcc_backtrace() to kkcc_backtrace_1() and add two params: a
`size' arg to control how many stack elements to print and a
`detailed' arg to control whether Lisp objects are printed using
`debug_print()'. Create front-ends to kkcc_backtrace_1() --
kkcc_detailed_backtrace(), kkcc_short_backtrace(),
kkcc_detailed_backtrace_full(), kkcc_short_backtrace_full(), as
well as shortened versions kbt(), kbts(), kbtf(), kbtsf() -- to
call it with various parameter values. Add an `is_lisp' field to
the stack and backtrace structures and use it to keep track of
whether an object pushed onto the stack is a Lisp object or a
non-Lisp structure; in kkcc_backtrace_1(), don't try to print a
non-Lisp structure as a Lisp object.
* elhash.c:
* extents.c:
* file-coding.c:
* lrecord.h:
* lrecord.h (IF_NEW_GC):
* marker.c:
* marker.c (Fmarker_buffer):
* mule-coding.c:
* number.c:
* rangetab.c:
* specifier.c:
New macros IF_OLD_GC(), IF_NEW_GC() to simplify declaration of
Lisp objects when a finalizer may exist in one but not the other.
Use them appropriately.
* extents.c (finalize_extent_info):
Don't zero out data->soe and data->extents before trying to free,
else we get memory leaks.
* lrecord.h (enum lrecord_type):
Make the first lrecord type have value 1 not 0 so that 0 remains
without implementation and attempts to interpret zeroed memory
as a Lisp object will be more obvious.
* array.c (Dynarr_free):
* device-msw.c (msprinter_delete_device):
* device-tty.c (free_tty_device_struct):
* device-tty.c (tty_delete_device):
* dialog-msw.c (handle_directory_dialog_box):
* dialog-x.c:
* emacs.c (free_argc_argv):
* emodules.c (attempt_module_delete):
* file-coding.c (chain_finalize_coding_stream_1):
* file-coding.c (chain_finalize_coding_stream):
* glyphs-eimage.c:
* glyphs-eimage.c (jpeg_instantiate_unwind):
* glyphs-eimage.c (gif_instantiate_unwind):
* glyphs-eimage.c (png_instantiate_unwind):
* glyphs-eimage.c (tiff_instantiate_unwind):
* imgproc.c:
* imgproc.c (build_EImage_quantable):
* insdel.c (uninit_buffer_text):
* mule-coding.c (iso2022_finalize_detection_state):
* objects-tty.c (tty_finalize_color_instance):
* objects-tty.c (tty_finalize_font_instance):
* objects-tty.c (tty_font_list):
* process.c:
* process.c (finalize_process):
* redisplay.c (add_propagation_runes):
* scrollbar-gtk.c:
* scrollbar-gtk.c (gtk_free_scrollbar_instance):
* scrollbar-gtk.c (gtk_release_scrollbar_instance):
* scrollbar-msw.c:
* scrollbar-msw.c (mswindows_free_scrollbar_instance):
* scrollbar-msw.c (unshow_that_mofo):
* scrollbar-x.c (x_free_scrollbar_instance):
* scrollbar-x.c (x_release_scrollbar_instance):
* select-x.c:
* select-x.c (x_handle_selection_request):
* syntax.c:
* syntax.c (uninit_buffer_syntax_cache):
* text.h (eifree):
If possible, whenever we call xfree() on a field in a structure,
set the field to 0 afterwards. A lot of code is written so that
it checks the value being freed to see if it is non-zero before
freeing it -- doing this and setting the value to 0 afterwards
ensures (a) we won't try to free twice if the cleanup code is
called twice; (b) if the object itself stays around, KKCC won't
crash when attempting to mark the freed field.
* rangetab.c:
Add a finalization method when not NEW_GC to avoid memory leaks.
(#### We still get memory leaks when NEW_GC; need to convert gap
array to Lisp object).
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Wed, 24 Mar 2010 01:22:51 -0500 |
parents | aa5ed11f473b |
children | 308d34e9f07d |
line wrap: on
line source
/* systty.h - System-dependent definitions for terminals. Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. This file is part of XEmacs. XEmacs is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. XEmacs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with XEmacs; see the file COPYING. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Synched up with: FSF 19.30. */ #ifndef INCLUDED_systty_h_ #define INCLUDED_systty_h_ #ifdef HAVE_TERMIOS # define HAVE_TCATTR #endif /* Include the proper files. */ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif /* XEmacs: TERMIOS is mo' better than TERMIO so we use it if it's there. Since TERMIO is backward-compatibility stuff if both it and TERMIOS exist, it's more likely to be broken. */ #if defined (HAVE_TERMIOS) /***** (1) The TERMIOS way (POSIX style) *****/ # if defined (_AIX) && defined (_I386) # include <termios.h> /* termios.h needs to be before termio.h */ # include <termio.h> # else # if !defined (NO_TERMIO) # include <termio.h> # endif # include <termios.h> # endif /* _AIX && _I386 */ # ifndef INCLUDED_FCNTL # define INCLUDED_FCNTL # include <fcntl.h> # endif #elif defined (HAVE_TERMIO) /***** (2) The TERMIO way (system V style) *****/ # ifndef NO_TERMIO # include <termio.h> # endif /* not NO_TERMIO */ # ifndef INCLUDED_FCNTL # define INCLUDED_FCNTL # include <fcntl.h> # endif #elif defined (WIN32_NATIVE) /***** (3) The WIN32_NATIVE way *****/ /* Nothing doing */ #else /***** (4) The BSD way *****/ # ifdef linux /* XEmacs addition -- necessary? */ # include <bsd/sgtty.h> # else # include <sgtty.h> # endif #endif /* HAVE_TERMIOS */ /* XEmacs: I don't think we need the following crap. */ #ifdef __GNU_LIBRARY__ #include <termios.h> #endif /* Formerly there was a conditional that included sys/filio.h if USG5_4 was defined, but this is already included in s/usg5-4.h */ /* Generally useful to include this file: */ #if !defined (WIN32_NATIVE) # include <sys/ioctl.h> #endif /* ----------------------------------------------------- */ /* miscellaneous includes */ /* ----------------------------------------------------- */ /* Include files for PTY's */ #if defined (HAVE_SYS_PTYIO_H) /* HP-UX */ #include <sys/ptyio.h> #endif #if defined (HAVE_PTY_H) #include <pty.h> #elif defined (HAVE_SYS_PTY_H) #include <sys/pty.h> #endif /* XEmacs: removed some random if defined (pfa) crap for FASYNC (SIGIO). We've cleaned SIGIO up. */ /* ----------------------------------------------------- */ /* inhibiting particular features */ /* ----------------------------------------------------- */ #if defined (BROKEN_TIOCGETC) #undef TIOCGETC /* Avoid confusing some conditionals that test this. */ #endif /* XEmacs: SIGIO is cleaned up so we remove the crap here that messes with it (and FIONREAD and FASYNC, which are related). */ /* On TERMIOS systems, the tcmumbleattr calls take care of these parameters, and it's a bad idea to use them (on AIX, it makes the tty hang for a long time). */ #if defined (TIOCGLTC) && !defined (HAVE_TERMIOS) #define HAVE_LTCHARS #endif #if defined (TIOCGETC) && !defined (HAVE_TERMIOS) #define HAVE_TCHARS #endif /* ----------------------------------------------------- */ /* disabling terminal functions */ /* ----------------------------------------------------- */ /* Try to establish the correct character to disable terminal functions in a system-independent manner. We use the POSIX standard way to do this, and emulate on other systems. */ #ifndef _POSIX_VDISABLE # if defined CDEL # define _POSIX_VDISABLE CDEL # else # define _POSIX_VDISABLE 255 # endif #endif /* ! _POSIX_VDISABLE */ /* ----------------------------------------------------- */ /* Get the number of characters queued for output */ /* ----------------------------------------------------- */ /* EMACS_OUTQSIZE(FD, int *SIZE) stores the number of characters queued for output to the terminal FD in *SIZE, if FD is a tty. Returns -1 if there was an error (i.e. FD is not a tty), 0 otherwise. */ #ifdef TIOCOUTQ #define EMACS_OUTQSIZE(fd, size) ioctl (fd, TIOCOUTQ, size) #endif #ifdef HAVE_TERMIO #ifdef TCOUTQ #undef EMACS_OUTQSIZE #define EMACS_OUTQSIZE(fd, size) ioctl (fd, TCOUTQ, size) #endif #endif /* -------------------------------------------------------------------- */ /* Manipulate a terminal's current (foreground) process group */ /* -------------------------------------------------------------------- */ /* EMACS_GET_TTY_PGRP(int FD, pid_t *PGID) sets *PGID to the terminal FD's current foreground process group. Return -1 if there is an error. EMACS_SET_TTY_PGRP(int FD, pid_t *PGID) sets the terminal FD's current foreground process group to *PGID. Return -1 if there is an error. We prefer using the ioctl (BSD) interface instead of its Posix replacement tgetpgrp/tcsetpgrp since that is documented as being restricted to processes sharing the same controlling tty. */ #if defined (TIOCGPGRP) #define EMACS_GET_TTY_PROCESS_GROUP(fd, pgid) ioctl (fd, TIOCGPGRP, pgid) #define EMACS_SET_TTY_PROCESS_GROUP(fd, pgid) ioctl (fd, TIOCSPGRP, pgid) #elif defined (HAVE_TCGETPGRP) #define EMACS_GET_TTY_PROCESS_GROUP(fd, pgid) (*(pgid) = tcgetpgrp (fd)) #define EMACS_SET_TTY_PROCESS_GROUP(fd, pgid) tcsetpgrp (fd, *(pgid)) #else /* Just ignore this for now and hope for the best */ #define EMACS_GET_TTY_PROCESS_GROUP(fd, pgid) 0 #define EMACS_SET_TTY_PROCESS_GROUP(fd, pgif) 0 #endif /* EMACS_GETPGRP (arg) returns the process group of the terminal. */ #ifdef GETPGRP_VOID #define EMACS_GETPGRP(x) getpgrp() #else #define EMACS_GETPGRP(x) getpgrp(x) #endif /* GETPGRP_VOID */ /* XEmacs backward-compatibility. Is 0 always a reasonable argument? */ #define EMACS_GET_PROCESS_GROUP() EMACS_GETPGRP (0) /* XEmacs addition? */ /* EMACS_SEPARATE_PROCESS_GROUP () creates a separate process group for the running process. */ /* EMACS_SET_PROCESS_GROUP () sets our process group as specified. */ /* POSIX calls for setpgid(), so we use it if it's available. Otherwise use setpgrp(), in USG or BSD flavor. Note that on newer systems, setpgrp() has unwanted effects (e.g. creating a new session), so we want to avoid its use if possible. NOTE: On some older systems, we should consider using setpgrp2() if it exists. This is sufficiently rare, though, that there seems no point in autodetecting it. Currently dgux.h is the only place where this has to be munged. */ #if defined (HAVE_SETPGID) # define EMACS_SEPARATE_PROCESS_GROUP() setpgid (0, 0) # define EMACS_SET_PROCESS_GROUP(pg) setpgid (0, pg) #elif defined (USG) # define EMACS_SEPARATE_PROCESS_GROUP() setpgrp () /* old (pre-SVR4) USG's don't provide any way to do this. No big loss -- it just means that ^Z won't work right if we're run from sh. */ # define EMACS_SET_PROCESS_GROUP(pg) #elif defined (WIN32_NATIVE) # define EMACS_SEPARATE_PROCESS_GROUP() #else /* Under NeXTstep, a process group of 0 is not the same as specifying your own process ID, so we go ahead and specify it explicitly. */ # define EMACS_SEPARATE_PROCESS_GROUP() setpgrp (0, getpid ()) # define EMACS_SET_PROCESS_GROUP(pg) setpgrp (0, pg) #endif /* --------------------------------------------------------- */ /* Manipulate a TTY's input/output processing parameters */ /* --------------------------------------------------------- */ /* struct emacs_tty is a structure used to hold the current tty parameters. If the terminal has several structures describing its state, for example a struct tchars, a struct sgttyb, a struct tchars, a struct ltchars, and a struct pagechars, struct emacs_tty should contain an element for each parameter struct that Emacs may change. emacs_get_tty (int FD, struct emacs_tty *P) stores the parameters of the tty on FD in *P. Return zero if all's well, or -1 if we ran into an error we couldn't deal with. emacs_set_tty (int FD, struct emacs_tty *P, int flushp) sets the parameters of the tty on FD according to the contents of *P. If flushp is non-zero, we discard queued input to be written before making the change. Return 0 if all went well, and -1 if anything failed. EMACS_TTY_TABS_OK (struct emacs_tty *P) is false iff the kernel expands tabs to spaces upon output; in that case, there is no advantage to using tabs over spaces. */ /* For each tty parameter structure that Emacs might want to save and restore, - include an element for it in this structure, and - extend the emacs_{get,set}_tty functions in sysdep.c to deal with the new members. */ struct emacs_tty { /* There is always one of the following elements, so there is no need for dummy get and set definitions. */ #ifdef HAVE_TCATTR struct termios main; #else /* !HAVE_TCATTR */ #ifdef HAVE_TERMIO struct termio main; #else /* !HAVE_TERMIO */ #ifdef WIN32_NATIVE int main; #else /* not WIN32_NATIVE */ struct sgttyb main; #endif /* not WIN32_NATIVE */ #endif /* !HAVE_TERMIO */ #endif /* !HAVE_TCATTR */ /* If we have TERMIOS, we don't need to do this - they're taken care of by the tc*attr calls. */ #ifndef HAVE_TERMIOS #ifdef HAVE_LTCHARS struct ltchars ltchars; #endif /* HAVE_LTCHARS */ #ifdef HAVE_TCHARS struct tchars tchars; int lmode; #endif /* HAVE_TCHARS */ #endif /* HAVE_TERMIOS */ }; int emacs_get_tty (int fd, struct emacs_tty *settings); int emacs_set_tty (int fd, struct emacs_tty *settings, int flushp); /* --------------------------------------------------------- */ /* Define EMACS_TTY_TABS_OK */ /* --------------------------------------------------------- */ #if defined (TABDLY) && defined (TAB3) # define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & TABDLY) != TAB3) #elif defined (OXTABS) # define EMACS_TTY_TABS_OK(p) (((p)->main.c_oflag & OXTABS) != OXTABS) #else # define EMACS_TTY_TABS_OK(p) 1 #endif #endif /* INCLUDED_systty_h_ */