1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00
Commit Graph

189 Commits

Author SHA1 Message Date
Lars Ingebrigtsen
59951f7af5 Audit quoting symbols in C doc strings
* test/manual/etags/c-src/emacs/src/keyboard.c (Frecursive_edit):
* src/xfns.c (syms_of_xfns):
* src/xdisp.c (Fwindow_text_pixel_size):
(syms_of_xdisp):
* src/w32notify.c (Fw32notify_add_watch):
(Fw32notify_add_watch):
* src/frame.c (Fframe_child_frame_border_width):
* src/comp.c (Fcomp__subr_signature):
* src/alloc.c (Fgarbage_collect):
* lib-src/make-docfile.c (scan_c_stream): Audit quoting symbols in C
doc strings.
2022-05-24 11:51:18 +02:00
Paul Eggert
ec35e2621a Do not include <attribute.h> from <config.h>
This is because mod-test.c shouldn’t use source code from lib,
but it does need to include <config.h>.
* lib-src/ebrowse.c, lib-src/emacsclient.c, lib-src/etags.c:
* lib-src/make-docfile.c, lib-src/movemail.c:
* lib-src/seccomp-filter.c, src/dynlib.h, src/lisp.h:
* src/syssignal.h, src/sysstdio.h, src/systhread.h, src/tparam.h:
Include <attribute.h>.
* src/conf_post.h: Do not include <attribute.h>.
All uses of attribute.h macros replaced with their _GL_ equivalents.
2022-03-08 18:51:17 -08:00
Stefan Kangas
24a52df738 Fix two unused variable warnings in make-docfile.c
* lib-src/make-docfile.c (scan_lisp_file): Fix unused variable
warnings.
2022-01-04 03:52:42 +01:00
Stefan Monnier
460f35e96d Revert part of 59732a83c8 to fix bug#52969
While we don't need to put docstrings of .elc files into etc/DOC,
we still need to put those of `loaddefs.el` there since we don't have
a "dynamic docstring" feature for the non-compiled files and keeping
the actual docstrings in the heap would be prohibitive.

* src/Makefile.in ($(etc)/DOC): Scan `lisp/loaddefs.el` still.

* lib-src/make-docfile.c (scan_lisp_file): New function.
(scan_file): Use it.
(skip_white, read_lisp_symbol, search_lisp_doc_at_eol): New functions.
2022-01-03 15:04:12 -05:00
Eli Zaretskii
dcd76bd48d Merge from origin/emacs-28
836be7a112 ; * etc/refcards/ru-refcard.tex: Update Copyright year.
86cbc6ee4a * lisp/net/tramp-sh.el: Adapt copyright year
ebe8772f65 ; Minor fixes related to copyright years
23c1ee6989 ; * test/manual/etags/ETAGS.good_N: Adjust to copyright ye...
8d3fc7ec89 * src/xfaces.c (face_for_font): Make 'hash' be uintptr_t.
19dcb237b5 ; Add 2022 to copyright years.

# Conflicts:
#	etc/NEWS
#	etc/refcards/ru-refcard.tex
#	lib/cdefs.h
#	lisp/erc/erc-dcc.el
#	lisp/erc/erc-imenu.el
#	lisp/erc/erc-replace.el
#	lisp/image-dired.el
#	lisp/progmodes/xref.el
#	m4/alloca.m4
#	m4/byteswap.m4
#	m4/errno_h.m4
#	m4/getopt.m4
#	m4/gnulib-common.m4
#	m4/inttypes.m4
#	m4/stddef_h.m4
#	m4/stdint.m4
#	m4/sys_socket_h.m4
2022-01-01 07:03:03 -05:00
Eli Zaretskii
19dcb237b5 ; Add 2022 to copyright years. 2022-01-01 02:45:51 -05:00
Stefan Monnier
59732a83c8 Don't store docstrings of preloaded .el files in etc/DOC
Since the location of those files changes between build time and
installation time, this requires to tweak the file name used in those
(#$ . NNN) references during the dump so they don't hardcode the build
directory.  We do it in the same way as was already done for those
same file names in `load-history`, except we convert them back to
absolute file names more lazily (i.e. when fetching the actual
docstring rather than at startup), which requires remembering the
`lisp-dir` computed at startup in the new `lisp-directory` variable.

* src/Makefile.in ($(etc)/DOC): Don't scan Lisp files any more.

* src/lread.c (Fload): Use relative file names for `load-file-name`
when preloading for the dump, like we already did for `current-load-list`.
(read_list): Don't zero-out dynamic docstring references during the
preload since they won't be filled later by Snarf-documentation any more.
(read1): Remove the hash-hack for doc references that were zeroed.

* lisp/startup.el (lisp-directory): New variable.
(command-line): Set it.

* src/doc.c (get_doc_string): Use `lisp-directory` for dynamic
docstring references using relative file names.
(syms_of_doc): Add `Qlisp_directory`.

* lib-src/make-docfile.c (scan_file): Don't handle `.el` or `.elc`
files any more.
(IS_SLASH): Remove macro, not used any more.
(skip_white, read_lisp_symbol, search_lisp_doc_at_eol)
(scan_lisp_file): Remove functions, not used any more.

* doc/lispref/loading.texi (Library Search): Mention `lisp-directory`.
2021-12-30 23:17:45 -05:00
Paul Eggert
ba05d005e5 Update copyright year to 2021
Run "TZ=UTC0 admin/update-copyright".
2021-01-01 01:13:56 -08:00
Paul Eggert
365e01cc9f Update copyright year to 2020
Run "TZ=UTC0 admin/update-copyright $(git ls-files)".
2020-01-01 00:59:52 +00:00
Paul Eggert
d539d5868c * lib-src/make-docfile.c: Fix comment typo. 2019-07-12 16:58:25 -07:00
Paul Eggert
81a1088ee8 Tweak builtin symbol order for speed
* lib-src/make-docfile.c (compare_globals):
Make symbols 1 through 4 be t, unbound, error, lambda.
This is in addition to symbol 0 being nil.
This change improved ‘make compile-always’ performance by 0.6%
on my platform.
2019-07-11 23:07:22 -07:00
Paul Eggert
6d6c55db2c Mark _Noreturn error functions as cold
On my platform this made ‘make compile-always’ 1.3% faster.
Suggested by Alex Gramiak in:
https://lists.gnu.org/r/emacs-devel/2019-04/msg00684.html
* configure.ac (nw): Don’t use -Wsuggest-attribute=cold.
* lib-src/make-docfile.c (write_globals):
Mark noreturn functions as cold.
* src/callproc.c (exec_failed):
* src/data.c (wrong_length_argument, wrong_type_argument):
* src/emacs-module.c (module_abort):
* src/emacs.c (terminate_due_to_signal):
* src/eval.c (unwind_to_catch):
* src/image.c (my_png_error, my_error_exit):
* src/json.c (json_out_of_memory, json_parse_error):
* src/keyboard.c (quit_throw_to_read_char, user_error):
* src/lisp.h (die, wrong_type_argument, wrong_choice)
(args_out_of_range, args_out_of_range_3, circular_list)
(buffer_overflow, memory_full, buffer_memory_full)
(string_overflow, xsignal, xsignal0, xsignal1, xsignal2)
(xsignal3, signal_error, overflow_error, error, verror)
(nsberror, report_file_errno, report_file_error)
(report_file_notify_error, terminate_due_to_signal)
(emacs_abort, fatal):
* src/lread.c (load_error_old_style_backquotes)
(end_of_file_error, invalid_syntax):
* src/pdumper.c (error_unsupported_dump_object):
* src/puresize.h (pure_write_error):
* src/search.c (matcher_overflow):
* src/sound.c (sound_perror, alsa_sound_perror):
* src/sysdep.c (handle_arith_signal):
* src/systime.h (time_overflow):
* src/term.c (maybe_fatal, vfatal):
* src/textprop.c (text_read_only):
* src/timefns.c (invalid_time_zone_specification)
(time_error, invalid_hz):
* src/xterm.c (x_connection_closed):
Use AVOID instead of _Noreturn void, so that it’s marked cold.
* src/conf_post.h (__has_attribute_cold) [!__has_attribute]:
New macro.
(ATTRIBUTE_COLD): New macro.
* src/frame.h (WINDOW_SYSTEM_RETURN): Add ATTRIBUTE_COLD.
* src/lisp.h (AVOID): New macro.
* src/xterm.c: Omit unnecessary static decls, so that we needn’t
worry about which functions should be marked cold.
(x_io_error_quitter): Mark as cold.
2019-04-18 00:35:18 -07:00
Paul Eggert
7e29eae023 Suppress GC stats when obviously not needed
This should help future improvements where these stats can be
bignums that do not fit into intmax_t.
* src/alloc.c (struct gcstat, gcstat): New type and static var,
to package up GC statistics into one C object.  It replaces ...
(total_free_intervals, total_intervals, total_strings)
(total_free_strings, total_string_bytes, total_vectors)
(total_vector_slots, total_free_vector_slots): ... these
removed static vars.  All uses changed.
(garbage_collect_1): Accept a struct gcstat *, not a void *
which was not used anymore anyway.  Return a bool indicating
success, instead of a Lisp object.  All callers changed.
(garbage_collect): New function.  All C callers of
Fgarbage_collect changed to use it, since none of them use the
return value.  Now, only Lisp code uses Fgarbage_collect.
(Fgarbage_collect): No longer noinline.  Cons up the return
value here, not in garbage_collect_1.
2019-03-01 09:09:47 -08:00
Paul Eggert
e828765d01 DEFVAR_INT variables are now intmax_t
Formerly they were fixnums, which led to problems when dealing
with values that might not fit on 32-bit platforms, such as
string-chars-consed or floats_consed.  64-bit counters should
be good enough for these (for a while, anyway...).
While we’re at it, fix some unlikely integer overflow bugs
that have been in the code for a while.
* lib-src/make-docfile.c (write_globals):
* src/data.c (do_symval_forwarding, store_symval_forwarding):
* src/eval.c (restore_stack_limits, call_debugger):
* src/frame.h (struct frame.cost_calculation_baud_rate):
* src/keyboard.c (last_auto_save, bind_polling_period, read_char):
* src/lisp.h (struct Lisp_Intfwd.intvar):
* src/lread.c (defvar_int):
* src/pdumper.c (dump_fwd_int):
* src/thread.h (struct thread_state.m_lisp_eval_depth):
* src/undo.c (truncate_undo_list):
* src/xselect.c (wait_for_property_change)
(x_get_foreign_selection):
* src/xterm.c (x_emacs_to_x_modifiers):
DEFVAR_INT variables now have the C type intmax_t, not EMACS_INT.
* src/data.c (store_symval_forwarding):
* src/gnutls.c (Fgnutls_boot):
* src/keyboard.c (bind_polling_period):
* src/macros.c (pop_kbd_macro, Fexecute_kbd_macro):
* src/undo.c (truncate_undo_list):
Allow any integer that fits into intmax_t, instead of
requiring it to be a Lisp fixnum.
* src/dispnew.c (update_window):
* src/frame.c (x_figure_window_size):
* src/gnutls.c (init_gnutls_functions)
(emacs_gnutls_handle_error):
* src/keyboard.c (make_lisp_event):
* src/nsterm.m (ns_dumpglyphs_image):
* src/profiler.c (make_log):
* src/scroll.c (calculate_scrolling)
(calculate_direct_scrolling):
* src/termcap.c (tputs):
* src/xterm.c (x_draw_image_relief):
Avoid implementation-defined behavior on conversion of
out-of-range integers.
* src/eval.c (when_entered_debugger): Now intmax_t.
(max_ensure_room): New function, that avoids signed integer overflow.
(call_debugger, signal_or_quit): Use it.
* src/fileio.c (Fdo_auto_save):
* src/keyboard.c (make_lisp_event):
* src/term.c (calculate_costs):
* src/xdisp.c (build_desired_tool_bar_string)
(hscroll_window_tree, try_scrolling, decode_mode_spec)
(x_produce_glyphs):
Avoid signed integer overflow.
* src/lisp.h (clip_to_bounds): Generalize to intmax_t.
* src/pdumper.c (dump_emacs_reloc_immediate_emacs_int): Remove, ...
(dump_emacs_reloc_immediate_intmax_t): ... replacing with this
function.  All uses changed.
* src/profiler.c (make_log): Omit args.  All callers changed.
* src/termcap.c: Include stdlib.h, for atoi.
Include intprops.h.
* src/window.c (sanitize_next_screen_context_lines): New function.
(window_scroll_pixel_based, window_scroll_line_based):
Use it to avoid signed integer overflow.
2019-02-27 01:23:30 -08:00
Paul Eggert
ba809612c0 Merge from origin/emacs-26
2fcf2df Fix copyright years by hand
26bed8b Update copyright year to 2019
2814292 Fix value of default frame height.  (Bug#33921)
2018-12-31 17:57:29 -08:00
Paul Eggert
26bed8ba10 Update copyright year to 2019
Run 'TZ=UTC0 admin/update-copyright $(git ls-files)'.
2019-01-01 01:01:13 +00:00
Paul Eggert
8c3215e7a4 Port --enable-gcc-warnings to GCC 8
* configure.ac: Do not use GCC 8’s new -Wcast-align flag.
* lib-src/ebrowse.c (xmalloc):
* lib-src/emacsclient.c (xmalloc, xstrdup):
* lib-src/etags.c (xmalloc):
* lib-src/make-docfile.c (xmalloc):
* lib-src/movemail.c (xmalloc):
* src/dispnew.c (new_glyph_pool):
* src/regex.c (xmalloc):
* src/term.c (tty_menu_create):
* src/tparam.h (tparam):
Use ATTRIBUTE_MALLOC.  Also see GCC bug 85562.
* lib-src/emacsclient.c (fail):
Do not dereference a null pointer.
* src/frame.c (delete_frame):
Add a decl with UNINIT to work around GCC bug 85563.
* src/menu.h (finish_menu_items):
Do not use attribute const.
* src/regex.c (analyze_first): Use FALLTHROUGH, not a comment.
2018-04-28 16:56:48 -07:00
Paul Eggert
2038b6a1dd make-docfile: minor fixes and cleanups
* lib-src/make-docfile.c: Include c-ctype.h.
(read_c_string_or_comment, write_c_args, scan_c_stream, skip_white)
(read_lisp_symbol, scan_lisp_file):
Prefer c_isspace etc. to listing characters by hand.
(read_c_string_or_comment): Simplify.
(scan_c_stream, read_lisp_symbol): Use true for boolean 1.
(scan_c_stream): Fix typo (c >= 'Z' && c <= 'Z').
Minor rewrites to avoid duplicate code.
(scan_c_stream, read_lisp_symbol, scan_lisp_file):
Avoid infloop if at EOF.
(skip_white, read_lisp_symbol): Don’t stuff getc result into
‘char’, as this mishandles EOF.
2018-03-01 16:25:42 -08:00
Paul Eggert
5c7dd8a783 Update copyright year to 2018
Run admin/update-copyright.
2018-01-01 00:57:59 -08:00
Paul Eggert
b1573a97e1 Use alignas to fix GCALIGN-related bugs
Use alignas and unions to specify alignments of objects needing
addresses that are at least a multiple of GCALIGNMENT.  Using
these standard C facilities should be safer than relying on ad hoc
and poorly-understood features like GCC’s __attribute__
((aligned (N))), the root cause for recent porting bugs like
Bug#29040.  The alignas macro was standardized by C11 and Gnulib
supports alignas for pre-C11 platforms.  I have tested this on Sun
Studio 12 sparc (2007) and GCC 4.4.7 x86-64 (2012) as well as on
more recent platforms like GCC 7.2.1 (2017) on Fedora 26 (both
x86-64 and x86).
* lib-src/make-docfile.c (close_emacs_globals): lispsym is now
just an array of struct Lisp_Symbol, since struct Lisp_Symbol is
now properly aligned.  All uses changed.
* src/alloc.c (NEXT_FREE_LISP_STRING): Just use the new u.next
member; this is simpler and safer than casting a pointer that
might not be aligned properly.
(aligned_Lisp_Symbol): Remove.  No longer needed, now that struct
Lisp_Symbol is aligned properly.  All uses replaced with struct
Lisp_Symbol.
* src/lisp.h (GCALIGNED): Remove, as it does not work as expected:
it can cause the natural alignment to be ignored.  All uses
replaced by unions with a ‘char alignas (GCALIGNMENT)’ member as
described below.
(struct Lisp_Symbol, struct Lisp_Cons, struct Lisp_String):
Change definition from ‘struct TAG { MEMBERS };’ to
‘struct TAG { union { struct { MEMBERS } s; char alignas
(GCALIGNMENT) gcaligned; } u; };’.  This guarantees ‘struct TAG’
to have an alignment that at least max (GCALIGNMENT, N) where N is
its old alignment.  All uses like ‘PTR->MEMBER’ changed to
‘PTR->u.s.MEMBER’; these uses were supposed to be mostly private
anyway.  Verify that the resulting ‘struct TAG’ is properly
aligned for Emacs.
(union vectorlike_header): New member ‘gcaligned’ to guarantee
that this type, and its containing types like ‘struct Lisp_Subr’,
‘struct buffer’ and ‘struct thread_state’, are all properly
aligned for Emacs.
(struct Lisp_String): New union member ‘next’, for the benefit
of NEXT_FREE_LISP_STRING.
(union Aligned_Cons, union Aligned_String): Remove.  All uses
replaced by struct Lisp_Cons and struct Lisp_String, since they
are now properly aligned.
(USE_STACK_CONS, USE_STACK_STRING): Simplify now that we can
assume struct Lisp_Cons and struct Lisp_String are properly
aligned.
2017-11-13 10:16:51 -08:00
Paul Eggert
9e59de9449 Use GCALIGNED properly for GCC
Apparently GCC requires that ‘__attribute__ ((aligned (8)))’ must
immediately follow the ‘struct’ keyword when aligning a structure.
The attribute silently does not work if it follows a tag after the
‘struct’ keyword.  Who knew?  Anyway, this patch is designed to
fix a SIGSEGV problem reported by John Mastro (Bug#29183).
* lib-src/make-docfile.c (close_emacs_globals):
* src/buffer.c (buffer_defaults, buffer_local_symbols):
* src/lisp.h (DEFUN):
* src/thread.c (main_thread):
Put 'GCALIGNED' immediately after 'struct'.
2017-11-08 19:12:02 -08:00
Paul Eggert
6b08ad5263 Fix alignment portability problems
Do not assume that the natural alignment of Lisp objects is a
multiple of GCALIGNMENT.  This improves on the portability of the
recent fix for Bug#29040.
* lib-src/make-docfile.c (close_emacs_globals):
* src/buffer.c (buffer_defaults, buffer_local_symbols):
* src/lisp.h (DEFUN):
* src/thread.c (main_thread):
Use GCALIGNED, not alignas (GCALIGNMENT).
* src/alloc.c (COMMON_MULTIPLE):
Move back here from lisp.h, since it is no longer used elsewhere.
* src/lisp.h (GCALIGNMENT): No longer a macro, since we need not
worry about MSVC.  Omit no-longer-needed consistency check.
* src/thread.c (THREAD_ALIGNMENT): Remove.
2017-11-02 13:21:33 -07:00
Paul Eggert
bc511a64f6 Prefer HTTPS to FTP and HTTP in documentation
Most of this change is to boilerplate commentary such as license URLs.
This change was prompted by ftp://ftp.gnu.org's going-away party,
planned for November.  Change these FTP URLs to https://ftp.gnu.org
instead.  Make similar changes for URLs to other organizations moving
away from FTP.  Also, change HTTP to HTTPS for URLs to gnu.org and
fsf.org when this works, as this will further help defend against
man-in-the-middle attacks (for this part I omitted the MS-DOS and
MS-Windows sources and the test tarballs to keep the workload down).
HTTPS is not fully working to lists.gnu.org so I left those URLs alone
for now.
2017-09-13 15:54:37 -07:00
Paul Eggert
9baeed3514 Improve stack-top heuristic
This is needed for gcc -Os -flto on x86-64; otherwise, GC misses part
of the stack when scanning for heap roots, causing Emacs to crash
later (Bug#28213).  The problem is that Emacs's hack for getting an
address near the stack top does not work when link-time optimization
moves stack variables around.
* configure.ac (HAVE___BUILTIN_FRAME_ADDRESS): New macro.
* lib-src/make-docfile.c (DEFUN_noinline): New constant.
(write_globals, scan_c_stream): Support noinline.
* src/alloc.c (NEAR_STACK_TOP): New macro.
(SET_STACK_TOP_ADDRESS): Use it.
(flush_stack_call_func, Fgarbage_collect): Now noinline.
2017-08-29 14:58:49 -07:00
Andreas Schwab
7a4d9f6304 Properly align global lispsym
* lib-src/make-docfile.c (close_emacs_globals): Wrap struct
Lisp_Symbols inside struct.
* src/alloc.c (sweep_symbols): Update use of lispsym.
* src/lisp.h (builtin_lisp_symbol): Likewise.
2017-07-25 01:20:44 +02:00
Paul Eggert
f6ef15cf84 Use unlocked stdio more systematically
This can improve performance significantly on stdio-bottlenecked code.
E.g., make-docfile is 3x faster on my Fedora 25 x86-64 desktop.
* admin/merge-gnulib (GNULIB_MODULES): Add unlocked-io.
* lib-src/ebrowse.c, lib-src/emacsclient.c, lib-src/etags.c:
* lib-src/hexl.c, lib-src/make-docfile.c, lib-src/movemail.c:
* lib-src/profile.c, lib-src/update-game-score.c:
Include unlocked-io.h instead of stdio.h, since these programs are
single-threaded.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
* lib/unlocked-io.h, m4/unlocked-io.m4: New files, copied from Gnulib.
* src/charset.c, src/cm.c, src/emacs.c, src/image.c, src/keyboard.c:
* src/lread.c, src/term.c:
Include sysstdio.h, possibly instead of stdio.h, to define
the unlocked functions if the system does not provide them.
* src/charset.c, src/lread.c (getc_unlocked):
Remove, since sysstdio.h now defines it if needed.
* src/cm.c (cmputc, cmcheckmagic):
* src/dispnew.c (update_frame, update_frame_with_menu)
(update_frame_1, Fsend_string_to_terminal, Fding, bitch_at_user):
* src/emacs.c (main, Fdump_emacs):
* src/fileio.c (Fdo_auto_save, Fset_binary_mode):
* src/image.c (slurp_file, png_read_from_file, png_load_body)
(our_stdio_fill_input_buffer):
* src/keyboard.c (record_char, kbd_buffer_get_event, handle_interrupt):
* src/lread.c (readbyte_from_file):
* src/minibuf.c (read_minibuf_noninteractive):
* src/print.c (printchar_to_stream, strout)
(Fredirect_debugging_output):
* src/sysdep.c (reset_sys_modes, procfs_ttyname)
(procfs_get_total_memory):
* src/term.c (tty_ring_bell, tty_send_additional_strings)
(tty_set_terminal_modes, tty_reset_terminal_modes)
(tty_update_end, tty_clear_end_of_line, tty_write_glyphs)
(tty_write_glyphs_with_face, tty_insert_glyphs)
(tty_menu_activate):
* src/xfaces.c (Fx_load_color_file):
Use unlocked stdio when it should be safe.
* src/sysstdio.h (clearerr_unlocked, feof_unlocked, ferror_unlocked)
(fflush_unlocked, fgets_unlocked, fputc_unlocked, fputs_unlocked)
(fread_unlocked, fwrite_unlocked, getc_unlocked, getchar_unlocked)
(putc_unlocked, putchar_unloced): Provide substitutes if not declared.
2017-06-22 11:22:53 -07:00
Paul Eggert
2b9620e6af No need to complicate make-docfile.c for Clang
* lib-src/make-docfile.c (put_filename): Undo recent change.
The Clang false alarm occurs only with CFLAGS=-save-temps and
we needn’t worry about pacifying unusual compiler configurations.
2017-06-15 12:34:30 -07:00
Philipp Stephani
e408e9aa03 Silence two Clang warnings by introducing additional local variables
* lib/strftime.c (libc_hidden_def):
* lib-src/make-docfile.c (put_filename): Introduce local variables to
silence Clang warnings.
2017-06-13 13:56:46 +02:00
Paul Eggert
a3f3fea14a Fix buffer overflow in make-docfile
* lib-src/make-docfile.c (scan_c_stream): Check for buffer
overflow when reading an identifier.  Use a static buffer for NAME
rather than a small dynamically-allocated buffer.
2017-04-29 23:35:46 -07:00
Paul Eggert
bcf244ef9b Merge from origin/emacs-25
2e2a806 Fix copyright years by hand
5badc81 Update copyright year to 2017
2017-01-01 01:10:47 -08:00
Paul Eggert
5badc81c1c Update copyright year to 2017
Run admin/update-copyright.
2016-12-31 19:42:26 -08:00
Paul Eggert
f4eb890029 Limit <config.h>’s includes
This follows up on recent problems with the fact that config.h
includes stdlib.h etc.; some files need to include stdlib.h later.
config.h generally should limit itself to includes that are
universally safe; outside of MS-Windows, only stdbool.h makes
the cut among the files currently included.  So, move the
other includes to just the files that need them (Bug#24506).
* configure.ac (config_opsysfile): Remove, as this generic hook
is no longer needed.
* lib-src/etags.c, src/unexmacosx.c, src/w32.c, src/w32notify.c:
* src/w32proc.c (_GNU_SOURCE):
Remove, as it’s OK for config.h to do this now.
* src/conf_post.h: Include <ms-w32.h>, instead of the generic
config_opsysfile, for simplicity as this old way of configuring is
now done only for the MS-Windows port.  Do not include <ms-w32.h>
if DEFER_MS_W32_H, for the benefit of the few files that want its
effects later.  Do not include <alloca.h>, <string.h>, or
<stdlib.h>.  Other files modified to include these headers as
needed, or to not include headers that are no longer needed.
* src/lisp.h: Include <alloca.h> and <string.h> here, since
some of the inline functions need them.
* src/regex.c: Include <alloca.h> if not emacs.  (If emacs,
we can rely on SAFE_ALLOCA.)  There is no longer any need to
worry about HAVE_ALLOCA_H.
* src/unexmacosx.c: Rely on config.h not including stdlib.h.
* src/w32.c, src/w32notify.c, src/w32proc.c (DEFER_MS_W32_H):
Define before including <config.h> first, and include <ms-w32.h>
after the troublesome headers.
2016-09-30 12:38:52 -07:00
Paul Eggert
82f49c6a37 Replace IF_LINT by NONVOLATILE and UNINIT
Inspired by a suggestion from RMS in: http://bugs.gnu.org/23640#58
* .dir-locals.el (c-mode): Adjust to macro changes.
* src/conf_post.h (NONVOLATILE, UNINIT): New macros (Bug#23640).
(IF_LINT): Remove.  All uses replaced by the new macros.
2016-06-08 11:50:42 -07:00
Paul Eggert
7352c6c695 Rework C source files to avoid ^(
Work around Bug#22884 by rewording comments and strings to avoid ‘(’
at the start of a line unless it starts a function.  This change
is a short-term hack; in the longer run we plan to fix cc-mode’s
performance for C files that have ‘(’ at the start of a line in a
comment or string.
2016-03-10 07:59:19 -08:00
Paul Eggert
5eb9989f9b * lib-src/make-docfile.c: Include stdarg.h. 2016-02-11 12:51:08 -08:00
Paul Eggert
456c0a3137 make-docfile cleanup for I/O, etc.
* lib-src/make-docfile.c (progname, generate_globals, num_globals)
(num_globals_allocated, globals): Now static.
(generate_globals, struct rcsoc_state, read_c_string_or_comment):
(write_c_args, scan_c_stream, search_lisp_doc_at_eol, scan_lisp_file):
Use bool for boolean.
(verror): New function.
(fatal, error): Use it.  API is now like printf.  All callers changed.
(main): Remove err_count local that was always 0.
(main, scan_c_stream, scan_lisp_file): Check for I/O error.
(scan_file, scan_c_file, scan_c_stream, scan_lisp_file):
Return void, not 0.
(put_char, scan_keyword_or_put_char, scan_c_file): Use char for byte.
(scan_keyword_or_put_char): Check for missing ( and unexpected EOF.
(close_emacs_globals): Use ptrdiff_t for index, not int.
(scan_c_file, scan_lisp_file): Exit with failure if file cannot be
opened, rather than diagnosing but exiting with status 0.
(search_lisp_doc_at_eol): Don't worry about ungetc of EOF; it's
portable now.
2016-02-10 11:41:10 -08:00
Paul Eggert
25ec995c06 Memory-management cleanup in make-docfile
I compiled it with -fsanitize=address and fixed the leaks it detected.
Also, I changed it to prefer signed to unsigned integer types,
and to check for integer overflow.
* lib-src/make-docfile.c:
Include <stddef.h>, <stdint.h>, <intprops.h>, <min-max.h>.
(memory_exhausted): New function.
(xmalloc, xrealloc): Use it.
(xmalloc, xrealloc, scan_file, struct rcsoc_state, write_c_args)
(uncompiled, scan_lisp_file):
Prefer signed integer types to unsigned.
(xstrdup): Remove.  All uses removed.
(num_globals, num_globals_allocated, write_globals, scan_c_stream):
Use ptrdiff_t, not int, for indexes that in theory could exceed INT_MAX.
(add_global): Use const to pacify --enable-gcc-warnings.
Make a copy here, rather than relying on strdup calls later.
(add_global, write_globals, scan_c_stream):
Avoid integer overflow when calculating sizes.
(write_globals, scan_c_stream, scan_lisp_file): Avoid memory leak.
(scan_c_stream): Check for add_global failure.
2016-02-10 11:41:10 -08:00
Paul Eggert
0e963201d0 Update copyright year to 2016
Run admin/update-copyright.
2016-01-01 01:34:24 -08:00
Paul Eggert
2934c21f2d Use straight quotes in lib-src diagnostics
These auxiliary programs can’t use Emacs’s text-quoting-style,
and it’s too much trouble to redo that mechanism by hand.
So just use straight quotes for now.
* lib-src/ebrowse.c (main):
* lib-src/emacsclient.c (decode_options, main):
* lib-src/etags.c (Ada_help, default_C_help, Cplusplus_help)
(Forth_help, HTML_help, Lisp_help, Makefile_help, Objc_help)
(Perl_help, PHP_help, Python_help, Scheme_help, TeX_help, auto_help)
(none_help, print_language_names, print_help, add_regex)
(suggest_asking_for_help):
* lib-src/make-docfile.c (write_c_args, scan_c_stream):
Use straight quotes in diagnostics.
2015-08-27 02:37:35 -07:00
Paul Eggert
14b4e657e2 Spelling fixes
* lisp/cedet/semantic/doc.el (semantic-documentation-comment-preceding-tag):
Rename from semantic-documentation-comment-preceeding-tag.  All
uses changed.  Leave an obsolete alias behind.
* src/lisp.h (DEFINE_NON_NIL_Q_SYMBOL_MACROS):
Rename from DEFINE_NONNIL_Q_SYMBOL_MACROS.  All uses changed.
2015-02-21 20:01:05 -08:00
Paul Eggert
65563fd771 Better support for future plugins
See the thread containing:
http://lists.gnu.org/archive/html/emacs-devel/2015-02/msg00720.html
* lib-src/make-docfile.c (write_globals): Generate code that #defines
Qxxx macros other than Qnil only if DEFINE_NONNIL_Q_SYMBOL_MACROS.
Qnil is safe to define even in plugins, since it must be zero for
other reasons.
* src/lisp.h (DEFINE_LISP_SYMBOL): New macro, replacing and simplifying
DEFINE_LISP_SYMBOL_BEGIN / DEFINE_LISP_SYMBOL_END.  All uses changed.
(DEFINE_NONNIL_Q_SYMBOL_MACROS): New macro, defaulting to true.
2015-02-12 18:21:32 -08:00
Paul Eggert
0adc75af18 Give up on -Wsuggest-attribute=const
The attribute doesn't help performance significantly, and the
warning seems to be more trouble than it's worth.  See the thread at:
http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00361.html
* configure.ac (WERROR_CFLAGS): Don't use -Wsuggest-attribute=const.
* lib-src/make-docfile.c (write_globals):
Remove special hack for Fnext_read_file_uses_dialog_p.
* src/decompress.c (Fzlib_available_p):
* src/gnutls.c (Fgnutls_available_p):
* src/gtkutil.h (xg_uses_old_file_dialog):
* src/xdisp.c (Ftool_bar_height):
* src/xmenu.c (popup_activated):
No longer const, since it's not const on at lest some
configurations, and we shouldn't lie to the compiler.
2015-01-15 20:37:44 -08:00
Paul Eggert
785adfcc8d Don't say Fnext_read_file_uses_dialog_p is const
It's const only if a windowing system is not used; don't say it's
const otherwise.  See:
http://lists.gnu.org/archive/html/emacs-devel/2015-01/msg00310.html
* lib-src/make-docfile.c (write_globals):
Add a special hack for Fnext_read_file_uses_dialog_p.
* src/fileio.c (next_read_file_uses_dialog_p): Remove.
Move guts back to ...
(Fnext_read_file_uses_dialog_p): ... here.
Don't declare as const, as make-docfile.c now has a special case
for this function.  This is an ugly hack, but it's better than
lying to the compiler.
2015-01-13 15:23:03 -08:00
Dmitry Antipov
ad9c4a4091 Support const and noreturn DEFUN attributes.
* lib-src/make-docfile.c (struct global): New field 'flags'.
(DEFUN_noreturn, DEFUN_const): New enum bitfields.
(add_global): Now return pointer to global.
(write_globals): Add _Noreturn and ATTRIBUTE_CONST attributes
if requested by global's flags.
(stream_match): New function.
(scan_c_stream): Recognize 'attributes:' of DEFUN.

* src/callint.c (Finteractive):
* src/character.c (Fcharacterp, Fmax_char):
* src.data.c (Feq, Fnull, Fconsp, Fatom, Flistp, Fnlistp, Fsymbolp)
(Fstringp, Fchar_or_string_p, Fintegerp, Fnatnump, Fnumberp)
(Ffloatp, Fbyteorder):
* src/decompress.c (Fzlib_available_p):
* src/fns.c (Fidentity):
* src/frame.c (Fframe_windows_min_size):
* src/gnutls.c (Fgnutls_error_p, Fgnutls_available_p):
* src/window.c (Fwindow__sanitize_window_sizes):
* src/xdisp.c (Ftool_bar_height):
* src/xfaces.c (Fface_attribute_relative_p): Add const attribute.
* src/emacs.c (Fkill_emacs):
* src/eval.c (Fthrow):
* src/keyboard.c (Ftop_level, Fexit_recursive_edit)
(Fabor_recursive_edit): Add noreturn attribute.
2015-01-13 06:39:45 +03:00
Paul Eggert
6a37ecee08 Port to 32-bit --with-wide-int
Prefer symbol indexes to struct Lisp_Symbol * casted and then
widened, as the latter had trouble with GCC on Fedora 21 when
configured --with-wide-int and when used in static initializers.
* lib-src/make-docfile.c (write_globals): Define and use symbols like
iQnil (a small integer, like 0) rather than aQnil (an address
constant).
* src/alloc.c (garbage_collect_1, which_symbols):
* src/lread.c (init_obarray):
Prefer builtin_lisp_symbol when it can be used.
* src/dispextern.h (struct image_type.type):
* src/font.c (font_property_table.key):
* src/frame.c (struct frame_parm_table.sym):
* src/keyboard.c (scroll_bar_parts, struct event_head):
* src/xdisp.c (struct props.name):
Use the index of a builtin symbol rather than its address.
All uses changed.
* src/lisp.h (TAG_SYMPTR, XSYMBOL_INIT): Remove, replacing with ...
(TAG_SYMOFFSET, SYMBOL_INDEX): ... new macros that deal with
symbol indexes rather than pointers, and which work better on MSB
hosts because they shift right before tagging.  All uses changed.
(DEFINE_LISP_SYMBOL_BEGIN, DEFINE_LISP_SYMBOL_END):
No longer noops on wide-int hosts, since they work now.
(builtin_lisp_symbol): New function.
2015-01-10 13:42:35 -08:00
Paul Eggert
288e1fd737 Port to 32-bit Sun C 5.12 sparc
* make-docfile.c (close_emacs_globals): Align lispsym to GCALIGNMENT.
The alignment is required on all platforms; it just happens to have
been properly aligned on the previous platforms we tested.
2015-01-10 13:42:34 -08:00
Paul Eggert
bc78ff2603 Use 0 for Qnil
Fixes Bug#15880.
If USE_LSB_TAG, arrange for the representation of Qnil to be zero so
that NILP (x) is equivalent to testing whether x is 0 at the
machine level.  The overall effects of this and the previous patch
shrink the size of the text segment by 2.3% and speeds up
compilation of all the .elc files by about 0.5% on my platform,
which is Fedora 20 x86-64.
* lib-src/make-docfile.c (compare_globals):
* src/lisp.h (lisp_h_XPNTR, lisp_h_XSYMBOL, lisp_h_XUNTAG)
(make_lisp_symbol) [USE_LSB_TAG]:
Symbols now tag the difference from lispsym, not the pointer.
(lisp_h_XUNTAGBASE, TAG_SYMPTR): New macros.
(Lisp_Int0, Lisp_Int1, Lisp_Symbol, Lisp_Misc, Lisp_String, Lisp_Cons):
Renumber so that Lisp_Symbol is 0, so that Qnil is zero.
(XSYMBOL): New forward decl.
(XUNTAGBASE): New function.
(XUNTAG): Use it.
2015-01-05 10:15:04 -08:00
Paul Eggert
58f2d6ef32 Compute C decls for DEFSYMs automatically
Fixes Bug#15880.
This patch also makes Q constants (e.g., Qnil) constant addresses
from the C point of view.
* make-docfile.c: Revamp to generate table of symbols, too.
Include <stdbool.h>.
(xstrdup): New function.
(main): Don't process the same file twice.
(SYMBOL): New constant in enum global_type.
(struct symbol): Turn 'value' member into a union, either v.value
for int or v.svalue for string.  All uses changed.
(add_global): New arg svalue, which overrides value, so that globals
can have a string value.
(close_emacs_global): New arg num_symbols; all uses changed.
Output lispsym decl.
(write_globals): Output symbol globals too.  Output more
ATTRIBUTE_CONST, now that Qnil etc. are C constants.
Output defsym_name table.
(scan_c_file): Move most of guts into ...
(scan_c_stream): ... new function.  Scan for DEFSYMs and
record symbols found.  Don't read past EOF if file doesn't
end in newline.
* alloc.c, bidi.c, buffer.c, bytecode.c, callint.c, casefiddle:
* casetab.c, category.c, ccl.c, charset.c, chartab.c, cmds.c, coding.c:
* composite.c, data.c, dbusbind.c, decompress.c, dired.c, dispnew.c:
* doc.c, editfns.c, emacs.c, eval.c, fileio.c, fns.c, font.c, fontset.c:
* frame.c, fringe.c, ftfont.c, ftxfont.c, gfilenotify.c, gnutls.c:
* image.c, inotify.c, insdel.c, keyboard.c, keymap.c, lread.c:
* macfont.m, macros.c, minibuf.c, nsfns.m, nsfont.m, nsimage.m:
* nsmenu.m, nsselect.m, nsterm.m, print.c, process.c, profiler.c:
* search.c, sound.c, syntax.c, term.c, terminal.c, textprop.c, undo.c:
* window.c, xdisp.c, xfaces.c, xfns.c, xftfont.c, xmenu.c, xml.c:
* xselect.c, xsettings.c, xterm.c:
Remove Q vars that represent symbols (e.g., Qnil, Qt, Qemacs).
These names are now defined automatically by make-docfile.
* alloc.c (init_symbol): New function.
(Fmake_symbol): Use it.
(c_symbol_p): New function.
(valid_lisp_object_p, purecopy): Use it.
* alloc.c (marked_pinned_symbols):
Use make_lisp_symbol instead of make_lisp_ptr.
(garbage_collect_1): Mark lispsym symbols.
(CHECK_ALLOCATED_AND_LIVE_SYMBOL): New macro.
(mark_object): Use it.
(sweep_symbols): Sweep lispsym symbols.
(symbol_uses_obj): New function.
(which_symbols): Use it.  Work for lispsym symbols, too.
(init_alloc_once): Initialize Vpurify_flag here; no need to wait,
since Qt's address is already known now.
(syms_of_alloc): Add lispsym count to symbols_consed.
* buffer.c (init_buffer_once): Compare to Qnil, not to make_number (0),
when testing whether storage is all bits zero.
* dispextern (struct image_type):
* font.c (font_property_table):
* frame.c (struct frame_parm_table, frame_parms):
* keyboard.c (scroll_bar_parts, struct event_head):
* xdisp.c (struct props):
Use XSYMBOL_INIT (Qfoo) and struct Lisp_Symbol * rather than &Qfoo and
Lisp_Object *, since Qfoo is no longer an object whose address can be
taken.  All uses changed.
* eval.c (run_hook): New function.  Most uses of Frun_hooks changed to
use it, so that they no longer need to take the address of a Lisp sym.
(syms_of_eval): Don't use DEFSYM on Vrun_hooks, as it's a variable.
* frame.c (syms_of_frame): Add defsyms for the frame_parms table.
* keyboard.c (syms_of_keyboard): Don't DEFSYM Qmenu_bar here.
DEFSYM Qdeactivate_mark before the corresponding var.
* keymap.c (syms_of_keymap): Use DEFSYM for Qmenu_bar and Qmode_line
instead of interning their symbols; this avoids duplicates.
(LISP_INITIALLY, TAG_PTR)
(DEFINE_LISP_SYMBOL_BEGIN, DEFINE_LISP_SYMBOL_END, XSYMBOL_INIT):
New macros.
(LISP_INITIALLY_ZERO): Use it.
(enum symbol_interned, enum symbol_redirect, struct Lisp_Symbol)
(EXFUN, DEFUN_ARGS_MANY, DEFUN_ARGS_UNEVALLED, DEFUN_ARGS_*):
Move decls up, to avoid forward uses.  Include globals.h earlier, too.
(make_lisp_symbol): New function.
(XSETSYMBOL): Use it.
(DEFSYM): Now just a placeholder for make-docfile.
* lread.c (DEFINE_SYMBOLS): Define, for globals.h.
(intern_sym): New function, with body taken from old intern_driver.
(intern_driver): Use it.  Last arg is now Lisp integer, not ptrdiff_t.
All uses changed.
(define_symbol): New function.
(init_obarray): Define the C symbols taken from lispsym.
Use plain DEFSYM for Qt and Qnil.
* syntax.c (init_syntax_once): No need to worry about
Qchar_table_extra_slots.
2015-01-05 10:14:58 -08:00
Paul Eggert
bf90e9ac7c 'temacs -nw' should not call missing functions
Without this patch, "temacs -nw" fails with the diagnostic
"emacs: Symbol's function definition is void: frame-windows-min-size"
and messes up the tty's state.
* lib-src/make-docfile.c (write_globals):
Declare Fframe_windows_min_size with ATTRIBUTE_CONST, too.  Sort.
* src/frame.c (Fframe_windows_min_size): New placeholder function.
(syms_of_frame): Define it.
* src/window.c (Fwindow__sanitize_window_sizes): New placeholder.
(syms_of_window): Define it.
2015-01-04 13:21:03 -08:00
Paul Eggert
7e09ef09a4 Update copyright year to 2015
Run admin/update-copyright.
2015-01-01 14:26:41 -08:00