Do not assume EMACS_INT is the same width as a pointer.

This prepares for a future patch that will prefer 64-bit EMACS_INT if
available.  That patch can be tried now, by compiling with -DWIDE_EMACS_INT,
but it is temporarily not the default so that it can be further tested.

Also, install some other fixes for problems discovered by the static
checking of GCC 4.6.0.

Fixes: debbugs:8545 debbugs:8601 debbugs:8600 debbugs:8602
This commit is contained in:
Paul Eggert 2011-05-06 00:13:19 -07:00
commit b08a63ccec
36 changed files with 754 additions and 370 deletions

View file

@ -1,3 +1,15 @@
2011-05-06 Paul Eggert <eggert@cs.ucla.edu>
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 <rgm@gnu.org>
* Makefile.in (bootstrap-clean): Save config.log. (Bug#765)

View file

@ -333,9 +333,10 @@ DOS_gnulib_comp.m4 = gl-comp.m4
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) && \

View file

@ -3518,7 +3518,8 @@ AH_BOTTOM([
#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 @@ AH_BOTTOM([
#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 @@ AH_BOTTOM([
#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

View file

@ -1,3 +1,7 @@
2011-05-06 Paul Eggert <eggert@cs.ucla.edu>
* numbers.texi (Integer Basics): Large integers are treated as floats.
2011-04-30 Lars Magne Ingebrigtsen <larsi@gnus.org>
* processes.texi (Synchronous Processes): Document the (:file

View file

@ -55,14 +55,15 @@ chapter assume an integer has 30 bits.
@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 @@ point values:
@samp{1.0e+INF}
@item negative infinity
@samp{-1.0e+INF}
@item Not-a-number
@item Not-a-number
@samp{0.0e+NaN} or @samp{-0.0e+NaN}.
@end table

View file

@ -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 @@ EXTRA_libgnu_a_SOURCES += md5.c
## begin gnulib module dosname
if gl_GNULIB_ENABLED_dosname
endif
EXTRA_DIST += dosname.h
## end gnulib module dosname
@ -157,8 +159,10 @@ EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c
## 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 @@ EXTRA_libgnu_a_SOURCES += readlink.c
## 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 $@-t $@ && \
{ 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; \
} > $@-t && \
mv $@-t $@
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 @@ EXTRA_libgnu_a_SOURCES += strftime.c
## 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 @@ EXTRA_DIST += unistd.in.h
## 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

36
lib/stdarg.in.h Normal file
View file

@ -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
@PRAGMA_SYSTEM_HEADER@
#endif
@PRAGMA_COLUMNS@
/* The include_next requires a split double-inclusion guard. */
#@INCLUDE_NEXT@ @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 */

View file

@ -81,8 +81,9 @@ struct random_data
# 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>

View file

@ -17,42 +17,37 @@
/* Written by Paul Eggert, Bruno Haible, and Jim Meyering. */
#ifndef VERIFY_H
# define VERIFY_H 1
#ifndef _GL_VERIFY_H
# define _GL_VERIFY_H
/* Define HAVE__STATIC_ASSERT to 1 if _Static_assert works as per the
/* 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.
Return 1. */
/* 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 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__; \
}))
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 verify_true(R) \
(!!sizeof \
(struct { unsigned int verify_error_if_negative_size__: (R) ? 1 : -1; }))
# 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. */
# 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

View file

@ -51,6 +51,12 @@ AC_DEFUN([gl_EARLY],
# 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 @@ AC_DEFUN([gl_INIT],
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 @@ changequote([, ])dnl
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 @@ AC_DEFUN([gl_FILE_LIST], [
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 @@ AC_DEFUN([gl_FILE_LIST], [
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

78
m4/stdarg.m4 Normal file
View file

@ -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])
])

View file

@ -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 @@ AC_DEFUN([gl_STDIO_H],
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

View file

@ -1,3 +1,11 @@
2011-05-06 Paul Eggert <eggert@cs.ucla.edu>
* 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 <bkey76@gmail.com>
* 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/>.

View file

@ -478,7 +478,22 @@ extern char *getenv ();
/* 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 @@ void w32_abort (void) NO_RETURN;
/* Make a leaner executable. */
#define WIN32_LEAN_AND_MEAN 1

View file

@ -1,3 +1,118 @@
2011-05-06 Paul Eggert <eggert@cs.ucla.edu>
* 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 <lekktu@gmail.com>
* gnutls.c (DEF_GNUTLS_FN):

View file

@ -438,7 +438,7 @@ static POINTER_TYPE *pure_alloc (size_t, int);
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 @@ struct ablocks
#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 @@ struct ablocks
#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 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
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 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
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 @@ lisp_align_malloc (size_t nbytes, enum mem_type type)
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 @@ lisp_align_free (POINTER_TYPE *block)
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 @@ lisp_align_free (POINTER_TYPE *block)
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 @@ check_string_free_list (void)
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 @@ make_uninit_multibyte_string (EMACS_INT nchars, EMACS_INT nbytes)
&= ~(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 @@ make_float (double float_value)
/ (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 @@ mark_maybe_pointer (void *p)
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 @@ We divide the value by 1024 to make sure it fits in a Lisp integer. */)
{
Lisp_Object end;
XSETINT (end, (EMACS_INT) (char *) sbrk (0) / 1024);
XSETINT (end, (intptr_t) (char *) sbrk (0) / 1024);
return end;
}

View file

@ -193,7 +193,6 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
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 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
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 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
BLOCK_INPUT;
pid = vfork ();
/* 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;
new_argv = new_argv_volatile;
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)
{

View file

@ -869,7 +869,7 @@ usage: (define-charset-internal ...) */)
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 @@ usage: (define-charset-internal ...) */)
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;
nchars *= charset.code_space[i * 4 + 2];
charset.code_space[i * 4 + 3] = nchars;
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;
}
val = args[charset_arg_dimension];

View file

@ -155,10 +155,11 @@ struct charset
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

View file

@ -5368,8 +5368,8 @@ detect_coding_charset (struct coding_system *coding,
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)

View file

@ -892,7 +892,7 @@ xd_remove_watch (DBusWatch *watch, void *data)
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 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0,
{
DBusConnection *connection;
CHECK_SYMBOL (bus);
/* Open a connection to the bus. */
connection = xd_initialize (bus, TRUE);
@ -929,7 +931,7 @@ DEFUN ("dbus-init-bus", Fdbus_init_bus, Sdbus_init_bus, 1, 1, 0,
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 @@ xd_read_queued_messages (int fd, void *data, int for_read)
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);
}

View file

@ -4576,8 +4576,8 @@ scrolling_window (struct window *w, int header_line_p)
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;
}

View file

@ -349,10 +349,10 @@ string is passed through `substitute-command-keys'. */)
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 @@ store_function_docstring (Lisp_Object fun, EMACS_INT offset)
/* 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))

View file

@ -70,9 +70,9 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
%<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 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
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 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
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 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
%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 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
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 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
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 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
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 @@ doprnt (char *buffer, register size_t bufsize, const char *format,
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)
{

View file

@ -1994,7 +1994,7 @@ verror (const char *m, va_list ap)
{
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 @@ verror (const char *m, va_list ap)
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 @@ this does nothing and returns nil. */)
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)));

View file

@ -75,7 +75,7 @@ Other values of LIMIT are ignored. */)
{
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 @@ Other values of LIMIT are ignored. */)
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));

View file

@ -3354,7 +3354,7 @@ xg_get_scroll_id_for_window (Display *dpy, Window wid)
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 @@ xg_create_scroll_bar (FRAME_PTR f,
{
GtkWidget *wscroll;
GtkWidget *webox;
int scroll_id;
intptr_t scroll_id;
#ifdef HAVE_GTK3
GtkAdjustment *vadj;
#else
@ -3397,11 +3397,10 @@ xg_create_scroll_bar (FRAME_PTR f,
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 @@ xg_tool_bar_button_cb (GtkWidget *widget,
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 @@ xg_tool_bar_button_cb (GtkWidget *widget,
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 @@ xg_tool_bar_help_callback (GtkWidget *w,
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 @@ xg_make_tool_item (FRAME_PTR f,
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 @@ xg_make_tool_item (FRAME_PTR f,
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;

View file

@ -8602,11 +8602,9 @@ Libraries to load are specified in alist LIBRARIES (usually, the value
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

View file

@ -22,6 +22,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#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 @@ extern void check_cons_list (void);
#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"
# 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 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
# define EMACS_UINT unsigned EMACS_INT
#endif
/* Extra internal type checking? */
@ -398,7 +402,7 @@ enum pvec_type
#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 @@ enum pvec_type
# 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 @@ enum pvec_type
#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 @@ enum pvec_type
/* 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 @@ enum pvec_type
#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 @@ typedef struct {
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 flush_pending_output (int);
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);

View file

@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
#include <inttypes.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
@ -2250,6 +2249,26 @@ read_escape (Lisp_Object readcharfun, int stringp)
}
}
/* 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 @@ read_escape (Lisp_Object readcharfun, int stringp)
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)
if (c == '0')
{
int digit;
*p++ = c;
valid = 1;
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;
/* 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;
}
valid = 0;
if (digit < 0 || digit >= radix)
invalid_p = 1;
number = radix * number + digit;
++ndigits;
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 @@ substitute_in_interval (INTERVAL interval, Lisp_Object arg)
}
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 @@ static Lisp_Object initial_obarray;
/* 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 @@ OBARRAY defaults to the value of the variable `obarray'. */)
(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 @@ OBARRAY defaults to the value of the variable `obarray'. */)
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 @@ oblookup (Lisp_Object obarray, register const char *ptr, EMACS_INT size, EMACS_I
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

View file

@ -800,9 +800,9 @@ digest_single_submenu (int start, int end, int top_level_items)
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 @@ find_and_call_menu_selection (FRAME_PTR f, int menu_bar_items_used, Lisp_Object
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;

View file

@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <sys/file.h>
#include <sys/stat.h>
#include <setjmp.h>
#include <inttypes.h>
#include <unistd.h>
#include <fcntl.h>
@ -1386,7 +1385,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
{
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);

View file

@ -1786,23 +1786,14 @@ seed_random (long int arg)
* 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

View file

@ -26,7 +26,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <sys/file.h>
#include <unistd.h>
#include <signal.h>
#include <stdarg.h>
#include <setjmp.h>
#include "lisp.h"
@ -3619,7 +3618,6 @@ vfatal (const char *str, va_list ap)
vfprintf (stderr, str, ap);
if (!(strlen (str) > 0 && str[strlen (str) - 1] == '\n'))
fprintf (stderr, "\n");
va_end (ap);
fflush (stderr);
exit (1);
}

View file

@ -8737,7 +8737,7 @@ display_echo_area (struct window *w)
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 @@ display_echo_area (struct window *w)
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_echo_area_exactly (void)
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 @@ resize_echo_area_exactly (void)
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 @@ current_message (void)
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 @@ current_message (void)
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 @@ set_message (const char *s, Lisp_Object string,
|| (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 @@ set_message (const char *s, Lisp_Object string,
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;

View file

@ -1012,10 +1012,10 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
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 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
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 @@ xmenu_show (FRAME_PTR f, int x, int y, int for_click, int keymaps,
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;