summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2012-02-24 11:11:02 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-02 14:48:00 +0100
commit17ddce4692b31af4374b28cd40b9f25e8ed629cd (patch)
tree773832a8b53104941f5a9744535e41c5f68858f6
parent62a654cc902197cc99326879076ba53b6509dc67 (diff)
Remove Q_BYTE_ORDER and -*-endian arguments from configures
Do not write Q_BYTE_ORDER to qconfig.h in the configures. Instead, we #define Q_BYTE_ORDER in qprocessordetection.h, since many CPUs only support a single endian format. For bi-endian processors, we set Q_BYTE_ORDER depending on how the preprocessor sets __BYTE_ORDER__, __BIG_ENDIAN__, or __LITTLE_ENDIAN__ (instead of using a compile test to do so). For operating systems that only support a single byte order, we can check for Q_OS_* in addition to the preprocessor macros above. This is possible because qprocessordetection.h is included by qglobal.h after Q_OS_* and Q_CC_* detection has been done. Do this for Windows CE, which is always little- endian according to MSDN. Change-Id: I019a95e05252ef69895c4b38fbfa6ebfb6a943cd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
-rwxr-xr-xconfig.tests/unix/endian.test60
-rw-r--r--config.tests/unix/endian/endiantest.cpp56
-rw-r--r--config.tests/unix/endian/endiantest.pro3
-rwxr-xr-xconfigure114
-rw-r--r--configure.bat4
-rw-r--r--src/corelib/global/qprocessordetection.h76
-rw-r--r--tools/configure/configureapp.cpp4
7 files changed, 76 insertions, 241 deletions
diff --git a/config.tests/unix/endian.test b/config.tests/unix/endian.test
deleted file mode 100755
index a662011a27..0000000000
--- a/config.tests/unix/endian.test
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/bin/sh
-
-QMKSPEC=$1
-VERBOSE=$2
-SRCDIR=$3
-OUTDIR=$4
-QMFLAGS=$5
-
-# debuggery
-[ "$VERBOSE" = "yes" ] && echo "Determining machine byte-order... ($*)"
-
-# build and run a test program
-test -d "$OUTDIR/config.tests/unix/endian" || mkdir -p "$OUTDIR/config.tests/unix/endian"
-"$OUTDIR/bin/qmake" -nocache -spec "$QMKSPEC" "QT_BUILD_TREE=$OUTDIR" $QMFLAGS "$SRCDIR/config.tests/unix/endian/endiantest.pro" -o "$OUTDIR/config.tests/unix/endian/Makefile" >/dev/null 2>&1
-cd "$OUTDIR/config.tests/unix/endian"
-
-
-ENDIAN="UNKNOWN"
-[ "$VERBOSE" = "yes" ] && $MAKE || $MAKE >/dev/null 2>&1
-
-if [ -f ./endiantest.exe ]; then
- binary=./endiantest.exe
-else
- binary=./endiantest
-fi
-
-
-if [ -f $binary ]; then
- : # nop
-else
- [ "$VERBOSE" = "yes" ] && echo "Unknown byte order!"
- exit 2
-fi
-
-if strings - $binary | grep LeastSignificantByteFirst >/dev/null 2>&1; then
- [ "$VERBOSE" = "yes" ] && echo " Found 'LeastSignificantByteFirst' in binary"
- ENDIAN="LITTLE"
-elif strings - $binary | grep MostSignificantByteFirst >/dev/null 2>&1; then
- [ "$VERBOSE" = "yes" ] && echo " Found 'MostSignificantByteFirst' in binary"
- ENDIAN="BIG"
-fi
-
-# make clean as this tests is compiled for both the host and the target
-if [ "$VERBOSE" = "yes" ]; then
- $MAKE distclean
-else
- $MAKE distclean >/dev/null 2>&1
-fi
-
-# done
-if [ "$ENDIAN" = "LITTLE" ]; then
- [ "$VERBOSE" = "yes" ] && echo "Using little endian."
- exit 0
-elif [ "$ENDIAN" = "BIG" ]; then
- [ "$VERBOSE" = "yes" ] && echo "Using big endian."
- exit 1
-else
- [ "$VERBOSE" = "yes" ] && echo "Unknown byte order!"
- exit 2
-fi
diff --git a/config.tests/unix/endian/endiantest.cpp b/config.tests/unix/endian/endiantest.cpp
deleted file mode 100644
index e08a11b944..0000000000
--- a/config.tests/unix/endian/endiantest.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/
-**
-** This file is part of the config.tests of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** GNU Lesser General Public License Usage
-** This file may be used under the terms of the GNU Lesser General Public
-** License version 2.1 as published by the Free Software Foundation and
-** appearing in the file LICENSE.LGPL included in the packaging of this
-** file. Please review the following information to ensure the GNU Lesser
-** General Public License version 2.1 requirements will be met:
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU General
-** Public License version 3.0 as published by the Free Software Foundation
-** and appearing in the file LICENSE.GPL included in the packaging of this
-** file. Please review the following information to ensure the GNU General
-** Public License version 3.0 requirements will be met:
-** http://www.gnu.org/copyleft/gpl.html.
-**
-** Other Usage
-** Alternatively, this file may be used in accordance with the terms and
-** conditions contained in a signed written agreement between you and Nokia.
-**
-**
-**
-**
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-// "MostSignificantByteFirst"
-short msb_bigendian[] = { 0x0000, 0x4d6f, 0x7374, 0x5369, 0x676e, 0x6966, 0x6963, 0x616e, 0x7442, 0x7974, 0x6546, 0x6972, 0x7374, 0x0000 };
-
-// "LeastSignificantByteFirst"
-short lsb_littleendian[] = { 0x0000, 0x654c, 0x7361, 0x5374, 0x6769, 0x696e, 0x6966, 0x6163, 0x746e, 0x7942, 0x6574, 0x6946, 0x7372, 0x0074, 0x0000 };
-
-int main(int, char **)
-{
- // make sure the linker doesn't throw away the arrays
- void (*msb_bigendian_string)() = (void (*)())msb_bigendian;
- void (*lsb_littleendian_string)() = (void (*)())lsb_littleendian;
- (void)msb_bigendian_string();
- (void)lsb_littleendian_string();
- return msb_bigendian[1] == lsb_littleendian[1];
-}
diff --git a/config.tests/unix/endian/endiantest.pro b/config.tests/unix/endian/endiantest.pro
deleted file mode 100644
index 7b739eb3f2..0000000000
--- a/config.tests/unix/endian/endiantest.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-SOURCES = endiantest.cpp
-CONFIG -= qt dylib
-mac:CONFIG -= app_bundle
diff --git a/configure b/configure
index cde6dccfa1..674462e928 100755
--- a/configure
+++ b/configure
@@ -763,8 +763,6 @@ CFG_AVX=auto
CFG_REDUCE_RELOCATIONS=auto
CFG_NAS=no
CFG_ACCESSIBILITY=auto
-CFG_ENDIAN=auto
-CFG_HOST_ENDIAN=auto
CFG_IWMMXT=no
CFG_NEON=auto
CFG_CLOCK_GETTIME=auto
@@ -1035,14 +1033,6 @@ while [ "$#" -gt 0 ]; do
VAL=$1
fi
;;
- -host-*-endian)
- VAR=host_endian
- VAL=`echo $1 | sed "s,^-.*-\(.*\)-.*,\1,"`
- ;;
- -*-endian)
- VAR=endian
- VAL=`echo $1 | sed "s,^-\(.*\)-.*,\1,"`
- ;;
-qtnamespace)
VAR="qtnamespace"
shift
@@ -1228,24 +1218,6 @@ while [ "$#" -gt 0 ]; do
UNKNOWN_OPT=yes
fi
;;
- endian)
- if [ "$VAL" = "little" ]; then
- CFG_ENDIAN="Q_LITTLE_ENDIAN"
- elif [ "$VAL" = "big" ]; then
- CFG_ENDIAN="Q_BIG_ENDIAN"
- else
- UNKNOWN_OPT=yes
- fi
- ;;
- host_endian)
- if [ "$VAL" = "little" ]; then
- CFG_HOST_ENDIAN="Q_LITTLE_ENDIAN"
- elif [ "$VAL" = "big" ]; then
- CFG_HOST_ENDIAN="Q_BIG_ENDIAN"
- else
- UNKNOWN_OPT=yes
- fi
- ;;
opengl)
if [ "$VAL" = "auto" ] || [ "$VAL" = "desktop" ] ||
[ "$VAL" = "yes" ] || [ "$VAL" = "no" ] ||
@@ -3727,16 +3699,6 @@ if [ "$PLATFORM_QPA" = "yes" ]; then
-feature-<feature> .. Compile in <feature>. The available features
are described in src/corelib/global/qfeatures.txt
- -little-endian ...... Target platform is little endian (LSB first).
- -big-endian ......... Target platform is big endian (MSB first).
-
- -host-little-endian . Host platform is little endian (LSB first).
- -host-big-endian .... Host platform is big endian (MSB first).
-
- You only need to specify the endianness when
- cross-compiling, otherwise the host
- endianness will be used.
-
-no-freetype ........ Do not compile in Freetype2 support.
-qt-freetype ........ Use the libfreetype bundled with Qt.
* -system-freetype .... Use libfreetype from the operating system.
@@ -5532,48 +5494,6 @@ if [ "$CFG_LIBFREETYPE" = "auto" ]; then
fi
fi
-if [ "$CFG_ENDIAN" = "auto" ]; then
- if [ "$XPLATFORM_MINGW" = "yes" ]; then
- CFG_ENDIAN="Q_LITTLE_ENDIAN"
- else
- "$unixtests/endian.test" "$XQMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath" "QMAKE_LFLAGS+=$SYSROOT_FLAG"
- F="$?"
- if [ "$F" -eq 0 ]; then
- CFG_ENDIAN="Q_LITTLE_ENDIAN"
- elif [ "$F" -eq 1 ]; then
- CFG_ENDIAN="Q_BIG_ENDIAN"
- else
- echo
- echo "The target system byte order could not be detected!"
- echo "Turn on verbose messaging (-v) to see the final report."
- echo "You can use the -little-endian or -big-endian switch to"
- echo "$0 to continue."
- exit 101
- fi
- fi
-fi
-
-if [ "$CFG_HOST_ENDIAN" = "auto" ]; then
- if [ "$BUILD_ON_MAC" = "yes" ]; then
- true #leave as auto
- else
- "$unixtests/endian.test" "$QMAKESPEC" $OPT_VERBOSE "$relpath" "$outpath"
- F="$?"
- if [ "$F" -eq 0 ]; then
- CFG_HOST_ENDIAN="Q_LITTLE_ENDIAN"
- elif [ "$F" -eq 1 ]; then
- CFG_HOST_ENDIAN="Q_BIG_ENDIAN"
- else
- echo
- echo "The host system byte order could not be detected!"
- echo "Turn on verbose messaging (-v) to see the final report."
- echo "You can use the -host-little-endian or -host-big-endian switch to"
- echo "$0 to continue."
- exit 101
- fi
- fi
-fi
-
HAVE_STL=no
if "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" $OPT_VERBOSE "$relpath" "$outpath" config.tests/unix/stl "STL" $L_FLAGS $I_FLAGS $l_FLAGS; then
HAVE_STL=yes
@@ -6447,41 +6367,7 @@ cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
#ifndef QT_EDITION
# define QT_EDITION $QT_EDITION
#endif
-
-/* Machine byte-order */
-#define Q_BIG_ENDIAN 4321
-#define Q_LITTLE_ENDIAN 1234
-EOF
-
-echo "#ifdef QT_BOOTSTRAPPED" >>"$outpath/src/corelib/global/qconfig.h.new"
-if [ "$CFG_HOST_ENDIAN" = "auto" ]; then
- cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
-#if defined(__BIG_ENDIAN__)
-# define Q_BYTE_ORDER Q_BIG_ENDIAN
-#elif defined(__LITTLE_ENDIAN__)
-# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
-#else
-# error "Unable to determine byte order!"
-#endif
EOF
-else
- echo "#define Q_BYTE_ORDER $CFG_HOST_ENDIAN" >>"$outpath/src/corelib/global/qconfig.h.new"
-fi
-echo "#else" >>"$outpath/src/corelib/global/qconfig.h.new"
-if [ "$CFG_ENDIAN" = "auto" ]; then
- cat >>"$outpath/src/corelib/global/qconfig.h.new" <<EOF
-#if defined(__BIG_ENDIAN__)
-# define Q_BYTE_ORDER Q_BIG_ENDIAN
-#elif defined(__LITTLE_ENDIAN__)
-# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
-#else
-# error "Unable to determine byte order!"
-#endif
-EOF
-else
- echo "#define Q_BYTE_ORDER $CFG_ENDIAN" >>"$outpath/src/corelib/global/qconfig.h.new"
-fi
-echo "#endif" >>"$outpath/src/corelib/global/qconfig.h.new"
CFG_ARCH_STR=`echo $CFG_ARCH | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
CFG_HOST_ARCH_STR=`echo $CFG_HOST_ARCH | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
diff --git a/configure.bat b/configure.bat
index f0b6ce5310..b5ffb14731 100644
--- a/configure.bat
+++ b/configure.bat
@@ -67,9 +67,7 @@ if not exist src\corelib\global\qconfig.h (
md src\corelib\global
if errorlevel 1 goto exit
)
- echo #define Q_BIG_ENDIAN 4321 > src\corelib\global\qconfig.h
- echo #define Q_LITTLE_ENDIAN 1234 >> src\corelib\global\qconfig.h
- echo #define Q_BYTE_ORDER Q_LITTLE_ENDIAN >> src\corelib\global\qconfig.h
+ echo /* Generated by configure.bat - DO NOT EDIT! */ > src\corelib\global\qconfig.h
)
if not exist tools\configure (
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index fd02f0e4c5..4213d5830e 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -53,16 +53,39 @@
The first is always defined. Defines for the various revisions/variants are
optional and usually dependent on how the compiler was invoked. Variants
that are a superset of another should have a define for the superset.
+
+ In addition to the procesor family, variants, and revisions, we also set
+ Q_BYTE_ORDER appropriately for the target processor. For bi-endian
+ processors, we try to auto-detect the byte order using the __BIG_ENDIAN__,
+ __LITTLE_ENDIAN__, or __BYTE_ORDER__ preprocessor macros.
*/
+/* Machine byte-order, reuse preprocessor provided macros when available */
+#if defined(__ORDER_BIG_ENDIAN__)
+# define Q_BIG_ENDIAN __ORDER_BIG_ENDIAN__
+#else
+# define Q_BIG_ENDIAN 4321
+#endif
+#if defined(__ORDER_LITTLE_ENDIAN__)
+# define Q_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
+#else
+# define Q_LITTLE_ENDIAN 1234
+#endif
+
/*
Alpha family, no revisions or variants
+
+ Alpha is bi-endian, use endianness auto-detection described above.
*/
// #elif defined(__alpha__) || defined(_M_ALPHA)
// # define Q_PROCESSOR_ALPHA
+// Q_BYTE_ORDER not defined, use endianness auto-detection
/*
- ARM family, known revisions: V5, V6, and V7
+ ARM family, known revisions: V5, V6, and V7
+
+ ARM is bi-endian, detect using __ARMEL__ or __ARMEB__, falling back to
+ auto-detection described above.
*/
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
# define Q_PROCESSOR_ARM
@@ -88,37 +111,59 @@
|| (__TARGET_ARCH_ARM-0 >= 5)
# define Q_PROCESSOR_ARM_V5
# endif
+# if defined(__ARMEL__)
+# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
+# elif defined(__ARMEB__)
+# define Q_BYTE_ORDER Q_BIG_ENDIAN
+# else
+// Q_BYTE_ORDER not defined, use endianness auto-detection
+#endif
/*
AVR32 family, no revisions or variants
+
+ AVR32 is big-endian.
*/
// #elif defined(__avr32__)
// # define Q_PROCESSOR_AVR32
+// # define Q_BYTE_ORDER Q_BIG_ENDIAN
/*
Blackfin family, no revisions or variants
+
+ Blackfin is little-endian.
*/
// #elif defined(__bfin__)
// # define Q_PROCESSOR_BLACKFIN
+// # define Q_BYTE_ORDER Q_LITTLE_ENDIAN
/*
X86 family, known variants: 32- and 64-bit
+
+ X86 is little-endian.
*/
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
# define Q_PROCESSOR_X86
# define Q_PROCESSOR_X86_32
+# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
# define Q_PROCESSOR_X86
# define Q_PROCESSOR_X86_64
+# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
/*
Itanium (IA-64) family, no revisions or variants
+
+ Itanium is bi-endian, use endianness auto-detection described above.
*/
#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
# define Q_PROCESSOR_IA64
+// Q_BYTE_ORDER not defined, use endianness auto-detection
/*
MIPS family, known revisions: I, II, III, IV, 32, 64
+
+ MIPS is bi-endian, use endianness auto-detection described above.
*/
#elif defined(__mips) || defined(__mips__) || defined(_M_MRX000)
# define Q_PROCESSOR_MIPS
@@ -143,6 +188,7 @@
# if defined(_MIPS_ARCH_MIPS64) || defined(__mips64)
# define Q_PROCESSOR_MIPS_64
# endif
+// Q_BYTE_ORDER not defined, use endianness auto-detection
/*
Power family, known variants: 32- and 64-bit
@@ -150,6 +196,8 @@
There are many more known variants/revisions that we do not handle/detect.
See http://en.wikipedia.org/wiki/Power_Architecture
and http://en.wikipedia.org/wiki/File:PowerISA-evolution.svg
+
+ Power is bi-endian, use endianness auto-detection described above.
*/
#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \
|| defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \
@@ -160,34 +208,60 @@
# else
# define Q_PROCESSOR_POWER_32
# endif
+// Q_BYTE_ORDER not defined, use endianness auto-detection
/*
S390 family, known variant: S390X (64-bit)
+
+ S390 is big-endian.
*/
// #elif defined(__s390__)
// # define Q_PROCESSOR_S390
// # if defined(__s390x__)
// # define Q_PROCESSOR_S390_X
// # endif
+// # define Q_BYTE_ORDER Q_BIG_ENDIAN
/*
SuperH family, optional revision: SH-4A
+
+ SuperH is bi-endian, use endianness auto-detection descrived above.
*/
// #elif defined(__sh__)
// # define Q_PROCESSOR_SH
// # if defined(__sh4a__)
// # define Q_PROCESSOR_SH_4A
// # endif
+// Q_BYTE_ORDER not defined, use endianness auto-detection
/*
SPARC family, optional revision: V9
+
+ SPARC is big-endian only prior to V9, while V9 is bi-endian with big-endian
+ as the default byte order. Assume all SPARC systems are big-endian.
*/
// #elif defined(__sparc__)
// # define Q_PROCESSOR_SPARC
// # if defined(__sparc_v9__)
// # define Q_PROCESSOR_SPARC_V9
// # endif
+// # define Q_BYTE_ORDER Q_BIG_ENDIAN
+
+#endif
+// Some processors support either endian format, try to detect which we are using.
+#if !defined(Q_BYTE_ORDER)
+# if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == Q_BIG_ENDIAN || __BYTE_ORDER__ == Q_LITTLE_ENDIAN)
+// Reuse __BYTE_ORDER__ as-is, since our Q_*_ENDIAN #defines match the preprocessor defaults
+# define Q_BYTE_ORDER __BYTE_ORDER__
+# elif defined(__BIG_ENDIAN__)
+# define Q_BYTE_ORDER Q_BIG_ENDIAN
+# elif defined(__LITTLE_ENDIAN__) \
+ || defined(Q_OS_WINCE) // Windows CE is always little-endian according to MSDN.
+# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
+# else
+# error "Unable to determine byte order!"
+# endif
#endif
#endif // QPROCESSORDETECTION_H
diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp
index 196fdc9540..b630d289a5 100644
--- a/tools/configure/configureapp.cpp
+++ b/tools/configure/configureapp.cpp
@@ -2704,10 +2704,6 @@ void Configure::generateConfigfiles()
tmpStream << "#define QT_BUILD_INTERNAL" << endl;
tmpStream << endl;
}
- tmpStream << "/* Machine byte-order */" << endl;
- tmpStream << "#define Q_BIG_ENDIAN 4321" << endl;
- tmpStream << "#define Q_LITTLE_ENDIAN 1234" << endl;
- tmpStream << "#define Q_BYTE_ORDER Q_LITTLE_ENDIAN" << endl;
if (dictionary[ "QPA" ] == "yes")
tmpStream << endl << "#define Q_WS_QPA" << endl;