aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-05-06 00:13:19 -0700
committerPaul Eggert2011-05-06 00:13:19 -0700
commitb08a63ccec4bda5556777ab8538b92726fd55a1e (patch)
treeceff3193260c813b66dff7254920ef8dc4a05b3f /src
parent548d0a63d6212c0baef9a3d2bf0093cceb4e1136 (diff)
parent8ff0ac3c78498c905a22786aa124f59d213b99a0 (diff)
downloademacs-b08a63ccec4bda5556777ab8538b92726fd55a1e.tar.gz
emacs-b08a63ccec4bda5556777ab8538b92726fd55a1e.zip
Do not assume EMACS_INT is the same width as a pointer.
This prepares for a future patch that will prefer 64-bit EMACS_INT if available. That patch can be tried now, by compiling with -DWIDE_EMACS_INT, but it is temporarily not the default so that it can be further tested. Also, install some other fixes for problems discovered by the static checking of GCC 4.6.0. Fixes: debbugs:8545 debbugs:8601 debbugs:8600 debbugs:8602
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog115
-rw-r--r--src/alloc.c42
-rw-r--r--src/callproc.c17
-rw-r--r--src/charset.c8
-rw-r--r--src/charset.h7
-rw-r--r--src/coding.c4
-rw-r--r--src/dbusbind.c8
-rw-r--r--src/dispnew.c4
-rw-r--r--src/doc.c9
-rw-r--r--src/doprnt.c58
-rw-r--r--src/eval.c9
-rw-r--r--src/fns.c4
-rw-r--r--src/gtkutil.c31
-rw-r--r--src/image.c4
-rw-r--r--src/lisp.h62
-rw-r--r--src/lread.c125
-rw-r--r--src/menu.c8
-rw-r--r--src/process.c3
-rw-r--r--src/sysdep.c21
-rw-r--r--src/term.c2
-rw-r--r--src/xdisp.c21
-rw-r--r--src/xmenu.c14
22 files changed, 354 insertions, 222 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 0df53250d7e..8d4ce09e4f7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,118 @@
12011-05-06 Paul Eggert <eggert@cs.ucla.edu>
2
3 * image.c (Finit_image_library) [!HAVE_NTGUI]: Omit unused local.
4
5 * term.c (vfatal): Remove stray call to va_end.
6 It's not needed and the C Standard doesn't allow it here anyway.
7
8 Use C99's va_copy to avoid undefined behavior on x86-64 GNU/Linux.
9 * eval.c (verror): doprnt a copy of ap, not the original. (Bug#8545)
10
11 * eval.c (verror): OK to create a string of up to MOST_POSITIVE_FIXNUM
12 bytes.
13
14 * term.c: Don't include <stdarg.h>, as <lisp.h> does that.
15
16 * callproc.c (Fcall_process): Use 'volatile' to avoid vfork clobbering.
17
18 * process.c (Fformat_network_address): Fix typo: args2 -> *args2.
19
20 * xmenu.c (set_frame_menubar): Fix typo: int * -> int (3 times).
21
22 * coding.c (detect_coding_charset): Fix typo: * 2 -> *4 (Bug#8601).
23
24 * charset.h (struct charset.code_space): Now has 15 elements, not 16.
25 * charset.c (Fdefine_charset_internal): Don't initialize
26 charset.code_space[15]. The value was garbage, on hosts with
27 32-bit int (Bug#8600).
28
29 * lread.c (read_integer): Be more consistent with string-to-number.
30 Use string_to_number to do the actual conversion; this avoids
31 rounding errors and fixes some other screwups. Without this fix,
32 for example, #x1fffffffffffffff was misread as -2305843009213693952.
33 (digit_to_number): Move earlier, for benefit of read_integer.
34 Return -1 if the digit is out of range for the base, -2 if it is
35 not a digit in any supported base. (Bug#8602)
36
37 * doprnt.c (doprnt): Support arbitrary pI values, such as "I64".
38
39 * dispnew.c (scrolling_window): Return 1 if we scrolled,
40 to match comment at start of function. This also removes a
41 GCC warning about overflow in a 32+64-bit port.
42
43 * lisp.h (EMACS_INT, EMACS_UINT, BITS_PER_EMACS_INT, pI): Simplify.
44
45 * dbusbind.c: Do not use XPNTR on a value that may be an integer.
46 Reported by Stefan Monnier in
47 <http://lists.gnu.org/archive/html/emacs-devel/2011-04/msg00919.html>.
48 (xd_remove_watch, Fdbus_init_bus, xd_read_queued_messages): Use
49 SYMBOLP-guarded XSYMBOL, not XPNTR.
50
51 * lisp.h (EMACS_INTPTR): Remove. All uses changed to intptr_t.
52 (EMACS_UINTPTR): Likewise, with uintptr_t.
53
54 * lisp.h: Prefer 64-bit EMACS_INT if available.
55 (EMACS_INT, EMACS_UINT, BITS_PER_EMACS_INT, pI): Define to 64-bit
56 on 32-bit hosts that have 64-bit int, so that they can access
57 large files.
58 However, temporarily disable this change unless the temporary
59 symbol WIDE_EMACS_INT is defined.
60
61 * lread.c, process.c: Do not include <inttypes.h>; lisp.h does it now.
62
63 Prefer intptr_t/uintptr_t for integers the same widths as pointers.
64 This removes an assumption that EMACS_INT and long are the same
65 width as pointers. The assumption is true for Emacs porting targets
66 now, but we want to make other targets possible.
67 * lisp.h: Include <inttypes.h>, for INTPTR_MAX, UINTPTR_MAX.
68 (EMACS_INTPTR, EMACS_UINTPTR): New macros.
69 In the rest of the code, change types of integers that hold casted
70 pointers to EMACS_INTPTR and EMACS_UINTPTR, systematically
71 replacing EMACS_INT, long, EMACS_UINT, and unsigned long.
72 (XTYPE): Don't cast arg to EMACS_UINT; normally is not needed.
73 (XSET): Cast type of XTYPE arg to EMACS_INTPTR; it is needed here.
74 No need to cast type when ORing.
75 (XPNTR): Return a value of type EMACS_INTPTR or EMACS_UINTPTR.
76 * alloc.c (lisp_align_malloc): Remove a no-longer-needed cast.
77 * doc.c (store_function_docstring): Use EMACS_INTPTR, so as not to
78 assume EMACS_INT is the same width as char *.
79 * gtkutil.c (xg_gtk_scroll_destroy, xg_tool_bar_button_cb):
80 (xg_tool_bar_callback, xg_tool_bar_help_callback, xg_make_tool_item):
81 Remove no-longer-needed casts.
82 (xg_create_scroll_bar, xg_tool_bar_button_cb, xg_tool_bar_callback):
83 (xg_tool_bar_help_callback, xg_make_tool_item):
84 Use EMACS_INTPTR to hold an integer
85 that will be cast to void *; this can avoid a GCC warning
86 if EMACS_INT is not the same width as void *.
87 * menu.c (find_and_call_menu_selection): Remove no-longer-needed cast.
88 * xdisp.c (display_echo_area_1, resize_mini_window_1):
89 (current_message_1, set_message_1):
90 Use a local to convert to proper width without a cast.
91 * xmenu.c (dialog_selection_callback): Likewise.
92
93 * sysdep.c (get_random): Don't assume EMACS_INT is no wider than long.
94 Also, don't assume VALBITS / RAND_BITS is less than 5,
95 and don't rely on undefined behavior when shifting a 1 left into
96 the sign bit.
97 * lisp.h (get_random): Change signature to match.
98
99 * lread.c (hash_string): Use size_t, not int, for hash computation.
100 Normally we prefer signed values; but hashing is special, because
101 it's better to use unsigned division on hash table sizes so that
102 the remainder is nonnegative. Also, size_t is the natural width
103 for hashing into memory. The previous code used 'int', which doesn't
104 retain enough info to hash well into very large tables.
105 (oblookup, oblookup_last_bucket_number, Funintern): Likewise.
106
107 * dbusbind.c: Don't possibly lose pointer info when converting.
108 (xd_remove_watch, Fdbus_init_bus, xd_read_queued_messages):
109 Use XPNTR rather than XHASH, so that the high-order bits of
110 the pointer aren't lost when converting through void *.
111
112 * eval.c (Fautoload): Don't double-shift a pointer.
113
114 * fns.c (Frandom): Let EMACS_UINT be wider than unsigned long.
115
12011-05-06 Juanma Barranquero <lekktu@gmail.com> 1162011-05-06 Juanma Barranquero <lekktu@gmail.com>
2 117
3 * gnutls.c (DEF_GNUTLS_FN): 118 * gnutls.c (DEF_GNUTLS_FN):
diff --git a/src/alloc.c b/src/alloc.c
index 842088f4e92..0bce83bfae7 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -438,7 +438,7 @@ static POINTER_TYPE *pure_alloc (size_t, int);
438 ALIGNMENT must be a power of 2. */ 438 ALIGNMENT must be a power of 2. */
439 439
440#define ALIGN(ptr, ALIGNMENT) \ 440#define ALIGN(ptr, ALIGNMENT) \
441 ((POINTER_TYPE *) ((((EMACS_UINT)(ptr)) + (ALIGNMENT) - 1) \ 441 ((POINTER_TYPE *) ((((uintptr_t) (ptr)) + (ALIGNMENT) - 1) \
442 & ~((ALIGNMENT) - 1))) 442 & ~((ALIGNMENT) - 1)))
443 443
444 444
@@ -876,7 +876,7 @@ struct ablocks
876#define ABLOCKS_BYTES (sizeof (struct ablocks) - BLOCK_PADDING) 876#define ABLOCKS_BYTES (sizeof (struct ablocks) - BLOCK_PADDING)
877 877
878#define ABLOCK_ABASE(block) \ 878#define ABLOCK_ABASE(block) \
879 (((unsigned long) (block)->abase) <= (1 + 2 * ABLOCKS_SIZE) \ 879 (((uintptr_t) (block)->abase) <= (1 + 2 * ABLOCKS_SIZE) \
880 ? (struct ablocks *)(block) \ 880 ? (struct ablocks *)(block) \
881 : (block)->abase) 881 : (block)->abase)
882 882
@@ -888,7 +888,7 @@ struct ablocks
888#define ABLOCKS_BASE(abase) (abase) 888#define ABLOCKS_BASE(abase) (abase)
889#else 889#else
890#define ABLOCKS_BASE(abase) \ 890#define ABLOCKS_BASE(abase) \
891 (1 & (long) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1]) 891 (1 & (intptr_t) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1])
892#endif 892#endif
893 893
894/* The list of free ablock. */ 894/* The list of free ablock. */
@@ -914,7 +914,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
914 if (!free_ablock) 914 if (!free_ablock)
915 { 915 {
916 int i; 916 int i;
917 EMACS_INT aligned; /* int gets warning casting to 64-bit pointer. */ 917 intptr_t aligned; /* int gets warning casting to 64-bit pointer. */
918 918
919#ifdef DOUG_LEA_MALLOC 919#ifdef DOUG_LEA_MALLOC
920 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed 920 /* Prevent mmap'ing the chunk. Lisp data may not be mmap'ed
@@ -977,17 +977,18 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
977 abase->blocks[i].x.next_free = free_ablock; 977 abase->blocks[i].x.next_free = free_ablock;
978 free_ablock = &abase->blocks[i]; 978 free_ablock = &abase->blocks[i];
979 } 979 }
980 ABLOCKS_BUSY (abase) = (struct ablocks *) (long) aligned; 980 ABLOCKS_BUSY (abase) = (struct ablocks *) aligned;
981 981
982 eassert (0 == ((EMACS_UINT)abase) % BLOCK_ALIGN); 982 eassert (0 == ((uintptr_t) abase) % BLOCK_ALIGN);
983 eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */ 983 eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */
984 eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase); 984 eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase);
985 eassert (ABLOCKS_BASE (abase) == base); 985 eassert (ABLOCKS_BASE (abase) == base);
986 eassert (aligned == (long) ABLOCKS_BUSY (abase)); 986 eassert (aligned == (intptr_t) ABLOCKS_BUSY (abase));
987 } 987 }
988 988
989 abase = ABLOCK_ABASE (free_ablock); 989 abase = ABLOCK_ABASE (free_ablock);
990 ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (long) ABLOCKS_BUSY (abase)); 990 ABLOCKS_BUSY (abase) =
991 (struct ablocks *) (2 + (intptr_t) ABLOCKS_BUSY (abase));
991 val = free_ablock; 992 val = free_ablock;
992 free_ablock = free_ablock->x.next_free; 993 free_ablock = free_ablock->x.next_free;
993 994
@@ -1000,7 +1001,7 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
1000 if (!val && nbytes) 1001 if (!val && nbytes)
1001 memory_full (); 1002 memory_full ();
1002 1003
1003 eassert (0 == ((EMACS_UINT)val) % BLOCK_ALIGN); 1004 eassert (0 == ((uintptr_t) val) % BLOCK_ALIGN);
1004 return val; 1005 return val;
1005} 1006}
1006 1007
@@ -1018,11 +1019,12 @@ lisp_align_free (POINTER_TYPE *block)
1018 ablock->x.next_free = free_ablock; 1019 ablock->x.next_free = free_ablock;
1019 free_ablock = ablock; 1020 free_ablock = ablock;
1020 /* Update busy count. */ 1021 /* Update busy count. */
1021 ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY (abase)); 1022 ABLOCKS_BUSY (abase) =
1023 (struct ablocks *) (-2 + (intptr_t) ABLOCKS_BUSY (abase));
1022 1024
1023 if (2 > (long) ABLOCKS_BUSY (abase)) 1025 if (2 > (intptr_t) ABLOCKS_BUSY (abase))
1024 { /* All the blocks are free. */ 1026 { /* All the blocks are free. */
1025 int i = 0, aligned = (long) ABLOCKS_BUSY (abase); 1027 int i = 0, aligned = (intptr_t) ABLOCKS_BUSY (abase);
1026 struct ablock **tem = &free_ablock; 1028 struct ablock **tem = &free_ablock;
1027 struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1]; 1029 struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1];
1028 1030
@@ -1039,7 +1041,7 @@ lisp_align_free (POINTER_TYPE *block)
1039 eassert ((aligned & 1) == aligned); 1041 eassert ((aligned & 1) == aligned);
1040 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1)); 1042 eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1));
1041#ifdef USE_POSIX_MEMALIGN 1043#ifdef USE_POSIX_MEMALIGN
1042 eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0); 1044 eassert ((uintptr_t) ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0);
1043#endif 1045#endif
1044 free (ABLOCKS_BASE (abase)); 1046 free (ABLOCKS_BASE (abase));
1045 } 1047 }
@@ -1772,7 +1774,7 @@ check_string_free_list (void)
1772 s = string_free_list; 1774 s = string_free_list;
1773 while (s != NULL) 1775 while (s != NULL)
1774 { 1776 {
1775 if ((unsigned long)s < 1024) 1777 if ((uintptr_t) s < 1024)
1776 abort(); 1778 abort();
1777 s = NEXT_FREE_LISP_STRING (s); 1779 s = NEXT_FREE_LISP_STRING (s);
1778 } 1780 }
@@ -2432,10 +2434,10 @@ make_uninit_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes)
2432 &= ~(1 << ((n) % (sizeof(int) * CHAR_BIT))) 2434 &= ~(1 << ((n) % (sizeof(int) * CHAR_BIT)))
2433 2435
2434#define FLOAT_BLOCK(fptr) \ 2436#define FLOAT_BLOCK(fptr) \
2435 ((struct float_block *)(((EMACS_UINT)(fptr)) & ~(BLOCK_ALIGN - 1))) 2437 ((struct float_block *) (((uintptr_t) (fptr)) & ~(BLOCK_ALIGN - 1)))
2436 2438
2437#define FLOAT_INDEX(fptr) \ 2439#define FLOAT_INDEX(fptr) \
2438 ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Float)) 2440 ((((uintptr_t) (fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Float))
2439 2441
2440struct float_block 2442struct float_block
2441{ 2443{
@@ -2544,10 +2546,10 @@ make_float (double float_value)
2544 / (sizeof (struct Lisp_Cons) * CHAR_BIT + 1)) 2546 / (sizeof (struct Lisp_Cons) * CHAR_BIT + 1))
2545 2547
2546#define CONS_BLOCK(fptr) \ 2548#define CONS_BLOCK(fptr) \
2547 ((struct cons_block *)(((EMACS_UINT)(fptr)) & ~(BLOCK_ALIGN - 1))) 2549 ((struct cons_block *) ((uintptr_t) (fptr) & ~(BLOCK_ALIGN - 1)))
2548 2550
2549#define CONS_INDEX(fptr) \ 2551#define CONS_INDEX(fptr) \
2550 ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Cons)) 2552 (((uintptr_t) (fptr) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Cons))
2551 2553
2552struct cons_block 2554struct cons_block
2553{ 2555{
@@ -4021,7 +4023,7 @@ mark_maybe_pointer (void *p)
4021 struct mem_node *m; 4023 struct mem_node *m;
4022 4024
4023 /* Quickly rule out some values which can't point to Lisp data. */ 4025 /* Quickly rule out some values which can't point to Lisp data. */
4024 if ((EMACS_INT) p % 4026 if ((intptr_t) p %
4025#ifdef USE_LSB_TAG 4027#ifdef USE_LSB_TAG
4026 8 /* USE_LSB_TAG needs Lisp data to be aligned on multiples of 8. */ 4028 8 /* USE_LSB_TAG needs Lisp data to be aligned on multiples of 8. */
4027#else 4029#else
@@ -6072,7 +6074,7 @@ We divide the value by 1024 to make sure it fits in a Lisp integer. */)
6072{ 6074{
6073 Lisp_Object end; 6075 Lisp_Object end;
6074 6076
6075 XSETINT (end, (EMACS_INT) (char *) sbrk (0) / 1024); 6077 XSETINT (end, (intptr_t) (char *) sbrk (0) / 1024);
6076 6078
6077 return end; 6079 return end;
6078} 6080}
diff --git a/src/callproc.c b/src/callproc.c
index 1d3d8764ff8..946670320ca 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -193,7 +193,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
193 int count = SPECPDL_INDEX (); 193 int count = SPECPDL_INDEX ();
194 volatile USE_SAFE_ALLOCA; 194 volatile USE_SAFE_ALLOCA;
195 195
196 const unsigned char **volatile new_argv_volatile;
197 register const unsigned char **new_argv; 196 register const unsigned char **new_argv;
198 /* File to use for stderr in the child. 197 /* File to use for stderr in the child.
199 t means use same as standard output. */ 198 t means use same as standard output. */
@@ -416,7 +415,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
416 415
417 SAFE_ALLOCA (new_argv, const unsigned char **, 416 SAFE_ALLOCA (new_argv, const unsigned char **,
418 (nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv); 417 (nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv);
419 new_argv_volatile = new_argv;
420 if (nargs > 4) 418 if (nargs > 4)
421 { 419 {
422 register size_t i; 420 register size_t i;
@@ -591,9 +589,20 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
591 589
592 BLOCK_INPUT; 590 BLOCK_INPUT;
593 591
594 pid = vfork (); 592 /* vfork, and prevent local vars from being clobbered by the vfork. */
593 {
594 int volatile fd_error_volatile = fd_error;
595 int volatile fd_output_volatile = fd_output;
596 int volatile output_to_buffer_volatile = output_to_buffer;
597 unsigned char const **volatile new_argv_volatile = new_argv;
598
599 pid = vfork ();
595 600
596 new_argv = new_argv_volatile; 601 fd_error = fd_error_volatile;
602 fd_output = fd_output_volatile;
603 output_to_buffer = output_to_buffer_volatile;
604 new_argv = new_argv_volatile;
605 }
597 606
598 if (pid == 0) 607 if (pid == 0)
599 { 608 {
diff --git a/src/charset.c b/src/charset.c
index 52c2ebdcc4e..55fd57031ac 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -869,7 +869,7 @@ usage: (define-charset-internal ...) */)
869 ASET (attrs, charset_name, args[charset_arg_name]); 869 ASET (attrs, charset_name, args[charset_arg_name]);
870 870
871 val = args[charset_arg_code_space]; 871 val = args[charset_arg_code_space];
872 for (i = 0, dimension = 0, nchars = 1; i < 4; i++) 872 for (i = 0, dimension = 0, nchars = 1; ; i++)
873 { 873 {
874 int min_byte, max_byte; 874 int min_byte, max_byte;
875 875
@@ -880,10 +880,12 @@ usage: (define-charset-internal ...) */)
880 charset.code_space[i * 4] = min_byte; 880 charset.code_space[i * 4] = min_byte;
881 charset.code_space[i * 4 + 1] = max_byte; 881 charset.code_space[i * 4 + 1] = max_byte;
882 charset.code_space[i * 4 + 2] = max_byte - min_byte + 1; 882 charset.code_space[i * 4 + 2] = max_byte - min_byte + 1;
883 nchars *= charset.code_space[i * 4 + 2];
884 charset.code_space[i * 4 + 3] = nchars;
885 if (max_byte > 0) 883 if (max_byte > 0)
886 dimension = i + 1; 884 dimension = i + 1;
885 if (i == 3)
886 break;
887 nchars *= charset.code_space[i * 4 + 2];
888 charset.code_space[i * 4 + 3] = nchars;
887 } 889 }
888 890
889 val = args[charset_arg_dimension]; 891 val = args[charset_arg_dimension];
diff --git a/src/charset.h b/src/charset.h
index 74d55a31b43..53784bf8455 100644
--- a/src/charset.h
+++ b/src/charset.h
@@ -155,10 +155,11 @@ struct charset
155 byte code of the (N+1)th dimension, <code_space>[4N+1] is a 155 byte code of the (N+1)th dimension, <code_space>[4N+1] is a
156 maximum byte code of the (N+1)th dimension, <code_space>[4N+2] is 156 maximum byte code of the (N+1)th dimension, <code_space>[4N+2] is
157 (<code_space>[4N+1] - <code_space>[4N] + 1), <code_space>[4N+3] 157 (<code_space>[4N+1] - <code_space>[4N] + 1), <code_space>[4N+3]
158 is a number of characters containd in the first to (N+1)th 158 is the number of characters contained in the first through (N+1)th
159 dismesions. We get `char-index' of a `code-point' from this 159 dimensions, except that there is no <code_space>[15].
160 We get `char-index' of a `code-point' from this
160 information. */ 161 information. */
161 int code_space[16]; 162 int code_space[15];
162 163
163 /* If B is a byte of Nth dimension of a code-point, the (N-1)th bit 164 /* If B is a byte of Nth dimension of a code-point, the (N-1)th bit
164 of code_space_mask[B] is set. This array is used to quickly 165 of code_space_mask[B] is set. This array is used to quickly
diff --git a/src/coding.c b/src/coding.c
index d17346efdcb..71253df6469 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5368,8 +5368,8 @@ detect_coding_charset (struct coding_system *coding,
5368 if (src == src_end) 5368 if (src == src_end)
5369 goto too_short; 5369 goto too_short;
5370 ONE_MORE_BYTE (c); 5370 ONE_MORE_BYTE (c);
5371 if (c < charset->code_space[(dim - 1 - idx) * 2] 5371 if (c < charset->code_space[(dim - 1 - idx) * 4]
5372 || c > charset->code_space[(dim - 1 - idx) * 2 + 1]) 5372 || c > charset->code_space[(dim - 1 - idx) * 4 + 1])
5373 break; 5373 break;
5374 } 5374 }
5375 if (idx < dim) 5375 if (idx < dim)
diff --git a/src/dbusbind.c b/src/dbusbind.c
index 4c0b9bd017a..76035341540 100644
--- a/src/dbusbind.c
+++ b/src/dbusbind.c
@@ -892,7 +892,7 @@ xd_remove_watch (DBusWatch *watch, void *data)
892 return; 892 return;
893 893
894 /* Unset session environment. */ 894 /* Unset session environment. */
895 if (data != NULL && data == (void*) XHASH (QCdbus_session_bus)) 895 if (SYMBOLP (QCdbus_session_bus) && XSYMBOL (QCdbus_session_bus) == data)
896 { 896 {
897 XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS"); 897 XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
898 unsetenv ("DBUS_SESSION_BUS_ADDRESS"); 898 unsetenv ("DBUS_SESSION_BUS_ADDRESS");
@@ -920,6 +920,8 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0,
920{ 920{
921 DBusConnection *connection; 921 DBusConnection *connection;
922 922
923 CHECK_SYMBOL (bus);
924
923 /* Open a connection to the bus. */ 925 /* Open a connection to the bus. */
924 connection = xd_initialize (bus, TRUE); 926 connection = xd_initialize (bus, TRUE);
925 927
@@ -929,7 +931,7 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0,
929 xd_add_watch, 931 xd_add_watch,
930 xd_remove_watch, 932 xd_remove_watch,
931 xd_toggle_watch, 933 xd_toggle_watch,
932 (void*) XHASH (bus), NULL)) 934 XSYMBOL (bus), NULL))
933 XD_SIGNAL1 (build_string ("Cannot add watch functions")); 935 XD_SIGNAL1 (build_string ("Cannot add watch functions"));
934 936
935 /* Add bus to list of registered buses. */ 937 /* Add bus to list of registered buses. */
@@ -1824,7 +1826,7 @@ xd_read_queued_messages (int fd, void *data, int for_read)
1824 if (data != NULL) 1826 if (data != NULL)
1825 while (!NILP (busp)) 1827 while (!NILP (busp))
1826 { 1828 {
1827 if (data == (void*) XHASH (CAR_SAFE (busp))) 1829 if (SYMBOLP (CAR_SAFE (busp)) && XSYMBOL (CAR_SAFE (busp)) == data)
1828 bus = CAR_SAFE (busp); 1830 bus = CAR_SAFE (busp);
1829 busp = CDR_SAFE (busp); 1831 busp = CDR_SAFE (busp);
1830 } 1832 }
diff --git a/src/dispnew.c b/src/dispnew.c
index 13e920166c5..0457d650b3a 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -4576,8 +4576,8 @@ scrolling_window (struct window *w, int header_line_p)
4576 for (i = 0; i < row_entry_idx; ++i) 4576 for (i = 0; i < row_entry_idx; ++i)
4577 row_table[row_entry_pool[i].bucket] = NULL; 4577 row_table[row_entry_pool[i].bucket] = NULL;
4578 4578
4579 /* Value is > 0 to indicate that we scrolled the display. */ 4579 /* Value is 1 to indicate that we scrolled the display. */
4580 return nruns; 4580 return 0 < nruns;
4581} 4581}
4582 4582
4583 4583
diff --git a/src/doc.c b/src/doc.c
index 3832eb3708d..89a7d322966 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -349,10 +349,10 @@ string is passed through `substitute-command-keys'. */)
349 return Qnil; 349 return Qnil;
350 /* FIXME: This is not portable, as it assumes that string 350 /* FIXME: This is not portable, as it assumes that string
351 pointers have the top bit clear. */ 351 pointers have the top bit clear. */
352 else if ((EMACS_INT) XSUBR (fun)->doc >= 0) 352 else if ((intptr_t) XSUBR (fun)->doc >= 0)
353 doc = build_string (XSUBR (fun)->doc); 353 doc = build_string (XSUBR (fun)->doc);
354 else 354 else
355 doc = make_number ((EMACS_INT) XSUBR (fun)->doc); 355 doc = make_number ((intptr_t) XSUBR (fun)->doc);
356 } 356 }
357 else if (COMPILEDP (fun)) 357 else if (COMPILEDP (fun))
358 { 358 {
@@ -507,7 +507,10 @@ store_function_docstring (Lisp_Object fun, EMACS_INT offset)
507 507
508 /* Lisp_Subrs have a slot for it. */ 508 /* Lisp_Subrs have a slot for it. */
509 if (SUBRP (fun)) 509 if (SUBRP (fun))
510 XSUBR (fun)->doc = (char *) - offset; 510 {
511 intptr_t negative_offset = - offset;
512 XSUBR (fun)->doc = (char *) negative_offset;
513 }
511 514
512 /* If it's a lisp form, stick it in the form. */ 515 /* If it's a lisp form, stick it in the form. */
513 else if (CONSP (fun)) 516 else if (CONSP (fun))
diff --git a/src/doprnt.c b/src/doprnt.c
index 7b4bd35d5b1..d2abc119912 100644
--- a/src/doprnt.c
+++ b/src/doprnt.c
@@ -70,9 +70,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
70 %<flags><width><precision><length>character 70 %<flags><width><precision><length>character
71 71
72 where flags is [+ -0], width is [0-9]+, precision is .[0-9]+, and length 72 where flags is [+ -0], width is [0-9]+, precision is .[0-9]+, and length
73 is empty or l or ll. Also, %% in a format stands for a single % in the 73 is empty or l or the value of the pI macro. Also, %% in a format
74 output. A % that does not introduce a valid %-sequence causes 74 stands for a single % in the output. A % that does not introduce a
75 undefined behavior. 75 valid %-sequence causes undefined behavior.
76 76
77 The + flag character inserts a + before any positive number, while a space 77 The + flag character inserts a + before any positive number, while a space
78 inserts a space before any positive number; these flags only affect %d, %o, 78 inserts a space before any positive number; these flags only affect %d, %o,
@@ -85,11 +85,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
85 modifier: it is supported for %d, %o, and %x conversions of integral 85 modifier: it is supported for %d, %o, and %x conversions of integral
86 arguments, must immediately precede the conversion specifier, and means that 86 arguments, must immediately precede the conversion specifier, and means that
87 the respective argument is to be treated as `long int' or `unsigned long 87 the respective argument is to be treated as `long int' or `unsigned long
88 int'. Similarly, ll (two letter ells) means to use `long long int' or 88 int'. Similarly, the value of the pI macro means to use EMACS_INT or
89 `unsigned long long int'; this can be used only on hosts that have 89 EMACS_UINT and the empty length modifier means `int' or `unsigned int'.
90 these two types. The empty length modifier means to use `int' or
91 `unsigned int'. EMACS_INT arguments should use the pI macro, which
92 expands to whatever length modifier is needed for the target host.
93 90
94 The width specifier supplies a lower limit for the length of the printed 91 The width specifier supplies a lower limit for the length of the printed
95 representation. The padding, if any, normally goes on the left, but it goes 92 representation. The padding, if any, normally goes on the left, but it goes
@@ -186,6 +183,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
186 size_t size_bound = 0; 183 size_t size_bound = 0;
187 EMACS_INT width; /* Columns occupied by STRING on display. */ 184 EMACS_INT width; /* Columns occupied by STRING on display. */
188 int long_flag = 0; 185 int long_flag = 0;
186 int pIlen = sizeof pI - 1;
189 187
190 fmt++; 188 fmt++;
191 /* Copy this one %-spec into fmtcpy. */ 189 /* Copy this one %-spec into fmtcpy. */
@@ -201,7 +199,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
201 %1.1000f and %1000.1f both might need 1000+ bytes. 199 %1.1000f and %1000.1f both might need 1000+ bytes.
202 Parse the width or precision, checking for overflow. */ 200 Parse the width or precision, checking for overflow. */
203 size_t n = *fmt - '0'; 201 size_t n = *fmt - '0';
204 while (fmt < format_end 202 while (fmt + 1 < format_end
205 && '0' <= fmt[1] && fmt[1] <= '9') 203 && '0' <= fmt[1] && fmt[1] <= '9')
206 { 204 {
207 /* Avoid size_t overflow. Avoid int overflow too, as 205 /* Avoid size_t overflow. Avoid int overflow too, as
@@ -218,20 +216,25 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
218 if (size_bound < n) 216 if (size_bound < n)
219 size_bound = n; 217 size_bound = n;
220 } 218 }
221 else if (*fmt == '-' || *fmt == ' ' || *fmt == '.' || *fmt == '+') 219 else if (! (*fmt == '-' || *fmt == ' ' || *fmt == '.'
222 ; 220 || *fmt == '+'))
223 else if (*fmt == 'l')
224 {
225 long_flag = 1 + (fmt + 1 < format_end && fmt[1] == 'l');
226 fmt += long_flag;
227 break;
228 }
229 else
230 break; 221 break;
231 fmt++; 222 fmt++;
232 } 223 }
233 if (fmt > format_end) 224
234 fmt = format_end; 225 if (0 < pIlen && pIlen <= format_end - fmt
226 && memcmp (fmt, pI, pIlen) == 0)
227 {
228 long_flag = 2;
229 memcpy (string, fmt + 1, pIlen);
230 string += pIlen;
231 fmt += pIlen;
232 }
233 else if (fmt < format_end && *fmt == 'l')
234 {
235 long_flag = 1;
236 *string++ = *++fmt;
237 }
235 *string = 0; 238 *string = 0;
236 239
237 /* Make the size bound large enough to handle floating point formats 240 /* Make the size bound large enough to handle floating point formats
@@ -253,8 +256,7 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
253 switch (*fmt++) 256 switch (*fmt++)
254 { 257 {
255 default: 258 default:
256 error ("Invalid format operation %%%s%c", 259 error ("Invalid format operation %s", fmtcpy);
257 "ll" + 2 - long_flag, fmt[-1]);
258 260
259/* case 'b': */ 261/* case 'b': */
260 case 'l': 262 case 'l':
@@ -265,12 +267,8 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
265 267
266 if (1 < long_flag) 268 if (1 < long_flag)
267 { 269 {
268#ifdef HAVE_LONG_LONG_INT 270 EMACS_INT ll = va_arg (ap, EMACS_INT);
269 long long ll = va_arg (ap, long long);
270 sprintf (sprintf_buffer, fmtcpy, ll); 271 sprintf (sprintf_buffer, fmtcpy, ll);
271#else
272 error ("Invalid format operation %%ll%c", fmt[-1]);
273#endif
274 } 272 }
275 else if (long_flag) 273 else if (long_flag)
276 { 274 {
@@ -295,12 +293,8 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
295 293
296 if (1 < long_flag) 294 if (1 < long_flag)
297 { 295 {
298#ifdef HAVE_UNSIGNED_LONG_LONG_INT 296 EMACS_UINT ull = va_arg (ap, EMACS_UINT);
299 unsigned long long ull = va_arg (ap, unsigned long long);
300 sprintf (sprintf_buffer, fmtcpy, ull); 297 sprintf (sprintf_buffer, fmtcpy, ull);
301#else
302 error ("Invalid format operation %%ll%c", fmt[-1]);
303#endif
304 } 298 }
305 else if (long_flag) 299 else if (long_flag)
306 { 300 {
diff --git a/src/eval.c b/src/eval.c
index ea090644c07..6b4182cb319 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -1994,7 +1994,7 @@ verror (const char *m, va_list ap)
1994{ 1994{
1995 char buf[4000]; 1995 char buf[4000];
1996 size_t size = sizeof buf; 1996 size_t size = sizeof buf;
1997 size_t size_max = min (MOST_POSITIVE_FIXNUM, SIZE_MAX); 1997 size_t size_max = min (MOST_POSITIVE_FIXNUM + 1, SIZE_MAX);
1998 size_t mlen = strlen (m); 1998 size_t mlen = strlen (m);
1999 char *buffer = buf; 1999 char *buffer = buf;
2000 size_t used; 2000 size_t used;
@@ -2002,7 +2002,10 @@ verror (const char *m, va_list ap)
2002 2002
2003 while (1) 2003 while (1)
2004 { 2004 {
2005 used = doprnt (buffer, size, m, m + mlen, ap); 2005 va_list ap_copy;
2006 va_copy (ap_copy, ap);
2007 used = doprnt (buffer, size, m, m + mlen, ap_copy);
2008 va_end (ap_copy);
2006 2009
2007 /* Note: the -1 below is because `doprnt' returns the number of bytes 2010 /* Note: the -1 below is because `doprnt' returns the number of bytes
2008 excluding the terminating null byte, and it always terminates with a 2011 excluding the terminating null byte, and it always terminates with a
@@ -2144,7 +2147,7 @@ this does nothing and returns nil. */)
2144 We used to use 0 here, but that leads to accidental sharing in 2147 We used to use 0 here, but that leads to accidental sharing in
2145 purecopy's hash-consing, so we use a (hopefully) unique integer 2148 purecopy's hash-consing, so we use a (hopefully) unique integer
2146 instead. */ 2149 instead. */
2147 docstring = make_number (XHASH (function)); 2150 docstring = make_number (XPNTR (function));
2148 return Ffset (function, 2151 return Ffset (function,
2149 Fpurecopy (list5 (Qautoload, file, docstring, 2152 Fpurecopy (list5 (Qautoload, file, docstring,
2150 interactive, type))); 2153 interactive, type)));
diff --git a/src/fns.c b/src/fns.c
index a128b9292c6..47ded456c6e 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -75,7 +75,7 @@ Other values of LIMIT are ignored. */)
75{ 75{
76 EMACS_INT val; 76 EMACS_INT val;
77 Lisp_Object lispy_val; 77 Lisp_Object lispy_val;
78 unsigned long denominator; 78 EMACS_UINT denominator;
79 79
80 if (EQ (limit, Qt)) 80 if (EQ (limit, Qt))
81 seed_random (getpid () + time (NULL)); 81 seed_random (getpid () + time (NULL));
@@ -88,7 +88,7 @@ Other values of LIMIT are ignored. */)
88 it's possible to get a quotient larger than n; discarding 88 it's possible to get a quotient larger than n; discarding
89 these values eliminates the bias that would otherwise appear 89 these values eliminates the bias that would otherwise appear
90 when using a large n. */ 90 when using a large n. */
91 denominator = ((unsigned long)1 << VALBITS) / XFASTINT (limit); 91 denominator = ((EMACS_UINT) 1 << VALBITS) / XFASTINT (limit);
92 do 92 do
93 val = get_random () / denominator; 93 val = get_random () / denominator;
94 while (val >= XFASTINT (limit)); 94 while (val >= XFASTINT (limit));
diff --git a/src/gtkutil.c b/src/gtkutil.c
index 9d3bfe6a89c..6e54006d913 100644
--- a/src/gtkutil.c
+++ b/src/gtkutil.c
@@ -3354,7 +3354,7 @@ xg_get_scroll_id_for_window (Display *dpy, Window wid)
3354static void 3354static void
3355xg_gtk_scroll_destroy (GtkWidget *widget, gpointer data) 3355xg_gtk_scroll_destroy (GtkWidget *widget, gpointer data)
3356{ 3356{
3357 int id = (int) (EMACS_INT) data; /* The EMACS_INT cast avoids a warning. */ 3357 int id = (intptr_t) data;
3358 xg_remove_widget_from_map (id); 3358 xg_remove_widget_from_map (id);
3359} 3359}
3360 3360
@@ -3375,7 +3375,7 @@ xg_create_scroll_bar (FRAME_PTR f,
3375{ 3375{
3376 GtkWidget *wscroll; 3376 GtkWidget *wscroll;
3377 GtkWidget *webox; 3377 GtkWidget *webox;
3378 int scroll_id; 3378 intptr_t scroll_id;
3379#ifdef HAVE_GTK3 3379#ifdef HAVE_GTK3
3380 GtkAdjustment *vadj; 3380 GtkAdjustment *vadj;
3381#else 3381#else
@@ -3397,11 +3397,10 @@ xg_create_scroll_bar (FRAME_PTR f,
3397 3397
3398 scroll_id = xg_store_widget_in_map (wscroll); 3398 scroll_id = xg_store_widget_in_map (wscroll);
3399 3399
3400 /* The EMACS_INT cast avoids a warning. */
3401 g_signal_connect (G_OBJECT (wscroll), 3400 g_signal_connect (G_OBJECT (wscroll),
3402 "destroy", 3401 "destroy",
3403 G_CALLBACK (xg_gtk_scroll_destroy), 3402 G_CALLBACK (xg_gtk_scroll_destroy),
3404 (gpointer) (EMACS_INT) scroll_id); 3403 (gpointer) scroll_id);
3405 g_signal_connect (G_OBJECT (wscroll), 3404 g_signal_connect (G_OBJECT (wscroll),
3406 "change-value", 3405 "change-value",
3407 scroll_callback, 3406 scroll_callback,
@@ -3663,8 +3662,8 @@ xg_tool_bar_button_cb (GtkWidget *widget,
3663 GdkEventButton *event, 3662 GdkEventButton *event,
3664 gpointer user_data) 3663 gpointer user_data)
3665{ 3664{
3666 /* Casts to avoid warnings when gpointer is 64 bits and int is 32 bits */ 3665 intptr_t state = event->state;
3667 gpointer ptr = (gpointer) (EMACS_INT) event->state; 3666 gpointer ptr = (gpointer) state;
3668 g_object_set_data (G_OBJECT (widget), XG_TOOL_BAR_LAST_MODIFIER, ptr); 3667 g_object_set_data (G_OBJECT (widget), XG_TOOL_BAR_LAST_MODIFIER, ptr);
3669 return FALSE; 3668 return FALSE;
3670} 3669}
@@ -3678,10 +3677,9 @@ xg_tool_bar_button_cb (GtkWidget *widget,
3678static void 3677static void
3679xg_tool_bar_callback (GtkWidget *w, gpointer client_data) 3678xg_tool_bar_callback (GtkWidget *w, gpointer client_data)
3680{ 3679{
3681 /* The EMACS_INT cast avoids a warning. */ 3680 intptr_t idx = (intptr_t) client_data;
3682 int idx = (int) (EMACS_INT) client_data;
3683 gpointer gmod = g_object_get_data (G_OBJECT (w), XG_TOOL_BAR_LAST_MODIFIER); 3681 gpointer gmod = g_object_get_data (G_OBJECT (w), XG_TOOL_BAR_LAST_MODIFIER);
3684 int mod = (int) (EMACS_INT) gmod; 3682 intptr_t mod = (intptr_t) gmod;
3685 3683
3686 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA); 3684 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA);
3687 Lisp_Object key, frame; 3685 Lisp_Object key, frame;
@@ -3960,8 +3958,7 @@ xg_tool_bar_help_callback (GtkWidget *w,
3960 GdkEventCrossing *event, 3958 GdkEventCrossing *event,
3961 gpointer client_data) 3959 gpointer client_data)
3962{ 3960{
3963 /* The EMACS_INT cast avoids a warning. */ 3961 intptr_t idx = (intptr_t) client_data;
3964 int idx = (int) (EMACS_INT) client_data;
3965 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA); 3962 FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA);
3966 Lisp_Object help, frame; 3963 Lisp_Object help, frame;
3967 3964
@@ -4155,14 +4152,16 @@ xg_make_tool_item (FRAME_PTR f,
4155 4152
4156 if (wimage) 4153 if (wimage)
4157 { 4154 {
4158 /* The EMACS_INT cast avoids a warning. */ 4155 intptr_t ii = i;
4156 gpointer gi = (gpointer) ii;
4157
4159 g_signal_connect (G_OBJECT (ti), "create-menu-proxy", 4158 g_signal_connect (G_OBJECT (ti), "create-menu-proxy",
4160 G_CALLBACK (xg_tool_bar_menu_proxy), 4159 G_CALLBACK (xg_tool_bar_menu_proxy),
4161 (gpointer) (EMACS_INT) i); 4160 gi);
4162 4161
4163 g_signal_connect (G_OBJECT (wb), "clicked", 4162 g_signal_connect (G_OBJECT (wb), "clicked",
4164 G_CALLBACK (xg_tool_bar_callback), 4163 G_CALLBACK (xg_tool_bar_callback),
4165 (gpointer) (EMACS_INT) i); 4164 gi);
4166 4165
4167 g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f); 4166 g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f);
4168 4167
@@ -4193,11 +4192,11 @@ xg_make_tool_item (FRAME_PTR f,
4193 g_signal_connect (G_OBJECT (weventbox), 4192 g_signal_connect (G_OBJECT (weventbox),
4194 "enter-notify-event", 4193 "enter-notify-event",
4195 G_CALLBACK (xg_tool_bar_help_callback), 4194 G_CALLBACK (xg_tool_bar_help_callback),
4196 (gpointer) (EMACS_INT) i); 4195 gi);
4197 g_signal_connect (G_OBJECT (weventbox), 4196 g_signal_connect (G_OBJECT (weventbox),
4198 "leave-notify-event", 4197 "leave-notify-event",
4199 G_CALLBACK (xg_tool_bar_help_callback), 4198 G_CALLBACK (xg_tool_bar_help_callback),
4200 (gpointer) (EMACS_INT) i); 4199 gi);
4201 } 4200 }
4202 4201
4203 if (wbutton) *wbutton = wb; 4202 if (wbutton) *wbutton = wb;
diff --git a/src/image.c b/src/image.c
index c091fea045e..747142635af 100644
--- a/src/image.c
+++ b/src/image.c
@@ -8602,11 +8602,9 @@ Libraries to load are specified in alist LIBRARIES (usually, the value
8602of `dynamic-library-alist', which see). */) 8602of `dynamic-library-alist', which see). */)
8603 (Lisp_Object type, Lisp_Object libraries) 8603 (Lisp_Object type, Lisp_Object libraries)
8604{ 8604{
8605 Lisp_Object tested;
8606
8607#ifdef HAVE_NTGUI 8605#ifdef HAVE_NTGUI
8608 /* Don't try to reload the library. */ 8606 /* Don't try to reload the library. */
8609 tested = Fassq (type, Vlibrary_cache); 8607 Lisp_Object tested = Fassq (type, Vlibrary_cache);
8610 if (CONSP (tested)) 8608 if (CONSP (tested))
8611 return XCDR (tested); 8609 return XCDR (tested);
8612#endif 8610#endif
diff --git a/src/lisp.h b/src/lisp.h
index 3eda487148e..66f5c962be8 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
22 22
23#include <stdarg.h> 23#include <stdarg.h>
24#include <stddef.h> 24#include <stddef.h>
25#include <inttypes.h>
25 26
26/* Use the configure flag --enable-checking[=LIST] to enable various 27/* Use the configure flag --enable-checking[=LIST] to enable various
27 types of run time checks for Lisp objects. */ 28 types of run time checks for Lisp objects. */
@@ -33,25 +34,28 @@ extern void check_cons_list (void);
33#define CHECK_CONS_LIST() ((void) 0) 34#define CHECK_CONS_LIST() ((void) 0)
34#endif 35#endif
35 36
37/* Temporarily disable wider-than-pointer integers until they're tested more.
38 Build with CFLAGS='-DWIDE_EMACS_INT' to try them out. */
39/* #undef WIDE_EMACS_INT */
40
36/* These are default choices for the types to use. */ 41/* These are default choices for the types to use. */
37#ifdef _LP64
38#ifndef EMACS_INT
39#define EMACS_INT long
40#define BITS_PER_EMACS_INT BITS_PER_LONG
41#define pI "l"
42#endif
43#ifndef EMACS_UINT
44#define EMACS_UINT unsigned long
45#endif
46#else /* not _LP64 */
47#ifndef EMACS_INT 42#ifndef EMACS_INT
48#define EMACS_INT int 43# if BITS_PER_LONG < BITS_PER_LONG_LONG && defined WIDE_EMACS_INT
49#define BITS_PER_EMACS_INT BITS_PER_INT 44# define EMACS_INT long long
50#define pI "" 45# define BITS_PER_EMACS_INT BITS_PER_LONG_LONG
46# define pI "ll"
47# elif BITS_PER_INT < BITS_PER_LONG
48# define EMACS_INT long
49# define BITS_PER_EMACS_INT BITS_PER_LONG
50# define pI "l"
51# else
52# define EMACS_INT int
53# define BITS_PER_EMACS_INT BITS_PER_INT
54# define pI ""
55# endif
51#endif 56#endif
52#ifndef EMACS_UINT 57#ifndef EMACS_UINT
53#define EMACS_UINT unsigned int 58# define EMACS_UINT unsigned EMACS_INT
54#endif
55#endif 59#endif
56 60
57/* Extra internal type checking? */ 61/* Extra internal type checking? */
@@ -398,7 +402,7 @@ enum pvec_type
398#ifdef USE_LSB_TAG 402#ifdef USE_LSB_TAG
399 403
400#define TYPEMASK ((((EMACS_INT) 1) << GCTYPEBITS) - 1) 404#define TYPEMASK ((((EMACS_INT) 1) << GCTYPEBITS) - 1)
401#define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT) (a)) & TYPEMASK)) 405#define XTYPE(a) ((enum Lisp_Type) ((a) & TYPEMASK))
402#ifdef USE_2_TAGS_FOR_INTS 406#ifdef USE_2_TAGS_FOR_INTS
403# define XINT(a) (((EMACS_INT) (a)) >> (GCTYPEBITS - 1)) 407# define XINT(a) (((EMACS_INT) (a)) >> (GCTYPEBITS - 1))
404# define XUINT(a) (((EMACS_UINT) (a)) >> (GCTYPEBITS - 1)) 408# define XUINT(a) (((EMACS_UINT) (a)) >> (GCTYPEBITS - 1))
@@ -408,11 +412,11 @@ enum pvec_type
408# define XUINT(a) (((EMACS_UINT) (a)) >> GCTYPEBITS) 412# define XUINT(a) (((EMACS_UINT) (a)) >> GCTYPEBITS)
409# define make_number(N) (((EMACS_INT) (N)) << GCTYPEBITS) 413# define make_number(N) (((EMACS_INT) (N)) << GCTYPEBITS)
410#endif 414#endif
411#define XSET(var, type, ptr) \ 415#define XSET(var, type, ptr) \
412 (eassert (XTYPE (ptr) == 0), /* Check alignment. */ \ 416 (eassert (XTYPE ((intptr_t) (ptr)) == 0), /* Check alignment. */ \
413 (var) = ((EMACS_INT) (type)) | ((EMACS_INT) (ptr))) 417 (var) = (type) | (intptr_t) (ptr))
414 418
415#define XPNTR(a) ((EMACS_INT) ((a) & ~TYPEMASK)) 419#define XPNTR(a) ((intptr_t) ((a) & ~TYPEMASK))
416 420
417#else /* not USE_LSB_TAG */ 421#else /* not USE_LSB_TAG */
418 422
@@ -446,14 +450,14 @@ enum pvec_type
446 450
447#define XSET(var, type, ptr) \ 451#define XSET(var, type, ptr) \
448 ((var) = ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \ 452 ((var) = ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \
449 + ((EMACS_INT) (ptr) & VALMASK))) 453 + ((intptr_t) (ptr) & VALMASK)))
450 454
451#ifdef DATA_SEG_BITS 455#ifdef DATA_SEG_BITS
452/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers 456/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
453 which were stored in a Lisp_Object */ 457 which were stored in a Lisp_Object */
454#define XPNTR(a) ((EMACS_UINT) (((a) & VALMASK) | DATA_SEG_BITS)) 458#define XPNTR(a) ((uintptr_t) (((a) & VALMASK)) | DATA_SEG_BITS))
455#else 459#else
456#define XPNTR(a) ((EMACS_UINT) ((a) & VALMASK)) 460#define XPNTR(a) ((uintptr_t) ((a) & VALMASK))
457#endif 461#endif
458 462
459#endif /* not USE_LSB_TAG */ 463#endif /* not USE_LSB_TAG */
@@ -479,7 +483,7 @@ enum pvec_type
479/* Some versions of gcc seem to consider the bitfield width when issuing 483/* Some versions of gcc seem to consider the bitfield width when issuing
480 the "cast to pointer from integer of different size" warning, so the 484 the "cast to pointer from integer of different size" warning, so the
481 cast is here to widen the value back to its natural size. */ 485 cast is here to widen the value back to its natural size. */
482# define XPNTR(v) ((EMACS_INT)((v).s.val) << GCTYPEBITS) 486# define XPNTR(v) ((intptr_t) (v).s.val << GCTYPEBITS)
483 487
484#else /* !USE_LSB_TAG */ 488#else /* !USE_LSB_TAG */
485 489
@@ -495,9 +499,9 @@ enum pvec_type
495#ifdef DATA_SEG_BITS 499#ifdef DATA_SEG_BITS
496/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers 500/* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
497 which were stored in a Lisp_Object */ 501 which were stored in a Lisp_Object */
498#define XPNTR(a) (XUINT (a) | DATA_SEG_BITS) 502#define XPNTR(a) ((intptr_t) (XUINT (a) | DATA_SEG_BITS))
499#else 503#else
500#define XPNTR(a) ((EMACS_INT) XUINT (a)) 504#define XPNTR(a) ((intptr_t) XUINT (a))
501#endif 505#endif
502 506
503#endif /* !USE_LSB_TAG */ 507#endif /* !USE_LSB_TAG */
@@ -1814,8 +1818,8 @@ typedef struct {
1814 XSETCDR ((x), tmp); \ 1818 XSETCDR ((x), tmp); \
1815 } while (0) 1819 } while (0)
1816 1820
1817/* Cast pointers to this type to compare them. Some machines want int. */ 1821/* Cast pointers to this type to compare them. */
1818#define PNTR_COMPARISON_TYPE EMACS_UINT 1822#define PNTR_COMPARISON_TYPE uintptr_t
1819 1823
1820/* Define a built-in function for calling from Lisp. 1824/* Define a built-in function for calling from Lisp.
1821 `lname' should be the name to give the function in Lisp, 1825 `lname' should be the name to give the function in Lisp,
@@ -3354,7 +3358,7 @@ extern void flush_pending_output (int);
3354extern void child_setup_tty (int); 3358extern void child_setup_tty (int);
3355extern void setup_pty (int); 3359extern void setup_pty (int);
3356extern int set_window_size (int, int, int); 3360extern int set_window_size (int, int, int);
3357extern long get_random (void); 3361extern EMACS_INT get_random (void);
3358extern void seed_random (long); 3362extern void seed_random (long);
3359extern int emacs_open (const char *, int, int); 3363extern int emacs_open (const char *, int, int);
3360extern int emacs_close (int); 3364extern int emacs_close (int);
diff --git a/src/lread.c b/src/lread.c
index 2139d558851..a6da09cf330 100644
--- a/src/lread.c
+++ b/src/lread.c
@@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <inttypes.h>
23#include <stdio.h> 22#include <stdio.h>
24#include <sys/types.h> 23#include <sys/types.h>
25#include <sys/stat.h> 24#include <sys/stat.h>
@@ -2250,6 +2249,26 @@ read_escape (Lisp_Object readcharfun, int stringp)
2250 } 2249 }
2251} 2250}
2252 2251
2252/* Return the digit that CHARACTER stands for in the given BASE.
2253 Return -1 if CHARACTER is out of range for BASE,
2254 and -2 if CHARACTER is not valid for any supported BASE. */
2255static inline int
2256digit_to_number (int character, int base)
2257{
2258 int digit;
2259
2260 if ('0' <= character && character <= '9')
2261 digit = character - '0';
2262 else if ('a' <= character && character <= 'z')
2263 digit = character - 'a' + 10;
2264 else if ('A' <= character && character <= 'Z')
2265 digit = character - 'A' + 10;
2266 else
2267 return -2;
2268
2269 return digit < base ? digit : -1;
2270}
2271
2253/* Read an integer in radix RADIX using READCHARFUN to read 2272/* Read an integer in radix RADIX using READCHARFUN to read
2254 characters. RADIX must be in the interval [2..36]; if it isn't, a 2273 characters. RADIX must be in the interval [2..36]; if it isn't, a
2255 read error is signaled . Value is the integer read. Signals an 2274 read error is signaled . Value is the integer read. Signals an
@@ -2259,59 +2278,64 @@ read_escape (Lisp_Object readcharfun, int stringp)
2259static Lisp_Object 2278static Lisp_Object
2260read_integer (Lisp_Object readcharfun, int radix) 2279read_integer (Lisp_Object readcharfun, int radix)
2261{ 2280{
2262 int ndigits = 0, invalid_p, c, sign = 0; 2281 /* Room for sign, leading 0, other digits, trailing null byte. */
2263 /* We use a floating point number because */ 2282 char buf[1 + 1 + sizeof (uintmax_t) * CHAR_BIT + 1];
2264 double number = 0; 2283
2284 int valid = -1; /* 1 if valid, 0 if not, -1 if incomplete. */
2265 2285
2266 if (radix < 2 || radix > 36) 2286 if (radix < 2 || radix > 36)
2267 invalid_p = 1; 2287 valid = 0;
2268 else 2288 else
2269 { 2289 {
2270 number = ndigits = invalid_p = 0; 2290 char *p = buf;
2271 sign = 1; 2291 int c, digit;
2272 2292
2273 c = READCHAR; 2293 c = READCHAR;
2274 if (c == '-') 2294 if (c == '-' || c == '+')
2275 { 2295 {
2296 *p++ = c;
2276 c = READCHAR; 2297 c = READCHAR;
2277 sign = -1;
2278 } 2298 }
2279 else if (c == '+')
2280 c = READCHAR;
2281 2299
2282 while (c >= 0) 2300 if (c == '0')
2283 { 2301 {
2284 int digit; 2302 *p++ = c;
2285 2303 valid = 1;
2286 if (c >= '0' && c <= '9')
2287 digit = c - '0';
2288 else if (c >= 'a' && c <= 'z')
2289 digit = c - 'a' + 10;
2290 else if (c >= 'A' && c <= 'Z')
2291 digit = c - 'A' + 10;
2292 else
2293 {
2294 UNREAD (c);
2295 break;
2296 }
2297 2304
2298 if (digit < 0 || digit >= radix) 2305 /* Ignore redundant leading zeros, so the buffer doesn't
2299 invalid_p = 1; 2306 fill up with them. */
2307 do
2308 c = READCHAR;
2309 while (c == '0');
2310 }
2311
2312 while (-1 <= (digit = digit_to_number (c, radix)))
2313 {
2314 if (digit == -1)
2315 valid = 0;
2316 if (valid < 0)
2317 valid = 1;
2318
2319 if (p < buf + sizeof buf - 1)
2320 *p++ = c;
2321 else
2322 valid = 0;
2300 2323
2301 number = radix * number + digit;
2302 ++ndigits;
2303 c = READCHAR; 2324 c = READCHAR;
2304 } 2325 }
2326
2327 if (c >= 0)
2328 UNREAD (c);
2329 *p = '\0';
2305 } 2330 }
2306 2331
2307 if (ndigits == 0 || invalid_p) 2332 if (! valid)
2308 { 2333 {
2309 char buf[50];
2310 sprintf (buf, "integer, radix %d", radix); 2334 sprintf (buf, "integer, radix %d", radix);
2311 invalid_syntax (buf, 0); 2335 invalid_syntax (buf, 0);
2312 } 2336 }
2313 2337
2314 return make_fixnum_or_float (sign * number); 2338 return string_to_number (buf, radix, 0);
2315} 2339}
2316 2340
2317 2341
@@ -3170,23 +3194,6 @@ substitute_in_interval (INTERVAL interval, Lisp_Object arg)
3170} 3194}
3171 3195
3172 3196
3173static inline int
3174digit_to_number (int character, int base)
3175{
3176 int digit;
3177
3178 if ('0' <= character && character <= '9')
3179 digit = character - '0';
3180 else if ('a' <= character && character <= 'z')
3181 digit = character - 'a' + 10;
3182 else if ('A' <= character && character <= 'Z')
3183 digit = character - 'A' + 10;
3184 else
3185 return -1;
3186
3187 return digit < base ? digit : -1;
3188}
3189
3190#define LEAD_INT 1 3197#define LEAD_INT 1
3191#define DOT_CHAR 2 3198#define DOT_CHAR 2
3192#define TRAIL_INT 4 3199#define TRAIL_INT 4
@@ -3615,9 +3622,9 @@ static Lisp_Object initial_obarray;
3615 3622
3616/* oblookup stores the bucket number here, for the sake of Funintern. */ 3623/* oblookup stores the bucket number here, for the sake of Funintern. */
3617 3624
3618static int oblookup_last_bucket_number; 3625static size_t oblookup_last_bucket_number;
3619 3626
3620static int hash_string (const char *ptr, int len); 3627static size_t hash_string (const char *ptr, size_t len);
3621 3628
3622/* Get an error if OBARRAY is not an obarray. 3629/* Get an error if OBARRAY is not an obarray.
3623 If it is one, return it. */ 3630 If it is one, return it. */
@@ -3759,7 +3766,7 @@ OBARRAY defaults to the value of the variable `obarray'. */)
3759 (Lisp_Object name, Lisp_Object obarray) 3766 (Lisp_Object name, Lisp_Object obarray)
3760{ 3767{
3761 register Lisp_Object string, tem; 3768 register Lisp_Object string, tem;
3762 int hash; 3769 size_t hash;
3763 3770
3764 if (NILP (obarray)) obarray = Vobarray; 3771 if (NILP (obarray)) obarray = Vobarray;
3765 obarray = check_obarray (obarray); 3772 obarray = check_obarray (obarray);
@@ -3828,8 +3835,8 @@ OBARRAY defaults to the value of the variable `obarray'. */)
3828Lisp_Object 3835Lisp_Object
3829oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_INT size_byte) 3836oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_INT size_byte)
3830{ 3837{
3831 int hash; 3838 size_t hash;
3832 int obsize; 3839 size_t obsize;
3833 register Lisp_Object tail; 3840 register Lisp_Object tail;
3834 Lisp_Object bucket, tem; 3841 Lisp_Object bucket, tem;
3835 3842
@@ -3862,21 +3869,21 @@ oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_I
3862 return tem; 3869 return tem;
3863} 3870}
3864 3871
3865static int 3872static size_t
3866hash_string (const char *ptr, int len) 3873hash_string (const char *ptr, size_t len)
3867{ 3874{
3868 register const char *p = ptr; 3875 register const char *p = ptr;
3869 register const char *end = p + len; 3876 register const char *end = p + len;
3870 register unsigned char c; 3877 register unsigned char c;
3871 register int hash = 0; 3878 register size_t hash = 0;
3872 3879
3873 while (p != end) 3880 while (p != end)
3874 { 3881 {
3875 c = *p++; 3882 c = *p++;
3876 if (c >= 0140) c -= 40; 3883 if (c >= 0140) c -= 40;
3877 hash = ((hash<<3) + (hash>>28) + c); 3884 hash = (hash << 3) + (hash >> (CHAR_BIT * sizeof hash - 4)) + c;
3878 } 3885 }
3879 return hash & 07777777777; 3886 return hash;
3880} 3887}
3881 3888
3882void 3889void
diff --git a/src/menu.c b/src/menu.c
index f637b92679a..7a3edcb6f4f 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -800,9 +800,9 @@ digest_single_submenu (int start, int end, int top_level_items)
800 if (!NILP (descrip)) 800 if (!NILP (descrip))
801 wv->lkey = descrip; 801 wv->lkey = descrip;
802 wv->value = 0; 802 wv->value = 0;
803 /* The EMACS_INT cast avoids a warning. There's no problem 803 /* The intptr_t cast avoids a warning. There's no problem
804 as long as pointers have enough bits to hold small integers. */ 804 as long as pointers have enough bits to hold small integers. */
805 wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0); 805 wv->call_data = (!NILP (def) ? (void *) (intptr_t) i : 0);
806 wv->enabled = !NILP (enable); 806 wv->enabled = !NILP (enable);
807 807
808 if (NILP (type)) 808 if (NILP (type))
@@ -911,9 +911,9 @@ find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object
911 else 911 else
912 { 912 {
913 entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE]; 913 entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE];
914 /* The EMACS_INT cast avoids a warning. There's no problem 914 /* Treat the pointer as an integer. There's no problem
915 as long as pointers have enough bits to hold small integers. */ 915 as long as pointers have enough bits to hold small integers. */
916 if ((int) (EMACS_INT) client_data == i) 916 if ((intptr_t) client_data == i)
917 { 917 {
918 int j; 918 int j;
919 struct input_event buf; 919 struct input_event buf;
diff --git a/src/process.c b/src/process.c
index 75dd7efd581..8a94b3e6047 100644
--- a/src/process.c
+++ b/src/process.c
@@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
28#include <sys/file.h> 28#include <sys/file.h>
29#include <sys/stat.h> 29#include <sys/stat.h>
30#include <setjmp.h> 30#include <setjmp.h>
31#include <inttypes.h>
32 31
33#include <unistd.h> 32#include <unistd.h>
34#include <fcntl.h> 33#include <fcntl.h>
@@ -1386,7 +1385,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1386 { 1385 {
1387 if (EQ (coding_systems, Qt)) 1386 if (EQ (coding_systems, Qt))
1388 { 1387 {
1389 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof args2); 1388 args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2);
1390 args2[0] = Qstart_process; 1389 args2[0] = Qstart_process;
1391 for (i = 0; i < nargs; i++) args2[i + 1] = args[i]; 1390 for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
1392 GCPRO2 (proc, current_dir); 1391 GCPRO2 (proc, current_dir);
diff --git a/src/sysdep.c b/src/sysdep.c
index 462e03879c6..5ad3389dd8f 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -1786,23 +1786,14 @@ seed_random (long int arg)
1786 * Build a full Emacs-sized word out of whatever we've got. 1786 * Build a full Emacs-sized word out of whatever we've got.
1787 * This suffices even for a 64-bit architecture with a 15-bit rand. 1787 * This suffices even for a 64-bit architecture with a 15-bit rand.
1788 */ 1788 */
1789long 1789EMACS_INT
1790get_random (void) 1790get_random (void)
1791{ 1791{
1792 long val = random (); 1792 EMACS_UINT val = 0;
1793#if VALBITS > RAND_BITS 1793 int i;
1794 val = (val << RAND_BITS) ^ random (); 1794 for (i = 0; i < (VALBITS + RAND_BITS - 1) / RAND_BITS; i++)
1795#if VALBITS > 2*RAND_BITS 1795 val = (val << RAND_BITS) ^ random ();
1796 val = (val << RAND_BITS) ^ random (); 1796 return val & (((EMACS_INT) 1 << VALBITS) - 1);
1797#if VALBITS > 3*RAND_BITS
1798 val = (val << RAND_BITS) ^ random ();
1799#if VALBITS > 4*RAND_BITS
1800 val = (val << RAND_BITS) ^ random ();
1801#endif /* need at least 5 */
1802#endif /* need at least 4 */
1803#endif /* need at least 3 */
1804#endif /* need at least 2 */
1805 return val & ((1L << VALBITS) - 1);
1806} 1797}
1807 1798
1808#ifndef HAVE_STRERROR 1799#ifndef HAVE_STRERROR
diff --git a/src/term.c b/src/term.c
index 28709138a17..c68228cc51a 100644
--- a/src/term.c
+++ b/src/term.c
@@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
26#include <sys/file.h> 26#include <sys/file.h>
27#include <unistd.h> 27#include <unistd.h>
28#include <signal.h> 28#include <signal.h>
29#include <stdarg.h>
30#include <setjmp.h> 29#include <setjmp.h>
31 30
32#include "lisp.h" 31#include "lisp.h"
@@ -3619,7 +3618,6 @@ vfatal (const char *str, va_list ap)
3619 vfprintf (stderr, str, ap); 3618 vfprintf (stderr, str, ap);
3620 if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n')) 3619 if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n'))
3621 fprintf (stderr, "\n"); 3620 fprintf (stderr, "\n");
3622 va_end (ap);
3623 fflush (stderr); 3621 fflush (stderr);
3624 exit (1); 3622 exit (1);
3625} 3623}
diff --git a/src/xdisp.c b/src/xdisp.c
index 6d3c142f62a..88353e37925 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -8737,7 +8737,7 @@ display_echo_area (struct window *w)
8737 window_height_changed_p 8737 window_height_changed_p
8738 = with_echo_area_buffer (w, display_last_displayed_message_p, 8738 = with_echo_area_buffer (w, display_last_displayed_message_p,
8739 display_echo_area_1, 8739 display_echo_area_1,
8740 (EMACS_INT) w, Qnil, 0, 0); 8740 (intptr_t) w, Qnil, 0, 0);
8741 8741
8742 if (no_message_p) 8742 if (no_message_p)
8743 echo_area_buffer[i] = Qnil; 8743 echo_area_buffer[i] = Qnil;
@@ -8756,7 +8756,8 @@ display_echo_area (struct window *w)
8756static int 8756static int
8757display_echo_area_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4) 8757display_echo_area_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4)
8758{ 8758{
8759 struct window *w = (struct window *) a1; 8759 intptr_t i1 = a1;
8760 struct window *w = (struct window *) i1;
8760 Lisp_Object window; 8761 Lisp_Object window;
8761 struct text_pos start; 8762 struct text_pos start;
8762 int window_height_changed_p = 0; 8763 int window_height_changed_p = 0;
@@ -8798,7 +8799,8 @@ resize_echo_area_exactly (void)
8798 resize_exactly = Qnil; 8799 resize_exactly = Qnil;
8799 8800
8800 resized_p = with_echo_area_buffer (w, 0, resize_mini_window_1, 8801 resized_p = with_echo_area_buffer (w, 0, resize_mini_window_1,
8801 (EMACS_INT) w, resize_exactly, 0, 0); 8802 (intptr_t) w, resize_exactly,
8803 0, 0);
8802 if (resized_p) 8804 if (resized_p)
8803 { 8805 {
8804 ++windows_or_buffers_changed; 8806 ++windows_or_buffers_changed;
@@ -8818,7 +8820,8 @@ resize_echo_area_exactly (void)
8818static int 8820static int
8819resize_mini_window_1 (EMACS_INT a1, Lisp_Object exactly, EMACS_INT a3, EMACS_INT a4) 8821resize_mini_window_1 (EMACS_INT a1, Lisp_Object exactly, EMACS_INT a3, EMACS_INT a4)
8820{ 8822{
8821 return resize_mini_window ((struct window *) a1, !NILP (exactly)); 8823 intptr_t i1 = a1;
8824 return resize_mini_window ((struct window *) i1, !NILP (exactly));
8822} 8825}
8823 8826
8824 8827
@@ -8984,7 +8987,7 @@ current_message (void)
8984 else 8987 else
8985 { 8988 {
8986 with_echo_area_buffer (0, 0, current_message_1, 8989 with_echo_area_buffer (0, 0, current_message_1,
8987 (EMACS_INT) &msg, Qnil, 0, 0); 8990 (intptr_t) &msg, Qnil, 0, 0);
8988 if (NILP (msg)) 8991 if (NILP (msg))
8989 echo_area_buffer[0] = Qnil; 8992 echo_area_buffer[0] = Qnil;
8990 } 8993 }
@@ -8996,7 +8999,8 @@ current_message (void)
8996static int 8999static int
8997current_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4) 9000current_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4)
8998{ 9001{
8999 Lisp_Object *msg = (Lisp_Object *) a1; 9002 intptr_t i1 = a1;
9003 Lisp_Object *msg = (Lisp_Object *) i1;
9000 9004
9001 if (Z > BEG) 9005 if (Z > BEG)
9002 *msg = make_buffer_string (BEG, Z, 1); 9006 *msg = make_buffer_string (BEG, Z, 1);
@@ -9127,7 +9131,7 @@ set_message (const char *s, Lisp_Object string,
9127 || (STRINGP (string) && STRING_MULTIBYTE (string))); 9131 || (STRINGP (string) && STRING_MULTIBYTE (string)));
9128 9132
9129 with_echo_area_buffer (0, -1, set_message_1, 9133 with_echo_area_buffer (0, -1, set_message_1,
9130 (EMACS_INT) s, string, nbytes, multibyte_p); 9134 (intptr_t) s, string, nbytes, multibyte_p);
9131 message_buf_print = 0; 9135 message_buf_print = 0;
9132 help_echo_showing_p = 0; 9136 help_echo_showing_p = 0;
9133} 9137}
@@ -9141,7 +9145,8 @@ set_message (const char *s, Lisp_Object string,
9141static int 9145static int
9142set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multibyte_p) 9146set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT multibyte_p)
9143{ 9147{
9144 const char *s = (const char *) a1; 9148 intptr_t i1 = a1;
9149 const char *s = (const char *) i1;
9145 const unsigned char *msg = (const unsigned char *) s; 9150 const unsigned char *msg = (const unsigned char *) s;
9146 Lisp_Object string = a2; 9151 Lisp_Object string = a2;
9147 9152
diff --git a/src/xmenu.c b/src/xmenu.c
index 2d6185c16e5..2a4359fa84a 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -1012,10 +1012,10 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
1012 menu_items = f->menu_bar_vector; 1012 menu_items = f->menu_bar_vector;
1013 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0; 1013 menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
1014 subitems = ASIZE (items) / 4; 1014 subitems = ASIZE (items) / 4;
1015 submenu_start = (int *) alloca (subitems * sizeof (int *)); 1015 submenu_start = (int *) alloca (subitems * sizeof (int));
1016 submenu_end = (int *) alloca (subitems * sizeof (int *)); 1016 submenu_end = (int *) alloca (subitems * sizeof (int));
1017 submenu_n_panes = (int *) alloca (subitems * sizeof (int)); 1017 submenu_n_panes = (int *) alloca (subitems * sizeof (int));
1018 submenu_top_level_items = (int *) alloca (subitems * sizeof (int *)); 1018 submenu_top_level_items = (int *) alloca (subitems * sizeof (int));
1019 init_menu_items (); 1019 init_menu_items ();
1020 for (i = 0; i < subitems; i++) 1020 for (i = 0; i < subitems; i++)
1021 { 1021 {
@@ -1139,9 +1139,9 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
1139 wv->help = Qnil; 1139 wv->help = Qnil;
1140 /* This prevents lwlib from assuming this 1140 /* This prevents lwlib from assuming this
1141 menu item is really supposed to be empty. */ 1141 menu item is really supposed to be empty. */
1142 /* The EMACS_INT cast avoids a warning. 1142 /* The intptr_t cast avoids a warning.
1143 This value just has to be different from small integers. */ 1143 This value just has to be different from small integers. */
1144 wv->call_data = (void *) (EMACS_INT) (-1); 1144 wv->call_data = (void *) (intptr_t) (-1);
1145 1145
1146 if (prev_wv) 1146 if (prev_wv)
1147 prev_wv->next = wv; 1147 prev_wv->next = wv;
@@ -1876,9 +1876,9 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
1876static void 1876static void
1877dialog_selection_callback (GtkWidget *widget, gpointer client_data) 1877dialog_selection_callback (GtkWidget *widget, gpointer client_data)
1878{ 1878{
1879 /* The EMACS_INT cast avoids a warning. There's no problem 1879 /* Treat the pointer as an integer. There's no problem
1880 as long as pointers have enough bits to hold small integers. */ 1880 as long as pointers have enough bits to hold small integers. */
1881 if ((int) (EMACS_INT) client_data != -1) 1881 if ((intptr_t) client_data != -1)
1882 menu_item_selection = (Lisp_Object *) client_data; 1882 menu_item_selection = (Lisp_Object *) client_data;
1883 1883
1884 popup_activated_flag = 0; 1884 popup_activated_flag = 0;