Fix compilation with MSVC 2008 (and prospective Windows CE build fix)

* Only 2010 and newer ship stdint.h, so for 2008 we have to provide a little
stdint.h compat header, for some of the third-party code we import. Our own
Qt code this patch changes to use quint* types instead.

* Include math.h and float.h for some math functions.

* disable the JIT on Windows CE for now.

* Change use of intptr_t to qintptr in Qt code. intptr_t is in inttypes.h,
  except that with VS 2008 it is indirectly available through stdio.h. Let's
  avoid the mess and just use the qt type, that's always available.

Change-Id: I19055edd89e0a6b147d9edbb3b711798ed3c05a5
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
This commit is contained in:
Simon Hausmann 2013-08-20 13:38:15 +02:00 committed by The Qt Project
parent ff959399c9
commit e04cadca4a
17 changed files with 90 additions and 33 deletions

View File

@ -1,4 +1,4 @@
!ios:!if(win*:isEqual(QT_ARCH, "x86_64")): DEFINES += V4_ENABLE_JIT
!wince*:!ios:!if(win*:isEqual(QT_ARCH, "x86_64")): DEFINES += V4_ENABLE_JIT
# On Qt/Android/ARM release builds are thumb and debug builds arm,
# but we'll force the JIT to always generate thumb2
@ -33,3 +33,4 @@ INCLUDEPATH += $$PWD/disassembler
INCLUDEPATH += $$PWD/disassembler/udis86
INCLUDEPATH += $$_OUT_PWD
win32-msvc2008|wince*: INCLUDEPATH += $$PWD/stubs/compat

55
src/3rdparty/masm/stubs/compat/stdint.h vendored Normal file
View File

@ -0,0 +1,55 @@
/****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtQml module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, 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, Digia gives you certain additional
** rights. These rights are described in the Digia 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.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QSTDINT_WRAPPER_H
#define QSTDINT_WRAPPER_H
/* Needed for VS 2008 and earlier that don't ship stdint.h */
typedef signed char int8_t;
typedef signed short int16_t;
typedef signed int int32_t;
typedef signed long long int64_t;
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long uint64_t;
#endif

View File

@ -191,7 +191,7 @@ static QString qmlsqldatabase_databaseFile(const QString& connectionName, QV8Eng
return qmlsqldatabase_databasesPath(engine) + QDir::separator() + connectionName;
}
static Value qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, ExecutionEngine *v4, uint32_t index, bool *hasProperty = 0)
static Value qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, ExecutionEngine *v4, quint32 index, bool *hasProperty = 0)
{
QV8Engine *v8 = v4->v8Engine;
@ -263,8 +263,8 @@ static Value qmlsqldatabase_executeSql(SimpleCallContext *ctx)
if (ctx->argumentCount > 1) {
Value values = ctx->arguments[1];
if (ArrayObject *array = values.asArrayObject()) {
uint32_t size = array->arrayLength();
for (uint32_t ii = 0; ii < size; ++ii)
quint32 size = array->arrayLength();
for (quint32 ii = 0; ii < size; ++ii)
query.bindValue(ii, engine->toVariant(array->getIndexed(ii), -1));
} else if (Object *object = values.asObject()) {
ObjectIterator it(object, ObjectIterator::WithProtoChain|ObjectIterator::EnumerableOnly);

View File

@ -47,6 +47,9 @@
#include <qtqmlglobal.h>
#if defined(Q_CC_MSVC)
#include <float.h>
#include <math.h>
namespace std {
inline bool isinf(double d) { return !_finite(d) && !_isnan(d); }

View File

@ -150,7 +150,7 @@ MemoryManager::MemoryManager()
// TLS is at the top of each thread's stack,
// so the stack base for thread is the result of __tls()
m_d->stackTop = reinterpret_cast<quintptr *>(
(((uintptr_t)__tls() + __PAGESIZE - 1) & ~(__PAGESIZE - 1)));
(((quintptr)__tls() + __PAGESIZE - 1) & ~(__PAGESIZE - 1)));
#elif USE(PTHREADS)
# if OS(DARWIN)
void *st = pthread_get_stackaddr_np(pthread_self());
@ -404,7 +404,7 @@ std::size_t MemoryManager::sweep(char *chunkStart, std::size_t chunkSize, size_t
// qDebug("chunk @ %p, size = %lu, in use: %s, mark bit: %s",
// chunk, m->size, (m->inUse ? "yes" : "no"), (m->markBit ? "true" : "false"));
assert((intptr_t) chunk % 16 == 0);
assert((qintptr) chunk % 16 == 0);
if (m->inUse) {
if (m->markBit) {

View File

@ -454,8 +454,8 @@ public:
static QVariant toVariant(QV4::ArrayObject *array)
{
Container result;
uint32_t length = array->arrayLength();
for (uint32_t i = 0; i < length; ++i)
quint32 length = array->arrayLength();
for (quint32 i = 0; i < length; ++i)
result << convertValueToElement<typename Container::value_type>(array->getIndexed(i));
return QVariant::fromValue(result);
}

View File

@ -64,7 +64,7 @@ namespace QV4 {
static void *removeThumbBit(void *addr)
{
return reinterpret_cast<void*>(reinterpret_cast<intptr_t>(addr) & ~1u);
return reinterpret_cast<void*>(reinterpret_cast<qintptr>(addr) & ~1u);
}
static QMutex functionProtector;

View File

@ -89,7 +89,7 @@ static const int initial_location_offset = 28;
static const int address_range_offset = 32;
#endif
void writeIntPtrValue(unsigned char *addr, intptr_t val)
void writeIntPtrValue(unsigned char *addr, qintptr val)
{
addr[0] = (val >> 0) & 0xff;
addr[1] = (val >> 8) & 0xff;
@ -144,7 +144,7 @@ static void ensureUnwindInfo(Function *f)
unsigned char *cie_and_fde = reinterpret_cast<unsigned char *>(info.data());
memcpy(cie_and_fde, cie_fde_data, sizeof(cie_fde_data));
intptr_t ptr = static_cast<char *>(chunk->pages->base()) - static_cast<char *>(0);
qintptr ptr = static_cast<char *>(chunk->pages->base()) - static_cast<char *>(0);
writeIntPtrValue(cie_and_fde + initial_location_offset, ptr);
writeIntPtrValue(cie_and_fde + address_range_offset, chunk->pages->size());

View File

@ -394,7 +394,7 @@ QString QHashedCStringRef::toUtf16() const
QString rv;
rv.resize(m_length);
writeUtf16((uint16_t*)rv.data());
writeUtf16((quint16*)rv.data());
return rv;
}

View File

@ -64,8 +64,6 @@
#include <stdlib.h>
#endif
#include <stdint.h>
QT_BEGIN_NAMESPACE
// Enable this to debug hash linking assumptions.
@ -164,7 +162,7 @@ public:
QString toUtf16() const;
inline int utf16length() const;
inline void writeUtf16(QChar *) const;
inline void writeUtf16(uint16_t *) const;
inline void writeUtf16(quint16 *) const;
private:
friend class QHashedStringRef;
@ -232,7 +230,7 @@ public:
void setQString(bool v) { if (v) next.setFlag(); else next.clearFlag(); }
inline char *cStrData() const { return (char *)ckey; }
inline uint16_t *utf16Data() const { return (uint16_t *)strData->data(); }
inline quint16 *utf16Data() const { return (quint16 *)strData->data(); }
inline bool equals(const QV4::Value &string) const {
QString s = string.toQString();
@ -1274,10 +1272,10 @@ int QHashedCStringRef::utf16length() const
void QHashedCStringRef::writeUtf16(QChar *output) const
{
writeUtf16((uint16_t *)output);
writeUtf16((quint16 *)output);
}
void QHashedCStringRef::writeUtf16(uint16_t *output) const
void QHashedCStringRef::writeUtf16(quint16 *output) const
{
int l = m_length;
const char *d = m_data;

View File

@ -171,7 +171,7 @@ private:
// the vTables array are used for dispatching.
// This saves a compiler-generated pointer to a compiler-generated vTable, and thus reduces
// the binding object size by sizeof(void*).
uintptr_t m_nextBindingPtr;
qintptr m_nextBindingPtr;
static VTable *vTables[];
inline const VTable *vtable() const { return vTables[bindingType()]; }
@ -200,7 +200,7 @@ QQmlAbstractBinding *QQmlAbstractBinding::nextBinding() const
void QQmlAbstractBinding::setNextBinding(QQmlAbstractBinding *b)
{
m_nextBindingPtr = uintptr_t(b) | (m_nextBindingPtr & 0x3);
m_nextBindingPtr = qintptr(b) | (m_nextBindingPtr & 0x3);
}
QQmlAbstractBinding::BindingType QQmlAbstractBinding::bindingType() const

View File

@ -94,7 +94,7 @@ class QQmlNotifier;
} while (false);
#define QML_PRIVATE_ACCESSOR(clazz, cpptype, name, variable) \
static void clazz ## _ ## name ## Read(QObject *o, intptr_t, void *rv) \
static void clazz ## _ ## name ## Read(QObject *o, qintptr, void *rv) \
{ \
clazz ## Private *d = clazz ## Private::get(static_cast<clazz *>(o)); \
*static_cast<cpptype *>(rv) = d->variable; \
@ -105,15 +105,15 @@ class QQmlNotifier;
class QQmlAccessors
{
public:
void (*read)(QObject *object, intptr_t property, void *output);
void (*notifier)(QObject *object, intptr_t property, QQmlNotifier **notifier);
void (*read)(QObject *object, qintptr property, void *output);
void (*notifier)(QObject *object, qintptr property, QQmlNotifier **notifier);
};
namespace QQmlAccessorProperties {
struct Property {
const char *name;
unsigned int nameLength;
intptr_t data;
qintptr data;
QQmlAccessors *accessors;
};

View File

@ -416,7 +416,7 @@ QV4::Value QQmlNumberExtension::toLocaleString(QV4::SimpleCallContext *ctx)
GET_LOCALE_DATA_RESOURCE(ctx->arguments[0]);
uint16_t format = 'f';
quint16 format = 'f';
if (ctx->argumentCount > 1) {
if (!ctx->arguments[1].isString())
V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments");

View File

@ -61,15 +61,15 @@ static Callback QQmlNotifier_callbacks[] = {
void QQmlNotifier::emitNotify(QQmlNotifierEndpoint *endpoint, void **a)
{
intptr_t originalSenderPtr;
intptr_t *disconnectWatch;
qintptr originalSenderPtr;
qintptr *disconnectWatch;
if (!endpoint->isNotifying()) {
originalSenderPtr = endpoint->senderPtr;
disconnectWatch = &originalSenderPtr;
endpoint->senderPtr = intptr_t(disconnectWatch) | 0x1;
endpoint->senderPtr = qintptr(disconnectWatch) | 0x1;
} else {
disconnectWatch = (intptr_t *)(endpoint->senderPtr & ~0x1);
disconnectWatch = (qintptr *)(endpoint->senderPtr & ~0x1);
}
if (endpoint->next)
@ -111,7 +111,7 @@ void QQmlNotifierEndpoint::connect(QObject *source, int sourceSignal, QQmlEngine
qPrintable(engineName));
}
senderPtr = intptr_t(source);
senderPtr = qintptr(source);
this->sourceSignal = sourceSignal;
QQmlPropertyPrivate::flushSignal(source, sourceSignal);
QQmlData *ddata = QQmlData::get(source, true);

View File

@ -205,7 +205,7 @@ public:
};
struct { // When HasAccessors
QQmlAccessors *accessors;
intptr_t accessorData;
qintptr accessorData;
};
};

View File

@ -106,7 +106,7 @@ void printFocusTree(QQuickItem *item, QQuickItem *scope, int depth)
}
#endif
static void QQuickItem_parentNotifier(QObject *o, intptr_t, QQmlNotifier **n)
static void QQuickItem_parentNotifier(QObject *o, qintptr, QQmlNotifier **n)
{
QQuickItemPrivate *d = QQuickItemPrivate::get(static_cast<QQuickItem *>(o));
*n = &d->parentNotifier;

View File

@ -398,7 +398,7 @@ public:
return QMatrix4x4();
float matVals[16];
for (uint32_t i = 0; i < 16; ++i) {
for (quint32 i = 0; i < 16; ++i) {
QV4::Value v = array->getIndexed(i);
if (!v.isNumber())
return QMatrix4x4();