aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Raeburn2001-10-16 09:09:51 +0000
committerKen Raeburn2001-10-16 09:09:51 +0000
commitf3fbd1553534bb85c75baf891c0ca9aaa4c3fa6f (patch)
tree43eb51ff0ca4af1705387403827ef210098f2da8
parent018ba359ab456f6a43f3acea0c15df616aa0ad02 (diff)
downloademacs-f3fbd1553534bb85c75baf891c0ca9aaa4c3fa6f.tar.gz
emacs-f3fbd1553534bb85c75baf891c0ca9aaa4c3fa6f.zip
Avoid (most) uses of XCAR/XCDR as lvalues, for flexibility in experimenting
with lisp system changes.
-rw-r--r--src/ChangeLog78
-rw-r--r--src/alloc.c19
-rw-r--r--src/buffer.c30
-rw-r--r--src/callint.c6
-rw-r--r--src/ccl.c2
-rw-r--r--src/coding.c2
-rw-r--r--src/composite.c10
-rw-r--r--src/data.c22
-rw-r--r--src/doc.c2
-rw-r--r--src/fileio.c6
-rw-r--r--src/fns.c8
-rw-r--r--src/fontset.c16
-rw-r--r--src/frame.c2
-rw-r--r--src/indent.c12
-rw-r--r--src/keyboard.c62
-rw-r--r--src/keyboard.h1
-rw-r--r--src/keymap.c46
-rw-r--r--src/lisp.h64
-rw-r--r--src/lread.c21
-rw-r--r--src/minibuf.c2
-rw-r--r--src/process.c32
-rw-r--r--src/search.c6
-rw-r--r--src/textprop.c2
-rw-r--r--src/undo.c6
-rw-r--r--src/w32fns.c14
-rw-r--r--src/w32term.c2
-rw-r--r--src/xfaces.c6
-rw-r--r--src/xselect.c20
-rw-r--r--src/xterm.c40
29 files changed, 348 insertions, 191 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 9eb34feec54..6667b6054fe 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,81 @@
12001-10-16 Ken Raeburn <raeburn@gnu.org>
2
3 Avoid the assumption that car and cdr slots of cons cells are
4 addressable lvalues; this allows for easier experimentation with
5 other lisp implementations that may not permit such accesses for
6 various reasons. Not quite complete -- buffer.c still needs some
7 work, and w32/mac files need rechecking -- so compile-time
8 enforcement is left disabled for now.
9
10 * lisp.h (LISP_MAKE_RVALUE): New macro, or function in the case of
11 gcc with a union-based Lisp object rep. Redefine as no-op for
12 now.
13 (XCAR_AS_LVALUE, XCDR_AS_LVALUE): Rename from old XCAR, XCDR.
14 (XCAR, XCDR): Apply LISP_MAKE_RVALUE to the _AS_LVALUE versions.
15 (XSETCAR, XSETCDR): New macros.
16 (XSETCARFASTINT, XSETCDRFASTINT): New macros.
17 (CHECK_NUMBER_CAR, CHECK_NUMBER_CDR): New macros.
18 * keyboard.h (POSN_BUFFER_SET_POSN): New macro.
19 * alloc.c (Fcons, pure_cons, Fgarbage_collect): Use XSETCAR and
20 XSETCDR.
21 (mark_buffer): Use XCAR_AS_LVALUE, XCDR_AS_LVALUE.
22 * buffer.c (record_buffer, Fbury_buffer,
23 swap_out_buffer_local_variables, recenter_overlay_lists,
24 Foverlay_put): Use XSETCAR and XSETCDR to set the car and cdr
25 fields of a cons cell respectively.
26 * callint.c (quotify_args, Fcall_interactively): Likewise.
27 * ccl.c (Fregister_code_conversion_map): Likewise.
28 * coding.c (detect_coding_system): Likewise.
29 * composite.c (get_composition_id, make_composition_value_copy):
30 Likewise.
31 * data.c (Fsetcar, Fsetcdr, swap_in_global_binding,
32 swap_in_symval_forwarding, set_internal, Fset_default,
33 Fmake_variable_buffer_local, Fmake_local_variable,
34 Fmake_variable_frame_local): Likewise.
35 * fns.c (concat, Fcopy_alist, Fwidget_put): Likewise.
36 * keymap.c (Fset_keymap_parent, store_in_keymap,
37 accessible_keymaps_1, where_is_internal_2, Fcopy_keymap):
38 Likewise.
39 * minibuf.c (get_minibuffer): Likewise.
40 * search.c (Fmatch_data): Likewise.
41 * textprop.c (extend_property_ranges): Likewise.
42 * undo.c (record_insert, Fundo_boundary, truncate_undo_list):
43 Likewise.
44 * w32fns.c (w32_msg_pump, Fw32_register_hot_key, w32_list_fonts):
45 Likewise.
46 * w32term.c (x_delete_display): Likewise.
47 * xfaces.c (remove_duplicates, Finternal_set_lisp_face_attribute):
48 Likewise.
49 * xterm.c (x_list_fonts, x_load_font, x_delete_display):
50 Likewise.
51 * doc.c (store_function_docstring): Use XSETCARFASTINT.
52 * fileio.c (Fdo_auto_save): Use XSETCARFASTINT and
53 XSETCDRFASTINT.
54 (Fread_file_name): Use XSETCAR.
55 * fontset.c (Fset_fontset_font): Use CHECK_NUMBER_CAR and
56 CHECK_NUMBER_CDR.
57 (accumulate_font_info, Ffontset_info): Use XSETCAR and XSETCDR.
58 * frame.c (Fmake_terminal_frame): Use XSETCDR.
59 * indent.c (Fcompute_motion): Use CHECK_NUMBER_CAR and
60 CHECK_NUMBER_CDR.
61 * keyboard.c (read_char): Alter list traversal to avoid taking the
62 address of cons cell slots. Use POSN_BUFFER_SET_POSN.
63 (parse_menu_item): Use XSETCAR and XSETCDR.
64 (reach_char_x_menu_prompt): Use XSETCAR.
65 (read_key_sequence): Use POSN_BUFFER_SET_POSN.
66 (Fcommand_execute): Use XSETCDR.
67 * lread.c (Fload): Use XSETCARFASTINT and XSETCDRFASTINT.
68 (openp): Change list traversal to avoid using XCAR as lvalue.
69 (read_list): Use XSETCDR.
70 * process.c (wait_reading_process_input): Change wait_for_cell
71 handling to avoid taking addresses of cons cell slots.
72 * xselect.c (x_own_selection, x_handle_selection_clear,
73 x_clear_frame_selections): Use XSETCDR.
74 (wait_for_property_change): Use XSETCARFASTINT and
75 XSETCDRFASTINT.
76 (x_handle_property_notify, x_get_foreign_selection,
77 x_handle_selection_notify): Use XSETCAR.
78
12001-10-15 Pavel Jan,Bm(Bk <Pavel@Janik.cz> 792001-10-15 Pavel Jan,Bm(Bk <Pavel@Janik.cz>
2 80
3 * buffer.c: Put doc strings in comments. 81 * buffer.c: Put doc strings in comments.
diff --git a/src/alloc.c b/src/alloc.c
index 3a9dcc3c59d..a7780e9ad91 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -2087,8 +2087,8 @@ DEFUN ("cons", Fcons, Scons, 2, 2, 0,
2087 XSETCONS (val, &cons_block->conses[cons_block_index++]); 2087 XSETCONS (val, &cons_block->conses[cons_block_index++]);
2088 } 2088 }
2089 2089
2090 XCAR (val) = car; 2090 XSETCAR (val, car);
2091 XCDR (val) = cdr; 2091 XSETCDR (val, cdr);
2092 consing_since_gc += sizeof (struct Lisp_Cons); 2092 consing_since_gc += sizeof (struct Lisp_Cons);
2093 cons_cells_consed++; 2093 cons_cells_consed++;
2094 return val; 2094 return val;
@@ -3878,8 +3878,8 @@ pure_cons (car, cdr)
3878 3878
3879 p = (struct Lisp_Cons *) pure_alloc (sizeof *p, Lisp_Cons); 3879 p = (struct Lisp_Cons *) pure_alloc (sizeof *p, Lisp_Cons);
3880 XSETCONS (new, p); 3880 XSETCONS (new, p);
3881 XCAR (new) = Fpurecopy (car); 3881 XSETCAR (new, Fpurecopy (car));
3882 XCDR (new) = Fpurecopy (cdr); 3882 XSETCDR (new, Fpurecopy (cdr));
3883 return new; 3883 return new;
3884} 3884}
3885 3885
@@ -4189,7 +4189,10 @@ Garbage collection happens automatically if you cons more than
4189 if (NILP (prev)) 4189 if (NILP (prev))
4190 nextb->undo_list = tail = XCDR (tail); 4190 nextb->undo_list = tail = XCDR (tail);
4191 else 4191 else
4192 tail = XCDR (prev) = XCDR (tail); 4192 {
4193 tail = XCDR (tail);
4194 XSETCDR (prev, tail);
4195 }
4193 } 4196 }
4194 else 4197 else
4195 { 4198 {
@@ -4800,8 +4803,8 @@ mark_buffer (buf)
4800 && ! XMARKBIT (XCAR (ptr->car)) 4803 && ! XMARKBIT (XCAR (ptr->car))
4801 && GC_MARKERP (XCAR (ptr->car))) 4804 && GC_MARKERP (XCAR (ptr->car)))
4802 { 4805 {
4803 XMARK (XCAR (ptr->car)); 4806 XMARK (XCAR_AS_LVALUE (ptr->car));
4804 mark_object (&XCDR (ptr->car)); 4807 mark_object (&XCDR_AS_LVALUE (ptr->car));
4805 } 4808 }
4806 else 4809 else
4807 mark_object (&ptr->car); 4810 mark_object (&ptr->car);
@@ -4812,7 +4815,7 @@ mark_buffer (buf)
4812 break; 4815 break;
4813 } 4816 }
4814 4817
4815 mark_object (&XCDR (tail)); 4818 mark_object (&XCDR_AS_LVALUE (tail));
4816 } 4819 }
4817 else 4820 else
4818 mark_object (&buffer->undo_list); 4821 mark_object (&buffer->undo_list);
diff --git a/src/buffer.c b/src/buffer.c
index e3c3c4c4524..5fd52c8cbaa 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1415,9 +1415,9 @@ record_buffer (buf)
1415 if (NILP (prev)) 1415 if (NILP (prev))
1416 Vbuffer_alist = XCDR (Vbuffer_alist); 1416 Vbuffer_alist = XCDR (Vbuffer_alist);
1417 else 1417 else
1418 XCDR (prev) = XCDR (XCDR (prev)); 1418 XSETCDR (prev, XCDR (XCDR (prev)));
1419 1419
1420 XCDR (link) = Vbuffer_alist; 1420 XSETCDR (link, Vbuffer_alist);
1421 Vbuffer_alist = link; 1421 Vbuffer_alist = link;
1422 1422
1423 /* Now move this buffer to the front of frame_buffer_list also. */ 1423 /* Now move this buffer to the front of frame_buffer_list also. */
@@ -1439,9 +1439,9 @@ record_buffer (buf)
1439 set_frame_buffer_list (frame, 1439 set_frame_buffer_list (frame,
1440 XCDR (frame_buffer_list (frame))); 1440 XCDR (frame_buffer_list (frame)));
1441 else 1441 else
1442 XCDR (prev) = XCDR (XCDR (prev)); 1442 XSETCDR (prev, XCDR (XCDR (prev)));
1443 1443
1444 XCDR (link) = frame_buffer_list (frame); 1444 XSETCDR (link, frame_buffer_list (frame));
1445 set_frame_buffer_list (frame, link); 1445 set_frame_buffer_list (frame, link);
1446 } 1446 }
1447 else 1447 else
@@ -1863,7 +1863,7 @@ selected window if it is displayed there. */
1863 aelt = Frassq (buffer, Vbuffer_alist); 1863 aelt = Frassq (buffer, Vbuffer_alist);
1864 link = Fmemq (aelt, Vbuffer_alist); 1864 link = Fmemq (aelt, Vbuffer_alist);
1865 Vbuffer_alist = Fdelq (aelt, Vbuffer_alist); 1865 Vbuffer_alist = Fdelq (aelt, Vbuffer_alist);
1866 XCDR (link) = Qnil; 1866 XSETCDR (link, Qnil);
1867 Vbuffer_alist = nconc2 (Vbuffer_alist, link); 1867 Vbuffer_alist = nconc2 (Vbuffer_alist, link);
1868 1868
1869 frames_bury_buffer (buffer); 1869 frames_bury_buffer (buffer);
@@ -2286,10 +2286,10 @@ swap_out_buffer_local_variables (b)
2286 it is currently set up for. This is so that, if the 2286 it is currently set up for. This is so that, if the
2287 local is marked permanent, and we make it local again 2287 local is marked permanent, and we make it local again
2288 later in Fkill_all_local_variables, we don't lose the value. */ 2288 later in Fkill_all_local_variables, we don't lose the value. */
2289 XCDR (XCAR (tem)) 2289 XSETCDR (XCAR (tem),
2290 = do_symval_forwarding (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue); 2290 do_symval_forwarding (XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->realvalue));
2291 /* Switch to the symbol's default-value alist entry. */ 2291 /* Switch to the symbol's default-value alist entry. */
2292 XCAR (tem) = tem; 2292 XSETCAR (tem, tem);
2293 /* Mark it as current for buffer B. */ 2293 /* Mark it as current for buffer B. */
2294 XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer = buffer; 2294 XBUFFER_LOCAL_VALUE (SYMBOL_VALUE (sym))->buffer = buffer;
2295 /* Store the current value into any forwarding in the symbol. */ 2295 /* Store the current value into any forwarding in the symbol. */
@@ -3008,7 +3008,7 @@ recenter_overlay_lists (buf, pos)
3008 3008
3009 /* Splice the cons cell TAIL out of overlays_before. */ 3009 /* Splice the cons cell TAIL out of overlays_before. */
3010 if (!NILP (prev)) 3010 if (!NILP (prev))
3011 XCDR (prev) = next; 3011 XSETCDR (prev, next);
3012 else 3012 else
3013 buf->overlays_before = next; 3013 buf->overlays_before = next;
3014 3014
@@ -3030,9 +3030,9 @@ recenter_overlay_lists (buf, pos)
3030 } 3030 }
3031 3031
3032 /* Add TAIL to overlays_after before OTHER. */ 3032 /* Add TAIL to overlays_after before OTHER. */
3033 XCDR (tail) = other; 3033 XSETCDR (tail, other);
3034 if (!NILP (other_prev)) 3034 if (!NILP (other_prev))
3035 XCDR (other_prev) = tail; 3035 XSETCDR (other_prev, tail);
3036 else 3036 else
3037 buf->overlays_after = tail; 3037 buf->overlays_after = tail;
3038 tail = prev; 3038 tail = prev;
@@ -3085,7 +3085,7 @@ recenter_overlay_lists (buf, pos)
3085 3085
3086 /* Splice the cons cell TAIL out of overlays_after. */ 3086 /* Splice the cons cell TAIL out of overlays_after. */
3087 if (!NILP (prev)) 3087 if (!NILP (prev))
3088 XCDR (prev) = next; 3088 XSETCDR (prev, next);
3089 else 3089 else
3090 buf->overlays_after = next; 3090 buf->overlays_after = next;
3091 3091
@@ -3107,9 +3107,9 @@ recenter_overlay_lists (buf, pos)
3107 } 3107 }
3108 3108
3109 /* Add TAIL to overlays_before before OTHER. */ 3109 /* Add TAIL to overlays_before before OTHER. */
3110 XCDR (tail) = other; 3110 XSETCDR (tail, other);
3111 if (!NILP (other_prev)) 3111 if (!NILP (other_prev))
3112 XCDR (other_prev) = tail; 3112 XSETCDR (other_prev, tail);
3113 else 3113 else
3114 buf->overlays_before = tail; 3114 buf->overlays_before = tail;
3115 tail = prev; 3115 tail = prev;
@@ -3841,7 +3841,7 @@ DEFUN ("overlay-put", Foverlay_put, Soverlay_put, 3, 3, 0,
3841 if (EQ (XCAR (tail), prop)) 3841 if (EQ (XCAR (tail), prop))
3842 { 3842 {
3843 changed = !EQ (XCAR (XCDR (tail)), value); 3843 changed = !EQ (XCAR (XCDR (tail)), value);
3844 XCAR (XCDR (tail)) = value; 3844 XSETCAR (XCDR (tail), value);
3845 goto found; 3845 goto found;
3846 } 3846 }
3847 /* It wasn't in the list, so add it to the front. */ 3847 /* It wasn't in the list, so add it to the front. */
diff --git a/src/callint.c b/src/callint.c
index 54ad0c2cf7e..329911cda6e 100644
--- a/src/callint.c
+++ b/src/callint.c
@@ -156,7 +156,7 @@ quotify_args (exp)
156 for (tail = exp; CONSP (tail); tail = next) 156 for (tail = exp; CONSP (tail); tail = next)
157 { 157 {
158 next = XCDR (tail); 158 next = XCDR (tail);
159 XCAR (tail) = quotify_arg (XCAR (tail)); 159 XSETCAR (tail, quotify_arg (XCAR (tail)));
160 } 160 }
161 return exp; 161 return exp;
162} 162}
@@ -358,7 +358,7 @@ supply if the command inquires which events were used to invoke it.")
358 { 358 {
359 teml = Fnthcdr (Vhistory_length, Vcommand_history); 359 teml = Fnthcdr (Vhistory_length, Vcommand_history);
360 if (CONSP (teml)) 360 if (CONSP (teml))
361 XCDR (teml) = Qnil; 361 XSETCDR (teml, Qnil);
362 } 362 }
363 } 363 }
364 single_kboard_state (); 364 single_kboard_state ();
@@ -776,7 +776,7 @@ supply if the command inquires which events were used to invoke it.")
776 { 776 {
777 teml = Fnthcdr (Vhistory_length, Vcommand_history); 777 teml = Fnthcdr (Vhistory_length, Vcommand_history);
778 if (CONSP (teml)) 778 if (CONSP (teml))
779 XCDR (teml) = Qnil; 779 XSETCDR (teml, Qnil);
780 } 780 }
781 } 781 }
782 782
diff --git a/src/ccl.c b/src/ccl.c
index d3879abae6b..52a4ff3c388 100644
--- a/src/ccl.c
+++ b/src/ccl.c
@@ -2274,7 +2274,7 @@ Return index number of the registered map.")
2274 if (EQ (symbol, XCAR (slot))) 2274 if (EQ (symbol, XCAR (slot)))
2275 { 2275 {
2276 index = make_number (i); 2276 index = make_number (i);
2277 XCDR (slot) = map; 2277 XSETCDR (slot, map);
2278 Fput (symbol, Qcode_conversion_map, map); 2278 Fput (symbol, Qcode_conversion_map, map);
2279 Fput (symbol, Qcode_conversion_map_id, index); 2279 Fput (symbol, Qcode_conversion_map_id, index);
2280 return index; 2280 return index;
diff --git a/src/coding.c b/src/coding.c
index 43f1867d9f8..08da1ae3dbb 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -6212,7 +6212,7 @@ detect_coding_system (src, src_bytes, highest, multibytep)
6212 Lisp_Object eol; 6212 Lisp_Object eol;
6213 eol = Fget (XCAR (tmp), Qeol_type); 6213 eol = Fget (XCAR (tmp), Qeol_type);
6214 if (VECTORP (eol)) 6214 if (VECTORP (eol))
6215 XCAR (tmp) = XVECTOR (eol)->contents[eol_type]; 6215 XSETCAR (tmp, XVECTOR (eol)->contents[eol_type]);
6216 } 6216 }
6217 } 6217 }
6218 return (highest ? XCAR (val) : val); 6218 return (highest ? XCAR (val) : val);
diff --git a/src/composite.c b/src/composite.c
index c3bf6878ce3..ff6d1a5ba34 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -249,8 +249,8 @@ get_composition_id (charpos, bytepos, nchars, prop, string)
249 modify the cons cell of PROP because it is not shared. */ 249 modify the cons cell of PROP because it is not shared. */
250 key = HASH_KEY (hash_table, hash_index); 250 key = HASH_KEY (hash_table, hash_index);
251 id = HASH_VALUE (hash_table, hash_index); 251 id = HASH_VALUE (hash_table, hash_index);
252 XCAR (prop) = id; 252 XSETCAR (prop, id);
253 XCDR (prop) = Fcons (make_number (nchars), Fcons (key, XCDR (prop))); 253 XSETCDR (prop, Fcons (make_number (nchars), Fcons (key, XCDR (prop))));
254 return XINT (id); 254 return XINT (id);
255 } 255 }
256 256
@@ -297,8 +297,8 @@ get_composition_id (charpos, bytepos, nchars, prop, string)
297 /* Change PROP from Form-A above to Form-B. We can directly modify 297 /* Change PROP from Form-A above to Form-B. We can directly modify
298 the cons cell of PROP because it is not shared. */ 298 the cons cell of PROP because it is not shared. */
299 XSETFASTINT (id, n_compositions); 299 XSETFASTINT (id, n_compositions);
300 XCAR (prop) = id; 300 XSETCAR (prop, id);
301 XCDR (prop) = Fcons (make_number (nchars), Fcons (key, XCDR (prop))); 301 XSETCDR (prop, Fcons (make_number (nchars), Fcons (key, XCDR (prop))));
302 302
303 /* Register the composition in composition_hash_table. */ 303 /* Register the composition in composition_hash_table. */
304 hash_index = hash_put (hash_table, key, id, hash_code); 304 hash_index = hash_put (hash_table, key, id, hash_code);
@@ -569,7 +569,7 @@ make_composition_value_copy (list)
569 { 569 {
570 if (EQ (XCAR (plist), Qcomposition) 570 if (EQ (XCAR (plist), Qcomposition)
571 && (val = XCAR (XCDR (plist)), CONSP (val))) 571 && (val = XCAR (XCDR (plist)), CONSP (val)))
572 XCAR (XCDR (plist)) = Fcons (XCAR (val), XCDR (val)); 572 XSETCAR (XCDR (plist), Fcons (XCAR (val), XCDR (val)));
573 plist = XCDR (XCDR (plist)); 573 plist = XCDR (XCDR (plist));
574 } 574 }
575 } 575 }
diff --git a/src/data.c b/src/data.c
index 336afa98d8c..e56512370e0 100644
--- a/src/data.c
+++ b/src/data.c
@@ -582,7 +582,7 @@ DEFUN ("setcar", Fsetcar, Ssetcar, 2, 2, 0,
582 cell = wrong_type_argument (Qconsp, cell); 582 cell = wrong_type_argument (Qconsp, cell);
583 583
584 CHECK_IMPURE (cell); 584 CHECK_IMPURE (cell);
585 XCAR (cell) = newcar; 585 XSETCAR (cell, newcar);
586 return newcar; 586 return newcar;
587} 587}
588 588
@@ -595,7 +595,7 @@ DEFUN ("setcdr", Fsetcdr, Ssetcdr, 2, 2, 0,
595 cell = wrong_type_argument (Qconsp, cell); 595 cell = wrong_type_argument (Qconsp, cell);
596 596
597 CHECK_IMPURE (cell); 597 CHECK_IMPURE (cell);
598 XCDR (cell) = newcdr; 598 XSETCDR (cell, newcdr);
599 return newcdr; 599 return newcdr;
600} 600}
601 601
@@ -937,7 +937,7 @@ swap_in_global_binding (symbol)
937 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue)); 937 do_symval_forwarding (XBUFFER_LOCAL_VALUE (valcontents)->realvalue));
938 938
939 /* Select the global binding in the symbol. */ 939 /* Select the global binding in the symbol. */
940 XCAR (cdr) = cdr; 940 XSETCAR (cdr, cdr);
941 store_symval_forwarding (symbol, valcontents, XCDR (cdr), NULL); 941 store_symval_forwarding (symbol, valcontents, XCDR (cdr), NULL);
942 942
943 /* Indicate that the global binding is set up now. */ 943 /* Indicate that the global binding is set up now. */
@@ -991,7 +991,7 @@ swap_in_symval_forwarding (symbol, valcontents)
991 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 1; 991 XBUFFER_LOCAL_VALUE (valcontents)->found_for_buffer = 1;
992 992
993 /* Load the new binding. */ 993 /* Load the new binding. */
994 XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr) = tem1; 994 XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, tem1);
995 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, current_buffer); 995 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, current_buffer);
996 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame; 996 XBUFFER_LOCAL_VALUE (valcontents)->frame = selected_frame;
997 store_symval_forwarding (symbol, 997 store_symval_forwarding (symbol,
@@ -1210,8 +1210,8 @@ set_internal (symbol, newval, buf, bindflag)
1210 } 1210 }
1211 1211
1212 /* Record which binding is now loaded. */ 1212 /* Record which binding is now loaded. */
1213 XCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr) 1213 XSETCAR (XBUFFER_LOCAL_VALUE (valcontents)->cdr,
1214 = tem1; 1214 tem1);
1215 1215
1216 /* Set `buffer' and `frame' slots for thebinding now loaded. */ 1216 /* Set `buffer' and `frame' slots for thebinding now loaded. */
1217 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, buf); 1217 XSETBUFFER (XBUFFER_LOCAL_VALUE (valcontents)->buffer, buf);
@@ -1243,7 +1243,7 @@ set_internal (symbol, newval, buf, bindflag)
1243 the default binding is loaded, the loaded binding may be the 1243 the default binding is loaded, the loaded binding may be the
1244 wrong one. */ 1244 wrong one. */
1245 if (XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame) 1245 if (XBUFFER_LOCAL_VALUE (valcontents)->found_for_frame)
1246 XCDR (current_alist_element) = newval; 1246 XSETCDR (current_alist_element, newval);
1247 } 1247 }
1248 1248
1249 return newval; 1249 return newval;
@@ -1362,7 +1362,7 @@ for this variable.")
1362 return Fset (symbol, value); 1362 return Fset (symbol, value);
1363 1363
1364 /* Store new value into the DEFAULT-VALUE slot. */ 1364 /* Store new value into the DEFAULT-VALUE slot. */
1365 XCDR (XBUFFER_LOCAL_VALUE (valcontents)->cdr) = value; 1365 XSETCDR (XBUFFER_LOCAL_VALUE (valcontents)->cdr, value);
1366 1366
1367 /* If the default binding is now loaded, set the REALVALUE slot too. */ 1367 /* If the default binding is now loaded, set the REALVALUE slot too. */
1368 current_alist_element 1368 current_alist_element
@@ -1448,7 +1448,7 @@ The function `default-value' gets the default value and `set-default' sets it.")
1448 if (EQ (valcontents, Qunbound)) 1448 if (EQ (valcontents, Qunbound))
1449 SET_SYMBOL_VALUE (variable, Qnil); 1449 SET_SYMBOL_VALUE (variable, Qnil);
1450 tem = Fcons (Qnil, Fsymbol_value (variable)); 1450 tem = Fcons (Qnil, Fsymbol_value (variable));
1451 XCAR (tem) = tem; 1451 XSETCAR (tem, tem);
1452 newval = allocate_misc (); 1452 newval = allocate_misc ();
1453 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value; 1453 XMISCTYPE (newval) = Lisp_Misc_Buffer_Local_Value;
1454 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); 1454 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
@@ -1505,7 +1505,7 @@ Use `make-local-hook' instead.")
1505 { 1505 {
1506 Lisp_Object newval; 1506 Lisp_Object newval;
1507 tem = Fcons (Qnil, do_symval_forwarding (valcontents)); 1507 tem = Fcons (Qnil, do_symval_forwarding (valcontents));
1508 XCAR (tem) = tem; 1508 XSETCAR (tem, tem);
1509 newval = allocate_misc (); 1509 newval = allocate_misc ();
1510 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; 1510 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value;
1511 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); 1511 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
@@ -1644,7 +1644,7 @@ See `modify-frame-parameters'.")
1644 if (EQ (valcontents, Qunbound)) 1644 if (EQ (valcontents, Qunbound))
1645 SET_SYMBOL_VALUE (variable, Qnil); 1645 SET_SYMBOL_VALUE (variable, Qnil);
1646 tem = Fcons (Qnil, Fsymbol_value (variable)); 1646 tem = Fcons (Qnil, Fsymbol_value (variable));
1647 XCAR (tem) = tem; 1647 XSETCAR (tem, tem);
1648 newval = allocate_misc (); 1648 newval = allocate_misc ();
1649 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value; 1649 XMISCTYPE (newval) = Lisp_Misc_Some_Buffer_Local_Value;
1650 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable); 1650 XBUFFER_LOCAL_VALUE (newval)->realvalue = SYMBOL_VALUE (variable);
diff --git a/src/doc.c b/src/doc.c
index 09f377bb1af..39cffee19cb 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -445,7 +445,7 @@ store_function_docstring (fun, offset)
445 { 445 {
446 tem = Fcdr (Fcdr (fun)); 446 tem = Fcdr (Fcdr (fun));
447 if (CONSP (tem) && INTEGERP (XCAR (tem))) 447 if (CONSP (tem) && INTEGERP (XCAR (tem)))
448 XSETFASTINT (XCAR (tem), offset); 448 XSETCARFASTINT (tem, offset);
449 } 449 }
450 else if (EQ (tem, Qmacro)) 450 else if (EQ (tem, Qmacro))
451 store_function_docstring (XCDR (fun), offset); 451 store_function_docstring (XCDR (fun), offset);
diff --git a/src/fileio.c b/src/fileio.c
index 0a726a4a01a..e7b9b0aa3db 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -5499,8 +5499,8 @@ A non-nil CURRENT-ONLY argument means save only current buffer.")
5499 /* Arrange to close that file whether or not we get an error. 5499 /* Arrange to close that file whether or not we get an error.
5500 Also reset auto_saving to 0. */ 5500 Also reset auto_saving to 0. */
5501 lispstream = Fcons (Qnil, Qnil); 5501 lispstream = Fcons (Qnil, Qnil);
5502 XSETFASTINT (XCAR (lispstream), (EMACS_UINT)stream >> 16); 5502 XSETCARFASTINT (lispstream, (EMACS_UINT)stream >> 16);
5503 XSETFASTINT (XCDR (lispstream), (EMACS_UINT)stream & 0xffff); 5503 XSETCDRFASTINT (lispstream, (EMACS_UINT)stream & 0xffff);
5504 } 5504 }
5505 else 5505 else
5506 lispstream = Qnil; 5506 lispstream = Qnil;
@@ -5939,7 +5939,7 @@ provides a file dialog box..")
5939 if (replace_in_history) 5939 if (replace_in_history)
5940 /* Replace what Fcompleting_read added to the history 5940 /* Replace what Fcompleting_read added to the history
5941 with what we will actually return. */ 5941 with what we will actually return. */
5942 XCAR (Fsymbol_value (Qfile_name_history)) = double_dollars (val); 5942 XSETCAR (Fsymbol_value (Qfile_name_history), double_dollars (val));
5943 else if (add_to_history) 5943 else if (add_to_history)
5944 { 5944 {
5945 /* Add the value to the history--but not if it matches 5945 /* Add the value to the history--but not if it matches
diff --git a/src/fns.c b/src/fns.c
index 7a43057ae72..e293d446511 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -782,7 +782,7 @@ concat (nargs, args, target_type, last_special)
782 /* Store this element into the result. */ 782 /* Store this element into the result. */
783 if (toindex < 0) 783 if (toindex < 0)
784 { 784 {
785 XCAR (tail) = elt; 785 XSETCAR (tail, elt);
786 prev = tail; 786 prev = tail;
787 tail = XCDR (tail); 787 tail = XCDR (tail);
788 } 788 }
@@ -823,7 +823,7 @@ concat (nargs, args, target_type, last_special)
823 } 823 }
824 } 824 }
825 if (!NILP (prev)) 825 if (!NILP (prev))
826 XCDR (prev) = last_tail; 826 XSETCDR (prev, last_tail);
827 827
828 if (num_textprops > 0) 828 if (num_textprops > 0)
829 { 829 {
@@ -1159,7 +1159,7 @@ Elements of ALIST that are not conses are also shared. */
1159 car = XCAR (tem); 1159 car = XCAR (tem);
1160 1160
1161 if (CONSP (car)) 1161 if (CONSP (car))
1162 XCAR (tem) = Fcons (XCAR (car), XCDR (car)); 1162 XSETCAR (tem, Fcons (XCAR (car), XCDR (car)));
1163 } 1163 }
1164 return alist; 1164 return alist;
1165} 1165}
@@ -3153,7 +3153,7 @@ The value can later be retrieved with `widget-get'. */
3153 Lisp_Object widget, property, value; 3153 Lisp_Object widget, property, value;
3154{ 3154{
3155 CHECK_CONS (widget, 1); 3155 CHECK_CONS (widget, 1);
3156 XCDR (widget) = Fplist_put (XCDR (widget), property, value); 3156 XSETCDR (widget, Fplist_put (XCDR (widget), property, value));
3157 return value; 3157 return value;
3158} 3158}
3159 3159
diff --git a/src/fontset.c b/src/fontset.c
index 5e359ddef8f..983222f4bb7 100644
--- a/src/fontset.c
+++ b/src/fontset.c
@@ -994,8 +994,8 @@ name of a font, REGSITRY is a registry name of a font.")
994 { 994 {
995 /* CH should be (FROM . TO) where FROM and TO are non-generic 995 /* CH should be (FROM . TO) where FROM and TO are non-generic
996 characters. */ 996 characters. */
997 CHECK_NUMBER (XCAR (character), 1); 997 CHECK_NUMBER_CAR (character, 1);
998 CHECK_NUMBER (XCDR (character), 1); 998 CHECK_NUMBER_CDR (character, 1);
999 from = XINT (XCAR (character)); 999 from = XINT (XCAR (character));
1000 to = XINT (XCDR (character)); 1000 to = XINT (XCDR (character));
1001 if (!char_valid_p (from, 0) || !char_valid_p (to, 0)) 1001 if (!char_valid_p (from, 0) || !char_valid_p (to, 0))
@@ -1214,7 +1214,7 @@ accumulate_font_info (arg, character, elt)
1214 { 1214 {
1215 if (this_charset == CHAR_CHARSET (XINT (XCAR (last_char)))) 1215 if (this_charset == CHAR_CHARSET (XINT (XCAR (last_char))))
1216 { 1216 {
1217 XCDR (last_char) = character; 1217 XSETCDR (last_char, character);
1218 return; 1218 return;
1219 } 1219 }
1220 } 1220 }
@@ -1222,12 +1222,12 @@ accumulate_font_info (arg, character, elt)
1222 return; 1222 return;
1223 else if (this_charset == CHAR_CHARSET (XINT (last_char))) 1223 else if (this_charset == CHAR_CHARSET (XINT (last_char)))
1224 { 1224 {
1225 XCAR (XCAR (last)) = Fcons (last_char, character); 1225 XSETCAR (XCAR (last), Fcons (last_char, character));
1226 return; 1226 return;
1227 } 1227 }
1228 } 1228 }
1229 XCDR (last) = Fcons (Fcons (character, Fcons (elt, Qnil)), Qnil); 1229 XSETCDR (last, Fcons (Fcons (character, Fcons (elt, Qnil)), Qnil));
1230 XCAR (arg) = XCDR (last); 1230 XSETCAR (arg, XCDR (last));
1231} 1231}
1232 1232
1233 1233
@@ -1306,7 +1306,7 @@ If FRAME is omitted, it defaults to the currently selected frame.")
1306 c = XINT (XCAR (elt)); 1306 c = XINT (XCAR (elt));
1307 SPLIT_CHAR (c, charset, c1, c2); 1307 SPLIT_CHAR (c, charset, c1, c2);
1308 if (c1 == 0) 1308 if (c1 == 0)
1309 XCAR (elt) = CHARSET_SYMBOL (charset); 1309 XSETCAR (elt, CHARSET_SYMBOL (charset));
1310 } 1310 }
1311 else 1311 else
1312 c = XINT (XCAR (XCAR (elt))); 1312 c = XINT (XCAR (XCAR (elt)));
@@ -1323,7 +1323,7 @@ If FRAME is omitted, it defaults to the currently selected frame.")
1323 { 1323 {
1324 font = build_string (face->font_name); 1324 font = build_string (face->font_name);
1325 if (NILP (Fmember (font, XCDR (XCDR (elt))))) 1325 if (NILP (Fmember (font, XCDR (XCDR (elt)))))
1326 XCDR (XCDR (elt)) = Fcons (font, XCDR (XCDR (elt))); 1326 XSETCDR (XCDR (elt), Fcons (font, XCDR (XCDR (elt))));
1327 } 1327 }
1328 } 1328 }
1329 } 1329 }
diff --git a/src/frame.c b/src/frame.c
index f6a4ee8e2cf..2bed16b9503 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -543,7 +543,7 @@ Note that changing the size of one terminal frame automatically affects all.")
543 the vectors which are the CDRs of associations in face_alist to 543 the vectors which are the CDRs of associations in face_alist to
544 be copied as well. */ 544 be copied as well. */
545 for (tem = f->face_alist; CONSP (tem); tem = XCDR (tem)) 545 for (tem = f->face_alist; CONSP (tem); tem = XCDR (tem))
546 XCDR (XCAR (tem)) = Fcopy_sequence (XCDR (XCAR (tem))); 546 XSETCDR (XCAR (tem), Fcopy_sequence (XCDR (XCAR (tem))));
547 return frame; 547 return frame;
548} 548}
549 549
diff --git a/src/indent.c b/src/indent.c
index d8ede2ad0e8..95e16d1fa56 100644
--- a/src/indent.c
+++ b/src/indent.c
@@ -1755,18 +1755,18 @@ DEFUN ("compute-motion", Fcompute_motion, Scompute_motion, 7, 7, 0,
1755 1755
1756 CHECK_NUMBER_COERCE_MARKER (from, 0); 1756 CHECK_NUMBER_COERCE_MARKER (from, 0);
1757 CHECK_CONS (frompos, 0); 1757 CHECK_CONS (frompos, 0);
1758 CHECK_NUMBER (XCAR (frompos), 0); 1758 CHECK_NUMBER_CAR (frompos, 0);
1759 CHECK_NUMBER (XCDR (frompos), 0); 1759 CHECK_NUMBER_CDR (frompos, 0);
1760 CHECK_NUMBER_COERCE_MARKER (to, 0); 1760 CHECK_NUMBER_COERCE_MARKER (to, 0);
1761 CHECK_CONS (topos, 0); 1761 CHECK_CONS (topos, 0);
1762 CHECK_NUMBER (XCAR (topos), 0); 1762 CHECK_NUMBER_CAR (topos, 0);
1763 CHECK_NUMBER (XCDR (topos), 0); 1763 CHECK_NUMBER_CDR (topos, 0);
1764 CHECK_NUMBER (width, 0); 1764 CHECK_NUMBER (width, 0);
1765 if (!NILP (offsets)) 1765 if (!NILP (offsets))
1766 { 1766 {
1767 CHECK_CONS (offsets, 0); 1767 CHECK_CONS (offsets, 0);
1768 CHECK_NUMBER (XCAR (offsets), 0); 1768 CHECK_NUMBER_CAR (offsets, 0);
1769 CHECK_NUMBER (XCDR (offsets), 0); 1769 CHECK_NUMBER_CDR (offsets, 0);
1770 hscroll = XINT (XCAR (offsets)); 1770 hscroll = XINT (XCAR (offsets));
1771 tab_offset = XINT (XCDR (offsets)); 1771 tab_offset = XINT (XCDR (offsets));
1772 } 1772 }
diff --git a/src/keyboard.c b/src/keyboard.c
index 414f72b971f..23b1f0d5b57 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -2358,15 +2358,21 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
2358 KBOARD *kb = FRAME_KBOARD (XFRAME (selected_frame)); 2358 KBOARD *kb = FRAME_KBOARD (XFRAME (selected_frame));
2359 if (kb != current_kboard) 2359 if (kb != current_kboard)
2360 { 2360 {
2361 Lisp_Object *tailp = &kb->kbd_queue; 2361 Lisp_Object link = kb->kbd_queue;
2362 /* We shouldn't get here if we were in single-kboard mode! */ 2362 /* We shouldn't get here if we were in single-kboard mode! */
2363 if (single_kboard) 2363 if (single_kboard)
2364 abort (); 2364 abort ();
2365 while (CONSP (*tailp)) 2365 if (CONSP (link))
2366 tailp = &XCDR (*tailp); 2366 {
2367 if (!NILP (*tailp)) 2367 while (CONSP (XCDR (link)))
2368 abort (); 2368 link = XCDR (link);
2369 *tailp = Fcons (c, Qnil); 2369 if (!NILP (XCDR (link)))
2370 abort ();
2371 }
2372 if (!CONSP (link))
2373 kb->kbd_queue = Fcons (c, Qnil);
2374 else
2375 XSETCDR (link, Fcons (c, Qnil));
2370 kb->kbd_queue_has_data = 1; 2376 kb->kbd_queue_has_data = 1;
2371 current_kboard = kb; 2377 current_kboard = kb;
2372 /* This is going to exit from read_char 2378 /* This is going to exit from read_char
@@ -2581,12 +2587,18 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
2581#ifdef MULTI_KBOARD 2587#ifdef MULTI_KBOARD
2582 if (! NILP (c) && (kb != current_kboard)) 2588 if (! NILP (c) && (kb != current_kboard))
2583 { 2589 {
2584 Lisp_Object *tailp = &kb->kbd_queue; 2590 Lisp_Object link = kb->kbd_queue;
2585 while (CONSP (*tailp)) 2591 if (CONSP (link))
2586 tailp = &XCDR (*tailp); 2592 {
2587 if (!NILP (*tailp)) 2593 while (CONSP (XCDR (link)))
2588 abort (); 2594 link = XCDR (link);
2589 *tailp = Fcons (c, Qnil); 2595 if (!NILP (XCDR (link)))
2596 abort ();
2597 }
2598 if (!CONSP (link))
2599 kb->kbd_queue = Fcons (c, Qnil);
2600 else
2601 XSETCDR (link, Fcons (c, Qnil));
2590 kb->kbd_queue_has_data = 1; 2602 kb->kbd_queue_has_data = 1;
2591 c = Qnil; 2603 c = Qnil;
2592 if (single_kboard) 2604 if (single_kboard)
@@ -2702,7 +2714,7 @@ read_char (commandflag, nmaps, maps, prev_event, used_mouse_menu)
2702 if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar)) 2714 if (EQ (posn, Qmenu_bar) || EQ (posn, Qtool_bar))
2703 { 2715 {
2704 /* Change menu-bar to (menu-bar) as the event "position". */ 2716 /* Change menu-bar to (menu-bar) as the event "position". */
2705 POSN_BUFFER_POSN (EVENT_START (c)) = Fcons (posn, Qnil); 2717 POSN_BUFFER_SET_POSN (EVENT_START (c), Fcons (posn, Qnil));
2706 2718
2707 also_record = c; 2719 also_record = c;
2708 Vunread_command_events = Fcons (c, Vunread_command_events); 2720 Vunread_command_events = Fcons (c, Vunread_command_events);
@@ -6854,19 +6866,19 @@ parse_menu_item (item, notreal, inmenubar)
6854 { 6866 {
6855 /* We have to create a cachelist. */ 6867 /* We have to create a cachelist. */
6856 CHECK_IMPURE (start); 6868 CHECK_IMPURE (start);
6857 XCDR (start) = Fcons (Fcons (Qnil, Qnil), XCDR (start)); 6869 XSETCDR (start, Fcons (Fcons (Qnil, Qnil), XCDR (start)));
6858 cachelist = XCAR (XCDR (start)); 6870 cachelist = XCAR (XCDR (start));
6859 newcache = 1; 6871 newcache = 1;
6860 tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ); 6872 tem = AREF (item_properties, ITEM_PROPERTY_KEYEQ);
6861 if (!NILP (keyhint)) 6873 if (!NILP (keyhint))
6862 { 6874 {
6863 XCAR (cachelist) = XCAR (keyhint); 6875 XSETCAR (cachelist, XCAR (keyhint));
6864 newcache = 0; 6876 newcache = 0;
6865 } 6877 }
6866 else if (STRINGP (tem)) 6878 else if (STRINGP (tem))
6867 { 6879 {
6868 XCDR (cachelist) = Fsubstitute_command_keys (tem); 6880 XSETCDR (cachelist, Fsubstitute_command_keys (tem));
6869 XCAR (cachelist) = Qt; 6881 XSETCAR (cachelist, Qt);
6870 } 6882 }
6871 } 6883 }
6872 6884
@@ -6924,10 +6936,10 @@ parse_menu_item (item, notreal, inmenubar)
6924 && ! NILP (Fget (def, Qmenu_alias))) 6936 && ! NILP (Fget (def, Qmenu_alias)))
6925 def = XSYMBOL (def)->function; 6937 def = XSYMBOL (def)->function;
6926 tem = Fwhere_is_internal (def, Qnil, Qt, Qnil); 6938 tem = Fwhere_is_internal (def, Qnil, Qt, Qnil);
6927 XCAR (cachelist) = tem; 6939 XSETCAR (cachelist, tem);
6928 if (NILP (tem)) 6940 if (NILP (tem))
6929 { 6941 {
6930 XCDR (cachelist) = Qnil; 6942 XSETCDR (cachelist, Qnil);
6931 chkcache = 0; 6943 chkcache = 0;
6932 } 6944 }
6933 } 6945 }
@@ -6948,7 +6960,7 @@ parse_menu_item (item, notreal, inmenubar)
6948 if (STRINGP (XCDR (prefix))) 6960 if (STRINGP (XCDR (prefix)))
6949 tem = concat2 (tem, XCDR (prefix)); 6961 tem = concat2 (tem, XCDR (prefix));
6950 } 6962 }
6951 XCDR (cachelist) = tem; 6963 XSETCDR (cachelist, tem);
6952 } 6964 }
6953 } 6965 }
6954 6966
@@ -6956,7 +6968,7 @@ parse_menu_item (item, notreal, inmenubar)
6956 if (newcache && !NILP (tem)) 6968 if (newcache && !NILP (tem))
6957 { 6969 {
6958 tem = concat3 (build_string (" ("), tem, build_string (")")); 6970 tem = concat3 (build_string (" ("), tem, build_string (")"));
6959 XCDR (cachelist) = tem; 6971 XSETCDR (cachelist, tem);
6960 } 6972 }
6961 6973
6962 /* If we only want to precompute equivalent key bindings, stop here. */ 6974 /* If we only want to precompute equivalent key bindings, stop here. */
@@ -7474,7 +7486,7 @@ read_char_x_menu_prompt (nmaps, maps, prev_event, used_mouse_menu)
7474 record_menu_key (XCAR (tem)); 7486 record_menu_key (XCAR (tem));
7475 if (SYMBOLP (XCAR (tem)) 7487 if (SYMBOLP (XCAR (tem))
7476 || INTEGERP (XCAR (tem))) 7488 || INTEGERP (XCAR (tem)))
7477 XCAR (tem) = Fcons (XCAR (tem), Qdisabled); 7489 XSETCAR (tem, Fcons (XCAR (tem), Qdisabled));
7478 } 7490 }
7479 7491
7480 /* If we got more than one event, put all but the first 7492 /* If we got more than one event, put all but the first
@@ -8466,8 +8478,8 @@ read_key_sequence (keybuf, bufsize, prompt, dont_downcase_last,
8466 8478
8467 /* Zap the position in key, so we know that we've 8479 /* Zap the position in key, so we know that we've
8468 expanded it, and don't try to do so again. */ 8480 expanded it, and don't try to do so again. */
8469 POSN_BUFFER_POSN (EVENT_START (key)) 8481 POSN_BUFFER_SET_POSN (EVENT_START (key),
8470 = Fcons (posn, Qnil); 8482 Fcons (posn, Qnil));
8471 8483
8472 mock_input = t + 2; 8484 mock_input = t + 2;
8473 goto replay_sequence; 8485 goto replay_sequence;
@@ -9203,7 +9215,7 @@ a special event, so ignore the prefix argument and don't clear it.")
9203 { 9215 {
9204 tem = Fnthcdr (Vhistory_length, Vcommand_history); 9216 tem = Fnthcdr (Vhistory_length, Vcommand_history);
9205 if (CONSP (tem)) 9217 if (CONSP (tem))
9206 XCDR (tem) = Qnil; 9218 XSETCDR (tem, Qnil);
9207 } 9219 }
9208 } 9220 }
9209 9221
diff --git a/src/keyboard.h b/src/keyboard.h
index ff867f0c268..625f40c94d7 100644
--- a/src/keyboard.h
+++ b/src/keyboard.h
@@ -260,6 +260,7 @@ extern Lisp_Object item_properties;
260/* Extract the fields of a position. */ 260/* Extract the fields of a position. */
261#define POSN_WINDOW(posn) (XCAR (posn)) 261#define POSN_WINDOW(posn) (XCAR (posn))
262#define POSN_BUFFER_POSN(posn) (XCAR (XCDR (posn))) 262#define POSN_BUFFER_POSN(posn) (XCAR (XCDR (posn)))
263#define POSN_BUFFER_SET_POSN(posn,x) (XSETCAR (XCDR (posn), (x)))
263#define POSN_WINDOW_POSN(posn) (XCAR (XCDR (XCDR (posn)))) 264#define POSN_WINDOW_POSN(posn) (XCAR (XCDR (XCDR (posn))))
264#define POSN_TIMESTAMP(posn) \ 265#define POSN_TIMESTAMP(posn) \
265 (XCAR (XCDR (XCDR (XCDR (posn))))) 266 (XCAR (XCDR (XCDR (XCDR (posn)))))
diff --git a/src/keymap.c b/src/keymap.c
index 75a12ead3ca..eb4d3ab375c 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -363,7 +363,7 @@ PARENT should be nil or another keymap.")
363 if (EQ (XCDR (prev), parent)) 363 if (EQ (XCDR (prev), parent))
364 RETURN_UNGCPRO (parent); 364 RETURN_UNGCPRO (parent);
365 365
366 XCDR (prev) = parent; 366 XSETCDR (prev, parent);
367 break; 367 break;
368 } 368 }
369 prev = list; 369 prev = list;
@@ -769,7 +769,7 @@ store_in_keymap (keymap, idx, def)
769 { 769 {
770 if (EQ (idx, XCAR (elt))) 770 if (EQ (idx, XCAR (elt)))
771 { 771 {
772 XCDR (elt) = def; 772 XSETCDR (elt, def);
773 return def; 773 return def;
774 } 774 }
775 } 775 }
@@ -786,8 +786,8 @@ store_in_keymap (keymap, idx, def)
786 keymap_end: 786 keymap_end:
787 /* We have scanned the entire keymap, and not found a binding for 787 /* We have scanned the entire keymap, and not found a binding for
788 IDX. Let's add one. */ 788 IDX. Let's add one. */
789 XCDR (insertion_point) 789 XSETCDR (insertion_point,
790 = Fcons (Fcons (idx, def), XCDR (insertion_point)); 790 Fcons (Fcons (idx, def), XCDR (insertion_point)));
791 } 791 }
792 792
793 return def; 793 return def;
@@ -830,7 +830,7 @@ is not copied.")
830 Lisp_Object indices[3]; 830 Lisp_Object indices[3];
831 831
832 elt = Fcopy_sequence (elt); 832 elt = Fcopy_sequence (elt);
833 XCAR (tail) = elt; 833 XSETCAR (tail, elt);
834 834
835 map_char_table (copy_keymap_1, Qnil, elt, elt, 0, indices); 835 map_char_table (copy_keymap_1, Qnil, elt, elt, 0, indices);
836 } 836 }
@@ -839,7 +839,7 @@ is not copied.")
839 int i; 839 int i;
840 840
841 elt = Fcopy_sequence (elt); 841 elt = Fcopy_sequence (elt);
842 XCAR (tail) = elt; 842 XSETCAR (tail, elt);
843 843
844 for (i = 0; i < ASIZE (elt); i++) 844 for (i = 0; i < ASIZE (elt); i++)
845 if (CONSP (AREF (elt, i)) && EQ (XCAR (AREF (elt, i)), Qkeymap)) 845 if (CONSP (AREF (elt, i)) && EQ (XCAR (AREF (elt, i)), Qkeymap))
@@ -854,15 +854,15 @@ is not copied.")
854 if (EQ (XCAR (tem),Qmenu_item)) 854 if (EQ (XCAR (tem),Qmenu_item))
855 { 855 {
856 /* Copy cell with menu-item marker. */ 856 /* Copy cell with menu-item marker. */
857 XCDR (elt) 857 XSETCDR (elt,
858 = Fcons (XCAR (tem), XCDR (tem)); 858 Fcons (XCAR (tem), XCDR (tem)));
859 elt = XCDR (elt); 859 elt = XCDR (elt);
860 tem = XCDR (elt); 860 tem = XCDR (elt);
861 if (CONSP (tem)) 861 if (CONSP (tem))
862 { 862 {
863 /* Copy cell with menu-item name. */ 863 /* Copy cell with menu-item name. */
864 XCDR (elt) 864 XSETCDR (elt,
865 = Fcons (XCAR (tem), XCDR (tem)); 865 Fcons (XCAR (tem), XCDR (tem)));
866 elt = XCDR (elt); 866 elt = XCDR (elt);
867 tem = XCDR (elt); 867 tem = XCDR (elt);
868 }; 868 };
@@ -870,16 +870,16 @@ is not copied.")
870 { 870 {
871 /* Copy cell with binding and if the binding is a keymap, 871 /* Copy cell with binding and if the binding is a keymap,
872 copy that. */ 872 copy that. */
873 XCDR (elt) 873 XSETCDR (elt,
874 = Fcons (XCAR (tem), XCDR (tem)); 874 Fcons (XCAR (tem), XCDR (tem)));
875 elt = XCDR (elt); 875 elt = XCDR (elt);
876 tem = XCAR (elt); 876 tem = XCAR (elt);
877 if (CONSP (tem) && EQ (XCAR (tem), Qkeymap)) 877 if (CONSP (tem) && EQ (XCAR (tem), Qkeymap))
878 XCAR (elt) = Fcopy_keymap (tem); 878 XSETCAR (elt, Fcopy_keymap (tem));
879 tem = XCDR (elt); 879 tem = XCDR (elt);
880 if (CONSP (tem) && CONSP (XCAR (tem))) 880 if (CONSP (tem) && CONSP (XCAR (tem)))
881 /* Delete cache for key equivalences. */ 881 /* Delete cache for key equivalences. */
882 XCDR (elt) = XCDR (tem); 882 XSETCDR (elt, XCDR (tem));
883 } 883 }
884 } 884 }
885 else 885 else
@@ -890,15 +890,15 @@ is not copied.")
890 if (STRINGP (XCAR (tem))) 890 if (STRINGP (XCAR (tem)))
891 { 891 {
892 /* Copy the cell, since copy-alist didn't go this deep. */ 892 /* Copy the cell, since copy-alist didn't go this deep. */
893 XCDR (elt) 893 XSETCDR (elt,
894 = Fcons (XCAR (tem), XCDR (tem)); 894 Fcons (XCAR (tem), XCDR (tem)));
895 elt = XCDR (elt); 895 elt = XCDR (elt);
896 tem = XCDR (elt); 896 tem = XCDR (elt);
897 /* Also skip the optional menu help string. */ 897 /* Also skip the optional menu help string. */
898 if (CONSP (tem) && STRINGP (XCAR (tem))) 898 if (CONSP (tem) && STRINGP (XCAR (tem)))
899 { 899 {
900 XCDR (elt) 900 XSETCDR (elt,
901 = Fcons (XCAR (tem), XCDR (tem)); 901 Fcons (XCAR (tem), XCDR (tem)));
902 elt = XCDR (elt); 902 elt = XCDR (elt);
903 tem = XCDR (elt); 903 tem = XCDR (elt);
904 } 904 }
@@ -908,12 +908,12 @@ is not copied.")
908 && CONSP (XCAR (tem)) 908 && CONSP (XCAR (tem))
909 && (NILP (XCAR (XCAR (tem))) 909 && (NILP (XCAR (XCAR (tem)))
910 || VECTORP (XCAR (XCAR (tem))))) 910 || VECTORP (XCAR (XCAR (tem)))))
911 XCDR (elt) = XCDR (tem); 911 XSETCDR (elt, XCDR (tem));
912 } 912 }
913 if (CONSP (elt) 913 if (CONSP (elt)
914 && CONSP (XCDR (elt)) 914 && CONSP (XCDR (elt))
915 && EQ (XCAR (XCDR (elt)), Qkeymap)) 915 && EQ (XCAR (XCDR (elt)), Qkeymap))
916 XCDR (elt) = Fcopy_keymap (XCDR (elt)); 916 XSETCDR (elt, Fcopy_keymap (XCDR (elt)));
917 } 917 }
918 918
919 } 919 }
@@ -1548,8 +1548,8 @@ accessible_keymaps_1 (key, cmd, maps, tail, thisseq, is_metized)
1548 /* This new sequence is the same length as 1548 /* This new sequence is the same length as
1549 thisseq, so stick it in the list right 1549 thisseq, so stick it in the list right
1550 after this one. */ 1550 after this one. */
1551 XCDR (tail) 1551 XSETCDR (tail,
1552 = Fcons (Fcons (tem, cmd), XCDR (tail)); 1552 Fcons (Fcons (tem, cmd), XCDR (tail)));
1553 } 1553 }
1554 else 1554 else
1555 { 1555 {
@@ -2396,7 +2396,7 @@ where_is_internal_2 (args, key, binding)
2396 this, last, nomenus, last_is_meta); 2396 this, last, nomenus, last_is_meta);
2397 2397
2398 if (!NILP (sequence)) 2398 if (!NILP (sequence))
2399 XCDR (XCAR (args)) = Fcons (sequence, result); 2399 XSETCDR (XCAR (args), Fcons (sequence, result));
2400 2400
2401 UNGCPRO; 2401 UNGCPRO;
2402} 2402}
diff --git a/src/lisp.h b/src/lisp.h
index add5312578b..2cb7a1fcc7f 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -248,6 +248,16 @@ Lisp_Object;
248 248
249#endif /* WORDS_BIG_ENDIAN */ 249#endif /* WORDS_BIG_ENDIAN */
250 250
251#ifdef __GNUC__
252static __inline__ Lisp_Object
253LISP_MAKE_RVALUE (Lisp_Object o)
254{
255 return o;
256}
257#else
258#define LISP_MAKE_RVALUE(o) (o) /* XXX - keeps arg as rvalue. */
259#endif
260
251#endif /* NO_UNION_TYPE */ 261#endif /* NO_UNION_TYPE */
252 262
253 263
@@ -255,6 +265,7 @@ Lisp_Object;
255 265
256#ifdef NO_UNION_TYPE 266#ifdef NO_UNION_TYPE
257#define Lisp_Object EMACS_INT 267#define Lisp_Object EMACS_INT
268#define LISP_MAKE_RVALUE(o) (0+(o))
258#endif /* NO_UNION_TYPE */ 269#endif /* NO_UNION_TYPE */
259 270
260#ifndef VALMASK 271#ifndef VALMASK
@@ -616,14 +627,43 @@ struct Lisp_Cons
616 }; 627 };
617 628
618/* Take the car or cdr of something known to be a cons cell. */ 629/* Take the car or cdr of something known to be a cons cell. */
630/* The _AS_LVALUE macros shouldn't be used outside of the minimal set
631 of code that has to know what a cons cell looks like. Other code not
632 part of the basic lisp implementation should assume that the car and cdr
633 fields are not accessible as lvalues. (What if we want to switch to
634 a copying collector someday? Cached cons cell field addresses may be
635 invalidated at arbitrary points.) */
619#ifdef HIDE_LISP_IMPLEMENTATION 636#ifdef HIDE_LISP_IMPLEMENTATION
620#define XCAR(c) (XCONS ((c))->car_) 637#define XCAR_AS_LVALUE(c) (XCONS ((c))->car_)
621#define XCDR(c) (XCONS ((c))->cdr_) 638#define XCDR_AS_LVALUE(c) (XCONS ((c))->cdr_)
622#else 639#else
623#define XCAR(c) (XCONS ((c))->car) 640#define XCAR_AS_LVALUE(c) (XCONS ((c))->car)
624#define XCDR(c) (XCONS ((c))->cdr) 641#define XCDR_AS_LVALUE(c) (XCONS ((c))->cdr)
625#endif 642#endif
626 643
644/* Okay, we're not quite ready to turn this on yet. A few files still
645 need to be updated and tested. */
646#undef LISP_MAKE_RVALUE
647#define LISP_MAKE_RVALUE(x) (x)
648
649/* Use these from normal code. */
650#define XCAR(c) LISP_MAKE_RVALUE(XCAR_AS_LVALUE(c))
651#define XCDR(c) LISP_MAKE_RVALUE(XCDR_AS_LVALUE(c))
652
653/* Use these to set the fields of a cons cell.
654
655 Note that both arguments may refer to the same object, so 'n'
656 should not be read after 'c' is first modified. Also, neither
657 argument should be evaluated more than once; side effects are
658 especially common in the second argument. */
659#define XSETCAR(c,n) (XCAR_AS_LVALUE(c) = (n))
660#define XSETCDR(c,n) (XCDR_AS_LVALUE(c) = (n))
661
662/* For performance: Fast storage of positive integers into the
663 fields of a cons cell. See above caveats. */
664#define XSETCARFASTINT(c,n) XSETFASTINT(XCAR_AS_LVALUE(c),(n))
665#define XSETCDRFASTINT(c,n) XSETFASTINT(XCDR_AS_LVALUE(c),(n))
666
627/* Take the car or cdr of something whose type is not known. */ 667/* Take the car or cdr of something whose type is not known. */
628#define CAR(c) \ 668#define CAR(c) \
629 (CONSP ((c)) ? XCAR ((c)) \ 669 (CONSP ((c)) ? XCAR ((c)) \
@@ -1474,6 +1514,22 @@ typedef unsigned char UCHAR;
1474#define CHECK_OVERLAY(x, i) \ 1514#define CHECK_OVERLAY(x, i) \
1475 do { if (!OVERLAYP ((x))) x = wrong_type_argument (Qoverlayp, (x));} while (0) 1515 do { if (!OVERLAYP ((x))) x = wrong_type_argument (Qoverlayp, (x));} while (0)
1476 1516
1517/* Since we can't assign directly to the CAR or CDR fields of a cons
1518 cell, use these when checking that those fields contain numbers. */
1519#define CHECK_NUMBER_CAR(x, i) \
1520 do { \
1521 Lisp_Object tmp = XCAR (x); \
1522 CHECK_NUMBER (tmp, (i)); \
1523 XSETCAR ((x), tmp); \
1524 } while (0)
1525
1526#define CHECK_NUMBER_CDR(x, i) \
1527 do { \
1528 Lisp_Object tmp = XCDR (x); \
1529 CHECK_NUMBER (tmp, (i)); \
1530 XSETCDR ((x), tmp); \
1531 } while (0)
1532
1477/* Cast pointers to this type to compare them. Some machines want int. */ 1533/* Cast pointers to this type to compare them. Some machines want int. */
1478#ifndef PNTR_COMPARISON_TYPE 1534#ifndef PNTR_COMPARISON_TYPE
1479#define PNTR_COMPARISON_TYPE EMACS_UINT 1535#define PNTR_COMPARISON_TYPE EMACS_UINT
diff --git a/src/lread.c b/src/lread.c
index 671305c6f93..6968c5394fb 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -832,8 +832,8 @@ Return t if file exists.")
832 832
833 GCPRO1 (file); 833 GCPRO1 (file);
834 lispstream = Fcons (Qnil, Qnil); 834 lispstream = Fcons (Qnil, Qnil);
835 XSETFASTINT (XCAR (lispstream), (EMACS_UINT)stream >> 16); 835 XSETCARFASTINT (lispstream, (EMACS_UINT)stream >> 16);
836 XSETFASTINT (XCDR (lispstream), (EMACS_UINT)stream & 0xffff); 836 XSETCDRFASTINT (lispstream, (EMACS_UINT)stream & 0xffff);
837 record_unwind_protect (load_unwind, lispstream); 837 record_unwind_protect (load_unwind, lispstream);
838 record_unwind_protect (load_descriptor_unwind, load_descriptor_list); 838 record_unwind_protect (load_descriptor_unwind, load_descriptor_list);
839 specbind (Qload_file_name, found); 839 specbind (Qload_file_name, found);
@@ -963,16 +963,19 @@ openp (path, str, suffixes, storeptr, exec_only)
963 Lisp_Object string, tail; 963 Lisp_Object string, tail;
964 int max_suffix_len = 0; 964 int max_suffix_len = 0;
965 965
966 string = filename = Qnil;
967 GCPRO5 (str, string, filename, path, suffixes);
968
966 for (tail = suffixes; CONSP (tail); tail = XCDR (tail)) 969 for (tail = suffixes; CONSP (tail); tail = XCDR (tail))
967 { 970 {
968 CHECK_STRING (XCAR (tail), 0); 971 string = XCAR (tail);
972 CHECK_STRING (string, 0);
973 if (! EQ (string, XCAR (tail)))
974 XSETCAR (tail, string);
969 max_suffix_len = max (max_suffix_len, 975 max_suffix_len = max (max_suffix_len,
970 STRING_BYTES (XSTRING (XCAR (tail)))); 976 STRING_BYTES (XSTRING (string)));
971 } 977 }
972 978
973 string = filename = Qnil;
974 GCPRO5 (str, string, filename, path, suffixes);
975
976 if (storeptr) 979 if (storeptr)
977 *storeptr = Qnil; 980 *storeptr = Qnil;
978 981
@@ -2724,7 +2727,7 @@ read_list (flag, readcharfun)
2724 { 2727 {
2725 GCPRO2 (val, tail); 2728 GCPRO2 (val, tail);
2726 if (!NILP (tail)) 2729 if (!NILP (tail))
2727 XCDR (tail) = read0 (readcharfun); 2730 XSETCDR (tail, read0 (readcharfun));
2728 else 2731 else
2729 val = read0 (readcharfun); 2732 val = read0 (readcharfun);
2730 read1 (readcharfun, &ch, 0); 2733 read1 (readcharfun, &ch, 0);
@@ -2817,7 +2820,7 @@ read_list (flag, readcharfun)
2817 ? pure_cons (elt, Qnil) 2820 ? pure_cons (elt, Qnil)
2818 : Fcons (elt, Qnil)); 2821 : Fcons (elt, Qnil));
2819 if (!NILP (tail)) 2822 if (!NILP (tail))
2820 XCDR (tail) = tem; 2823 XSETCDR (tail, tem);
2821 else 2824 else
2822 val = tem; 2825 val = tem;
2823 tail = tem; 2826 tail = tem;
diff --git a/src/minibuf.c b/src/minibuf.c
index 9af0c0b0fe5..655a6061aaa 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -723,7 +723,7 @@ get_minibuffer (depth)
723 enabled in it. */ 723 enabled in it. */
724 Fbuffer_enable_undo (buf); 724 Fbuffer_enable_undo (buf);
725 725
726 XCAR (tail) = buf; 726 XSETCAR (tail, buf);
727 } 727 }
728 else 728 else
729 { 729 {
diff --git a/src/process.c b/src/process.c
index f3407838720..956f2b8fdb3 100644
--- a/src/process.c
+++ b/src/process.c
@@ -2367,7 +2367,9 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
2367 int wait_channel = -1; 2367 int wait_channel = -1;
2368 struct Lisp_Process *wait_proc = 0; 2368 struct Lisp_Process *wait_proc = 0;
2369 int got_some_input = 0; 2369 int got_some_input = 0;
2370 Lisp_Object *wait_for_cell = 0; 2370 /* Either nil or a cons cell, the car of which is of interest and
2371 may be changed outside of this routine. */
2372 Lisp_Object wait_for_cell = Qnil;
2371 2373
2372 FD_ZERO (&Available); 2374 FD_ZERO (&Available);
2373 2375
@@ -2383,7 +2385,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
2383 /* If waiting for non-nil in a cell, record where. */ 2385 /* If waiting for non-nil in a cell, record where. */
2384 if (CONSP (read_kbd)) 2386 if (CONSP (read_kbd))
2385 { 2387 {
2386 wait_for_cell = &XCAR (read_kbd); 2388 wait_for_cell = read_kbd;
2387 XSETFASTINT (read_kbd, 0); 2389 XSETFASTINT (read_kbd, 0);
2388 } 2390 }
2389 2391
@@ -2417,7 +2419,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
2417 QUIT; 2419 QUIT;
2418 2420
2419 /* Exit now if the cell we're waiting for became non-nil. */ 2421 /* Exit now if the cell we're waiting for became non-nil. */
2420 if (wait_for_cell && ! NILP (*wait_for_cell)) 2422 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
2421 break; 2423 break;
2422 2424
2423 /* Compute time from now till when time limit is up */ 2425 /* Compute time from now till when time limit is up */
@@ -2446,7 +2448,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
2446 But not if wait_for_cell; in those cases, 2448 But not if wait_for_cell; in those cases,
2447 the wait is supposed to be short, 2449 the wait is supposed to be short,
2448 and those callers cannot handle running arbitrary Lisp code here. */ 2450 and those callers cannot handle running arbitrary Lisp code here. */
2449 if (! wait_for_cell) 2451 if (NILP (wait_for_cell))
2450 { 2452 {
2451 EMACS_TIME timer_delay; 2453 EMACS_TIME timer_delay;
2452 2454
@@ -2567,7 +2569,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
2567 2569
2568 /* Wait till there is something to do */ 2570 /* Wait till there is something to do */
2569 2571
2570 if (wait_for_cell) 2572 if (!NILP (wait_for_cell))
2571 Available = non_process_wait_mask; 2573 Available = non_process_wait_mask;
2572 else if (! XINT (read_kbd)) 2574 else if (! XINT (read_kbd))
2573 Available = non_keyboard_wait_mask; 2575 Available = non_keyboard_wait_mask;
@@ -2723,7 +2725,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
2723 } 2725 }
2724 2726
2725 /* Exit now if the cell we're waiting for became non-nil. */ 2727 /* Exit now if the cell we're waiting for became non-nil. */
2726 if (wait_for_cell && ! NILP (*wait_for_cell)) 2728 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
2727 break; 2729 break;
2728 2730
2729#ifdef SIGIO 2731#ifdef SIGIO
@@ -2742,7 +2744,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
2742 2744
2743 /* If checking input just got us a size-change event from X, 2745 /* If checking input just got us a size-change event from X,
2744 obey it now if we should. */ 2746 obey it now if we should. */
2745 if (XINT (read_kbd) || wait_for_cell) 2747 if (XINT (read_kbd) || ! NILP (wait_for_cell))
2746 do_pending_window_change (0); 2748 do_pending_window_change (0);
2747 2749
2748 /* Check for data from a process. */ 2750 /* Check for data from a process. */
@@ -4768,12 +4770,14 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4768 EMACS_TIME end_time, timeout; 4770 EMACS_TIME end_time, timeout;
4769 SELECT_TYPE waitchannels; 4771 SELECT_TYPE waitchannels;
4770 int xerrno; 4772 int xerrno;
4771 Lisp_Object *wait_for_cell = 0; 4773 /* Either nil or a cons cell, the car of which is of interest and
4774 may be changed outside of this routine. */
4775 Lisp_Object wait_for_cell = Qnil;
4772 4776
4773 /* If waiting for non-nil in a cell, record where. */ 4777 /* If waiting for non-nil in a cell, record where. */
4774 if (CONSP (read_kbd)) 4778 if (CONSP (read_kbd))
4775 { 4779 {
4776 wait_for_cell = &XCAR (read_kbd); 4780 wait_for_cell = read_kbd;
4777 XSETFASTINT (read_kbd, 0); 4781 XSETFASTINT (read_kbd, 0);
4778 } 4782 }
4779 4783
@@ -4800,7 +4804,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4800 QUIT; 4804 QUIT;
4801 4805
4802 /* Exit now if the cell we're waiting for became non-nil. */ 4806 /* Exit now if the cell we're waiting for became non-nil. */
4803 if (wait_for_cell && ! NILP (*wait_for_cell)) 4807 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
4804 break; 4808 break;
4805 4809
4806 /* Compute time from now till when time limit is up */ 4810 /* Compute time from now till when time limit is up */
@@ -4829,7 +4833,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4829 run timer events directly. 4833 run timer events directly.
4830 (Callers that will immediately read keyboard events 4834 (Callers that will immediately read keyboard events
4831 call timer_delay on their own.) */ 4835 call timer_delay on their own.) */
4832 if (! wait_for_cell) 4836 if (NILP (wait_for_cell))
4833 { 4837 {
4834 EMACS_TIME timer_delay; 4838 EMACS_TIME timer_delay;
4835 4839
@@ -4870,7 +4874,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4870 4874
4871 /* Wait till there is something to do. */ 4875 /* Wait till there is something to do. */
4872 4876
4873 if (! XINT (read_kbd) && wait_for_cell == 0) 4877 if (! XINT (read_kbd) && NILP (wait_for_cell))
4874 FD_ZERO (&waitchannels); 4878 FD_ZERO (&waitchannels);
4875 else 4879 else
4876 FD_SET (0, &waitchannels); 4880 FD_SET (0, &waitchannels);
@@ -4946,7 +4950,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4946 input at all when wait_for_cell, but the code 4950 input at all when wait_for_cell, but the code
4947 has been this way since July 1994. 4951 has been this way since July 1994.
4948 Try changing this after version 19.31.) */ 4952 Try changing this after version 19.31.) */
4949 if (wait_for_cell 4953 if (! NILP (wait_for_cell)
4950 && detect_input_pending ()) 4954 && detect_input_pending ())
4951 { 4955 {
4952 swallow_events (do_display); 4956 swallow_events (do_display);
@@ -4955,7 +4959,7 @@ wait_reading_process_input (time_limit, microsecs, read_kbd, do_display)
4955 } 4959 }
4956 4960
4957 /* Exit now if the cell we're waiting for became non-nil. */ 4961 /* Exit now if the cell we're waiting for became non-nil. */
4958 if (wait_for_cell && ! NILP (*wait_for_cell)) 4962 if (! NILP (wait_for_cell) && ! NILP (XCAR (wait_for_cell)))
4959 break; 4963 break;
4960 } 4964 }
4961 4965
diff --git a/src/search.c b/src/search.c
index f05f2cc0bf3..519a7b48665 100644
--- a/src/search.c
+++ b/src/search.c
@@ -2691,16 +2691,16 @@ to hold all the values, and if INTEGERS is non-nil, no consing is done.")
2691 i++, tail = XCDR (tail)) 2691 i++, tail = XCDR (tail))
2692 { 2692 {
2693 if (i < 2 * len + 2) 2693 if (i < 2 * len + 2)
2694 XCAR (tail) = data[i]; 2694 XSETCAR (tail, data[i]);
2695 else 2695 else
2696 XCAR (tail) = Qnil; 2696 XSETCAR (tail, Qnil);
2697 prev = tail; 2697 prev = tail;
2698 } 2698 }
2699 2699
2700 /* If we couldn't fit all value elements into REUSE, 2700 /* If we couldn't fit all value elements into REUSE,
2701 cons up the rest of them and add them to the end of REUSE. */ 2701 cons up the rest of them and add them to the end of REUSE. */
2702 if (i < 2 * len + 2) 2702 if (i < 2 * len + 2)
2703 XCDR (prev) = Flist (2 * len + 2 - i, data + i); 2703 XSETCDR (prev, Flist (2 * len + 2 - i, data + i));
2704 2704
2705 return reuse; 2705 return reuse;
2706} 2706}
diff --git a/src/textprop.c b/src/textprop.c
index 0cb09791f5e..b43503dfdb8 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1738,7 +1738,7 @@ extend_property_ranges (list, old_end, new_end)
1738 end = XCAR (XCDR (item)); 1738 end = XCAR (XCDR (item));
1739 1739
1740 if (EQ (end, old_end)) 1740 if (EQ (end, old_end))
1741 XCAR (XCDR (item)) = new_end; 1741 XSETCAR (XCDR (item), new_end);
1742 } 1742 }
1743} 1743}
1744 1744
diff --git a/src/undo.c b/src/undo.c
index b664cf3c61f..bf10de6e502 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -73,7 +73,7 @@ record_insert (beg, length)
73 && INTEGERP (XCDR (elt)) 73 && INTEGERP (XCDR (elt))
74 && XINT (XCDR (elt)) == beg) 74 && XINT (XCDR (elt)) == beg)
75 { 75 {
76 XSETINT (XCDR (elt), beg + length); 76 XSETCDR (elt, make_number (beg + length));
77 return; 77 return;
78 } 78 }
79 } 79 }
@@ -273,7 +273,7 @@ but another undo command will undo to the previous boundary.")
273 { 273 {
274 /* If we have preallocated the cons cell to use here, 274 /* If we have preallocated the cons cell to use here,
275 use that one. */ 275 use that one. */
276 XCDR (pending_boundary) = current_buffer->undo_list; 276 XSETCDR (pending_boundary, current_buffer->undo_list);
277 current_buffer->undo_list = pending_boundary; 277 current_buffer->undo_list = pending_boundary;
278 pending_boundary = Qnil; 278 pending_boundary = Qnil;
279 } 279 }
@@ -378,7 +378,7 @@ truncate_undo_list (list, minsize, maxsize)
378 /* Truncate at the boundary where we decided to truncate. */ 378 /* Truncate at the boundary where we decided to truncate. */
379 if (!NILP (last_boundary)) 379 if (!NILP (last_boundary))
380 { 380 {
381 XCDR (last_boundary) = Qnil; 381 XSETCDR (last_boundary, Qnil);
382 return list; 382 return list;
383 } 383 }
384 else 384 else
diff --git a/src/w32fns.c b/src/w32fns.c
index f1884e0f4e5..18e40ed09ed 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -3784,7 +3784,7 @@ w32_msg_pump (deferred_msg * msg_buf)
3784 thread-safe. The next line is okay because the cons 3784 thread-safe. The next line is okay because the cons
3785 cell is never made into garbage and is not relocated by 3785 cell is never made into garbage and is not relocated by
3786 GC. */ 3786 GC. */
3787 XCAR ((Lisp_Object) msg.lParam) = Qnil; 3787 XSETCAR ((Lisp_Object) msg.lParam, Qnil);
3788 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0)) 3788 if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
3789 abort (); 3789 abort ();
3790 break; 3790 break;
@@ -6866,9 +6866,9 @@ w32_list_fonts (f, pattern, size, maxnames)
6866 6866
6867 /* Make a list of the fonts we got back. 6867 /* Make a list of the fonts we got back.
6868 Store that in the font cache for the display. */ 6868 Store that in the font cache for the display. */
6869 XCDR (dpyinfo->name_list_element) 6869 XSETCDR (dpyinfo->name_list_element,
6870 = Fcons (Fcons (tpat, list), 6870 Fcons (Fcons (tpat, list),
6871 XCDR (dpyinfo->name_list_element)); 6871 XCDR (dpyinfo->name_list_element)));
6872 6872
6873 label_cached: 6873 label_cached:
6874 if (NILP (list)) continue; /* Try the remaining alternatives. */ 6874 if (NILP (list)) continue; /* Try the remaining alternatives. */
@@ -6915,9 +6915,9 @@ w32_list_fonts (f, pattern, size, maxnames)
6915 hdc = GetDC (dpyinfo->root_window); 6915 hdc = GetDC (dpyinfo->root_window);
6916 oldobj = SelectObject (hdc, thisinfo.hfont); 6916 oldobj = SelectObject (hdc, thisinfo.hfont);
6917 if (GetTextMetrics (hdc, &thisinfo.tm)) 6917 if (GetTextMetrics (hdc, &thisinfo.tm))
6918 XCDR (tem) = make_number (FONT_WIDTH (&thisinfo)); 6918 XSETCDR (tem, make_number (FONT_WIDTH (&thisinfo)));
6919 else 6919 else
6920 XCDR (tem) = make_number (0); 6920 XSETCDR (tem, make_number (0));
6921 SelectObject (hdc, oldobj); 6921 SelectObject (hdc, oldobj);
6922 ReleaseDC (dpyinfo->root_window, hdc); 6922 ReleaseDC (dpyinfo->root_window, hdc);
6923 DeleteObject(thisinfo.hfont); 6923 DeleteObject(thisinfo.hfont);
@@ -13240,7 +13240,7 @@ The return value is the hotkey-id if registered, otherwise nil.")
13240 if (NILP (item)) 13240 if (NILP (item))
13241 w32_grabbed_keys = Fcons (key, w32_grabbed_keys); 13241 w32_grabbed_keys = Fcons (key, w32_grabbed_keys);
13242 else 13242 else
13243 XCAR (item) = key; 13243 XSETCAR (item, key);
13244 13244
13245 /* Notify input thread about new hot-key definition, so that it 13245 /* Notify input thread about new hot-key definition, so that it
13246 takes effect without needing to switch focus. */ 13246 takes effect without needing to switch focus. */
diff --git a/src/w32term.c b/src/w32term.c
index 42a8fdd957f..8478f6c8b5e 100644
--- a/src/w32term.c
+++ b/src/w32term.c
@@ -10286,7 +10286,7 @@ x_delete_display (dpyinfo)
10286 { 10286 {
10287 if (EQ (XCAR (XCDR (tail)), dpyinfo->name_list_element)) 10287 if (EQ (XCAR (XCDR (tail)), dpyinfo->name_list_element))
10288 { 10288 {
10289 XCDR (tail) = XCDR (XCDR (tail)); 10289 XSETCDR (tail, XCDR (XCDR (tail)));
10290 break; 10290 break;
10291 } 10291 }
10292 tail = XCDR (tail); 10292 tail = XCDR (tail);
diff --git a/src/xfaces.c b/src/xfaces.c
index 476908e5b15..c9867c4ce1f 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -2684,7 +2684,7 @@ remove_duplicates (list)
2684 { 2684 {
2685 Lisp_Object next = XCDR (tail); 2685 Lisp_Object next = XCDR (tail);
2686 if (!NILP (Fequal (XCAR (next), XCAR (tail)))) 2686 if (!NILP (Fequal (XCAR (next), XCAR (tail))))
2687 XCDR (tail) = XCDR (next); 2687 XSETCDR (tail, XCDR (next));
2688 else 2688 else
2689 tail = XCDR (tail); 2689 tail = XCDR (tail);
2690 } 2690 }
@@ -4199,8 +4199,8 @@ FRAME 0 means change the face on all frames, and change the default
4199 { 4199 {
4200 Lisp_Object cons; 4200 Lisp_Object cons;
4201 cons = XCAR (Vparam_value_alist); 4201 cons = XCAR (Vparam_value_alist);
4202 XCAR (cons) = param; 4202 XSETCAR (cons, param);
4203 XCDR (cons) = value; 4203 XSETCDR (cons, value);
4204 Fmodify_frame_parameters (frame, Vparam_value_alist); 4204 Fmodify_frame_parameters (frame, Vparam_value_alist);
4205 } 4205 }
4206 } 4206 }
diff --git a/src/xselect.c b/src/xselect.c
index 91011589bc4..ad27323d358 100644
--- a/src/xselect.c
+++ b/src/xselect.c
@@ -338,7 +338,7 @@ x_own_selection (selection_name, selection_value)
338 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest)) 338 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
339 if (EQ (prev_value, Fcar (XCDR (rest)))) 339 if (EQ (prev_value, Fcar (XCDR (rest))))
340 { 340 {
341 XCDR (rest) = Fcdr (XCDR (rest)); 341 XSETCDR (rest, Fcdr (XCDR (rest)));
342 break; 342 break;
343 } 343 }
344 } 344 }
@@ -905,7 +905,7 @@ x_handle_selection_clear (event)
905 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest)) 905 for (rest = Vselection_alist; !NILP (rest); rest = Fcdr (rest))
906 if (EQ (local_selection_data, Fcar (XCDR (rest)))) 906 if (EQ (local_selection_data, Fcar (XCDR (rest))))
907 { 907 {
908 XCDR (rest) = Fcdr (XCDR (rest)); 908 XSETCDR (rest, Fcdr (XCDR (rest)));
909 break; 909 break;
910 } 910 }
911 } 911 }
@@ -982,7 +982,7 @@ x_clear_frame_selections (f)
982 redisplay_preserve_echo_area (22); 982 redisplay_preserve_echo_area (22);
983#endif 983#endif
984 } 984 }
985 XCDR (rest) = Fcdr (XCDR (rest)); 985 XSETCDR (rest, Fcdr (XCDR (rest)));
986 break; 986 break;
987 } 987 }
988} 988}
@@ -1076,13 +1076,13 @@ wait_for_property_change (location)
1076 Lisp_Object tem; 1076 Lisp_Object tem;
1077 1077
1078 tem = Fcons (Qnil, Qnil); 1078 tem = Fcons (Qnil, Qnil);
1079 XSETFASTINT (XCAR (tem), (EMACS_UINT)location >> 16); 1079 XSETCARFASTINT (tem, (EMACS_UINT)location >> 16);
1080 XSETFASTINT (XCDR (tem), (EMACS_UINT)location & 0xffff); 1080 XSETCDRFASTINT (tem, (EMACS_UINT)location & 0xffff);
1081 1081
1082 /* Make sure to do unexpect_property_change if we quit or err. */ 1082 /* Make sure to do unexpect_property_change if we quit or err. */
1083 record_unwind_protect (wait_for_property_change_unwind, tem); 1083 record_unwind_protect (wait_for_property_change_unwind, tem);
1084 1084
1085 XCAR (property_change_reply) = Qnil; 1085 XSETCAR (property_change_reply, Qnil);
1086 1086
1087 property_change_reply_object = location; 1087 property_change_reply_object = location;
1088 /* If the event we are waiting for arrives beyond here, it will set 1088 /* If the event we are waiting for arrives beyond here, it will set
@@ -1128,7 +1128,7 @@ x_handle_property_notify (event)
1128 /* If this is the one wait_for_property_change is waiting for, 1128 /* If this is the one wait_for_property_change is waiting for,
1129 tell it to wake up. */ 1129 tell it to wake up. */
1130 if (rest == property_change_reply_object) 1130 if (rest == property_change_reply_object)
1131 XCAR (property_change_reply) = Qt; 1131 XSETCAR (property_change_reply, Qt);
1132 1132
1133 if (prev) 1133 if (prev)
1134 prev->next = rest->next; 1134 prev->next = rest->next;
@@ -1239,7 +1239,7 @@ x_get_foreign_selection (selection_symbol, target_type)
1239 /* Prepare to block until the reply has been read. */ 1239 /* Prepare to block until the reply has been read. */
1240 reading_selection_window = requestor_window; 1240 reading_selection_window = requestor_window;
1241 reading_which_selection = selection_atom; 1241 reading_which_selection = selection_atom;
1242 XCAR (reading_selection_reply) = Qnil; 1242 XSETCAR (reading_selection_reply, Qnil);
1243 1243
1244 frame = some_frame_on_display (dpyinfo); 1244 frame = some_frame_on_display (dpyinfo);
1245 1245
@@ -1942,8 +1942,8 @@ x_handle_selection_notify (event)
1942 return; 1942 return;
1943 1943
1944 TRACE0 ("Received SelectionNotify"); 1944 TRACE0 ("Received SelectionNotify");
1945 XCAR (reading_selection_reply) 1945 XSETCAR (reading_selection_reply,
1946 = (event->property != 0 ? Qt : Qlambda); 1946 (event->property != 0 ? Qt : Qlambda));
1947} 1947}
1948 1948
1949 1949
diff --git a/src/xterm.c b/src/xterm.c
index 1fe78ad6407..492966253de 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -13714,8 +13714,8 @@ x_list_fonts (f, pattern, size, maxnames)
13714 } 13714 }
13715 13715
13716 /* Now store the result in the cache. */ 13716 /* Now store the result in the cache. */
13717 XCDR (dpyinfo->name_list_element) 13717 XSETCDR (dpyinfo->name_list_element,
13718 = Fcons (Fcons (key, list), XCDR (dpyinfo->name_list_element)); 13718 Fcons (Fcons (key, list), XCDR (dpyinfo->name_list_element)));
13719 13719
13720 label_cached: 13720 label_cached:
13721 if (NILP (list)) continue; /* Try the remaining alternatives. */ 13721 if (NILP (list)) continue; /* Try the remaining alternatives. */
@@ -13758,10 +13758,10 @@ x_list_fonts (f, pattern, size, maxnames)
13758 13758
13759 if (thisinfo) 13759 if (thisinfo)
13760 { 13760 {
13761 XCDR (tem) 13761 XSETCDR (tem,
13762 = (thisinfo->min_bounds.width == 0 13762 (thisinfo->min_bounds.width == 0
13763 ? make_number (0) 13763 ? make_number (0)
13764 : make_number (thisinfo->max_bounds.width)); 13764 : make_number (thisinfo->max_bounds.width)));
13765 BLOCK_INPUT; 13765 BLOCK_INPUT;
13766 XFreeFont (dpy, thisinfo); 13766 XFreeFont (dpy, thisinfo);
13767 UNBLOCK_INPUT; 13767 UNBLOCK_INPUT;
@@ -13770,7 +13770,7 @@ x_list_fonts (f, pattern, size, maxnames)
13770 /* For unknown reason, the previous call of XListFont had 13770 /* For unknown reason, the previous call of XListFont had
13771 returned a font which can't be opened. Record the size 13771 returned a font which can't be opened. Record the size
13772 as 0 not to try to open it again. */ 13772 as 0 not to try to open it again. */
13773 XCDR (tem) = make_number (0); 13773 XSETCDR (tem, make_number (0));
13774 } 13774 }
13775 13775
13776 found_size = XINT (XCDR (tem)); 13776 found_size = XINT (XCDR (tem));
@@ -14036,22 +14036,22 @@ x_load_font (f, fontname, size)
14036 Lisp_Object key = Fcons (Fcons (lispy_name, make_number (256)), 14036 Lisp_Object key = Fcons (Fcons (lispy_name, make_number (256)),
14037 Qnil); 14037 Qnil);
14038 14038
14039 XCDR (dpyinfo->name_list_element) 14039 XSETCDR (dpyinfo->name_list_element,
14040 = Fcons (Fcons (key, 14040 Fcons (Fcons (key,
14041 Fcons (Fcons (lispy_full_name, 14041 Fcons (Fcons (lispy_full_name,
14042 make_number (fontp->size)), 14042 make_number (fontp->size)),
14043 Qnil)), 14043 Qnil)),
14044 XCDR (dpyinfo->name_list_element)); 14044 XCDR (dpyinfo->name_list_element)));
14045 if (full_name) 14045 if (full_name)
14046 { 14046 {
14047 key = Fcons (Fcons (lispy_full_name, make_number (256)), 14047 key = Fcons (Fcons (lispy_full_name, make_number (256)),
14048 Qnil); 14048 Qnil);
14049 XCDR (dpyinfo->name_list_element) 14049 XSETCDR (dpyinfo->name_list_element,
14050 = Fcons (Fcons (key, 14050 Fcons (Fcons (key,
14051 Fcons (Fcons (lispy_full_name, 14051 Fcons (Fcons (lispy_full_name,
14052 make_number (fontp->size)), 14052 make_number (fontp->size)),
14053 Qnil)), 14053 Qnil)),
14054 XCDR (dpyinfo->name_list_element)); 14054 XCDR (dpyinfo->name_list_element)));
14055 } 14055 }
14056 } 14056 }
14057 14057
@@ -14622,7 +14622,7 @@ x_delete_display (dpyinfo)
14622 { 14622 {
14623 if (EQ (XCAR (XCDR (tail)), dpyinfo->name_list_element)) 14623 if (EQ (XCAR (XCDR (tail)), dpyinfo->name_list_element))
14624 { 14624 {
14625 XCDR (tail) = XCDR (XCDR (tail)); 14625 XSETCDR (tail, XCDR (XCDR (tail)));
14626 break; 14626 break;
14627 } 14627 }
14628 tail = XCDR (tail); 14628 tail = XCDR (tail);