changeset 5934:e2fae7783046 cygwin

lots of use of EMACS_INT, a few others, to eliminate all pointer truncation warnings
author Henry Thompson <ht@markup.co.uk>
date Sat, 12 Dec 2015 19:08:46 +0000
parents c1e8f3294298
children d5eb0914ca1f
files lib-src/i.c notes.txt src/alloc.c src/alloca.c src/array.h src/buffer.c src/dumper.c src/emacs.c src/events.c src/extents.c src/fns.c src/fontcolor-msw.c src/frame-msw.c src/glyphs-msw.c src/hash.c src/hash.h src/lisp.h src/mem-limits.h src/menubar-msw.c src/nt.c src/number.c src/opaque.c src/process-nt.c src/profile.c src/regex.c src/sysdep.c src/tests.c src/toolbar-msw.c
diffstat 28 files changed, 103 insertions(+), 92 deletions(-) [+]
line wrap: on
line diff
--- a/lib-src/i.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/lib-src/i.c	Sat Dec 12 19:08:46 2015 +0000
@@ -240,7 +240,7 @@
     _tcsncpy (new_command, command, past_exe - command);
     _stprintf (new_command + (past_exe - command),
 	       /* start with space in case no args past command name */
-	       " -mswindows-termination-handle %d ", (long) external_event);
+	       " -mswindows-termination-handle %Id ", (uintptr_t) external_event);
     _tcscat (new_command, past_exe);
     
     if (CreateProcess (NULL, new_command, NULL, NULL, TRUE, 0,
--- a/notes.txt	Thu Dec 10 17:55:59 2015 +0000
+++ b/notes.txt	Sat Dec 12 19:08:46 2015 +0000
@@ -358,3 +358,7 @@
 Now getting 2192 conversion warnings, makes me v. nervous!
 
 But it runs. . .
+
+Using various means to locate and attempt to correct warnings.  Have
+now eliminated all pointer truncation warnings.  1254 remain, of which
+1246 are conversion from [64 bits] to [32 bits], possible loss of data
--- a/src/alloc.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/alloc.c	Sat Dec 12 19:08:46 2015 +0000
@@ -889,8 +889,8 @@
    about expressions in src/.gdbinit.  See src/.gdbinit or src/.dbxrc
    to see how this is used.  */
 
-EMACS_UINT dbg_valmask = ((1UL << VALBITS) - 1) << GCBITS;
-EMACS_UINT dbg_typemask = (1UL << GCTYPEBITS) - 1;
+EMACS_UINT dbg_valmask = (((EMACS_UINT)1 << VALBITS) - 1) << GCBITS;
+EMACS_UINT dbg_typemask = ((EMACS_UINT)1 << GCTYPEBITS) - 1;
 
 #ifdef USE_UNION_TYPE
 unsigned char dbg_USE_UNION_TYPE = 1;
--- a/src/alloca.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/alloca.c	Sat Dec 12 19:08:46 2015 +0000
@@ -129,7 +129,7 @@
    implementations of C, for example under Gould's UTX/32.  */
 
 pointer
-xemacs_c_alloca (unsigned int size)
+xemacs_c_alloca (EMACS_UINT size)
 {
   char probe;			/* Probes stack depth: */
   register char *depth = ADDRESS_FUNCTION (probe);
--- a/src/array.h	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/array.h	Sat Dec 12 19:08:46 2015 +0000
@@ -46,15 +46,16 @@
 #define DECLARE_DYNARR_LOCKED()
 #endif
 
+/* HST increased these for 64-bit */
 #define Dynarr_declare(type)			\
   struct lrecord_header header;			\
   type *base;					\
   DECLARE_DYNARR_LISP_IMP ()			\
   DECLARE_DYNARR_LOCKED ()			\
   int elsize_;					\
-  int len_;					\
-  int largest_;					\
-  int max_
+  EMACS_INT len_;					\
+  EMACS_INT largest_;					\
+  EMACS_INT max_
 
 typedef struct dynarr
 {
--- a/src/buffer.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/buffer.c	Sat Dec 12 19:08:46 2015 +0000
@@ -739,8 +739,9 @@
   b->local_var_flags = 0;
   /* For each slot that has a default value,
      copy that into the slot.  */
+  /* HST added (int) -- dangerous?? */
 #define MARKED_SLOT(slot)						\
-  { int mask = XFIXNUM (buffer_local_flags.slot);				\
+  { int mask = (int)XFIXNUM (buffer_local_flags.slot);			\
     if ((mask > 0 || mask == -1 || mask == -3)				\
 	&& (first_time							\
 	    || NILP (Fget (XBUFFER (Vbuffer_local_symbols)->slot,	\
@@ -889,8 +890,9 @@
   /* Add on all the variables stored in special slots.  */
   {
     struct buffer *syms = XBUFFER (Vbuffer_local_symbols);
+  /* HST added (int) -- dangerous?? */
 #define MARKED_SLOT(slot)					\
-    { int mask = XFIXNUM (buffer_local_flags.slot);		\
+    { int mask = (int)XFIXNUM (buffer_local_flags.slot);	\
       if (mask == 0 || mask == -1				\
 	  || ((mask > 0) && (buf->local_var_flags & mask)))	\
         result = Fcons (Fcons (syms->slot, buf->slot), result);	\
--- a/src/dumper.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/dumper.c	Sat Dec 12 19:08:46 2015 +0000
@@ -472,9 +472,9 @@
 pdump_make_hash (const void *obj)
 {
 #ifdef NEW_GC
-  return ((unsigned long)(obj) * PDUMP_HASH_MULTIPLIER) % PDUMP_HASHSIZE;
+  return ((uintptr_t)(obj) * PDUMP_HASH_MULTIPLIER) % PDUMP_HASHSIZE;
 #else /* not NEW_GC */
-  return ((unsigned long)(obj)>>3) % PDUMP_HASHSIZE;
+  return ((uintptr_t)(obj)>>3) % PDUMP_HASHSIZE;
 #endif /* not NEW_GC */
 }
 
--- a/src/emacs.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/emacs.c	Sat Dec 12 19:08:46 2015 +0000
@@ -4117,7 +4117,7 @@
 {
   Ascbyte bigstr[1000]; /* #### Could overflow, but avoids any need to do any
 			   allocation, even alloca(), hence safer */
-  sprintf (bigstr, "%s (%ld) should == %s (%ld) but doesn't",
+  sprintf (bigstr, "%s (%Id) should == %s (%Id) but doesn't",
 	   exprx, x, expry, y);
   assert_failed (file, line, bigstr);
 }
--- a/src/events.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/events.c	Sat Dec 12 19:08:46 2015 +0000
@@ -1766,7 +1766,7 @@
   return make_fixnum (MOST_POSITIVE_FIXNUM & XEVENT_TIMESTAMP (event));
 }
 
-#define TIMESTAMP_HALFSPACE (1L << (FIXNUM_VALBITS - 2))
+#define TIMESTAMP_HALFSPACE ((EMACS_INT)1 << (FIXNUM_VALBITS - 2))
 
 DEFUN ("event-timestamp<", Fevent_timestamp_lessp, 2, 2, 0, /*
 Return true if timestamp TIME1 is earlier than timestamp TIME2.
--- a/src/extents.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/extents.c	Sat Dec 12 19:08:46 2015 +0000
@@ -2850,7 +2850,7 @@
   if (extent_detached_p (ext))
     strcpy (bp, "detached");
   else
-    sprintf (bp, "%ld, %ld",
+    sprintf (bp, "%Id, %Id",
 	     XFIXNUM (Fextent_start_position (obj)),
 	     XFIXNUM (Fextent_end_position (obj)));
   bp += strlen (bp);
--- a/src/fns.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/fns.c	Sat Dec 12 19:08:46 2015 +0000
@@ -98,7 +98,7 @@
 	 it's possible to get a quotient larger than limit; discarding
 	 these values eliminates the bias that would otherwise appear
 	 when using a large limit.  */
-      denominator = ((unsigned long)1 << FIXNUM_VALBITS) / XFIXNUM (limit);
+      denominator = ((EMACS_UINT)1 << FIXNUM_VALBITS) / XFIXNUM (limit);
       do
 	val = get_random () / denominator;
       while (val >= XFIXNUM (limit));
--- a/src/fontcolor-msw.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/fontcolor-msw.c	Sat Dec 12 19:08:46 2015 +0000
@@ -1418,7 +1418,7 @@
 static Hashcode
 mswindows_color_instance_hash (Lisp_Color_Instance *c, int UNUSED (depth))
 {
-  return (unsigned long) COLOR_INSTANCE_MSWINDOWS_COLOR (c);
+  return (uintptr_t) COLOR_INSTANCE_MSWINDOWS_COLOR (c);
 }
 
 static Lisp_Object
@@ -1947,7 +1947,7 @@
 			       int UNUSED (escapeflag))
 {
   write_fmt_string (printcharfun, " 0x%lx",
-		    (unsigned long)
+		    (uintptr_t)
 		    FONT_INSTANCE_MSWINDOWS_HFONT_VARIANT (f, 0, 0));
 
 }
--- a/src/frame-msw.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/frame-msw.c	Sat Dec 12 19:08:46 2015 +0000
@@ -602,7 +602,7 @@
   Ibyte str[255];
   struct frame *f = decode_mswindows_frame (frame);
 
-  qxesprintf (str, "%lu", (unsigned long) FRAME_MSWINDOWS_HANDLE (f));
+  qxesprintf (str, "%lu", (uintptr_t) FRAME_MSWINDOWS_HANDLE (f));
   return build_istring (str);
 }
 
--- a/src/glyphs-msw.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/glyphs-msw.c	Sat Dec 12 19:08:46 2015 +0000
@@ -1710,11 +1710,11 @@
     case IMAGE_COLOR_PIXMAP:
     case IMAGE_POINTER:
       write_fmt_string (printcharfun, " (0x%lx",
-			(unsigned long) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
+			(uintptr_t) IMAGE_INSTANCE_MSWINDOWS_BITMAP (p));
       if (IMAGE_INSTANCE_MSWINDOWS_MASK (p))
 	{
 	  write_fmt_string (printcharfun, "/0x%lx",
-			    (unsigned long) IMAGE_INSTANCE_MSWINDOWS_MASK (p));
+			    (uintptr_t) IMAGE_INSTANCE_MSWINDOWS_MASK (p));
 	}
       write_ascstring (printcharfun, ")");
       break;
--- a/src/hash.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/hash.c	Sat Dec 12 19:08:46 2015 +0000
@@ -26,7 +26,7 @@
 #include "lisp.h"
 #include "hash.h"
 
-#define NULL_ENTRY ((void *) 0xDEADBEEF) /* -559038737 base 10 */
+#define NULL_ENTRY ((void *) (EMACS_UINT)0xDEADBEEF) /* -559038737 base 10 */
 
 #define COMFORTABLE_SIZE(size) (21 * (size) / 16)
 
@@ -214,7 +214,7 @@
 
   /* do the rehash on the "grown" table */
   {
-    long old_zero_set    = hash_table->zero_set;
+    EMACS_INT old_zero_set    = hash_table->zero_set;
     void *old_zero_entry = hash_table->zero_entry;
     clrhash (hash_table);
     hash_table->zero_set   = old_zero_set;
@@ -240,7 +240,7 @@
   if (!key)
     {
       hash_table->zero_entry = contents;
-      hash_table->zero_set = 1;
+      hash_table->zero_set = (EMACS_INT)1;
     }
   else
     {
--- a/src/hash.h	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/hash.h	Sat Dec 12 19:08:46 2015 +0000
@@ -31,7 +31,7 @@
 struct hash_table
 {
   hentry	*harray;
-  long		zero_set;
+  EMACS_INT      zero_set;
   void		*zero_entry;
   Elemcount	size;		/* size of the hasharray */
   Elemcount	fullness;	/* number of entries in the hash table */
--- a/src/lisp.h	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/lisp.h	Sat Dec 12 19:08:46 2015 +0000
@@ -467,13 +467,17 @@
 # define SIZEOF_EMACS_INT SIZEOF_VOID_P
 #endif
 
+/* HST moved MOST_POSITIVE_FIXNUM_UNSIGNED here */
 #ifndef EMACS_INT
 # if   SIZEOF_EMACS_INT == SIZEOF_LONG
 #  define EMACS_INT long
+#define MOST_POSITIVE_FIXNUM_UNSIGNED ((1UL << (FIXNUM_VALBITS - 1)) -1UL)
 # elif SIZEOF_EMACS_INT == SIZEOF_INT
 #  define EMACS_INT int
+#define MOST_POSITIVE_FIXNUM_UNSIGNED ((1U << (FIXNUM_VALBITS - 1)) -1U)
 # elif SIZEOF_EMACS_INT == SIZEOF_LONG_LONG
 #  define EMACS_INT long long
+#define MOST_POSITIVE_FIXNUM_UNSIGNED ((1ULL << (FIXNUM_VALBITS - 1)) -1ULL)
 # else
 #  error Unable to determine suitable type for EMACS_INT
 # endif
@@ -1149,7 +1153,7 @@
 /* Counts of elements */
 typedef EMACS_INT Elemcount;
 /* Hash codes */
-typedef unsigned long Hashcode;
+typedef uintptr_t Hashcode; /* HST: protect wrt _WIN64 short longs */
 /* Booleans */
 typedef int Boolint;
 
@@ -1385,7 +1389,7 @@
 #define ALLOCA_FUNCALL_OK(size) ALLOCA (size)
 #endif
 
-MODULE_API void *xemacs_c_alloca (unsigned int size) ATTRIBUTE_MALLOC;
+MODULE_API void *xemacs_c_alloca (EMACS_UINT size) ATTRIBUTE_MALLOC;
 
 MODULE_API int record_unwind_protect_freeing (void *ptr);
 
@@ -1682,7 +1686,6 @@
 
 #define FIXNUM_VALBITS (BITS_PER_EMACS_INT - FIXNUM_GCBITS)
 #define VALBITS (BITS_PER_EMACS_INT - GCBITS)
-#define MOST_POSITIVE_FIXNUM_UNSIGNED ((1UL << (FIXNUM_VALBITS - 1)) -1UL)
 #define MOST_POSITIVE_FIXNUM ((EMACS_INT) MOST_POSITIVE_FIXNUM_UNSIGNED)
 #define MOST_NEGATIVE_FIXNUM (-(MOST_POSITIVE_FIXNUM) - 1)
 /* WARNING: evaluates its arg twice. */
@@ -1747,7 +1750,7 @@
 {
   EMACS_UINT p = (EMACS_UINT) ptr;
 
-  type_checking_assert ((p & 1) == 0);
+  type_checking_assert ((p & (EMACS_UINT)1) == 0);
   return make_fixnum (p >> 1);
 }
 
@@ -3106,12 +3109,13 @@
    character. */
 #define CHAR_OR_CHAR_INTP(x) (CHARP (x) || CHAR_INTP (x))
 
+/* HST editted in the (int) to stop many warnings */
 DECLARE_INLINE_HEADER (
 Ichar
 XCHAR_OR_CHAR_INT (Lisp_Object obj)
 )
 {
-  return CHARP (obj) ? XCHAR (obj) : XFIXNUM (obj);
+  return CHARP (obj) ? XCHAR (obj) : (int)XFIXNUM (obj);
 }
 
 /* Signal an error if CH is not a valid character or integer Lisp_Object.
@@ -3843,7 +3847,7 @@
 #define HASH8(a,b,c,d,e,f,g,h)   (GOOD_HASH * HASH7 (a,b,c,d,e,f,g)   + (h))
 #define HASH9(a,b,c,d,e,f,g,h,i) (GOOD_HASH * HASH8 (a,b,c,d,e,f,g,h) + (i))
 
-#define LISP_HASH(obj) ((unsigned long) STORE_LISP_IN_VOID (obj))
+#define LISP_HASH(obj) ((Hashcode) STORE_LISP_IN_VOID (obj))
 Hashcode memory_hash (const void *xv, Bytecount size);
 Hashcode internal_hash (Lisp_Object obj, int depth, Boolint equalp);
 Hashcode internal_array_hash (Lisp_Object *arr, int size, int depth,
--- a/src/mem-limits.h	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/mem-limits.h	Sat Dec 12 19:08:46 2015 +0000
@@ -54,7 +54,7 @@
 typedef void *POINTER;
 
 #ifndef CYGWIN
-typedef unsigned long SIZE;
+typedef uintptr_t SIZE;
 #endif
 
 extern POINTER start_of_data (void);
--- a/src/menubar-msw.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/menubar-msw.c	Sat Dec 12 19:08:46 2015 +0000
@@ -376,7 +376,7 @@
 {
   int deep_p, flush_right;
   struct gcpro gcpro1, gcpro2, gcpro3;
-  unsigned long checksum;
+  uintptr_t checksum;
   Lisp_Object gui_item = allocate_gui_item ();
   Lisp_Object accel_list = Qnil;
   Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
--- a/src/nt.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/nt.c	Sat Dec 12 19:08:46 2015 +0000
@@ -2185,19 +2185,19 @@
     retry_fclose (stderr);
 
     if (stdin_save != INVALID_HANDLE_VALUE)
-      _open_osfhandle ((long) stdin_save, O_TEXT);
+      _open_osfhandle ((EMACS_INT) stdin_save, O_TEXT);
     else
       _open ("nul", O_TEXT | O_NOINHERIT | O_RDONLY);
     _fdopen (0, "r");
 
     if (stdout_save != INVALID_HANDLE_VALUE)
-      _open_osfhandle ((long) stdout_save, O_TEXT);
+      _open_osfhandle ((EMACS_INT) stdout_save, O_TEXT);
     else
       _open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY);
     _fdopen (1, "w");
 
     if (stderr_save != INVALID_HANDLE_VALUE)
-      _open_osfhandle ((long) stderr_save, O_TEXT);
+      _open_osfhandle ((EMACS_INT) stderr_save, O_TEXT);
     else
       _open ("nul", O_TEXT | O_NOINHERIT | O_WRONLY);
     _fdopen (2, "w");
--- a/src/number.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/number.c	Sat Dec 12 19:08:46 2015 +0000
@@ -351,7 +351,7 @@
   CHECK_BIGFLOAT (f);
   if (FIXNUMP (precision))
     {
-      prec = (XFIXNUM (precision) <= 0) ? 1UL : (unsigned long) XFIXNUM (precision);
+      prec = (XFIXNUM (precision) <= 0) ? (EMACS_UINT)1 : (unsigned long) XFIXNUM (precision);
     }
 #ifdef HAVE_BIGNUM
   else if (BIGNUMP (precision))
@@ -519,7 +519,7 @@
 #endif /* HAVE_BIGNUM */
 	case RATIO_T:
 #ifdef HAVE_RATIO
-	  return make_ratio (XREALFIXNUM (number), 1UL);
+	  return make_ratio (XREALFIXNUM (number), (EMACS_UINT)1);
 #else
 	  ABORT ();
 #endif /* HAVE_RATIO */
--- a/src/opaque.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/opaque.c	Sat Dec 12 19:08:46 2015 +0000
@@ -131,7 +131,7 @@
   write_fmt_string
     (printcharfun,
      "#<INTERNAL OBJECT (XEmacs bug?) (opaque-ptr, adr=0x%lx) 0x%x>",
-     (long)(p->ptr), LISP_OBJECT_UID (obj));
+     (EMACS_INT)(p->ptr), LISP_OBJECT_UID (obj));
 }
 
 static int
--- a/src/process-nt.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/process-nt.c	Sat Dec 12 19:08:46 2015 +0000
@@ -422,7 +422,7 @@
 /* ---------------------------- the 95 way ------------------------------- */
 
 static BOOL CALLBACK
-find_child_console (HWND hwnd, long putada)
+find_child_console (HWND hwnd, EMACS_INT putada)
 {
   DWORD thread_id;
   DWORD process_id;
--- a/src/profile.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/profile.c	Sat Dec 12 19:08:46 2015 +0000
@@ -311,13 +311,13 @@
       profiling_lock = 1;
 
       {
-	long count;
+	EMACS_INT count;
 	const void *vval;
 
 	if (gethash (STORE_LISP_IN_VOID (fun), big_profile_table, &vval))
-	  count = (long) vval;
+	  count = (EMACS_INT) vval;
 	else
-	  count = 0;
+	  count = (EMACS_INT)0;
 	count++;
 	vval = (const void *) count;
 	puthash (STORE_LISP_IN_VOID (fun), (void *) vval, big_profile_table);
--- a/src/regex.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/regex.c	Sat Dec 12 19:08:46 2015 +0000
@@ -820,7 +820,7 @@
   /* Loop over pattern commands.  */
   while (p < pend)
     {
-      printf ("%ld:\t", (long)(p - start));
+      printf ("%Id:\t", (EMACS_INT)(p - start));
 
       switch ((re_opcode_t) *p++)
 	{
@@ -919,14 +919,14 @@
 		if (first < 0x80)
 		  putchar (first);
 		else
-		  printf ("(0x%lx)", (long)first);
+		  printf ("(0x%Ix)", (EMACS_INT)first);
 		if (first != last)
 		  {
 		    putchar ('-');
 		    if (last < 0x80)
 		      putchar (last);
 		    else
-		      printf ("(0x%lx)", (long)last);
+		      printf ("(0x%Ix)", (EMACS_INT)last);
 		  }
 	      }
 	    putchar (']');
@@ -945,17 +945,17 @@
 
 	case on_failure_jump:
           extract_number_and_incr (&mcnt, &p);
-  	  printf ("/on_failure_jump to %ld", (long)(p + mcnt - start));
+  	  printf ("/on_failure_jump to %Id", (EMACS_INT)(p + mcnt - start));
           break;
 
 	case on_failure_keep_string_jump:
           extract_number_and_incr (&mcnt, &p);
-  	  printf ("/on_failure_keep_string_jump to %ld", (long)(p + mcnt - start));
+  	  printf ("/on_failure_keep_string_jump to %Id", (EMACS_INT)(p + mcnt - start));
           break;
 
 	case dummy_failure_jump:
           extract_number_and_incr (&mcnt, &p);
-  	  printf ("/dummy_failure_jump to %ld", (long)(p + mcnt - start));
+  	  printf ("/dummy_failure_jump to %Id", (EMACS_INT)(p + mcnt - start));
           break;
 
 	case push_dummy_failure:
@@ -964,40 +964,40 @@
 
         case maybe_pop_jump:
           extract_number_and_incr (&mcnt, &p);
-  	  printf ("/maybe_pop_jump to %ld", (long)(p + mcnt - start));
+  	  printf ("/maybe_pop_jump to %Id", (EMACS_INT)(p + mcnt - start));
 	  break;
 
         case pop_failure_jump:
 	  extract_number_and_incr (&mcnt, &p);
-  	  printf ("/pop_failure_jump to %ld", (long)(p + mcnt - start));
+  	  printf ("/pop_failure_jump to %Id", (EMACS_INT)(p + mcnt - start));
 	  break;
 
         case jump_past_alt:
 	  extract_number_and_incr (&mcnt, &p);
-  	  printf ("/jump_past_alt to %ld", (long)(p + mcnt - start));
+  	  printf ("/jump_past_alt to %Id", (EMACS_INT)(p + mcnt - start));
 	  break;
 
         case jump:
 	  extract_number_and_incr (&mcnt, &p);
-  	  printf ("/jump to %ld", (long)(p + mcnt - start));
+  	  printf ("/jump to %Id", (EMACS_INT)(p + mcnt - start));
 	  break;
 
         case succeed_n:
           extract_number_and_incr (&mcnt, &p);
           extract_number_and_incr (&mcnt2, &p);
-	  printf ("/succeed_n to %ld, %d times", (long)(p + mcnt - start), mcnt2);
+	  printf ("/succeed_n to %Id, %d times", (EMACS_INT)(p + mcnt - start), mcnt2);
           break;
 
         case jump_n:
           extract_number_and_incr (&mcnt, &p);
           extract_number_and_incr (&mcnt2, &p);
-	  printf ("/jump_n to %ld, %d times", (long)(p + mcnt - start), mcnt2);
+	  printf ("/jump_n to %Id, %d times", (EMACS_INT)(p + mcnt - start), mcnt2);
           break;
 
         case set_number_at:
           extract_number_and_incr (&mcnt, &p);
           extract_number_and_incr (&mcnt2, &p);
-	  printf ("/set_number_at location %ld to %d", (long)(p + mcnt - start), mcnt2);
+	  printf ("/set_number_at location %Id to %d", (EMACS_INT)(p + mcnt - start), mcnt2);
           break;
 
         case wordbound:
@@ -1080,7 +1080,7 @@
       putchar ('\n');
     }
 
-  printf ("%ld:\tend of pattern.\n", (long)(p - start));
+  printf ("%Id:\tend of pattern.\n", (EMACS_INT)(p - start));
 }
 
 
@@ -1099,8 +1099,8 @@
       print_fastmap (bufp->fastmap);
     }
 
-  printf ("re_nsub: %ld\t", (long)bufp->re_nsub);
-  printf ("re_ngroups: %ld\t", (long)bufp->re_ngroups);
+  printf ("re_nsub: %Id\t", (EMACS_INT)bufp->re_nsub);
+  printf ("re_ngroups: %Id\t", (EMACS_INT)bufp->re_ngroups);
   printf ("regs_alloc: %d\t", bufp->regs_allocated);
   printf ("can_be_null: %d\t", bufp->can_be_null);
   printf ("newline_anchor: %d\n", bufp->newline_anchor);
@@ -1564,14 +1564,14 @@
   DEBUG_STATEMENT (failure_id++);					\
   DEBUG_STATEMENT (nfailure_points_pushed++);				\
   DEBUG_FAIL_PRINT2 ("\nPUSH_FAILURE_POINT #%d:\n", failure_id);	\
-  DEBUG_FAIL_PRINT2 ("  Before push, next avail: %ld\n",		\
-		(long) (fail_stack).avail);				\
-  DEBUG_FAIL_PRINT2 ("                     size: %ld\n",		\
-		(long) (fail_stack).size);				\
+  DEBUG_FAIL_PRINT2 ("  Before push, next avail: %Id\n",		\
+		(EMACS_INT) (fail_stack).avail);				\
+  DEBUG_FAIL_PRINT2 ("                     size: %Id\n",		\
+		(EMACS_INT) (fail_stack).size);				\
 									\
   DEBUG_FAIL_PRINT2 ("  slots needed: %d\n", NUM_FAILURE_ITEMS);	\
-  DEBUG_FAIL_PRINT2 ("     available: %ld\n",				\
-		(long) REMAINING_AVAIL_SLOTS);				\
+  DEBUG_FAIL_PRINT2 ("     available: %Id\n",				\
+		(EMACS_INT) REMAINING_AVAIL_SLOTS);				\
 									\
   /* Ensure we have enough space allocated for what we will push.  */	\
   while (REMAINING_AVAIL_SLOTS < NUM_FAILURE_ITEMS)			\
@@ -1584,10 +1584,10 @@
 	  return failure_code;						\
 	}								\
       END_REGEX_MALLOC_OK ();						\
-      DEBUG_FAIL_PRINT2 ("\n  Doubled stack; size now: %ld\n",		\
-		    (long) (fail_stack).size);				\
-      DEBUG_FAIL_PRINT2 ("  slots available: %ld\n",			\
-		    (long) REMAINING_AVAIL_SLOTS);			\
+      DEBUG_FAIL_PRINT2 ("\n  Doubled stack; size now: %Id\n",		\
+		    (EMACS_INT) (fail_stack).size);				\
+      DEBUG_FAIL_PRINT2 ("  slots available: %Id\n",			\
+		    (EMACS_INT) REMAINING_AVAIL_SLOTS);			\
 									\
       RE_MATCH_RELOCATE_MOVEABLE_DATA_POINTERS ();			\
     }									\
@@ -1601,10 +1601,10 @@
       DEBUG_FAIL_PRINT2 ("  Pushing reg: %d\n", this_reg);		\
       DEBUG_STATEMENT (num_regs_pushed++);				\
 									\
-      DEBUG_FAIL_PRINT2 ("    start: 0x%lx\n", (long) regstart[this_reg]); \
+      DEBUG_FAIL_PRINT2 ("    start: 0x%Ix\n", (EMACS_INT) regstart[this_reg]); \
       PUSH_FAILURE_POINTER (regstart[this_reg]);			\
 									\
-      DEBUG_FAIL_PRINT2 ("    end: 0x%lx\n", (long) regend[this_reg]);	\
+      DEBUG_FAIL_PRINT2 ("    end: 0x%Ix\n", (EMACS_INT) regend[this_reg]);	\
       PUSH_FAILURE_POINTER (regend[this_reg]);				\
 									\
       DEBUG_FAIL_PRINT2 ("    info: 0x%lx\n      ",			\
@@ -1626,11 +1626,11 @@
   DEBUG_FAIL_PRINT2 ("  Pushing high active reg: %d\n", highest_active_reg); \
   PUSH_FAILURE_INT (highest_active_reg);				\
 									\
-  DEBUG_FAIL_PRINT2 ("  Pushing pattern 0x%lx: \n", (long) pattern_place); \
+  DEBUG_FAIL_PRINT2 ("  Pushing pattern 0x%Ix: \n", (EMACS_INT) pattern_place); \
   DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pattern_place, pend);	\
   PUSH_FAILURE_POINTER (pattern_place);					\
 									\
-  DEBUG_FAIL_PRINT2 ("  Pushing string 0x%lx: `", (long) string_place);	\
+  DEBUG_FAIL_PRINT2 ("  Pushing string 0x%Ix: `", (EMACS_INT) string_place);	\
   DEBUG_FAIL_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, \
 			     size2);					\
   DEBUG_FAIL_PRINT1 ("'\n");						\
@@ -1689,10 +1689,10 @@
 									\
   /* Remove failure points and point to how many regs pushed.  */	\
   DEBUG_FAIL_PRINT1 ("POP_FAILURE_POINT:\n");				\
-  DEBUG_FAIL_PRINT2 ("  Before pop, next avail: %ld\n",			\
-		(long) fail_stack.avail);				\
-  DEBUG_FAIL_PRINT2 ("                    size: %ld\n",			\
-		(long) fail_stack.size);				\
+  DEBUG_FAIL_PRINT2 ("  Before pop, next avail: %Id\n",			\
+		(EMACS_INT) fail_stack.avail);				\
+  DEBUG_FAIL_PRINT2 ("                    size: %Id\n",			\
+		(EMACS_INT) fail_stack.size);				\
 									\
   assert (fail_stack.avail >= NUM_NONREG_ITEMS);			\
 									\
@@ -1707,12 +1707,12 @@
   if (string_temp != NULL)						\
     str = string_temp;							\
 									\
-  DEBUG_FAIL_PRINT2 ("  Popping string 0x%lx: `",  (long) str);		\
+  DEBUG_FAIL_PRINT2 ("  Popping string 0x%Ix: `",  (EMACS_INT) str);		\
   DEBUG_FAIL_PRINT_DOUBLE_STRING (str, string1, size1, string2, size2);	\
   DEBUG_FAIL_PRINT1 ("'\n");						\
 									\
   pat = (unsigned char *) POP_FAILURE_POINTER ();			\
-  DEBUG_FAIL_PRINT2 ("  Popping pattern 0x%lx: ", (long) pat);		\
+  DEBUG_FAIL_PRINT2 ("  Popping pattern 0x%Ix: ", (EMACS_INT) pat);		\
   DEBUG_FAIL_PRINT_COMPILED_PATTERN (bufp, pat, pend);			\
 									\
   /* Restore register info.  */						\
@@ -1731,10 +1731,10 @@
 		    * (long *) &reg_info[this_reg]);			\
 									\
       regend[this_reg] = POP_FAILURE_POINTER ();			\
-      DEBUG_FAIL_PRINT2 ("      end: 0x%lx\n", (long) regend[this_reg]); \
+      DEBUG_FAIL_PRINT2 ("      end: 0x%Ix\n", (EMACS_INT) regend[this_reg]); \
 									\
       regstart[this_reg] = POP_FAILURE_POINTER ();			\
-      DEBUG_FAIL_PRINT2 ("      start: 0x%lx\n", (long) regstart[this_reg]); \
+      DEBUG_FAIL_PRINT2 ("      start: 0x%Ix\n", (EMACS_INT) regstart[this_reg]); \
     }									\
 									\
   set_regs_matched_done = 0;						\
@@ -5351,7 +5351,7 @@
      fails at this starting point in the input data.  */
   for (;;)
     {
-      DEBUG_MATCH_PRINT2 ("\n0x%lx: ", (long) p);
+      DEBUG_MATCH_PRINT2 ("\n0x%Ix: ", (EMACS_UINT) p);
 #ifdef emacs /* XEmacs added, w/removal of immediate_quit */
       if (!no_quit_in_re_search)
 	{
@@ -6068,7 +6068,7 @@
           DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_keep_string_jump");
 
           EXTRACT_NUMBER_AND_INCR (mcnt, p);
-          DEBUG_MATCH_PRINT3 (" %d (to 0x%lx):\n", mcnt, (long) (p + mcnt));
+          DEBUG_MATCH_PRINT3 (" %d (to 0x%Ix):\n", mcnt, (EMACS_INT) (p + mcnt));
 
           PUSH_FAILURE_POINT (p + mcnt, (unsigned char *) 0, -2);
           break;
@@ -6091,7 +6091,7 @@
           DEBUG_MATCH_PRINT1 ("EXECUTING on_failure_jump");
 
           EXTRACT_NUMBER_AND_INCR (mcnt, p);
-          DEBUG_MATCH_PRINT3 (" %d (to 0x%lx)", mcnt, (long) (p + mcnt));
+          DEBUG_MATCH_PRINT3 (" %d (to 0x%Ix)", mcnt, (EMACS_INT) (p + mcnt));
 
           /* If this on_failure_jump comes right before a group (i.e.,
              the original * applied to a group), save the information
@@ -6306,7 +6306,7 @@
 	  EXTRACT_NUMBER_AND_INCR (mcnt, p);	/* Get the amount to jump.  */
           DEBUG_MATCH_PRINT2 ("EXECUTING jump %d ", mcnt);
 	  p += mcnt;				/* Do the jump.  */
-          DEBUG_MATCH_PRINT2 ("(to 0x%lx).\n", (long) p);
+          DEBUG_MATCH_PRINT2 ("(to 0x%Ix).\n", (EMACS_INT) p);
 	  break;
 
 
@@ -6355,12 +6355,12 @@
                mcnt--;
 	       p += 2;
                STORE_NUMBER_AND_INCR (p, mcnt);
-               DEBUG_MATCH_PRINT3 ("  Setting 0x%lx to %d.\n", (long) p, mcnt);
+               DEBUG_MATCH_PRINT3 ("  Setting 0x%Ix to %d.\n", (EMACS_INT) p, mcnt);
             }
 	  else if (mcnt == 0)
             {
-              DEBUG_MATCH_PRINT2 ("  Setting two bytes from 0x%lx to no_op.\n",
-			    (long) (p+2));
+              DEBUG_MATCH_PRINT2 ("  Setting two bytes from 0x%Ix to no_op.\n",
+			    (EMACS_INT) (p+2));
 	      p[2] = (unsigned char) no_op;
               p[3] = (unsigned char) no_op;
               goto on_failure;
@@ -6390,7 +6390,7 @@
             EXTRACT_NUMBER_AND_INCR (mcnt, p);
             p1 = p + mcnt;
             EXTRACT_NUMBER_AND_INCR (mcnt, p);
-            DEBUG_MATCH_PRINT3 ("  Setting 0x%lx to %d.\n", (long) p1, mcnt);
+            DEBUG_MATCH_PRINT3 ("  Setting 0x%Ix to %d.\n", (EMACS_INT) p1, mcnt);
 	    STORE_NUMBER (p1, mcnt);
             break;
           }
--- a/src/sysdep.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/sysdep.c	Sat Dec 12 19:08:46 2015 +0000
@@ -3509,7 +3509,7 @@
 #endif /* need at least 4 */
 #endif /* need at least 3 */
 #endif /* need at least 2 */
-  return val & (EMACS_INT) ((1UL << FIXNUM_VALBITS) - 1);
+  return val & (((EMACS_UINT)1 << FIXNUM_VALBITS) - 1);
 }
 
 
--- a/src/tests.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/tests.c	Sat Dec 12 19:08:46 2015 +0000
@@ -850,7 +850,7 @@
 #define FROB(val)							\
 do									\
 {									\
-  void *pval = (void *) (val);						\
+  void *pval = (void *) ((EMACS_UINT)val);				\
   assert (GET_VOID_FROM_LISP (STORE_VOID_IN_LISP (pval)) == pval);	\
 }									\
 while (0)
@@ -866,7 +866,7 @@
   FROB (0x00000080);
   FROB (0x00008080);
   FROB (0x00808080);
-  FROB (0x80808080);
+  FROB (0x80808080);/*this and next two fail w/o the above added (EMACS_UINT) -- HST */
   FROB (0xCAFEBABE);
   FROB (0xFFFFFFFE);
 #if FIXNUM_VALBITS >= 63
--- a/src/toolbar-msw.c	Thu Dec 10 17:55:59 2015 +0000
+++ b/src/toolbar-msw.c	Sat Dec 12 19:08:46 2015 +0000
@@ -125,7 +125,7 @@
   int shadow_thickness = 2;	/* get this from somewhere else? */
   int window_frame_width = 3;
   int padding = (border_width + shadow_thickness) * 2;
-  unsigned int checksum=0;
+  uintptr_t checksum=0;
   struct window *w = XWINDOW (window);
   TBBUTTON *button_tbl, *tbbutton;
   HIMAGELIST ilist=NULL;