+++ /dev/null
-#!/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
+++ /dev/null
-/****************************************************************************
-**
-** 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];
-}
+++ /dev/null
-SOURCES = endiantest.cpp
-CONFIG -= qt dylib
-mac:CONFIG -= app_bundle
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
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
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" ] ||
-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.
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
#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'`
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 (
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
|| (__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
# 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
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) \
# 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
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;