static UString pointerToSourceString(void* p)
{
- char buffer[2 + 2 * sizeof(void*) + 1]; // 0x [two characters per byte] \0
+ char buffer[2 + 2 * QT_POINTER_SIZE + 1]; // 0x [two characters per byte] \0
snprintf(buffer, sizeof(buffer), "%p", p);
return buffer;
}
markConservatively(markStack, stackPointer, stackBase);
}
-#define REGISTER_BUFFER_ALIGNMENT Q_DECL_ALIGN(sizeof(void*))
+#define REGISTER_BUFFER_ALIGNMENT Q_DECL_ALIGN(QT_POINTER_SIZE)
void Heap::markCurrentThreadConservatively(MarkStack& markStack)
{
{
*WTF::bitwise_cast<NativeFunction*>(m_data) = func;
}
- unsigned char m_data[sizeof(void*)];
+ unsigned char m_data[QT_POINTER_SIZE];
};
JSFunction* asFunction(JSValue);
void allocatePropertyStorageInline(size_t oldSize, size_t newSize);
bool isUsingInlineStorage() const { return m_structure->isUsingInlineStorage(); }
- static const unsigned inlineStorageCapacity = sizeof(EncodedJSValue) == 2 * sizeof(void*) ? 4 : 3;
+ static const unsigned inlineStorageCapacity = sizeof(EncodedJSValue) == 2 * QT_POINTER_SIZE ? 4 : 3;
static const unsigned nonInlineBaseStorageCapacity = 16;
static PassRefPtr<Structure> createStructure(JSValue prototype)
class Q_CORE_EXPORT QSysInfo {
public:
enum Sizes {
- WordSize = (sizeof(void *)<<3)
+ WordSize = (QT_POINTER_SIZE << 3)
};
enum Endian {
isPointer = false,
isComplex = true,
isStatic = true,
- isLarge = (sizeof(T)>sizeof(void*))
+ isLarge = (sizeof(T) > QT_POINTER_SIZE)
};
};
enum { \
isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), \
isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), \
- isLarge = (sizeof(TYPE)>sizeof(void*)), \
+ isLarge = (sizeof(TYPE) > QT_POINTER_SIZE), \
isPointer = false \
}; \
static inline const char *name() { return #TYPE; } \
}
int nargs = 1; // include return type
- void **args = (void **) malloc(paramCount * sizeof(void *));
+ void **args = (void **) malloc(paramCount * QT_POINTER_SIZE);
Q_CHECK_PTR(args);
int *types = (int *) malloc(paramCount * sizeof(int));
Q_CHECK_PTR(types);
int nargs = 1; // include return type
while (c->argumentTypes[nargs-1])
++nargs;
- int *types = (int *) malloc(nargs*sizeof(int));
+ int *types = (int *) ::malloc(nargs * sizeof(int));
Q_CHECK_PTR(types);
- void **args = (void **) malloc(nargs*sizeof(void *));
+ void **args = (void **) ::malloc(nargs * QT_POINTER_SIZE);
Q_CHECK_PTR(args);
types[0] = 0; // return type
args[0] = Q_NULLPTR; // return value
result += mapToJson(value.toMap());
break;
}
-
default: {
error = QCoreApplication::translate("QJsonDocument", "Unknown JSON type");
break;
static int grow(int size)
{
// dear compiler: don't optimize me out.
- volatile int x = qAllocMore(size * sizeof(void *), QListData::DataHeaderSize) / sizeof(void *);
+ volatile int x = qAllocMore(size * QT_POINTER_SIZE, QListData::DataHeaderSize) / QT_POINTER_SIZE;
return x;
}
int l = x->end - x->begin;
int nl = l + num;
int alloc = grow(nl);
- Data* t = static_cast<Data *>(malloc(DataHeaderSize + alloc * sizeof(void *)));
+ Data* t = static_cast<Data *>(malloc(DataHeaderSize + alloc * QT_POINTER_SIZE));
Q_CHECK_PTR(t);
t->ref = 1;
QListData::Data *QListData::detach(int alloc)
{
Data *x = d;
- Data* t = static_cast<Data *>(malloc(DataHeaderSize + alloc * sizeof(void *)));
+ Data* t = static_cast<Data *>(malloc(DataHeaderSize + alloc * QT_POINTER_SIZE));
Q_CHECK_PTR(t);
t->ref = 1;
void QListData::reallocData(int alloc)
{
Q_ASSERT(d->ref == 1);
- Data *x = static_cast<Data *>(realloc(d, DataHeaderSize + alloc * sizeof(void *)));
+ Data *x = static_cast<Data *>(realloc(d, DataHeaderSize + alloc * QT_POINTER_SIZE));
Q_CHECK_PTR(x);
d = x;
if (b - n >= 2 * d->alloc / 3) {
// we have enough space. Just not at the end -> move it.
e -= b;
- ::memmove(d->array, d->array + b, e * sizeof(void *));
+ ::memmove(d->array, d->array + b, e * QT_POINTER_SIZE);
d->begin = 0;
} else {
reallocData(grow(d->alloc + n));
else
d->begin = d->alloc - d->end;
- ::memmove(d->array + d->begin, d->array, d->end * sizeof(void *));
+ ::memmove(d->array + d->begin, d->array, d->end * QT_POINTER_SIZE);
d->end += d->begin;
}
return d->array + --d->begin;
if (leftward) {
--d->begin;
- ::memmove(d->array + d->begin, d->array + d->begin + 1, i * sizeof(void *));
+ ::memmove(d->array + d->begin, d->array + d->begin + 1, i * QT_POINTER_SIZE);
} else {
::memmove(d->array + d->begin + i + 1, d->array + d->begin + i,
- (size - i) * sizeof(void *));
+ (size - i) * QT_POINTER_SIZE);
++d->end;
}
return d->array + d->begin + i;
i += d->begin;
if (i - d->begin < d->end - i) {
if (int offset = i - d->begin)
- ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *));
+ ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * QT_POINTER_SIZE);
d->begin++;
} else {
if (int offset = d->end - i - 1)
- ::memmove(d->array + i, d->array + i + 1, offset * sizeof(void *));
+ ::memmove(d->array + i, d->array + i + 1, offset * QT_POINTER_SIZE);
d->end--;
}
}
int middle = i + n/2;
if (middle - d->begin < d->end - middle) {
::memmove(d->array + d->begin + n, d->array + d->begin,
- (i - d->begin) * sizeof(void*));
+ (i - d->begin) * QT_POINTER_SIZE);
d->begin += n;
} else {
::memmove(d->array + i, d->array + i + n,
- (d->end - i - n) * sizeof(void*));
+ (d->end - i - n) * QT_POINTER_SIZE);
d->end -= n;
}
}
if (from < to) {
if (d->end == d->alloc || 3 * (to - from) < 2 * (d->end - d->begin)) {
- ::memmove(d->array + from, d->array + from + 1, (to - from) * sizeof(void *));
+ ::memmove(d->array + from, d->array + from + 1, (to - from) * QT_POINTER_SIZE);
} else {
// optimization
if (int offset = from - d->begin)
- ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * sizeof(void *));
+ ::memmove(d->array + d->begin + 1, d->array + d->begin, offset * QT_POINTER_SIZE);
if (int offset = d->end - (to + 1))
- ::memmove(d->array + to + 2, d->array + to + 1, offset * sizeof(void *));
+ ::memmove(d->array + to + 2, d->array + to + 1, offset * QT_POINTER_SIZE);
++d->begin;
++d->end;
++to;
}
} else {
if (d->begin == 0 || 3 * (from - to) < 2 * (d->end - d->begin)) {
- ::memmove(d->array + to + 1, d->array + to, (from - to) * sizeof(void *));
+ ::memmove(d->array + to + 1, d->array + to, (from - to) * QT_POINTER_SIZE);
} else {
// optimization
if (int offset = to - d->begin)
- ::memmove(d->array + d->begin - 1, d->array + d->begin, offset * sizeof(void *));
+ ::memmove(d->array + d->begin - 1, d->array + d->begin, offset * QT_POINTER_SIZE);
if (int offset = d->end - (from + 1))
- ::memmove(d->array + from, d->array + from + 1, offset * sizeof(void *));
+ ::memmove(d->array + from, d->array + from + 1, offset * QT_POINTER_SIZE);
--d->begin;
--d->end;
--to;
int alloc, begin, end;
void *array[1];
};
- enum { DataHeaderSize = sizeof(Data) - sizeof(void *) };
+ enum { DataHeaderSize = sizeof(Data) - QT_POINTER_SIZE };
Data *detach(int alloc);
Data *detach_grow(int *i, int n);
inline CustomDeleter(T *p, Deleter d) : deleter(d), ptr(p) {}
};
CustomDeleter extra;
- // sizeof(CustomDeleter) = sizeof(Deleter) + sizeof(void*)
+ // sizeof(CustomDeleter) = sizeof(Deleter) + QT_POINTER_SIZE
// for Deleter = function pointer: 8 (32-bit) / 16 (64-bit)
// for Deleter = PMF: 12 (32-bit) / 24 (64-bit) (GCC)
QBidiControl control(rtl);
if (ignore) {
- memset(analysis, 0, length*sizeof(QScriptAnalysis));
+ ::memset(analysis, 0, length * sizeof(QScriptAnalysis));
if (option.textDirection() == Qt::RightToLeft) {
for (int i = 0; i < length; ++i)
analysis[i].bidiLevel = 1;
{
allocated = _allocated;
- int space_charAttributes = sizeof(HB_CharAttributes)*string.length()/sizeof(void*) + 1;
- int space_logClusters = sizeof(unsigned short)*string.length()/sizeof(void*) + 1;
- available_glyphs = ((int)allocated - space_charAttributes - space_logClusters)*(int)sizeof(void*)/(int)QGlyphLayout::spaceNeededForGlyphLayout(1);
+ int space_charAttributes = sizeof(HB_CharAttributes) * string.length() / QT_POINTER_SIZE + 1;
+ int space_logClusters = sizeof(unsigned short) * string.length() / QT_POINTER_SIZE + 1;
+ available_glyphs = (allocated - space_charAttributes - space_logClusters) * QT_POINTER_SIZE / QGlyphLayout::spaceNeededForGlyphLayout(1);
if (available_glyphs < str.length()) {
// need to allocate on the heap
void *m = memory + space_charAttributes + space_logClusters;
glyphLayout = QGlyphLayout(reinterpret_cast<char *>(m), str.length());
glyphLayout.clear();
- memset(memory, 0, space_charAttributes*sizeof(void *));
+ ::memset(memory, 0, space_charAttributes * QT_POINTER_SIZE);
}
used = 0;
hasBidi = false;
QTextEngine::LayoutData::~LayoutData()
{
if (!memory_on_stack)
- free(memory);
+ ::free(memory);
memory = 0;
}
return true;
}
- int space_charAttributes = sizeof(HB_CharAttributes)*string.length()/sizeof(void*) + 1;
- int space_logClusters = sizeof(unsigned short)*string.length()/sizeof(void*) + 1;
- int space_glyphs = QGlyphLayout::spaceNeededForGlyphLayout(totalGlyphs)/sizeof(void*) + 2;
+ int space_charAttributes = sizeof(HB_CharAttributes) * string.length() / QT_POINTER_SIZE + 1;
+ int space_logClusters = sizeof(unsigned short) * string.length() / QT_POINTER_SIZE + 1;
+ int space_glyphs = QGlyphLayout::spaceNeededForGlyphLayout(totalGlyphs) / QT_POINTER_SIZE + 2;
int newAllocated = space_charAttributes + space_glyphs + space_logClusters;
// These values can be negative if the length of string/glyphs causes overflow,
return false;
}
- void **newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated*sizeof(void *));
+ void **newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated * QT_POINTER_SIZE);
if (!newMem) {
layoutState = LayoutFailed;
return false;
}
if (memory_on_stack)
- memcpy(newMem, memory, allocated*sizeof(void *));
+ memcpy(newMem, memory, allocated * QT_POINTER_SIZE);
memory = newMem;
memory_on_stack = false;
const int space_preGlyphLayout = space_charAttributes + space_logClusters;
if (allocated < space_preGlyphLayout)
- memset(memory + allocated, 0, (space_preGlyphLayout - allocated)*sizeof(void *));
+ memset(memory + allocated, 0, (space_preGlyphLayout - allocated) * QT_POINTER_SIZE);
glyphLayout.grow(reinterpret_cast<char *>(m), totalGlyphs);
typedef QVarLengthArray<void *> Array;
public:
QVarLengthGlyphLayoutArray(int totalGlyphs)
- : Array(spaceNeededForGlyphLayout(totalGlyphs) / sizeof(void *) + 1)
+ : Array(spaceNeededForGlyphLayout(totalGlyphs) / QT_POINTER_SIZE + 1)
, QGlyphLayout(reinterpret_cast<char *>(Array::data()), totalGlyphs)
{
- memset(Array::data(), 0, Array::size() * sizeof(void *));
+ memset(Array::data(), 0, Array::size() * QT_POINTER_SIZE);
}
void resize(int totalGlyphs)
{
- Array::resize(spaceNeededForGlyphLayout(totalGlyphs) / sizeof(void *) + 1);
+ Array::resize(spaceNeededForGlyphLayout(totalGlyphs) / QT_POINTER_SIZE + 1);
*((QGlyphLayout *)this) = QGlyphLayout(reinterpret_cast<char *>(Array::data()), totalGlyphs);
- memset(Array::data(), 0, Array::size() * sizeof(void *));
+ memset(Array::data(), 0, Array::size() * QT_POINTER_SIZE);
}
};
void *buffer[(N * (sizeof(HB_Glyph) + sizeof(HB_GlyphAttributes)
+ sizeof(QFixed) + sizeof(QFixed) + sizeof(QFixedPoint)
+ sizeof(QGlyphJustification)))
- / sizeof(void *) + 1];
+ / QT_POINTER_SIZE + 1];
};
struct QScriptItem;
class QStackTextEngine : public QTextEngine {
public:
- enum { MemSize = 256*40/sizeof(void *) };
+ enum { MemSize = 256 * 40 / QT_POINTER_SIZE };
QStackTextEngine(const QString &string, const QFont &f);
LayoutData _layoutData;
void *_memory[MemSize];
QScriptDeclarativeClass::QScriptDeclarativeClass(QScriptEngine *engine)
: d_ptr(new QScriptDeclarativeClassPrivate)
{
- Q_ASSERT(sizeof(void*) == sizeof(JSC::Identifier));
+ Q_ASSERT(sizeof(JSC::Identifier) == QT_POINTER_SIZE);
d_ptr->engine = engine;
}
inline bool qCompare(QIcon const &t1, QIcon const &t2, const char *actual, const char *expected,
const char *file, int line)
{
- QTEST_ASSERT(sizeof(QIcon) == sizeof(void *));
+ QTEST_ASSERT(sizeof(QIcon) == QT_POINTER_SIZE);
return qCompare<void *>(*reinterpret_cast<void * const *>(&t1),
*reinterpret_cast<void * const *>(&t2), actual, expected, file, line);
}
d->tag = qstrdup(tag);
d->parent = parent;
d->data = new void *[parent->elementCount()];
- memset(d->data, 0, parent->elementCount() * sizeof(void*));
+ memset(d->data, 0, parent->elementCount() * QT_POINTER_SIZE);
}
QTestData::~QTestData()
}
static inline int alignOfTypedData()
{
-#ifdef Q_ALIGNOF
- return qMax<int>(sizeof(void*), Q_ALIGNOF(Data));
-#else
- return 0;
-#endif
+ return qMax<int>(QT_POINTER_SIZE, Q_ALIGNOF(Data));
}
public: