Re: AC_C_BIGENDIAN answers "universal" on powerpc-aix

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

 



On Thu, Aug 14, 2008 at 09:39:32AM -0500, Peter O'Gorman wrote:
> On Wed, Aug 13, 2008 at 08:19:03PM -0600, Eric Blake wrote:
> > According to Peter O'Gorman on 8/13/2008 12:13 PM:
> > | Hi,
> > |
> > | "checking whether byte ordering is bigendian... universal" is not the
> > | correct answer on powerpc-ibm-aix. The question is not really correct
> > | either (yes/no question, answer is neither yes nor no), but that is
> > | beside the point.
> > |
> > | As far as I know, it is only possible to built differently endian output
> > | on Mac OS X with Apple's gcc. Would a patch to limit the check for
> > | universal to when __APPLE_CC__ is defined be accepted?
> >
> > The brokenness of AC_C_BIGENDIAN has been known for some time now, still
> > without a patch.  At this point, any approach is better than none, so it
> > might be worth posting your ideas.
> >
> 
> Ok. This should still "work" for universal builds.
> 
> [Only lightly tested though.]
> +# else
> +  /* This is not really correct, but there is little that we can do about
> +   * it, #undef WORDS_BIGENDIAN would have some value substituted by
> +   * config.status, not necessarily the correct one. */
> +#  define WORDS_BIGENDIAN 0
> +# endif

I'm a dummy.

Peter
>From 8e97c12604717a30c8c79e2f2a3c3c004dc42d35 Mon Sep 17 00:00:00 2001
From: Peter O'Gorman <peter@xxxxxxxxx>
Date: Thu, 14 Aug 2008 10:09:01 -0500
Subject: [PATCH] Limit AC_C_BIGENDIAN univeral checks to Mac OS X.

* lib/autoconf/c.m4 (AC_C_BIGENDIAN): Limit the check to __APPLE_C__ with possible -arch flags.
---
 ChangeLog         |    6 ++++++
 lib/autoconf/c.m4 |   27 +++++++++++++++++++--------
 2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aa82465..867552d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-14  Peter O'Gorman  <pogma@xxxxxxxxxxxxxxxxxx>
+
+	Limit AC_C_BIGENDIAN univeral checks to Mac OS X.
+	* lib/autoconf/c.m4 (AC_C_BIGENDIAN): Limit the check to
+	__APPLE_C__ with possible -arch flags.
+
 2008-08-12  Eric Blake  <ebb9@xxxxxxx>
 
 	Optimize m4_bmatch.
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index ffaa06e..22876a5 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -1399,11 +1399,15 @@ fi
 AC_DEFUN([AC_C_BIGENDIAN],
 [AH_VERBATIM([WORDS_BIGENDIAN],
 [/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
-   significant byte first (like Motorola and SPARC, unlike Intel and VAX). */
-#if defined __BIG_ENDIAN__
-# define WORDS_BIGENDIAN 1
-#elif ! defined __LITTLE_ENDIAN__
-# undef WORDS_BIGENDIAN
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+#  undef WORDS_BIGENDIAN
+# endif
 #endif])dnl
  AC_CACHE_CHECK([whether byte ordering is bigendian], [ac_cv_c_bigendian],
    [ac_cv_c_bigendian=unknown
@@ -1411,12 +1415,18 @@ AC_DEFUN([AC_C_BIGENDIAN],
       [# See if __BIG_ENDIAN__ or __LITTLE_ENDIAN__ is defined.
        AC_COMPILE_IFELSE(
 	 [AC_LANG_SOURCE(
-	    [[#if ! (defined __BIG_ENDIAN__ || defined __LITTLE_ENDIAN__)
-	       neither is defined;
+	    [[#ifndef __APPLE_CC__
+	       not a universal capable compiler 
 	     #endif
 	     typedef int dummy;
 	    ]])],
-	 [ac_cv_c_bigendian=universal])],
+	 [
+	# Check for potential -arch flags it is not universal unless
+	# there are some -arch flags, note that *ppc* also matches
+	# ppc64. This check is also rather less than ideal.
+	case "${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}" in  #(
+	  *"ppc"*|*"i386"*|*"x86_64"*) ac_cv_c_bigendian=universal;;
+	esac])],
       [AC_DIAGNOSE([obsolete], [AC_C_BIGENDIAN suggests AC_CONFIG_HEADERS])])
     if test $ac_cv_c_bigendian = unknown; then
       # See if sys/param.h defines the BYTE_ORDER macro.
@@ -1521,6 +1531,7 @@ AC_DEFUN([AC_C_BIGENDIAN],
    no)
      $2 ;; #(
    universal)
+     AC_DEFINE([AC_APPLE_UNIVERSAL_BUILD],1,[Define if building universal])
      $4 ;; #(
    *)
      m4_default([$3],
-- 
1.5.4.1

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux