[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
removing stdint's dependency on wchar
From: |
Paul Eggert |
Subject: |
removing stdint's dependency on wchar |
Date: |
Thu, 17 Feb 2011 23:10:29 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 |
I looked into importing the md5 module into Emacs, and
found that it dragged in a whole bunch of stuff related
to wchar_t that were irrelevant to md5. The problem is
that md5 includes stdint.h for uint32_t, and the stdint
module depends on wchar for WCHAR_MIN etc; but md5 does
not need WCHAR_MIN etc.
Here's a proposed patch to make stdint configure faster,
primarily by removing its dependency on wchar.
Independently, I'll look into removing the dependency
of md5 on stdint.
stdint: don't depend on wchar
* NEWS: Document this.
* lib/stdint.in.h: Put the wchar-related stuff inside
"#if @GNULIB_WCHAR@".
* m4/stdint.m4 (gl_STDINT_H): Require gl_STDINT_H_DEFAULTS.
Invoke gl_PREREQ_STDINT_H if building a substitute stdint.h.
(gl_PREREQ_STDINT_H): New macro.
Move gl_CHECK_NEXT_HEADERS([stdint.h]) and related code here,
from gl_STDINT_H, because it needs to be executed only if we
are building the substitute stdint.h. Similarly for
sys/inttypes.h and other stuff needed only by the substitute.
(gl_STDINT_H_DEFAULTS): New macro, with default initializations
that should work regardless of whether the wchar module is also
used.
* m4/wchar_h.m4 (gl_WCHAR_H): Set GNULIB_WCHAR=1, as a witness,
for stdint's benefit.
* modules/stdint (Depends-on): Remove wchar.
(Makefile.in): Propagate GNULIB_WCHAR into stdint.h.
* modules/stdint-tests (Depends-on): Add wchar.
diff --git a/NEWS b/NEWS
index b203b2c..2ad3b99 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ User visible incompatible changes
Date Modules Changes
+2011-02-18 stdint This module no longer guarantees that WCHAR_MAX,
+ WCHAR_MIN, WINT_MAX, and WINT_MIN are #defined
+ unless the wchar module is also used.
+
2011-02-14 getloadavg This module no longer #defines C_GETLOADAVG or
HAVE_GETLOADAVG, as the application no longer needs
to worry about how getloadavg is defined. It no
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index c48be52..4c806eb 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -491,6 +491,7 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof
(uintmax_t)
# define SIZE_MAX _STDINT_MAX (0, @BITSIZEOF_SIZE_T@, address@hidden@)
#endif
+#if @GNULIB_WCHAR@
/* wchar_t limits */
/* Get WCHAR_MIN, WCHAR_MAX.
This include is not on the top, above, because on OSF/1 4.0 we have a
@@ -516,6 +517,7 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof
(uintmax_t)
_STDINT_MIN (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, address@hidden@)
#define WINT_MAX \
_STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, address@hidden@)
+#endif /* @GNULIB_WCHAR@ */
#endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */
diff --git a/m4/stdint.m4 b/m4/stdint.m4
index 26654c6..0145ceb 100644
--- a/m4/stdint.m4
+++ b/m4/stdint.m4
@@ -1,4 +1,4 @@
-# stdint.m4 serial 37
+# stdint.m4 serial 38
dnl Copyright (C) 2001-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,
@@ -10,6 +10,7 @@ dnl Test whether <stdint.h> is supported or must be
substituted.
AC_DEFUN([gl_STDINT_H],
[
AC_PREREQ([2.59])dnl
+ AC_REQUIRE([gl_STDINT_H_DEFAULTS])
dnl Check for long long int and unsigned long long int.
AC_REQUIRE([AC_TYPE_LONG_LONG_INT])
@@ -45,17 +46,8 @@ AC_DEFUN([gl_STDINT_H],
fi
AC_SUBST([HAVE_SYS_TYPES_H])
- gl_CHECK_NEXT_HEADERS([stdint.h])
- if test $ac_cv_header_stdint_h = yes; then
- HAVE_STDINT_H=1
- else
- HAVE_STDINT_H=0
- fi
- AC_SUBST([HAVE_STDINT_H])
-
dnl Now see whether we need a substitute <stdint.h>.
- if test $ac_cv_header_stdint_h = yes; then
- AC_CACHE_CHECK([whether stdint.h conforms to C99],
+ AC_CACHE_CHECK([whether stdint.h conforms to C99],
[gl_cv_header_working_stdint_h],
[gl_cv_header_working_stdint_h=no
AC_COMPILE_IFELSE([
@@ -272,10 +264,25 @@ static const char *macro_values[] =
])
])
])
- fi
if test "$gl_cv_header_working_stdint_h" = yes; then
STDINT_H=
else
+ STDINT_H=stdint.h
+ gl_PREREQ_STDINT_H
+ fi
+ AC_SUBST([STDINT_H])
+])
+
+AC_DEFUN([gl_PREREQ_STDINT_H],
+[
+ gl_CHECK_NEXT_HEADERS([stdint.h])
+ if test $ac_cv_header_stdint_h = yes; then
+ HAVE_STDINT_H=1
+ else
+ HAVE_STDINT_H=0
+ fi
+ AC_SUBST([HAVE_STDINT_H])
+
dnl Check for <sys/inttypes.h>, and for
dnl <sys/bitypes.h> (used in Linux libc4 >= 4.6.7 and libc5).
AC_CHECK_HEADERS([sys/inttypes.h sys/bitypes.h])
@@ -297,9 +304,6 @@ static const char *macro_values[] =
AC_CHECK_HEADERS_ONCE([wchar.h])
gl_STDINT_TYPE_PROPERTIES
- STDINT_H=stdint.h
- fi
- AC_SUBST([STDINT_H])
])
dnl gl_STDINT_BITSIZEOF(TYPES, INCLUDES)
@@ -468,6 +472,14 @@ m4_ifdef([AC_COMPUTE_INT], [], [
AC_DEFUN([AC_COMPUTE_INT], [_AC_COMPUTE_INT([$2],[$1],[$3],[$4])])
])
+AC_DEFUN([gl_STDINT_H_DEFAULTS],
+[
+ dnl Set these to zero only if not set already, so that the default
+ dnl is OK regardless of whether the wchar module is present.
+ : ${GNULIB_WCHAR=0}; AC_SUBST([GNULIB_WCHAR])
+ : ${HAVE_WCHAR_H=0}; AC_SUBST([HAVE_WCHAR_H])
+])
+
# Hey Emacs!
# Local Variables:
# indent-tabs-mode: nil
diff --git a/m4/wchar_h.m4 b/m4/wchar_h.m4
index 6255ff3..ba5ba4e 100644
--- a/m4/wchar_h.m4
+++ b/m4/wchar_h.m4
@@ -7,10 +7,11 @@ dnl with or without modifications, as long as this notice is
preserved.
dnl Written by Eric Blake.
-# wchar_h.m4 serial 38
+# wchar_h.m4 serial 39
AC_DEFUN([gl_WCHAR_H],
[
+ GNULIB_WCHAR=1
AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
dnl Prepare for creating substitute <wchar.h>.
diff --git a/modules/stdint b/modules/stdint
index 9e5f7ad..1950397 100644
--- a/modules/stdint
+++ b/modules/stdint
@@ -14,7 +14,6 @@ m4/longlong.m4
Depends-on:
include_next
multiarch
-wchar
configure.ac:
gl_STDINT_H
@@ -32,6 +31,7 @@ stdint.h: stdint.in.h
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_STDINT_H''@|$(NEXT_STDINT_H)|g' \
+ -e 's/@''GNULIB_WCHAR''@/$(GNULIB_WCHAR)/g' \
-e 's/@''HAVE_SYS_TYPES_H''@/$(HAVE_SYS_TYPES_H)/g' \
-e 's/@''HAVE_INTTYPES_H''@/$(HAVE_INTTYPES_H)/g' \
-e 's/@''HAVE_SYS_INTTYPES_H''@/$(HAVE_SYS_INTTYPES_H)/g' \
diff --git a/modules/stdint-tests b/modules/stdint-tests
index ad320b2..ed177f8 100644
--- a/modules/stdint-tests
+++ b/modules/stdint-tests
@@ -4,6 +4,7 @@ m4/wchar_t.m4
m4/wint_t.m4
Depends-on:
+wchar
verify
intprops