This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Patch: Change from configure time to compile time probe for intptr_t, definition.
- From: Joel Sherrill <joel dot sherrill at oarcorp dot com>
- To: "newlib at sourceware dot org" <newlib at sourceware dot org>, Yaakov Selkowitz <yselkowi at redhat dot com>
- Date: Fri, 20 Mar 2015 15:12:27 -0500
- Subject: Patch: Change from configure time to compile time probe for intptr_t, definition.
- Authentication-results: sourceware.org; auth=none
Hi
It doesn't look like the git send-email made it to the list. Attached is
the patch I have tested on some targets. I was trying to build a
complete set of tools with the gcc and binutils/gdb head and that
hasn't gone so well. This definitely gives the right answer on m32c
though.
It removes the configure time probe and replaces it with logic
in <sys/config.h>.
Yaakov.. how does this work for you?
2015-03-18 Joel Sherrill <joel.sherrill@oarcorp.com
* configure.in: Delete logic to determine _UINTPTR_EQ_ULONGLONG
and _UINTPTR_EQ_ULONG at configuration time.
*libc/include/sys/config.h: Add logic to determine
_UINTPTR_EQ_ULONGLONG and _UINTPTR_EQ_ULONG at compilation time.
* libc/include/inttypes.h: Add include of <sys/config.h>.
* configure: Regenerated.
--
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherrill@OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
>From 3323703d02533cacc3c6367f1c45daba78ff7137 Mon Sep 17 00:00:00 2001
From: Joel Sherrill <joel.sherrill@oarcorp.com>
Date: Wed, 18 Mar 2015 15:44:41 -0500
Subject: [PATCH] Change from configure time to compile time probe for intptr_t
definition.
---
newlib/ChangeLog | 9 ++++++
newlib/configure | 69 ----------------------------------------
newlib/configure.in | 41 ------------------------
newlib/libc/include/inttypes.h | 1 +
newlib/libc/include/sys/config.h | 23 ++++++++++++++
5 files changed, 33 insertions(+), 110 deletions(-)
diff --git a/newlib/ChangeLog b/newlib/ChangeLog
index 4a694a4..6686d68 100644
--- a/newlib/ChangeLog
+++ b/newlib/ChangeLog
@@ -1,3 +1,12 @@
+2015-03-18 Joel Sherrill <joel.sherrill@oarcorp.com
+
+ * configure.in: Delete logic to determine _UINTPTR_EQ_ULONGLONG
+ and _UINTPTR_EQ_ULONG at configuration time.
+ *libc/include/sys/config.h: Add logic to determine
+ _UINTPTR_EQ_ULONGLONG and _UINTPTR_EQ_ULONG at compilation time.
+ * libc/include/inttypes.h: Add include of <sys/config.h>.
+ * configure: Regenerated.
+
2015-03-13 Jon TURNEY <jon.turney@dronecode.org.uk>
* libc/libc.texinfo: Fix directory entry.
diff --git a/newlib/configure b/newlib/configure
index 8000b87..19cf1d9 100755
--- a/newlib/configure
+++ b/newlib/configure
@@ -12646,75 +12646,6 @@ _ACEOF
fi
-#### Determine if uintptr_t is unsigned long long
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether uintptr_t equals unsigned long long" >&5
-$as_echo_n "checking whether uintptr_t equals unsigned long long... " >&6; }
-if ${newlib_cv_uintptr_eq_ulonglong+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat > conftest.c <<EOF
-#include <inttypes.h>
-extern int foo(uintptr_t);
-extern int foo(unsigned long long);
-EOF
-if { ac_try='${CC} $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c
- 1>&5'
- { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; }
-then
- newlib_cv_uintptr_eq_ulonglong=yes;
-else
- newlib_cv_uintptr_eq_ulonglong=no;
-fi
-rm -f conftest*
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $newlib_cv_uintptr_eq_ulonglong" >&5
-$as_echo "$newlib_cv_uintptr_eq_ulonglong" >&6; }
-if test $newlib_cv_uintptr_eq_ulonglong = yes; then
- cat >>confdefs.h <<_ACEOF
-#define _UINTPTR_EQ_ULONGLONG 1
-_ACEOF
-
-else
-#### Determine if uintptr_t is unsigned long
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether uintptr_t equals unsigned long" >&5
-$as_echo_n "checking whether uintptr_t equals unsigned long... " >&6; }
-if ${newlib_cv_uintptr_eq_ulong+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- cat > conftest.c <<EOF
-#include <inttypes.h>
-extern int foo(uintptr_t);
-extern int foo(unsigned long);
-EOF
-if { ac_try='${CC} $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c
- 1>&5'
- { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
- (eval $ac_try) 2>&5
- ac_status=$?
- $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
- test $ac_status = 0; }; }
-then
- newlib_cv_uintptr_eq_ulong=yes;
-else
- newlib_cv_uintptr_eq_ulong=no;
-fi
-rm -f conftest*
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $newlib_cv_uintptr_eq_ulong" >&5
-$as_echo "$newlib_cv_uintptr_eq_ulong" >&6; }
-if test $newlib_cv_uintptr_eq_ulong = yes; then
- cat >>confdefs.h <<_ACEOF
-#define _UINTPTR_EQ_ULONG 1
-_ACEOF
-
-fi
-fi
-
-
ac_config_files="$ac_config_files Makefile"
diff --git a/newlib/configure.in b/newlib/configure.in
index fbe5b7b..9465787 100644
--- a/newlib/configure.in
+++ b/newlib/configure.in
@@ -617,47 +617,6 @@ if test $newlib_cv_ldbl_eq_dbl = yes; then
AC_DEFINE_UNQUOTED(_LDBL_EQ_DBL)
fi
-#### Determine if uintptr_t is unsigned long long
-AC_CACHE_CHECK(whether uintptr_t equals unsigned long long,
- newlib_cv_uintptr_eq_ulonglong, [dnl
-cat > conftest.c <<EOF
-#include <inttypes.h>
-extern int foo(uintptr_t);
-extern int foo(unsigned long long);
-EOF
-if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c
- 1>&AS_MESSAGE_LOG_FD])
-then
- newlib_cv_uintptr_eq_ulonglong=yes;
-else
- newlib_cv_uintptr_eq_ulonglong=no;
-fi
-rm -f conftest*])
-if test $newlib_cv_uintptr_eq_ulonglong = yes; then
- AC_DEFINE_UNQUOTED(_UINTPTR_EQ_ULONGLONG)
-else
-#### Determine if uintptr_t is unsigned long
-AC_CACHE_CHECK(whether uintptr_t equals unsigned long,
- newlib_cv_uintptr_eq_ulong, [dnl
-cat > conftest.c <<EOF
-#include <inttypes.h>
-extern int foo(uintptr_t);
-extern int foo(unsigned long);
-EOF
-if AC_TRY_COMMAND([${CC} $CFLAGS $CPPFLAGS -c -o conftest.o conftest.c
- 1>&AS_MESSAGE_LOG_FD])
-then
- newlib_cv_uintptr_eq_ulong=yes;
-else
- newlib_cv_uintptr_eq_ulong=no;
-fi
-rm -f conftest*])
-if test $newlib_cv_uintptr_eq_ulong = yes; then
- AC_DEFINE_UNQUOTED(_UINTPTR_EQ_ULONG)
-fi
-fi
-
-
AC_SUBST(CFLAGS)
AC_CONFIG_FILES([Makefile],
diff --git a/newlib/libc/include/inttypes.h b/newlib/libc/include/inttypes.h
index 39bf135..52b2d84 100644
--- a/newlib/libc/include/inttypes.h
+++ b/newlib/libc/include/inttypes.h
@@ -14,6 +14,7 @@
#define _INTTYPES_H
#include <newlib.h>
+#include <sys/config.h>
#include <sys/_intsup.h>
#include <stdint.h>
#define __need_wchar_t
diff --git a/newlib/libc/include/sys/config.h b/newlib/libc/include/sys/config.h
index 5297bef..a5a57c9 100644
--- a/newlib/libc/include/sys/config.h
+++ b/newlib/libc/include/sys/config.h
@@ -287,4 +287,27 @@
#define _MB_EXTENDED_CHARSETS_WINDOWS 1
#endif
+/* Determine how uintptr_t is defined by gcc for this target. This
+ is used to determine the correct printf() constant in inttypes.h */
+#pragma push_macro("signed")
+#pragma push_macro("int")
+#pragma push_macro("long")
+#undef signed
+#undef int
+#undef long
+#define signed +0
+#define int +0
+#define long +1
+#if __INTPTR_TYPE__ == 2
+#define _UINTPTR_EQ_ULONGLONG
+#elif __INTPTR_TYPE__ == 1
+#define _UINTPTR_EQ_ULONG
+#elif __INTPTR_TYPE__ == 0
+/* Nothing to define because intptr_t is safe to print as an int. */
+#else
+#error "Unable to determine type definition of uintptr_t"
+#endif
+#pragma pop_macro("signed")
+#pragma pop_macro("int")
+#pragma pop_macro("long")
#endif /* __SYS_CONFIG_H__ */
--
1.9.3