aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJoakim Verona2012-10-16 17:14:35 +0200
committerJoakim Verona2012-10-16 17:14:35 +0200
commit017a270078be5ae39301e3205afad80d23facbbc (patch)
tree5c85d8c3890f3a0cead231e87823b621a8f28e16 /src
parent5fcc7035c884b4419a1619551222b5f28ad9906f (diff)
parent2b794d6940aa7dc58e297b3649b7799190d71f64 (diff)
downloademacs-017a270078be5ae39301e3205afad80d23facbbc.tar.gz
emacs-017a270078be5ae39301e3205afad80d23facbbc.zip
upstream
Diffstat (limited to 'src')
-rw-r--r--src/.gdbinit8
-rw-r--r--src/ChangeLog479
-rw-r--r--src/alloc.c33
-rw-r--r--src/atimer.c6
-rw-r--r--src/bidi.c68
-rw-r--r--src/buffer.c106
-rw-r--r--src/category.c2
-rw-r--r--src/charset.c2
-rw-r--r--src/coding.c27
-rw-r--r--src/coding.h6
-rw-r--r--src/dispextern.h2
-rw-r--r--src/dispnew.c14
-rw-r--r--src/emacs.c18
-rw-r--r--src/eval.c77
-rw-r--r--src/fileio.c3
-rw-r--r--src/fns.c15
-rw-r--r--src/frame.c18
-rw-r--r--src/gmalloc.c8
-rw-r--r--src/image.c4
-rw-r--r--src/intervals.c14
-rw-r--r--src/keyboard.c22
-rw-r--r--src/lisp.h2
-rw-r--r--src/lread.c23
-rw-r--r--src/makefile.w32-in13
-rw-r--r--src/marker.c6
-rw-r--r--src/nsfns.m38
-rw-r--r--src/nsterm.h18
-rw-r--r--src/nsterm.m297
-rw-r--r--src/process.c34
-rw-r--r--src/profiler.c232
-rw-r--r--src/ralloc.c16
-rw-r--r--src/syntax.c4
-rw-r--r--src/sysdep.c39
-rw-r--r--src/syssignal.h13
-rw-r--r--src/terminal.c2
-rw-r--r--src/textprop.c4
-rw-r--r--src/unexw32.c46
-rw-r--r--src/vm-limit.c12
-rw-r--r--src/w32.c78
-rw-r--r--src/w32.h3
-rw-r--r--src/w32fns.c91
-rw-r--r--src/w32heap.c44
-rw-r--r--src/w32heap.h12
-rw-r--r--src/w32menu.c10
-rw-r--r--src/w32proc.c555
-rw-r--r--src/w32term.c8
-rw-r--r--src/w32term.h14
-rw-r--r--src/window.c60
-rw-r--r--src/xdisp.c61
-rw-r--r--src/xfaces.c38
-rw-r--r--src/xfns.c4
-rw-r--r--src/xml.c2
-rw-r--r--src/xterm.c8
53 files changed, 2079 insertions, 640 deletions
diff --git a/src/.gdbinit b/src/.gdbinit
index 7a6bfb07fed..952d7392a4c 100644
--- a/src/.gdbinit
+++ b/src/.gdbinit
@@ -1121,15 +1121,15 @@ end
1121define xbacktrace 1121define xbacktrace
1122 set $bt = backtrace_list 1122 set $bt = backtrace_list
1123 while $bt 1123 while $bt
1124 xgettype (*$bt->function) 1124 xgettype ($bt->function)
1125 if $type == Lisp_Symbol 1125 if $type == Lisp_Symbol
1126 xprintsym (*$bt->function) 1126 xprintsym ($bt->function)
1127 printf " (0x%x)\n", $bt->args 1127 printf " (0x%x)\n", $bt->args
1128 else 1128 else
1129 xgetptr *$bt->function 1129 xgetptr $bt->function
1130 printf "0x%x ", $ptr 1130 printf "0x%x ", $ptr
1131 if $type == Lisp_Vectorlike 1131 if $type == Lisp_Vectorlike
1132 xgetptr (*$bt->function) 1132 xgetptr ($bt->function)
1133 set $size = ((struct Lisp_Vector *) $ptr)->header.size 1133 set $size = ((struct Lisp_Vector *) $ptr)->header.size
1134 if ($size & PSEUDOVECTOR_FLAG) 1134 if ($size & PSEUDOVECTOR_FLAG)
1135 output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_SIZE_BITS) 1135 output (enum pvec_type) (($size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_SIZE_BITS)
diff --git a/src/ChangeLog b/src/ChangeLog
index b0899d67ca8..ced0e057e27 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,481 @@
12012-10-02 Paul Eggert <eggert@cs.ucla.edu>
2
3 * profiler.c (handle_profiler_signal): Fix a malloc race
4 that caused Emacs to hang on Fedora 17 when profiling Lisp.
5
62012-10-02 Jan Djärv <jan.h.d@swipnet.se>
7
8 * nsterm.m (windowDidEnterFullScreen): Remove fprintf.
9
102012-10-02 Eli Zaretskii <eliz@gnu.org>
11
12 * w32proc.c (sys_wait): Declare 'signame' 'const char *', to be
13 consistent with the change in return value of 'safe_strsignal'.
14
152012-10-02 Paul Eggert <eggert@cs.ucla.edu>
16
17 Prefer plain 'static' to 'static inline' (Bug#12541).
18 * bidi.c (bidi_get_type, bidi_check_type, bidi_get_category)
19 (bidi_set_sor_type, bidi_push_embedding_level)
20 (bidi_pop_embedding_level, bidi_remember_char, bidi_copy_it)
21 (bidi_cache_reset, bidi_cache_shrink, bidi_cache_fetch_state)
22 (bidi_cache_search, bidi_cache_ensure_space)
23 (bidi_cache_iterator_state, bidi_cache_find)
24 (bidi_peek_at_next_level, bidi_set_paragraph_end)
25 (bidi_count_bytes, bidi_char_at_pos, bidi_fetch_char)
26 (bidi_explicit_dir_char, bidi_resolve_neutral_1):
27 Now 'static', not 'static inline'.
28
29 Count overruns when profiling; change units to ns.
30 * profiler.c (handle_profiler_signal): Count sampling intervals, not ms.
31 Give extra weight to samples after overruns, to attempt to count
32 the time more accurately.
33 (setup_cpu_timer): Change sampling interval units from ms to ns, since
34 the underlying primitives nominally do ns.
35 (Fprofiler_cpu_start): Document the change. Mention that
36 the sampling intervals are only approximate.
37
382012-10-02 Stefan Monnier <monnier@iro.umontreal.ca>
39
40 * frame.c (Fmake_terminal_frame): Prefer safer CONSP over !NILP.
41
42 * coding.h (ENCODE_FILE, DECODE_FILE, DECODE_SYSTEM): Remove special
43 case for the special 0 coding-system.
44
45 * buffer.c (Fset_buffer_multibyte): Signal an error instead of widening.
46 (Fmake_overlay): Remove redundant tests.
47 (fix_start_end_in_overlays): Remove redundant recentering.
48
492012-10-02 Juanma Barranquero <lekktu@gmail.com>
50
51 * makefile.w32-in ($(BLD)/alloc.$(O), $(BLD)/gmalloc.$(O)):
52 Update dependencies.
53
542012-10-01 Paul Eggert <eggert@cs.ucla.edu>
55
56 Fix a malloc race condition involving strsignal.
57 A signal can arrive in the middle of a malloc, and Emacs's signal
58 handler can invoke strsignal, which can invoke malloc, which is
59 not portable. This race condition bug makes Emacs hang on GNU/Linux.
60 Fix it by altering the signal handler so that it does not invoke
61 strsignal.
62 * emacs.c (shut_down_emacs): Use safe_strsignal, not strsignal.
63 * process.c (status_message): Use const pointer, in case strsignal
64 is #defined to safe_strsignal.
65 * sysdep.c (sys_siglist, init_signals): Always define and
66 initialize a substitute sys_siglist if the system does not define
67 one, even if HAVE_STRSIGNAL.
68 (safe_strsignal): Rename from strsignal. Always define,
69 using sys_siglist. Return a const pointer.
70 * syssignal.h (safe_strsignal): New decl.
71 (strsignal) [!HAVE_STRSIGNAL]: Define in terms of safe_strsignal.
72
732012-10-01 Eli Zaretskii <eliz@gnu.org>
74
75 * w32proc.c (timer_loop): Fix code that waits for timer
76 expiration, to avoid high CPU usage.
77
782012-10-01 Stefan Monnier <monnier@iro.umontreal.ca>
79
80 * fns.c (check_hash_table, get_key_arg, maybe_resize_hash_table)
81 (sweep_weak_table): Remove redundant prototypes.
82
832012-10-01 Fabrice Popineau <fabrice.popineau@gmail.com>
84
85 * emacs.c: Move the inclusion of TERM_HEADER after including
86 windows.h on WINDOWSNT. This avoids compilation problems with
87 MSVC.
88
892012-10-01 Eli Zaretskii <eliz@gnu.org>
90
91 * unexw32.c (OFFSET_TO_RVA, RVA_TO_OFFSET)
92 (RVA_TO_SECTION_OFFSET): Encode all macro arguments in parentheses.
93 (RVA_TO_PTR): Cast the result of RVA_TO_OFFSET to 'unsigned char *',
94 as the previous version used 'void *'.
95
96 * ralloc.c (ROUNDUP): Fix last change.
97 (MEM_ROUNDUP): Don't cast MEM_ALIGN, it is already of type
98 'size_t'.
99
100 * w32proc.c <disable_itimers>: New static flag.
101 (init_timers): Initialize it to zero, after creating the critical
102 sections used by the timer threads.
103 (term_timers): Set to 1 before deleting the critical sections.
104 (getitimer, setitimer): If disable_itimers is non-zero, return an
105 error indication without doing anything. Reported by Fabrice
106 Popineau <fabrice.popineau@supelec.fr> as part of bug#12544.
107 (alarm) [HAVE_SETITIMER]: Be more conformant to the expected
108 return results.
109 [!HAVE_SETITIMER]: Behave as the previous version that didn't
110 support timers.
111
112 * emacs.c (shut_down_emacs) [WINDOWSNT]: Move the call to
113 term_ntproc after all the other bookkeeping, to get timers working
114 as long as possible.
115
1162012-10-01 Paul Eggert <eggert@cs.ucla.edu>
117
118 * xdisp.c (syms_of_xdisp): Default message-log-max to 1000, not 100.
119 Suggested by Juri Linkov in
120 <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00821.html>.
121
122 Prefer plain 'static' to 'static inline' (Bug#12541).
123 With static functions, modern compilers inline pretty well by
124 themselves; advice from programmers often hurts as much as it helps.
125 On my host (x86-64, Fedora 17, GCC 4.7.2, default 'configure'),
126 this change shrinks the text size of the Emacs executable by 1.1%
127 without affecting CPU significantly in my benchmark.
128 * alloc.c (mem_find, live_string_p, live_cons_p, live_symbol_p)
129 (live_float_p, live_misc_p, live_vector_p, live_buffer_p)
130 (mark_maybe_object, mark_maybe_pointer, bounded_number):
131 * buffer.c (bset_abbrev_mode, bset_abbrev_table)
132 (bset_auto_fill_function, bset_auto_save_file_format)
133 (bset_auto_save_file_name, bset_backed_up, bset_begv_marker)
134 (bset_bidi_display_reordering, bset_buffer_file_coding_system)
135 (bset_cache_long_line_scans, bset_case_fold_search)
136 (bset_ctl_arrow, bset_cursor_in_non_selected_windows)
137 (bset_cursor_type, bset_display_table, bset_extra_line_spacing)
138 (bset_file_format, bset_file_truename, bset_fringe_cursor_alist)
139 (bset_fringe_indicator_alist, bset_fringes_outside_margins)
140 (bset_header_line_format, bset_indicate_buffer_boundaries)
141 (bset_indicate_empty_lines, bset_invisibility_spec)
142 (bset_left_fringe_width, bset_major_mode, bset_mark)
143 (bset_minor_modes, bset_mode_line_format, bset_mode_name)
144 (bset_name, bset_overwrite_mode, bset_pt_marker)
145 (bset_right_fringe_width, bset_save_length)
146 (bset_scroll_bar_width, bset_scroll_down_aggressively)
147 (bset_scroll_up_aggressively, bset_selective_display)
148 (bset_selective_display_ellipses, bset_vertical_scroll_bar_type)
149 (bset_word_wrap, bset_zv_marker, set_buffer_overlays_before)
150 (set_buffer_overlays_after):
151 * category.c (bset_category_table):
152 * charset.c (read_hex):
153 * coding.c (produce_composition, produce_charset)
154 (handle_composition_annotation, handle_charset_annotation)
155 (char_encodable_p):
156 * dispnew.c (swap_glyph_pointers, copy_row_except_pointers)
157 (assign_row, set_frame_matrix_frame, make_current)
158 (add_row_entry):
159 * eval.c (set_specpdl_symbol, set_specpdl_old_value):
160 * fns.c (maybe_resize_hash_table):
161 * frame.c (fset_buffer_predicate, fset_minibuffer_window):
162 * gmalloc.c (register_heapinfo):
163 * image.c (lookup_image_type):
164 * intervals.c (set_interval_object, set_interval_left)
165 (set_interval_right, copy_interval_parent, rotate_right)
166 (rotate_left, balance_possible_root_interval):
167 * keyboard.c (kset_echo_string, kset_kbd_queue)
168 (kset_keyboard_translate_table, kset_last_prefix_arg)
169 (kset_last_repeatable_command, kset_local_function_key_map)
170 (kset_overriding_terminal_local_map, kset_real_last_command)
171 (kset_system_key_syms, clear_event, set_prop):
172 * lread.c (digit_to_number):
173 * marker.c (attach_marker, live_buffer, set_marker_internal):
174 * nsterm.m (ns_compute_glyph_string_overhangs):
175 * process.c (pset_buffer, pset_command)
176 (pset_decode_coding_system, pset_decoding_buf)
177 (pset_encode_coding_system, pset_encoding_buf, pset_filter)
178 (pset_log, pset_mark, pset_name, pset_plist, pset_sentinel)
179 (pset_status, pset_tty_name, pset_type, pset_write_queue):
180 * syntax.c (bset_syntax_table, dec_bytepos):
181 * terminal.c (tset_param_alist):
182 * textprop.c (interval_has_some_properties)
183 (interval_has_some_properties_list):
184 * window.c (wset_combination_limit, wset_dedicated)
185 (wset_display_table, wset_hchild, wset_left_fringe_width)
186 (wset_left_margin_cols, wset_new_normal, wset_new_total)
187 (wset_normal_cols, wset_normal_lines, wset_parent, wset_pointm)
188 (wset_right_fringe_width, wset_right_margin_cols)
189 (wset_scroll_bar_width, wset_start, wset_temslot, wset_vchild)
190 (wset_vertical_scroll_bar_type, wset_window_parameters):
191 * xdisp.c (wset_base_line_number, wset_base_line_pos)
192 (wset_column_number_displayed, wset_region_showing)
193 (window_box_edges, run_window_scroll_functions)
194 (append_glyph_string_lists, prepend_glyph_string_lists)
195 (append_glyph_string, set_glyph_string_background_width)
196 (append_glyph, append_composite_glyph)
197 (take_vertical_position_into_account):
198 * xfaces.c (x_create_gc, x_free_gc, merge_face_vectors)
199 (face_attr_equal_p, lface_equal_p, hash_string_case_insensitive)
200 (lface_hash, lface_same_font_attributes_p, lookup_face):
201 * xml.c (libxml2_loaded_p):
202 * xterm.c (x_set_mode_line_face_gc, x_set_glyph_string_gc)
203 (x_set_glyph_string_clipping, x_clear_glyph_string_rect):
204 Now 'static', not 'static inline'.
205
206 * bidi.c: Tune.
207 (bidi_copy_it): Do the whole copy with a single memcpy.
208 (bidi_char_at_pos): Merge the two STRING_CHAR calls into one.
209
210 Revert the FOLLOW-SYMLINKS change for file-attributes.
211 Doing it right would require several changes to Tramp, and there's
212 not enough time to get that tested before the freeze today.
213 * dired.c (directory_files_internal, Ffile_attributes):
214 Undo last change.
215
216 * frame.c (x_report_frame_params): Port better to wider ints.
217 Do not assume that EMACS_UINT is the same width as uprintmax_t,
218 or that pointers can be printed in 15 decimal digits.
219 Avoid GCC warnings if EMACS_UINT is wider than a pointer.
220
2212012-09-30 Fabrice Popineau <fabrice.popineau@supelec.fr>
222
223 Support x64 build on MS-Windows.
224 * w32term.h (SCROLL_BAR_PACK, SCROLL_BAR_UNPACK): Define for x64.
225 (SET_SCROLL_BAR_W32_WINDOW): Cast ID to intptr_t, for
226 compatibility with x64.
227 (x_get_focus_frame): Add prototype.
228
229 * w32term.c (w32_draw_underwave): Don't use GCC extensions for
230 defining an XRectangle structure.
231
232 * w32proc.c (RVA_TO_PTR, w32_executable_type): Fix pointer
233 arithmetics for compatibility with x64.
234
235 * w32menu.c (add_menu_item): Use UINT_PTR instead of UINT, for
236 compatibility with x64.
237
238 * w32heap.h: Adjust prototypes and declarations.
239
240 * w32heap.c (RVA_TO_PTR, allocate_heap, sbrk, init_heap)
241 (round_heap): Use DWORD_PTR, ptrdiff_t and size_t instead of
242 DWORD, long, and unsigned long, for compatibility with x64.
243 (allocate_heap) [_WIN64]: Reserve 32GB of memory.
244 (sbrk): Argument is now of type ptrdiff_t.
245
246 * w32fns.c (HMONITOR): Condition declaration on _WIN32_WINNT being
247 less than 0x0500.
248 (w32_msg_pump): Use WPARAM type for 'result'.
249
250 * w32.c (init_environment, get_emacs_configuration): Support AMD64
251 architecture.
252 (init_ntproc): Cast arguments of _open_osfhandle to intptr_t, for
253 compatibility with x64.
254
255 * vm-limit.c (lim_data): Now size_t.
256 (check_memory_limits): Adjust prototypes of real_morecore and
257 __morecore to receive argument of type ptrdiff_t. Use size_t for
258 five_percent and data_size.
259
260 * unexw32.c: Use DWORD_PTR instead of DWORD for file-scope
261 variables, for compatibility with x64.
262 (rva_to_section, offset_to_section, relocate_offset)
263 (OFFSET_TO_RVA, RVA_TO_OFFSET, RVA_TO_SECTION_OFFSET)
264 (PTR_TO_RVA, RVA_TO_PTR, OFFSET_TO_PTR, get_section_info)
265 (copy_executable_and_dump_data): Use DWORD_PTR instead of DWORD
266 for compatibility with x64.
267
268 * sysdep.c (STDERR_FILENO): Define if not already defined.
269
270 * ralloc.c (real_morecore): Argument type is now ptrdiff_t.
271 (__morecore): Argument type is now ptrdiff_t.
272 (ROUNDUP, MEM_ROUNDUP): Use size_t instead of 'unsigned long'.
273 (relinquish): Use ptrdiff_t type for 'excess'.
274 (r_alloc_sbrk): Argument type is now ptrdiff_t.
275
276 * makefile.w32-in (HEAPSIZE): Get value from EMACS_HEAPSIZE.
277 (bootstrap-temacs-CMD, bootstrap-temacs-SH): Use $(EMACS_PURESIZE)
278 instead of a literal number.
279
280 * gmalloc.c [WINDOWSNT]: Include w32heap.h.
281 (min): Define only if not already defined.
282
283 * frame.c (x_report_frame_params): Use EMACS_UINT for the return
284 value of FRAME_X_WINDOW, to fit a 64-bit pointer on 64-bit Windows
285 hosts.
286
287 * image.c (x_bitmap_pixmap): Return ptrdiff_t, not int, since
288 'bitmaps' is a pointer.
289
290 * dispextern.h (x_bitmap_pixmap): Adjust prototype.
291
292 * alloc.c (gdb_make_enums_visible): Now conditional on __GNUC__.
293
2942012-09-30 Paul Eggert <eggert@cs.ucla.edu>
295
296 file-attributes has a new optional arg FOLLOW-SYMLINKS.
297 * dired.c (directory_files_internal, Ffile_attributes):
298 New arg follow_symlinks. All uses changed.
299
3002012-09-30 Stefan Monnier <monnier@iro.umontreal.ca>
301
302 * .gdbinit (xbacktrace): Adjust to recent "struct backtrace" change.
303
3042012-09-30 Eli Zaretskii <eliz@gnu.org>
305
306 Support atimers and CPU profiler via profile.c on MS-Windows.
307 * w32proc.c (sig_mask, crit_sig): New static variables.
308 (sys_signal): Support SIGALRM and SIGPROF.
309 (sigemptyset, sigaddset, sigfillset, sigprocmask)
310 (pthread_sigmask, setpgrp): Move here from w32.c. sigaddset,
311 sigfillset, and sigprocmask are no longer no-ops.
312 (sigismember): New function.
313 (struct itimer_data): New definition.
314 (ticks_now, real_itimer, prof_itimer, clocks_min, crit_real)
315 (crit_prof): New static variables.
316 (MAX_SINGLE_SLEEP): New definition.
317 (timer_loop, stop_timer_thread, term_timers, init_timers)
318 (start_timer_thread, getitimer, setitimer): New functions.
319 (alarm): No longer a no-op, calls setitimer.
320
321 * w32.c (term_ntproc): Call term_timers.
322 (init_ntproc): Make sure all signals are unblocked at startup, to
323 erase any traces of dumping. Call init_timers.
324
325 * w32fns.c (hourglass_timer, HOURGLASS_ID): Remove.
326 Windows-specific code to display the hourglass mouse pointer is no
327 longer used.
328 (w32_wnd_proc): Remove code that handled the WM_TIMER message due
329 to hourglass timer expiration.
330 (start_hourglass, cancel_hourglass, DEFAULT_HOURGLASS_DELAY):
331 Remove, no longer used.
332 (w32_note_current_window, show_hourglass, hide_hourglass):
333 New functions, in support of hourglass cursor display similar to other
334 window systems.
335 (syms_of_w32fns): Don't initialize hourglass_timer.
336
337 * xdisp.c (start_hourglass, cancel_hourglass): Now used on
338 WINDOWSNT as well.
339 (start_hourglass) [WINDOWSNT]: Call w32_note_current_window.
340
341 * w32.h (init_timers, term_timers): Add prototypes.
342
3432012-09-30 Kenichi Handa <handa@gnu.org>
344
345 * coding.c (decode_coding_ccl, encode_coding_ccl): Pay attention
346 to the buffer relocation which may be caused by ccl_driver.
347
3482012-09-30 Jan Djärv <jan.h.d@swipnet.se>
349
350 * xfns.c (Fx_file_dialog): Update comment.
351
352 * w32fns.c (Fx_file_dialog): Update comment.
353
354 * nsfns.m (Fns_read_file_name): Add argument DIR_ONLY_P.
355 Initialize panel name field if OSX >= 10.6.
356
357 * fileio.c (Fnext_read_file_uses_dialog_p): Add HAVE_NS.
358
359 * nsfns.m (ns_frame_parm_handlers): Add x_set_fullscreen.
360
361 * nsterm.m (NEW_STYLE_FS): New define.
362 (ns_fullscreen_hook, windowWillEnterFullScreen)
363 (windowDidEnterFullScreen, windowWillExitFullScreen)
364 (windowDidExitFullScreen, toggleFullScreen, handleFS)
365 (setFSValue): New functions.
366 (EmacsFSWindow): New implementation.
367 (canBecomeKeyWindow): New function for EmacsFSWindow.
368 (ns_create_terminal): Set fullscreen_hook to ns_fullscreen_hook.
369 (dealloc): Release nonfs_window if in fullscreen.
370 (updateFrameSize:): Call windowDidMove to update top/left.
371 (windowWillResize:toSize:): Check if frame is still maximized.
372 (initFrameFromEmacs:): Initialize fs_state, fs_before_fs,
373 next_maximized, maximized_width, maximized_height and nonfs_window.
374 Call setCollectionBehavior if NEW_STYLE_FS. Initialize bwidth and
375 tbar_height.
376 (windowWillUseStandardFrame:defaultFrame:): Update frame parameter
377 fullscreen. Set maximized_width/height. Act on next_maximized.
378
379 * nsterm.h (MAC_OS_X_VERSION_10_7, MAC_OS_X_VERSION_10_8): New.
380 (EmacsView): Add variables for fullscreen.
381 (handleFS, setFSValue, toggleFullScreen): New in EmacsView.
382 (EmacsFSWindow): New interface for fullscreen.
383
3842012-09-30 Juanma Barranquero <lekktu@gmail.com>
385
386 * makefile.w32-in ($(BLD)/profiler.$(O)): Update dependencies.
387
3882012-09-30 Chong Yidong <cyd@gnu.org>
389
390 * fns.c (Frandom): Doc fix.
391
3922012-09-30 Martin Rudalics <rudalics@gmx.at>
393
394 * window.c (Vwindow_combination_limit): New default value.
395 (Qwindow_size): New symbol replacing Qtemp_buffer_resize.
396
3972012-09-30 Paul Eggert <eggert@cs.ucla.edu>
398
399 * syssignal.h (PROFILER_CPU_SUPPORT): Don't define if PROFILING.
400 Suggested by Eli Zaretskii in
401 <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00811.html>.
402
4032012-09-30 Eli Zaretskii <eliz@gnu.org>
404
405 * profiler.c (Fprofiler_cpu_stop): Use timer_settime only if
406 HAVE_TIMER_SETTIME is defined.
407
4082012-09-30 Paul Eggert <eggert@cs.ucla.edu>
409
410 Profiler improvements: more-accurate timers, overflow checks.
411 * profiler.c: Don't include stdio.h, limits.h, sys/time.h,
412 signal.h, setjmp.h. Include systime.h instead.
413 (saturated_add): New function.
414 (record_backtrace, current_sample_interval): Use EMACS_INT, not size_t.
415 (record_backtrace, handle_profiler_signal): Saturate on fixnum overflow.
416 (profiler_timer, profiler_timer_ok) [HAVE_TIMER_SETTIME]:
417 New static vars.
418 (enum profiler_cpu_running): New enum.
419 (profiler_cpu_running): Now of that enum type, not bool.
420 All uses changed to store the new value.
421 (handle_profiler_signal): Rename from sigprof_handler_1,
422 for consistency with other handlers. Do not check whether
423 cpu_log is a hash-table if garbage collecting, since it
424 doesn't matter in that case.
425 (deliver_profiler_signal): Rename from sigprof_handler,
426 for consistency with other handlers.
427 (setup_cpu_timer): New function, with much of what used to be in
428 Fprofiler_cpu_start. Check for out-of-range argument.
429 Prefer timer_settime if available, and prefer
430 thread cputime clocks, then process cputime clocks, then
431 monotonic clocks, to the old realtime clock. Use make_timeval
432 to round more-correctly when falling back to setitimer.
433 (Fprofiler_cpu_start): Use it.
434 (Fprofiler_cpu_stop): Prefer timer_settime if available.
435 Don't assume that passing NULL as the 2nd argument of setitimer
436 is the same as passing a pointer to all-zero storage.
437 Ignore SIGPROF afterwards.
438 (malloc_probe): Saturate at MOST_POSITIVE_FIXNUM.
439 * sysdep.c (emacs_sigaction_init): Also mask out SIGPROF in
440 non-fatal signal handlers. Ignore SIGPROF on startup.
441 * syssignal.h (PROFILER_CPU_SUPPORT): Define this macro here, not
442 in profiler.c, since sysdep.c now uses it.
443
444 * sysdep.c (handle_fatal_signal): Bump backtrace size to 40.
445 Suggested by Eli Zaretskii in
446 <http://lists.gnu.org/archive/html/emacs-devel/2012-09/msg00796.html>.
447
4482012-09-29 Juanma Barranquero <lekktu@gmail.com>
449
450 * makefile.w32-in ($(BLD)/profiler.$(O)): Update dependencies.
451
4522012-09-29 Stefan Monnier <monnier@iro.umontreal.ca>
453
454 * lisp.h (struct backtrace): Remove indirection for `function' field.
455 * xdisp.c (redisplay_internal):
456 * profiler.c (record_backtrace, sigprof_handler_1):
457 * alloc.c (Fgarbage_collect):
458 * eval.c (interactive_p, Fsignal, eval_sub, Ffuncall, Fbacktrace)
459 (Fbacktrace_frame): Adjust accordingly.
460
4612012-09-28 Glenn Morris <rgm@gnu.org>
462
463 * eval.c (Frun_hook_with_args, Frun_hook_with_args_until_success)
464 (Frun_hook_with_args_until_failure): Doc fixes.
465
4662012-09-28 Eli Zaretskii <eliz@gnu.org>
467
468 * xdisp.c (syms_of_xdisp) <Qredisplay_internal>: Rename from
469 Qautomatic_redisplay and change the symbol name. All users changed.
470
4712012-09-28 Tomohiro Matsuyama <tomo@cx4a.org>
472
473 * profiler.c (sigprof_handler): Fix race condition.
474
4752012-09-28 Glenn Morris <rgm@gnu.org>
476
477 * lread.c (lisp_file_lexically_bound_p): Handle #! lines. (Bug#12528)
478
12012-09-27 Paul Eggert <eggert@cs.ucla.edu> 4792012-09-27 Paul Eggert <eggert@cs.ucla.edu>
2 480
3 Check more robustly for timer_settime. 481 Check more robustly for timer_settime.
@@ -49,6 +527,7 @@
49 (redisplay_internal): Record itself in backtrace_list. 527 (redisplay_internal): Record itself in backtrace_list.
50 (syms_of_xdisp): Define Qautomatic_redisplay. 528 (syms_of_xdisp): Define Qautomatic_redisplay.
51 529
5302012-09-25 Eli Zaretskii <eliz@gnu.org>
522012-09-25 Juanma Barranquero <lekktu@gmail.com> 5312012-09-25 Juanma Barranquero <lekktu@gmail.com>
53 532
54 * makefile.w32-in ($(BLD)/callproc.$(O)): Update dependencies. 533 * makefile.w32-in ($(BLD)/callproc.$(O)): Update dependencies.
diff --git a/src/alloc.c b/src/alloc.c
index 46c9a10c725..3ed8cc2d990 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -74,6 +74,7 @@ extern void *sbrk ();
74#endif 74#endif
75#ifdef WINDOWSNT 75#ifdef WINDOWSNT
76#include "w32.h" 76#include "w32.h"
77#include "w32heap.h" /* for sbrk */
77#endif 78#endif
78 79
79#ifdef DOUG_LEA_MALLOC 80#ifdef DOUG_LEA_MALLOC
@@ -354,7 +355,7 @@ static void mem_rotate_left (struct mem_node *);
354static void mem_rotate_right (struct mem_node *); 355static void mem_rotate_right (struct mem_node *);
355static void mem_delete (struct mem_node *); 356static void mem_delete (struct mem_node *);
356static void mem_delete_fixup (struct mem_node *); 357static void mem_delete_fixup (struct mem_node *);
357static inline struct mem_node *mem_find (void *); 358static struct mem_node *mem_find (void *);
358#endif 359#endif
359 360
360 361
@@ -3549,7 +3550,7 @@ mem_init (void)
3549/* Value is a pointer to the mem_node containing START. Value is 3550/* Value is a pointer to the mem_node containing START. Value is
3550 MEM_NIL if there is no node in the tree containing START. */ 3551 MEM_NIL if there is no node in the tree containing START. */
3551 3552
3552static inline struct mem_node * 3553static struct mem_node *
3553mem_find (void *start) 3554mem_find (void *start)
3554{ 3555{
3555 struct mem_node *p; 3556 struct mem_node *p;
@@ -3925,7 +3926,7 @@ mem_delete_fixup (struct mem_node *x)
3925/* Value is non-zero if P is a pointer to a live Lisp string on 3926/* Value is non-zero if P is a pointer to a live Lisp string on
3926 the heap. M is a pointer to the mem_block for P. */ 3927 the heap. M is a pointer to the mem_block for P. */
3927 3928
3928static inline bool 3929static bool
3929live_string_p (struct mem_node *m, void *p) 3930live_string_p (struct mem_node *m, void *p)
3930{ 3931{
3931 if (m->type == MEM_TYPE_STRING) 3932 if (m->type == MEM_TYPE_STRING)
@@ -3948,7 +3949,7 @@ live_string_p (struct mem_node *m, void *p)
3948/* Value is non-zero if P is a pointer to a live Lisp cons on 3949/* Value is non-zero if P is a pointer to a live Lisp cons on
3949 the heap. M is a pointer to the mem_block for P. */ 3950 the heap. M is a pointer to the mem_block for P. */
3950 3951
3951static inline bool 3952static bool
3952live_cons_p (struct mem_node *m, void *p) 3953live_cons_p (struct mem_node *m, void *p)
3953{ 3954{
3954 if (m->type == MEM_TYPE_CONS) 3955 if (m->type == MEM_TYPE_CONS)
@@ -3974,7 +3975,7 @@ live_cons_p (struct mem_node *m, void *p)
3974/* Value is non-zero if P is a pointer to a live Lisp symbol on 3975/* Value is non-zero if P is a pointer to a live Lisp symbol on
3975 the heap. M is a pointer to the mem_block for P. */ 3976 the heap. M is a pointer to the mem_block for P. */
3976 3977
3977static inline bool 3978static bool
3978live_symbol_p (struct mem_node *m, void *p) 3979live_symbol_p (struct mem_node *m, void *p)
3979{ 3980{
3980 if (m->type == MEM_TYPE_SYMBOL) 3981 if (m->type == MEM_TYPE_SYMBOL)
@@ -4000,7 +4001,7 @@ live_symbol_p (struct mem_node *m, void *p)
4000/* Value is non-zero if P is a pointer to a live Lisp float on 4001/* Value is non-zero if P is a pointer to a live Lisp float on
4001 the heap. M is a pointer to the mem_block for P. */ 4002 the heap. M is a pointer to the mem_block for P. */
4002 4003
4003static inline bool 4004static bool
4004live_float_p (struct mem_node *m, void *p) 4005live_float_p (struct mem_node *m, void *p)
4005{ 4006{
4006 if (m->type == MEM_TYPE_FLOAT) 4007 if (m->type == MEM_TYPE_FLOAT)
@@ -4024,7 +4025,7 @@ live_float_p (struct mem_node *m, void *p)
4024/* Value is non-zero if P is a pointer to a live Lisp Misc on 4025/* Value is non-zero if P is a pointer to a live Lisp Misc on
4025 the heap. M is a pointer to the mem_block for P. */ 4026 the heap. M is a pointer to the mem_block for P. */
4026 4027
4027static inline bool 4028static bool
4028live_misc_p (struct mem_node *m, void *p) 4029live_misc_p (struct mem_node *m, void *p)
4029{ 4030{
4030 if (m->type == MEM_TYPE_MISC) 4031 if (m->type == MEM_TYPE_MISC)
@@ -4050,7 +4051,7 @@ live_misc_p (struct mem_node *m, void *p)
4050/* Value is non-zero if P is a pointer to a live vector-like object. 4051/* Value is non-zero if P is a pointer to a live vector-like object.
4051 M is a pointer to the mem_block for P. */ 4052 M is a pointer to the mem_block for P. */
4052 4053
4053static inline bool 4054static bool
4054live_vector_p (struct mem_node *m, void *p) 4055live_vector_p (struct mem_node *m, void *p)
4055{ 4056{
4056 if (m->type == MEM_TYPE_VECTOR_BLOCK) 4057 if (m->type == MEM_TYPE_VECTOR_BLOCK)
@@ -4086,7 +4087,7 @@ live_vector_p (struct mem_node *m, void *p)
4086/* Value is non-zero if P is a pointer to a live buffer. M is a 4087/* Value is non-zero if P is a pointer to a live buffer. M is a
4087 pointer to the mem_block for P. */ 4088 pointer to the mem_block for P. */
4088 4089
4089static inline bool 4090static bool
4090live_buffer_p (struct mem_node *m, void *p) 4091live_buffer_p (struct mem_node *m, void *p)
4091{ 4092{
4092 /* P must point to the start of the block, and the buffer 4093 /* P must point to the start of the block, and the buffer
@@ -4152,7 +4153,7 @@ DEFUN ("gc-status", Fgc_status, Sgc_status, 0, 0, "",
4152 4153
4153/* Mark OBJ if we can prove it's a Lisp_Object. */ 4154/* Mark OBJ if we can prove it's a Lisp_Object. */
4154 4155
4155static inline void 4156static void
4156mark_maybe_object (Lisp_Object obj) 4157mark_maybe_object (Lisp_Object obj)
4157{ 4158{
4158 void *po; 4159 void *po;
@@ -4221,7 +4222,7 @@ mark_maybe_object (Lisp_Object obj)
4221/* If P points to Lisp data, mark that as live if it isn't already 4222/* If P points to Lisp data, mark that as live if it isn't already
4222 marked. */ 4223 marked. */
4223 4224
4224static inline void 4225static void
4225mark_maybe_pointer (void *p) 4226mark_maybe_pointer (void *p)
4226{ 4227{
4227 struct mem_node *m; 4228 struct mem_node *m;
@@ -5051,7 +5052,7 @@ inhibit_garbage_collection (void)
5051/* Used to avoid possible overflows when 5052/* Used to avoid possible overflows when
5052 converting from C to Lisp integers. */ 5053 converting from C to Lisp integers. */
5053 5054
5054static inline Lisp_Object 5055static Lisp_Object
5055bounded_number (EMACS_INT number) 5056bounded_number (EMACS_INT number)
5056{ 5057{
5057 return make_number (min (MOST_POSITIVE_FIXNUM, number)); 5058 return make_number (min (MOST_POSITIVE_FIXNUM, number));
@@ -5112,8 +5113,8 @@ See Info node `(elisp)Garbage Collection'. */)
5112 5113
5113 /* Record this function, so it appears on the profiler's backtraces. */ 5114 /* Record this function, so it appears on the profiler's backtraces. */
5114 backtrace.next = backtrace_list; 5115 backtrace.next = backtrace_list;
5115 backtrace.function = &Qautomatic_gc; 5116 backtrace.function = Qautomatic_gc;
5116 backtrace.args = &Qautomatic_gc; 5117 backtrace.args = &Qnil;
5117 backtrace.nargs = 0; 5118 backtrace.nargs = 0;
5118 backtrace.debug_on_exit = 0; 5119 backtrace.debug_on_exit = 0;
5119 backtrace_list = &backtrace; 5120 backtrace_list = &backtrace;
@@ -6607,7 +6608,8 @@ The time is in seconds as a floating point value. */);
6607/* When compiled with GCC, GDB might say "No enum type named 6608/* When compiled with GCC, GDB might say "No enum type named
6608 pvec_type" if we don't have at least one symbol with that type, and 6609 pvec_type" if we don't have at least one symbol with that type, and
6609 then xbacktrace could fail. Similarly for the other enums and 6610 then xbacktrace could fail. Similarly for the other enums and
6610 their values. */ 6611 their values. Some non-GCC compilers don't like these constructs. */
6612#ifdef __GNUC__
6611union 6613union
6612{ 6614{
6613 enum CHARTAB_SIZE_BITS CHARTAB_SIZE_BITS; 6615 enum CHARTAB_SIZE_BITS CHARTAB_SIZE_BITS;
@@ -6627,3 +6629,4 @@ union
6627 enum lsb_bits lsb_bits; 6629 enum lsb_bits lsb_bits;
6628#endif 6630#endif
6629} const EXTERNALLY_VISIBLE gdb_make_enums_visible = {0}; 6631} const EXTERNALLY_VISIBLE gdb_make_enums_visible = {0};
6632#endif /* __GNUC__ */
diff --git a/src/atimer.c b/src/atimer.c
index 048c62798ef..5752192be76 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -42,7 +42,7 @@ static struct atimer *atimers;
42 42
43/* The alarm timer and whether it was properly initialized, if 43/* The alarm timer and whether it was properly initialized, if
44 POSIX timers are available. */ 44 POSIX timers are available. */
45#ifdef HAVE_TIMER_SETTIME 45#ifdef HAVE_ITIMERSPEC
46static timer_t alarm_timer; 46static timer_t alarm_timer;
47static bool alarm_timer_ok; 47static bool alarm_timer_ok;
48#endif 48#endif
@@ -296,7 +296,7 @@ set_alarm (void)
296#endif 296#endif
297 EMACS_TIME now, interval; 297 EMACS_TIME now, interval;
298 298
299#ifdef HAVE_TIMER_SETTIME 299#ifdef HAVE_ITIMERSPEC
300 if (alarm_timer_ok) 300 if (alarm_timer_ok)
301 { 301 {
302 struct itimerspec ispec; 302 struct itimerspec ispec;
@@ -416,7 +416,7 @@ void
416init_atimer (void) 416init_atimer (void)
417{ 417{
418 struct sigaction action; 418 struct sigaction action;
419#ifdef HAVE_TIMER_SETTIME 419#ifdef HAVE_ITIMERSPEC
420 struct sigevent sigev; 420 struct sigevent sigev;
421 sigev.sigev_notify = SIGEV_SIGNAL; 421 sigev.sigev_notify = SIGEV_SIGNAL;
422 sigev.sigev_signo = SIGALRM; 422 sigev.sigev_signo = SIGALRM;
diff --git a/src/bidi.c b/src/bidi.c
index af0209565e2..6f3d749ef22 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -96,7 +96,7 @@ static Lisp_Object Qparagraph_start, Qparagraph_separate;
96 96
97/* Return the bidi type of a character CH, subject to the current 97/* Return the bidi type of a character CH, subject to the current
98 directional OVERRIDE. */ 98 directional OVERRIDE. */
99static inline bidi_type_t 99static bidi_type_t
100bidi_get_type (int ch, bidi_dir_t override) 100bidi_get_type (int ch, bidi_dir_t override)
101{ 101{
102 bidi_type_t default_type; 102 bidi_type_t default_type;
@@ -145,14 +145,14 @@ bidi_get_type (int ch, bidi_dir_t override)
145 } 145 }
146} 146}
147 147
148static inline void 148static void
149bidi_check_type (bidi_type_t type) 149bidi_check_type (bidi_type_t type)
150{ 150{
151 eassert (UNKNOWN_BT <= type && type <= NEUTRAL_ON); 151 eassert (UNKNOWN_BT <= type && type <= NEUTRAL_ON);
152} 152}
153 153
154/* Given a bidi TYPE of a character, return its category. */ 154/* Given a bidi TYPE of a character, return its category. */
155static inline bidi_category_t 155static bidi_category_t
156bidi_get_category (bidi_type_t type) 156bidi_get_category (bidi_type_t type)
157{ 157{
158 switch (type) 158 switch (type)
@@ -226,7 +226,7 @@ bidi_mirror_char (int c)
226 embedding levels on either side of the run boundary. Also, update 226 embedding levels on either side of the run boundary. Also, update
227 the saved info about previously seen characters, since that info is 227 the saved info about previously seen characters, since that info is
228 generally valid for a single level run. */ 228 generally valid for a single level run. */
229static inline void 229static void
230bidi_set_sor_type (struct bidi_it *bidi_it, int level_before, int level_after) 230bidi_set_sor_type (struct bidi_it *bidi_it, int level_before, int level_after)
231{ 231{
232 int higher_level = (level_before > level_after ? level_before : level_after); 232 int higher_level = (level_before > level_after ? level_before : level_after);
@@ -257,7 +257,7 @@ bidi_set_sor_type (struct bidi_it *bidi_it, int level_before, int level_after)
257 257
258/* Push the current embedding level and override status; reset the 258/* Push the current embedding level and override status; reset the
259 current level to LEVEL and the current override status to OVERRIDE. */ 259 current level to LEVEL and the current override status to OVERRIDE. */
260static inline void 260static void
261bidi_push_embedding_level (struct bidi_it *bidi_it, 261bidi_push_embedding_level (struct bidi_it *bidi_it,
262 int level, bidi_dir_t override) 262 int level, bidi_dir_t override)
263{ 263{
@@ -269,7 +269,7 @@ bidi_push_embedding_level (struct bidi_it *bidi_it,
269 269
270/* Pop the embedding level and directional override status from the 270/* Pop the embedding level and directional override status from the
271 stack, and return the new level. */ 271 stack, and return the new level. */
272static inline int 272static int
273bidi_pop_embedding_level (struct bidi_it *bidi_it) 273bidi_pop_embedding_level (struct bidi_it *bidi_it)
274{ 274{
275 /* UAX#9 says to ignore invalid PDFs. */ 275 /* UAX#9 says to ignore invalid PDFs. */
@@ -279,7 +279,7 @@ bidi_pop_embedding_level (struct bidi_it *bidi_it)
279} 279}
280 280
281/* Record in SAVED_INFO the information about the current character. */ 281/* Record in SAVED_INFO the information about the current character. */
282static inline void 282static void
283bidi_remember_char (struct bidi_saved_info *saved_info, 283bidi_remember_char (struct bidi_saved_info *saved_info,
284 struct bidi_it *bidi_it) 284 struct bidi_it *bidi_it)
285{ 285{
@@ -295,18 +295,14 @@ bidi_remember_char (struct bidi_saved_info *saved_info,
295 295
296/* Copy the bidi iterator from FROM to TO. To save cycles, this only 296/* Copy the bidi iterator from FROM to TO. To save cycles, this only
297 copies the part of the level stack that is actually in use. */ 297 copies the part of the level stack that is actually in use. */
298static inline void 298static void
299bidi_copy_it (struct bidi_it *to, struct bidi_it *from) 299bidi_copy_it (struct bidi_it *to, struct bidi_it *from)
300{ 300{
301 int i; 301 /* Copy everything from the start through the active part of
302 302 the level stack. */
303 /* Copy everything except the level stack and beyond. */ 303 memcpy (to, from,
304 memcpy (to, from, offsetof (struct bidi_it, level_stack[0])); 304 (offsetof (struct bidi_it, level_stack[1])
305 305 + from->stack_idx * sizeof from->level_stack[0]));
306 /* Copy the active part of the level stack. */
307 to->level_stack[0] = from->level_stack[0]; /* level zero is always in use */
308 for (i = 1; i <= from->stack_idx; i++)
309 to->level_stack[i] = from->level_stack[i];
310} 306}
311 307
312 308
@@ -344,7 +340,7 @@ enum
344 intact. This is called when the cached information is no more 340 intact. This is called when the cached information is no more
345 useful for the current iteration, e.g. when we were reseated to a 341 useful for the current iteration, e.g. when we were reseated to a
346 new position on the same object. */ 342 new position on the same object. */
347static inline void 343static void
348bidi_cache_reset (void) 344bidi_cache_reset (void)
349{ 345{
350 bidi_cache_idx = bidi_cache_start; 346 bidi_cache_idx = bidi_cache_start;
@@ -355,7 +351,7 @@ bidi_cache_reset (void)
355 iterator for reordering a buffer or a string that does not come 351 iterator for reordering a buffer or a string that does not come
356 from display properties, because that means all the previously 352 from display properties, because that means all the previously
357 cached info is of no further use. */ 353 cached info is of no further use. */
358static inline void 354static void
359bidi_cache_shrink (void) 355bidi_cache_shrink (void)
360{ 356{
361 if (bidi_cache_size > BIDI_CACHE_CHUNK) 357 if (bidi_cache_size > BIDI_CACHE_CHUNK)
@@ -366,7 +362,7 @@ bidi_cache_shrink (void)
366 bidi_cache_reset (); 362 bidi_cache_reset ();
367} 363}
368 364
369static inline void 365static void
370bidi_cache_fetch_state (ptrdiff_t idx, struct bidi_it *bidi_it) 366bidi_cache_fetch_state (ptrdiff_t idx, struct bidi_it *bidi_it)
371{ 367{
372 int current_scan_dir = bidi_it->scan_dir; 368 int current_scan_dir = bidi_it->scan_dir;
@@ -383,7 +379,7 @@ bidi_cache_fetch_state (ptrdiff_t idx, struct bidi_it *bidi_it)
383 level less or equal to LEVEL. if LEVEL is -1, disregard the 379 level less or equal to LEVEL. if LEVEL is -1, disregard the
384 resolved levels in cached states. DIR, if non-zero, means search 380 resolved levels in cached states. DIR, if non-zero, means search
385 in that direction from the last cache hit. */ 381 in that direction from the last cache hit. */
386static inline ptrdiff_t 382static ptrdiff_t
387bidi_cache_search (ptrdiff_t charpos, int level, int dir) 383bidi_cache_search (ptrdiff_t charpos, int level, int dir)
388{ 384{
389 ptrdiff_t i, i_start; 385 ptrdiff_t i, i_start;
@@ -488,7 +484,7 @@ bidi_cache_find_level_change (int level, int dir, bool before)
488 return -1; 484 return -1;
489} 485}
490 486
491static inline void 487static void
492bidi_cache_ensure_space (ptrdiff_t idx) 488bidi_cache_ensure_space (ptrdiff_t idx)
493{ 489{
494 /* Enlarge the cache as needed. */ 490 /* Enlarge the cache as needed. */
@@ -510,7 +506,7 @@ bidi_cache_ensure_space (ptrdiff_t idx)
510 } 506 }
511} 507}
512 508
513static inline void 509static void
514bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved) 510bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved)
515{ 511{
516 ptrdiff_t idx; 512 ptrdiff_t idx;
@@ -567,7 +563,7 @@ bidi_cache_iterator_state (struct bidi_it *bidi_it, bool resolved)
567 bidi_cache_idx = idx + 1; 563 bidi_cache_idx = idx + 1;
568} 564}
569 565
570static inline bidi_type_t 566static bidi_type_t
571bidi_cache_find (ptrdiff_t charpos, int level, struct bidi_it *bidi_it) 567bidi_cache_find (ptrdiff_t charpos, int level, struct bidi_it *bidi_it)
572{ 568{
573 ptrdiff_t i = bidi_cache_search (charpos, level, bidi_it->scan_dir); 569 ptrdiff_t i = bidi_cache_search (charpos, level, bidi_it->scan_dir);
@@ -587,7 +583,7 @@ bidi_cache_find (ptrdiff_t charpos, int level, struct bidi_it *bidi_it)
587 return UNKNOWN_BT; 583 return UNKNOWN_BT;
588} 584}
589 585
590static inline int 586static int
591bidi_peek_at_next_level (struct bidi_it *bidi_it) 587bidi_peek_at_next_level (struct bidi_it *bidi_it)
592{ 588{
593 if (bidi_cache_idx == bidi_cache_start || bidi_cache_last_idx == -1) 589 if (bidi_cache_idx == bidi_cache_start || bidi_cache_last_idx == -1)
@@ -790,7 +786,7 @@ bidi_initialize (void)
790 786
791/* Do whatever UAX#9 clause X8 says should be done at paragraph's 787/* Do whatever UAX#9 clause X8 says should be done at paragraph's
792 end. */ 788 end. */
793static inline void 789static void
794bidi_set_paragraph_end (struct bidi_it *bidi_it) 790bidi_set_paragraph_end (struct bidi_it *bidi_it)
795{ 791{
796 bidi_it->invalid_levels = 0; 792 bidi_it->invalid_levels = 0;
@@ -872,7 +868,7 @@ bidi_line_init (struct bidi_it *bidi_it)
872/* Count bytes in string S between BEG/BEGBYTE and END. BEG and END 868/* Count bytes in string S between BEG/BEGBYTE and END. BEG and END
873 are zero-based character positions in S, BEGBYTE is byte position 869 are zero-based character positions in S, BEGBYTE is byte position
874 corresponding to BEG. UNIBYTE means S is a unibyte string. */ 870 corresponding to BEG. UNIBYTE means S is a unibyte string. */
875static inline ptrdiff_t 871static ptrdiff_t
876bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg, 872bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg,
877 const ptrdiff_t begbyte, const ptrdiff_t end, bool unibyte) 873 const ptrdiff_t begbyte, const ptrdiff_t end, bool unibyte)
878{ 874{
@@ -896,22 +892,22 @@ bidi_count_bytes (const unsigned char *s, const ptrdiff_t beg,
896 return p - start; 892 return p - start;
897} 893}
898 894
899/* Fetch and returns the character at byte position BYTEPOS. If S is 895/* Fetch and return the character at byte position BYTEPOS. If S is
900 non-NULL, fetch the character from string S; otherwise fetch the 896 non-NULL, fetch the character from string S; otherwise fetch the
901 character from the current buffer. UNIBYTE means S is a 897 character from the current buffer. UNIBYTE means S is a
902 unibyte string. */ 898 unibyte string. */
903static inline int 899static int
904bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, bool unibyte) 900bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, bool unibyte)
905{ 901{
906 if (s) 902 if (s)
907 { 903 {
904 s += bytepos;
908 if (unibyte) 905 if (unibyte)
909 return s[bytepos]; 906 return *s;
910 else
911 return STRING_CHAR (s + bytepos);
912 } 907 }
913 else 908 else
914 return FETCH_MULTIBYTE_CHAR (bytepos); 909 s = BYTE_POS_ADDR (bytepos);
910 return STRING_CHAR (s);
915} 911}
916 912
917/* Fetch and return the character at BYTEPOS/CHARPOS. If that 913/* Fetch and return the character at BYTEPOS/CHARPOS. If that
@@ -928,7 +924,7 @@ bidi_char_at_pos (ptrdiff_t bytepos, const unsigned char *s, bool unibyte)
928 u+2029 to handle it as a paragraph separator. STRING->s is the C 924 u+2029 to handle it as a paragraph separator. STRING->s is the C
929 string to iterate, or NULL if iterating over a buffer or a Lisp 925 string to iterate, or NULL if iterating over a buffer or a Lisp
930 string; in the latter case, STRING->lstring is the Lisp string. */ 926 string; in the latter case, STRING->lstring is the Lisp string. */
931static inline int 927static int
932bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos, 928bidi_fetch_char (ptrdiff_t bytepos, ptrdiff_t charpos, ptrdiff_t *disp_pos,
933 int *disp_prop, struct bidi_string_data *string, 929 int *disp_prop, struct bidi_string_data *string,
934 bool frame_window_p, ptrdiff_t *ch_len, ptrdiff_t *nchars) 930 bool frame_window_p, ptrdiff_t *ch_len, ptrdiff_t *nchars)
@@ -1318,7 +1314,7 @@ bidi_paragraph_init (bidi_dir_t dir, struct bidi_it *bidi_it, bool no_default_p)
1318 The rest of this file constitutes the core of the UBA implementation. 1314 The rest of this file constitutes the core of the UBA implementation.
1319 ***********************************************************************/ 1315 ***********************************************************************/
1320 1316
1321static inline bool 1317static bool
1322bidi_explicit_dir_char (int ch) 1318bidi_explicit_dir_char (int ch)
1323{ 1319{
1324 bidi_type_t ch_type; 1320 bidi_type_t ch_type;
@@ -1841,7 +1837,7 @@ bidi_resolve_weak (struct bidi_it *bidi_it)
1841 1837
1842/* Resolve the type of a neutral character according to the type of 1838/* Resolve the type of a neutral character according to the type of
1843 surrounding strong text and the current embedding level. */ 1839 surrounding strong text and the current embedding level. */
1844static inline bidi_type_t 1840static bidi_type_t
1845bidi_resolve_neutral_1 (bidi_type_t prev_type, bidi_type_t next_type, int lev) 1841bidi_resolve_neutral_1 (bidi_type_t prev_type, bidi_type_t next_type, int lev)
1846{ 1842{
1847 /* N1: European and Arabic numbers are treated as though they were R. */ 1843 /* N1: European and Arabic numbers are treated as though they were R. */
diff --git a/src/buffer.c b/src/buffer.c
index 356a308fce6..425d05ca790 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -150,222 +150,222 @@ static void modify_overlay (struct buffer *, ptrdiff_t, ptrdiff_t);
150static Lisp_Object buffer_lisp_local_variables (struct buffer *, bool); 150static Lisp_Object buffer_lisp_local_variables (struct buffer *, bool);
151 151
152/* These setters are used only in this file, so they can be private. */ 152/* These setters are used only in this file, so they can be private. */
153static inline void 153static void
154bset_abbrev_mode (struct buffer *b, Lisp_Object val) 154bset_abbrev_mode (struct buffer *b, Lisp_Object val)
155{ 155{
156 b->INTERNAL_FIELD (abbrev_mode) = val; 156 b->INTERNAL_FIELD (abbrev_mode) = val;
157} 157}
158static inline void 158static void
159bset_abbrev_table (struct buffer *b, Lisp_Object val) 159bset_abbrev_table (struct buffer *b, Lisp_Object val)
160{ 160{
161 b->INTERNAL_FIELD (abbrev_table) = val; 161 b->INTERNAL_FIELD (abbrev_table) = val;
162} 162}
163static inline void 163static void
164bset_auto_fill_function (struct buffer *b, Lisp_Object val) 164bset_auto_fill_function (struct buffer *b, Lisp_Object val)
165{ 165{
166 b->INTERNAL_FIELD (auto_fill_function) = val; 166 b->INTERNAL_FIELD (auto_fill_function) = val;
167} 167}
168static inline void 168static void
169bset_auto_save_file_format (struct buffer *b, Lisp_Object val) 169bset_auto_save_file_format (struct buffer *b, Lisp_Object val)
170{ 170{
171 b->INTERNAL_FIELD (auto_save_file_format) = val; 171 b->INTERNAL_FIELD (auto_save_file_format) = val;
172} 172}
173static inline void 173static void
174bset_auto_save_file_name (struct buffer *b, Lisp_Object val) 174bset_auto_save_file_name (struct buffer *b, Lisp_Object val)
175{ 175{
176 b->INTERNAL_FIELD (auto_save_file_name) = val; 176 b->INTERNAL_FIELD (auto_save_file_name) = val;
177} 177}
178static inline void 178static void
179bset_backed_up (struct buffer *b, Lisp_Object val) 179bset_backed_up (struct buffer *b, Lisp_Object val)
180{ 180{
181 b->INTERNAL_FIELD (backed_up) = val; 181 b->INTERNAL_FIELD (backed_up) = val;
182} 182}
183static inline void 183static void
184bset_begv_marker (struct buffer *b, Lisp_Object val) 184bset_begv_marker (struct buffer *b, Lisp_Object val)
185{ 185{
186 b->INTERNAL_FIELD (begv_marker) = val; 186 b->INTERNAL_FIELD (begv_marker) = val;
187} 187}
188static inline void 188static void
189bset_bidi_display_reordering (struct buffer *b, Lisp_Object val) 189bset_bidi_display_reordering (struct buffer *b, Lisp_Object val)
190{ 190{
191 b->INTERNAL_FIELD (bidi_display_reordering) = val; 191 b->INTERNAL_FIELD (bidi_display_reordering) = val;
192} 192}
193static inline void 193static void
194bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val) 194bset_buffer_file_coding_system (struct buffer *b, Lisp_Object val)
195{ 195{
196 b->INTERNAL_FIELD (buffer_file_coding_system) = val; 196 b->INTERNAL_FIELD (buffer_file_coding_system) = val;
197} 197}
198static inline void 198static void
199bset_cache_long_line_scans (struct buffer *b, Lisp_Object val) 199bset_cache_long_line_scans (struct buffer *b, Lisp_Object val)
200{ 200{
201 b->INTERNAL_FIELD (cache_long_line_scans) = val; 201 b->INTERNAL_FIELD (cache_long_line_scans) = val;
202} 202}
203static inline void 203static void
204bset_case_fold_search (struct buffer *b, Lisp_Object val) 204bset_case_fold_search (struct buffer *b, Lisp_Object val)
205{ 205{
206 b->INTERNAL_FIELD (case_fold_search) = val; 206 b->INTERNAL_FIELD (case_fold_search) = val;
207} 207}
208static inline void 208static void
209bset_ctl_arrow (struct buffer *b, Lisp_Object val) 209bset_ctl_arrow (struct buffer *b, Lisp_Object val)
210{ 210{
211 b->INTERNAL_FIELD (ctl_arrow) = val; 211 b->INTERNAL_FIELD (ctl_arrow) = val;
212} 212}
213static inline void 213static void
214bset_cursor_in_non_selected_windows (struct buffer *b, Lisp_Object val) 214bset_cursor_in_non_selected_windows (struct buffer *b, Lisp_Object val)
215{ 215{
216 b->INTERNAL_FIELD (cursor_in_non_selected_windows) = val; 216 b->INTERNAL_FIELD (cursor_in_non_selected_windows) = val;
217} 217}
218static inline void 218static void
219bset_cursor_type (struct buffer *b, Lisp_Object val) 219bset_cursor_type (struct buffer *b, Lisp_Object val)
220{ 220{
221 b->INTERNAL_FIELD (cursor_type) = val; 221 b->INTERNAL_FIELD (cursor_type) = val;
222} 222}
223static inline void 223static void
224bset_display_table (struct buffer *b, Lisp_Object val) 224bset_display_table (struct buffer *b, Lisp_Object val)
225{ 225{
226 b->INTERNAL_FIELD (display_table) = val; 226 b->INTERNAL_FIELD (display_table) = val;
227} 227}
228static inline void 228static void
229bset_extra_line_spacing (struct buffer *b, Lisp_Object val) 229bset_extra_line_spacing (struct buffer *b, Lisp_Object val)
230{ 230{
231 b->INTERNAL_FIELD (extra_line_spacing) = val; 231 b->INTERNAL_FIELD (extra_line_spacing) = val;
232} 232}
233static inline void 233static void
234bset_file_format (struct buffer *b, Lisp_Object val) 234bset_file_format (struct buffer *b, Lisp_Object val)
235{ 235{
236 b->INTERNAL_FIELD (file_format) = val; 236 b->INTERNAL_FIELD (file_format) = val;
237} 237}
238static inline void 238static void
239bset_file_truename (struct buffer *b, Lisp_Object val) 239bset_file_truename (struct buffer *b, Lisp_Object val)
240{ 240{
241 b->INTERNAL_FIELD (file_truename) = val; 241 b->INTERNAL_FIELD (file_truename) = val;
242} 242}
243static inline void 243static void
244bset_fringe_cursor_alist (struct buffer *b, Lisp_Object val) 244bset_fringe_cursor_alist (struct buffer *b, Lisp_Object val)
245{ 245{
246 b->INTERNAL_FIELD (fringe_cursor_alist) = val; 246 b->INTERNAL_FIELD (fringe_cursor_alist) = val;
247} 247}
248static inline void 248static void
249bset_fringe_indicator_alist (struct buffer *b, Lisp_Object val) 249bset_fringe_indicator_alist (struct buffer *b, Lisp_Object val)
250{ 250{
251 b->INTERNAL_FIELD (fringe_indicator_alist) = val; 251 b->INTERNAL_FIELD (fringe_indicator_alist) = val;
252} 252}
253static inline void 253static void
254bset_fringes_outside_margins (struct buffer *b, Lisp_Object val) 254bset_fringes_outside_margins (struct buffer *b, Lisp_Object val)
255{ 255{
256 b->INTERNAL_FIELD (fringes_outside_margins) = val; 256 b->INTERNAL_FIELD (fringes_outside_margins) = val;
257} 257}
258static inline void 258static void
259bset_header_line_format (struct buffer *b, Lisp_Object val) 259bset_header_line_format (struct buffer *b, Lisp_Object val)
260{ 260{
261 b->INTERNAL_FIELD (header_line_format) = val; 261 b->INTERNAL_FIELD (header_line_format) = val;
262} 262}
263static inline void 263static void
264bset_indicate_buffer_boundaries (struct buffer *b, Lisp_Object val) 264bset_indicate_buffer_boundaries (struct buffer *b, Lisp_Object val)
265{ 265{
266 b->INTERNAL_FIELD (indicate_buffer_boundaries) = val; 266 b->INTERNAL_FIELD (indicate_buffer_boundaries) = val;
267} 267}
268static inline void 268static void
269bset_indicate_empty_lines (struct buffer *b, Lisp_Object val) 269bset_indicate_empty_lines (struct buffer *b, Lisp_Object val)
270{ 270{
271 b->INTERNAL_FIELD (indicate_empty_lines) = val; 271 b->INTERNAL_FIELD (indicate_empty_lines) = val;
272} 272}
273static inline void 273static void
274bset_invisibility_spec (struct buffer *b, Lisp_Object val) 274bset_invisibility_spec (struct buffer *b, Lisp_Object val)
275{ 275{
276 b->INTERNAL_FIELD (invisibility_spec) = val; 276 b->INTERNAL_FIELD (invisibility_spec) = val;
277} 277}
278static inline void 278static void
279bset_left_fringe_width (struct buffer *b, Lisp_Object val) 279bset_left_fringe_width (struct buffer *b, Lisp_Object val)
280{ 280{
281 b->INTERNAL_FIELD (left_fringe_width) = val; 281 b->INTERNAL_FIELD (left_fringe_width) = val;
282} 282}
283static inline void 283static void
284bset_major_mode (struct buffer *b, Lisp_Object val) 284bset_major_mode (struct buffer *b, Lisp_Object val)
285{ 285{
286 b->INTERNAL_FIELD (major_mode) = val; 286 b->INTERNAL_FIELD (major_mode) = val;
287} 287}
288static inline void 288static void
289bset_mark (struct buffer *b, Lisp_Object val) 289bset_mark (struct buffer *b, Lisp_Object val)
290{ 290{
291 b->INTERNAL_FIELD (mark) = val; 291 b->INTERNAL_FIELD (mark) = val;
292} 292}
293static inline void 293static void
294bset_minor_modes (struct buffer *b, Lisp_Object val) 294bset_minor_modes (struct buffer *b, Lisp_Object val)
295{ 295{
296 b->INTERNAL_FIELD (minor_modes) = val; 296 b->INTERNAL_FIELD (minor_modes) = val;
297} 297}
298static inline void 298static void
299bset_mode_line_format (struct buffer *b, Lisp_Object val) 299bset_mode_line_format (struct buffer *b, Lisp_Object val)
300{ 300{
301 b->INTERNAL_FIELD (mode_line_format) = val; 301 b->INTERNAL_FIELD (mode_line_format) = val;
302} 302}
303static inline void 303static void
304bset_mode_name (struct buffer *b, Lisp_Object val) 304bset_mode_name (struct buffer *b, Lisp_Object val)
305{ 305{
306 b->INTERNAL_FIELD (mode_name) = val; 306 b->INTERNAL_FIELD (mode_name) = val;
307} 307}
308static inline void 308static void
309bset_name (struct buffer *b, Lisp_Object val) 309bset_name (struct buffer *b, Lisp_Object val)
310{ 310{
311 b->INTERNAL_FIELD (name) = val; 311 b->INTERNAL_FIELD (name) = val;
312} 312}
313static inline void 313static void
314bset_overwrite_mode (struct buffer *b, Lisp_Object val) 314bset_overwrite_mode (struct buffer *b, Lisp_Object val)
315{ 315{
316 b->INTERNAL_FIELD (overwrite_mode) = val; 316 b->INTERNAL_FIELD (overwrite_mode) = val;
317} 317}
318static inline void 318static void
319bset_pt_marker (struct buffer *b, Lisp_Object val) 319bset_pt_marker (struct buffer *b, Lisp_Object val)
320{ 320{
321 b->INTERNAL_FIELD (pt_marker) = val; 321 b->INTERNAL_FIELD (pt_marker) = val;
322} 322}
323static inline void 323static void
324bset_right_fringe_width (struct buffer *b, Lisp_Object val) 324bset_right_fringe_width (struct buffer *b, Lisp_Object val)
325{ 325{
326 b->INTERNAL_FIELD (right_fringe_width) = val; 326 b->INTERNAL_FIELD (right_fringe_width) = val;
327} 327}
328static inline void 328static void
329bset_save_length (struct buffer *b, Lisp_Object val) 329bset_save_length (struct buffer *b, Lisp_Object val)
330{ 330{
331 b->INTERNAL_FIELD (save_length) = val; 331 b->INTERNAL_FIELD (save_length) = val;
332} 332}
333static inline void 333static void
334bset_scroll_bar_width (struct buffer *b, Lisp_Object val) 334bset_scroll_bar_width (struct buffer *b, Lisp_Object val)
335{ 335{
336 b->INTERNAL_FIELD (scroll_bar_width) = val; 336 b->INTERNAL_FIELD (scroll_bar_width) = val;
337} 337}
338static inline void 338static void
339bset_scroll_down_aggressively (struct buffer *b, Lisp_Object val) 339bset_scroll_down_aggressively (struct buffer *b, Lisp_Object val)
340{ 340{
341 b->INTERNAL_FIELD (scroll_down_aggressively) = val; 341 b->INTERNAL_FIELD (scroll_down_aggressively) = val;
342} 342}
343static inline void 343static void
344bset_scroll_up_aggressively (struct buffer *b, Lisp_Object val) 344bset_scroll_up_aggressively (struct buffer *b, Lisp_Object val)
345{ 345{
346 b->INTERNAL_FIELD (scroll_up_aggressively) = val; 346 b->INTERNAL_FIELD (scroll_up_aggressively) = val;
347} 347}
348static inline void 348static void
349bset_selective_display (struct buffer *b, Lisp_Object val) 349bset_selective_display (struct buffer *b, Lisp_Object val)
350{ 350{
351 b->INTERNAL_FIELD (selective_display) = val; 351 b->INTERNAL_FIELD (selective_display) = val;
352} 352}
353static inline void 353static void
354bset_selective_display_ellipses (struct buffer *b, Lisp_Object val) 354bset_selective_display_ellipses (struct buffer *b, Lisp_Object val)
355{ 355{
356 b->INTERNAL_FIELD (selective_display_ellipses) = val; 356 b->INTERNAL_FIELD (selective_display_ellipses) = val;
357} 357}
358static inline void 358static void
359bset_vertical_scroll_bar_type (struct buffer *b, Lisp_Object val) 359bset_vertical_scroll_bar_type (struct buffer *b, Lisp_Object val)
360{ 360{
361 b->INTERNAL_FIELD (vertical_scroll_bar_type) = val; 361 b->INTERNAL_FIELD (vertical_scroll_bar_type) = val;
362} 362}
363static inline void 363static void
364bset_word_wrap (struct buffer *b, Lisp_Object val) 364bset_word_wrap (struct buffer *b, Lisp_Object val)
365{ 365{
366 b->INTERNAL_FIELD (word_wrap) = val; 366 b->INTERNAL_FIELD (word_wrap) = val;
367} 367}
368static inline void 368static void
369bset_zv_marker (struct buffer *b, Lisp_Object val) 369bset_zv_marker (struct buffer *b, Lisp_Object val)
370{ 370{
371 b->INTERNAL_FIELD (zv_marker) = val; 371 b->INTERNAL_FIELD (zv_marker) = val;
@@ -651,13 +651,13 @@ copy_overlays (struct buffer *b, struct Lisp_Overlay *list)
651 651
652/* Set an appropriate overlay of B. */ 652/* Set an appropriate overlay of B. */
653 653
654static inline void 654static void
655set_buffer_overlays_before (struct buffer *b, struct Lisp_Overlay *o) 655set_buffer_overlays_before (struct buffer *b, struct Lisp_Overlay *o)
656{ 656{
657 b->overlays_before = o; 657 b->overlays_before = o;
658} 658}
659 659
660static inline void 660static void
661set_buffer_overlays_after (struct buffer *b, struct Lisp_Overlay *o) 661set_buffer_overlays_after (struct buffer *b, struct Lisp_Overlay *o)
662{ 662{
663 b->overlays_after = o; 663 b->overlays_after = o;
@@ -2464,7 +2464,7 @@ current buffer is cleared. */)
2464 begv = BEGV, zv = ZV; 2464 begv = BEGV, zv = ZV;
2465 2465
2466 if (narrowed) 2466 if (narrowed)
2467 Fwiden (); 2467 error ("Changing multibyteness in a narrowed buffer");
2468 2468
2469 if (NILP (flag)) 2469 if (NILP (flag))
2470 { 2470 {
@@ -3689,7 +3689,6 @@ fix_start_end_in_overlays (register ptrdiff_t start, register ptrdiff_t end)
3689 beforep->next = current_buffer->overlays_before; 3689 beforep->next = current_buffer->overlays_before;
3690 set_buffer_overlays_before (current_buffer, before_list); 3690 set_buffer_overlays_before (current_buffer, before_list);
3691 } 3691 }
3692 recenter_overlay_lists (current_buffer, current_buffer->overlay_center);
3693 3692
3694 if (afterp) 3693 if (afterp)
3695 { 3694 {
@@ -3847,17 +3846,16 @@ for the rear of the overlay advance when text is inserted there
3847 end = OVERLAY_END (overlay); 3846 end = OVERLAY_END (overlay);
3848 if (OVERLAY_POSITION (end) < b->overlay_center) 3847 if (OVERLAY_POSITION (end) < b->overlay_center)
3849 { 3848 {
3850 if (b->overlays_after) 3849 eassert (b->overlays_after || (XOVERLAY (overlay)->next == NULL));
3851 XOVERLAY (overlay)->next = b->overlays_after; 3850 XOVERLAY (overlay)->next = b->overlays_after;
3852 set_buffer_overlays_after (b, XOVERLAY (overlay)); 3851 set_buffer_overlays_after (b, XOVERLAY (overlay));
3853 } 3852 }
3854 else 3853 else
3855 { 3854 {
3856 if (b->overlays_before) 3855 eassert (b->overlays_before || (XOVERLAY (overlay)->next == NULL));
3857 XOVERLAY (overlay)->next = b->overlays_before; 3856 XOVERLAY (overlay)->next = b->overlays_before;
3858 set_buffer_overlays_before (b, XOVERLAY (overlay)); 3857 set_buffer_overlays_before (b, XOVERLAY (overlay));
3859 } 3858 }
3860
3861 /* This puts it in the right list, and in the right order. */ 3859 /* This puts it in the right list, and in the right order. */
3862 recenter_overlay_lists (b, b->overlay_center); 3860 recenter_overlay_lists (b, b->overlay_center);
3863 3861
@@ -4141,7 +4139,7 @@ DEFUN ("overlays-at", Foverlays_at, Soverlays_at, 1, 1, 0,
4141 /* Put all the overlays we want in a vector in overlay_vec. 4139 /* Put all the overlays we want in a vector in overlay_vec.
4142 Store the length in len. */ 4140 Store the length in len. */
4143 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len, 4141 noverlays = overlays_at (XINT (pos), 1, &overlay_vec, &len,
4144 0, 0, 0); 4142 NULL, NULL, 0);
4145 4143
4146 /* Make a list of them all. */ 4144 /* Make a list of them all. */
4147 result = Flist (noverlays, overlay_vec); 4145 result = Flist (noverlays, overlay_vec);
diff --git a/src/category.c b/src/category.c
index 01a6f54ad17..fe02303f679 100644
--- a/src/category.c
+++ b/src/category.c
@@ -40,7 +40,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
40#include "keymap.h" 40#include "keymap.h"
41 41
42/* This setter is used only in this file, so it can be private. */ 42/* This setter is used only in this file, so it can be private. */
43static inline void 43static void
44bset_category_table (struct buffer *b, Lisp_Object val) 44bset_category_table (struct buffer *b, Lisp_Object val)
45{ 45{
46 b->INTERNAL_FIELD (category_table) = val; 46 b->INTERNAL_FIELD (category_table) = val;
diff --git a/src/charset.c b/src/charset.c
index b0915ffde9c..6b999824dab 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -421,7 +421,7 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
421/* Read a hexadecimal number (preceded by "0x") from the file FP while 421/* Read a hexadecimal number (preceded by "0x") from the file FP while
422 paying attention to comment character '#'. */ 422 paying attention to comment character '#'. */
423 423
424static inline unsigned 424static unsigned
425read_hex (FILE *fp, bool *eof, bool *overflow) 425read_hex (FILE *fp, bool *eof, bool *overflow)
426{ 426{
427 int c; 427 int c;
diff --git a/src/coding.c b/src/coding.c
index 13f53ad5abc..d9606cf5710 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5059,6 +5059,7 @@ decode_coding_ccl (struct coding_system *coding)
5059 while (1) 5059 while (1)
5060 { 5060 {
5061 const unsigned char *p = src; 5061 const unsigned char *p = src;
5062 ptrdiff_t offset;
5062 int i = 0; 5063 int i = 0;
5063 5064
5064 if (multibytep) 5065 if (multibytep)
@@ -5076,8 +5077,17 @@ decode_coding_ccl (struct coding_system *coding)
5076 5077
5077 if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK) 5078 if (p == src_end && coding->mode & CODING_MODE_LAST_BLOCK)
5078 ccl->last_block = 1; 5079 ccl->last_block = 1;
5080 /* As ccl_driver calls DECODE_CHAR, buffer may be relocated. */
5081 charset_map_loaded = 0;
5079 ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf, 5082 ccl_driver (ccl, source_charbuf, charbuf, i, charbuf_end - charbuf,
5080 charset_list); 5083 charset_list);
5084 if (charset_map_loaded
5085 && (offset = coding_change_source (coding)))
5086 {
5087 p += offset;
5088 src += offset;
5089 src_end += offset;
5090 }
5081 charbuf += ccl->produced; 5091 charbuf += ccl->produced;
5082 if (multibytep) 5092 if (multibytep)
5083 src += source_byteidx[ccl->consumed]; 5093 src += source_byteidx[ccl->consumed];
@@ -5130,8 +5140,15 @@ encode_coding_ccl (struct coding_system *coding)
5130 5140
5131 do 5141 do
5132 { 5142 {
5143 ptrdiff_t offset;
5144
5145 /* As ccl_driver calls DECODE_CHAR, buffer may be relocated. */
5146 charset_map_loaded = 0;
5133 ccl_driver (ccl, charbuf, destination_charbuf, 5147 ccl_driver (ccl, charbuf, destination_charbuf,
5134 charbuf_end - charbuf, 1024, charset_list); 5148 charbuf_end - charbuf, 1024, charset_list);
5149 if (charset_map_loaded
5150 && (offset = coding_change_destination (coding)))
5151 dst += offset;
5135 if (multibytep) 5152 if (multibytep)
5136 { 5153 {
5137 ASSURE_DESTINATION (ccl->produced * 2); 5154 ASSURE_DESTINATION (ccl->produced * 2);
@@ -6805,7 +6822,7 @@ produce_chars (struct coding_system *coding, Lisp_Object translation_table,
6805 [ -LENGTH ANNOTATION_MASK NCHARS NBYTES METHOD [ COMPONENTS... ] ] 6822 [ -LENGTH ANNOTATION_MASK NCHARS NBYTES METHOD [ COMPONENTS... ] ]
6806 */ 6823 */
6807 6824
6808static inline void 6825static void
6809produce_composition (struct coding_system *coding, int *charbuf, ptrdiff_t pos) 6826produce_composition (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
6810{ 6827{
6811 int len; 6828 int len;
@@ -6849,7 +6866,7 @@ produce_composition (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
6849 [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ] 6866 [ -LENGTH ANNOTATION_MASK NCHARS CHARSET-ID ]
6850 */ 6867 */
6851 6868
6852static inline void 6869static void
6853produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos) 6870produce_charset (struct coding_system *coding, int *charbuf, ptrdiff_t pos)
6854{ 6871{
6855 ptrdiff_t from = pos - charbuf[2]; 6872 ptrdiff_t from = pos - charbuf[2];
@@ -7084,7 +7101,7 @@ decode_coding (struct coding_system *coding)
7084 position of a composition after POS (if any) or to LIMIT, and 7101 position of a composition after POS (if any) or to LIMIT, and
7085 return BUF. */ 7102 return BUF. */
7086 7103
7087static inline int * 7104static int *
7088handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit, 7105handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit,
7089 struct coding_system *coding, int *buf, 7106 struct coding_system *coding, int *buf,
7090 ptrdiff_t *stop) 7107 ptrdiff_t *stop)
@@ -7167,7 +7184,7 @@ handle_composition_annotation (ptrdiff_t pos, ptrdiff_t limit,
7167 If the property value is nil, set *STOP to the position where the 7184 If the property value is nil, set *STOP to the position where the
7168 property value is non-nil (limiting by LIMIT), and return BUF. */ 7185 property value is non-nil (limiting by LIMIT), and return BUF. */
7169 7186
7170static inline int * 7187static int *
7171handle_charset_annotation (ptrdiff_t pos, ptrdiff_t limit, 7188handle_charset_annotation (ptrdiff_t pos, ptrdiff_t limit,
7172 struct coding_system *coding, int *buf, 7189 struct coding_system *coding, int *buf,
7173 ptrdiff_t *stop) 7190 ptrdiff_t *stop)
@@ -8412,7 +8429,7 @@ highest priority. */)
8412} 8429}
8413 8430
8414 8431
8415static inline bool 8432static bool
8416char_encodable_p (int c, Lisp_Object attrs) 8433char_encodable_p (int c, Lisp_Object attrs)
8417{ 8434{
8418 Lisp_Object tail; 8435 Lisp_Object tail;
diff --git a/src/coding.h b/src/coding.h
index c45d2ef86e2..989552bf667 100644
--- a/src/coding.h
+++ b/src/coding.h
@@ -646,10 +646,8 @@ struct coding_system
646 for file names, if any. */ 646 for file names, if any. */
647#define ENCODE_FILE(name) \ 647#define ENCODE_FILE(name) \
648 (! NILP (Vfile_name_coding_system) \ 648 (! NILP (Vfile_name_coding_system) \
649 && !EQ (Vfile_name_coding_system, make_number (0)) \
650 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \ 649 ? code_convert_string_norecord (name, Vfile_name_coding_system, 1) \
651 : (! NILP (Vdefault_file_name_coding_system) \ 650 : (! NILP (Vdefault_file_name_coding_system) \
652 && !EQ (Vdefault_file_name_coding_system, make_number (0)) \
653 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \ 651 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 1) \
654 : name)) 652 : name))
655 653
@@ -658,10 +656,8 @@ struct coding_system
658 for file names, if any. */ 656 for file names, if any. */
659#define DECODE_FILE(name) \ 657#define DECODE_FILE(name) \
660 (! NILP (Vfile_name_coding_system) \ 658 (! NILP (Vfile_name_coding_system) \
661 && !EQ (Vfile_name_coding_system, make_number (0)) \
662 ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \ 659 ? code_convert_string_norecord (name, Vfile_name_coding_system, 0) \
663 : (! NILP (Vdefault_file_name_coding_system) \ 660 : (! NILP (Vdefault_file_name_coding_system) \
664 && !EQ (Vdefault_file_name_coding_system, make_number (0)) \
665 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \ 661 ? code_convert_string_norecord (name, Vdefault_file_name_coding_system, 0) \
666 : name)) 662 : name))
667 663
@@ -670,7 +666,6 @@ struct coding_system
670 for system functions, if any. */ 666 for system functions, if any. */
671#define ENCODE_SYSTEM(str) \ 667#define ENCODE_SYSTEM(str) \
672 (! NILP (Vlocale_coding_system) \ 668 (! NILP (Vlocale_coding_system) \
673 && !EQ (Vlocale_coding_system, make_number (0)) \
674 ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \ 669 ? code_convert_string_norecord (str, Vlocale_coding_system, 1) \
675 : str) 670 : str)
676 671
@@ -678,7 +673,6 @@ struct coding_system
678 for system functions, if any. */ 673 for system functions, if any. */
679#define DECODE_SYSTEM(str) \ 674#define DECODE_SYSTEM(str) \
680 (! NILP (Vlocale_coding_system) \ 675 (! NILP (Vlocale_coding_system) \
681 && !EQ (Vlocale_coding_system, make_number (0)) \
682 ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \ 676 ? code_convert_string_norecord (str, Vlocale_coding_system, 0) \
683 : str) 677 : str)
684 678
diff --git a/src/dispextern.h b/src/dispextern.h
index 47d5b51fb55..1201f52e946 100644
--- a/src/dispextern.h
+++ b/src/dispextern.h
@@ -3185,7 +3185,7 @@ extern unsigned row_hash (struct glyph_row *);
3185 3185
3186extern int x_bitmap_height (struct frame *, ptrdiff_t); 3186extern int x_bitmap_height (struct frame *, ptrdiff_t);
3187extern int x_bitmap_width (struct frame *, ptrdiff_t); 3187extern int x_bitmap_width (struct frame *, ptrdiff_t);
3188extern int x_bitmap_pixmap (struct frame *, ptrdiff_t); 3188extern ptrdiff_t x_bitmap_pixmap (struct frame *, ptrdiff_t);
3189extern void x_reference_bitmap (struct frame *, ptrdiff_t); 3189extern void x_reference_bitmap (struct frame *, ptrdiff_t);
3190extern ptrdiff_t x_create_bitmap_from_data (struct frame *, char *, 3190extern ptrdiff_t x_create_bitmap_from_data (struct frame *, char *,
3191 unsigned int, unsigned int); 3191 unsigned int, unsigned int);
diff --git a/src/dispnew.c b/src/dispnew.c
index 92262c07295..f20db42592a 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -1030,7 +1030,7 @@ swap_glyphs_in_rows (struct glyph_row *a, struct glyph_row *b)
1030 these should all go together for the row's hash value to be 1030 these should all go together for the row's hash value to be
1031 correct. */ 1031 correct. */
1032 1032
1033static inline void 1033static void
1034swap_glyph_pointers (struct glyph_row *a, struct glyph_row *b) 1034swap_glyph_pointers (struct glyph_row *a, struct glyph_row *b)
1035{ 1035{
1036 int i; 1036 int i;
@@ -1059,7 +1059,7 @@ swap_glyph_pointers (struct glyph_row *a, struct glyph_row *b)
1059 that glyph pointers, the `used' counts, and the hash values in the 1059 that glyph pointers, the `used' counts, and the hash values in the
1060 structures are left unchanged. */ 1060 structures are left unchanged. */
1061 1061
1062static inline void 1062static void
1063copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from) 1063copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from)
1064{ 1064{
1065 struct glyph *pointers[1 + LAST_AREA]; 1065 struct glyph *pointers[1 + LAST_AREA];
@@ -1086,7 +1086,7 @@ copy_row_except_pointers (struct glyph_row *to, struct glyph_row *from)
1086 exchanged between TO and FROM. Pointers must be exchanged to avoid 1086 exchanged between TO and FROM. Pointers must be exchanged to avoid
1087 a memory leak. */ 1087 a memory leak. */
1088 1088
1089static inline void 1089static void
1090assign_row (struct glyph_row *to, struct glyph_row *from) 1090assign_row (struct glyph_row *to, struct glyph_row *from)
1091{ 1091{
1092 swap_glyph_pointers (to, from); 1092 swap_glyph_pointers (to, from);
@@ -1251,7 +1251,7 @@ line_draw_cost (struct glyph_matrix *matrix, int vpos)
1251/* Return true if the glyph rows A and B have equal contents. 1251/* Return true if the glyph rows A and B have equal contents.
1252 MOUSE_FACE_P means compare the mouse_face_p flags of A and B, too. */ 1252 MOUSE_FACE_P means compare the mouse_face_p flags of A and B, too. */
1253 1253
1254static inline bool 1254static bool
1255row_equal_p (struct glyph_row *a, struct glyph_row *b, bool mouse_face_p) 1255row_equal_p (struct glyph_row *a, struct glyph_row *b, bool mouse_face_p)
1256{ 1256{
1257 eassert (verify_row_hash (a)); 1257 eassert (verify_row_hash (a));
@@ -2659,7 +2659,7 @@ fill_up_frame_row_with_spaces (struct glyph_row *row, int upto)
2659 function must be called before updates to make explicit that we are 2659 function must be called before updates to make explicit that we are
2660 working on frame matrices or not. */ 2660 working on frame matrices or not. */
2661 2661
2662static inline void 2662static void
2663set_frame_matrix_frame (struct frame *f) 2663set_frame_matrix_frame (struct frame *f)
2664{ 2664{
2665 frame_matrix_frame = f; 2665 frame_matrix_frame = f;
@@ -2674,7 +2674,7 @@ set_frame_matrix_frame (struct frame *f)
2674 done in frame matrices, and that we have to perform analogous 2674 done in frame matrices, and that we have to perform analogous
2675 operations in window matrices of frame_matrix_frame. */ 2675 operations in window matrices of frame_matrix_frame. */
2676 2676
2677static inline void 2677static void
2678make_current (struct glyph_matrix *desired_matrix, struct glyph_matrix *current_matrix, int row) 2678make_current (struct glyph_matrix *desired_matrix, struct glyph_matrix *current_matrix, int row)
2679{ 2679{
2680 struct glyph_row *current_row = MATRIX_ROW (current_matrix, row); 2680 struct glyph_row *current_row = MATRIX_ROW (current_matrix, row);
@@ -4163,7 +4163,7 @@ static struct run **runs;
4163 4163
4164/* Add glyph row ROW to the scrolling hash table. */ 4164/* Add glyph row ROW to the scrolling hash table. */
4165 4165
4166static inline struct row_entry * 4166static struct row_entry *
4167add_row_entry (struct glyph_row *row) 4167add_row_entry (struct glyph_row *row)
4168{ 4168{
4169 struct row_entry *entry; 4169 struct row_entry *entry;
diff --git a/src/emacs.c b/src/emacs.c
index 42108108a34..3b82152e647 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -31,10 +31,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
31 31
32#include "lisp.h" 32#include "lisp.h"
33 33
34#ifdef HAVE_WINDOW_SYSTEM
35#include TERM_HEADER
36#endif /* HAVE_WINDOW_SYSTEM */
37
38#ifdef WINDOWSNT 34#ifdef WINDOWSNT
39#include <fcntl.h> 35#include <fcntl.h>
40#include <windows.h> /* just for w32.h */ 36#include <windows.h> /* just for w32.h */
@@ -42,6 +38,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
42#include "w32heap.h" /* for prototype of sbrk */ 38#include "w32heap.h" /* for prototype of sbrk */
43#endif 39#endif
44 40
41#ifdef HAVE_WINDOW_SYSTEM
42#include TERM_HEADER
43#endif /* HAVE_WINDOW_SYSTEM */
44
45#ifdef NS_IMPL_GNUSTEP 45#ifdef NS_IMPL_GNUSTEP
46/* At least under Debian, GSConfig is in a subdirectory. --Stef */ 46/* At least under Debian, GSConfig is in a subdirectory. --Stef */
47#include <GNUstepBase/GSConfig.h> 47#include <GNUstepBase/GSConfig.h>
@@ -1892,7 +1892,7 @@ shut_down_emacs (int sig, Lisp_Object stuff)
1892 static char const format[] = "Fatal error %d: "; 1892 static char const format[] = "Fatal error %d: ";
1893 char buf[sizeof format - 2 + INT_STRLEN_BOUND (int)]; 1893 char buf[sizeof format - 2 + INT_STRLEN_BOUND (int)];
1894 int buflen = sprintf (buf, format, sig); 1894 int buflen = sprintf (buf, format, sig);
1895 char const *sig_desc = strsignal (sig); 1895 char const *sig_desc = safe_strsignal (sig);
1896 ignore_value (write (STDERR_FILENO, buf, buflen)); 1896 ignore_value (write (STDERR_FILENO, buf, buflen));
1897 ignore_value (write (STDERR_FILENO, sig_desc, strlen (sig_desc))); 1897 ignore_value (write (STDERR_FILENO, sig_desc, strlen (sig_desc)));
1898 } 1898 }
@@ -1918,10 +1918,6 @@ shut_down_emacs (int sig, Lisp_Object stuff)
1918 unrequest_sigio (); 1918 unrequest_sigio ();
1919 ignore_sigio (); 1919 ignore_sigio ();
1920 1920
1921#ifdef WINDOWSNT
1922 term_ntproc (0);
1923#endif
1924
1925 /* Do this only if terminating normally, we want glyph matrices 1921 /* Do this only if terminating normally, we want glyph matrices
1926 etc. in a core dump. */ 1922 etc. in a core dump. */
1927 if (sig == 0 || sig == SIGTERM) 1923 if (sig == 0 || sig == SIGTERM)
@@ -1941,6 +1937,10 @@ shut_down_emacs (int sig, Lisp_Object stuff)
1941#ifdef HAVE_LIBXML2 1937#ifdef HAVE_LIBXML2
1942 xml_cleanup_parser (); 1938 xml_cleanup_parser ();
1943#endif 1939#endif
1940
1941#ifdef WINDOWSNT
1942 term_ntproc (0);
1943#endif
1944} 1944}
1945 1945
1946 1946
diff --git a/src/eval.c b/src/eval.c
index d984331ec41..4d200fbc2bd 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -119,13 +119,13 @@ static Lisp_Object apply_lambda (Lisp_Object fun, Lisp_Object args);
119 119
120/* Functions to set Lisp_Object slots of struct specbinding. */ 120/* Functions to set Lisp_Object slots of struct specbinding. */
121 121
122static inline void 122static void
123set_specpdl_symbol (Lisp_Object symbol) 123set_specpdl_symbol (Lisp_Object symbol)
124{ 124{
125 specpdl_ptr->symbol = symbol; 125 specpdl_ptr->symbol = symbol;
126} 126}
127 127
128static inline void 128static void
129set_specpdl_old_value (Lisp_Object oldval) 129set_specpdl_old_value (Lisp_Object oldval)
130{ 130{
131 specpdl_ptr->old_value = oldval; 131 specpdl_ptr->old_value = oldval;
@@ -552,7 +552,7 @@ interactive_p (void)
552 552
553 /* If this isn't a byte-compiled function, there may be a frame at 553 /* If this isn't a byte-compiled function, there may be a frame at
554 the top for Finteractive_p. If so, skip it. */ 554 the top for Finteractive_p. If so, skip it. */
555 fun = Findirect_function (*btp->function, Qnil); 555 fun = Findirect_function (btp->function, Qnil);
556 if (SUBRP (fun) && (XSUBR (fun) == &Sinteractive_p 556 if (SUBRP (fun) && (XSUBR (fun) == &Sinteractive_p
557 || XSUBR (fun) == &Scalled_interactively_p)) 557 || XSUBR (fun) == &Scalled_interactively_p))
558 btp = btp->next; 558 btp = btp->next;
@@ -565,7 +565,7 @@ interactive_p (void)
565 If this isn't a byte-compiled function, then we may now be 565 If this isn't a byte-compiled function, then we may now be
566 looking at several frames for special forms. Skip past them. */ 566 looking at several frames for special forms. Skip past them. */
567 while (btp 567 while (btp
568 && (EQ (*btp->function, Qbytecode) 568 && (EQ (btp->function, Qbytecode)
569 || btp->nargs == UNEVALLED)) 569 || btp->nargs == UNEVALLED))
570 btp = btp->next; 570 btp = btp->next;
571 571
@@ -573,13 +573,13 @@ interactive_p (void)
573 a special form, ignoring frames for Finteractive_p and/or 573 a special form, ignoring frames for Finteractive_p and/or
574 Fbytecode at the top. If this frame is for a built-in function 574 Fbytecode at the top. If this frame is for a built-in function
575 (such as load or eval-region) return false. */ 575 (such as load or eval-region) return false. */
576 fun = Findirect_function (*btp->function, Qnil); 576 fun = Findirect_function (btp->function, Qnil);
577 if (SUBRP (fun)) 577 if (SUBRP (fun))
578 return 0; 578 return 0;
579 579
580 /* `btp' points to the frame of a Lisp function that called interactive-p. 580 /* `btp' points to the frame of a Lisp function that called interactive-p.
581 Return t if that function was called interactively. */ 581 Return t if that function was called interactively. */
582 if (btp && btp->next && EQ (*btp->next->function, Qcall_interactively)) 582 if (btp && btp->next && EQ (btp->next->function, Qcall_interactively))
583 return 1; 583 return 1;
584 return 0; 584 return 0;
585} 585}
@@ -1496,10 +1496,10 @@ See also the function `condition-case'. */)
1496 if (backtrace_list && !NILP (error_symbol)) 1496 if (backtrace_list && !NILP (error_symbol))
1497 { 1497 {
1498 bp = backtrace_list->next; 1498 bp = backtrace_list->next;
1499 if (bp && bp->function && EQ (*bp->function, Qerror)) 1499 if (bp && EQ (bp->function, Qerror))
1500 bp = bp->next; 1500 bp = bp->next;
1501 if (bp && bp->function) 1501 if (bp)
1502 Vsignaling_function = *bp->function; 1502 Vsignaling_function = bp->function;
1503 } 1503 }
1504 1504
1505 for (h = handlerlist; h; h = h->next) 1505 for (h = handlerlist; h; h = h->next)
@@ -1510,7 +1510,7 @@ See also the function `condition-case'. */)
1510 } 1510 }
1511 1511
1512 if (/* Don't run the debugger for a memory-full error. 1512 if (/* Don't run the debugger for a memory-full error.
1513 (There is no room in memory to do that!) */ 1513 (There is no room in memory to do that!) */
1514 !NILP (error_symbol) 1514 !NILP (error_symbol)
1515 && (!NILP (Vdebug_on_signal) 1515 && (!NILP (Vdebug_on_signal)
1516 /* If no handler is present now, try to run the debugger. */ 1516 /* If no handler is present now, try to run the debugger. */
@@ -2045,7 +2045,7 @@ eval_sub (Lisp_Object form)
2045 original_args = XCDR (form); 2045 original_args = XCDR (form);
2046 2046
2047 backtrace.next = backtrace_list; 2047 backtrace.next = backtrace_list;
2048 backtrace.function = &original_fun; /* This also protects them from gc. */ 2048 backtrace.function = original_fun; /* This also protects them from gc. */
2049 backtrace.args = &original_args; 2049 backtrace.args = &original_args;
2050 backtrace.nargs = UNEVALLED; 2050 backtrace.nargs = UNEVALLED;
2051 backtrace.debug_on_exit = 0; 2051 backtrace.debug_on_exit = 0;
@@ -2351,14 +2351,10 @@ usage: (run-hooks &rest HOOKS) */)
2351DEFUN ("run-hook-with-args", Frun_hook_with_args, 2351DEFUN ("run-hook-with-args", Frun_hook_with_args,
2352 Srun_hook_with_args, 1, MANY, 0, 2352 Srun_hook_with_args, 1, MANY, 0,
2353 doc: /* Run HOOK with the specified arguments ARGS. 2353 doc: /* Run HOOK with the specified arguments ARGS.
2354HOOK should be a symbol, a hook variable. If HOOK has a non-nil 2354HOOK should be a symbol, a hook variable. The value of HOOK
2355value, that value may be a function or a list of functions to be 2355may be nil, a function, or a list of functions. Call each
2356called to run the hook. If the value is a function, it is called with 2356function in order with arguments ARGS. The final return value
2357the given arguments and its return value is returned. If it is a list 2357is unspecified.
2358of functions, those functions are called, in order,
2359with the given arguments ARGS.
2360It is best not to depend on the value returned by `run-hook-with-args',
2361as that may change.
2362 2358
2363Do not use `make-local-variable' to make a hook variable buffer-local. 2359Do not use `make-local-variable' to make a hook variable buffer-local.
2364Instead, use `add-hook' and specify t for the LOCAL argument. 2360Instead, use `add-hook' and specify t for the LOCAL argument.
@@ -2368,18 +2364,18 @@ usage: (run-hook-with-args HOOK &rest ARGS) */)
2368 return run_hook_with_args (nargs, args, funcall_nil); 2364 return run_hook_with_args (nargs, args, funcall_nil);
2369} 2365}
2370 2366
2367/* NB this one still documents a specific non-nil return value.
2368 (As did run-hook-with-args and run-hook-with-args-until-failure
2369 until they were changed in 24.1.) */
2371DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success, 2370DEFUN ("run-hook-with-args-until-success", Frun_hook_with_args_until_success,
2372 Srun_hook_with_args_until_success, 1, MANY, 0, 2371 Srun_hook_with_args_until_success, 1, MANY, 0,
2373 doc: /* Run HOOK with the specified arguments ARGS. 2372 doc: /* Run HOOK with the specified arguments ARGS.
2374HOOK should be a symbol, a hook variable. If HOOK has a non-nil 2373HOOK should be a symbol, a hook variable. The value of HOOK
2375value, that value may be a function or a list of functions to be 2374may be nil, a function, or a list of functions. Call each
2376called to run the hook. If the value is a function, it is called with 2375function in order with arguments ARGS, stopping at the first
2377the given arguments and its return value is returned. 2376one that returns non-nil, and return that value. Otherwise (if
2378If it is a list of functions, those functions are called, in order, 2377all functions return nil, or if there are no functions to call),
2379with the given arguments ARGS, until one of them 2378return nil.
2380returns a non-nil value. Then we return that value.
2381However, if they all return nil, we return nil.
2382If the value of HOOK is nil, this function returns nil.
2383 2379
2384Do not use `make-local-variable' to make a hook variable buffer-local. 2380Do not use `make-local-variable' to make a hook variable buffer-local.
2385Instead, use `add-hook' and specify t for the LOCAL argument. 2381Instead, use `add-hook' and specify t for the LOCAL argument.
@@ -2398,15 +2394,12 @@ funcall_not (ptrdiff_t nargs, Lisp_Object *args)
2398DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure, 2394DEFUN ("run-hook-with-args-until-failure", Frun_hook_with_args_until_failure,
2399 Srun_hook_with_args_until_failure, 1, MANY, 0, 2395 Srun_hook_with_args_until_failure, 1, MANY, 0,
2400 doc: /* Run HOOK with the specified arguments ARGS. 2396 doc: /* Run HOOK with the specified arguments ARGS.
2401HOOK should be a symbol, a hook variable. If HOOK has a non-nil 2397HOOK should be a symbol, a hook variable. The value of HOOK
2402value, that value may be a function or a list of functions to be 2398may be nil, a function, or a list of functions. Call each
2403called to run the hook. If the value is a function, it is called with 2399function in order with arguments ARGS, stopping at the first
2404the given arguments. Then we return nil if the function returns nil, 2400one that returns nil, and return nil. Otherwise (if all functions
2405and t if it returns non-nil. 2401return non-nil, or if there are no functions to call), return non-nil
2406If it is a list of functions, those functions are called, in order, 2402\(do not rely on the precise return value in this case).
2407with the given arguments ARGS, until one of them returns nil.
2408Then we return nil. However, if they all return non-nil, we return t.
2409If the value of HOOK is nil, this function returns t.
2410 2403
2411Do not use `make-local-variable' to make a hook variable buffer-local. 2404Do not use `make-local-variable' to make a hook variable buffer-local.
2412Instead, use `add-hook' and specify t for the LOCAL argument. 2405Instead, use `add-hook' and specify t for the LOCAL argument.
@@ -2720,7 +2713,7 @@ usage: (funcall FUNCTION &rest ARGUMENTS) */)
2720 } 2713 }
2721 2714
2722 backtrace.next = backtrace_list; 2715 backtrace.next = backtrace_list;
2723 backtrace.function = &args[0]; 2716 backtrace.function = args[0];
2724 backtrace.args = &args[1]; /* This also GCPROs them. */ 2717 backtrace.args = &args[1]; /* This also GCPROs them. */
2725 backtrace.nargs = nargs - 1; 2718 backtrace.nargs = nargs - 1;
2726 backtrace.debug_on_exit = 0; 2719 backtrace.debug_on_exit = 0;
@@ -3296,12 +3289,12 @@ Output stream used is value of `standard-output'. */)
3296 write_string (backlist->debug_on_exit ? "* " : " ", 2); 3289 write_string (backlist->debug_on_exit ? "* " : " ", 2);
3297 if (backlist->nargs == UNEVALLED) 3290 if (backlist->nargs == UNEVALLED)
3298 { 3291 {
3299 Fprin1 (Fcons (*backlist->function, *backlist->args), Qnil); 3292 Fprin1 (Fcons (backlist->function, *backlist->args), Qnil);
3300 write_string ("\n", -1); 3293 write_string ("\n", -1);
3301 } 3294 }
3302 else 3295 else
3303 { 3296 {
3304 tem = *backlist->function; 3297 tem = backlist->function;
3305 Fprin1 (tem, Qnil); /* This can QUIT. */ 3298 Fprin1 (tem, Qnil); /* This can QUIT. */
3306 write_string ("(", -1); 3299 write_string ("(", -1);
3307 if (backlist->nargs == MANY) 3300 if (backlist->nargs == MANY)
@@ -3359,7 +3352,7 @@ If NFRAMES is more than the number of frames, the value is nil. */)
3359 if (!backlist) 3352 if (!backlist)
3360 return Qnil; 3353 return Qnil;
3361 if (backlist->nargs == UNEVALLED) 3354 if (backlist->nargs == UNEVALLED)
3362 return Fcons (Qnil, Fcons (*backlist->function, *backlist->args)); 3355 return Fcons (Qnil, Fcons (backlist->function, *backlist->args));
3363 else 3356 else
3364 { 3357 {
3365 if (backlist->nargs == MANY) /* FIXME: Can this happen? */ 3358 if (backlist->nargs == MANY) /* FIXME: Can this happen? */
@@ -3367,7 +3360,7 @@ If NFRAMES is more than the number of frames, the value is nil. */)
3367 else 3360 else
3368 tem = Flist (backlist->nargs, backlist->args); 3361 tem = Flist (backlist->nargs, backlist->args);
3369 3362
3370 return Fcons (Qt, Fcons (*backlist->function, tem)); 3363 return Fcons (Qt, Fcons (backlist->function, tem));
3371 } 3364 }
3372} 3365}
3373 3366
diff --git a/src/fileio.c b/src/fileio.c
index 9d8a0dc8b45..9ce9e7b8395 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5520,7 +5520,8 @@ The return value is only relevant for a call to `read-file-name' that happens
5520before any other event (mouse or keypress) is handled. */) 5520before any other event (mouse or keypress) is handled. */)
5521 (void) 5521 (void)
5522{ 5522{
5523#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) 5523#if defined (USE_MOTIF) || defined (HAVE_NTGUI) || defined (USE_GTK) \
5524 || defined (HAVE_NS)
5524 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event)) 5525 if ((NILP (last_nonmenu_event) || CONSP (last_nonmenu_event))
5525 && use_dialog_box 5526 && use_dialog_box
5526 && use_file_dialog 5527 && use_file_dialog
diff --git a/src/fns.c b/src/fns.c
index b4bb9e83fa8..c999b5b08b9 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -61,8 +61,9 @@ DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0,
61 61
62DEFUN ("random", Frandom, Srandom, 0, 1, 0, 62DEFUN ("random", Frandom, Srandom, 0, 1, 0,
63 doc: /* Return a pseudo-random number. 63 doc: /* Return a pseudo-random number.
64All integers representable in Lisp are equally likely. 64All integers representable in Lisp, i.e. between `most-negative-fixnum'
65 On most systems, this is 29 bits' worth. 65and `most-positive-fixnum', inclusive, are equally likely.
66
66With positive integer LIMIT, return random number in interval [0,LIMIT). 67With positive integer LIMIT, return random number in interval [0,LIMIT).
67With argument t, set the random number seed from the current time and pid. 68With argument t, set the random number seed from the current time and pid.
68Other values of LIMIT are ignored. */) 69Other values of LIMIT are ignored. */)
@@ -3336,14 +3337,6 @@ Lisp_Object Qeq, Qeql, Qequal;
3336Lisp_Object QCtest, QCsize, QCrehash_size, QCrehash_threshold, QCweakness; 3337Lisp_Object QCtest, QCsize, QCrehash_size, QCrehash_threshold, QCweakness;
3337static Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value; 3338static Lisp_Object Qhash_table_test, Qkey_or_value, Qkey_and_value;
3338 3339
3339/* Function prototypes. */
3340
3341static struct Lisp_Hash_Table *check_hash_table (Lisp_Object);
3342static ptrdiff_t get_key_arg (Lisp_Object, ptrdiff_t, Lisp_Object *, char *);
3343static void maybe_resize_hash_table (struct Lisp_Hash_Table *);
3344static bool sweep_weak_table (struct Lisp_Hash_Table *, bool);
3345
3346
3347 3340
3348/*********************************************************************** 3341/***********************************************************************
3349 Utilities 3342 Utilities
@@ -3694,7 +3687,7 @@ copy_hash_table (struct Lisp_Hash_Table *h1)
3694/* Resize hash table H if it's too full. If H cannot be resized 3687/* Resize hash table H if it's too full. If H cannot be resized
3695 because it's already too large, throw an error. */ 3688 because it's already too large, throw an error. */
3696 3689
3697static inline void 3690static void
3698maybe_resize_hash_table (struct Lisp_Hash_Table *h) 3691maybe_resize_hash_table (struct Lisp_Hash_Table *h)
3699{ 3692{
3700 if (NILP (h->next_free)) 3693 if (NILP (h->next_free))
diff --git a/src/frame.c b/src/frame.c
index 4bcacef39c5..2fcf7275f9c 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -120,12 +120,12 @@ static void x_report_frame_params (struct frame *, Lisp_Object *);
120#endif 120#endif
121 121
122/* These setters are used only in this file, so they can be private. */ 122/* These setters are used only in this file, so they can be private. */
123static inline void 123static void
124fset_buffer_predicate (struct frame *f, Lisp_Object val) 124fset_buffer_predicate (struct frame *f, Lisp_Object val)
125{ 125{
126 f->buffer_predicate = val; 126 f->buffer_predicate = val;
127} 127}
128static inline void 128static void
129fset_minibuffer_window (struct frame *f, Lisp_Object val) 129fset_minibuffer_window (struct frame *f, Lisp_Object val)
130{ 130{
131 f->minibuffer_window = val; 131 f->minibuffer_window = val;
@@ -632,7 +632,7 @@ affects all frames on the same terminal device. */)
632 Lisp_Object terminal; 632 Lisp_Object terminal;
633 633
634 terminal = Fassq (Qterminal, parms); 634 terminal = Fassq (Qterminal, parms);
635 if (!NILP (terminal)) 635 if (CONSP (terminal))
636 { 636 {
637 terminal = XCDR (terminal); 637 terminal = XCDR (terminal);
638 t = get_terminal (terminal, 1); 638 t = get_terminal (terminal, 1);
@@ -3028,9 +3028,9 @@ x_set_frame_parameters (FRAME_PTR f, Lisp_Object alist)
3028void 3028void
3029x_report_frame_params (struct frame *f, Lisp_Object *alistptr) 3029x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
3030{ 3030{
3031 char buf[16];
3032 Lisp_Object tem; 3031 Lisp_Object tem;
3033 unsigned long w; 3032 uprintmax_t w;
3033 char buf[INT_BUFSIZE_BOUND (w)];
3034 3034
3035 /* Represent negative positions (off the top or left screen edge) 3035 /* Represent negative positions (off the top or left screen edge)
3036 in a way that Fmodify_frame_parameters will understand correctly. */ 3036 in a way that Fmodify_frame_parameters will understand correctly. */
@@ -3067,17 +3067,17 @@ x_report_frame_params (struct frame *f, Lisp_Object *alistptr)
3067 MS-Windows it returns a value whose type is HANDLE, which is 3067 MS-Windows it returns a value whose type is HANDLE, which is
3068 actually a pointer. Explicit casting avoids compiler 3068 actually a pointer. Explicit casting avoids compiler
3069 warnings. */ 3069 warnings. */
3070 w = (unsigned long) FRAME_X_WINDOW (f); 3070 w = (uintptr_t) FRAME_X_WINDOW (f);
3071 store_in_alist (alistptr, Qwindow_id, 3071 store_in_alist (alistptr, Qwindow_id,
3072 make_formatted_string (buf, "%lu", w)); 3072 make_formatted_string (buf, "%"pMu, w));
3073#ifdef HAVE_X_WINDOWS 3073#ifdef HAVE_X_WINDOWS
3074#ifdef USE_X_TOOLKIT 3074#ifdef USE_X_TOOLKIT
3075 /* Tooltip frame may not have this widget. */ 3075 /* Tooltip frame may not have this widget. */
3076 if (FRAME_X_OUTPUT (f)->widget) 3076 if (FRAME_X_OUTPUT (f)->widget)
3077#endif 3077#endif
3078 w = (unsigned long) FRAME_OUTER_WINDOW (f); 3078 w = (uintptr_t) FRAME_OUTER_WINDOW (f);
3079 store_in_alist (alistptr, Qouter_window_id, 3079 store_in_alist (alistptr, Qouter_window_id,
3080 make_formatted_string (buf, "%lu", w)); 3080 make_formatted_string (buf, "%"pMu, w));
3081#endif 3081#endif
3082 store_in_alist (alistptr, Qicon_name, f->icon_name); 3082 store_in_alist (alistptr, Qicon_name, f->icon_name);
3083 FRAME_SAMPLE_VISIBILITY (f); 3083 FRAME_SAMPLE_VISIBILITY (f);
diff --git a/src/gmalloc.c b/src/gmalloc.c
index 78d6934755b..dc584955661 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -36,6 +36,10 @@ Fifth Floor, Boston, MA 02110-1301, USA.
36#include <pthread.h> 36#include <pthread.h>
37#endif 37#endif
38 38
39#ifdef WINDOWSNT
40#include <w32heap.h> /* for sbrk */
41#endif
42
39#ifdef __cplusplus 43#ifdef __cplusplus
40extern "C" 44extern "C"
41{ 45{
@@ -460,7 +464,7 @@ get_contiguous_space (ptrdiff_t size, void *position)
460/* This is called when `_heapinfo' and `heapsize' have just 464/* This is called when `_heapinfo' and `heapsize' have just
461 been set to describe a new info table. Set up the table 465 been set to describe a new info table. Set up the table
462 to describe itself and account for it in the statistics. */ 466 to describe itself and account for it in the statistics. */
463static inline void 467static void
464register_heapinfo (void) 468register_heapinfo (void)
465{ 469{
466 size_t block, blocks; 470 size_t block, blocks;
@@ -1289,7 +1293,9 @@ Fifth Floor, Boston, MA 02110-1301, USA.
1289 The author may be reached (Email) at the address mike@ai.mit.edu, 1293 The author may be reached (Email) at the address mike@ai.mit.edu,
1290 or (US mail) as Mike Haertel c/o Free Software Foundation. */ 1294 or (US mail) as Mike Haertel c/o Free Software Foundation. */
1291 1295
1296#ifndef min
1292#define min(A, B) ((A) < (B) ? (A) : (B)) 1297#define min(A, B) ((A) < (B) ? (A) : (B))
1298#endif
1293 1299
1294/* On Cygwin the dumped emacs may try to realloc storage allocated in 1300/* On Cygwin the dumped emacs may try to realloc storage allocated in
1295 the static heap. We just malloc space in the new heap and copy the 1301 the static heap. We just malloc space in the new heap and copy the
diff --git a/src/image.c b/src/image.c
index 7901b95f236..91eeb91920c 100644
--- a/src/image.c
+++ b/src/image.c
@@ -186,11 +186,11 @@ x_bitmap_width (FRAME_PTR f, ptrdiff_t id)
186} 186}
187 187
188#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI) 188#if defined (HAVE_X_WINDOWS) || defined (HAVE_NTGUI)
189int 189ptrdiff_t
190x_bitmap_pixmap (FRAME_PTR f, ptrdiff_t id) 190x_bitmap_pixmap (FRAME_PTR f, ptrdiff_t id)
191{ 191{
192 /* HAVE_NTGUI needs the explicit cast here. */ 192 /* HAVE_NTGUI needs the explicit cast here. */
193 return (int) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap; 193 return (ptrdiff_t) FRAME_X_DISPLAY_INFO (f)->bitmaps[id - 1].pixmap;
194} 194}
195#endif 195#endif
196 196
diff --git a/src/intervals.c b/src/intervals.c
index 584ee1e923d..1ed93e1302d 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -64,7 +64,7 @@ static INTERVAL reproduce_tree (INTERVAL, INTERVAL);
64/* Use these functions to set Lisp_Object 64/* Use these functions to set Lisp_Object
65 or pointer slots of struct interval. */ 65 or pointer slots of struct interval. */
66 66
67static inline void 67static void
68set_interval_object (INTERVAL i, Lisp_Object obj) 68set_interval_object (INTERVAL i, Lisp_Object obj)
69{ 69{
70 eassert (BUFFERP (obj) || STRINGP (obj)); 70 eassert (BUFFERP (obj) || STRINGP (obj));
@@ -72,13 +72,13 @@ set_interval_object (INTERVAL i, Lisp_Object obj)
72 i->up.obj = obj; 72 i->up.obj = obj;
73} 73}
74 74
75static inline void 75static void
76set_interval_left (INTERVAL i, INTERVAL left) 76set_interval_left (INTERVAL i, INTERVAL left)
77{ 77{
78 i->left = left; 78 i->left = left;
79} 79}
80 80
81static inline void 81static void
82set_interval_right (INTERVAL i, INTERVAL right) 82set_interval_right (INTERVAL i, INTERVAL right)
83{ 83{
84 i->right = right; 84 i->right = right;
@@ -87,7 +87,7 @@ set_interval_right (INTERVAL i, INTERVAL right)
87/* Make the parent of D be whatever the parent of S is, regardless 87/* Make the parent of D be whatever the parent of S is, regardless
88 of the type. This is used when balancing an interval tree. */ 88 of the type. This is used when balancing an interval tree. */
89 89
90static inline void 90static void
91copy_interval_parent (INTERVAL d, INTERVAL s) 91copy_interval_parent (INTERVAL d, INTERVAL s)
92{ 92{
93 d->up = s->up; 93 d->up = s->up;
@@ -341,7 +341,7 @@ root_interval (INTERVAL interval)
341 c c 341 c c
342*/ 342*/
343 343
344static inline INTERVAL 344static INTERVAL
345rotate_right (INTERVAL interval) 345rotate_right (INTERVAL interval)
346{ 346{
347 INTERVAL i; 347 INTERVAL i;
@@ -388,7 +388,7 @@ rotate_right (INTERVAL interval)
388 c c 388 c c
389*/ 389*/
390 390
391static inline INTERVAL 391static INTERVAL
392rotate_left (INTERVAL interval) 392rotate_left (INTERVAL interval)
393{ 393{
394 INTERVAL i; 394 INTERVAL i;
@@ -466,7 +466,7 @@ balance_an_interval (INTERVAL i)
466/* Balance INTERVAL, potentially stuffing it back into its parent 466/* Balance INTERVAL, potentially stuffing it back into its parent
467 Lisp Object. */ 467 Lisp Object. */
468 468
469static inline INTERVAL 469static INTERVAL
470balance_possible_root_interval (INTERVAL interval) 470balance_possible_root_interval (INTERVAL interval)
471{ 471{
472 Lisp_Object parent; 472 Lisp_Object parent;
diff --git a/src/keyboard.c b/src/keyboard.c
index e594c8b0947..276602216d2 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -451,47 +451,47 @@ static char *find_user_signal_name (int);
451static void store_user_signal_events (void); 451static void store_user_signal_events (void);
452 452
453/* These setters are used only in this file, so they can be private. */ 453/* These setters are used only in this file, so they can be private. */
454static inline void 454static void
455kset_echo_string (struct kboard *kb, Lisp_Object val) 455kset_echo_string (struct kboard *kb, Lisp_Object val)
456{ 456{
457 kb->INTERNAL_FIELD (echo_string) = val; 457 kb->INTERNAL_FIELD (echo_string) = val;
458} 458}
459static inline void 459static void
460kset_kbd_queue (struct kboard *kb, Lisp_Object val) 460kset_kbd_queue (struct kboard *kb, Lisp_Object val)
461{ 461{
462 kb->INTERNAL_FIELD (kbd_queue) = val; 462 kb->INTERNAL_FIELD (kbd_queue) = val;
463} 463}
464static inline void 464static void
465kset_keyboard_translate_table (struct kboard *kb, Lisp_Object val) 465kset_keyboard_translate_table (struct kboard *kb, Lisp_Object val)
466{ 466{
467 kb->INTERNAL_FIELD (Vkeyboard_translate_table) = val; 467 kb->INTERNAL_FIELD (Vkeyboard_translate_table) = val;
468} 468}
469static inline void 469static void
470kset_last_prefix_arg (struct kboard *kb, Lisp_Object val) 470kset_last_prefix_arg (struct kboard *kb, Lisp_Object val)
471{ 471{
472 kb->INTERNAL_FIELD (Vlast_prefix_arg) = val; 472 kb->INTERNAL_FIELD (Vlast_prefix_arg) = val;
473} 473}
474static inline void 474static void
475kset_last_repeatable_command (struct kboard *kb, Lisp_Object val) 475kset_last_repeatable_command (struct kboard *kb, Lisp_Object val)
476{ 476{
477 kb->INTERNAL_FIELD (Vlast_repeatable_command) = val; 477 kb->INTERNAL_FIELD (Vlast_repeatable_command) = val;
478} 478}
479static inline void 479static void
480kset_local_function_key_map (struct kboard *kb, Lisp_Object val) 480kset_local_function_key_map (struct kboard *kb, Lisp_Object val)
481{ 481{
482 kb->INTERNAL_FIELD (Vlocal_function_key_map) = val; 482 kb->INTERNAL_FIELD (Vlocal_function_key_map) = val;
483} 483}
484static inline void 484static void
485kset_overriding_terminal_local_map (struct kboard *kb, Lisp_Object val) 485kset_overriding_terminal_local_map (struct kboard *kb, Lisp_Object val)
486{ 486{
487 kb->INTERNAL_FIELD (Voverriding_terminal_local_map) = val; 487 kb->INTERNAL_FIELD (Voverriding_terminal_local_map) = val;
488} 488}
489static inline void 489static void
490kset_real_last_command (struct kboard *kb, Lisp_Object val) 490kset_real_last_command (struct kboard *kb, Lisp_Object val)
491{ 491{
492 kb->INTERNAL_FIELD (Vreal_last_command) = val; 492 kb->INTERNAL_FIELD (Vreal_last_command) = val;
493} 493}
494static inline void 494static void
495kset_system_key_syms (struct kboard *kb, Lisp_Object val) 495kset_system_key_syms (struct kboard *kb, Lisp_Object val)
496{ 496{
497 kb->INTERNAL_FIELD (system_key_syms) = val; 497 kb->INTERNAL_FIELD (system_key_syms) = val;
@@ -3752,7 +3752,7 @@ kbd_buffer_events_waiting (int discard)
3752 3752
3753/* Clear input event EVENT. */ 3753/* Clear input event EVENT. */
3754 3754
3755static inline void 3755static void
3756clear_event (struct input_event *event) 3756clear_event (struct input_event *event)
3757{ 3757{
3758 event->kind = NO_EVENT; 3758 event->kind = NO_EVENT;
@@ -8070,7 +8070,7 @@ process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void
8070 8070
8071/* Access slot with index IDX of vector tool_bar_item_properties. */ 8071/* Access slot with index IDX of vector tool_bar_item_properties. */
8072#define PROP(IDX) AREF (tool_bar_item_properties, (IDX)) 8072#define PROP(IDX) AREF (tool_bar_item_properties, (IDX))
8073static inline void 8073static void
8074set_prop (ptrdiff_t idx, Lisp_Object val) 8074set_prop (ptrdiff_t idx, Lisp_Object val)
8075{ 8075{
8076 ASET (tool_bar_item_properties, idx, val); 8076 ASET (tool_bar_item_properties, idx, val);
diff --git a/src/lisp.h b/src/lisp.h
index cebc617e1e0..be571ca4a35 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -2039,7 +2039,7 @@ extern ptrdiff_t specpdl_size;
2039struct backtrace 2039struct backtrace
2040{ 2040{
2041 struct backtrace *next; 2041 struct backtrace *next;
2042 Lisp_Object *function; 2042 Lisp_Object function;
2043 Lisp_Object *args; /* Points to vector of args. */ 2043 Lisp_Object *args; /* Points to vector of args. */
2044 ptrdiff_t nargs; /* Length of vector. */ 2044 ptrdiff_t nargs; /* Length of vector. */
2045 /* Nonzero means call value of debugger when done with this operation. */ 2045 /* Nonzero means call value of debugger when done with this operation. */
diff --git a/src/lread.c b/src/lread.c
index cb808b37677..581332502ed 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -764,13 +764,30 @@ DEFUN ("get-file-char", Fget_file_char, Sget_file_char, 0, 0, 0,
764 764
765/* Return true if the lisp code read using READCHARFUN defines a non-nil 765/* Return true if the lisp code read using READCHARFUN defines a non-nil
766 `lexical-binding' file variable. After returning, the stream is 766 `lexical-binding' file variable. After returning, the stream is
767 positioned following the first line, if it is a comment, otherwise 767 positioned following the first line, if it is a comment or #! line,
768 nothing is read. */ 768 otherwise nothing is read. */
769 769
770static int 770static int
771lisp_file_lexically_bound_p (Lisp_Object readcharfun) 771lisp_file_lexically_bound_p (Lisp_Object readcharfun)
772{ 772{
773 int ch = READCHAR; 773 int ch = READCHAR;
774
775 if (ch == '#')
776 {
777 ch = READCHAR;
778 if (ch != '!')
779 {
780 UNREAD (ch);
781 UNREAD ('#');
782 return 0;
783 }
784 while (ch != '\n' && ch != EOF)
785 ch = READCHAR;
786 if (ch == '\n') ch = READCHAR;
787 /* It is OK to leave the position after a #! line, since
788 that is what read1 does. */
789 }
790
774 if (ch != ';') 791 if (ch != ';')
775 /* The first line isn't a comment, just give up. */ 792 /* The first line isn't a comment, just give up. */
776 { 793 {
@@ -2266,7 +2283,7 @@ read_escape (Lisp_Object readcharfun, int stringp)
2266/* Return the digit that CHARACTER stands for in the given BASE. 2283/* Return the digit that CHARACTER stands for in the given BASE.
2267 Return -1 if CHARACTER is out of range for BASE, 2284 Return -1 if CHARACTER is out of range for BASE,
2268 and -2 if CHARACTER is not valid for any supported BASE. */ 2285 and -2 if CHARACTER is not valid for any supported BASE. */
2269static inline int 2286static int
2270digit_to_number (int character, int base) 2287digit_to_number (int character, int base)
2271{ 2288{
2272 int digit; 2289 int digit;
diff --git a/src/makefile.w32-in b/src/makefile.w32-in
index 83e101d2c76..c6fbf59fb5a 100644
--- a/src/makefile.w32-in
+++ b/src/makefile.w32-in
@@ -25,7 +25,7 @@ ALL = emacs
25EMACSLOADPATH=$(CURDIR)/../lisp 25EMACSLOADPATH=$(CURDIR)/../lisp
26 26
27# Size in MBs of the static heap in temacs.exe. 27# Size in MBs of the static heap in temacs.exe.
28HEAPSIZE = 27 28HEAPSIZE = $(EMACS_HEAPSIZE)
29 29
30LOCAL_FLAGS = -Demacs=1 -I../lib -I../nt/inc -DHAVE_NTGUI=1 $(EMACS_EXTRA_C_FLAGS) 30LOCAL_FLAGS = -Demacs=1 -I../lib -I../nt/inc -DHAVE_NTGUI=1 $(EMACS_EXTRA_C_FLAGS)
31 31
@@ -247,10 +247,10 @@ bootstrap: bootstrap-emacs
247# WARNING: Do NOT split the part inside $(ARGQUOTE)s into multiple lines as 247# WARNING: Do NOT split the part inside $(ARGQUOTE)s into multiple lines as
248# this can break with GNU Make 3.81 and later if sh.exe is used. 248# this can break with GNU Make 3.81 and later if sh.exe is used.
249bootstrap-temacs-CMD: 249bootstrap-temacs-CMD:
250 $(MAKE) $(MFLAGS) $(XMFLAGS) temacs CFLAGS=$(ARGQUOTE)$(ESC_CFLAGS) -DPURESIZE=5000000$(ARGQUOTE) 250 $(MAKE) $(MFLAGS) $(XMFLAGS) temacs CFLAGS=$(ARGQUOTE)$(ESC_CFLAGS) -DPURESIZE=$(EMACS_PURESIZE)$(ARGQUOTE)
251 251
252bootstrap-temacs-SH: 252bootstrap-temacs-SH:
253 $(MAKE) $(MFLAGS) $(XMFLAGS) temacs CFLAGS=$(ARGQUOTE)$(CFLAGS) -DPURESIZE=5000000$(ARGQUOTE) 253 $(MAKE) $(MFLAGS) $(XMFLAGS) temacs CFLAGS=$(ARGQUOTE)$(CFLAGS) -DPURESIZE=$(EMACS_PURESIZE)$(ARGQUOTE)
254 254
255bootstrap-temacs: 255bootstrap-temacs:
256 $(MAKE) $(MFLAGS) bootstrap-temacs-$(SHELLTYPE) 256 $(MAKE) $(MFLAGS) bootstrap-temacs-$(SHELLTYPE)
@@ -485,6 +485,7 @@ $(BLD)/alloc.$(O) : \
485 $(SRC)/blockinput.h \ 485 $(SRC)/blockinput.h \
486 $(SRC)/puresize.h \ 486 $(SRC)/puresize.h \
487 $(SRC)/w32.h \ 487 $(SRC)/w32.h \
488 $(SRC)/w32heap.h \
488 $(NT_INC)/unistd.h \ 489 $(NT_INC)/unistd.h \
489 $(GNU_LIB)/verify.h \ 490 $(GNU_LIB)/verify.h \
490 $(BUFFER_H) \ 491 $(BUFFER_H) \
@@ -955,6 +956,7 @@ $(BLD)/fringe.$(O) : \
955 956
956$(BLD)/gmalloc.$(O) : \ 957$(BLD)/gmalloc.$(O) : \
957 $(SRC)/gmalloc.c \ 958 $(SRC)/gmalloc.c \
959 $(SRC)/w32heap.h \
958 $(NT_INC)/stdint.h \ 960 $(NT_INC)/stdint.h \
959 $(NT_INC)/unistd.h \ 961 $(NT_INC)/unistd.h \
960 $(CONFIG_H) 962 $(CONFIG_H)
@@ -976,9 +978,10 @@ $(BLD)/xml.$(O) : \
976 978
977$(BLD)/profiler.$(O) : \ 979$(BLD)/profiler.$(O) : \
978 $(SRC)/profiler.c \ 980 $(SRC)/profiler.c \
979 $(NT_INC)/sys/time.h \
980 $(CONFIG_H) \ 981 $(CONFIG_H) \
981 $(LISP_H) 982 $(LISP_H) \
983 $(SYSSIGNAL_H) \
984 $(SYSTIME_H)
982 985
983$(BLD)/image.$(O) : \ 986$(BLD)/image.$(O) : \
984 $(SRC)/image.c \ 987 $(SRC)/image.c \
diff --git a/src/marker.c b/src/marker.c
index 0c4e8cb3b55..e01647bdb2a 100644
--- a/src/marker.c
+++ b/src/marker.c
@@ -427,7 +427,7 @@ Returns nil if MARKER points nowhere. */)
427 427
428/* Change M so it points to B at CHARPOS and BYTEPOS. */ 428/* Change M so it points to B at CHARPOS and BYTEPOS. */
429 429
430static inline void 430static void
431attach_marker (struct Lisp_Marker *m, struct buffer *b, 431attach_marker (struct Lisp_Marker *m, struct buffer *b,
432 ptrdiff_t charpos, ptrdiff_t bytepos) 432 ptrdiff_t charpos, ptrdiff_t bytepos)
433{ 433{
@@ -454,7 +454,7 @@ attach_marker (struct Lisp_Marker *m, struct buffer *b,
454 whether BUFFER is a buffer object and return buffer pointer 454 whether BUFFER is a buffer object and return buffer pointer
455 corresponding to BUFFER if BUFFER is live, or NULL otherwise. */ 455 corresponding to BUFFER if BUFFER is live, or NULL otherwise. */
456 456
457static inline struct buffer * 457static struct buffer *
458live_buffer (Lisp_Object buffer) 458live_buffer (Lisp_Object buffer)
459{ 459{
460 struct buffer *b; 460 struct buffer *b;
@@ -477,7 +477,7 @@ live_buffer (Lisp_Object buffer)
477/* Internal function to set MARKER in BUFFER at POSITION. Non-zero 477/* Internal function to set MARKER in BUFFER at POSITION. Non-zero
478 RESTRICTED means limit the POSITION by the visible part of BUFFER. */ 478 RESTRICTED means limit the POSITION by the visible part of BUFFER. */
479 479
480static inline Lisp_Object 480static Lisp_Object
481set_marker_internal (Lisp_Object marker, Lisp_Object position, 481set_marker_internal (Lisp_Object marker, Lisp_Object position,
482 Lisp_Object buffer, int restricted) 482 Lisp_Object buffer, int restricted)
483{ 483{
diff --git a/src/nsfns.m b/src/nsfns.m
index 94ace360438..1efadf0cb98 100644
--- a/src/nsfns.m
+++ b/src/nsfns.m
@@ -1018,7 +1018,7 @@ frame_parm_handler ns_frame_parm_handlers[] =
1018 x_set_fringe_width, /* generic OK */ 1018 x_set_fringe_width, /* generic OK */
1019 x_set_fringe_width, /* generic OK */ 1019 x_set_fringe_width, /* generic OK */
1020 0, /* x_set_wait_for_wm, will ignore */ 1020 0, /* x_set_wait_for_wm, will ignore */
1021 0, /* x_set_fullscreen will ignore */ 1021 x_set_fullscreen, /* generic OK */
1022 x_set_font_backend, /* generic OK */ 1022 x_set_font_backend, /* generic OK */
1023 x_set_alpha, 1023 x_set_alpha,
1024 0, /* x_set_sticky */ 1024 0, /* x_set_sticky */
@@ -1467,13 +1467,15 @@ DEFUN ("ns-popup-color-panel", Fns_popup_color_panel, Sns_popup_color_panel,
1467} 1467}
1468 1468
1469 1469
1470DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 4, 0, 1470DEFUN ("ns-read-file-name", Fns_read_file_name, Sns_read_file_name, 1, 5, 0,
1471 doc: /* Use a graphical panel to read a file name, using prompt PROMPT. 1471 doc: /* Use a graphical panel to read a file name, using prompt PROMPT.
1472Optional arg DIR, if non-nil, supplies a default directory. 1472Optional arg DIR, if non-nil, supplies a default directory.
1473Optional arg MUSTMATCH, if non-nil, means the returned file or 1473Optional arg MUSTMATCH, if non-nil, means the returned file or
1474directory must exist. 1474directory must exist.
1475Optional arg INIT, if non-nil, provides a default file name to use. */) 1475Optional arg INIT, if non-nil, provides a default file name to use.
1476 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object mustmatch, Lisp_Object init) 1476Optional arg DIR_ONLY_P, if non-nil, means choose only directories. */)
1477 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object mustmatch,
1478 Lisp_Object init, Lisp_Object dir_only_p)
1477{ 1479{
1478 static id fileDelegate = nil; 1480 static id fileDelegate = nil;
1479 int ret; 1481 int ret;
@@ -1498,21 +1500,36 @@ Optional arg INIT, if non-nil, provides a default file name to use. */)
1498 if ([dirS characterAtIndex: 0] == '~') 1500 if ([dirS characterAtIndex: 0] == '~')
1499 dirS = [dirS stringByExpandingTildeInPath]; 1501 dirS = [dirS stringByExpandingTildeInPath];
1500 1502
1501 panel = NILP (mustmatch) ? 1503 panel = NILP (mustmatch) && NILP (dir_only_p) ?
1502 (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel]; 1504 (id)[EmacsSavePanel savePanel] : (id)[EmacsOpenPanel openPanel];
1503 1505
1504 [panel setTitle: promptS]; 1506 [panel setTitle: promptS];
1505 1507
1506 /* Puma (10.1) does not have */ 1508 [panel setAllowsOtherFileTypes: YES];
1507 if ([panel respondsToSelector: @selector (setAllowsOtherFileTypes:)])
1508 [panel setAllowsOtherFileTypes: YES];
1509
1510 [panel setTreatsFilePackagesAsDirectories: YES]; 1509 [panel setTreatsFilePackagesAsDirectories: YES];
1511 [panel setDelegate: fileDelegate]; 1510 [panel setDelegate: fileDelegate];
1512 1511
1513 panelOK = 0; 1512 panelOK = 0;
1513 if (! NILP (dir_only_p))
1514 {
1515 [panel setCanChooseDirectories: YES];
1516 [panel setCanChooseFiles: NO];
1517 }
1518
1514 block_input (); 1519 block_input ();
1515 if (NILP (mustmatch)) 1520#if defined (NS_IMPL_COCOA) && \
1521 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
1522 if (! NILP (mustmatch) || ! NILP (dir_only_p))
1523 [panel setAllowedFileTypes: nil];
1524 if (dirS) [panel setDirectoryURL: [NSURL fileURLWithPath: dirS]];
1525 if (initS && NILP (Ffile_directory_p (init)))
1526 [panel setNameFieldStringValue: [initS lastPathComponent]];
1527 else
1528 [panel setNameFieldStringValue: @""];
1529
1530 ret = [panel runModal];
1531#else
1532 if (NILP (mustmatch) && NILP (dir_only_p))
1516 { 1533 {
1517 ret = [panel runModalForDirectory: dirS file: initS]; 1534 ret = [panel runModalForDirectory: dirS file: initS];
1518 } 1535 }
@@ -1521,6 +1538,7 @@ Optional arg INIT, if non-nil, provides a default file name to use. */)
1521 [panel setCanChooseDirectories: YES]; 1538 [panel setCanChooseDirectories: YES];
1522 ret = [panel runModalForDirectory: dirS file: initS types: nil]; 1539 ret = [panel runModalForDirectory: dirS file: initS types: nil];
1523 } 1540 }
1541#endif
1524 1542
1525 ret = (ret == NSOKButton) || panelOK; 1543 ret = (ret == NSOKButton) || panelOK;
1526 1544
diff --git a/src/nsterm.h b/src/nsterm.h
index 97fc6be20e5..f06e0cb0f7f 100644
--- a/src/nsterm.h
+++ b/src/nsterm.h
@@ -38,6 +38,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
38#ifndef MAC_OS_X_VERSION_10_6 38#ifndef MAC_OS_X_VERSION_10_6
39#define MAC_OS_X_VERSION_10_6 1060 39#define MAC_OS_X_VERSION_10_6 1060
40#endif 40#endif
41#ifndef MAC_OS_X_VERSION_10_7
42#define MAC_OS_X_VERSION_10_7 1070
43#endif
44#ifndef MAC_OS_X_VERSION_10_8
45#define MAC_OS_X_VERSION_10_8 1080
46#endif
41#endif /* NS_IMPL_COCOA */ 47#endif /* NS_IMPL_COCOA */
42 48
43#ifdef __OBJC__ 49#ifdef __OBJC__
@@ -80,6 +86,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
80 BOOL windowClosing; 86 BOOL windowClosing;
81 NSString *workingText; 87 NSString *workingText;
82 BOOL processingCompose; 88 BOOL processingCompose;
89 int fs_state, fs_before_fs, next_maximized, tbar_height, bwidth;
90 int maximized_width, maximized_height;
91 NSWindow *nonfs_window;
83@public 92@public
84 struct frame *emacsframe; 93 struct frame *emacsframe;
85 int rows, cols; 94 int rows, cols;
@@ -104,6 +113,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
104- (EmacsToolbar *) toolbar; 113- (EmacsToolbar *) toolbar;
105- (void) deleteWorkingText; 114- (void) deleteWorkingText;
106- (void) updateFrameSize: (BOOL) delay; 115- (void) updateFrameSize: (BOOL) delay;
116- (void) handleFS;
117- (void) setFSValue: (int)value;
118- (void) toggleFullScreen: (id) sender;
107 119
108#ifdef NS_IMPL_GNUSTEP 120#ifdef NS_IMPL_GNUSTEP
109/* Not declared, but useful. */ 121/* Not declared, but useful. */
@@ -120,6 +132,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
120@end 132@end
121 133
122 134
135/* Fullscreen version of the above. */
136@interface EmacsFSWindow : EmacsWindow
137{
138}
139@end
140
123/* ========================================================================== 141/* ==========================================================================
124 142
125 The main menu implementation 143 The main menu implementation
diff --git a/src/nsterm.m b/src/nsterm.m
index 5af3c2e2ae1..2df0e1a1ad5 100644
--- a/src/nsterm.m
+++ b/src/nsterm.m
@@ -72,6 +72,11 @@ int term_trace_num = 0;
72#define NSTRACE(x) 72#define NSTRACE(x)
73#endif 73#endif
74 74
75#if defined (NS_IMPL_COCOA) && \
76 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
77#define NEW_STYLE_FS
78#endif
79
75extern NSString *NSMenuDidBeginTrackingNotification; 80extern NSString *NSMenuDidBeginTrackingNotification;
76 81
77/* ========================================================================== 82/* ==========================================================================
@@ -1306,6 +1311,17 @@ x_set_window_size (struct frame *f, int change_grav, int cols, int rows)
1306} 1311}
1307 1312
1308 1313
1314static void
1315ns_fullscreen_hook (FRAME_PTR f)
1316{
1317 EmacsView *view = (EmacsView *)FRAME_NS_VIEW (f);
1318
1319 if (! f->async_visible) return;
1320
1321 block_input ();
1322 [view handleFS];
1323 unblock_input ();
1324}
1309 1325
1310/* ========================================================================== 1326/* ==========================================================================
1311 1327
@@ -2155,7 +2171,7 @@ ns_shift_glyphs_for_insert (struct frame *f,
2155 ========================================================================== */ 2171 ========================================================================== */
2156 2172
2157 2173
2158static inline void 2174static void
2159ns_compute_glyph_string_overhangs (struct glyph_string *s) 2175ns_compute_glyph_string_overhangs (struct glyph_string *s)
2160/* -------------------------------------------------------------------------- 2176/* --------------------------------------------------------------------------
2161 External (RIF); compute left/right overhang of whole string and set in s 2177 External (RIF); compute left/right overhang of whole string and set in s
@@ -3932,7 +3948,7 @@ ns_create_terminal (struct ns_display_info *dpyinfo)
3932 terminal->frame_rehighlight_hook = ns_frame_rehighlight; 3948 terminal->frame_rehighlight_hook = ns_frame_rehighlight;
3933 terminal->frame_raise_lower_hook = ns_frame_raise_lower; 3949 terminal->frame_raise_lower_hook = ns_frame_raise_lower;
3934 3950
3935 terminal->fullscreen_hook = 0; /* see XTfullscreen_hook */ 3951 terminal->fullscreen_hook = ns_fullscreen_hook;
3936 3952
3937 terminal->set_vertical_scroll_bar_hook = ns_set_vertical_scroll_bar; 3953 terminal->set_vertical_scroll_bar_hook = ns_set_vertical_scroll_bar;
3938 terminal->condemn_scroll_bars_hook = ns_condemn_scroll_bars; 3954 terminal->condemn_scroll_bars_hook = ns_condemn_scroll_bars;
@@ -4687,6 +4703,8 @@ not_in_argv (NSString *arg)
4687{ 4703{
4688 NSTRACE (EmacsView_dealloc); 4704 NSTRACE (EmacsView_dealloc);
4689 [toolbar release]; 4705 [toolbar release];
4706 if (fs_state == FULLSCREEN_BOTH)
4707 [nonfs_window release];
4690 [super dealloc]; 4708 [super dealloc];
4691} 4709}
4692 4710
@@ -5405,6 +5423,7 @@ not_in_argv (NSString *arg)
5405 SET_FRAME_GARBAGED (emacsframe); 5423 SET_FRAME_GARBAGED (emacsframe);
5406 cancel_mouse_face (emacsframe); 5424 cancel_mouse_face (emacsframe);
5407 [view setFrame: NSMakeRect (0, 0, neww, newh)]; 5425 [view setFrame: NSMakeRect (0, 0, neww, newh)];
5426 [self windowDidMove:nil]; // Update top/left.
5408 } 5427 }
5409} 5428}
5410 5429
@@ -5414,6 +5433,19 @@ not_in_argv (NSString *arg)
5414 NSTRACE (windowWillResize); 5433 NSTRACE (windowWillResize);
5415/*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */ 5434/*fprintf (stderr,"Window will resize: %.0f x %.0f\n",frameSize.width,frameSize.height); */
5416 5435
5436 if (fs_state == FULLSCREEN_MAXIMIZED
5437 && (maximized_width != (int)frameSize.width
5438 || maximized_height != (int)frameSize.height))
5439 [self setFSValue: FULLSCREEN_NONE];
5440 else if (fs_state == FULLSCREEN_WIDTH
5441 && maximized_width != (int)frameSize.width)
5442 [self setFSValue: FULLSCREEN_NONE];
5443 else if (fs_state == FULLSCREEN_HEIGHT
5444 && maximized_height != (int)frameSize.height)
5445 [self setFSValue: FULLSCREEN_NONE];
5446 if (fs_state == FULLSCREEN_NONE)
5447 maximized_width = maximized_height = -1;
5448
5417 cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe, 5449 cols = FRAME_PIXEL_WIDTH_TO_TEXT_COLS (emacsframe,
5418#ifdef NS_IMPL_GNUSTEP 5450#ifdef NS_IMPL_GNUSTEP
5419 frameSize.width + 3); 5451 frameSize.width + 3);
@@ -5595,6 +5627,10 @@ not_in_argv (NSString *arg)
5595 windowClosing = NO; 5627 windowClosing = NO;
5596 processingCompose = NO; 5628 processingCompose = NO;
5597 scrollbarsNeedingUpdate = 0; 5629 scrollbarsNeedingUpdate = 0;
5630 fs_state = FULLSCREEN_NONE;
5631 fs_before_fs = next_maximized = -1;
5632 maximized_width = maximized_height = -1;
5633 nonfs_window = nil;
5598 5634
5599/*fprintf (stderr,"init with %d, %d\n",f->text_cols, f->text_lines); */ 5635/*fprintf (stderr,"init with %d, %d\n",f->text_cols, f->text_lines); */
5600 5636
@@ -5619,9 +5655,13 @@ not_in_argv (NSString *arg)
5619 backing: NSBackingStoreBuffered 5655 backing: NSBackingStoreBuffered
5620 defer: YES]; 5656 defer: YES];
5621 5657
5658#ifdef NEW_STYLE_FS
5659 [win setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
5660#endif
5661
5622 wr = [win frame]; 5662 wr = [win frame];
5623 f->border_width = wr.size.width - r.size.width; 5663 bwidth = f->border_width = wr.size.width - r.size.width;
5624 FRAME_NS_TITLEBAR_HEIGHT (f) = wr.size.height - r.size.height; 5664 tbar_height = FRAME_NS_TITLEBAR_HEIGHT (f) = wr.size.height - r.size.height;
5625 5665
5626 [win setAcceptsMouseMovedEvents: YES]; 5666 [win setAcceptsMouseMovedEvents: YES];
5627 [win setDelegate: self]; 5667 [win setDelegate: self];
@@ -5727,27 +5767,50 @@ not_in_argv (NSString *arg)
5727 5767
5728 NSTRACE (windowWillUseStandardFrame); 5768 NSTRACE (windowWillUseStandardFrame);
5729 5769
5730 if (abs (defaultFrame.size.height - result.size.height) 5770 if (fs_before_fs != -1) /* Entering fullscreen */
5731 > FRAME_LINE_HEIGHT (emacsframe)) 5771 {
5772 result = defaultFrame;
5773 }
5774 else if (next_maximized == FULLSCREEN_HEIGHT
5775 || (next_maximized == -1
5776 && abs (defaultFrame.size.height - result.size.height)
5777 > FRAME_LINE_HEIGHT (emacsframe)))
5732 { 5778 {
5733 /* first click */ 5779 /* first click */
5734 ns_userRect = result; 5780 ns_userRect = result;
5735 result.size.height = defaultFrame.size.height; 5781 maximized_height = result.size.height = defaultFrame.size.height;
5782 maximized_width = -1;
5736 result.origin.y = defaultFrame.origin.y; 5783 result.origin.y = defaultFrame.origin.y;
5784 [self setFSValue: FULLSCREEN_HEIGHT];
5785 }
5786 else if (next_maximized == FULLSCREEN_WIDTH)
5787 {
5788 ns_userRect = result;
5789 maximized_width = result.size.width = defaultFrame.size.width;
5790 maximized_height = -1;
5791 result.origin.x = defaultFrame.origin.x;
5792 [self setFSValue: FULLSCREEN_WIDTH];
5793 }
5794 else if (next_maximized == FULLSCREEN_MAXIMIZED
5795 || (next_maximized == -1
5796 && abs (defaultFrame.size.width - result.size.width)
5797 > FRAME_COLUMN_WIDTH (emacsframe)))
5798 {
5799 result = defaultFrame; /* second click */
5800 maximized_width = result.size.width;
5801 maximized_height = result.size.height;
5802 [self setFSValue: FULLSCREEN_MAXIMIZED];
5737 } 5803 }
5738 else 5804 else
5739 { 5805 {
5740 if (abs (defaultFrame.size.width - result.size.width) 5806 /* restore */
5741 > FRAME_COLUMN_WIDTH (emacsframe)) 5807 result = ns_userRect.size.height ? ns_userRect : result;
5742 result = defaultFrame; /* second click */ 5808 ns_userRect = NSMakeRect (0, 0, 0, 0);
5743 else 5809 [self setFSValue: FULLSCREEN_NONE];
5744 { 5810 maximized_width = maximized_width = -1;
5745 /* restore */
5746 result = ns_userRect.size.height ? ns_userRect : result;
5747 ns_userRect = NSMakeRect (0, 0, 0, 0);
5748 }
5749 } 5811 }
5750 5812
5813 if (fs_before_fs == -1) next_maximized = -1;
5751 [self windowWillResize: sender toSize: result.size]; 5814 [self windowWillResize: sender toSize: result.size];
5752 return result; 5815 return result;
5753} 5816}
@@ -5799,6 +5862,199 @@ not_in_argv (NSString *arg)
5799 } 5862 }
5800} 5863}
5801 5864
5865- (void)windowWillEnterFullScreen:(NSNotification *)notification
5866{
5867 fs_before_fs = fs_state;
5868}
5869
5870- (void)windowDidEnterFullScreen:(NSNotification *)notification
5871{
5872 [self setFSValue: FULLSCREEN_BOTH];
5873#ifndef NEW_STYLE_FS
5874 [self windowDidBecomeKey:notification];
5875#endif
5876}
5877
5878- (void)windowWillExitFullScreen:(NSNotification *)notification
5879{
5880 if (next_maximized != -1)
5881 fs_before_fs = next_maximized;
5882}
5883
5884- (void)windowDidExitFullScreen:(NSNotification *)notification
5885{
5886 [self setFSValue: fs_before_fs];
5887 fs_before_fs = -1;
5888 if (next_maximized != -1)
5889 [[self window] performZoom:self];
5890}
5891
5892- (void)toggleFullScreen: (id)sender
5893{
5894 /* Bugs remain:
5895 1) Having fullscreen in initial/default frame alist.
5896 2) Fullscreen in default frame alist only applied to first frame.
5897 */
5898
5899#ifdef NEW_STYLE_FS
5900 [[self window] toggleFullScreen:sender];
5901#else
5902 NSWindow *w = [self window], *fw;
5903 BOOL onFirstScreen = [[w screen]
5904 isEqual:[[NSScreen screens] objectAtIndex:0]];
5905 struct frame *f = emacsframe;
5906 NSSize sz;
5907 NSRect r;
5908 NSColor *col = ns_lookup_indexed_color (NS_FACE_BACKGROUND
5909 (FRAME_DEFAULT_FACE (f)),
5910 f);
5911
5912 sz.width = FRAME_COLUMN_WIDTH (f);
5913 sz.height = FRAME_LINE_HEIGHT (f);
5914
5915 if (fs_state != FULLSCREEN_BOTH)
5916 {
5917 /* Hide dock and menubar if we are on the primary screen. */
5918 if (onFirstScreen)
5919 {
5920#if defined (NS_IMPL_COCOA) && \
5921 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
5922 NSApplicationPresentationOptions options
5923 = NSApplicationPresentationAutoHideDock
5924 | NSApplicationPresentationAutoHideMenuBar;
5925
5926 [NSApp setPresentationOptions: options];
5927#else
5928 [NSMenu setMenuBarVisible:NO];
5929#endif
5930 }
5931
5932 fw = [[EmacsFSWindow alloc]
5933 initWithContentRect:[w contentRectForFrameRect:[w frame]]
5934 styleMask:NSBorderlessWindowMask
5935 backing:NSBackingStoreBuffered
5936 defer:YES
5937 screen:[w screen]];
5938
5939 [fw setContentView:[w contentView]];
5940 [fw setTitle:[w title]];
5941 [fw makeKeyAndOrderFront:NSApp];
5942 [fw setDelegate:self];
5943 [fw makeFirstResponder:self];
5944 [fw setAcceptsMouseMovedEvents: YES];
5945 [fw useOptimizedDrawing: YES];
5946 [fw setResizeIncrements: sz];
5947 [fw setBackgroundColor: col];
5948 if ([col alphaComponent] != 1.0)
5949 [fw setOpaque: NO];
5950
5951 f->border_width = 0;
5952 FRAME_NS_TITLEBAR_HEIGHT (f) = 0;
5953
5954 nonfs_window = w;
5955 [self windowWillEnterFullScreen:nil];
5956 [w orderOut:self];
5957 r = [fw frameRectForContentRect:[[fw screen] frame]];
5958 [fw setFrame: r display:YES animate:YES];
5959 [self windowDidEnterFullScreen:nil];
5960 }
5961 else
5962 {
5963 fw = w;
5964 w = nonfs_window;
5965
5966 if (onFirstScreen)
5967 {
5968#if defined (NS_IMPL_COCOA) && \
5969 MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6
5970 [NSApp setPresentationOptions: NSApplicationPresentationDefault];
5971#else
5972 [NSMenu setMenuBarVisible:YES];
5973#endif
5974 }
5975
5976 [w setContentView:[fw contentView]];
5977 [w setResizeIncrements: sz];
5978 [w setBackgroundColor: col];
5979 if ([col alphaComponent] != 1.0)
5980 [w setOpaque: NO];
5981
5982 f->border_width = bwidth;
5983 FRAME_NS_TITLEBAR_HEIGHT (f) = tbar_height;
5984
5985 [self windowWillExitFullScreen:nil];
5986 [fw setFrame: [w frame] display:YES animate:YES];
5987 [fw close];
5988 [w makeKeyAndOrderFront:NSApp];
5989 [self windowDidExitFullScreen:nil];
5990 }
5991#endif
5992}
5993
5994- (void)handleFS
5995{
5996 if (fs_state != emacsframe->want_fullscreen)
5997 {
5998 if (fs_state == FULLSCREEN_BOTH)
5999 {
6000 [self toggleFullScreen:self];
6001 }
6002
6003 switch (emacsframe->want_fullscreen)
6004 {
6005 case FULLSCREEN_BOTH:
6006 [self toggleFullScreen:self];
6007 break;
6008 case FULLSCREEN_WIDTH:
6009 next_maximized = FULLSCREEN_WIDTH;
6010 if (fs_state != FULLSCREEN_BOTH)
6011 [[self window] performZoom:self];
6012 break;
6013 case FULLSCREEN_HEIGHT:
6014 next_maximized = FULLSCREEN_HEIGHT;
6015 if (fs_state != FULLSCREEN_BOTH)
6016 [[self window] performZoom:self];
6017 break;
6018 case FULLSCREEN_MAXIMIZED:
6019 next_maximized = FULLSCREEN_MAXIMIZED;
6020 if (fs_state != FULLSCREEN_BOTH)
6021 [[self window] performZoom:self];
6022 break;
6023 case FULLSCREEN_NONE:
6024 if (fs_state != FULLSCREEN_BOTH)
6025 {
6026 next_maximized = FULLSCREEN_NONE;
6027 [[self window] performZoom:self];
6028 }
6029 break;
6030 }
6031
6032 emacsframe->want_fullscreen = FULLSCREEN_NONE;
6033 }
6034
6035}
6036
6037- (void) setFSValue: (int)value
6038{
6039 Lisp_Object lval = Qnil;
6040 switch (value)
6041 {
6042 case FULLSCREEN_BOTH:
6043 lval = Qfullboth;
6044 break;
6045 case FULLSCREEN_WIDTH:
6046 lval = Qfullwidth;
6047 break;
6048 case FULLSCREEN_HEIGHT:
6049 lval = Qfullheight;
6050 break;
6051 case FULLSCREEN_MAXIMIZED:
6052 lval = Qmaximized;
6053 break;
6054 }
6055 store_frame_param (emacsframe, Qfullscreen, lval);
6056 fs_state = value;
6057}
5802 6058
5803- (void)mouseEntered: (NSEvent *)theEvent 6059- (void)mouseEntered: (NSEvent *)theEvent
5804{ 6060{
@@ -6290,6 +6546,15 @@ not_in_argv (NSString *arg)
6290@end /* EmacsWindow */ 6546@end /* EmacsWindow */
6291 6547
6292 6548
6549@implementation EmacsFSWindow
6550
6551- (BOOL)canBecomeKeyWindow
6552{
6553 return YES;
6554}
6555
6556@end
6557
6293/* ========================================================================== 6558/* ==========================================================================
6294 6559
6295 EmacsScroller implementation 6560 EmacsScroller implementation
diff --git a/src/process.c b/src/process.c
index ab215766c07..92bea0d3a27 100644
--- a/src/process.c
+++ b/src/process.c
@@ -335,82 +335,82 @@ static struct sockaddr_and_len {
335static int pty_max_bytes; 335static int pty_max_bytes;
336 336
337/* These setters are used only in this file, so they can be private. */ 337/* These setters are used only in this file, so they can be private. */
338static inline void 338static void
339pset_buffer (struct Lisp_Process *p, Lisp_Object val) 339pset_buffer (struct Lisp_Process *p, Lisp_Object val)
340{ 340{
341 p->buffer = val; 341 p->buffer = val;
342} 342}
343static inline void 343static void
344pset_command (struct Lisp_Process *p, Lisp_Object val) 344pset_command (struct Lisp_Process *p, Lisp_Object val)
345{ 345{
346 p->command = val; 346 p->command = val;
347} 347}
348static inline void 348static void
349pset_decode_coding_system (struct Lisp_Process *p, Lisp_Object val) 349pset_decode_coding_system (struct Lisp_Process *p, Lisp_Object val)
350{ 350{
351 p->decode_coding_system = val; 351 p->decode_coding_system = val;
352} 352}
353static inline void 353static void
354pset_decoding_buf (struct Lisp_Process *p, Lisp_Object val) 354pset_decoding_buf (struct Lisp_Process *p, Lisp_Object val)
355{ 355{
356 p->decoding_buf = val; 356 p->decoding_buf = val;
357} 357}
358static inline void 358static void
359pset_encode_coding_system (struct Lisp_Process *p, Lisp_Object val) 359pset_encode_coding_system (struct Lisp_Process *p, Lisp_Object val)
360{ 360{
361 p->encode_coding_system = val; 361 p->encode_coding_system = val;
362} 362}
363static inline void 363static void
364pset_encoding_buf (struct Lisp_Process *p, Lisp_Object val) 364pset_encoding_buf (struct Lisp_Process *p, Lisp_Object val)
365{ 365{
366 p->encoding_buf = val; 366 p->encoding_buf = val;
367} 367}
368static inline void 368static void
369pset_filter (struct Lisp_Process *p, Lisp_Object val) 369pset_filter (struct Lisp_Process *p, Lisp_Object val)
370{ 370{
371 p->filter = val; 371 p->filter = val;
372} 372}
373static inline void 373static void
374pset_log (struct Lisp_Process *p, Lisp_Object val) 374pset_log (struct Lisp_Process *p, Lisp_Object val)
375{ 375{
376 p->log = val; 376 p->log = val;
377} 377}
378static inline void 378static void
379pset_mark (struct Lisp_Process *p, Lisp_Object val) 379pset_mark (struct Lisp_Process *p, Lisp_Object val)
380{ 380{
381 p->mark = val; 381 p->mark = val;
382} 382}
383static inline void 383static void
384pset_name (struct Lisp_Process *p, Lisp_Object val) 384pset_name (struct Lisp_Process *p, Lisp_Object val)
385{ 385{
386 p->name = val; 386 p->name = val;
387} 387}
388static inline void 388static void
389pset_plist (struct Lisp_Process *p, Lisp_Object val) 389pset_plist (struct Lisp_Process *p, Lisp_Object val)
390{ 390{
391 p->plist = val; 391 p->plist = val;
392} 392}
393static inline void 393static void
394pset_sentinel (struct Lisp_Process *p, Lisp_Object val) 394pset_sentinel (struct Lisp_Process *p, Lisp_Object val)
395{ 395{
396 p->sentinel = val; 396 p->sentinel = val;
397} 397}
398static inline void 398static void
399pset_status (struct Lisp_Process *p, Lisp_Object val) 399pset_status (struct Lisp_Process *p, Lisp_Object val)
400{ 400{
401 p->status = val; 401 p->status = val;
402} 402}
403static inline void 403static void
404pset_tty_name (struct Lisp_Process *p, Lisp_Object val) 404pset_tty_name (struct Lisp_Process *p, Lisp_Object val)
405{ 405{
406 p->tty_name = val; 406 p->tty_name = val;
407} 407}
408static inline void 408static void
409pset_type (struct Lisp_Process *p, Lisp_Object val) 409pset_type (struct Lisp_Process *p, Lisp_Object val)
410{ 410{
411 p->type = val; 411 p->type = val;
412} 412}
413static inline void 413static void
414pset_write_queue (struct Lisp_Process *p, Lisp_Object val) 414pset_write_queue (struct Lisp_Process *p, Lisp_Object val)
415{ 415{
416 p->write_queue = val; 416 p->write_queue = val;
@@ -570,7 +570,7 @@ status_message (struct Lisp_Process *p)
570 570
571 if (EQ (symbol, Qsignal) || EQ (symbol, Qstop)) 571 if (EQ (symbol, Qsignal) || EQ (symbol, Qstop))
572 { 572 {
573 char *signame; 573 char const *signame;
574 synchronize_system_messages_locale (); 574 synchronize_system_messages_locale ();
575 signame = strsignal (code); 575 signame = strsignal (code);
576 if (signame == 0) 576 if (signame == 0)
diff --git a/src/profiler.c b/src/profiler.c
index 877a42cc98e..461aae3e09f 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -18,12 +18,18 @@ You should have received a copy of the GNU General Public License
18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ 18along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20#include <config.h> 20#include <config.h>
21#include <stdio.h>
22#include <limits.h>
23#include <sys/time.h>
24#include <signal.h>
25#include <setjmp.h>
26#include "lisp.h" 21#include "lisp.h"
22#include "syssignal.h"
23#include "systime.h"
24
25/* Return A + B, but return the maximum fixnum if the result would overflow.
26 Assume A and B are nonnegative and in fixnum range. */
27
28static EMACS_INT
29saturated_add (EMACS_INT a, EMACS_INT b)
30{
31 return min (a + b, MOST_POSITIVE_FIXNUM);
32}
27 33
28/* Logs. */ 34/* Logs. */
29 35
@@ -121,14 +127,12 @@ static void evict_lower_half (log_t *log)
121 } 127 }
122} 128}
123 129
124/* Record the current backtrace in LOG. BASE is a special name for 130/* Record the current backtrace in LOG. COUNT is the weight of this
125 describing which the backtrace come from. BASE can be nil. COUNT is 131 current backtrace: interrupt counts for CPU, and the allocation
126 a number how many times the profiler sees the backtrace at the 132 size for memory. */
127 time. ELAPSED is a elapsed time in millisecond that the backtrace
128 took. */
129 133
130static void 134static void
131record_backtrace (log_t *log, size_t count) 135record_backtrace (log_t *log, EMACS_INT count)
132{ 136{
133 struct backtrace *backlist = backtrace_list; 137 struct backtrace *backlist = backtrace_list;
134 Lisp_Object backtrace; 138 Lisp_Object backtrace;
@@ -148,7 +152,7 @@ record_backtrace (log_t *log, size_t count)
148 /* Copy the backtrace contents into working memory. */ 152 /* Copy the backtrace contents into working memory. */
149 for (; i < asize && backlist; i++, backlist = backlist->next) 153 for (; i < asize && backlist; i++, backlist = backlist->next)
150 /* FIXME: For closures we should ignore the environment. */ 154 /* FIXME: For closures we should ignore the environment. */
151 ASET (backtrace, i, *backlist->function); 155 ASET (backtrace, i, backlist->function);
152 156
153 /* Make sure that unused space of working memory is filled with nil. */ 157 /* Make sure that unused space of working memory is filled with nil. */
154 for (; i < asize; i++) 158 for (; i < asize; i++)
@@ -161,8 +165,11 @@ record_backtrace (log_t *log, size_t count)
161 EMACS_UINT hash; 165 EMACS_UINT hash;
162 ptrdiff_t j = hash_lookup (log, backtrace, &hash); 166 ptrdiff_t j = hash_lookup (log, backtrace, &hash);
163 if (j >= 0) 167 if (j >= 0)
164 set_hash_value_slot (log, j, 168 {
165 make_number (count + XINT (HASH_VALUE (log, j)))); 169 EMACS_INT old_val = XINT (HASH_VALUE (log, j));
170 EMACS_INT new_val = saturated_add (old_val, count);
171 set_hash_value_slot (log, j, make_number (new_val));
172 }
166 else 173 else
167 { /* BEWARE! hash_put in general can allocate memory. 174 { /* BEWARE! hash_put in general can allocate memory.
168 But currently it only does that if log->next_free is nil. */ 175 But currently it only does that if log->next_free is nil. */
@@ -191,56 +198,153 @@ record_backtrace (log_t *log, size_t count)
191 } 198 }
192} 199}
193 200
194/* Sample profiler. */ 201/* Sampling profiler. */
195 202
196/* FIXME: Add support for the CPU profiler in W32. */ 203#ifdef PROFILER_CPU_SUPPORT
197/* FIXME: the sigprof_handler suffers from race-conditions if the signal
198 is delivered to a thread other than the main Emacs thread. */
199 204
200#if defined SIGPROF && defined HAVE_SETITIMER 205/* The profiler timer and whether it was properly initialized, if
201#define PROFILER_CPU_SUPPORT 206 POSIX timers are available. */
207#ifdef HAVE_ITIMERSPEC
208static timer_t profiler_timer;
209static bool profiler_timer_ok;
210#endif
202 211
203/* True if sampling profiler is running. */ 212/* Status of sampling profiler. */
204static bool profiler_cpu_running; 213static enum profiler_cpu_running
214 { NOT_RUNNING, TIMER_SETTIME_RUNNING, SETITIMER_RUNNING }
215 profiler_cpu_running;
205 216
217/* Hash-table log of CPU profiler. */
206static Lisp_Object cpu_log; 218static Lisp_Object cpu_log;
219
207/* Separate counter for the time spent in the GC. */ 220/* Separate counter for the time spent in the GC. */
208static EMACS_INT cpu_gc_count; 221static EMACS_INT cpu_gc_count;
209 222
210/* The current sample interval in millisecond. */ 223/* The current sampling interval in nanoseconds. */
224static EMACS_INT current_sampling_interval;
211 225
212static int current_sample_interval; 226/* Signal handler for sampling profiler. */
213
214/* Signal handler for sample profiler. */
215 227
216static void 228static void
217sigprof_handler (int signal) 229handle_profiler_signal (int signal)
218{ 230{
219 eassert (HASH_TABLE_P (cpu_log)); 231 if (backtrace_list && EQ (backtrace_list->function, Qautomatic_gc))
220 if (backtrace_list && EQ (*backtrace_list->function, Qautomatic_gc))
221 /* Special case the time-count inside GC because the hash-table 232 /* Special case the time-count inside GC because the hash-table
222 code is not prepared to be used while the GC is running. 233 code is not prepared to be used while the GC is running.
223 More specifically it uses ASIZE at many places where it does 234 More specifically it uses ASIZE at many places where it does
224 not expect the ARRAY_MARK_FLAG to be set. We could try and 235 not expect the ARRAY_MARK_FLAG to be set. We could try and
225 harden the hash-table code, but it doesn't seem worth the 236 harden the hash-table code, but it doesn't seem worth the
226 effort. */ 237 effort. */
227 cpu_gc_count += current_sample_interval; 238 cpu_gc_count = saturated_add (cpu_gc_count, 1);
228 else 239 else
229 record_backtrace (XHASH_TABLE (cpu_log), current_sample_interval); 240 {
241 Lisp_Object oquit;
242 EMACS_INT count = 1;
243#ifdef HAVE_ITIMERSPEC
244 if (profiler_timer_ok)
245 {
246 int overruns = timer_getoverrun (profiler_timer);
247 eassert (0 <= overruns);
248 count += overruns;
249 }
250#endif
251 /* record_backtrace uses hash functions that call Fequal, which
252 uses QUIT, which can call malloc, which can cause disaster in
253 a signal handler. So inhibit QUIT. */
254 oquit = Vinhibit_quit;
255 Vinhibit_quit = Qt;
256
257 eassert (HASH_TABLE_P (cpu_log));
258 record_backtrace (XHASH_TABLE (cpu_log), count);
259
260 Vinhibit_quit = oquit;
261 }
262}
263
264static void
265deliver_profiler_signal (int signal)
266{
267 deliver_process_signal (signal, handle_profiler_signal);
268}
269
270static enum profiler_cpu_running
271setup_cpu_timer (Lisp_Object sampling_interval)
272{
273 struct sigaction action;
274 struct itimerval timer;
275 struct timespec interval;
276 int billion = 1000000000;
277
278 if (! RANGED_INTEGERP (1, sampling_interval,
279 (TYPE_MAXIMUM (time_t) < EMACS_INT_MAX / billion
280 ? ((EMACS_INT) TYPE_MAXIMUM (time_t) * billion
281 + (billion - 1))
282 : EMACS_INT_MAX)))
283 return NOT_RUNNING;
284
285 current_sampling_interval = XINT (sampling_interval);
286 interval = make_emacs_time (current_sampling_interval / billion,
287 current_sampling_interval % billion);
288 emacs_sigaction_init (&action, deliver_profiler_signal);
289 sigaction (SIGPROF, &action, 0);
290
291#ifdef HAVE_ITIMERSPEC
292 if (! profiler_timer_ok)
293 {
294 /* System clocks to try, in decreasing order of desirability. */
295 static clockid_t const system_clock[] = {
296#ifdef CLOCK_THREAD_CPUTIME_ID
297 CLOCK_THREAD_CPUTIME_ID,
298#endif
299#ifdef CLOCK_PROCESS_CPUTIME_ID
300 CLOCK_PROCESS_CPUTIME_ID,
301#endif
302#ifdef CLOCK_MONOTONIC
303 CLOCK_MONOTONIC,
304#endif
305 CLOCK_REALTIME
306 };
307 int i;
308 struct sigevent sigev;
309 sigev.sigev_value.sival_ptr = &profiler_timer;
310 sigev.sigev_signo = SIGPROF;
311 sigev.sigev_notify = SIGEV_SIGNAL;
312
313 for (i = 0; i < sizeof system_clock / sizeof *system_clock; i++)
314 if (timer_create (system_clock[i], &sigev, &profiler_timer) == 0)
315 {
316 profiler_timer_ok = 1;
317 break;
318 }
319 }
320
321 if (profiler_timer_ok)
322 {
323 struct itimerspec ispec;
324 ispec.it_value = ispec.it_interval = interval;
325 if (timer_settime (profiler_timer, 0, &ispec, 0) == 0)
326 return TIMER_SETTIME_RUNNING;
327 }
328#endif
329
330#ifdef HAVE_SETITIMER
331 timer.it_value = timer.it_interval = make_timeval (interval);
332 if (setitimer (ITIMER_PROF, &timer, 0) == 0)
333 return SETITIMER_RUNNING;
334#endif
335
336 return NOT_RUNNING;
230} 337}
231 338
232DEFUN ("profiler-cpu-start", Fprofiler_cpu_start, Sprofiler_cpu_start, 339DEFUN ("profiler-cpu-start", Fprofiler_cpu_start, Sprofiler_cpu_start,
233 1, 1, 0, 340 1, 1, 0,
234 doc: /* Start or restart the cpu profiler. 341 doc: /* Start or restart the cpu profiler.
235The cpu profiler will take call-stack samples each SAMPLE-INTERVAL (expressed in milliseconds). 342It takes call-stack samples each SAMPLING-INTERVAL nanoseconds, approximately.
236See also `profiler-log-size' and `profiler-max-stack-depth'. */) 343See also `profiler-log-size' and `profiler-max-stack-depth'. */)
237 (Lisp_Object sample_interval) 344 (Lisp_Object sampling_interval)
238{ 345{
239 struct sigaction sa;
240 struct itimerval timer;
241
242 if (profiler_cpu_running) 346 if (profiler_cpu_running)
243 error ("Sample profiler is already running"); 347 error ("CPU profiler is already running");
244 348
245 if (NILP (cpu_log)) 349 if (NILP (cpu_log))
246 { 350 {
@@ -249,19 +353,9 @@ See also `profiler-log-size' and `profiler-max-stack-depth'. */)
249 profiler_max_stack_depth); 353 profiler_max_stack_depth);
250 } 354 }
251 355
252 current_sample_interval = XINT (sample_interval); 356 profiler_cpu_running = setup_cpu_timer (sampling_interval);
253 357 if (! profiler_cpu_running)
254 sa.sa_handler = sigprof_handler; 358 error ("Invalid sampling interval");
255 sa.sa_flags = SA_RESTART;
256 sigemptyset (&sa.sa_mask);
257 sigaction (SIGPROF, &sa, 0);
258
259 timer.it_interval.tv_sec = 0;
260 timer.it_interval.tv_usec = current_sample_interval * 1000;
261 timer.it_value = timer.it_interval;
262 setitimer (ITIMER_PROF, &timer, 0);
263
264 profiler_cpu_running = true;
265 359
266 return Qt; 360 return Qt;
267} 361}
@@ -272,12 +366,34 @@ DEFUN ("profiler-cpu-stop", Fprofiler_cpu_stop, Sprofiler_cpu_stop,
272Return non-nil if the profiler was running. */) 366Return non-nil if the profiler was running. */)
273 (void) 367 (void)
274{ 368{
275 if (!profiler_cpu_running) 369 switch (profiler_cpu_running)
276 return Qnil; 370 {
277 profiler_cpu_running = false; 371 case NOT_RUNNING:
372 return Qnil;
278 373
279 setitimer (ITIMER_PROF, 0, 0); 374#ifdef HAVE_ITIMERSPEC
375 case TIMER_SETTIME_RUNNING:
376 {
377 struct itimerspec disable;
378 memset (&disable, 0, sizeof disable);
379 timer_settime (profiler_timer, 0, &disable, 0);
380 }
381 break;
382#endif
280 383
384#ifdef HAVE_SETITIMER
385 case SETITIMER_RUNNING:
386 {
387 struct itimerval disable;
388 memset (&disable, 0, sizeof disable);
389 setitimer (ITIMER_PROF, &disable, 0);
390 }
391 break;
392#endif
393 }
394
395 signal (SIGPROF, SIG_IGN);
396 profiler_cpu_running = NOT_RUNNING;
281 return Qt; 397 return Qt;
282} 398}
283 399
@@ -300,7 +416,7 @@ Before returning, a new log is allocated for future samples. */)
300 (void) 416 (void)
301{ 417{
302 Lisp_Object result = cpu_log; 418 Lisp_Object result = cpu_log;
303 /* Here we're making the log visible to Elisp , so it's not safe any 419 /* Here we're making the log visible to Elisp, so it's not safe any
304 more for our use afterwards since we can't rely on its special 420 more for our use afterwards since we can't rely on its special
305 pre-allocated keys anymore. So we have to allocate a new one. */ 421 pre-allocated keys anymore. So we have to allocate a new one. */
306 cpu_log = (profiler_cpu_running 422 cpu_log = (profiler_cpu_running
@@ -312,7 +428,7 @@ Before returning, a new log is allocated for future samples. */)
312 cpu_gc_count = 0; 428 cpu_gc_count = 0;
313 return result; 429 return result;
314} 430}
315#endif /* not defined PROFILER_CPU_SUPPORT */ 431#endif /* PROFILER_CPU_SUPPORT */
316 432
317/* Memory profiler. */ 433/* Memory profiler. */
318 434
@@ -392,7 +508,7 @@ void
392malloc_probe (size_t size) 508malloc_probe (size_t size)
393{ 509{
394 eassert (HASH_TABLE_P (memory_log)); 510 eassert (HASH_TABLE_P (memory_log));
395 record_backtrace (XHASH_TABLE (memory_log), size); 511 record_backtrace (XHASH_TABLE (memory_log), min (size, MOST_POSITIVE_FIXNUM));
396} 512}
397 513
398void 514void
@@ -408,7 +524,7 @@ to make room for new entries. */);
408 profiler_log_size = 10000; 524 profiler_log_size = 10000;
409 525
410#ifdef PROFILER_CPU_SUPPORT 526#ifdef PROFILER_CPU_SUPPORT
411 profiler_cpu_running = false; 527 profiler_cpu_running = NOT_RUNNING;
412 cpu_log = Qnil; 528 cpu_log = Qnil;
413 staticpro (&cpu_log); 529 staticpro (&cpu_log);
414 defsubr (&Sprofiler_cpu_start); 530 defsubr (&Sprofiler_cpu_start);
diff --git a/src/ralloc.c b/src/ralloc.c
index ab91baae5b5..e4a8fe9c6da 100644
--- a/src/ralloc.c
+++ b/src/ralloc.c
@@ -72,7 +72,7 @@ static void r_alloc_init (void);
72/* Declarations for working with the malloc, ralloc, and system breaks. */ 72/* Declarations for working with the malloc, ralloc, and system breaks. */
73 73
74/* Function to set the real break value. */ 74/* Function to set the real break value. */
75POINTER (*real_morecore) (long int); 75POINTER (*real_morecore) (ptrdiff_t);
76 76
77/* The break value, as seen by malloc. */ 77/* The break value, as seen by malloc. */
78static POINTER virtual_break_value; 78static POINTER virtual_break_value;
@@ -91,18 +91,18 @@ static int extra_bytes;
91/* Macros for rounding. Note that rounding to any value is possible 91/* Macros for rounding. Note that rounding to any value is possible
92 by changing the definition of PAGE. */ 92 by changing the definition of PAGE. */
93#define PAGE (getpagesize ()) 93#define PAGE (getpagesize ())
94#define ROUNDUP(size) (((unsigned long int) (size) + page_size - 1) \ 94#define ROUNDUP(size) (((size_t) (size) + page_size - 1) \
95 & ~(page_size - 1)) 95 & ~((size_t)(page_size - 1)))
96 96
97#define MEM_ALIGN sizeof (double) 97#define MEM_ALIGN sizeof (double)
98#define MEM_ROUNDUP(addr) (((unsigned long int)(addr) + MEM_ALIGN - 1) \ 98#define MEM_ROUNDUP(addr) (((size_t)(addr) + MEM_ALIGN - 1) \
99 & ~(MEM_ALIGN - 1)) 99 & ~(MEM_ALIGN - 1))
100 100
101/* The hook `malloc' uses for the function which gets more space 101/* The hook `malloc' uses for the function which gets more space
102 from the system. */ 102 from the system. */
103 103
104#ifndef SYSTEM_MALLOC 104#ifndef SYSTEM_MALLOC
105extern POINTER (*__morecore) (long int); 105extern POINTER (*__morecore) (ptrdiff_t);
106#endif 106#endif
107 107
108 108
@@ -308,7 +308,7 @@ static void
308relinquish (void) 308relinquish (void)
309{ 309{
310 register heap_ptr h; 310 register heap_ptr h;
311 long excess = 0; 311 ptrdiff_t excess = 0;
312 312
313 /* Add the amount of space beyond break_value 313 /* Add the amount of space beyond break_value
314 in all heaps which have extend beyond break_value at all. */ 314 in all heaps which have extend beyond break_value at all. */
@@ -752,7 +752,7 @@ free_bloc (bloc_ptr bloc)
752 GNU malloc package. */ 752 GNU malloc package. */
753 753
754static POINTER 754static POINTER
755r_alloc_sbrk (long int size) 755r_alloc_sbrk (ptrdiff_t size)
756{ 756{
757 register bloc_ptr b; 757 register bloc_ptr b;
758 POINTER address; 758 POINTER address;
diff --git a/src/syntax.c b/src/syntax.c
index 91ef4e66663..d3cafcc472e 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -151,7 +151,7 @@ static void scan_sexps_forward (struct lisp_parse_state *,
151static int in_classes (int, Lisp_Object); 151static int in_classes (int, Lisp_Object);
152 152
153/* This setter is used only in this file, so it can be private. */ 153/* This setter is used only in this file, so it can be private. */
154static inline void 154static void
155bset_syntax_table (struct buffer *b, Lisp_Object val) 155bset_syntax_table (struct buffer *b, Lisp_Object val)
156{ 156{
157 b->INTERNAL_FIELD (syntax_table) = val; 157 b->INTERNAL_FIELD (syntax_table) = val;
@@ -372,7 +372,7 @@ char_quoted (ptrdiff_t charpos, ptrdiff_t bytepos)
372/* Return the bytepos one character before BYTEPOS. 372/* Return the bytepos one character before BYTEPOS.
373 We assume that BYTEPOS is not at the start of the buffer. */ 373 We assume that BYTEPOS is not at the start of the buffer. */
374 374
375static inline ptrdiff_t 375static ptrdiff_t
376dec_bytepos (ptrdiff_t bytepos) 376dec_bytepos (ptrdiff_t bytepos)
377{ 377{
378 if (NILP (BVAR (current_buffer, enable_multibyte_characters))) 378 if (NILP (BVAR (current_buffer, enable_multibyte_characters)))
diff --git a/src/sysdep.c b/src/sysdep.c
index f4e055c31a0..74617fcaf0f 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -54,6 +54,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
54#ifdef WINDOWSNT 54#ifdef WINDOWSNT
55#define read sys_read 55#define read sys_read
56#define write sys_write 56#define write sys_write
57#ifndef STDERR_FILENO
58#define STDERR_FILENO fileno(GetStdHandle(STD_ERROR_HANDLE))
59#endif
57#include <windows.h> 60#include <windows.h>
58#endif /* not WINDOWSNT */ 61#endif /* not WINDOWSNT */
59 62
@@ -1447,6 +1450,9 @@ emacs_sigaction_init (struct sigaction *action, signal_handler_t handler)
1447#ifdef SIGDANGER 1450#ifdef SIGDANGER
1448 sigaddset (&action->sa_mask, SIGDANGER); 1451 sigaddset (&action->sa_mask, SIGDANGER);
1449#endif 1452#endif
1453#ifdef PROFILER_CPU_SUPPORT
1454 sigaddset (&action->sa_mask, SIGPROF);
1455#endif
1450#ifdef SIGWINCH 1456#ifdef SIGWINCH
1451 sigaddset (&action->sa_mask, SIGWINCH); 1457 sigaddset (&action->sa_mask, SIGWINCH);
1452#endif 1458#endif
@@ -1537,19 +1543,17 @@ deliver_thread_signal (int sig, signal_handler_t handler)
1537 errno = old_errno; 1543 errno = old_errno;
1538} 1544}
1539 1545
1540#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST 1546#if !HAVE_DECL_SYS_SIGLIST
1541static char *my_sys_siglist[NSIG]; 1547# undef sys_siglist
1542# ifdef sys_siglist
1543# undef sys_siglist
1544# endif
1545# define sys_siglist my_sys_siglist 1548# define sys_siglist my_sys_siglist
1549static char const *sys_siglist[NSIG];
1546#endif 1550#endif
1547 1551
1548/* Handle bus errors, invalid instruction, etc. */ 1552/* Handle bus errors, invalid instruction, etc. */
1549static void 1553static void
1550handle_fatal_signal (int sig) 1554handle_fatal_signal (int sig)
1551{ 1555{
1552 terminate_due_to_signal (sig, 10); 1556 terminate_due_to_signal (sig, 40);
1553} 1557}
1554 1558
1555static void 1559static void
@@ -1605,7 +1609,7 @@ init_signals (bool dumping)
1605 main_thread = pthread_self (); 1609 main_thread = pthread_self ();
1606#endif 1610#endif
1607 1611
1608#if !defined HAVE_STRSIGNAL && !HAVE_DECL_SYS_SIGLIST 1612#if !HAVE_DECL_SYS_SIGLIST
1609 if (! initialized) 1613 if (! initialized)
1610 { 1614 {
1611 sys_siglist[SIGABRT] = "Aborted"; 1615 sys_siglist[SIGABRT] = "Aborted";
@@ -1753,7 +1757,7 @@ init_signals (bool dumping)
1753 sys_siglist[SIGXFSZ] = "File size limit exceeded"; 1757 sys_siglist[SIGXFSZ] = "File size limit exceeded";
1754# endif 1758# endif
1755 } 1759 }
1756#endif /* !defined HAVE_STRSIGNAL && !defined HAVE_DECL_SYS_SIGLIST */ 1760#endif /* !HAVE_DECL_SYS_SIGLIST */
1757 1761
1758 /* Don't alter signal handlers if dumping. On some machines, 1762 /* Don't alter signal handlers if dumping. On some machines,
1759 changing signal handlers sets static data that would make signals 1763 changing signal handlers sets static data that would make signals
@@ -1837,7 +1841,7 @@ init_signals (bool dumping)
1837#endif 1841#endif
1838 sigaction (SIGTERM, &process_fatal_action, 0); 1842 sigaction (SIGTERM, &process_fatal_action, 0);
1839#ifdef SIGPROF 1843#ifdef SIGPROF
1840 sigaction (SIGPROF, &process_fatal_action, 0); 1844 signal (SIGPROF, SIG_IGN);
1841#endif 1845#endif
1842#ifdef SIGVTALRM 1846#ifdef SIGVTALRM
1843 sigaction (SIGVTALRM, &process_fatal_action, 0); 1847 sigaction (SIGVTALRM, &process_fatal_action, 0);
@@ -2274,21 +2278,20 @@ set_file_times (int fd, const char *filename,
2274 return fdutimens (fd, filename, timespec); 2278 return fdutimens (fd, filename, timespec);
2275} 2279}
2276 2280
2277#ifndef HAVE_STRSIGNAL 2281/* Like strsignal, except async-signal-safe, and this function typically
2278char * 2282 returns a string in the C locale rather than the current locale. */
2279strsignal (int code) 2283char const *
2284safe_strsignal (int code)
2280{ 2285{
2281 char *signame = 0; 2286 char const *signame = 0;
2282 2287
2283 if (0 <= code && code < NSIG) 2288 if (0 <= code && code < NSIG)
2284 { 2289 signame = sys_siglist[code];
2285 /* Cast to suppress warning if the table has const char *. */ 2290 if (! signame)
2286 signame = (char *) sys_siglist[code]; 2291 signame = "Unknown signal";
2287 }
2288 2292
2289 return signame; 2293 return signame;
2290} 2294}
2291#endif /* HAVE_STRSIGNAL */
2292 2295
2293#ifndef DOS_NT 2296#ifndef DOS_NT
2294/* For make-serial-process */ 2297/* For make-serial-process */
diff --git a/src/syssignal.h b/src/syssignal.h
index 5c0edaa591d..83ab19698dd 100644
--- a/src/syssignal.h
+++ b/src/syssignal.h
@@ -29,11 +29,21 @@ extern void init_signals (bool);
29#define FORWARD_SIGNAL_TO_MAIN_THREAD 29#define FORWARD_SIGNAL_TO_MAIN_THREAD
30#endif 30#endif
31 31
32#if defined HAVE_TIMER_SETTIME && defined SIGEV_SIGNAL
33# define HAVE_ITIMERSPEC
34#endif
35
36#if (defined SIGPROF && !defined PROFILING \
37 && (defined HAVE_SETITIMER || defined HAVE_ITIMERSPEC))
38# define PROFILER_CPU_SUPPORT
39#endif
40
32extern sigset_t empty_mask; 41extern sigset_t empty_mask;
33 42
34typedef void (*signal_handler_t) (int); 43typedef void (*signal_handler_t) (int);
35 44
36extern void emacs_sigaction_init (struct sigaction *, signal_handler_t); 45extern void emacs_sigaction_init (struct sigaction *, signal_handler_t);
46char const *safe_strsignal (int);
37 47
38#if NSIG < NSIG_MINIMUM 48#if NSIG < NSIG_MINIMUM
39# undef NSIG 49# undef NSIG
@@ -65,8 +75,7 @@ extern void emacs_sigaction_init (struct sigaction *, signal_handler_t);
65#endif /* ! defined (SIGCLD) */ 75#endif /* ! defined (SIGCLD) */
66 76
67#ifndef HAVE_STRSIGNAL 77#ifndef HAVE_STRSIGNAL
68/* strsignal is in sysdep.c */ 78# define strsignal(sig) safe_strsignal (sig)
69char *strsignal (int);
70#endif 79#endif
71 80
72void deliver_process_signal (int, signal_handler_t); 81void deliver_process_signal (int, signal_handler_t);
diff --git a/src/terminal.c b/src/terminal.c
index 719c2a36111..2c0c60e7345 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -42,7 +42,7 @@ struct terminal *initial_terminal;
42static void delete_initial_terminal (struct terminal *); 42static void delete_initial_terminal (struct terminal *);
43 43
44/* This setter is used only in this file, so it can be private. */ 44/* This setter is used only in this file, so it can be private. */
45static inline void 45static void
46tset_param_alist (struct terminal *t, Lisp_Object val) 46tset_param_alist (struct terminal *t, Lisp_Object val)
47{ 47{
48 t->param_alist = val; 48 t->param_alist = val;
diff --git a/src/textprop.c b/src/textprop.c
index 872912ea706..379eafb73f7 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -241,7 +241,7 @@ interval_has_all_properties (Lisp_Object plist, INTERVAL i)
241/* Return nonzero if the plist of interval I has any of the 241/* Return nonzero if the plist of interval I has any of the
242 properties of PLIST, regardless of their values. */ 242 properties of PLIST, regardless of their values. */
243 243
244static inline int 244static int
245interval_has_some_properties (Lisp_Object plist, INTERVAL i) 245interval_has_some_properties (Lisp_Object plist, INTERVAL i)
246{ 246{
247 register Lisp_Object tail1, tail2, sym; 247 register Lisp_Object tail1, tail2, sym;
@@ -263,7 +263,7 @@ interval_has_some_properties (Lisp_Object plist, INTERVAL i)
263/* Return nonzero if the plist of interval I has any of the 263/* Return nonzero if the plist of interval I has any of the
264 property names in LIST, regardless of their values. */ 264 property names in LIST, regardless of their values. */
265 265
266static inline int 266static int
267interval_has_some_properties_list (Lisp_Object list, INTERVAL i) 267interval_has_some_properties_list (Lisp_Object list, INTERVAL i)
268{ 268{
269 register Lisp_Object tail1, tail2, sym; 269 register Lisp_Object tail1, tail2, sym;
diff --git a/src/unexw32.c b/src/unexw32.c
index 52b2ec4bf2b..3eefc9ce058 100644
--- a/src/unexw32.c
+++ b/src/unexw32.c
@@ -67,18 +67,18 @@ void dump_bss_and_heap (file_data *p_infile, file_data *p_outfile);
67/* Cached info about the .data section in the executable. */ 67/* Cached info about the .data section in the executable. */
68PIMAGE_SECTION_HEADER data_section; 68PIMAGE_SECTION_HEADER data_section;
69PCHAR data_start = 0; 69PCHAR data_start = 0;
70DWORD data_size = 0; 70DWORD_PTR data_size = 0;
71 71
72/* Cached info about the .bss section in the executable. */ 72/* Cached info about the .bss section in the executable. */
73PIMAGE_SECTION_HEADER bss_section; 73PIMAGE_SECTION_HEADER bss_section;
74PCHAR bss_start = 0; 74PCHAR bss_start = 0;
75DWORD bss_size = 0; 75DWORD_PTR bss_size = 0;
76DWORD extra_bss_size = 0; 76DWORD_PTR extra_bss_size = 0;
77/* bss data that is static might be discontiguous from non-static. */ 77/* bss data that is static might be discontiguous from non-static. */
78PIMAGE_SECTION_HEADER bss_section_static; 78PIMAGE_SECTION_HEADER bss_section_static;
79PCHAR bss_start_static = 0; 79PCHAR bss_start_static = 0;
80DWORD bss_size_static = 0; 80DWORD_PTR bss_size_static = 0;
81DWORD extra_bss_size_static = 0; 81DWORD_PTR extra_bss_size_static = 0;
82 82
83PIMAGE_SECTION_HEADER heap_section; 83PIMAGE_SECTION_HEADER heap_section;
84 84
@@ -231,7 +231,7 @@ find_section (char * name, IMAGE_NT_HEADERS * nt_header)
231/* Return pointer to section header for section containing the given 231/* Return pointer to section header for section containing the given
232 relative virtual address. */ 232 relative virtual address. */
233IMAGE_SECTION_HEADER * 233IMAGE_SECTION_HEADER *
234rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header) 234rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header)
235{ 235{
236 PIMAGE_SECTION_HEADER section; 236 PIMAGE_SECTION_HEADER section;
237 int i; 237 int i;
@@ -246,7 +246,7 @@ rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
246 some very old exes (eg. gzip dated Dec 1993). Since 246 some very old exes (eg. gzip dated Dec 1993). Since
247 w32_executable_type relies on this function to work reliably, 247 w32_executable_type relies on this function to work reliably,
248 we need to cope with this. */ 248 we need to cope with this. */
249 DWORD real_size = max (section->SizeOfRawData, 249 DWORD_PTR real_size = max (section->SizeOfRawData,
250 section->Misc.VirtualSize); 250 section->Misc.VirtualSize);
251 if (rva >= section->VirtualAddress 251 if (rva >= section->VirtualAddress
252 && rva < section->VirtualAddress + real_size) 252 && rva < section->VirtualAddress + real_size)
@@ -259,7 +259,7 @@ rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header)
259/* Return pointer to section header for section containing the given 259/* Return pointer to section header for section containing the given
260 offset in its raw data area. */ 260 offset in its raw data area. */
261IMAGE_SECTION_HEADER * 261IMAGE_SECTION_HEADER *
262offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header) 262offset_to_section (DWORD_PTR offset, IMAGE_NT_HEADERS * nt_header)
263{ 263{
264 PIMAGE_SECTION_HEADER section; 264 PIMAGE_SECTION_HEADER section;
265 int i; 265 int i;
@@ -279,8 +279,8 @@ offset_to_section (DWORD offset, IMAGE_NT_HEADERS * nt_header)
279/* Return offset to an object in dst, given offset in src. We assume 279/* Return offset to an object in dst, given offset in src. We assume
280 there is at least one section in both src and dst images, and that 280 there is at least one section in both src and dst images, and that
281 the some sections may have been added to dst (after sections in src). */ 281 the some sections may have been added to dst (after sections in src). */
282DWORD 282DWORD_PTR
283relocate_offset (DWORD offset, 283relocate_offset (DWORD_PTR offset,
284 IMAGE_NT_HEADERS * src_nt_header, 284 IMAGE_NT_HEADERS * src_nt_header,
285 IMAGE_NT_HEADERS * dst_nt_header) 285 IMAGE_NT_HEADERS * dst_nt_header)
286{ 286{
@@ -314,25 +314,25 @@ relocate_offset (DWORD offset,
314} 314}
315 315
316#define OFFSET_TO_RVA(offset, section) \ 316#define OFFSET_TO_RVA(offset, section) \
317 (section->VirtualAddress + ((DWORD)(offset) - section->PointerToRawData)) 317 ((section)->VirtualAddress + ((DWORD_PTR)(offset) - (section)->PointerToRawData))
318 318
319#define RVA_TO_OFFSET(rva, section) \ 319#define RVA_TO_OFFSET(rva, section) \
320 (section->PointerToRawData + ((DWORD)(rva) - section->VirtualAddress)) 320 ((section)->PointerToRawData + ((DWORD_PTR)(rva) - (section)->VirtualAddress))
321 321
322#define RVA_TO_SECTION_OFFSET(rva, section) \ 322#define RVA_TO_SECTION_OFFSET(rva, section) \
323 ((DWORD)(rva) - section->VirtualAddress) 323 ((DWORD_PTR)(rva) - (section)->VirtualAddress)
324 324
325/* Convert address in executing image to RVA. */ 325/* Convert address in executing image to RVA. */
326#define PTR_TO_RVA(ptr) ((DWORD)(ptr) - (DWORD) GetModuleHandle (NULL)) 326#define PTR_TO_RVA(ptr) ((DWORD_PTR)(ptr) - (DWORD_PTR) GetModuleHandle (NULL))
327 327
328#define RVA_TO_PTR(var,section,filedata) \ 328#define RVA_TO_PTR(var,section,filedata) \
329 ((void *)(RVA_TO_OFFSET (var,section) + (filedata).file_base)) 329 ((unsigned char *)(RVA_TO_OFFSET (var,section) + (filedata).file_base))
330 330
331#define PTR_TO_OFFSET(ptr, pfile_data) \ 331#define PTR_TO_OFFSET(ptr, pfile_data) \
332 ((unsigned char *)(ptr) - (pfile_data)->file_base) 332 ((unsigned char *)(ptr) - (pfile_data)->file_base)
333 333
334#define OFFSET_TO_PTR(offset, pfile_data) \ 334#define OFFSET_TO_PTR(offset, pfile_data) \
335 ((pfile_data)->file_base + (DWORD)(offset)) 335 ((pfile_data)->file_base + (DWORD_PTR)(offset))
336 336
337 337
338/* Flip through the executable and cache the info necessary for dumping. */ 338/* Flip through the executable and cache the info necessary for dumping. */
@@ -349,7 +349,7 @@ get_section_info (file_data *p_infile)
349 printf ("Unknown EXE header in %s...bailing.\n", p_infile->name); 349 printf ("Unknown EXE header in %s...bailing.\n", p_infile->name);
350 exit (1); 350 exit (1);
351 } 351 }
352 nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) + 352 nt_header = (PIMAGE_NT_HEADERS) (((DWORD_PTR) dos_header) +
353 dos_header->e_lfanew); 353 dos_header->e_lfanew);
354 if (nt_header == NULL) 354 if (nt_header == NULL)
355 { 355 {
@@ -488,7 +488,7 @@ copy_executable_and_dump_data (file_data *p_infile,
488 PIMAGE_NT_HEADERS dst_nt_header; 488 PIMAGE_NT_HEADERS dst_nt_header;
489 PIMAGE_SECTION_HEADER section; 489 PIMAGE_SECTION_HEADER section;
490 PIMAGE_SECTION_HEADER dst_section; 490 PIMAGE_SECTION_HEADER dst_section;
491 DWORD offset; 491 DWORD_PTR offset;
492 int i; 492 int i;
493 int be_verbose = GetEnvironmentVariable ("DEBUG_DUMP", NULL, 0) > 0; 493 int be_verbose = GetEnvironmentVariable ("DEBUG_DUMP", NULL, 0) > 0;
494 494
@@ -541,17 +541,17 @@ copy_executable_and_dump_data (file_data *p_infile,
541 Note that dst is updated implicitly by each COPY_CHUNK. */ 541 Note that dst is updated implicitly by each COPY_CHUNK. */
542 542
543 dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base; 543 dos_header = (PIMAGE_DOS_HEADER) p_infile->file_base;
544 nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) + 544 nt_header = (PIMAGE_NT_HEADERS) (((DWORD_PTR) dos_header) +
545 dos_header->e_lfanew); 545 dos_header->e_lfanew);
546 section = IMAGE_FIRST_SECTION (nt_header); 546 section = IMAGE_FIRST_SECTION (nt_header);
547 547
548 dst = (unsigned char *) p_outfile->file_base; 548 dst = (unsigned char *) p_outfile->file_base;
549 549
550 COPY_CHUNK ("Copying DOS header...", dos_header, 550 COPY_CHUNK ("Copying DOS header...", dos_header,
551 (DWORD) nt_header - (DWORD) dos_header, be_verbose); 551 (DWORD_PTR) nt_header - (DWORD_PTR) dos_header, be_verbose);
552 dst_nt_header = (PIMAGE_NT_HEADERS) dst; 552 dst_nt_header = (PIMAGE_NT_HEADERS) dst;
553 COPY_CHUNK ("Copying NT header...", nt_header, 553 COPY_CHUNK ("Copying NT header...", nt_header,
554 (DWORD) section - (DWORD) nt_header, be_verbose); 554 (DWORD_PTR) section - (DWORD_PTR) nt_header, be_verbose);
555 dst_section = (PIMAGE_SECTION_HEADER) dst; 555 dst_section = (PIMAGE_SECTION_HEADER) dst;
556 COPY_CHUNK ("Copying section table...", section, 556 COPY_CHUNK ("Copying section table...", section,
557 nt_header->FileHeader.NumberOfSections * sizeof (*section), 557 nt_header->FileHeader.NumberOfSections * sizeof (*section),
@@ -627,8 +627,8 @@ copy_executable_and_dump_data (file_data *p_infile,
627 } 627 }
628 if (section == heap_section) 628 if (section == heap_section)
629 { 629 {
630 DWORD heap_start = (DWORD) get_heap_start (); 630 DWORD_PTR heap_start = (DWORD_PTR) get_heap_start ();
631 DWORD heap_size = get_committed_heap_size (); 631 DWORD_PTR heap_size = get_committed_heap_size ();
632 632
633 /* Dump the used portion of the predump heap, adjusting the 633 /* Dump the used portion of the predump heap, adjusting the
634 section's size to the appropriate size. */ 634 section's size to the appropriate size. */
diff --git a/src/vm-limit.c b/src/vm-limit.c
index 8de0acd1bb2..3020b84858a 100644
--- a/src/vm-limit.c
+++ b/src/vm-limit.c
@@ -41,7 +41,7 @@ static void (*warn_function) (const char *);
41static POINTER data_space_start; 41static POINTER data_space_start;
42 42
43/* Number of bytes of writable memory we can expect to be able to get. */ 43/* Number of bytes of writable memory we can expect to be able to get. */
44static unsigned long lim_data; 44static size_t lim_data;
45 45
46 46
47#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_AS) 47#if defined (HAVE_GETRLIMIT) && defined (RLIMIT_AS)
@@ -88,7 +88,7 @@ get_lim_data (void)
88static void 88static void
89get_lim_data (void) 89get_lim_data (void)
90{ 90{
91 extern unsigned long reserved_heap_size; 91 extern size_t reserved_heap_size;
92 lim_data = reserved_heap_size; 92 lim_data = reserved_heap_size;
93} 93}
94 94
@@ -166,13 +166,13 @@ static void
166check_memory_limits (void) 166check_memory_limits (void)
167{ 167{
168#ifdef REL_ALLOC 168#ifdef REL_ALLOC
169 extern POINTER (*real_morecore) (long); 169 extern POINTER (*real_morecore) (ptrdiff_t);
170#endif 170#endif
171 extern POINTER (*__morecore) (long); 171 extern POINTER (*__morecore) (ptrdiff_t);
172 172
173 register POINTER cp; 173 register POINTER cp;
174 unsigned long five_percent; 174 size_t five_percent;
175 unsigned long data_size; 175 size_t data_size;
176 enum warnlevel new_warnlevel; 176 enum warnlevel new_warnlevel;
177 177
178 if (lim_data == 0) 178 if (lim_data == 0)
diff --git a/src/w32.c b/src/w32.c
index 3154c725abf..3d3ae7eebc3 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -1528,52 +1528,6 @@ is_unc_volume (const char *filename)
1528 return 1; 1528 return 1;
1529} 1529}
1530 1530
1531/* Routines that are no-ops on NT but are defined to get Emacs to compile. */
1532int
1533sigemptyset (sigset_t *set)
1534{
1535 *set = 0;
1536 return 0;
1537}
1538
1539int
1540sigaddset (sigset_t *set, int signo)
1541{
1542 return 0;
1543}
1544
1545int
1546sigfillset (sigset_t *set)
1547{
1548 return 0;
1549}
1550
1551int
1552sigprocmask (int how, const sigset_t *set, sigset_t *oset)
1553{
1554 return 0;
1555}
1556
1557int
1558pthread_sigmask (int how, const sigset_t *set, sigset_t *oset)
1559{
1560 if (sigprocmask (how, set, oset) == -1)
1561 return EINVAL;
1562 return 0;
1563}
1564
1565int
1566setpgrp (int pid, int gid)
1567{
1568 return 0;
1569}
1570
1571int
1572alarm (int seconds)
1573{
1574 return 0;
1575}
1576
1577#define REG_ROOT "SOFTWARE\\GNU\\Emacs" 1531#define REG_ROOT "SOFTWARE\\GNU\\Emacs"
1578 1532
1579LPBYTE 1533LPBYTE
@@ -1784,7 +1738,8 @@ init_environment (char ** argv)
1784 /* FIXME: should use substring of get_emacs_configuration (). 1738 /* FIXME: should use substring of get_emacs_configuration ().
1785 But I don't think the Windows build supports alpha, mips etc 1739 But I don't think the Windows build supports alpha, mips etc
1786 anymore, so have taken the easy option for now. */ 1740 anymore, so have taken the easy option for now. */
1787 else if (p && xstrcasecmp (p, "\\i386") == 0) 1741 else if (p && (xstrcasecmp (p, "\\i386") == 0
1742 || xstrcasecmp (p, "\\AMD64") == 0))
1788 { 1743 {
1789 *p = 0; 1744 *p = 0;
1790 p = strrchr (modname, '\\'); 1745 p = strrchr (modname, '\\');
@@ -1932,7 +1887,16 @@ get_emacs_configuration (void)
1932 case PROCESSOR_INTEL_386: 1887 case PROCESSOR_INTEL_386:
1933 case PROCESSOR_INTEL_486: 1888 case PROCESSOR_INTEL_486:
1934 case PROCESSOR_INTEL_PENTIUM: 1889 case PROCESSOR_INTEL_PENTIUM:
1890#ifdef _WIN64
1891 arch = "amd64";
1892#else
1935 arch = "i386"; 1893 arch = "i386";
1894#endif
1895 break;
1896#endif
1897#ifdef PROCESSOR_AMD_X8664
1898 case PROCESSOR_AMD_X8664:
1899 arch = "amd64";
1936 break; 1900 break;
1937#endif 1901#endif
1938 1902
@@ -6623,6 +6587,9 @@ void
6623term_ntproc (int ignored) 6587term_ntproc (int ignored)
6624{ 6588{
6625 (void)ignored; 6589 (void)ignored;
6590
6591 term_timers ();
6592
6626 /* shutdown the socket interface if necessary */ 6593 /* shutdown the socket interface if necessary */
6627 term_winsock (); 6594 term_winsock ();
6628 6595
@@ -6632,6 +6599,8 @@ term_ntproc (int ignored)
6632void 6599void
6633init_ntproc (int dumping) 6600init_ntproc (int dumping)
6634{ 6601{
6602 sigset_t initial_mask = 0;
6603
6635 /* Initialize the socket interface now if available and requested by 6604 /* Initialize the socket interface now if available and requested by
6636 the user by defining PRELOAD_WINSOCK; otherwise loading will be 6605 the user by defining PRELOAD_WINSOCK; otherwise loading will be
6637 delayed until open-network-stream is called (w32-has-winsock can 6606 delayed until open-network-stream is called (w32-has-winsock can
@@ -6687,19 +6656,19 @@ init_ntproc (int dumping)
6687 fclose (stderr); 6656 fclose (stderr);
6688 6657
6689 if (stdin_save != INVALID_HANDLE_VALUE) 6658 if (stdin_save != INVALID_HANDLE_VALUE)
6690 _open_osfhandle ((long) stdin_save, O_TEXT); 6659 _open_osfhandle ((intptr_t) stdin_save, O_TEXT);
6691 else 6660 else
6692 _open ("nul", O_TEXT | O_NOINHERIT | O_RDONLY); 6661 _open ("nul", O_TEXT | O_NOINHERIT | O_RDONLY);
6693 _fdopen (0, "r"); 6662 _fdopen (0, "r");
6694 6663
6695 if (stdout_save != INVALID_HANDLE_VALUE) 6664 if (stdout_save != INVALID_HANDLE_VALUE)
6696 _open_osfhandle ((long) stdout_save, O_TEXT); 6665 _open_osfhandle ((intptr_t) stdout_save, O_TEXT);
6697 else 6666 else
6698 _open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY); 6667 _open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY);
6699 _fdopen (1, "w"); 6668 _fdopen (1, "w");
6700 6669
6701 if (stderr_save != INVALID_HANDLE_VALUE) 6670 if (stderr_save != INVALID_HANDLE_VALUE)
6702 _open_osfhandle ((long) stderr_save, O_TEXT); 6671 _open_osfhandle ((intptr_t) stderr_save, O_TEXT);
6703 else 6672 else
6704 _open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY); 6673 _open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY);
6705 _fdopen (2, "w"); 6674 _fdopen (2, "w");
@@ -6708,7 +6677,12 @@ init_ntproc (int dumping)
6708 /* unfortunately, atexit depends on implementation of malloc */ 6677 /* unfortunately, atexit depends on implementation of malloc */
6709 /* atexit (term_ntproc); */ 6678 /* atexit (term_ntproc); */
6710 if (!dumping) 6679 if (!dumping)
6711 signal (SIGABRT, term_ntproc); 6680 {
6681 /* Make sure we start with all signals unblocked. */
6682 sigprocmask (SIG_SETMASK, &initial_mask, NULL);
6683 signal (SIGABRT, term_ntproc);
6684 }
6685 init_timers ();
6712 6686
6713 /* determine which drives are fixed, for GetCachedVolumeInformation */ 6687 /* determine which drives are fixed, for GetCachedVolumeInformation */
6714 { 6688 {
@@ -6815,7 +6789,7 @@ serial_open (char *port)
6815 OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); 6789 OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
6816 if (hnd == INVALID_HANDLE_VALUE) 6790 if (hnd == INVALID_HANDLE_VALUE)
6817 error ("Could not open %s", port); 6791 error ("Could not open %s", port);
6818 fd = (int) _open_osfhandle ((int) hnd, 0); 6792 fd = (int) _open_osfhandle ((intptr_t) hnd, 0);
6819 if (fd == -1) 6793 if (fd == -1)
6820 error ("Could not open %s", port); 6794 error ("Could not open %s", port);
6821 6795
diff --git a/src/w32.h b/src/w32.h
index a833c8f4315..2e2315e245d 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -142,6 +142,9 @@ extern void syms_of_fontset (void);
142extern void syms_of_w32font (void); 142extern void syms_of_w32font (void);
143extern void check_windows_init_file (void); 143extern void check_windows_init_file (void);
144 144
145extern void term_timers (void);
146extern void init_timers (void);
147
145extern int _sys_read_ahead (int fd); 148extern int _sys_read_ahead (int fd);
146extern int _sys_wait_accept (int fd); 149extern int _sys_wait_accept (int fd);
147 150
diff --git a/src/w32fns.c b/src/w32fns.c
index 808e19d0b66..6d5d6822354 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -79,9 +79,7 @@ extern void w32_menu_display_help (HWND, HMENU, UINT, UINT);
79extern void w32_free_menu_strings (HWND); 79extern void w32_free_menu_strings (HWND);
80extern const char *map_w32_filename (const char *, const char **); 80extern const char *map_w32_filename (const char *, const char **);
81 81
82/* If non-zero, a w32 timer that, when it expires, displays an 82/* If non-NULL, a handle to a frame where to display the hourglass cursor. */
83 hourglass cursor on all frames. */
84static unsigned hourglass_timer = 0;
85static HWND hourglass_hwnd = NULL; 83static HWND hourglass_hwnd = NULL;
86 84
87#ifndef IDC_HAND 85#ifndef IDC_HAND
@@ -139,7 +137,7 @@ struct MONITOR_INFO
139}; 137};
140 138
141/* Reportedly, MSVC does not have this in its headers. */ 139/* Reportedly, MSVC does not have this in its headers. */
142#ifdef _MSC_VER 140#if defined (_MSC_VER) && _WIN32_WINNT < 0x0500
143DECLARE_HANDLE(HMONITOR); 141DECLARE_HANDLE(HMONITOR);
144#endif 142#endif
145 143
@@ -175,7 +173,6 @@ unsigned int msh_mousewheel = 0;
175#define MOUSE_BUTTON_ID 1 173#define MOUSE_BUTTON_ID 1
176#define MOUSE_MOVE_ID 2 174#define MOUSE_MOVE_ID 2
177#define MENU_FREE_ID 3 175#define MENU_FREE_ID 3
178#define HOURGLASS_ID 4
179/* The delay (milliseconds) before a menu is freed after WM_EXITMENULOOP 176/* The delay (milliseconds) before a menu is freed after WM_EXITMENULOOP
180 is received. */ 177 is received. */
181#define MENU_FREE_DELAY 1000 178#define MENU_FREE_DELAY 1000
@@ -2255,7 +2252,7 @@ static void
2255w32_msg_pump (deferred_msg * msg_buf) 2252w32_msg_pump (deferred_msg * msg_buf)
2256{ 2253{
2257 MSG msg; 2254 MSG msg;
2258 int result; 2255 WPARAM result;
2259 HWND focus_window; 2256 HWND focus_window;
2260 2257
2261 msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL); 2258 msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL);
@@ -2286,7 +2283,7 @@ w32_msg_pump (deferred_msg * msg_buf)
2286 /* Reply is not expected. */ 2283 /* Reply is not expected. */
2287 break; 2284 break;
2288 case WM_EMACS_SETKEYBOARDLAYOUT: 2285 case WM_EMACS_SETKEYBOARDLAYOUT:
2289 result = (int) ActivateKeyboardLayout ((HKL) msg.wParam, 0); 2286 result = (WPARAM) ActivateKeyboardLayout ((HKL) msg.wParam, 0);
2290 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 2287 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE,
2291 result, 0)) 2288 result, 0))
2292 emacs_abort (); 2289 emacs_abort ();
@@ -3313,12 +3310,6 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3313 menubar_in_use = 0; 3310 menubar_in_use = 0;
3314 } 3311 }
3315 } 3312 }
3316 else if (wParam == hourglass_timer)
3317 {
3318 KillTimer (hwnd, hourglass_timer);
3319 hourglass_timer = 0;
3320 w32_show_hourglass (x_window_to_frame (dpyinfo, hwnd));
3321 }
3322 return 0; 3313 return 0;
3323 3314
3324 case WM_NCACTIVATE: 3315 case WM_NCACTIVATE:
@@ -5040,66 +5031,50 @@ no value of TYPE (always string in the MS Windows case). */)
5040 Busy cursor 5031 Busy cursor
5041 ***********************************************************************/ 5032 ***********************************************************************/
5042 5033
5043/* Default number of seconds to wait before displaying an hourglass
5044 cursor. Duplicated from xdisp.c, but cannot use the version there
5045 due to lack of atimers on w32. */
5046#define DEFAULT_HOURGLASS_DELAY 1
5047
5048/* Cancel a currently active hourglass timer, and start a new one. */
5049
5050void 5034void
5051start_hourglass (void) 5035w32_note_current_window (void)
5052{ 5036{
5053 DWORD delay;
5054 int secs, msecs = 0;
5055 struct frame * f = SELECTED_FRAME (); 5037 struct frame * f = SELECTED_FRAME ();
5056 5038
5057 /* No cursors on non GUI frames. */
5058 if (!FRAME_W32_P (f)) 5039 if (!FRAME_W32_P (f))
5059 return; 5040 return;
5060 5041
5061 cancel_hourglass ();
5062
5063 if (INTEGERP (Vhourglass_delay)
5064 && XINT (Vhourglass_delay) > 0)
5065 secs = XFASTINT (Vhourglass_delay);
5066 else if (FLOATP (Vhourglass_delay)
5067 && XFLOAT_DATA (Vhourglass_delay) > 0)
5068 {
5069 Lisp_Object tem;
5070 tem = Ftruncate (Vhourglass_delay, Qnil);
5071 secs = XFASTINT (tem);
5072 msecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000;
5073 }
5074 else
5075 secs = DEFAULT_HOURGLASS_DELAY;
5076
5077 delay = secs * 1000 + msecs;
5078 hourglass_hwnd = FRAME_W32_WINDOW (f); 5042 hourglass_hwnd = FRAME_W32_WINDOW (f);
5079 hourglass_timer = SetTimer (hourglass_hwnd, HOURGLASS_ID, delay, NULL);
5080} 5043}
5081 5044
5082
5083/* Cancel the hourglass cursor timer if active, hide an hourglass
5084 cursor if shown. */
5085
5086void 5045void
5087cancel_hourglass (void) 5046show_hourglass (struct atimer *timer)
5088{ 5047{
5089 if (hourglass_timer) 5048 struct frame *f;
5090 {
5091 KillTimer (hourglass_hwnd, hourglass_timer);
5092 hourglass_timer = 0;
5093 }
5094 5049
5095 if (hourglass_shown_p) 5050 hourglass_atimer = NULL;
5096 w32_hide_hourglass (); 5051
5052 block_input ();
5053 f = x_window_to_frame (&one_w32_display_info,
5054 hourglass_hwnd);
5055
5056 if (f)
5057 f->output_data.w32->hourglass_p = 0;
5058 else
5059 f = SELECTED_FRAME ();
5060
5061 if (!FRAME_W32_P (f))
5062 return;
5063
5064 w32_show_hourglass (f);
5065 unblock_input ();
5097} 5066}
5098 5067
5068void
5069hide_hourglass (void)
5070{
5071 block_input ();
5072 w32_hide_hourglass ();
5073 unblock_input ();
5074}
5099 5075
5100/* Timer function of hourglass_timer.
5101 5076
5102 Display an hourglass cursor. Set the hourglass_p flag in display info 5077/* Display an hourglass cursor. Set the hourglass_p flag in display info
5103 to indicate that an hourglass cursor is shown. */ 5078 to indicate that an hourglass cursor is shown. */
5104 5079
5105static void 5080static void
@@ -5945,7 +5920,7 @@ Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
5945selection box, if specified. If MUSTMATCH is non-nil, the returned file 5920selection box, if specified. If MUSTMATCH is non-nil, the returned file
5946or directory must exist. 5921or directory must exist.
5947 5922
5948This function is only defined on MS Windows, and X Windows with the 5923This function is only defined on NS, MS Windows, and X Windows with the
5949Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored. 5924Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
5950Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) 5925Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5951 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) 5926 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
@@ -7123,8 +7098,6 @@ only be necessary if the default setting causes problems. */);
7123 7098
7124 check_window_system_func = check_w32; 7099 check_window_system_func = check_w32;
7125 7100
7126
7127 hourglass_timer = 0;
7128 hourglass_hwnd = NULL; 7101 hourglass_hwnd = NULL;
7129 7102
7130 defsubr (&Sx_show_tip); 7103 defsubr (&Sx_show_tip);
diff --git a/src/w32heap.c b/src/w32heap.c
index dc65198f90b..8b9b19ea35d 100644
--- a/src/w32heap.c
+++ b/src/w32heap.c
@@ -26,7 +26,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#include "w32heap.h" 26#include "w32heap.h"
27#include "lisp.h" /* for VALMASK */ 27#include "lisp.h" /* for VALMASK */
28 28
29#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD)(rva) + (DWORD)GetModuleHandle (NULL))) 29#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD_PTR)(rva) + (DWORD_PTR)GetModuleHandle (NULL)))
30 30
31/* This gives us the page size and the size of the allocation unit on NT. */ 31/* This gives us the page size and the size of the allocation unit on NT. */
32SYSTEM_INFO sysinfo_cache; 32SYSTEM_INFO sysinfo_cache;
@@ -34,7 +34,7 @@ SYSTEM_INFO sysinfo_cache;
34/* This gives us version, build, and platform identification. */ 34/* This gives us version, build, and platform identification. */
35OSVERSIONINFO osinfo_cache; 35OSVERSIONINFO osinfo_cache;
36 36
37unsigned long syspage_mask = 0; 37size_t syspage_mask = 0;
38 38
39/* The major and minor versions of NT. */ 39/* The major and minor versions of NT. */
40int w32_major_version; 40int w32_major_version;
@@ -97,7 +97,7 @@ PIMAGE_SECTION_HEADER preload_heap_section;
97unsigned char *data_region_base = NULL; 97unsigned char *data_region_base = NULL;
98unsigned char *data_region_end = NULL; 98unsigned char *data_region_end = NULL;
99unsigned char *real_data_region_end = NULL; 99unsigned char *real_data_region_end = NULL;
100unsigned long reserved_heap_size = 0; 100size_t reserved_heap_size = 0;
101 101
102/* The start of the data segment. */ 102/* The start of the data segment. */
103unsigned char * 103unsigned char *
@@ -121,16 +121,20 @@ allocate_heap (void)
121 the preload heap section up to the usable address limit. Since GNU 121 the preload heap section up to the usable address limit. Since GNU
122 malloc can handle gaps in the memory it gets from sbrk, we can 122 malloc can handle gaps in the memory it gets from sbrk, we can
123 simply set the sbrk pointer to the base of the new heap region. */ 123 simply set the sbrk pointer to the base of the new heap region. */
124 unsigned long base = 124 DWORD_PTR base =
125 ROUND_UP ((RVA_TO_PTR (preload_heap_section->VirtualAddress) 125 ROUND_UP ((RVA_TO_PTR (preload_heap_section->VirtualAddress)
126 + preload_heap_section->Misc.VirtualSize), 126 + preload_heap_section->Misc.VirtualSize),
127 get_allocation_unit ()); 127 get_allocation_unit ());
128 unsigned long end = 1 << VALBITS; /* 256MB */ 128 DWORD_PTR end = ((unsigned __int64)1) << VALBITS; /* 256MB */
129 void *ptr = NULL; 129 void *ptr = NULL;
130 130
131 while (!ptr && (base < end)) 131 while (!ptr && (base < end))
132 { 132 {
133#ifdef _WIN64
134 reserved_heap_size = min(end - base, 0x4000000000i64); /* Limit to 256Gb */
135#else
133 reserved_heap_size = end - base; 136 reserved_heap_size = end - base;
137#endif
134 ptr = VirtualAlloc ((void *) base, 138 ptr = VirtualAlloc ((void *) base,
135 get_reserved_heap_size (), 139 get_reserved_heap_size (),
136 MEM_RESERVE, 140 MEM_RESERVE,
@@ -144,7 +148,11 @@ allocate_heap (void)
144static char * 148static char *
145allocate_heap (void) 149allocate_heap (void)
146{ 150{
147 unsigned long size = 0x80000000; /* start by asking for 2GB */ 151#ifdef _WIN64
152 size_t size = 0x4000000000i64; /* start by asking for 32GB */
153#else
154 size_t size = 0x80000000; /* start by asking for 2GB */
155#endif
148 void *ptr = NULL; 156 void *ptr = NULL;
149 157
150 while (!ptr && size > 0x00100000) 158 while (!ptr && size > 0x00100000)
@@ -166,17 +174,17 @@ allocate_heap (void)
166 be the address of the _start_ (not end) of the new block in case of 174 be the address of the _start_ (not end) of the new block in case of
167 success, and zero (not -1) in case of failure. */ 175 success, and zero (not -1) in case of failure. */
168void * 176void *
169sbrk (unsigned long increment) 177sbrk (ptrdiff_t increment)
170{ 178{
171 void *result; 179 void *result;
172 long size = (long) increment; 180 ptrdiff_t size = increment;
173 181
174 result = data_region_end; 182 result = data_region_end;
175 183
176 /* If size is negative, shrink the heap by decommitting pages. */ 184 /* If size is negative, shrink the heap by decommitting pages. */
177 if (size < 0) 185 if (size < 0)
178 { 186 {
179 int new_size; 187 ptrdiff_t new_size;
180 unsigned char *new_data_region_end; 188 unsigned char *new_data_region_end;
181 189
182 size = -size; 190 size = -size;
@@ -189,7 +197,7 @@ sbrk (unsigned long increment)
189 partial deallocation [cga]. */ 197 partial deallocation [cga]. */
190 new_data_region_end = (data_region_end - size); 198 new_data_region_end = (data_region_end - size);
191 new_data_region_end = (unsigned char *) 199 new_data_region_end = (unsigned char *)
192 ((long) (new_data_region_end + syspage_mask) & ~syspage_mask); 200 ((DWORD_PTR) (new_data_region_end + syspage_mask) & ~syspage_mask);
193 new_size = real_data_region_end - new_data_region_end; 201 new_size = real_data_region_end - new_data_region_end;
194 real_data_region_end = new_data_region_end; 202 real_data_region_end = new_data_region_end;
195 if (new_size > 0) 203 if (new_size > 0)
@@ -220,7 +228,7 @@ sbrk (unsigned long increment)
220 /* We really only commit full pages, so record where 228 /* We really only commit full pages, so record where
221 the real end of committed memory is [cga]. */ 229 the real end of committed memory is [cga]. */
222 real_data_region_end = (unsigned char *) 230 real_data_region_end = (unsigned char *)
223 ((long) (data_region_end + syspage_mask) & ~syspage_mask); 231 ((DWORD_PTR) (data_region_end + syspage_mask) & ~syspage_mask);
224 } 232 }
225 233
226 return result; 234 return result;
@@ -245,7 +253,7 @@ init_heap (void)
245 PIMAGE_NT_HEADERS nt_header; 253 PIMAGE_NT_HEADERS nt_header;
246 254
247 dos_header = (PIMAGE_DOS_HEADER) RVA_TO_PTR (0); 255 dos_header = (PIMAGE_DOS_HEADER) RVA_TO_PTR (0);
248 nt_header = (PIMAGE_NT_HEADERS) (((unsigned long) dos_header) + 256 nt_header = (PIMAGE_NT_HEADERS) (((DWORD_PTR) dos_header) +
249 dos_header->e_lfanew); 257 dos_header->e_lfanew);
250 preload_heap_section = find_section ("EMHEAP", nt_header); 258 preload_heap_section = find_section ("EMHEAP", nt_header);
251 259
@@ -261,7 +269,7 @@ init_heap (void)
261#if !USE_LSB_TAG 269#if !USE_LSB_TAG
262 /* Ensure that the addresses don't use the upper tag bits since 270 /* Ensure that the addresses don't use the upper tag bits since
263 the Lisp type goes there. */ 271 the Lisp type goes there. */
264 if (((unsigned long) data_region_base & ~VALMASK) != 0) 272 if (((DWORD_PTR) data_region_base & ~VALMASK) != 0)
265 { 273 {
266 printf ("Error: The heap was allocated in upper memory.\n"); 274 printf ("Error: The heap was allocated in upper memory.\n");
267 exit (1); 275 exit (1);
@@ -284,13 +292,13 @@ init_heap (void)
284 292
285/* Round the heap up to the given alignment. */ 293/* Round the heap up to the given alignment. */
286void 294void
287round_heap (unsigned long align) 295round_heap (size_t align)
288{ 296{
289 unsigned long needs_to_be; 297 DWORD_PTR needs_to_be;
290 unsigned long need_to_alloc; 298 DWORD_PTR need_to_alloc;
291 299
292 needs_to_be = (unsigned long) ROUND_UP (get_heap_end (), align); 300 needs_to_be = (DWORD_PTR) ROUND_UP (get_heap_end (), align);
293 need_to_alloc = needs_to_be - (unsigned long) get_heap_end (); 301 need_to_alloc = needs_to_be - (DWORD_PTR) get_heap_end ();
294 302
295 if (need_to_alloc) 303 if (need_to_alloc)
296 sbrk (need_to_alloc); 304 sbrk (need_to_alloc);
diff --git a/src/w32heap.h b/src/w32heap.h
index fda3c58bf01..aae4845b4cc 100644
--- a/src/w32heap.h
+++ b/src/w32heap.h
@@ -24,8 +24,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 24
25#include <windows.h> 25#include <windows.h>
26 26
27#define ROUND_UP(p, align) (((DWORD)(p) + (align)-1) & ~((align)-1)) 27#define ROUND_UP(p, align) (((DWORD_PTR)(p) + (align)-1) & ~((DWORD_PTR)(align)-1))
28#define ROUND_DOWN(p, align) ((DWORD)(p) & ~((align)-1)) 28#define ROUND_DOWN(p, align) ((DWORD_PTR)(p) & ~((DWORD_PTR)(align)-1))
29 29
30/* 30/*
31 * Heap related stuff. 31 * Heap related stuff.
@@ -42,7 +42,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
42 42
43extern unsigned char *get_data_start (void); 43extern unsigned char *get_data_start (void);
44extern unsigned char *get_data_end (void); 44extern unsigned char *get_data_end (void);
45extern unsigned long reserved_heap_size; 45extern size_t reserved_heap_size;
46extern SYSTEM_INFO sysinfo_cache; 46extern SYSTEM_INFO sysinfo_cache;
47extern OSVERSIONINFO osinfo_cache; 47extern OSVERSIONINFO osinfo_cache;
48extern BOOL using_dynamic_heap; 48extern BOOL using_dynamic_heap;
@@ -58,13 +58,13 @@ enum {
58extern int os_subtype; 58extern int os_subtype;
59 59
60/* Emulation of Unix sbrk(). */ 60/* Emulation of Unix sbrk(). */
61extern void *sbrk (unsigned long size); 61extern void *sbrk (ptrdiff_t size);
62 62
63/* Initialize heap structures for sbrk on startup. */ 63/* Initialize heap structures for sbrk on startup. */
64extern void init_heap (void); 64extern void init_heap (void);
65 65
66/* Round the heap to this size. */ 66/* Round the heap to this size. */
67extern void round_heap (unsigned long size); 67extern void round_heap (size_t size);
68 68
69/* Cache system info, e.g., the NT page size. */ 69/* Cache system info, e.g., the NT page size. */
70extern void cache_system_info (void); 70extern void cache_system_info (void);
@@ -89,6 +89,6 @@ IMAGE_SECTION_HEADER * find_section (char * name, IMAGE_NT_HEADERS * nt_header);
89 89
90/* Return pointer to section header for section containing the given 90/* Return pointer to section header for section containing the given
91 relative virtual address. */ 91 relative virtual address. */
92IMAGE_SECTION_HEADER * rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header); 92IMAGE_SECTION_HEADER * rva_to_section (DWORD_PTR rva, IMAGE_NT_HEADERS * nt_header);
93 93
94#endif /* NTHEAP_H_ */ 94#endif /* NTHEAP_H_ */
diff --git a/src/w32menu.c b/src/w32menu.c
index fb1cb606940..0a10f1f0893 100644
--- a/src/w32menu.c
+++ b/src/w32menu.c
@@ -1483,8 +1483,8 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1483 1483
1484 utf8to16 (out_string, utf8_len, utf16_string); 1484 utf8to16 (out_string, utf8_len, utf16_string);
1485 return_value = unicode_append_menu (menu, fuFlags, 1485 return_value = unicode_append_menu (menu, fuFlags,
1486 item != NULL ? (UINT) item 1486 item != NULL ? (UINT_PTR) item
1487 : (UINT) wv->call_data, 1487 : (UINT_PTR) wv->call_data,
1488 utf16_string); 1488 utf16_string);
1489 if (!return_value) 1489 if (!return_value)
1490 { 1490 {
@@ -1496,7 +1496,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1496 of minor importance compared with menus not working at all. */ 1496 of minor importance compared with menus not working at all. */
1497 return_value = 1497 return_value =
1498 AppendMenu (menu, fuFlags, 1498 AppendMenu (menu, fuFlags,
1499 item != NULL ? (UINT) item: (UINT) wv->call_data, 1499 item != NULL ? (UINT_PTR) item: (UINT_PTR) wv->call_data,
1500 out_string); 1500 out_string);
1501 /* Don't use Unicode menus in future, unless this is Windows 1501 /* Don't use Unicode menus in future, unless this is Windows
1502 NT or later, where a failure of AppendMenuW does NOT mean 1502 NT or later, where a failure of AppendMenuW does NOT mean
@@ -1513,7 +1513,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1513 return_value = 1513 return_value =
1514 AppendMenu (menu, 1514 AppendMenu (menu,
1515 fuFlags, 1515 fuFlags,
1516 item != NULL ? (UINT) item : (UINT) wv->call_data, 1516 item != NULL ? (UINT_PTR) item : (UINT_PTR) wv->call_data,
1517 out_string ); 1517 out_string );
1518 } 1518 }
1519 1519
@@ -1550,7 +1550,7 @@ add_menu_item (HMENU menu, widget_value *wv, HMENU item)
1550 } 1550 }
1551 1551
1552 set_menu_item_info (menu, 1552 set_menu_item_info (menu,
1553 item != NULL ? (UINT) item : (UINT) wv->call_data, 1553 item != NULL ? (UINT_PTR) item : (UINT_PTR) wv->call_data,
1554 FALSE, &info); 1554 FALSE, &info);
1555 } 1555 }
1556 } 1556 }
diff --git a/src/w32proc.c b/src/w32proc.c
index b367b42d8c6..56a60fbf25f 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -62,7 +62,7 @@ extern BOOL WINAPI IsValidLocale (LCID, DWORD);
62 62
63#define RVA_TO_PTR(var,section,filedata) \ 63#define RVA_TO_PTR(var,section,filedata) \
64 ((void *)((section)->PointerToRawData \ 64 ((void *)((section)->PointerToRawData \
65 + ((DWORD)(var) - (section)->VirtualAddress) \ 65 + ((DWORD_PTR)(var) - (section)->VirtualAddress) \
66 + (filedata).file_base)) 66 + (filedata).file_base))
67 67
68Lisp_Object Qhigh, Qlow; 68Lisp_Object Qhigh, Qlow;
@@ -86,18 +86,23 @@ typedef void (_CALLBACK_ *signal_handler) (int);
86/* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */ 86/* Signal handlers...SIG_DFL == 0 so this is initialized correctly. */
87static signal_handler sig_handlers[NSIG]; 87static signal_handler sig_handlers[NSIG];
88 88
89static sigset_t sig_mask;
90
91static CRITICAL_SECTION crit_sig;
92
89/* Improve on the CRT 'signal' implementation so that we could record 93/* Improve on the CRT 'signal' implementation so that we could record
90 the SIGCHLD handler. */ 94 the SIGCHLD handler and fake interval timers. */
91signal_handler 95signal_handler
92sys_signal (int sig, signal_handler handler) 96sys_signal (int sig, signal_handler handler)
93{ 97{
94 signal_handler old; 98 signal_handler old;
95 99
96 /* SIGCHLD is needed for supporting subprocesses, see sys_kill 100 /* SIGCHLD is needed for supporting subprocesses, see sys_kill
97 below. All the others are the only ones supported by the MS 101 below. SIGALRM and SIGPROF are used by setitimer. All the
98 runtime. */ 102 others are the only ones supported by the MS runtime. */
99 if (!(sig == SIGCHLD || sig == SIGSEGV || sig == SIGILL 103 if (!(sig == SIGCHLD || sig == SIGSEGV || sig == SIGILL
100 || sig == SIGFPE || sig == SIGABRT || sig == SIGTERM)) 104 || sig == SIGFPE || sig == SIGABRT || sig == SIGTERM
105 || sig == SIGALRM || sig == SIGPROF))
101 { 106 {
102 errno = EINVAL; 107 errno = EINVAL;
103 return SIG_ERR; 108 return SIG_ERR;
@@ -111,7 +116,7 @@ sys_signal (int sig, signal_handler handler)
111 if (!(sig == SIGABRT && old == term_ntproc)) 116 if (!(sig == SIGABRT && old == term_ntproc))
112 { 117 {
113 sig_handlers[sig] = handler; 118 sig_handlers[sig] = handler;
114 if (sig != SIGCHLD) 119 if (!(sig == SIGCHLD || sig == SIGALRM || sig == SIGPROF))
115 signal (sig, handler); 120 signal (sig, handler);
116 } 121 }
117 return old; 122 return old;
@@ -143,6 +148,540 @@ sigaction (int sig, const struct sigaction *act, struct sigaction *oact)
143 return retval; 148 return retval;
144} 149}
145 150
151/* Emulate signal sets and blocking of signals used by timers. */
152
153int
154sigemptyset (sigset_t *set)
155{
156 *set = 0;
157 return 0;
158}
159
160int
161sigaddset (sigset_t *set, int signo)
162{
163 if (!set)
164 {
165 errno = EINVAL;
166 return -1;
167 }
168 if (signo < 0 || signo >= NSIG)
169 {
170 errno = EINVAL;
171 return -1;
172 }
173
174 *set |= (1U << signo);
175
176 return 0;
177}
178
179int
180sigfillset (sigset_t *set)
181{
182 if (!set)
183 {
184 errno = EINVAL;
185 return -1;
186 }
187
188 *set = 0xFFFFFFFF;
189 return 0;
190}
191
192int
193sigprocmask (int how, const sigset_t *set, sigset_t *oset)
194{
195 if (!(how == SIG_BLOCK || how == SIG_UNBLOCK || how == SIG_SETMASK))
196 {
197 errno = EINVAL;
198 return -1;
199 }
200
201 if (oset)
202 *oset = sig_mask;
203
204 if (!set)
205 return 0;
206
207 switch (how)
208 {
209 case SIG_BLOCK:
210 sig_mask |= *set;
211 break;
212 case SIG_SETMASK:
213 sig_mask = *set;
214 break;
215 case SIG_UNBLOCK:
216 /* FIXME: Catch signals that are blocked and reissue them when
217 they are unblocked. Important for SIGALRM and SIGPROF only. */
218 sig_mask &= ~(*set);
219 break;
220 }
221
222 return 0;
223}
224
225int
226pthread_sigmask (int how, const sigset_t *set, sigset_t *oset)
227{
228 if (sigprocmask (how, set, oset) == -1)
229 return EINVAL;
230 return 0;
231}
232
233int
234sigismember (const sigset_t *set, int signo)
235{
236 if (signo < 0 || signo >= NSIG)
237 {
238 errno = EINVAL;
239 return -1;
240 }
241 if (signo > sizeof (*set) * BITS_PER_CHAR)
242 emacs_abort ();
243
244 return (*set & (1U << signo)) != 0;
245}
246
247int
248setpgrp (int pid, int gid)
249{
250 return 0;
251}
252
253/* Emulations of interval timers.
254
255 Limitations: only ITIMER_REAL and ITIMER_PROF are supported.
256
257 Implementation: a separate thread is started for each timer type,
258 the thread calls the appropriate signal handler when the timer
259 expires, after stopping the thread which installed the timer. */
260
261/* FIXME: clock_t counts overflow after 49 days, need to handle the
262 wrap-around. */
263struct itimer_data {
264 clock_t expire;
265 clock_t reload;
266 int terminate;
267 int type;
268 HANDLE caller_thread;
269 HANDLE timer_thread;
270};
271
272static clock_t ticks_now;
273static struct itimer_data real_itimer, prof_itimer;
274static clock_t clocks_min;
275/* If non-zero, itimers are disabled. Used during shutdown, when we
276 delete the critical sections used by the timer threads. */
277static int disable_itimers;
278
279static CRITICAL_SECTION crit_real, crit_prof;
280
281#define MAX_SINGLE_SLEEP 30
282
283static DWORD WINAPI
284timer_loop (LPVOID arg)
285{
286 struct itimer_data *itimer = (struct itimer_data *)arg;
287 int which = itimer->type;
288 int sig = (which == ITIMER_REAL) ? SIGALRM : SIGPROF;
289 CRITICAL_SECTION *crit = (which == ITIMER_REAL) ? &crit_real : &crit_prof;
290 const DWORD max_sleep = MAX_SINGLE_SLEEP * 1000 / CLOCKS_PER_SEC;
291 int new_count = 0;
292
293 while (1)
294 {
295 DWORD sleep_time;
296 signal_handler handler;
297 clock_t now, expire, reload;
298
299 /* Load new values if requested by setitimer. */
300 EnterCriticalSection (crit);
301 expire = itimer->expire;
302 reload = itimer->reload;
303 LeaveCriticalSection (crit);
304 if (itimer->terminate)
305 return 0;
306
307 if (itimer->expire == 0)
308 {
309 /* We are idle. */
310 Sleep (max_sleep);
311 continue;
312 }
313
314 expire = itimer->expire;
315 if (expire > (now = clock ()))
316 sleep_time = expire - now;
317 else
318 sleep_time = 0;
319 /* Don't sleep too long at a time, to be able to see the
320 termination flag without too long a delay. */
321 while (sleep_time > max_sleep)
322 {
323 if (itimer->terminate)
324 return 0;
325 Sleep (max_sleep);
326 expire = itimer->expire;
327 sleep_time = (expire > (now = clock ())) ? expire - now : 0;
328 }
329 if (itimer->terminate)
330 return 0;
331 if (sleep_time > 0)
332 {
333 Sleep (sleep_time * 1000 / CLOCKS_PER_SEC);
334 /* Always sleep past the expiration time, to make sure we
335 never call the handler _before_ the expiration time,
336 always slightly after it. Sleep(5) makes sure we don't
337 hog the CPU by calling 'clock' with high frequency, and
338 also let other threads work. */
339 while (clock () < expire)
340 Sleep (5);
341 }
342
343 if (itimer->expire == 0)
344 continue;
345
346 /* Time's up. */
347 handler = sig_handlers[sig];
348 if (!(handler == SIG_DFL || handler == SIG_IGN || handler == SIG_ERR)
349 /* FIXME: Don't ignore masked signals. Instead, record that
350 they happened and reissue them when the signal is
351 unblocked. */
352 && !sigismember (&sig_mask, sig)
353 /* Simulate masking of SIGALRM and SIGPROF when processing
354 fatal signals. */
355 && !fatal_error_in_progress
356 && itimer->caller_thread)
357 {
358 /* Simulate a signal delivered to the thread which installed
359 the timer, by suspending that thread while the handler
360 runs. */
361 DWORD result = SuspendThread (itimer->caller_thread);
362
363 if (result == (DWORD)-1)
364 return 2;
365
366 handler (sig);
367 ResumeThread (itimer->caller_thread);
368 }
369
370 if (itimer->expire == 0)
371 continue;
372
373 /* Update expiration time and loop. */
374 EnterCriticalSection (crit);
375 expire = itimer->expire;
376 reload = itimer->reload;
377 if (reload > 0)
378 {
379 now = clock ();
380 if (expire <= now)
381 {
382 clock_t lag = now - expire;
383
384 /* If we missed some opportunities (presumably while
385 sleeping or while the signal handler ran), skip
386 them. */
387 if (lag > reload)
388 expire = now - (lag % reload);
389
390 expire += reload;
391 }
392 }
393 else
394 expire = 0; /* become idle */
395 itimer->expire = expire;
396 LeaveCriticalSection (crit);
397 }
398 return 0;
399}
400
401static void
402stop_timer_thread (int which)
403{
404 struct itimer_data *itimer =
405 (which == ITIMER_REAL) ? &real_itimer : &prof_itimer;
406 int i;
407 DWORD exit_code = 255;
408 BOOL status, err;
409
410 /* Signal the thread that it should terminate. */
411 itimer->terminate = 1;
412
413 if (itimer->timer_thread == NULL)
414 return;
415
416 /* Wait for the timer thread to terminate voluntarily, then kill it
417 if it doesn't. This loop waits twice more than the maximum
418 amount of time a timer thread sleeps, see above. */
419 for (i = 0; i < MAX_SINGLE_SLEEP / 5; i++)
420 {
421 if (!((status = GetExitCodeThread (itimer->timer_thread, &exit_code))
422 && exit_code == STILL_ACTIVE))
423 break;
424 Sleep (10);
425 }
426 if ((status == FALSE && (err = GetLastError ()) == ERROR_INVALID_HANDLE)
427 || exit_code == STILL_ACTIVE)
428 {
429 if (!(status == FALSE && err == ERROR_INVALID_HANDLE))
430 TerminateThread (itimer->timer_thread, 0);
431 }
432
433 /* Clean up. */
434 CloseHandle (itimer->timer_thread);
435 itimer->timer_thread = NULL;
436 if (itimer->caller_thread)
437 {
438 CloseHandle (itimer->caller_thread);
439 itimer->caller_thread = NULL;
440 }
441}
442
443/* This is called at shutdown time from term_ntproc. */
444void
445term_timers (void)
446{
447 if (real_itimer.timer_thread)
448 stop_timer_thread (ITIMER_REAL);
449 if (prof_itimer.timer_thread)
450 stop_timer_thread (ITIMER_PROF);
451
452 /* We are going to delete the critical sections, so timers cannot
453 work after this. */
454 disable_itimers = 1;
455
456 DeleteCriticalSection (&crit_real);
457 DeleteCriticalSection (&crit_prof);
458 DeleteCriticalSection (&crit_sig);
459}
460
461/* This is called at initialization time from init_ntproc. */
462void
463init_timers (void)
464{
465 /* Make sure we start with zeroed out itimer structures, since
466 dumping may have left there traces of threads long dead. */
467 memset (&real_itimer, 0, sizeof real_itimer);
468 memset (&prof_itimer, 0, sizeof prof_itimer);
469
470 InitializeCriticalSection (&crit_real);
471 InitializeCriticalSection (&crit_prof);
472 InitializeCriticalSection (&crit_sig);
473
474 disable_itimers = 0;
475}
476
477static int
478start_timer_thread (int which)
479{
480 DWORD exit_code;
481 struct itimer_data *itimer =
482 (which == ITIMER_REAL) ? &real_itimer : &prof_itimer;
483
484 if (itimer->timer_thread
485 && GetExitCodeThread (itimer->timer_thread, &exit_code)
486 && exit_code == STILL_ACTIVE)
487 return 0;
488
489 /* Start a new thread. */
490 if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
491 GetCurrentProcess (), &itimer->caller_thread, 0,
492 FALSE, DUPLICATE_SAME_ACCESS))
493 {
494 errno = ESRCH;
495 return -1;
496 }
497
498 itimer->terminate = 0;
499 itimer->type = which;
500 /* Request that no more than 64KB of stack be reserved for this
501 thread, to avoid reserving too much memory, which would get in
502 the way of threads we start to wait for subprocesses. See also
503 new_child below. */
504 itimer->timer_thread = CreateThread (NULL, 64 * 1024, timer_loop,
505 (void *)itimer, 0x00010000, NULL);
506
507 if (!itimer->timer_thread)
508 {
509 CloseHandle (itimer->caller_thread);
510 itimer->caller_thread = NULL;
511 errno = EAGAIN;
512 return -1;
513 }
514
515 /* This is needed to make sure that the timer thread running for
516 profiling gets CPU as soon as the Sleep call terminates. */
517 if (which == ITIMER_PROF)
518 SetThreadPriority (itimer->caller_thread, THREAD_PRIORITY_TIME_CRITICAL);
519
520 return 0;
521}
522
523/* Most of the code of getitimer and setitimer (but not of their
524 subroutines) was shamelessly stolen from itimer.c in the DJGPP
525 library, see www.delorie.com/djgpp. */
526int
527getitimer (int which, struct itimerval *value)
528{
529 volatile clock_t *t_expire;
530 volatile clock_t *t_reload;
531 clock_t expire, reload;
532 __int64 usecs;
533 CRITICAL_SECTION *crit;
534
535 if (disable_itimers)
536 return -1;
537
538 ticks_now = clock ();
539
540 if (!value)
541 {
542 errno = EFAULT;
543 return -1;
544 }
545
546 if (which != ITIMER_REAL && which != ITIMER_PROF)
547 {
548 errno = EINVAL;
549 return -1;
550 }
551
552 t_expire = (which == ITIMER_REAL) ? &real_itimer.expire: &prof_itimer.expire;
553 t_reload = (which == ITIMER_REAL) ? &real_itimer.reload: &prof_itimer.reload;
554 crit = (which == ITIMER_REAL) ? &crit_real : &crit_prof;
555
556 EnterCriticalSection (crit);
557 reload = *t_reload;
558 expire = *t_expire;
559 LeaveCriticalSection (crit);
560
561 if (expire)
562 expire -= ticks_now;
563
564 value->it_value.tv_sec = expire / CLOCKS_PER_SEC;
565 usecs = (expire % CLOCKS_PER_SEC) * (__int64)1000000 / CLOCKS_PER_SEC;
566 value->it_value.tv_usec = usecs;
567 value->it_interval.tv_sec = reload / CLOCKS_PER_SEC;
568 usecs = (reload % CLOCKS_PER_SEC) * (__int64)1000000 / CLOCKS_PER_SEC;
569 value->it_interval.tv_usec= usecs;
570
571 return 0;
572}
573
574int
575setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
576{
577 volatile clock_t *t_expire, *t_reload;
578 clock_t expire, reload, expire_old, reload_old;
579 __int64 usecs;
580 CRITICAL_SECTION *crit;
581
582 if (disable_itimers)
583 return -1;
584
585 /* Posix systems expect timer values smaller than the resolution of
586 the system clock be rounded up to the clock resolution. First
587 time we are called, measure the clock tick resolution. */
588 if (!clocks_min)
589 {
590 clock_t t1, t2;
591
592 for (t1 = clock (); (t2 = clock ()) == t1; )
593 ;
594 clocks_min = t2 - t1;
595 }
596
597 if (ovalue)
598 {
599 if (getitimer (which, ovalue)) /* also sets ticks_now */
600 return -1; /* errno already set */
601 }
602 else
603 ticks_now = clock ();
604
605 if (which != ITIMER_REAL && which != ITIMER_PROF)
606 {
607 errno = EINVAL;
608 return -1;
609 }
610
611 t_expire =
612 (which == ITIMER_REAL) ? &real_itimer.expire : &prof_itimer.expire;
613 t_reload =
614 (which == ITIMER_REAL) ? &real_itimer.reload : &prof_itimer.reload;
615
616 crit = (which == ITIMER_REAL) ? &crit_real : &crit_prof;
617
618 if (!value
619 || (value->it_value.tv_sec == 0 && value->it_value.tv_usec == 0))
620 {
621 EnterCriticalSection (crit);
622 /* Disable the timer. */
623 *t_expire = 0;
624 *t_reload = 0;
625 LeaveCriticalSection (crit);
626 return 0;
627 }
628
629 reload = value->it_interval.tv_sec * CLOCKS_PER_SEC;
630
631 usecs = value->it_interval.tv_usec;
632 if (value->it_interval.tv_sec == 0
633 && usecs && usecs * CLOCKS_PER_SEC < clocks_min * 1000000)
634 reload = clocks_min;
635 else
636 {
637 usecs *= CLOCKS_PER_SEC;
638 reload += usecs / 1000000;
639 }
640
641 expire = value->it_value.tv_sec * CLOCKS_PER_SEC;
642 usecs = value->it_value.tv_usec;
643 if (value->it_value.tv_sec == 0
644 && usecs * CLOCKS_PER_SEC < clocks_min * 1000000)
645 expire = clocks_min;
646 else
647 {
648 usecs *= CLOCKS_PER_SEC;
649 expire += usecs / 1000000;
650 }
651
652 expire += ticks_now;
653
654 EnterCriticalSection (crit);
655 expire_old = *t_expire;
656 reload_old = *t_reload;
657 if (!(expire == expire_old && reload == reload_old))
658 {
659 *t_reload = reload;
660 *t_expire = expire;
661 }
662 LeaveCriticalSection (crit);
663
664 return start_timer_thread (which);
665}
666
667int
668alarm (int seconds)
669{
670#ifdef HAVE_SETITIMER
671 struct itimerval new_values, old_values;
672
673 new_values.it_value.tv_sec = seconds;
674 new_values.it_value.tv_usec = 0;
675 new_values.it_interval.tv_sec = new_values.it_interval.tv_usec = 0;
676
677 if (setitimer (ITIMER_REAL, &new_values, &old_values) < 0)
678 return 0;
679 return old_values.it_value.tv_sec;
680#else
681 return seconds;
682#endif
683}
684
146/* Defined in <process.h> which conflicts with the local copy */ 685/* Defined in <process.h> which conflicts with the local copy */
147#define _P_NOWAIT 1 686#define _P_NOWAIT 1
148 687
@@ -593,7 +1132,7 @@ get_result:
593 else if (WIFSIGNALED (retval)) 1132 else if (WIFSIGNALED (retval))
594 { 1133 {
595 int code = WTERMSIG (retval); 1134 int code = WTERMSIG (retval);
596 char *signame; 1135 const char *signame;
597 1136
598 synchronize_system_messages_locale (); 1137 synchronize_system_messages_locale ();
599 signame = strsignal (code); 1138 signame = strsignal (code);
@@ -668,7 +1207,7 @@ w32_executable_type (char * filename,
668 if (dos_header->e_magic != IMAGE_DOS_SIGNATURE) 1207 if (dos_header->e_magic != IMAGE_DOS_SIGNATURE)
669 goto unwind; 1208 goto unwind;
670 1209
671 nt_header = (PIMAGE_NT_HEADERS) ((char *) dos_header + dos_header->e_lfanew); 1210 nt_header = (PIMAGE_NT_HEADERS) ((unsigned char *) dos_header + dos_header->e_lfanew);
672 1211
673 if ((char *) nt_header > (char *) dos_header + executable.size) 1212 if ((char *) nt_header > (char *) dos_header + executable.size)
674 { 1213 {
diff --git a/src/w32term.c b/src/w32term.c
index 5d5e572c475..1cc8bd2adef 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -102,7 +102,7 @@ struct w32_display_info *x_display_list;
102Lisp_Object w32_display_name_list; 102Lisp_Object w32_display_name_list;
103 103
104 104
105#ifndef GLYPHSET 105#if _WIN32_WINNT < 0x0500
106/* Pre Windows 2000, this was not available, but define it here so 106/* Pre Windows 2000, this was not available, but define it here so
107 that Emacs compiled on such a platform will run on newer versions. */ 107 that Emacs compiled on such a platform will run on newer versions. */
108 108
@@ -360,7 +360,11 @@ w32_draw_underwave (struct glyph_string *s, COLORREF color)
360 360
361 /* Find and set clipping rectangle */ 361 /* Find and set clipping rectangle */
362 362
363 wave_clip = (XRectangle){ x0, y0, width, wave_height }; 363 wave_clip.x = x0;
364 wave_clip.y = y0;
365 wave_clip.width = width;
366 wave_clip.height = wave_height;
367
364 get_glyph_string_clip_rect (s, &w32_string_clip); 368 get_glyph_string_clip_rect (s, &w32_string_clip);
365 CONVERT_TO_XRECT (string_clip, w32_string_clip); 369 CONVERT_TO_XRECT (string_clip, w32_string_clip);
366 370
diff --git a/src/w32term.h b/src/w32term.h
index 5d756f435e4..fcaccc4d624 100644
--- a/src/w32term.h
+++ b/src/w32term.h
@@ -201,6 +201,8 @@ extern struct w32_display_info *w32_term_init (Lisp_Object,
201extern int x_display_pixel_height (struct w32_display_info *); 201extern int x_display_pixel_height (struct w32_display_info *);
202extern int x_display_pixel_width (struct w32_display_info *); 202extern int x_display_pixel_width (struct w32_display_info *);
203 203
204extern Lisp_Object x_get_focus_frame (struct frame *);
205
204 206
205#define PIX_TYPE COLORREF 207#define PIX_TYPE COLORREF
206 208
@@ -431,7 +433,15 @@ struct scroll_bar {
431/* Turning a lisp vector value into a pointer to a struct scroll_bar. */ 433/* Turning a lisp vector value into a pointer to a struct scroll_bar. */
432#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec)) 434#define XSCROLL_BAR(vec) ((struct scroll_bar *) XVECTOR (vec))
433 435
436#ifdef _WIN64
437/* Building a 64-bit C integer from two 32-bit lisp integers. */
438#define SCROLL_BAR_PACK(low, high) (XINT (high) << 32 | XINT (low))
434 439
440/* Setting two lisp integers to the low and high words of a 64-bit C int. */
441#define SCROLL_BAR_UNPACK(low, high, int64) \
442 (XSETINT ((low), ((DWORDLONG)(int64)) & 0xffffffff), \
443 XSETINT ((high), ((DWORDLONG)(int64) >> 32) & 0xffffffff))
444#else /* not _WIN64 */
435/* Building a 32-bit C integer from two 16-bit lisp integers. */ 445/* Building a 32-bit C integer from two 16-bit lisp integers. */
436#define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low)) 446#define SCROLL_BAR_PACK(low, high) (XINT (high) << 16 | XINT (low))
437 447
@@ -439,7 +449,7 @@ struct scroll_bar {
439#define SCROLL_BAR_UNPACK(low, high, int32) \ 449#define SCROLL_BAR_UNPACK(low, high, int32) \
440 (XSETINT ((low), (int32) & 0xffff), \ 450 (XSETINT ((low), (int32) & 0xffff), \
441 XSETINT ((high), ((int32) >> 16) & 0xffff)) 451 XSETINT ((high), ((int32) >> 16) & 0xffff))
442 452#endif /* not _WIN64 */
443 453
444/* Extract the window id of the scroll bar from a struct scroll_bar. */ 454/* Extract the window id of the scroll bar from a struct scroll_bar. */
445#define SCROLL_BAR_W32_WINDOW(ptr) \ 455#define SCROLL_BAR_W32_WINDOW(ptr) \
@@ -447,7 +457,7 @@ struct scroll_bar {
447 457
448/* Store a window id in a struct scroll_bar. */ 458/* Store a window id in a struct scroll_bar. */
449#define SET_SCROLL_BAR_W32_WINDOW(ptr, id) \ 459#define SET_SCROLL_BAR_W32_WINDOW(ptr, id) \
450 (SCROLL_BAR_UNPACK ((ptr)->w32_window_low, (ptr)->w32_window_high, (int) id)) 460 (SCROLL_BAR_UNPACK ((ptr)->w32_window_low, (ptr)->w32_window_high, (intptr_t) id))
451 461
452/* Extract the X widget of the scroll bar from a struct scroll_bar. */ 462/* Extract the X widget of the scroll bar from a struct scroll_bar. */
453#define SCROLL_BAR_X_WIDGET(ptr) \ 463#define SCROLL_BAR_X_WIDGET(ptr) \
diff --git a/src/window.c b/src/window.c
index 21dddb8a931..101fb3ff94f 100644
--- a/src/window.c
+++ b/src/window.c
@@ -61,7 +61,7 @@ static Lisp_Object Qwindow_deletable_p, Qdelete_window, Qdisplay_buffer;
61static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window; 61static Lisp_Object Qreplace_buffer_in_windows, Qget_mru_window;
62static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically; 62static Lisp_Object Qwindow_resize_root_window, Qwindow_resize_root_window_vertically;
63static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command; 63static Lisp_Object Qscroll_up, Qscroll_down, Qscroll_command;
64static Lisp_Object Qsafe, Qabove, Qbelow, Qtemp_buffer_resize, Qclone_of; 64static Lisp_Object Qsafe, Qabove, Qbelow, Qwindow_size, Qclone_of;
65 65
66static int displayed_window_lines (struct window *); 66static int displayed_window_lines (struct window *);
67static int count_windows (struct window *); 67static int count_windows (struct window *);
@@ -134,102 +134,102 @@ static EMACS_INT window_scroll_preserve_hpos;
134static EMACS_INT window_scroll_preserve_vpos; 134static EMACS_INT window_scroll_preserve_vpos;
135 135
136/* These setters are used only in this file, so they can be private. */ 136/* These setters are used only in this file, so they can be private. */
137static inline void 137static void
138wset_combination_limit (struct window *w, Lisp_Object val) 138wset_combination_limit (struct window *w, Lisp_Object val)
139{ 139{
140 w->combination_limit = val; 140 w->combination_limit = val;
141} 141}
142static inline void 142static void
143wset_dedicated (struct window *w, Lisp_Object val) 143wset_dedicated (struct window *w, Lisp_Object val)
144{ 144{
145 w->dedicated = val; 145 w->dedicated = val;
146} 146}
147static inline void 147static void
148wset_display_table (struct window *w, Lisp_Object val) 148wset_display_table (struct window *w, Lisp_Object val)
149{ 149{
150 w->display_table = val; 150 w->display_table = val;
151} 151}
152static inline void 152static void
153wset_hchild (struct window *w, Lisp_Object val) 153wset_hchild (struct window *w, Lisp_Object val)
154{ 154{
155 w->hchild = val; 155 w->hchild = val;
156} 156}
157static inline void 157static void
158wset_left_fringe_width (struct window *w, Lisp_Object val) 158wset_left_fringe_width (struct window *w, Lisp_Object val)
159{ 159{
160 w->left_fringe_width = val; 160 w->left_fringe_width = val;
161} 161}
162static inline void 162static void
163wset_left_margin_cols (struct window *w, Lisp_Object val) 163wset_left_margin_cols (struct window *w, Lisp_Object val)
164{ 164{
165 w->left_margin_cols = val; 165 w->left_margin_cols = val;
166} 166}
167static inline void 167static void
168wset_new_normal (struct window *w, Lisp_Object val) 168wset_new_normal (struct window *w, Lisp_Object val)
169{ 169{
170 w->new_normal = val; 170 w->new_normal = val;
171} 171}
172static inline void 172static void
173wset_new_total (struct window *w, Lisp_Object val) 173wset_new_total (struct window *w, Lisp_Object val)
174{ 174{
175 w->new_total = val; 175 w->new_total = val;
176} 176}
177static inline void 177static void
178wset_normal_cols (struct window *w, Lisp_Object val) 178wset_normal_cols (struct window *w, Lisp_Object val)
179{ 179{
180 w->normal_cols = val; 180 w->normal_cols = val;
181} 181}
182static inline void 182static void
183wset_normal_lines (struct window *w, Lisp_Object val) 183wset_normal_lines (struct window *w, Lisp_Object val)
184{ 184{
185 w->normal_lines = val; 185 w->normal_lines = val;
186} 186}
187static inline void 187static void
188wset_parent (struct window *w, Lisp_Object val) 188wset_parent (struct window *w, Lisp_Object val)
189{ 189{
190 w->parent = val; 190 w->parent = val;
191} 191}
192static inline void 192static void
193wset_pointm (struct window *w, Lisp_Object val) 193wset_pointm (struct window *w, Lisp_Object val)
194{ 194{
195 w->pointm = val; 195 w->pointm = val;
196} 196}
197static inline void 197static void
198wset_right_fringe_width (struct window *w, Lisp_Object val) 198wset_right_fringe_width (struct window *w, Lisp_Object val)
199{ 199{
200 w->right_fringe_width = val; 200 w->right_fringe_width = val;
201} 201}
202static inline void 202static void
203wset_right_margin_cols (struct window *w, Lisp_Object val) 203wset_right_margin_cols (struct window *w, Lisp_Object val)
204{ 204{
205 w->right_margin_cols = val; 205 w->right_margin_cols = val;
206} 206}
207static inline void 207static void
208wset_scroll_bar_width (struct window *w, Lisp_Object val) 208wset_scroll_bar_width (struct window *w, Lisp_Object val)
209{ 209{
210 w->scroll_bar_width = val; 210 w->scroll_bar_width = val;
211} 211}
212static inline void 212static void
213wset_start (struct window *w, Lisp_Object val) 213wset_start (struct window *w, Lisp_Object val)
214{ 214{
215 w->start = val; 215 w->start = val;
216} 216}
217static inline void 217static void
218wset_temslot (struct window *w, Lisp_Object val) 218wset_temslot (struct window *w, Lisp_Object val)
219{ 219{
220 w->temslot = val; 220 w->temslot = val;
221} 221}
222static inline void 222static void
223wset_vchild (struct window *w, Lisp_Object val) 223wset_vchild (struct window *w, Lisp_Object val)
224{ 224{
225 w->vchild = val; 225 w->vchild = val;
226} 226}
227static inline void 227static void
228wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val) 228wset_vertical_scroll_bar_type (struct window *w, Lisp_Object val)
229{ 229{
230 w->vertical_scroll_bar_type = val; 230 w->vertical_scroll_bar_type = val;
231} 231}
232static inline void 232static void
233wset_window_parameters (struct window *w, Lisp_Object val) 233wset_window_parameters (struct window *w, Lisp_Object val)
234{ 234{
235 w->window_parameters = val; 235 w->window_parameters = val;
@@ -6708,7 +6708,7 @@ syms_of_window (void)
6708 DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows"); 6708 DEFSYM (Qreplace_buffer_in_windows, "replace-buffer-in-windows");
6709 DEFSYM (Qrecord_window_buffer, "record-window-buffer"); 6709 DEFSYM (Qrecord_window_buffer, "record-window-buffer");
6710 DEFSYM (Qget_mru_window, "get-mru-window"); 6710 DEFSYM (Qget_mru_window, "get-mru-window");
6711 DEFSYM (Qtemp_buffer_resize, "temp-buffer-resize"); 6711 DEFSYM (Qwindow_size, "window-size");
6712 DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook"); 6712 DEFSYM (Qtemp_buffer_show_hook, "temp-buffer-show-hook");
6713 DEFSYM (Qabove, "above"); 6713 DEFSYM (Qabove, "above");
6714 DEFSYM (Qbelow, "below"); 6714 DEFSYM (Qbelow, "below");
@@ -6808,19 +6808,19 @@ This variable takes no effect if `window-combination-limit' is non-nil. */);
6808The following values are recognized: 6808The following values are recognized:
6809 6809
6810nil means splitting a window will create a new parent window only if the 6810nil means splitting a window will create a new parent window only if the
6811 window has no parent window or the window shall become a combination 6811 window has no parent window or the window shall become part of a
6812 orthogonal to the one it is part of. 6812 combination orthogonal to the one it is part of.
6813 6813
6814`temp-buffer-resize' means that splitting a window for displaying a 6814`window-size' means that splitting a window for displaying a buffer
6815 temporary buffer makes a new parent window provided 6815 makes a new parent window provided `display-buffer' is supposed to
6816 `temp-buffer-resize-mode' is enabled. Otherwise, this value is 6816 explicitly set the window's size due to the presence of a
6817 handled like nil. 6817 `window-height' or `window-width' entry in the alist used by
6818 `display-buffer'. Otherwise, this value is handled like nil.
6818 6819
6819`temp-buffer' means that splitting a window for displaying a temporary 6820`temp-buffer' means that splitting a window for displaying a temporary
6820 buffer always makes a new parent window. Otherwise, this value is 6821 buffer always makes a new parent window. Otherwise, this value is
6821 handled like nil. 6822 handled like nil.
6822 6823
6823
6824`display-buffer' means that splitting a window for displaying a buffer 6824`display-buffer' means that splitting a window for displaying a buffer
6825 always makes a new parent window. Since temporary buffers are 6825 always makes a new parent window. Since temporary buffers are
6826 displayed by the function `display-buffer', this value is stronger 6826 displayed by the function `display-buffer', this value is stronger
@@ -6833,7 +6833,7 @@ t means that splitting a window always creates a new parent window. If
6833 sibling. 6833 sibling.
6834 6834
6835Other values are reserved for future use. */); 6835Other values are reserved for future use. */);
6836 Vwindow_combination_limit = Qtemp_buffer_resize; 6836 Vwindow_combination_limit = Qwindow_size;
6837 6837
6838 DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters, 6838 DEFVAR_LISP ("window-persistent-parameters", Vwindow_persistent_parameters,
6839 doc: /* Alist of persistent window parameters. 6839 doc: /* Alist of persistent window parameters.
diff --git a/src/xdisp.c b/src/xdisp.c
index b4ac9a6ec08..91f826edefc 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -349,7 +349,7 @@ static Lisp_Object Qfontification_functions;
349 349
350static Lisp_Object Qwrap_prefix; 350static Lisp_Object Qwrap_prefix;
351static Lisp_Object Qline_prefix; 351static Lisp_Object Qline_prefix;
352static Lisp_Object Qautomatic_redisplay; 352static Lisp_Object Qredisplay_internal;
353 353
354/* Non-nil means don't actually do any redisplay. */ 354/* Non-nil means don't actually do any redisplay. */
355 355
@@ -369,22 +369,22 @@ static Lisp_Object Qmargin, Qpointer;
369static Lisp_Object Qline_height; 369static Lisp_Object Qline_height;
370 370
371/* These setters are used only in this file, so they can be private. */ 371/* These setters are used only in this file, so they can be private. */
372static inline void 372static void
373wset_base_line_number (struct window *w, Lisp_Object val) 373wset_base_line_number (struct window *w, Lisp_Object val)
374{ 374{
375 w->base_line_number = val; 375 w->base_line_number = val;
376} 376}
377static inline void 377static void
378wset_base_line_pos (struct window *w, Lisp_Object val) 378wset_base_line_pos (struct window *w, Lisp_Object val)
379{ 379{
380 w->base_line_pos = val; 380 w->base_line_pos = val;
381} 381}
382static inline void 382static void
383wset_column_number_displayed (struct window *w, Lisp_Object val) 383wset_column_number_displayed (struct window *w, Lisp_Object val)
384{ 384{
385 w->column_number_displayed = val; 385 w->column_number_displayed = val;
386} 386}
387static inline void 387static void
388wset_region_showing (struct window *w, Lisp_Object val) 388wset_region_showing (struct window *w, Lisp_Object val)
389{ 389{
390 w->region_showing = val; 390 w->region_showing = val;
@@ -1196,7 +1196,7 @@ window_box (struct window *w, int area, int *box_x, int *box_y,
1196 *BOTTOM_RIGHT_Y the coordinates of the bottom-right corner of the 1196 *BOTTOM_RIGHT_Y the coordinates of the bottom-right corner of the
1197 box. */ 1197 box. */
1198 1198
1199static inline void 1199static void
1200window_box_edges (struct window *w, int area, int *top_left_x, int *top_left_y, 1200window_box_edges (struct window *w, int area, int *top_left_x, int *top_left_y,
1201 int *bottom_right_x, int *bottom_right_y) 1201 int *bottom_right_x, int *bottom_right_y)
1202{ 1202{
@@ -1283,7 +1283,7 @@ string_from_display_spec (Lisp_Object spec)
1283/* Limit insanely large values of W->hscroll on frame F to the largest 1283/* Limit insanely large values of W->hscroll on frame F to the largest
1284 value that will still prevent first_visible_x and last_visible_x of 1284 value that will still prevent first_visible_x and last_visible_x of
1285 'struct it' from overflowing an int. */ 1285 'struct it' from overflowing an int. */
1286static inline int 1286static int
1287window_hscroll_limited (struct window *w, struct frame *f) 1287window_hscroll_limited (struct window *w, struct frame *f)
1288{ 1288{
1289 ptrdiff_t window_hscroll = w->hscroll; 1289 ptrdiff_t window_hscroll = w->hscroll;
@@ -1630,7 +1630,7 @@ pos_visible_p (struct window *w, ptrdiff_t charpos, int *x, int *y,
1630 returns an invalid character. If we find one, we return a `?', but 1630 returns an invalid character. If we find one, we return a `?', but
1631 with the length of the invalid character. */ 1631 with the length of the invalid character. */
1632 1632
1633static inline int 1633static int
1634string_char_and_length (const unsigned char *str, int *len) 1634string_char_and_length (const unsigned char *str, int *len)
1635{ 1635{
1636 int c; 1636 int c;
@@ -1678,7 +1678,7 @@ string_pos_nchars_ahead (struct text_pos pos, Lisp_Object string, ptrdiff_t ncha
1678/* Value is the text position, i.e. character and byte position, 1678/* Value is the text position, i.e. character and byte position,
1679 for character position CHARPOS in STRING. */ 1679 for character position CHARPOS in STRING. */
1680 1680
1681static inline struct text_pos 1681static struct text_pos
1682string_pos (ptrdiff_t charpos, Lisp_Object string) 1682string_pos (ptrdiff_t charpos, Lisp_Object string)
1683{ 1683{
1684 struct text_pos pos; 1684 struct text_pos pos;
@@ -12631,7 +12631,7 @@ debug_method_add (struct window *w, char const *fmt, ...)
12631 buffer position, END is given as a distance from Z. Used in 12631 buffer position, END is given as a distance from Z. Used in
12632 redisplay_internal for display optimization. */ 12632 redisplay_internal for display optimization. */
12633 12633
12634static inline int 12634static int
12635text_outside_line_unchanged_p (struct window *w, 12635text_outside_line_unchanged_p (struct window *w,
12636 ptrdiff_t start, ptrdiff_t end) 12636 ptrdiff_t start, ptrdiff_t end)
12637{ 12637{
@@ -12892,7 +12892,7 @@ check_point_in_composition (struct buffer *prev_buf, ptrdiff_t prev_pt,
12892/* Reconsider the setting of B->clip_changed which is displayed 12892/* Reconsider the setting of B->clip_changed which is displayed
12893 in window W. */ 12893 in window W. */
12894 12894
12895static inline void 12895static void
12896reconsider_clip_changes (struct window *w, struct buffer *b) 12896reconsider_clip_changes (struct window *w, struct buffer *b)
12897{ 12897{
12898 if (b->clip_changed 12898 if (b->clip_changed
@@ -13029,8 +13029,8 @@ redisplay_internal (void)
13029 13029
13030 /* Record this function, so it appears on the profiler's backtraces. */ 13030 /* Record this function, so it appears on the profiler's backtraces. */
13031 backtrace.next = backtrace_list; 13031 backtrace.next = backtrace_list;
13032 backtrace.function = &Qautomatic_redisplay; 13032 backtrace.function = Qredisplay_internal;
13033 backtrace.args = &Qautomatic_redisplay; 13033 backtrace.args = &Qnil;
13034 backtrace.nargs = 0; 13034 backtrace.nargs = 0;
13035 backtrace.debug_on_exit = 0; 13035 backtrace.debug_on_exit = 0;
13036 backtrace_list = &backtrace; 13036 backtrace_list = &backtrace;
@@ -14599,7 +14599,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
14599 14599
14600 We assume that the window's buffer is really current. */ 14600 We assume that the window's buffer is really current. */
14601 14601
14602static inline struct text_pos 14602static struct text_pos
14603run_window_scroll_functions (Lisp_Object window, struct text_pos startp) 14603run_window_scroll_functions (Lisp_Object window, struct text_pos startp)
14604{ 14604{
14605 struct window *w = XWINDOW (window); 14605 struct window *w = XWINDOW (window);
@@ -22603,7 +22603,7 @@ init_glyph_string (struct glyph_string *s,
22603/* Append the list of glyph strings with head H and tail T to the list 22603/* Append the list of glyph strings with head H and tail T to the list
22604 with head *HEAD and tail *TAIL. Set *HEAD and *TAIL to the result. */ 22604 with head *HEAD and tail *TAIL. Set *HEAD and *TAIL to the result. */
22605 22605
22606static inline void 22606static void
22607append_glyph_string_lists (struct glyph_string **head, struct glyph_string **tail, 22607append_glyph_string_lists (struct glyph_string **head, struct glyph_string **tail,
22608 struct glyph_string *h, struct glyph_string *t) 22608 struct glyph_string *h, struct glyph_string *t)
22609{ 22609{
@@ -22623,7 +22623,7 @@ append_glyph_string_lists (struct glyph_string **head, struct glyph_string **tai
22623 list with head *HEAD and tail *TAIL. Set *HEAD and *TAIL to the 22623 list with head *HEAD and tail *TAIL. Set *HEAD and *TAIL to the
22624 result. */ 22624 result. */
22625 22625
22626static inline void 22626static void
22627prepend_glyph_string_lists (struct glyph_string **head, struct glyph_string **tail, 22627prepend_glyph_string_lists (struct glyph_string **head, struct glyph_string **tail,
22628 struct glyph_string *h, struct glyph_string *t) 22628 struct glyph_string *h, struct glyph_string *t)
22629{ 22629{
@@ -22642,7 +22642,7 @@ prepend_glyph_string_lists (struct glyph_string **head, struct glyph_string **ta
22642/* Append glyph string S to the list with head *HEAD and tail *TAIL. 22642/* Append glyph string S to the list with head *HEAD and tail *TAIL.
22643 Set *HEAD and *TAIL to the resulting list. */ 22643 Set *HEAD and *TAIL to the resulting list. */
22644 22644
22645static inline void 22645static void
22646append_glyph_string (struct glyph_string **head, struct glyph_string **tail, 22646append_glyph_string (struct glyph_string **head, struct glyph_string **tail,
22647 struct glyph_string *s) 22647 struct glyph_string *s)
22648{ 22648{
@@ -22657,7 +22657,7 @@ append_glyph_string (struct glyph_string **head, struct glyph_string **tail,
22657 Value is a pointer to a realized face that is ready for display if 22657 Value is a pointer to a realized face that is ready for display if
22658 DISPLAY_P is non-zero. */ 22658 DISPLAY_P is non-zero. */
22659 22659
22660static inline struct face * 22660static struct face *
22661get_char_face_and_encoding (struct frame *f, int c, int face_id, 22661get_char_face_and_encoding (struct frame *f, int c, int face_id,
22662 XChar2b *char2b, int display_p) 22662 XChar2b *char2b, int display_p)
22663{ 22663{
@@ -22690,7 +22690,7 @@ get_char_face_and_encoding (struct frame *f, int c, int face_id,
22690 The encoding of GLYPH->u.ch is returned in *CHAR2B. Value is 22690 The encoding of GLYPH->u.ch is returned in *CHAR2B. Value is
22691 a pointer to a realized face that is ready for display. */ 22691 a pointer to a realized face that is ready for display. */
22692 22692
22693static inline struct face * 22693static struct face *
22694get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph, 22694get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
22695 XChar2b *char2b, int *two_byte_p) 22695 XChar2b *char2b, int *two_byte_p)
22696{ 22696{
@@ -22727,7 +22727,7 @@ get_glyph_face_and_encoding (struct frame *f, struct glyph *glyph,
22727/* Get glyph code of character C in FONT in the two-byte form CHAR2B. 22727/* Get glyph code of character C in FONT in the two-byte form CHAR2B.
22728 Return 1 if FONT has a glyph for C, otherwise return 0. */ 22728 Return 1 if FONT has a glyph for C, otherwise return 0. */
22729 22729
22730static inline int 22730static int
22731get_char_glyph_code (int c, struct font *font, XChar2b *char2b) 22731get_char_glyph_code (int c, struct font *font, XChar2b *char2b)
22732{ 22732{
22733 unsigned code; 22733 unsigned code;
@@ -23214,7 +23214,7 @@ right_overwriting (struct glyph_string *s)
23214 first glyph following S. LAST_X is the right-most x-position + 1 23214 first glyph following S. LAST_X is the right-most x-position + 1
23215 in the drawing area. */ 23215 in the drawing area. */
23216 23216
23217static inline void 23217static void
23218set_glyph_string_background_width (struct glyph_string *s, int start, int last_x) 23218set_glyph_string_background_width (struct glyph_string *s, int start, int last_x)
23219{ 23219{
23220 /* If the face of this glyph string has to be drawn to the end of 23220 /* If the face of this glyph string has to be drawn to the end of
@@ -23809,7 +23809,7 @@ draw_glyphs (struct window *w, int x, struct glyph_row *row,
23809/* Store one glyph for IT->char_to_display in IT->glyph_row. 23809/* Store one glyph for IT->char_to_display in IT->glyph_row.
23810 Called from x_produce_glyphs when IT->glyph_row is non-null. */ 23810 Called from x_produce_glyphs when IT->glyph_row is non-null. */
23811 23811
23812static inline void 23812static void
23813append_glyph (struct it *it) 23813append_glyph (struct it *it)
23814{ 23814{
23815 struct glyph *glyph; 23815 struct glyph *glyph;
@@ -23883,7 +23883,7 @@ append_glyph (struct it *it)
23883 IT->glyph_row. Called from x_produce_glyphs when IT->glyph_row is 23883 IT->glyph_row. Called from x_produce_glyphs when IT->glyph_row is
23884 non-null. */ 23884 non-null. */
23885 23885
23886static inline void 23886static void
23887append_composite_glyph (struct it *it) 23887append_composite_glyph (struct it *it)
23888{ 23888{
23889 struct glyph *glyph; 23889 struct glyph *glyph;
@@ -23952,7 +23952,7 @@ append_composite_glyph (struct it *it)
23952/* Change IT->ascent and IT->height according to the setting of 23952/* Change IT->ascent and IT->height according to the setting of
23953 IT->voffset. */ 23953 IT->voffset. */
23954 23954
23955static inline void 23955static void
23956take_vertical_position_into_account (struct it *it) 23956take_vertical_position_into_account (struct it *it)
23957{ 23957{
23958 if (it->voffset) 23958 if (it->voffset)
@@ -28946,7 +28946,7 @@ syms_of_xdisp (void)
28946 staticpro (&Vmessage_stack); 28946 staticpro (&Vmessage_stack);
28947 28947
28948 DEFSYM (Qinhibit_redisplay, "inhibit-redisplay"); 28948 DEFSYM (Qinhibit_redisplay, "inhibit-redisplay");
28949 DEFSYM (Qautomatic_redisplay, "Automatic Redisplay"); 28949 DEFSYM (Qredisplay_internal, "redisplay_internal (C function)");
28950 28950
28951 message_dolog_marker1 = Fmake_marker (); 28951 message_dolog_marker1 = Fmake_marker ();
28952 staticpro (&message_dolog_marker1); 28952 staticpro (&message_dolog_marker1);
@@ -29238,7 +29238,7 @@ and is used only on frames for which no explicit name has been set
29238 doc: /* Maximum number of lines to keep in the message log buffer. 29238 doc: /* Maximum number of lines to keep in the message log buffer.
29239If nil, disable message logging. If t, log messages but don't truncate 29239If nil, disable message logging. If t, log messages but don't truncate
29240the buffer when it becomes large. */); 29240the buffer when it becomes large. */);
29241 Vmessage_log_max = make_number (100); 29241 Vmessage_log_max = make_number (1000);
29242 29242
29243 DEFVAR_LISP ("window-size-change-functions", Vwindow_size_change_functions, 29243 DEFVAR_LISP ("window-size-change-functions", Vwindow_size_change_functions,
29244 doc: /* Functions called before redisplay, if window sizes have changed. 29244 doc: /* Functions called before redisplay, if window sizes have changed.
@@ -29609,10 +29609,6 @@ init_xdisp (void)
29609 help_echo_showing_p = 0; 29609 help_echo_showing_p = 0;
29610} 29610}
29611 29611
29612/* Since w32 does not support atimers, it defines its own implementation of
29613 the following three functions in w32fns.c. */
29614#ifndef WINDOWSNT
29615
29616/* Platform-independent portion of hourglass implementation. */ 29612/* Platform-independent portion of hourglass implementation. */
29617 29613
29618/* Cancel a currently active hourglass timer, and start a new one. */ 29614/* Cancel a currently active hourglass timer, and start a new one. */
@@ -29635,6 +29631,10 @@ start_hourglass (void)
29635 else 29631 else
29636 delay = make_emacs_time (DEFAULT_HOURGLASS_DELAY, 0); 29632 delay = make_emacs_time (DEFAULT_HOURGLASS_DELAY, 0);
29637 29633
29634#ifdef WINDOWSNT
29635 w32_note_current_window ();
29636#endif
29637
29638 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay, 29638 hourglass_atimer = start_atimer (ATIMER_RELATIVE, delay,
29639 show_hourglass, NULL); 29639 show_hourglass, NULL);
29640#endif 29640#endif
@@ -29657,4 +29657,3 @@ cancel_hourglass (void)
29657 hide_hourglass (); 29657 hide_hourglass ();
29658#endif 29658#endif
29659} 29659}
29660#endif /* ! WINDOWSNT */
diff --git a/src/xfaces.c b/src/xfaces.c
index 28be6aaf082..f861dde2d15 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -601,7 +601,7 @@ x_free_dpy_colors (Display *dpy, Screen *screen, Colormap cmap,
601/* Create and return a GC for use on frame F. GC values and mask 601/* Create and return a GC for use on frame F. GC values and mask
602 are given by XGCV and MASK. */ 602 are given by XGCV and MASK. */
603 603
604static inline GC 604static GC
605x_create_gc (struct frame *f, long unsigned int mask, XGCValues *xgcv) 605x_create_gc (struct frame *f, long unsigned int mask, XGCValues *xgcv)
606{ 606{
607 GC gc; 607 GC gc;
@@ -615,7 +615,7 @@ x_create_gc (struct frame *f, long unsigned int mask, XGCValues *xgcv)
615 615
616/* Free GC which was used on frame F. */ 616/* Free GC which was used on frame F. */
617 617
618static inline void 618static void
619x_free_gc (struct frame *f, GC gc) 619x_free_gc (struct frame *f, GC gc)
620{ 620{
621 eassert (input_blocked_p ()); 621 eassert (input_blocked_p ());
@@ -628,7 +628,7 @@ x_free_gc (struct frame *f, GC gc)
628#ifdef WINDOWSNT 628#ifdef WINDOWSNT
629/* W32 emulation of GCs */ 629/* W32 emulation of GCs */
630 630
631static inline GC 631static GC
632x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv) 632x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv)
633{ 633{
634 GC gc; 634 GC gc;
@@ -642,7 +642,7 @@ x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv)
642 642
643/* Free GC which was used on frame F. */ 643/* Free GC which was used on frame F. */
644 644
645static inline void 645static void
646x_free_gc (struct frame *f, GC gc) 646x_free_gc (struct frame *f, GC gc)
647{ 647{
648 IF_DEBUG (eassert (--ngcs >= 0)); 648 IF_DEBUG (eassert (--ngcs >= 0));
@@ -654,7 +654,7 @@ x_free_gc (struct frame *f, GC gc)
654#ifdef HAVE_NS 654#ifdef HAVE_NS
655/* NS emulation of GCs */ 655/* NS emulation of GCs */
656 656
657static inline GC 657static GC
658x_create_gc (struct frame *f, 658x_create_gc (struct frame *f,
659 unsigned long mask, 659 unsigned long mask,
660 XGCValues *xgcv) 660 XGCValues *xgcv)
@@ -664,7 +664,7 @@ x_create_gc (struct frame *f,
664 return gc; 664 return gc;
665} 665}
666 666
667static inline void 667static void
668x_free_gc (struct frame *f, GC gc) 668x_free_gc (struct frame *f, GC gc)
669{ 669{
670 xfree (gc); 670 xfree (gc);
@@ -677,7 +677,7 @@ x_free_gc (struct frame *f, GC gc)
677 CHECK_LIVE_FRAME. This is here because it's a frequent pattern in 677 CHECK_LIVE_FRAME. This is here because it's a frequent pattern in
678 Lisp function definitions. */ 678 Lisp function definitions. */
679 679
680static inline struct frame * 680static struct frame *
681frame_or_selected_frame (Lisp_Object frame, int nparam) 681frame_or_selected_frame (Lisp_Object frame, int nparam)
682{ 682{
683 if (NILP (frame)) 683 if (NILP (frame))
@@ -1920,7 +1920,7 @@ struct named_merge_point
1920 FACE_NAME and NAMED_MERGE_POINT_KIND, as the head of the linked list 1920 FACE_NAME and NAMED_MERGE_POINT_KIND, as the head of the linked list
1921 pointed to by NAMED_MERGE_POINTS, and return 1. */ 1921 pointed to by NAMED_MERGE_POINTS, and return 1. */
1922 1922
1923static inline int 1923static int
1924push_named_merge_point (struct named_merge_point *new_named_merge_point, 1924push_named_merge_point (struct named_merge_point *new_named_merge_point,
1925 Lisp_Object face_name, 1925 Lisp_Object face_name,
1926 enum named_merge_point_kind named_merge_point_kind, 1926 enum named_merge_point_kind named_merge_point_kind,
@@ -2004,7 +2004,7 @@ resolve_face_name (Lisp_Object face_name, int signal_p)
2004 face text properties; Ediff uses that). If SIGNAL_P is non-zero, 2004 face text properties; Ediff uses that). If SIGNAL_P is non-zero,
2005 signal an error if FACE_NAME is not a valid face name. If SIGNAL_P 2005 signal an error if FACE_NAME is not a valid face name. If SIGNAL_P
2006 is zero, value is nil if FACE_NAME is not a valid face name. */ 2006 is zero, value is nil if FACE_NAME is not a valid face name. */
2007static inline Lisp_Object 2007static Lisp_Object
2008lface_from_face_name_no_resolve (struct frame *f, Lisp_Object face_name, 2008lface_from_face_name_no_resolve (struct frame *f, Lisp_Object face_name,
2009 int signal_p) 2009 int signal_p)
2010{ 2010{
@@ -2033,7 +2033,7 @@ lface_from_face_name_no_resolve (struct frame *f, Lisp_Object face_name,
2033 non-zero, signal an error if FACE_NAME is not a valid face name. 2033 non-zero, signal an error if FACE_NAME is not a valid face name.
2034 If SIGNAL_P is zero, value is nil if FACE_NAME is not a valid face 2034 If SIGNAL_P is zero, value is nil if FACE_NAME is not a valid face
2035 name. */ 2035 name. */
2036static inline Lisp_Object 2036static Lisp_Object
2037lface_from_face_name (struct frame *f, Lisp_Object face_name, int signal_p) 2037lface_from_face_name (struct frame *f, Lisp_Object face_name, int signal_p)
2038{ 2038{
2039 face_name = resolve_face_name (face_name, signal_p); 2039 face_name = resolve_face_name (face_name, signal_p);
@@ -2047,7 +2047,7 @@ lface_from_face_name (struct frame *f, Lisp_Object face_name, int signal_p)
2047 is non-zero, signal an error if FACE_NAME does not name a face. 2047 is non-zero, signal an error if FACE_NAME does not name a face.
2048 Otherwise, value is zero if FACE_NAME is not a face. */ 2048 Otherwise, value is zero if FACE_NAME is not a face. */
2049 2049
2050static inline int 2050static int
2051get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name, 2051get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name,
2052 Lisp_Object *attrs, int signal_p) 2052 Lisp_Object *attrs, int signal_p)
2053{ 2053{
@@ -2069,7 +2069,7 @@ get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name,
2069 non-zero, signal an error if FACE_NAME does not name a face. 2069 non-zero, signal an error if FACE_NAME does not name a face.
2070 Otherwise, value is zero if FACE_NAME is not a face. */ 2070 Otherwise, value is zero if FACE_NAME is not a face. */
2071 2071
2072static inline int 2072static int
2073get_lface_attributes (struct frame *f, Lisp_Object face_name, 2073get_lface_attributes (struct frame *f, Lisp_Object face_name,
2074 Lisp_Object *attrs, int signal_p, 2074 Lisp_Object *attrs, int signal_p,
2075 struct named_merge_point *named_merge_points) 2075 struct named_merge_point *named_merge_points)
@@ -2234,7 +2234,7 @@ merge_face_heights (Lisp_Object from, Lisp_Object to, Lisp_Object invalid)
2234 loops in face inheritance/remapping; it should be 0 when called from 2234 loops in face inheritance/remapping; it should be 0 when called from
2235 other places. */ 2235 other places. */
2236 2236
2237static inline void 2237static void
2238merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to, 2238merge_face_vectors (struct frame *f, Lisp_Object *from, Lisp_Object *to,
2239 struct named_merge_point *named_merge_points) 2239 struct named_merge_point *named_merge_points)
2240{ 2240{
@@ -3906,7 +3906,7 @@ return the font name used for CHARACTER. */)
3906 all attributes are `equal'. Tries to be fast because this function 3906 all attributes are `equal'. Tries to be fast because this function
3907 is called quite often. */ 3907 is called quite often. */
3908 3908
3909static inline int 3909static int
3910face_attr_equal_p (Lisp_Object v1, Lisp_Object v2) 3910face_attr_equal_p (Lisp_Object v1, Lisp_Object v2)
3911{ 3911{
3912 /* Type can differ, e.g. when one attribute is unspecified, i.e. nil, 3912 /* Type can differ, e.g. when one attribute is unspecified, i.e. nil,
@@ -3939,7 +3939,7 @@ face_attr_equal_p (Lisp_Object v1, Lisp_Object v2)
3939 all attributes are `equal'. Tries to be fast because this function 3939 all attributes are `equal'. Tries to be fast because this function
3940 is called quite often. */ 3940 is called quite often. */
3941 3941
3942static inline int 3942static int
3943lface_equal_p (Lisp_Object *v1, Lisp_Object *v2) 3943lface_equal_p (Lisp_Object *v1, Lisp_Object *v2)
3944{ 3944{
3945 int i, equal_p = 1; 3945 int i, equal_p = 1;
@@ -4024,7 +4024,7 @@ For internal use only. */)
4024/* Return a hash code for Lisp string STRING with case ignored. Used 4024/* Return a hash code for Lisp string STRING with case ignored. Used
4025 below in computing a hash value for a Lisp face. */ 4025 below in computing a hash value for a Lisp face. */
4026 4026
4027static inline unsigned 4027static unsigned
4028hash_string_case_insensitive (Lisp_Object string) 4028hash_string_case_insensitive (Lisp_Object string)
4029{ 4029{
4030 const unsigned char *s; 4030 const unsigned char *s;
@@ -4038,7 +4038,7 @@ hash_string_case_insensitive (Lisp_Object string)
4038 4038
4039/* Return a hash code for face attribute vector V. */ 4039/* Return a hash code for face attribute vector V. */
4040 4040
4041static inline unsigned 4041static unsigned
4042lface_hash (Lisp_Object *v) 4042lface_hash (Lisp_Object *v)
4043{ 4043{
4044 return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX]) 4044 return (hash_string_case_insensitive (v[LFACE_FAMILY_INDEX])
@@ -4057,7 +4057,7 @@ lface_hash (Lisp_Object *v)
4057 family, point size, weight, width, slant, and font. Both 4057 family, point size, weight, width, slant, and font. Both
4058 LFACE1 and LFACE2 must be fully-specified. */ 4058 LFACE1 and LFACE2 must be fully-specified. */
4059 4059
4060static inline int 4060static int
4061lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2) 4061lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2)
4062{ 4062{
4063 eassert (lface_fully_specified_p (lface1) 4063 eassert (lface_fully_specified_p (lface1)
@@ -4453,7 +4453,7 @@ uncache_face (struct face_cache *c, struct face *face)
4453 Value is the ID of the face found. If no suitable face is found, 4453 Value is the ID of the face found. If no suitable face is found,
4454 realize a new one. */ 4454 realize a new one. */
4455 4455
4456static inline int 4456static int
4457lookup_face (struct frame *f, Lisp_Object *attr) 4457lookup_face (struct frame *f, Lisp_Object *attr)
4458{ 4458{
4459 struct face_cache *cache = FRAME_FACE_CACHE (f); 4459 struct face_cache *cache = FRAME_FACE_CACHE (f);
diff --git a/src/xfns.c b/src/xfns.c
index 928e6367743..d497cffe3df 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -5344,7 +5344,7 @@ Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
5344selection box, if specified. If MUSTMATCH is non-nil, the returned file 5344selection box, if specified. If MUSTMATCH is non-nil, the returned file
5345or directory must exist. 5345or directory must exist.
5346 5346
5347This function is only defined on MS Windows, and X Windows with the 5347This function is only defined on NS, MS Windows, and X Windows with the
5348Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored. 5348Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
5349Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) 5349Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5350 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) 5350 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
@@ -5517,7 +5517,7 @@ Use a file selection dialog. Select DEFAULT-FILENAME in the dialog's file
5517selection box, if specified. If MUSTMATCH is non-nil, the returned file 5517selection box, if specified. If MUSTMATCH is non-nil, the returned file
5518or directory must exist. 5518or directory must exist.
5519 5519
5520This function is only defined on MS Windows, and X Windows with the 5520This function is only defined on NS, MS Windows, and X Windows with the
5521Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored. 5521Motif or Gtk toolkits. With the Motif toolkit, ONLY-DIR-P is ignored.
5522Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */) 5522Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories. */)
5523 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p) 5523 (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
diff --git a/src/xml.c b/src/xml.c
index a22ca208743..a0c4fe17fc4 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -73,7 +73,7 @@ libxml2_loaded_p (void)
73#define fn_xmlCleanupParser xmlCleanupParser 73#define fn_xmlCleanupParser xmlCleanupParser
74#define fn_xmlCheckVersion xmlCheckVersion 74#define fn_xmlCheckVersion xmlCheckVersion
75 75
76static inline int 76static int
77libxml2_loaded_p (void) 77libxml2_loaded_p (void)
78{ 78{
79 return 1; 79 return 1;
diff --git a/src/xterm.c b/src/xterm.c
index 8b5d3d2a9b3..23685ee8ae6 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -1030,7 +1030,7 @@ x_set_mouse_face_gc (struct glyph_string *s)
1030 Faces to use in the mode line have already been computed when the 1030 Faces to use in the mode line have already been computed when the
1031 matrix was built, so there isn't much to do, here. */ 1031 matrix was built, so there isn't much to do, here. */
1032 1032
1033static inline void 1033static void
1034x_set_mode_line_face_gc (struct glyph_string *s) 1034x_set_mode_line_face_gc (struct glyph_string *s)
1035{ 1035{
1036 s->gc = s->face->gc; 1036 s->gc = s->face->gc;
@@ -1041,7 +1041,7 @@ x_set_mode_line_face_gc (struct glyph_string *s)
1041 S->stippled_p to a non-zero value if the face of S has a stipple 1041 S->stippled_p to a non-zero value if the face of S has a stipple
1042 pattern. */ 1042 pattern. */
1043 1043
1044static inline void 1044static void
1045x_set_glyph_string_gc (struct glyph_string *s) 1045x_set_glyph_string_gc (struct glyph_string *s)
1046{ 1046{
1047 PREPARE_FACE_FOR_DISPLAY (s->f, s->face); 1047 PREPARE_FACE_FOR_DISPLAY (s->f, s->face);
@@ -1086,7 +1086,7 @@ x_set_glyph_string_gc (struct glyph_string *s)
1086/* Set clipping for output of glyph string S. S may be part of a mode 1086/* Set clipping for output of glyph string S. S may be part of a mode
1087 line or menu if we don't have X toolkit support. */ 1087 line or menu if we don't have X toolkit support. */
1088 1088
1089static inline void 1089static void
1090x_set_glyph_string_clipping (struct glyph_string *s) 1090x_set_glyph_string_clipping (struct glyph_string *s)
1091{ 1091{
1092 XRectangle *r = s->clip; 1092 XRectangle *r = s->clip;
@@ -1159,7 +1159,7 @@ x_compute_glyph_string_overhangs (struct glyph_string *s)
1159 1159
1160/* Fill rectangle X, Y, W, H with background color of glyph string S. */ 1160/* Fill rectangle X, Y, W, H with background color of glyph string S. */
1161 1161
1162static inline void 1162static void
1163x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h) 1163x_clear_glyph_string_rect (struct glyph_string *s, int x, int y, int w, int h)
1164{ 1164{
1165 XGCValues xgcv; 1165 XGCValues xgcv;