1. 10 Nov, 2011 1 commit
    • Paul Eggert's avatar
      Standardize on VIRT_ADDR_VARIES behavior; otherwise, valgrind · 6a0bf43d
      Paul Eggert authored
      does not work on some platforms.  Problem reported by Andreas Schwab in
      * puresize.h (pure, PURE_P): Always behave as if VIRT_ADDR_VARIES
      is set, removing the need for VIRT_ADDRESS_VARIES.
      (PURE_P): Use a more-efficient implementation that needs just one
      comparison, not two: on x86-64 with GCC 4.6.2, this cut down the
      number of instructions from 6 (xorl, cmpq, jge, xorl, cmpq, setge)
      to 4 (xorl, subq, cmpq, setbe).
      * alloc.c (pure): Always extern now, since that's the
      VIRT_ADDR_VARIES behavior.
      (PURE_POINTER_P): Use a single comparison, not two, for
      consistency with the new puresize.h.
      * lisp.h (PNTR_COMPARISON_TYPE): Remove; no longer needed.
      * m/ibms390.h, m/intel386.h, m/template.h, s/cygwin.h, s/hpux10-20.h:
      Remove VIRT_ADDR_VARIES no longer needed.
  2. 07 Nov, 2011 1 commit
  3. 05 Nov, 2011 1 commit
    • Eli Zaretskii's avatar
      Support MSVC build with newer versions of Visual Studio. · a6fc3b5c
      Eli Zaretskii authored
      Small portions of the changes by Fabrice Popineau <fabrice.popineau@supelec.fr>.
       src/makefile.w32-in (TAGS-gmake): Don't use $(patsubst ...), as
       Nmake barfs on that.  Use $(OBJ*_c) variables instead, defined on
       src/lisp.h (ENUM_BF): New macro, for enumerated types in bitfields,
       which are not supported by MSVC.
       (Lisp_Symbol, Lisp_Misc_Any, Lisp_Marker, Lisp_Misc_Overlay)
       (Lisp_Save_Value, Lisp_Free): Use ENUM_BF for enumerated types in
       (Lisp_Object) [USE_LISP_UNION_TYPE]: Use ENUM_BF for enumerated
       types in bitfields.
       (DEFUN) [_MSC_VER]: Define in a different way for MSVC.
       src/w32fns.c [_MSC_VER]: DECLARE_HANDLE for any MSVC version.
       src/w32.c: Don't include w32api.h for MSVC.
       (init_environment) [_MSC_VER]: Call sys_access, not _access.
       src/s/ms-w32.h <sigset_t, ssize_t> [_MSC_VER]: Typedefs for MSVC.
       [_MSC_VER]: Include sys/timeb.h, sys/stat.h, and signal.h.
       (fstat, stat, utime) [_MSC_VER]: Redirect to their sys_* cousins.
       (malloc, free, realloc, calloc) [_MSC_VER]: Always redirect to the
       e_* cousins.
       (alloca) [_MSC_VER]: Define to _alloca.
       src/lisp.h (DECL_ALIGN) [_MSC_VER]: Define for MSVC.
       src/regex.c <re_char> [_MSC_VER]: A separate definition for MSVC.
       nt/makefile.w32-in (clean-other-dirs-nmake)
       (distclean-other-dirs-nmake, maintainer-clean-other-dirs-nmake):
       Update for current structure of doc/ subdirectories.
       nt/gmake.defs (OBJ0_c, OBJ1_c, OBJ2_c): New variables.
       nt/INSTALL: Update for newer versions of MSVC.
       lib/makefile.w32-in (FRC): New dummy target.
       (TAGS): Depend on FRC.
      Fixes: debbugs:9960
  4. 28 Oct, 2011 1 commit
  5. 11 Oct, 2011 1 commit
  6. 30 Sep, 2011 2 commits
    • Paul Eggert's avatar
      Remove dependency on glibc malloc internals. · f701dc2a
      Paul Eggert authored
      Move back here from lisp.h, but with their new implementations.
      (XMALLOC_OVERRUN_SIZE_SIZE): Move these new lisp.h macros here.
      * charset.c (charset_table_init): New static var.
      (syms_of_charset): Use it instead of xmalloc.  This removes a
      dependency on glibc malloc internals.  See Eli Zaretskii's comment in
      Move back to alloc.c.
      (XMALLOC_OVERRUN_SIZE_SIZE): Move to alloc.c.
    • Paul Eggert's avatar
      Port --enable-checking=all to Fedora 14 x86. · cb993c58
      Paul Eggert authored
      Move to lisp.h.
      (xmalloc_put_size, xmalloc_get_size, overrun_check_malloc)
      (overrun_check_realloc, overrun_check_free):
      Use XMALLOC_OVERRUN_SIZE_SIZE, not sizeof (size_t).
      That way, xmalloc returns a properly-aligned pointer even if
      XMALLOC_OVERRUN_CHECK is defined.  The old debugging code happened
      to align OK on typical 64-bit hosts, but not on Fedora 14 x86.
      * charset.c (syms_of_charset): Take XMALLOC_OVERRUN_CHECK_OVERHEAD
      into account when calculating the initial malloc maximum.
      Move here from alloc.c, so that charset.c can use it too.
      Properly align; the old code wasn't right for common 32-bit hosts
      when configured with --enable-checking=all.
      (XMALLOC_OVERRUN_SIZE_SIZE): New macros.
  7. 11 Sep, 2011 1 commit
  8. 09 Sep, 2011 1 commit
  9. 01 Sep, 2011 1 commit
  10. 29 Aug, 2011 1 commit
    • Paul Eggert's avatar
      sprintf-related integer and memory overflow issues. · 62f19c19
      Paul Eggert authored
      * doprnt.c (doprnt): Support printing ptrdiff_t and intmax_t values.
      (esprintf, esnprintf, exprintf, evxprintf): New functions.
      * keyboard.c (command_loop_level): Now EMACS_INT, not int.
      (cmd_error): kbd macro iterations count is now EMACS_INT, not int.
      (modify_event_symbol): Do not assume that the length of
      name_alist_or_stem is safe to alloca and fits in int.
      (Fexecute_extended_command): Likewise for function name and binding.
      (Frecursion_depth): Wrap around reliably on integer overflow.
      * keymap.c (push_key_description): First arg is now EMACS_INT, not int,
      since some callers pass EMACS_INT values.
      (Fsingle_key_description): Don't crash if symbol name contains more
      than MAX_ALLOCA bytes.
      * minibuf.c (minibuf_level): Now EMACS_INT, not int.
      (get_minibuffer): Arg is now EMACS_INT, not int.
      * lisp.h (get_minibuffer, push_key_description): Reflect API changes.
      (esprintf, esnprintf, exprintf, evxprintf): New decls.
      * window.h (command_loop_level, minibuf_level): Reflect API changes.
  11. 05 Aug, 2011 1 commit
  12. 03 Aug, 2011 1 commit
  13. 02 Aug, 2011 1 commit
  14. 28 Jul, 2011 1 commit
    • Paul Eggert's avatar
      Integer and memory overflow fixes for display code. · ca9ce8f2
      Paul Eggert authored
      * dispextern.h (struct glyph_pool.nglyphs): Now ptrdiff_t, not int.
      * dispnew.c (adjust_glyph_matrix, realloc_glyph_pool, scrolling_window):
      Check for overflow in size calculations.
      (line_draw_cost, realloc_glyph_pool, add_row_entry):
      Don't assume glyph table len fits in int.
      (struct row_entry.bucket, row_entry_pool_size, row_entry_idx)
      (row_table_size): Now ptrdiff_t, not int.
      (scrolling_window): Avoid overflow in size calculations.
      Don't update size until allocation succeeds.
      * fns.c (concat): Check for overflow in size calculations.
      (next_almost_prime): Verify NEXT_ALMOST_PRIME_LIMIT.
      * lisp.h (RANGED_INTEGERP, TYPE_RANGED_INTEGERP): New macros.
      (NEXT_ALMOST_PRIME_LIMIT): New constant.
  15. 19 Jul, 2011 1 commit
    • Paul Eggert's avatar
      Use ptrdiff_t for hash table indexes. · d3411f89
      Paul Eggert authored
      * category.c (hash_get_category_set):
      * ccl.c (ccl_driver):
      * charset.h (struct charset.hash_index, CHECK_CHARSET_GET_ID):
      * coding.c (coding_system_charset_list, detect_coding_system):
      * coding.h (struct coding_system.id):
      * composite.c (get_composition_id, gstring_lookup_cache):
      * fns.c (hash_lookup, hash_put, Fgethash, Fputhash):
      * image.c (xpm_get_color_table_h):
      * lisp.h (hash_lookup, hash_put):
      * minibuf.c (Ftest_completion):
      Use ptrdiff_t for hash table indexes, not int (which is too
      narrow, on 64-bit hosts) or EMACS_INT (which is too wide, on
      32-bit --with-wide-int hosts).
  16. 08 Jul, 2011 1 commit
    • Paul Eggert's avatar
      Improve hashing quality when configured --with-wide-int. · 3cc5a532
      Paul Eggert authored
      * fns.c (hash_string): New function, taken from sxhash_string.
      Do not discard information about ASCII character case; this
      discarding is no longer needed.
      (sxhash-string): Use it.  Change sig to match it.  Caller changed.
      * lisp.h: Declare it.
      * lread.c (hash_string): Remove, since we now use fns.c's version.
      The fns.c version returns a wider integer if --with-wide-int is
      specified, so this should help the quality of the hashing a bit.
  17. 07 Jul, 2011 2 commits
    • Paul Eggert's avatar
      * editfns.c (pWIDE, pWIDElen, signed_wide, unsigned_wide): · a81d11a3
      Paul Eggert authored
      Remove, replacing with the new symbols in lisp.h.  All uses changed.
      * fileio.c (make_temp_name):
      * filelock.c (lock_file_1, lock_file):
      * xdisp.c (message_dolog):
      Don't assume PRIdMAX etc. works; this isn't portable to pre-C99 hosts.
      Use pMd etc. instead.
      * lisp.h (printmax_t, uprintmax_t, pMd, pMu): New types and macros,
      replacing the pWIDE etc. symbols removed from editfns.c.
    • Paul Eggert's avatar
      * doprnt.c: Prefer signed to unsigned when either works. · c2d1e36d
      Paul Eggert authored
      * eval.c (verror):
      * doprnt.c (doprnt):
      * lisp.h (doprnt):
      * xdisp.c (vmessage):
      Use ptrdiff_t, not size_t, when using or implementing doprnt,
      since the sizes cannot exceed ptrdiff_t bounds anyway, and we
      prefer signed arithmetic to avoid comparison confusion.
      * doprnt.c (doprnt): Avoid a "+ 1" that can't overflow,
      but is a bit tricky.
  18. 05 Jul, 2011 2 commits
    • Paul Eggert's avatar
      [ChangeLog] · 9cfdb3ec
      Paul Eggert authored
      Assume support for memcmp, memcpy, memmove, memset.
      This simplifies the code a bit.  All current platforms have these,
      as they are required for C89.  If this turns into a problem we
      can add the gnulib modules for these (a 1-line change to Makefile.in).
      * configure.in: Don't check for memcmp, memcpy, memmove, memset.
      Assume support for memcmp, memcpy, memmove, memset.
      * etags.c (absolute_filename): Assume memmove exists.
      Assume support for memcmp, memcpy, memmove, memset.
      * lisp.h, sysdep.c (memcmp, memcpy, memmove, memset):
      * regex.c (memcmp, memcpy):
      Remove; we assume C89 now.
      * gmalloc.c (memcpy, memset, memmove): Remove; we assume C89 now.
      (__malloc_safe_bcopy): Remove; no longer needed.
    • Paul Eggert's avatar
      * lisp.h (struct vectorlike_header, struct Lisp_Subr): Signed sizes. · 6089c567
      Paul Eggert authored
      Use EMACS_INT, not EMACS_UINT, for sizes.  The code works equally
      well either way, and we prefer signed to unsigned.
  19. 24 Jun, 2011 1 commit
  20. 23 Jun, 2011 1 commit
  21. 22 Jun, 2011 1 commit
    • Paul Eggert's avatar
      * dispextern.h (struct face.stipple): · 0766b489
      Paul Eggert authored
      * image.c (x_bitmap_height, x_bitmap_width, x_bitmap_pixmap)
      (x_bitmap_mask, x_allocate_bitmap_record)
      (x_create_bitmap_from_data, x_create_bitmap_from_file)
      (x_destroy_bitmap, x_destroy_all_bitmaps, x_create_bitmap_mask)
      * nsterm.h (struct ns_display_info.bitmaps_size, .bitmaps_last):
      * w32term.h (struct w32_display_info.icon_bitmap_id, .bitmaps_size)
      * xfaces.c (load_pixmap):
      * xterm.c (x_bitmap_icon, x_wm_set_icon_pixmap):
      * xterm.h (struct x_display_info.icon_bitmap_id, .bitmaps_size)
      (.bitmaps_last, struct x_output.icon_bitmap):
      Use ptrdiff_t, not int, for bitmap indexes.
      (x_allocate_bitmap_record): Check for size overflow.
      * dispextern.h, lisp.h: Adjust to API changes elsewhere.
  22. 19 Jun, 2011 3 commits
  23. 18 Jun, 2011 4 commits
  24. 16 Jun, 2011 2 commits
  25. 14 Jun, 2011 1 commit
    • Paul Eggert's avatar
      Variadic C functions now count arguments with ptrdiff_t. · f66c7cf8
      Paul Eggert authored
      This partly undoes my 2011-03-30 change, which replaced int with size_t.
      Back then I didn't know that the Emacs coding style prefers signed int.
      Also, in the meantime I found a few more instances where arguments
      were being counted with int, which may truncate counts on 64-bit
      machines, or EMACS_INT, which may be unnecessarily wide.
      * lisp.h (struct Lisp_Subr.function.aMANY)
      (DEFUN_ARGS_MANY, internal_condition_case_n, safe_call):
      Arg counts are now ptrdiff_t, not size_t.
      All variadic functions and their callers changed accordingly.
      (struct gcpro.nvars): Now size_t, not size_t.  All uses changed.
      * bytecode.c (exec_byte_code): Check maxdepth for overflow,
      to avoid potential buffer overrun.  Don't assume arg counts fit in 'int'.
      * callint.c (Fcall_interactively): Check arg count for overflow,
      to avoid potential buffer overrun.  Use signed char, not 'int',
      for 'varies' array, so that we needn't bother to check its size
      calculation for overflow.
      * editfns.c (Fformat): Use ptrdiff_t, not EMACS_INT, to count args.
      * eval.c (apply_lambda):
      * fns.c (Fmapconcat): Use XFASTINT, not XINT, to get args length.
      (struct textprop_rec.argnum): Now ptrdiff_t, not int.  All uses changed.
      (mapconcat): Use ptrdiff_t, not int and EMACS_INT, to count args.
  26. 13 Jun, 2011 2 commits
  27. 12 Jun, 2011 1 commit
    • Paul Eggert's avatar
      * lisp.h (UNSIGNED_CMP): New macro. · ea204efb
      Paul Eggert authored
      This fixes comparison bugs on 64-bit hosts.
      (ASCII_CHAR_P): Use it.
      * casefiddle.c (casify_object):
      * character.h (ASCII_BYTE_P, CHAR_VALID_P):
      * composite.h (COMPOSITION_ENCODE_RULE_VALID):
      * dispextern.h (FACE_FROM_ID):
      * keyboard.c (read_char): Use UNSIGNED_CMP.
  28. 11 Jun, 2011 2 commits
    • Paul Eggert's avatar
      * buffer.c (Qclone_number): Remove for now, as it's unused. · 4475bec4
      Paul Eggert authored
      (record_buffer, Funrecord_buffer): Rename local to avoid shadowing.
      (record_buffer): Remove unused local.
      * frame.c (other_visible_frames, frame_buffer_list): Now static.
      (set_frame_buffer_list): Remove; unused.
      * frame.h (other_visible_frames): Remove decl.
      * keyboard.h (menu_items_inuse): Declare only if USE_GTK || USE_MOTIF.
      * lisp.h (frame_buffer_list, set_frame_buffer_list): Remove decls.
      (add_gpm_wait_descriptor, delete_gpm_wait_descriptor): Declare only
      if HAVE_GPM.
      * menu.c (menu_items_inuse): Now static unless USE_GTK || USE_MOTIF.
      * process.c (add_gpm_wait_descriptor, delete_gpm_wait_descriptor):
      Define only if HAVE_GPM.
      * widget.c (EmacsFrameResize, emacsFrameClassRec): Now static.
      (update_hints_inhibit): Remove; never set.  All uses removed.
      * widgetprv.h (emacsFrameClassRec): Remove decl.
      * window.c (delete_deletable_window): Now returns void, since it
      wasn't returning anything.
      (compare_window_configurations): Remove unused locals.
      * xfns.c (x_set_scroll_bar_default_width): Remove unused locals.
      * xmenu.c (x_menu_set_in_use): Define only if USE_GTK || USE_MOTIF.
      Omit no-longer-needed #ifdef USE_X_TOOLKIT, since USE_X_TOOLKIT is
      implied by USE_GTK || USE_MOTIF.
      (dialog_selection_callback) [!USE_GTK]: Prefer intptr_t for integers
      the same widths as pointers.  This follows up on the 2011-05-06 patch.
      * xterm.c (x_alloc_lighter_color_for_widget): Define only if USE_LUCID.
      * xterm.h: Likewise.
      (x_menu_set_in_use): Declare only if USE_GTK || USE_MOTIF.
    • Martin Rudalics's avatar
      Move/add window-buffer-related functions to window.el. · 9397e56f
      Martin Rudalics authored
      * buffer.c: New Lisp objects Qbuffer_list_update_hook and
      Qclone_number.  Remove external declaration of Qdelete_window.
      (Fbuffer_list): Rewrite doc-string.  Minor restructuring of
      (Fget_buffer_create, Fmake_indirect_buffer, Frename_buffer): Run
      Qbuffer_list_update_hook if allowed.
      (Fother_buffer): Rewrite doc-string.  Major rewrite for new
      buffer list implementation.
      (other_buffer_safely): New function.
      (Fkill_buffer): Replace call to replace_buffer_in_all_windows by
      calls to replace_buffer_in_windows and
      replace_buffer_in_windows_safely.  Run Qbuffer_list_update_hook
      if allowed.
      (record_buffer): Inhibit quitting and rewrite using quittable
      functions.  Run Qbuffer_list_update_hook if allowed.
      (Frecord_buffer, Funrecord_buffer): New functions.
      (switch_to_buffer_1, Fswitch_to_buffer): Remove.  Move
      switch-to-buffer to window.el.
      (bury-buffer): Move to window.el.
      (Vbuffer_list_update_hook): New variable.
      * lisp.h (other_buffer_safely): Add prototype in buffer.c
      * window.h (resize_frame_windows): Move up in code.
      (Fwindow_frame): Remove EXFUN.
      (replace_buffer_in_all_windows): Remove prototype.
      (replace_buffer_in_windows_safely): Add prototype.
      * window.c: Declare Qdelete_window static again.  Move down
      declaration of select_count.
      (Fnext_window, Fprevious_window): Rewrite doc-strings.
      (Fother_window): Move to window.el.
      (window_loop): Remove DELETE_BUFFER_WINDOWS and UNSHOW_BUFFER
      (Fdelete_windows_on, Freplace_buffer_in_windows): Move to
      (replace_buffer_in_windows): Implement by calling
      (replace_buffer_in_all_windows): Remove with some functionality
      moved into replace_buffer_in_windows_safely.
      (replace_buffer_in_windows_safely): New function.
      (select_window_norecord, select_frame_norecord): Move in front
      of run_window_configuration_change_hook.  Remove now obsolete
      (Fset_window_buffer): Rewrite doc-string.  Call
      (keys_of_window): Move binding for other-window to window.el.
      * loadup.el (top-level): Load window before files for the sake
      of replace-buffer-in-windows.
      * files.el (read-buffer-to-switch)
      (switch-to-buffer-other-frame, display-buffer-other-frame): Move
      to window.el.
      * simple.el (get-next-valid-buffer, last-buffer, next-buffer)
      (previous-buffer): Move to window.el.
      * bindings.el (unbury-buffer): Move to window.el.
      * window.el (delete-other-windows-vertically): Move after
      definition of delete-other-windows.
      (other-window, delete-windows-on, replace-buffer-in-windows):
      Move here from window.c.
      (record-window-buffer, unrecord-window-buffer)
      (set-window-buffer-start-and-point, switch-to-prev-buffer)
      (switch-to-next-buffer): New functions.
      (get-next-valid-buffer, last-buffer, next-buffer): Move here
      from simple.el.  Call switch-to-next-buffer.
      (previous-buffer): Move here from simple.el.  Call
      (bury-buffer): Move here from buffer.c.  Switch to previous
      buffer when window cannot be deleted.
      (unbury-buffer): Move here from bindings.el.
      (ctl-x-map): Move binding for other-window from window.c to
      (read-buffer-to-switch, switch-to-buffer-other-window)
      (switch-to-buffer-other-frame): Move here from files.el.
      (normalize-buffer-to-switch-to): New functions.
      (switch-to-buffer): Move here from buffer.c.  Use
      read-buffer-to-switch and normalize-buffer-to-switch-to.
  29. 08 Jun, 2011 1 commit
    • Paul Eggert's avatar
      * lisp.h (SAFE_ALLOCA_LISP): Check for integer overflow. · 9c4c5f81
      Paul Eggert authored
      (struct Lisp_Save_Value): Use ptrdiff_t, not int, for 'integer' member.
      * alloc.c (make_save_value): Integer argument is now of type
      ptrdiff_t, not int.
      (mark_object): Use ptrdiff_t, not int.
      * lisp.h (pD): New macro.
      * print.c (print_object): Use it.