emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104134: Do not assume EMACS_INT is t


From: Paul Eggert
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104134: Do not assume EMACS_INT is the same width as a pointer.
Date: Fri, 06 May 2011 00:13:19 -0700
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104134 [merge]
fixes bug(s): http://debbugs.gnu.org/8545 http://debbugs.gnu.org/8601 
http://debbugs.gnu.org/8600 http://debbugs.gnu.org/8602
committer: Paul Eggert <address@hidden>
branch nick: trunk
timestamp: Fri 2011-05-06 00:13:19 -0700
message:
  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.
added:
  lib/stdarg.in.h
  m4/stdarg.m4
modified:
  ChangeLog
  Makefile.in
  configure.in
  doc/lispref/ChangeLog
  doc/lispref/numbers.texi
  lib/gnulib.mk
  lib/stdlib.in.h
  lib/verify.h
  m4/gl-comp.m4
  m4/stdio_h.m4
  nt/ChangeLog
  nt/config.nt
  src/ChangeLog
  src/alloc.c
  src/callproc.c
  src/charset.c
  src/charset.h
  src/coding.c
  src/dbusbind.c
  src/dispnew.c
  src/doc.c
  src/doprnt.c
  src/eval.c
  src/fns.c
  src/gtkutil.c
  src/image.c
  src/lisp.h
  src/lread.c
  src/menu.c
  src/process.c
  src/sysdep.c
  src/term.c
  src/xdisp.c
  src/xmenu.c
=== modified file 'ChangeLog'
--- a/ChangeLog 2011-05-05 03:30:03 +0000
+++ b/ChangeLog 2011-05-06 07:13:19 +0000
@@ -1,3 +1,15 @@
+2011-05-06  Paul Eggert  <address@hidden>
+
+       Use C99's va_copy to avoid undefined behavior on x86-64 GNU/Linux.
+       * Makefile.in (GNULIB_MODULES): Add stdarg, for va_copy.
+       * lib/stdarg.in.h, m4/stdarg.m4: New files, from gnulib.
+
+       * Makefile.in (GNULIB_TOOL_FLAG): Add --conditional-dependencies.
+       This new gnulib-tool option saves 'configure' the trouble of
+       checking for strtoull when strtoumax exists.
+
+       * configure.in (BITS_PER_LONG_LONG): New macro.
+
 2011-05-05  Glenn Morris  <address@hidden>
 
        * Makefile.in (bootstrap-clean): Save config.log.  (Bug#765)

=== modified file 'Makefile.in'
--- a/Makefile.in       2011-05-05 06:04:38 +0000
+++ b/Makefile.in       2011-05-06 06:30:56 +0000
@@ -333,9 +333,10 @@
 GNULIB_MODULES = \
   careadlinkat crypto/md5 dtoastr filemode getloadavg getopt-gnu \
   ignore-value intprops lstat mktime readlink \
-  socklen stdio strftime strtoumax symlink sys_stat
+  socklen stdarg stdio strftime strtoumax symlink sys_stat
 GNULIB_TOOL_FLAGS = \
- --import --no-changelog --no-vc-files --makefile-name=gnulib.mk
+ --conditional-dependencies --import --no-changelog --no-vc-files \
+ --makefile-name=gnulib.mk
 sync-from-gnulib: $(gnulib_srcdir)
        -cd $(srcdir)/m4 && cp $(DOS_gnulib_comp.m4) gnulib-comp.m4
        cd $(srcdir) && \

=== modified file 'configure.in'
--- a/configure.in      2011-04-27 02:17:44 +0000
+++ b/configure.in      2011-04-29 07:55:57 +0000
@@ -3518,7 +3518,8 @@
 #endif
 
 /* These default definitions are good for almost all machines.
-   The exceptions override them in m/MACHINE.h.  */
+   Any exceptions should override them in m/MACHINE.h.
+   They must be usable in preprocessor conditionals.  */
 
 #ifndef BITS_PER_CHAR
 #define BITS_PER_CHAR 8
@@ -3528,9 +3529,6 @@
 #define BITS_PER_SHORT 16
 #endif
 
-/* Note that lisp.h uses this in a preprocessor conditional, so it
-   would not work to use sizeof.  That being so, we do all of them
-   without sizeof, for uniformity's sake.  */
 #ifndef BITS_PER_INT
 #define BITS_PER_INT 32
 #endif
@@ -3543,6 +3541,10 @@
 #endif
 #endif
 
+#if !defined BITS_PER_LONG_LONG && HAVE_LONG_LONG_INT
+#define BITS_PER_LONG_LONG 64
+#endif
+
 /* Define if the compiler supports function prototypes.  It may do so but
    not define __STDC__ (e.g. DEC C by default) or may define it as zero.  */
 #undef PROTOTYPES

=== modified file 'doc/lispref/ChangeLog'
--- a/doc/lispref/ChangeLog     2011-05-01 00:04:17 +0000
+++ b/doc/lispref/ChangeLog     2011-05-06 07:13:19 +0000
@@ -1,3 +1,7 @@
+2011-05-06  Paul Eggert  <address@hidden>
+
+       * numbers.texi (Integer Basics): Large integers are treated as floats.
+
 2011-04-30  Lars Magne Ingebrigtsen  <address@hidden>
 
        * processes.texi (Synchronous Processes): Document the (:file

=== modified file 'doc/lispref/numbers.texi'
--- a/doc/lispref/numbers.texi  2011-01-25 04:08:28 +0000
+++ b/doc/lispref/numbers.texi  2011-05-05 06:31:14 +0000
@@ -55,14 +55,15 @@
 @cindex overflow
 
   The Lisp reader reads an integer as a sequence of digits with optional
-initial sign and optional final period.
+initial sign and optional final period.  An integer that is out of the
+Emacs range is treated as a floating-point number.
 
 @example
  1               ; @r{The integer 1.}
  1.              ; @r{The integer 1.}
 +1               ; @r{Also the integer 1.}
 -1               ; @r{The integer @minus{}1.}
- 1073741825      ; @r{Also the integer 1, due to overflow.}
+ 1073741825      ; @r{The floating point number 1073741825.0.}
  0               ; @r{The integer 0.}
 -0               ; @r{The integer 0.}
 @end example
@@ -195,7 +196,7 @@
 @samp{1.0e+INF}
 @item negative infinity
 @samp{-1.0e+INF}
address@hidden Not-a-number 
address@hidden Not-a-number
 @samp{0.0e+NaN} or @samp{-0.0e+NaN}.
 @end table
 

=== modified file 'lib/gnulib.mk'
--- a/lib/gnulib.mk     2011-04-26 19:29:47 +0000
+++ b/lib/gnulib.mk     2011-05-04 07:19:21 +0000
@@ -9,7 +9,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib 
--m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. 
--makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files 
careadlinkat crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value 
intprops lstat mktime readlink socklen stdio strftime strtoumax symlink sys_stat
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib 
--m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=. 
--makefile-name=gnulib.mk --no-libtool --macro-prefix=gl --no-vc-files 
careadlinkat crypto/md5 dtoastr filemode getloadavg getopt-gnu ignore-value 
intprops lstat mktime readlink socklen stdarg stdio strftime strtoumax symlink 
sys_stat
 
 
 MOSTLYCLEANFILES += core *.stackdump
@@ -96,7 +96,9 @@
 
 ## begin gnulib module dosname
 
+if gl_GNULIB_ENABLED_dosname
 
+endif
 EXTRA_DIST += dosname.h
 
 ## end   gnulib module dosname
@@ -157,8 +159,10 @@
 
 ## begin gnulib module gettext-h
 
+if gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36
 libgnu_a_SOURCES += gettext.h
 
+endif
 ## end   gnulib module gettext-h
 
 ## begin gnulib module ignore-value
@@ -245,13 +249,42 @@
 
 ## begin gnulib module stat
 
+if gl_GNULIB_ENABLED_stat
 
+endif
 EXTRA_DIST += stat.c
 
 EXTRA_libgnu_a_SOURCES += stat.c
 
 ## end   gnulib module stat
 
+## begin gnulib module stdarg
+
+BUILT_SOURCES += $(STDARG_H)
+
+# We need the following in order to create <stdarg.h> when the system
+# doesn't have one that works with the given compiler.
+if GL_GENERATE_STDARG_H
+stdarg.h: stdarg.in.h $(top_builddir)/config.status
+       $(AM_V_GEN)rm -f address@hidden $@ && \
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+             -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+             -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
+             -e 's|@''NEXT_STDARG_H''@|$(NEXT_STDARG_H)|g' \
+             < $(srcdir)/stdarg.in.h; \
+       } > address@hidden && \
+       mv address@hidden $@
+else
+stdarg.h: $(top_builddir)/config.status
+       rm -f $@
+endif
+MOSTLYCLEANFILES += stdarg.h stdarg.h-t
+
+EXTRA_DIST += stdarg.in.h
+
+## end   gnulib module stdarg
+
 ## begin gnulib module stdbool
 
 BUILT_SOURCES += $(STDBOOL_H)
@@ -576,7 +609,9 @@
 
 ## begin gnulib module strtoull
 
+if gl_GNULIB_ENABLED_strtoull
 
+endif
 EXTRA_DIST += strtol.c strtoul.c strtoull.c
 
 EXTRA_libgnu_a_SOURCES += strtol.c strtoul.c strtoull.c
@@ -847,8 +882,10 @@
 
 ## begin gnulib module verify
 
+if gl_GNULIB_ENABLED_verify
 libgnu_a_SOURCES += verify.h
 
+endif
 ## end   gnulib module verify
 
 ## begin gnulib module warn-on-use

=== added file 'lib/stdarg.in.h'
--- a/lib/stdarg.in.h   1970-01-01 00:00:00 +0000
+++ b/lib/stdarg.in.h   2011-05-04 07:19:21 +0000
@@ -0,0 +1,36 @@
+/* Substitute for and wrapper around <stdarg.h>.
+   Copyright (C) 2008-2011 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+#ifndef _GL_STDARG_H
+
+#if __GNUC__ >= 3
address@hidden@
+#endif
address@hidden@
+
+/* The include_next requires a split double-inclusion guard.  */
address@hidden@ @NEXT_STDARG_H@
+
+#ifndef _GL_STDARG_H
+#define _GL_STDARG_H
+
+#ifndef va_copy
+# define va_copy(a,b) ((a) = (b))
+#endif
+
+#endif /* _GL_STDARG_H */
+#endif /* _GL_STDARG_H */

=== modified file 'lib/stdlib.in.h'
--- a/lib/stdlib.in.h   2011-04-08 21:53:30 +0000
+++ b/lib/stdlib.in.h   2011-05-04 06:11:49 +0000
@@ -81,8 +81,9 @@
 # endif
 #endif
 
-#if (@GNULIB_MKSTEMP@ || @GNULIB_GETSUBOPT@ || defined GNULIB_POSIXCHECK) && ! 
defined __GLIBC__ && !((defined _WIN32 || defined __WIN32__) && ! defined 
__CYGWIN__)
+#if (@GNULIB_MKSTEMP@ || @GNULIB_MKSTEMPS@ || @GNULIB_GETSUBOPT@ || defined 
GNULIB_POSIXCHECK) && ! defined __GLIBC__ && !((defined _WIN32 || defined 
__WIN32__) && ! defined __CYGWIN__)
 /* On MacOS X 10.3, only <unistd.h> declares mkstemp.  */
+/* On MacOS X 10.5, only <unistd.h> declares mkstemps.  */
 /* On Cygwin 1.7.1, only <unistd.h> declares getsubopt.  */
 /* But avoid namespace pollution on glibc systems and native Windows.  */
 # include <unistd.h>

=== modified file 'lib/verify.h'
--- a/lib/verify.h      2011-04-21 19:12:13 +0000
+++ b/lib/verify.h      2011-05-06 06:03:30 +0000
@@ -17,42 +17,37 @@
 
 /* Written by Paul Eggert, Bruno Haible, and Jim Meyering.  */
 
-#ifndef VERIFY_H
-# define VERIFY_H 1
-
-/* Define HAVE__STATIC_ASSERT to 1 if _Static_assert works as per the
+#ifndef _GL_VERIFY_H
+# define _GL_VERIFY_H
+
+
+/* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert works as per the
    C1X draft N1548 section 6.7.10.  This is supported by GCC 4.6.0 and
    later, in C mode, and its use here generates easier-to-read diagnostics
    when verify (R) fails.
 
-   Define HAVE_STATIC_ASSERT to 1 if static_assert works as per the
-   C1X draft N1548 section 7.2 or the C++0X draft N3242 section 7.(4).
+   Define _GL_HAVE_STATIC_ASSERT to 1 if static_assert works as per the
+   C++0X draft N3242 section 7.(4).
    This will likely be supported by future GCC versions, in C++ mode.
 
-   For now, use this only with GCC.  Eventually whether _Static_assert
-   and static_assert works should be determined by 'configure'.  */
+   Use this only with GCC.  If we were willing to slow 'configure'
+   down we could also use it with other compilers, but since this
+   affects only the quality of diagnostics, why bother?  */
 # if (4 < __GNUC__ || (__GNUC__ == 4 && 6 <= __GNUC_MINOR__)) && !defined 
__cplusplus
-#  define HAVE__STATIC_ASSERT 1
+#  define _GL_HAVE__STATIC_ASSERT 1
 # endif
 /* The condition (99 < __GNUC__) is temporary, until we know about the
    first G++ release that supports static_assert.  */
 # if (99 < __GNUC__) && defined __cplusplus
-#  define HAVE_STATIC_ASSERT 1
+#  define _GL_HAVE_STATIC_ASSERT 1
 # endif
 
 /* Each of these macros verifies that its argument R is nonzero.  To
    be portable, R should be an integer constant expression.  Unlike
    assert (R), there is no run-time overhead.
 
-   There are two macros, since no single macro can be used in all
-   contexts in C.  verify_true (R) is for scalar contexts, including
-   integer constant expression contexts.  verify (R) is for declaration
-   contexts, e.g., the top level.
-
-   Symbols ending in "__" are private to this header.
-
    If _Static_assert works, verify (R) uses it directly.  Similarly,
-   verify_true (R) works by packaging a _Static_assert inside a struct
+   _GL_VERIFY_TRUE works by packaging a _Static_assert inside a struct
    that is an operand of sizeof.
 
    The code below uses several ideas for C++ compilers, and for C
@@ -64,7 +59,9 @@
      constant and nonnegative.
 
    * Next this expression W is wrapped in a type
-     struct verify_type__ { unsigned int verify_error_if_negative_size__: W; }.
+     struct _gl_verify_type {
+       unsigned int _gl_verify_error_if_negative: W;
+     }.
      If W is negative, this yields a compile-time error.  No compiler can
      deal with a bit-field of negative size.
 
@@ -78,7 +75,7 @@
 
        void function (int n) { verify (n < 0); }
 
-   * For the verify macro, the struct verify_type__ will need to
+   * For the verify macro, the struct _gl_verify_type will need to
      somehow be embedded into a declaration.  To be portable, this
      declaration must declare an object, a constant, a function, or a
      typedef name.  If the declared entity uses the type directly,
@@ -116,11 +113,11 @@
      Which of the following alternatives can be used?
 
        extern int dummy [sizeof (struct {...})];
-       extern int dummy [sizeof (struct verify_type__ {...})];
+       extern int dummy [sizeof (struct _gl_verify_type {...})];
        extern void dummy (int [sizeof (struct {...})]);
-       extern void dummy (int [sizeof (struct verify_type__ {...})]);
+       extern void dummy (int [sizeof (struct _gl_verify_type {...})]);
        extern int (*dummy (void)) [sizeof (struct {...})];
-       extern int (*dummy (void)) [sizeof (struct verify_type__ {...})];
+       extern int (*dummy (void)) [sizeof (struct _gl_verify_type {...})];
 
      In the second and sixth case, the struct type is exported to the
      outer scope; two such declarations therefore collide.  GCC warns
@@ -159,44 +156,75 @@
    possible.  */
 # define _GL_GENSYM(prefix) _GL_CONCAT (prefix, _GL_COUNTER)
 
+/* Verify requirement R at compile-time, as an integer constant expression
+   that returns 1.  If R is false, fail at compile-time, preferably
+   with a diagnostic that includes the string-literal DIAGNOSTIC.  */
+
+# define _GL_VERIFY_TRUE(R, DIAGNOSTIC) \
+    (!!sizeof (_GL_VERIFY_TYPE (R, DIAGNOSTIC)))
+
+# ifdef __cplusplus
+template <int w>
+  struct _gl_verify_type {
+    unsigned int _gl_verify_error_if_negative: w;
+  };
+#  define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+    _gl_verify_type<(R) ? 1 : -1>
+# elif defined _GL_HAVE__STATIC_ASSERT
+#  define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+     struct {                                   \
+       _Static_assert (R, DIAGNOSTIC);          \
+       int _gl_dummy;                          \
+     }
+# else
+#  define _GL_VERIFY_TYPE(R, DIAGNOSTIC) \
+     struct { unsigned int _gl_verify_error_if_negative: (R) ? 1 : -1; }
+# endif
+
+/* Verify requirement R at compile-time, as a declaration without a
+   trailing ';'.  If R is false, fail at compile-time, preferably
+   with a diagnostic that includes the string-literal DIAGNOSTIC.
+
+   Unfortunately, unlike C1X, this implementation must appear as an
+   ordinary declaration, and cannot appear inside struct { ... }.  */
+
+# ifdef _GL_HAVE__STATIC_ASSERT
+#  define _GL_VERIFY _Static_assert
+# else
+#  define _GL_VERIFY(R, DIAGNOSTIC)                                   \
+     extern int (*_GL_GENSYM (_gl_verify_function) (void))            \
+       [_GL_VERIFY_TRUE (R, DIAGNOSTIC)]
+# endif
+
+/* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h.  */
+# ifdef _GL_STATIC_ASSERT_H
+#  if !defined _GL_HAVE__STATIC_ASSERT && !defined _Static_assert
+#   define _Static_assert(R, DIAGNOSTIC) _GL_VERIFY (R, DIAGNOSTIC)
+#  endif
+#  if !defined _GL_HAVE_STATIC_ASSERT && !defined static_assert
+#   define static_assert _Static_assert /* Draft C1X requires this #define.  */
+#  endif
+# else
+
+/* Each of these macros verifies that its argument R is nonzero.  To
+   be portable, R should be an integer constant expression.  Unlike
+   assert (R), there is no run-time overhead.
+
+   There are two macros, since no single macro can be used in all
+   contexts in C.  verify_true (R) is for scalar contexts, including
+   integer constant expression contexts.  verify (R) is for declaration
+   contexts, e.g., the top level.  */
+
 /* Verify requirement R at compile-time, as an integer constant expression.
    Return 1.  */
 
-# ifdef __cplusplus
-template <int w>
-  struct verify_type__ { unsigned int verify_error_if_negative_size__: w; };
-#  define verify_true(R) \
-     (!!sizeof (verify_type__<(R) ? 1 : -1>))
-# elif HAVE__STATIC_ASSERT
-#  define verify_true(R) \
-     (!!sizeof \
-      (struct { \
-        _Static_assert (R, "verify_true (" #R ")"); \
-        int verify_dummy__; \
-       }))
-# elif HAVE_STATIC_ASSERT
-#  define verify_true(R) \
-     (!!sizeof \
-      (struct { \
-        static_assert (R, "verify_true (" #R ")"); \
-        int verify_dummy__; \
-       }))
-# else
-#  define verify_true(R) \
-     (!!sizeof \
-      (struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
-# endif
+#  define verify_true(R) _GL_VERIFY_TRUE (R, "verify_true (" #R ")")
 
 /* Verify requirement R at compile-time, as a declaration without a
    trailing ';'.  */
 
-# if HAVE__STATIC_ASSERT
-#  define verify(R) _Static_assert (R, "verify (" #R ")")
-# elif HAVE_STATIC_ASSERT
-#  define verify(R) static_assert (R, "verify (" #R ")")
-# else
-#  define verify(R) \
-    extern int (* _GL_GENSYM (verify_function) (void)) [verify_true (R)]
+#  define verify(R) _GL_VERIFY (R, "verify (" #R ")")
+
 # endif
 
 #endif

=== modified file 'm4/gl-comp.m4'
--- a/m4/gl-comp.m4     2011-04-26 19:29:47 +0000
+++ b/m4/gl-comp.m4     2011-05-04 07:19:21 +0000
@@ -51,6 +51,12 @@
   # Code from module socklen:
   # Code from module ssize_t:
   # Code from module stat:
+  # Code from module stdarg:
+  dnl Some compilers (e.g., AIX 5.3 cc) need to be in c99 mode
+  dnl for the builtin va_copy to work.  With Autoconf 2.60 or later,
+  dnl AC_PROG_CC_STDC arranges for this.  With older Autoconf AC_PROG_CC_STDC
+  dnl shouldn't hurt, though installers are on their own to set c99 mode.
+  AC_REQUIRE([AC_PROG_CC_STDC])
   # Code from module stdbool:
   # Code from module stddef:
   # Code from module stdint:
@@ -84,87 +90,111 @@
   m4_pushdef([gl_LIBSOURCES_DIR], [])
   gl_COMMON
   gl_source_base='lib'
-  # Code from module allocator:
-  # Code from module arg-nonnull:
-  # Code from module c++defs:
-  # Code from module careadlinkat:
-  AC_CHECK_FUNCS_ONCE([readlinkat])
-  # Code from module crypto/md5:
-  gl_MD5
-  # Code from module dosname:
-  # Code from module dtoastr:
-  AC_REQUIRE([gl_C99_STRTOLD])
-  # Code from module extensions:
-  # Code from module filemode:
-  gl_FILEMODE
-  # Code from module getloadavg:
-  gl_GETLOADAVG([$gl_source_base])
-  gl_STDLIB_MODULE_INDICATOR([getloadavg])
-  # Code from module getopt-gnu:
-  gl_FUNC_GETOPT_GNU
-  gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
-  # Code from module getopt-posix:
-  gl_FUNC_GETOPT_POSIX
-  # Code from module gettext-h:
-  AC_SUBST([LIBINTL])
-  AC_SUBST([LTLIBINTL])
-  # Code from module ignore-value:
-  AC_REQUIRE([AC_C_INLINE])
-  # Code from module include_next:
-  # Code from module intprops:
-  # Code from module inttypes-incomplete:
-  gl_INTTYPES_INCOMPLETE
-  # Code from module lstat:
-  gl_FUNC_LSTAT
-  gl_SYS_STAT_MODULE_INDICATOR([lstat])
-  # Code from module mktime:
-  gl_FUNC_MKTIME
-  gl_TIME_MODULE_INDICATOR([mktime])
-  # Code from module multiarch:
-  gl_MULTIARCH
-  # Code from module readlink:
-  gl_FUNC_READLINK
-  gl_UNISTD_MODULE_INDICATOR([readlink])
-  # Code from module socklen:
-  gl_TYPE_SOCKLEN_T
-  # Code from module ssize_t:
-  gt_TYPE_SSIZE_T
-  # Code from module stat:
-  gl_FUNC_STAT
-  gl_SYS_STAT_MODULE_INDICATOR([stat])
-  # Code from module stdbool:
-  AM_STDBOOL_H
-  # Code from module stddef:
-  gl_STDDEF_H
-  # Code from module stdint:
-  gl_STDINT_H
-  # Code from module stdio:
-  gl_STDIO_H
-  # Code from module stdlib:
-  gl_STDLIB_H
-  # Code from module strftime:
-  gl_FUNC_GNU_STRFTIME
-  # Code from module strtoull:
-  gl_FUNC_STRTOULL
-  gl_STDLIB_MODULE_INDICATOR([strtoull])
-  # Code from module strtoumax:
-  gl_FUNC_STRTOUMAX
-  gl_INTTYPES_MODULE_INDICATOR([strtoumax])
-  # Code from module symlink:
-  gl_FUNC_SYMLINK
-  gl_UNISTD_MODULE_INDICATOR([symlink])
-  # Code from module sys_stat:
-  gl_HEADER_SYS_STAT_H
-  AC_PROG_MKDIR_P
-  # Code from module time:
-  gl_HEADER_TIME_H
-  # Code from module time_r:
-  gl_TIME_R
-  gl_TIME_MODULE_INDICATOR([time_r])
-  # Code from module unistd:
-  gl_UNISTD_H
-  # Code from module verify:
-  # Code from module warn-on-use:
+AC_CHECK_FUNCS_ONCE([readlinkat])
+gl_MD5
+AC_REQUIRE([gl_C99_STRTOLD])
+gl_FILEMODE
+gl_GETLOADAVG([$gl_source_base])
+gl_STDLIB_MODULE_INDICATOR([getloadavg])
+gl_FUNC_GETOPT_GNU
+gl_MODULE_INDICATOR_FOR_TESTS([getopt-gnu])
+gl_FUNC_GETOPT_POSIX
+AC_REQUIRE([AC_C_INLINE])
+gl_INTTYPES_INCOMPLETE
+gl_FUNC_LSTAT
+gl_SYS_STAT_MODULE_INDICATOR([lstat])
+gl_FUNC_MKTIME
+gl_TIME_MODULE_INDICATOR([mktime])
+gl_MULTIARCH
+gl_FUNC_READLINK
+gl_UNISTD_MODULE_INDICATOR([readlink])
+gl_TYPE_SOCKLEN_T
+gt_TYPE_SSIZE_T
+gl_STDARG_H
+AM_STDBOOL_H
+gl_STDDEF_H
+gl_STDINT_H
+gl_STDIO_H
+gl_STDLIB_H
+gl_FUNC_GNU_STRFTIME
+gl_FUNC_STRTOUMAX
+gl_INTTYPES_MODULE_INDICATOR([strtoumax])
+gl_FUNC_SYMLINK
+gl_UNISTD_MODULE_INDICATOR([symlink])
+gl_HEADER_SYS_STAT_H
+AC_PROG_MKDIR_P
+gl_HEADER_TIME_H
+gl_TIME_R
+gl_TIME_MODULE_INDICATOR([time_r])
+gl_UNISTD_H
+  gl_gnulib_enabled_dosname=false
+  gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=false
+  gl_gnulib_enabled_stat=false
+  gl_gnulib_enabled_strtoull=false
+  gl_gnulib_enabled_verify=false
+  func_gl_gnulib_m4code_dosname ()
+  {
+    if ! $gl_gnulib_enabled_dosname; then
+      gl_gnulib_enabled_dosname=true
+    fi
+  }
+  func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36 ()
+  {
+    if ! $gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36; then
+AC_SUBST([LIBINTL])
+AC_SUBST([LTLIBINTL])
+      gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36=true
+    fi
+  }
+  func_gl_gnulib_m4code_stat ()
+  {
+    if ! $gl_gnulib_enabled_stat; then
+gl_FUNC_STAT
+gl_SYS_STAT_MODULE_INDICATOR([stat])
+      gl_gnulib_enabled_stat=true
+      if $condition; then
+        func_gl_gnulib_m4code_dosname
+      fi
+    fi
+  }
+  func_gl_gnulib_m4code_strtoull ()
+  {
+    if ! $gl_gnulib_enabled_strtoull; then
+gl_FUNC_STRTOULL
+gl_STDLIB_MODULE_INDICATOR([strtoull])
+      gl_gnulib_enabled_strtoull=true
+    fi
+  }
+  func_gl_gnulib_m4code_verify ()
+  {
+    if ! $gl_gnulib_enabled_verify; then
+      gl_gnulib_enabled_verify=true
+    fi
+  }
+  if test $GNULIB_UNISTD_H_GETOPT = 1; then
+    func_gl_gnulib_m4code_be453cec5eecf5731a274f2de7f2db36
+  fi
+  if test $REPLACE_LSTAT = 1; then
+    func_gl_gnulib_m4code_dosname
+  fi
+  if test $REPLACE_LSTAT = 1; then
+    func_gl_gnulib_m4code_stat
+  fi
+  if test $HAVE_READLINK = 0 || test $REPLACE_READLINK = 1; then
+    func_gl_gnulib_m4code_stat
+  fi
+  if test "$ac_cv_have_decl_strtoumax" != yes && test $ac_cv_func_strtoumax = 
no; then
+    func_gl_gnulib_m4code_verify
+  fi
+  if test "$ac_cv_have_decl_strtoumax" != yes && test $ac_cv_func_strtoumax = 
no && test $ac_cv_type_unsigned_long_long_int = yes; then
+    func_gl_gnulib_m4code_strtoull
+  fi
+  m4_pattern_allow([^gl_GNULIB_ENABLED_])
+  AM_CONDITIONAL([gl_GNULIB_ENABLED_dosname], [$gl_gnulib_enabled_dosname])
+  AM_CONDITIONAL([gl_GNULIB_ENABLED_be453cec5eecf5731a274f2de7f2db36], 
[$gl_gnulib_enabled_be453cec5eecf5731a274f2de7f2db36])
+  AM_CONDITIONAL([gl_GNULIB_ENABLED_stat], [$gl_gnulib_enabled_stat])
+  AM_CONDITIONAL([gl_GNULIB_ENABLED_strtoull], [$gl_gnulib_enabled_strtoull])
+  AM_CONDITIONAL([gl_GNULIB_ENABLED_verify], [$gl_gnulib_enabled_verify])
   # End of code from modules
   m4_ifval(gl_LIBSOURCES_LIST, [
     m4_syscmd([test ! -d ]m4_defn([gl_LIBSOURCES_DIR])[ ||
@@ -211,6 +241,7 @@
   AC_SUBST([gltests_WITNESS])
   gl_module_indicator_condition=$gltests_WITNESS
   m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$gl_module_indicator_condition])
+  m4_pattern_allow([^gl_GNULIB_ENABLED_])
   m4_popdef([gl_MODULE_INDICATOR_CONDITION])
   m4_ifval(gltests_LIBSOURCES_LIST, [
     m4_syscmd([test ! -d ]m4_defn([gltests_LIBSOURCES_DIR])[ ||
@@ -334,6 +365,7 @@
   lib/mktime.c
   lib/readlink.c
   lib/stat.c
+  lib/stdarg.in.h
   lib/stdbool.in.h
   lib/stddef.in.h
   lib/stdint.in.h
@@ -371,6 +403,7 @@
   m4/ssize_t.m4
   m4/st_dm_mode.m4
   m4/stat.m4
+  m4/stdarg.m4
   m4/stdbool.m4
   m4/stddef_h.m4
   m4/stdint.m4

=== added file 'm4/stdarg.m4'
--- a/m4/stdarg.m4      1970-01-01 00:00:00 +0000
+++ b/m4/stdarg.m4      2011-05-04 07:19:21 +0000
@@ -0,0 +1,78 @@
+# stdarg.m4 serial 6
+dnl Copyright (C) 2006, 2008-2011 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+dnl Provide a working va_copy in combination with <stdarg.h>.
+
+AC_DEFUN([gl_STDARG_H],
+[
+  STDARG_H=''
+  NEXT_STDARG_H='<stdarg.h>'
+  AC_MSG_CHECKING([for va_copy])
+  AC_CACHE_VAL([gl_cv_func_va_copy], [
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+         [[#include <stdarg.h>]],
+         [[
+#ifndef va_copy
+void (*func) (va_list, va_list) = va_copy;
+#endif
+         ]])],
+      [gl_cv_func_va_copy=yes],
+      [gl_cv_func_va_copy=no])])
+  AC_MSG_RESULT([$gl_cv_func_va_copy])
+  if test $gl_cv_func_va_copy = no; then
+    dnl Provide a substitute.
+    dnl Usually a simple definition in <config.h> is enough. Not so on AIX 5
+    dnl with some versions of the /usr/vac/bin/cc compiler. It has an 
<stdarg.h>
+    dnl which does '#undef va_copy', leading to a missing va_copy symbol. For
+    dnl this platform, we use an <stdarg.h> substitute. But we cannot use this
+    dnl approach on other platforms, because <stdarg.h> often defines only
+    dnl preprocessor macros and gl_ABSOLUTE_HEADER, gl_CHECK_NEXT_HEADERS do
+    dnl not work in this situation.
+    AC_EGREP_CPP([vaccine],
+      [#if defined _AIX && !defined __GNUC__
+        AIX vaccine
+       #endif
+      ], [gl_aixcc=yes], [gl_aixcc=no])
+    if test $gl_aixcc = yes; then
+      dnl Provide a substitute <stdarg.h> file.
+      STDARG_H=stdarg.h
+      gl_NEXT_HEADERS([stdarg.h])
+      dnl Fallback for the case when <stdarg.h> contains only macro 
definitions.
+      if test "$gl_cv_next_stdarg_h" = '""'; then
+        gl_cv_next_stdarg_h='"///usr/include/stdarg.h"'
+        NEXT_STDARG_H="$gl_cv_next_stdarg_h"
+      fi
+    else
+      dnl Provide a substitute in <config.h>, either __va_copy or as a simple
+      dnl assignment.
+      gl_CACHE_VAL_SILENT([gl_cv_func___va_copy], [
+        AC_COMPILE_IFELSE(
+          [AC_LANG_PROGRAM(
+             [[#include <stdarg.h>]],
+             [[
+#ifndef __va_copy
+error, bail out
+#endif
+             ]])],
+          [gl_cv_func___va_copy=yes],
+          [gl_cv_func___va_copy=no])])
+      if test $gl_cv_func___va_copy = yes; then
+        AC_DEFINE([va_copy], [__va_copy],
+          [Define as a macro for copying va_list variables.])
+      else
+        AH_VERBATIM([gl_VA_COPY], [/* A replacement for va_copy, if needed.  */
+#define gl_va_copy(a,b) ((a) = (b))])
+        AC_DEFINE([va_copy], [gl_va_copy],
+          [Define as a macro for copying va_list variables.])
+      fi
+    fi
+  fi
+  AC_SUBST([STDARG_H])
+  AM_CONDITIONAL([GL_GENERATE_STDARG_H], [test -n "$STDARG_H"])
+  AC_SUBST([NEXT_STDARG_H])
+])

=== modified file 'm4/stdio_h.m4'
--- a/m4/stdio_h.m4     2011-04-18 04:03:18 +0000
+++ b/m4/stdio_h.m4     2011-05-04 06:11:49 +0000
@@ -1,4 +1,4 @@
-# stdio_h.m4 serial 36
+# stdio_h.m4 serial 37
 dnl Copyright (C) 2007-2011 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,8 +14,6 @@
   dnl <stdio.h> likely needs them.
   GNULIB_FSCANF=1
   GNULIB_SCANF=1
-  GNULIB_VFSCANF=1
-  GNULIB_VSCANF=1
   GNULIB_FGETC=1
   GNULIB_GETC=1
   GNULIB_GETCHAR=1

=== modified file 'nt/ChangeLog'
--- a/nt/ChangeLog      2011-05-05 02:56:16 +0000
+++ b/nt/ChangeLog      2011-05-06 05:55:01 +0000
@@ -1,3 +1,11 @@
+2011-05-06  Paul Eggert  <address@hidden>
+
+       * config.nt: Prepare to configure 64-bit integers for older compilers.
+       However, temporarily disable this change unless the temporary
+       symbol WIDE_EMACS_INT is defined.
+       (EMACS_INT, BITS_PER_EMACS_INT, pI): Define these if __int64 and
+       "%I64d" work but long long and "%lld" do not.
+
 2011-05-05  Ben Key  <address@hidden>
 
        * configure.bat: Added support for --cflags and --ldflags
@@ -2082,4 +2090,3 @@
 
   You should have received a copy of the GNU General Public License
   along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
-

=== modified file 'nt/config.nt'
--- a/nt/config.nt      2011-04-30 09:14:30 +0000
+++ b/nt/config.nt      2011-05-06 05:55:01 +0000
@@ -478,7 +478,22 @@
 /* Define to 1 if the system has the type `unsigned long long int'. */
 # define HAVE_UNSIGNED_LONG_LONG_INT 1
 
-#endif /* __MINGW32__ || _MSC_VER >= 1400 */
+#elif _MSC_VER >= 1200
+
+/* Temporarily disable wider-than-pointer integers until they're tested more.
+   Build with CFLAGS='-DWIDE_EMACS_INT' to try them out.  */
+/* #undef WIDE_EMACS_INT */
+
+# ifdef WIDE_EMACS_INT
+
+/* Use pre-C99-style 64-bit integers.  */
+# define EMACS_INT __int64
+# define BITS_PER_EMACS_INT 64
+# define pI "I64"
+
+# endif
+
+#endif
 
 #ifndef POINTER_TYPE
 #define POINTER_TYPE void
@@ -518,4 +533,3 @@
 
 /* Make a leaner executable.  */
 #define WIN32_LEAN_AND_MEAN 1
-

=== modified file 'src/ChangeLog'
--- a/src/ChangeLog     2011-05-06 01:05:25 +0000
+++ b/src/ChangeLog     2011-05-06 06:30:56 +0000
@@ -1,3 +1,118 @@
+2011-05-06  Paul Eggert  <address@hidden>
+
+       * image.c (Finit_image_library) [!HAVE_NTGUI]: Omit unused local.
+
+       * term.c (vfatal): Remove stray call to va_end.
+       It's not needed and the C Standard doesn't allow it here anyway.
+
+       Use C99's va_copy to avoid undefined behavior on x86-64 GNU/Linux.
+       * eval.c (verror): doprnt a copy of ap, not the original.  (Bug#8545)
+
+       * eval.c (verror): OK to create a string of up to MOST_POSITIVE_FIXNUM
+       bytes.
+
+       * term.c: Don't include <stdarg.h>, as <lisp.h> does that.
+
+       * callproc.c (Fcall_process): Use 'volatile' to avoid vfork clobbering.
+
+       * process.c (Fformat_network_address): Fix typo: args2 -> *args2.
+
+       * xmenu.c (set_frame_menubar): Fix typo: int * -> int (3 times).
+
+       * coding.c (detect_coding_charset): Fix typo: * 2 -> *4 (Bug#8601).
+
+       * charset.h (struct charset.code_space): Now has 15 elements, not 16.
+       * charset.c (Fdefine_charset_internal): Don't initialize
+       charset.code_space[15].  The value was garbage, on hosts with
+       32-bit int (Bug#8600).
+
+       * lread.c (read_integer): Be more consistent with string-to-number.
+       Use string_to_number to do the actual conversion; this avoids
+       rounding errors and fixes some other screwups.  Without this fix,
+       for example, #x1fffffffffffffff was misread as -2305843009213693952.
+       (digit_to_number): Move earlier, for benefit of read_integer.
+       Return -1 if the digit is out of range for the base, -2 if it is
+       not a digit in any supported base.  (Bug#8602)
+
+       * doprnt.c (doprnt): Support arbitrary pI values, such as "I64".
+
+       * dispnew.c (scrolling_window): Return 1 if we scrolled,
+       to match comment at start of function.  This also removes a
+       GCC warning about overflow in a 32+64-bit port.
+
+       * lisp.h (EMACS_INT, EMACS_UINT, BITS_PER_EMACS_INT, pI): Simplify.
+
+       * dbusbind.c: Do not use XPNTR on a value that may be an integer.
+       Reported by Stefan Monnier in
+       <http://lists.gnu.org/archive/html/emacs-devel/2011-04/msg00919.html>.
+       (xd_remove_watch, Fdbus_init_bus, xd_read_queued_messages): Use
+       SYMBOLP-guarded XSYMBOL, not XPNTR.
+
+       * lisp.h (EMACS_INTPTR): Remove.  All uses changed to intptr_t.
+       (EMACS_UINTPTR): Likewise, with uintptr_t.
+
+       * lisp.h: Prefer 64-bit EMACS_INT if available.
+       (EMACS_INT, EMACS_UINT, BITS_PER_EMACS_INT, pI): Define to 64-bit
+       on 32-bit hosts that have 64-bit int, so that they can access
+       large files.
+       However, temporarily disable this change unless the temporary
+       symbol WIDE_EMACS_INT is defined.
+
+       * lread.c, process.c: Do not include <inttypes.h>; lisp.h does it now.
+
+       Prefer intptr_t/uintptr_t for integers the same widths as pointers.
+       This removes an assumption that EMACS_INT and long are the same
+       width as pointers.  The assumption is true for Emacs porting targets
+       now, but we want to make other targets possible.
+       * lisp.h: Include <inttypes.h>, for INTPTR_MAX, UINTPTR_MAX.
+       (EMACS_INTPTR, EMACS_UINTPTR): New macros.
+       In the rest of the code, change types of integers that hold casted
+       pointers to EMACS_INTPTR and EMACS_UINTPTR, systematically
+       replacing EMACS_INT, long, EMACS_UINT, and unsigned long.
+       (XTYPE): Don't cast arg to EMACS_UINT; normally is not needed.
+       (XSET): Cast type of XTYPE arg to EMACS_INTPTR; it is needed here.
+       No need to cast type when ORing.
+       (XPNTR): Return a value of type EMACS_INTPTR or EMACS_UINTPTR.
+       * alloc.c (lisp_align_malloc): Remove a no-longer-needed cast.
+       * doc.c (store_function_docstring): Use EMACS_INTPTR, so as not to
+       assume EMACS_INT is the same width as char *.
+       * gtkutil.c (xg_gtk_scroll_destroy, xg_tool_bar_button_cb):
+       (xg_tool_bar_callback, xg_tool_bar_help_callback, xg_make_tool_item):
+       Remove no-longer-needed casts.
+       (xg_create_scroll_bar, xg_tool_bar_button_cb, xg_tool_bar_callback):
+       (xg_tool_bar_help_callback, xg_make_tool_item):
+       Use EMACS_INTPTR to hold an integer
+       that will be cast to void *; this can avoid a GCC warning
+       if EMACS_INT is not the same width as void *.
+       * menu.c (find_and_call_menu_selection): Remove no-longer-needed cast.
+       * xdisp.c (display_echo_area_1, resize_mini_window_1):
+       (current_message_1, set_message_1):
+       Use a local to convert to proper width without a cast.
+       * xmenu.c (dialog_selection_callback): Likewise.
+
+       * sysdep.c (get_random): Don't assume EMACS_INT is no wider than long.
+       Also, don't assume VALBITS / RAND_BITS is less than 5,
+       and don't rely on undefined behavior when shifting a 1 left into
+       the sign bit.
+       * lisp.h (get_random): Change signature to match.
+
+       * lread.c (hash_string): Use size_t, not int, for hash computation.
+       Normally we prefer signed values; but hashing is special, because
+       it's better to use unsigned division on hash table sizes so that
+       the remainder is nonnegative.  Also, size_t is the natural width
+       for hashing into memory.  The previous code used 'int', which doesn't
+       retain enough info to hash well into very large tables.
+       (oblookup, oblookup_last_bucket_number, Funintern): Likewise.
+
+       * dbusbind.c: Don't possibly lose pointer info when converting.
+       (xd_remove_watch, Fdbus_init_bus, xd_read_queued_messages):
+       Use XPNTR rather than XHASH, so that the high-order bits of
+       the pointer aren't lost when converting through void *.
+
+       * eval.c (Fautoload): Don't double-shift a pointer.
+
+       * fns.c (Frandom): Let EMACS_UINT be wider than unsigned long.
+
 2011-05-06  Juanma Barranquero  <address@hidden>
 
        * gnutls.c (DEF_GNUTLS_FN):

=== modified file 'src/alloc.c'
--- a/src/alloc.c       2011-04-26 06:17:52 +0000
+++ b/src/alloc.c       2011-04-29 17:56:27 +0000
@@ -438,7 +438,7 @@
    ALIGNMENT must be a power of 2.  */
 
 #define ALIGN(ptr, ALIGNMENT) \
-  ((POINTER_TYPE *) ((((EMACS_UINT)(ptr)) + (ALIGNMENT) - 1) \
+  ((POINTER_TYPE *) ((((uintptr_t) (ptr)) + (ALIGNMENT) - 1) \
                     & ~((ALIGNMENT) - 1)))
 
 
@@ -876,7 +876,7 @@
 #define ABLOCKS_BYTES (sizeof (struct ablocks) - BLOCK_PADDING)
 
 #define ABLOCK_ABASE(block) \
-  (((unsigned long) (block)->abase) <= (1 + 2 * ABLOCKS_SIZE)   \
+  (((uintptr_t) (block)->abase) <= (1 + 2 * ABLOCKS_SIZE)      \
    ? (struct ablocks *)(block)                                 \
    : (block)->abase)
 
@@ -888,7 +888,7 @@
 #define ABLOCKS_BASE(abase) (abase)
 #else
 #define ABLOCKS_BASE(abase) \
-  (1 & (long) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1])
+  (1 & (intptr_t) ABLOCKS_BUSY (abase) ? abase : ((void**)abase)[-1])
 #endif
 
 /* The list of free ablock.   */
@@ -914,7 +914,7 @@
   if (!free_ablock)
     {
       int i;
-      EMACS_INT aligned; /* int gets warning casting to 64-bit pointer.  */
+      intptr_t aligned; /* int gets warning casting to 64-bit pointer.  */
 
 #ifdef DOUG_LEA_MALLOC
       /* Prevent mmap'ing the chunk.  Lisp data may not be mmap'ed
@@ -977,17 +977,18 @@
          abase->blocks[i].x.next_free = free_ablock;
          free_ablock = &abase->blocks[i];
        }
-      ABLOCKS_BUSY (abase) = (struct ablocks *) (long) aligned;
+      ABLOCKS_BUSY (abase) = (struct ablocks *) aligned;
 
-      eassert (0 == ((EMACS_UINT)abase) % BLOCK_ALIGN);
+      eassert (0 == ((uintptr_t) abase) % BLOCK_ALIGN);
       eassert (ABLOCK_ABASE (&abase->blocks[3]) == abase); /* 3 is arbitrary */
       eassert (ABLOCK_ABASE (&abase->blocks[0]) == abase);
       eassert (ABLOCKS_BASE (abase) == base);
-      eassert (aligned == (long) ABLOCKS_BUSY (abase));
+      eassert (aligned == (intptr_t) ABLOCKS_BUSY (abase));
     }
 
   abase = ABLOCK_ABASE (free_ablock);
-  ABLOCKS_BUSY (abase) = (struct ablocks *) (2 + (long) ABLOCKS_BUSY (abase));
+  ABLOCKS_BUSY (abase) =
+    (struct ablocks *) (2 + (intptr_t) ABLOCKS_BUSY (abase));
   val = free_ablock;
   free_ablock = free_ablock->x.next_free;
 
@@ -1000,7 +1001,7 @@
   if (!val && nbytes)
     memory_full ();
 
-  eassert (0 == ((EMACS_UINT)val) % BLOCK_ALIGN);
+  eassert (0 == ((uintptr_t) val) % BLOCK_ALIGN);
   return val;
 }
 
@@ -1018,11 +1019,12 @@
   ablock->x.next_free = free_ablock;
   free_ablock = ablock;
   /* Update busy count.  */
-  ABLOCKS_BUSY (abase) = (struct ablocks *) (-2 + (long) ABLOCKS_BUSY (abase));
+  ABLOCKS_BUSY (abase) =
+    (struct ablocks *) (-2 + (intptr_t) ABLOCKS_BUSY (abase));
 
-  if (2 > (long) ABLOCKS_BUSY (abase))
+  if (2 > (intptr_t) ABLOCKS_BUSY (abase))
     { /* All the blocks are free.  */
-      int i = 0, aligned = (long) ABLOCKS_BUSY (abase);
+      int i = 0, aligned = (intptr_t) ABLOCKS_BUSY (abase);
       struct ablock **tem = &free_ablock;
       struct ablock *atop = &abase->blocks[aligned ? ABLOCKS_SIZE : 
ABLOCKS_SIZE - 1];
 
@@ -1039,7 +1041,7 @@
       eassert ((aligned & 1) == aligned);
       eassert (i == (aligned ? ABLOCKS_SIZE : ABLOCKS_SIZE - 1));
 #ifdef USE_POSIX_MEMALIGN
-      eassert ((unsigned long)ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0);
+      eassert ((uintptr_t) ABLOCKS_BASE (abase) % BLOCK_ALIGN == 0);
 #endif
       free (ABLOCKS_BASE (abase));
     }
@@ -1772,7 +1774,7 @@
   s = string_free_list;
   while (s != NULL)
     {
-      if ((unsigned long)s < 1024)
+      if ((uintptr_t) s < 1024)
        abort();
       s = NEXT_FREE_LISP_STRING (s);
     }
@@ -2432,10 +2434,10 @@
   &= ~(1 << ((n) % (sizeof(int) * CHAR_BIT)))
 
 #define FLOAT_BLOCK(fptr) \
-  ((struct float_block *)(((EMACS_UINT)(fptr)) & ~(BLOCK_ALIGN - 1)))
+  ((struct float_block *) (((uintptr_t) (fptr)) & ~(BLOCK_ALIGN - 1)))
 
 #define FLOAT_INDEX(fptr) \
-  ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Float))
+  ((((uintptr_t) (fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Float))
 
 struct float_block
 {
@@ -2544,10 +2546,10 @@
    / (sizeof (struct Lisp_Cons) * CHAR_BIT + 1))
 
 #define CONS_BLOCK(fptr) \
-  ((struct cons_block *)(((EMACS_UINT)(fptr)) & ~(BLOCK_ALIGN - 1)))
+  ((struct cons_block *) ((uintptr_t) (fptr) & ~(BLOCK_ALIGN - 1)))
 
 #define CONS_INDEX(fptr) \
-  ((((EMACS_UINT)(fptr)) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Cons))
+  (((uintptr_t) (fptr) & (BLOCK_ALIGN - 1)) / sizeof (struct Lisp_Cons))
 
 struct cons_block
 {
@@ -4021,7 +4023,7 @@
   struct mem_node *m;
 
   /* Quickly rule out some values which can't point to Lisp data.  */
-  if ((EMACS_INT) p %
+  if ((intptr_t) p %
 #ifdef USE_LSB_TAG
       8 /* USE_LSB_TAG needs Lisp data to be aligned on multiples of 8.  */
 #else
@@ -6072,7 +6074,7 @@
 {
   Lisp_Object end;
 
-  XSETINT (end, (EMACS_INT) (char *) sbrk (0) / 1024);
+  XSETINT (end, (intptr_t) (char *) sbrk (0) / 1024);
 
   return end;
 }

=== modified file 'src/callproc.c'
--- a/src/callproc.c    2011-05-04 14:03:16 +0000
+++ b/src/callproc.c    2011-05-06 07:13:19 +0000
@@ -193,7 +193,6 @@
   int count = SPECPDL_INDEX ();
   volatile USE_SAFE_ALLOCA;
 
-  const unsigned char **volatile new_argv_volatile;
   register const unsigned char **new_argv;
   /* File to use for stderr in the child.
      t means use same as standard output.  */
@@ -416,7 +415,6 @@
 
   SAFE_ALLOCA (new_argv, const unsigned char **,
               (nargs > 4 ? nargs - 2 : 2) * sizeof *new_argv);
-  new_argv_volatile = new_argv;
   if (nargs > 4)
     {
       register size_t i;
@@ -591,9 +589,20 @@
 
     BLOCK_INPUT;
 
-    pid = vfork ();
-
-    new_argv = new_argv_volatile;
+    /* vfork, and prevent local vars from being clobbered by the vfork.  */
+    {
+      int volatile fd_error_volatile = fd_error;
+      int volatile fd_output_volatile = fd_output;
+      int volatile output_to_buffer_volatile = output_to_buffer;
+      unsigned char const **volatile new_argv_volatile = new_argv;
+
+      pid = vfork ();
+
+      fd_error = fd_error_volatile;
+      fd_output = fd_output_volatile;
+      output_to_buffer = output_to_buffer_volatile;
+      new_argv = new_argv_volatile;
+    }
 
     if (pid == 0)
       {

=== modified file 'src/charset.c'
--- a/src/charset.c     2011-04-26 06:17:52 +0000
+++ b/src/charset.c     2011-05-01 16:27:34 +0000
@@ -869,7 +869,7 @@
   ASET (attrs, charset_name, args[charset_arg_name]);
 
   val = args[charset_arg_code_space];
-  for (i = 0, dimension = 0, nchars = 1; i < 4; i++)
+  for (i = 0, dimension = 0, nchars = 1; ; i++)
     {
       int min_byte, max_byte;
 
@@ -880,10 +880,12 @@
       charset.code_space[i * 4] = min_byte;
       charset.code_space[i * 4 + 1] = max_byte;
       charset.code_space[i * 4 + 2] = max_byte - min_byte + 1;
+      if (max_byte > 0)
+       dimension = i + 1;
+      if (i == 3)
+       break;
       nchars *= charset.code_space[i * 4 + 2];
       charset.code_space[i * 4 + 3] = nchars;
-      if (max_byte > 0)
-       dimension = i + 1;
     }
 
   val = args[charset_arg_dimension];

=== modified file 'src/charset.h'
--- a/src/charset.h     2011-04-11 06:48:18 +0000
+++ b/src/charset.h     2011-05-01 16:27:34 +0000
@@ -155,10 +155,11 @@
      byte code of the (N+1)th dimension, <code_space>[4N+1] is a
      maximum byte code of the (N+1)th dimension, <code_space>[4N+2] is
      (<code_space>[4N+1] - <code_space>[4N] + 1), <code_space>[4N+3]
-     is a number of characters containd in the first to (N+1)th
-     dismesions.  We get `char-index' of a `code-point' from this
+     is the number of characters contained in the first through (N+1)th
+     dimensions, except that there is no <code_space>[15].
+     We get `char-index' of a `code-point' from this
      information.  */
-  int code_space[16];
+  int code_space[15];
 
   /* If B is a byte of Nth dimension of a code-point, the (N-1)th bit
      of code_space_mask[B] is set.  This array is used to quickly

=== modified file 'src/coding.c'
--- a/src/coding.c      2011-04-29 19:47:29 +0000
+++ b/src/coding.c      2011-05-01 23:37:08 +0000
@@ -5368,8 +5368,8 @@
              if (src == src_end)
                goto too_short;
              ONE_MORE_BYTE (c);
-             if (c < charset->code_space[(dim - 1 - idx) * 2]
-                 || c > charset->code_space[(dim - 1 - idx) * 2 + 1])
+             if (c < charset->code_space[(dim - 1 - idx) * 4]
+                 || c > charset->code_space[(dim - 1 - idx) * 4 + 1])
                break;
            }
          if (idx < dim)

=== modified file 'src/dbusbind.c'
--- a/src/dbusbind.c    2011-04-19 00:34:42 +0000
+++ b/src/dbusbind.c    2011-04-30 01:06:41 +0000
@@ -892,7 +892,7 @@
     return;
 
   /* Unset session environment.  */
-  if (data != NULL && data == (void*) XHASH (QCdbus_session_bus))
+  if (SYMBOLP (QCdbus_session_bus) && XSYMBOL (QCdbus_session_bus) == data)
     {
       XD_DEBUG_MESSAGE ("unsetenv DBUS_SESSION_BUS_ADDRESS");
       unsetenv ("DBUS_SESSION_BUS_ADDRESS");
@@ -920,6 +920,8 @@
 {
   DBusConnection *connection;
 
+  CHECK_SYMBOL (bus);
+
   /* Open a connection to the bus.  */
   connection = xd_initialize (bus, TRUE);
 
@@ -929,7 +931,7 @@
                                            xd_add_watch,
                                            xd_remove_watch,
                                             xd_toggle_watch,
-                                           (void*) XHASH (bus), NULL))
+                                           XSYMBOL (bus), NULL))
     XD_SIGNAL1 (build_string ("Cannot add watch functions"));
 
   /* Add bus to list of registered buses.  */
@@ -1824,7 +1826,7 @@
   if (data != NULL)
     while (!NILP (busp))
       {
-       if (data == (void*) XHASH (CAR_SAFE (busp)))
+       if (SYMBOLP (CAR_SAFE (busp)) && XSYMBOL (CAR_SAFE (busp)) == data)
          bus = CAR_SAFE (busp);
        busp = CDR_SAFE (busp);
       }

=== modified file 'src/dispnew.c'
--- a/src/dispnew.c     2011-04-25 21:34:39 +0000
+++ b/src/dispnew.c     2011-04-30 15:40:06 +0000
@@ -4576,8 +4576,8 @@
   for (i = 0; i < row_entry_idx; ++i)
     row_table[row_entry_pool[i].bucket] = NULL;
 
-  /* Value is > 0 to indicate that we scrolled the display.  */
-  return nruns;
+  /* Value is 1 to indicate that we scrolled the display.  */
+  return 0 < nruns;
 }
 
 

=== modified file 'src/doc.c'
--- a/src/doc.c 2011-04-27 19:05:21 +0000
+++ b/src/doc.c 2011-05-06 07:13:19 +0000
@@ -349,10 +349,10 @@
        return Qnil;
       /* FIXME: This is not portable, as it assumes that string
         pointers have the top bit clear.  */
-      else if ((EMACS_INT) XSUBR (fun)->doc >= 0)
+      else if ((intptr_t) XSUBR (fun)->doc >= 0)
        doc = build_string (XSUBR (fun)->doc);
       else
-       doc = make_number ((EMACS_INT) XSUBR (fun)->doc);
+       doc = make_number ((intptr_t) XSUBR (fun)->doc);
     }
   else if (COMPILEDP (fun))
     {
@@ -507,7 +507,10 @@
 
   /* Lisp_Subrs have a slot for it.  */
   if (SUBRP (fun))
-    XSUBR (fun)->doc = (char *) - offset;
+    {
+      intptr_t negative_offset = - offset;
+      XSUBR (fun)->doc = (char *) negative_offset;
+    }
 
   /* If it's a lisp form, stick it in the form.  */
   else if (CONSP (fun))

=== modified file 'src/doprnt.c'
--- a/src/doprnt.c      2011-04-29 19:34:06 +0000
+++ b/src/doprnt.c      2011-04-30 20:05:43 +0000
@@ -70,9 +70,9 @@
      %<flags><width><precision><length>character
 
    where flags is [+ -0], width is [0-9]+, precision is .[0-9]+, and length
-   is empty or l or ll.  Also, %% in a format stands for a single % in the
-   output.  A % that does not introduce a valid %-sequence causes
-   undefined behavior.
+   is empty or l or the value of the pI macro.  Also, %% in a format
+   stands for a single % in the output.  A % that does not introduce a
+   valid %-sequence causes undefined behavior.
 
    The + flag character inserts a + before any positive number, while a space
    inserts a space before any positive number; these flags only affect %d, %o,
@@ -85,11 +85,8 @@
    modifier: it is supported for %d, %o, and %x conversions of integral
    arguments, must immediately precede the conversion specifier, and means that
    the respective argument is to be treated as `long int' or `unsigned long
-   int'.  Similarly, ll (two letter ells) means to use `long long int' or
-   `unsigned long long int'; this can be used only on hosts that have
-   these two types.  The empty length modifier means to use `int' or
-   `unsigned int'.  EMACS_INT arguments should use the pI macro, which
-   expands to whatever length modifier is needed for the target host.
+   int'.  Similarly, the value of the pI macro means to use EMACS_INT or
+   EMACS_UINT and the empty length modifier means `int' or `unsigned int'.
 
    The width specifier supplies a lower limit for the length of the printed
    representation.  The padding, if any, normally goes on the left, but it goes
@@ -186,6 +183,7 @@
          size_t size_bound = 0;
          EMACS_INT width;  /* Columns occupied by STRING on display.  */
          int long_flag = 0;
+         int pIlen = sizeof pI - 1;
 
          fmt++;
          /* Copy this one %-spec into fmtcpy.  */
@@ -201,7 +199,7 @@
                     %1.1000f and %1000.1f both might need 1000+ bytes.
                     Parse the width or precision, checking for overflow.  */
                  size_t n = *fmt - '0';
-                 while (fmt < format_end
+                 while (fmt + 1 < format_end
                         && '0' <= fmt[1] && fmt[1] <= '9')
                    {
                      /* Avoid size_t overflow.  Avoid int overflow too, as
@@ -218,20 +216,25 @@
                  if (size_bound < n)
                    size_bound = n;
                }
-             else if (*fmt == '-' || *fmt == ' ' || *fmt == '.' || *fmt == '+')
-               ;
-             else if (*fmt == 'l')
-               {
-                 long_flag = 1 + (fmt + 1 < format_end && fmt[1] == 'l');
-                 fmt += long_flag;
-                 break;
-               }
-             else
+             else if (! (*fmt == '-' || *fmt == ' ' || *fmt == '.'
+                         || *fmt == '+'))
                break;
              fmt++;
            }
-         if (fmt > format_end)
-           fmt = format_end;
+
+         if (0 < pIlen && pIlen <= format_end - fmt
+             && memcmp (fmt, pI, pIlen) == 0)
+           {
+             long_flag = 2;
+             memcpy (string, fmt + 1, pIlen);
+             string += pIlen;
+             fmt += pIlen;
+           }
+         else if (fmt < format_end && *fmt == 'l')
+           {
+             long_flag = 1;
+             *string++ = *++fmt;
+           }
          *string = 0;
 
          /* Make the size bound large enough to handle floating point formats
@@ -253,8 +256,7 @@
          switch (*fmt++)
            {
            default:
-             error ("Invalid format operation %%%s%c",
-                    "ll" + 2 - long_flag, fmt[-1]);
+             error ("Invalid format operation %s", fmtcpy);
 
 /*         case 'b': */
            case 'l':
@@ -265,12 +267,8 @@
 
                if (1 < long_flag)
                  {
-#ifdef HAVE_LONG_LONG_INT
-                   long long ll = va_arg (ap, long long);
+                   EMACS_INT ll = va_arg (ap, EMACS_INT);
                    sprintf (sprintf_buffer, fmtcpy, ll);
-#else
-                   error ("Invalid format operation %%ll%c", fmt[-1]);
-#endif
                  }
                else if (long_flag)
                  {
@@ -295,12 +293,8 @@
 
                if (1 < long_flag)
                  {
-#ifdef HAVE_UNSIGNED_LONG_LONG_INT
-                   unsigned long long ull = va_arg (ap, unsigned long long);
+                   EMACS_UINT ull = va_arg (ap, EMACS_UINT);
                    sprintf (sprintf_buffer, fmtcpy, ull);
-#else
-                   error ("Invalid format operation %%ll%c", fmt[-1]);
-#endif
                  }
                else if (long_flag)
                  {

=== modified file 'src/eval.c'
--- a/src/eval.c        2011-04-29 11:01:11 +0000
+++ b/src/eval.c        2011-05-04 07:19:21 +0000
@@ -1994,7 +1994,7 @@
 {
   char buf[4000];
   size_t size = sizeof buf;
-  size_t size_max = min (MOST_POSITIVE_FIXNUM, SIZE_MAX);
+  size_t size_max = min (MOST_POSITIVE_FIXNUM + 1, SIZE_MAX);
   size_t mlen = strlen (m);
   char *buffer = buf;
   size_t used;
@@ -2002,7 +2002,10 @@
 
   while (1)
     {
-      used = doprnt (buffer, size, m, m + mlen, ap);
+      va_list ap_copy;
+      va_copy (ap_copy, ap);
+      used = doprnt (buffer, size, m, m + mlen, ap_copy);
+      va_end (ap_copy);
 
       /* Note: the -1 below is because `doprnt' returns the number of bytes
         excluding the terminating null byte, and it always terminates with a
@@ -2144,7 +2147,7 @@
        We used to use 0 here, but that leads to accidental sharing in
        purecopy's hash-consing, so we use a (hopefully) unique integer
        instead.  */
-    docstring = make_number (XHASH (function));
+    docstring = make_number (XPNTR (function));
   return Ffset (function,
                Fpurecopy (list5 (Qautoload, file, docstring,
                                  interactive, type)));

=== modified file 'src/fns.c'
--- a/src/fns.c 2011-04-25 07:14:46 +0000
+++ b/src/fns.c 2011-04-28 00:43:18 +0000
@@ -75,7 +75,7 @@
 {
   EMACS_INT val;
   Lisp_Object lispy_val;
-  unsigned long denominator;
+  EMACS_UINT denominator;
 
   if (EQ (limit, Qt))
     seed_random (getpid () + time (NULL));
@@ -88,7 +88,7 @@
         it's possible to get a quotient larger than n; discarding
         these values eliminates the bias that would otherwise appear
         when using a large n.  */
-      denominator = ((unsigned long)1 << VALBITS) / XFASTINT (limit);
+      denominator = ((EMACS_UINT) 1 << VALBITS) / XFASTINT (limit);
       do
        val = get_random () / denominator;
       while (val >= XFASTINT (limit));

=== modified file 'src/gtkutil.c'
--- a/src/gtkutil.c     2011-04-19 07:10:55 +0000
+++ b/src/gtkutil.c     2011-04-29 17:56:27 +0000
@@ -3354,7 +3354,7 @@
 static void
 xg_gtk_scroll_destroy (GtkWidget *widget, gpointer data)
 {
-  int id = (int) (EMACS_INT) data; /* The EMACS_INT cast avoids a warning. */
+  int id = (intptr_t) data;
   xg_remove_widget_from_map (id);
 }
 
@@ -3375,7 +3375,7 @@
 {
   GtkWidget *wscroll;
   GtkWidget *webox;
-  int scroll_id;
+  intptr_t scroll_id;
 #ifdef HAVE_GTK3
   GtkAdjustment *vadj;
 #else
@@ -3397,11 +3397,10 @@
 
   scroll_id = xg_store_widget_in_map (wscroll);
 
-  /* The EMACS_INT cast avoids a warning. */
   g_signal_connect (G_OBJECT (wscroll),
                     "destroy",
                     G_CALLBACK (xg_gtk_scroll_destroy),
-                    (gpointer) (EMACS_INT) scroll_id);
+                    (gpointer) scroll_id);
   g_signal_connect (G_OBJECT (wscroll),
                     "change-value",
                     scroll_callback,
@@ -3663,8 +3662,8 @@
                        GdkEventButton *event,
                        gpointer user_data)
 {
-  /* Casts to avoid warnings when gpointer is 64 bits and int is 32 bits */
-  gpointer ptr = (gpointer) (EMACS_INT) event->state;
+  intptr_t state = event->state;
+  gpointer ptr = (gpointer) state;
   g_object_set_data (G_OBJECT (widget), XG_TOOL_BAR_LAST_MODIFIER, ptr);
   return FALSE;
 }
@@ -3678,10 +3677,9 @@
 static void
 xg_tool_bar_callback (GtkWidget *w, gpointer client_data)
 {
-  /* The EMACS_INT cast avoids a warning. */
-  int idx = (int) (EMACS_INT) client_data;
+  intptr_t idx = (intptr_t) client_data;
   gpointer gmod = g_object_get_data (G_OBJECT (w), XG_TOOL_BAR_LAST_MODIFIER);
-  int mod = (int) (EMACS_INT) gmod;
+  intptr_t mod = (intptr_t) gmod;
 
   FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA);
   Lisp_Object key, frame;
@@ -3960,8 +3958,7 @@
                            GdkEventCrossing *event,
                            gpointer client_data)
 {
-  /* The EMACS_INT cast avoids a warning. */
-  int idx = (int) (EMACS_INT) client_data;
+  intptr_t idx = (intptr_t) client_data;
   FRAME_PTR f = (FRAME_PTR) g_object_get_data (G_OBJECT (w), XG_FRAME_DATA);
   Lisp_Object help, frame;
 
@@ -4155,14 +4152,16 @@
 
   if (wimage)
     {
-      /* The EMACS_INT cast avoids a warning. */
+      intptr_t ii = i;
+      gpointer gi = (gpointer) ii;
+
       g_signal_connect (G_OBJECT (ti), "create-menu-proxy",
                         G_CALLBACK (xg_tool_bar_menu_proxy),
-                        (gpointer) (EMACS_INT) i);
+                        gi);
 
       g_signal_connect (G_OBJECT (wb), "clicked",
                         G_CALLBACK (xg_tool_bar_callback),
-                        (gpointer) (EMACS_INT) i);
+                        gi);
 
       g_object_set_data (G_OBJECT (weventbox), XG_FRAME_DATA, (gpointer)f);
 
@@ -4193,11 +4192,11 @@
       g_signal_connect (G_OBJECT (weventbox),
                         "enter-notify-event",
                         G_CALLBACK (xg_tool_bar_help_callback),
-                        (gpointer) (EMACS_INT) i);
+                        gi);
       g_signal_connect (G_OBJECT (weventbox),
                         "leave-notify-event",
                         G_CALLBACK (xg_tool_bar_help_callback),
-                        (gpointer) (EMACS_INT) i);
+                        gi);
     }
 
   if (wbutton) *wbutton = wb;

=== modified file 'src/image.c'
--- a/src/image.c       2011-05-06 01:05:25 +0000
+++ b/src/image.c       2011-05-06 06:30:56 +0000
@@ -8602,11 +8602,9 @@
 of `dynamic-library-alist', which see).  */)
   (Lisp_Object type, Lisp_Object libraries)
 {
-  Lisp_Object tested;
-
 #ifdef HAVE_NTGUI
   /* Don't try to reload the library.  */
-  tested = Fassq (type, Vlibrary_cache);
+  Lisp_Object tested = Fassq (type, Vlibrary_cache);
   if (CONSP (tested))
     return XCDR (tested);
 #endif

=== modified file 'src/lisp.h'
--- a/src/lisp.h        2011-05-01 00:04:17 +0000
+++ b/src/lisp.h        2011-05-06 05:55:01 +0000
@@ -22,6 +22,7 @@
 
 #include <stdarg.h>
 #include <stddef.h>
+#include <inttypes.h>
 
 /* Use the configure flag --enable-checking[=LIST] to enable various
    types of run time checks for Lisp objects.  */
@@ -33,25 +34,28 @@
 #define CHECK_CONS_LIST() ((void) 0)
 #endif
 
+/* Temporarily disable wider-than-pointer integers until they're tested more.
+   Build with CFLAGS='-DWIDE_EMACS_INT' to try them out.  */
+/* #undef WIDE_EMACS_INT */
+
 /* These are default choices for the types to use.  */
-#ifdef _LP64
-#ifndef EMACS_INT
-#define EMACS_INT long
-#define BITS_PER_EMACS_INT BITS_PER_LONG
-#define pI "l"
-#endif
-#ifndef EMACS_UINT
-#define EMACS_UINT unsigned long
-#endif
-#else /* not _LP64 */
-#ifndef EMACS_INT
-#define EMACS_INT int
-#define BITS_PER_EMACS_INT BITS_PER_INT
-#define pI ""
-#endif
-#ifndef EMACS_UINT
-#define EMACS_UINT unsigned int
-#endif
+#ifndef EMACS_INT
+# if BITS_PER_LONG < BITS_PER_LONG_LONG && defined WIDE_EMACS_INT
+#  define EMACS_INT long long
+#  define BITS_PER_EMACS_INT BITS_PER_LONG_LONG
+#  define pI "ll"
+# elif BITS_PER_INT < BITS_PER_LONG
+#  define EMACS_INT long
+#  define BITS_PER_EMACS_INT BITS_PER_LONG
+#  define pI "l"
+# else
+#  define EMACS_INT int
+#  define BITS_PER_EMACS_INT BITS_PER_INT
+#  define pI ""
+# endif
+#endif
+#ifndef EMACS_UINT
+# define EMACS_UINT unsigned EMACS_INT
 #endif
 
 /* Extra internal type checking?  */
@@ -398,7 +402,7 @@
 #ifdef USE_LSB_TAG
 
 #define TYPEMASK ((((EMACS_INT) 1) << GCTYPEBITS) - 1)
-#define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT) (a)) & TYPEMASK))
+#define XTYPE(a) ((enum Lisp_Type) ((a) & TYPEMASK))
 #ifdef USE_2_TAGS_FOR_INTS
 # define XINT(a) (((EMACS_INT) (a)) >> (GCTYPEBITS - 1))
 # define XUINT(a) (((EMACS_UINT) (a)) >> (GCTYPEBITS - 1))
@@ -408,11 +412,11 @@
 # define XUINT(a) (((EMACS_UINT) (a)) >> GCTYPEBITS)
 # define make_number(N) (((EMACS_INT) (N)) << GCTYPEBITS)
 #endif
-#define XSET(var, type, ptr)                                   \
-    (eassert (XTYPE (ptr) == 0), /* Check alignment.  */       \
-     (var) = ((EMACS_INT) (type)) | ((EMACS_INT) (ptr)))
+#define XSET(var, type, ptr)                                           \
+    (eassert (XTYPE ((intptr_t) (ptr)) == 0), /* Check alignment.  */ \
+     (var) = (type) | (intptr_t) (ptr))
 
-#define XPNTR(a) ((EMACS_INT) ((a) & ~TYPEMASK))
+#define XPNTR(a) ((intptr_t) ((a) & ~TYPEMASK))
 
 #else  /* not USE_LSB_TAG */
 
@@ -446,14 +450,14 @@
 
 #define XSET(var, type, ptr)                             \
    ((var) = ((EMACS_INT) ((EMACS_UINT) (type) << VALBITS) \
-            + ((EMACS_INT) (ptr) & VALMASK)))
+            + ((intptr_t) (ptr) & VALMASK)))
 
 #ifdef DATA_SEG_BITS
 /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
    which were stored in a Lisp_Object */
-#define XPNTR(a) ((EMACS_UINT) (((a) & VALMASK) | DATA_SEG_BITS))
+#define XPNTR(a) ((uintptr_t) (((a) & VALMASK)) | DATA_SEG_BITS))
 #else
-#define XPNTR(a) ((EMACS_UINT) ((a) & VALMASK))
+#define XPNTR(a) ((uintptr_t) ((a) & VALMASK))
 #endif
 
 #endif /* not USE_LSB_TAG */
@@ -479,7 +483,7 @@
 /* Some versions of gcc seem to consider the bitfield width when issuing
    the "cast to pointer from integer of different size" warning, so the
    cast is here to widen the value back to its natural size.  */
-# define XPNTR(v) ((EMACS_INT)((v).s.val) << GCTYPEBITS)
+# define XPNTR(v) ((intptr_t) (v).s.val << GCTYPEBITS)
 
 #else  /* !USE_LSB_TAG */
 
@@ -495,9 +499,9 @@
 #ifdef DATA_SEG_BITS
 /* DATA_SEG_BITS forces extra bits to be or'd in with any pointers
    which were stored in a Lisp_Object */
-#define XPNTR(a) (XUINT (a) | DATA_SEG_BITS)
+#define XPNTR(a) ((intptr_t) (XUINT (a) | DATA_SEG_BITS))
 #else
-#define XPNTR(a) ((EMACS_INT) XUINT (a))
+#define XPNTR(a) ((intptr_t) XUINT (a))
 #endif
 
 #endif /* !USE_LSB_TAG */
@@ -1814,8 +1818,8 @@
     XSETCDR ((x), tmp);                        \
   } while (0)
 
-/* Cast pointers to this type to compare them.  Some machines want int.  */
-#define PNTR_COMPARISON_TYPE EMACS_UINT
+/* Cast pointers to this type to compare them.  */
+#define PNTR_COMPARISON_TYPE uintptr_t
 
 /* Define a built-in function for calling from Lisp.
  `lname' should be the name to give the function in Lisp,
@@ -3354,7 +3358,7 @@
 extern void child_setup_tty (int);
 extern void setup_pty (int);
 extern int set_window_size (int, int, int);
-extern long get_random (void);
+extern EMACS_INT get_random (void);
 extern void seed_random (long);
 extern int emacs_open (const char *, int, int);
 extern int emacs_close (int);

=== modified file 'src/lread.c'
--- a/src/lread.c       2011-05-05 16:56:39 +0000
+++ b/src/lread.c       2011-05-06 06:30:56 +0000
@@ -19,7 +19,6 @@
 
 
 #include <config.h>
-#include <inttypes.h>
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -2250,6 +2249,26 @@
     }
 }
 
+/* Return the digit that CHARACTER stands for in the given BASE.
+   Return -1 if CHARACTER is out of range for BASE,
+   and -2 if CHARACTER is not valid for any supported BASE.  */
+static inline int
+digit_to_number (int character, int base)
+{
+  int digit;
+
+  if ('0' <= character && character <= '9')
+    digit = character - '0';
+  else if ('a' <= character && character <= 'z')
+    digit = character - 'a' + 10;
+  else if ('A' <= character && character <= 'Z')
+    digit = character - 'A' + 10;
+  else
+    return -2;
+
+  return digit < base ? digit : -1;
+}
+
 /* Read an integer in radix RADIX using READCHARFUN to read
    characters.  RADIX must be in the interval [2..36]; if it isn't, a
    read error is signaled .  Value is the integer read.  Signals an
@@ -2259,59 +2278,64 @@
 static Lisp_Object
 read_integer (Lisp_Object readcharfun, int radix)
 {
-  int ndigits = 0, invalid_p, c, sign = 0;
-  /* We use a floating point number because  */
-  double number = 0;
+  /* Room for sign, leading 0, other digits, trailing null byte.  */
+  char buf[1 + 1 + sizeof (uintmax_t) * CHAR_BIT + 1];
+
+  int valid = -1; /* 1 if valid, 0 if not, -1 if incomplete.  */
 
   if (radix < 2 || radix > 36)
-    invalid_p = 1;
+    valid = 0;
   else
     {
-      number = ndigits = invalid_p = 0;
-      sign = 1;
+      char *p = buf;
+      int c, digit;
 
       c = READCHAR;
-      if (c == '-')
+      if (c == '-' || c == '+')
        {
+         *p++ = c;
          c = READCHAR;
-         sign = -1;
-       }
-      else if (c == '+')
-       c = READCHAR;
-
-      while (c >= 0)
-       {
-         int digit;
-
-         if (c >= '0' && c <= '9')
-           digit = c - '0';
-         else if (c >= 'a' && c <= 'z')
-           digit = c - 'a' + 10;
-         else if (c >= 'A' && c <= 'Z')
-           digit = c - 'A' + 10;
+       }
+
+      if (c == '0')
+       {
+         *p++ = c;
+         valid = 1;
+
+         /* Ignore redundant leading zeros, so the buffer doesn't
+            fill up with them.  */
+         do
+           c = READCHAR;
+         while (c == '0');
+       }
+
+      while (-1 <= (digit = digit_to_number (c, radix)))
+       {
+         if (digit == -1)
+           valid = 0;
+         if (valid < 0)
+           valid = 1;
+
+         if (p < buf + sizeof buf - 1)
+           *p++ = c;
          else
-           {
-             UNREAD (c);
-             break;
-           }
-
-         if (digit < 0 || digit >= radix)
-           invalid_p = 1;
-
-         number = radix * number + digit;
-         ++ndigits;
+           valid = 0;
+
          c = READCHAR;
        }
+
+      if (c >= 0)
+       UNREAD (c);
+      *p = '\0';
     }
 
-  if (ndigits == 0 || invalid_p)
+  if (! valid)
     {
-      char buf[50];
       sprintf (buf, "integer, radix %d", radix);
       invalid_syntax (buf, 0);
     }
 
-  return make_fixnum_or_float (sign * number);
+  return string_to_number (buf, radix, 0);
 }
 
 
@@ -3170,23 +3194,6 @@
 }
 
 
-static inline int
-digit_to_number (int character, int base)
-{
-  int digit;
-
-  if ('0' <= character && character <= '9')
-    digit = character - '0';
-  else if ('a' <= character && character <= 'z')
-    digit = character - 'a' + 10;
-  else if ('A' <= character && character <= 'Z')
-    digit = character - 'A' + 10;
-  else
-    return -1;
-
-  return digit < base ? digit : -1;
-}
-
 #define LEAD_INT 1
 #define DOT_CHAR 2
 #define TRAIL_INT 4
@@ -3615,9 +3622,9 @@
 
 /* oblookup stores the bucket number here, for the sake of Funintern.  */
 
-static int oblookup_last_bucket_number;
+static size_t oblookup_last_bucket_number;
 
-static int hash_string (const char *ptr, int len);
+static size_t hash_string (const char *ptr, size_t len);
 
 /* Get an error if OBARRAY is not an obarray.
    If it is one, return it.  */
@@ -3759,7 +3766,7 @@
   (Lisp_Object name, Lisp_Object obarray)
 {
   register Lisp_Object string, tem;
-  int hash;
+  size_t hash;
 
   if (NILP (obarray)) obarray = Vobarray;
   obarray = check_obarray (obarray);
@@ -3828,8 +3835,8 @@
 Lisp_Object
 oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, 
EMACS_INT size_byte)
 {
-  int hash;
-  int obsize;
+  size_t hash;
+  size_t obsize;
   register Lisp_Object tail;
   Lisp_Object bucket, tem;
 
@@ -3862,21 +3869,21 @@
   return tem;
 }
 
-static int
-hash_string (const char *ptr, int len)
+static size_t
+hash_string (const char *ptr, size_t len)
 {
   register const char *p = ptr;
   register const char *end = p + len;
   register unsigned char c;
-  register int hash = 0;
+  register size_t hash = 0;
 
   while (p != end)
     {
       c = *p++;
       if (c >= 0140) c -= 40;
-      hash = ((hash<<3) + (hash>>28) + c);
+      hash = (hash << 3) + (hash >> (CHAR_BIT * sizeof hash - 4)) + c;
     }
-  return hash & 07777777777;
+  return hash;
 }
 
 void

=== modified file 'src/menu.c'
--- a/src/menu.c        2011-04-16 15:11:41 +0000
+++ b/src/menu.c        2011-04-29 17:56:27 +0000
@@ -800,9 +800,9 @@
          if (!NILP (descrip))
            wv->lkey = descrip;
          wv->value = 0;
-         /* The EMACS_INT cast avoids a warning.  There's no problem
+         /* The intptr_t cast avoids a warning.  There's no problem
             as long as pointers have enough bits to hold small integers.  */
-         wv->call_data = (!NILP (def) ? (void *) (EMACS_INT) i : 0);
+         wv->call_data = (!NILP (def) ? (void *) (intptr_t) i : 0);
          wv->enabled = !NILP (enable);
 
          if (NILP (type))
@@ -911,9 +911,9 @@
       else
        {
          entry = XVECTOR (vector)->contents[i + MENU_ITEMS_ITEM_VALUE];
-         /* The EMACS_INT cast avoids a warning.  There's no problem
+         /* Treat the pointer as an integer.  There's no problem
             as long as pointers have enough bits to hold small integers.  */
-         if ((int) (EMACS_INT) client_data == i)
+         if ((intptr_t) client_data == i)
            {
              int j;
              struct input_event buf;

=== modified file 'src/process.c'
--- a/src/process.c     2011-05-04 23:56:09 +0000
+++ b/src/process.c     2011-05-05 05:31:24 +0000
@@ -28,7 +28,6 @@
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <setjmp.h>
-#include <inttypes.h>
 
 #include <unistd.h>
 #include <fcntl.h>
@@ -1386,7 +1385,7 @@
       {
        if (EQ (coding_systems, Qt))
          {
-           args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof args2);
+           args2 = (Lisp_Object *) alloca ((nargs + 1) * sizeof *args2);
            args2[0] = Qstart_process;
            for (i = 0; i < nargs; i++) args2[i + 1] = args[i];
            GCPRO2 (proc, current_dir);

=== modified file 'src/sysdep.c'
--- a/src/sysdep.c      2011-05-02 03:57:02 +0000
+++ b/src/sysdep.c      2011-05-03 05:47:50 +0000
@@ -1786,23 +1786,14 @@
  * Build a full Emacs-sized word out of whatever we've got.
  * This suffices even for a 64-bit architecture with a 15-bit rand.
  */
-long
+EMACS_INT
 get_random (void)
 {
-  long val = random ();
-#if VALBITS > RAND_BITS
-  val = (val << RAND_BITS) ^ random ();
-#if VALBITS > 2*RAND_BITS
-  val = (val << RAND_BITS) ^ random ();
-#if VALBITS > 3*RAND_BITS
-  val = (val << RAND_BITS) ^ random ();
-#if VALBITS > 4*RAND_BITS
-  val = (val << RAND_BITS) ^ random ();
-#endif /* need at least 5 */
-#endif /* need at least 4 */
-#endif /* need at least 3 */
-#endif /* need at least 2 */
-  return val & ((1L << VALBITS) - 1);
+  EMACS_UINT val = 0;
+  int i;
+  for (i = 0; i < (VALBITS + RAND_BITS - 1) / RAND_BITS; i++)
+    val = (val << RAND_BITS) ^ random ();
+  return val & (((EMACS_INT) 1 << VALBITS) - 1);
 }
 
 #ifndef HAVE_STRERROR

=== modified file 'src/term.c'
--- a/src/term.c        2011-04-24 09:00:03 +0000
+++ b/src/term.c        2011-05-04 07:20:46 +0000
@@ -26,7 +26,6 @@
 #include <sys/file.h>
 #include <unistd.h>
 #include <signal.h>
-#include <stdarg.h>
 #include <setjmp.h>
 
 #include "lisp.h"
@@ -3619,7 +3618,6 @@
   vfprintf (stderr, str, ap);
   if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n'))
     fprintf (stderr, "\n");
-  va_end (ap);
   fflush (stderr);
   exit (1);
 }

=== modified file 'src/xdisp.c'
--- a/src/xdisp.c       2011-04-26 06:17:52 +0000
+++ b/src/xdisp.c       2011-04-29 17:56:27 +0000
@@ -8737,7 +8737,7 @@
   window_height_changed_p
     = with_echo_area_buffer (w, display_last_displayed_message_p,
                             display_echo_area_1,
-                            (EMACS_INT) w, Qnil, 0, 0);
+                            (intptr_t) w, Qnil, 0, 0);
 
   if (no_message_p)
     echo_area_buffer[i] = Qnil;
@@ -8756,7 +8756,8 @@
 static int
 display_echo_area_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4)
 {
-  struct window *w = (struct window *) a1;
+  intptr_t i1 = a1;
+  struct window *w = (struct window *) i1;
   Lisp_Object window;
   struct text_pos start;
   int window_height_changed_p = 0;
@@ -8798,7 +8799,8 @@
        resize_exactly = Qnil;
 
       resized_p = with_echo_area_buffer (w, 0, resize_mini_window_1,
-                                        (EMACS_INT) w, resize_exactly, 0, 0);
+                                        (intptr_t) w, resize_exactly,
+                                        0, 0);
       if (resized_p)
        {
          ++windows_or_buffers_changed;
@@ -8818,7 +8820,8 @@
 static int
 resize_mini_window_1 (EMACS_INT a1, Lisp_Object exactly, EMACS_INT a3, 
EMACS_INT a4)
 {
-  return resize_mini_window ((struct window *) a1, !NILP (exactly));
+  intptr_t i1 = a1;
+  return resize_mini_window ((struct window *) i1, !NILP (exactly));
 }
 
 
@@ -8984,7 +8987,7 @@
   else
     {
       with_echo_area_buffer (0, 0, current_message_1,
-                            (EMACS_INT) &msg, Qnil, 0, 0);
+                            (intptr_t) &msg, Qnil, 0, 0);
       if (NILP (msg))
        echo_area_buffer[0] = Qnil;
     }
@@ -8996,7 +8999,8 @@
 static int
 current_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT a3, EMACS_INT a4)
 {
-  Lisp_Object *msg = (Lisp_Object *) a1;
+  intptr_t i1 = a1;
+  Lisp_Object *msg = (Lisp_Object *) i1;
 
   if (Z > BEG)
     *msg = make_buffer_string (BEG, Z, 1);
@@ -9127,7 +9131,7 @@
        || (STRINGP (string) && STRING_MULTIBYTE (string)));
 
   with_echo_area_buffer (0, -1, set_message_1,
-                        (EMACS_INT) s, string, nbytes, multibyte_p);
+                        (intptr_t) s, string, nbytes, multibyte_p);
   message_buf_print = 0;
   help_echo_showing_p = 0;
 }
@@ -9141,7 +9145,8 @@
 static int
 set_message_1 (EMACS_INT a1, Lisp_Object a2, EMACS_INT nbytes, EMACS_INT 
multibyte_p)
 {
-  const char *s = (const char *) a1;
+  intptr_t i1 = a1;
+  const char *s = (const char *) i1;
   const unsigned char *msg = (const unsigned char *) s;
   Lisp_Object string = a2;
 

=== modified file 'src/xmenu.c'
--- a/src/xmenu.c       2011-04-25 21:34:39 +0000
+++ b/src/xmenu.c       2011-05-03 06:12:50 +0000
@@ -1012,10 +1012,10 @@
       menu_items = f->menu_bar_vector;
       menu_items_allocated = VECTORP (menu_items) ? ASIZE (menu_items) : 0;
       subitems = ASIZE (items) / 4;
-      submenu_start = (int *) alloca (subitems * sizeof (int *));
-      submenu_end = (int *) alloca (subitems * sizeof (int *));
+      submenu_start = (int *) alloca (subitems * sizeof (int));
+      submenu_end = (int *) alloca (subitems * sizeof (int));
       submenu_n_panes = (int *) alloca (subitems * sizeof (int));
-      submenu_top_level_items = (int *) alloca (subitems * sizeof (int *));
+      submenu_top_level_items = (int *) alloca (subitems * sizeof (int));
       init_menu_items ();
       for (i = 0; i < subitems; i++)
        {
@@ -1139,9 +1139,9 @@
          wv->help = Qnil;
          /* This prevents lwlib from assuming this
             menu item is really supposed to be empty.  */
-         /* The EMACS_INT cast avoids a warning.
+         /* The intptr_t cast avoids a warning.
             This value just has to be different from small integers.  */
-         wv->call_data = (void *) (EMACS_INT) (-1);
+         wv->call_data = (void *) (intptr_t) (-1);
 
          if (prev_wv)
            prev_wv->next = wv;
@@ -1876,9 +1876,9 @@
 static void
 dialog_selection_callback (GtkWidget *widget, gpointer client_data)
 {
-  /* The EMACS_INT cast avoids a warning.  There's no problem
+  /* Treat the pointer as an integer.  There's no problem
      as long as pointers have enough bits to hold small integers.  */
-  if ((int) (EMACS_INT) client_data != -1)
+  if ((intptr_t) client_data != -1)
     menu_item_selection = (Lisp_Object *) client_data;
 
   popup_activated_flag = 0;


reply via email to

[Prev in Thread] Current Thread [Next in Thread]