summaryrefslogtreecommitdiff
path: root/qtools
diff options
context:
space:
mode:
Diffstat (limited to 'qtools')
-rw-r--r--qtools/CMakeLists.txt8
-rw-r--r--qtools/Doxyfile1
-rw-r--r--qtools/qasciidict.h2
-rw-r--r--qtools/qcache.h2
-rw-r--r--qtools/qcollection.cpp2
-rw-r--r--qtools/qcstring.h57
-rw-r--r--qtools/qdatastream.cpp17
-rw-r--r--qtools/qfile.cpp4
-rw-r--r--qtools/qglobal.h1
-rw-r--r--qtools/qgstring.h2
-rw-r--r--qtools/qintdict.h2
-rw-r--r--qtools/qmutex.cpp95
-rw-r--r--qtools/qmutex.h83
-rw-r--r--qtools/qmutex_p.h90
-rw-r--r--qtools/qmutex_unix.cpp117
-rw-r--r--qtools/qmutex_win32.cpp108
-rw-r--r--qtools/qptrdict.h2
-rw-r--r--qtools/qstring.h6
-rw-r--r--qtools/qtextcodec.cpp2
-rw-r--r--qtools/qthread.cpp86
-rw-r--r--qtools/qthread.h77
-rw-r--r--qtools/qthread_p.h85
-rw-r--r--qtools/qthread_unix.cpp239
-rw-r--r--qtools/qthread_win32.cpp158
-rw-r--r--qtools/qtools.pro.in19
-rw-r--r--qtools/qvaluelist.h4
-rw-r--r--qtools/qwaitcondition.h68
-rw-r--r--qtools/qwaitcondition_unix.cpp134
-rw-r--r--qtools/qwaitcondition_win32.cpp186
29 files changed, 52 insertions, 1605 deletions
diff --git a/qtools/CMakeLists.txt b/qtools/CMakeLists.txt
index cc64de1..a7082c7 100644
--- a/qtools/CMakeLists.txt
+++ b/qtools/CMakeLists.txt
@@ -25,8 +25,6 @@ qstringlist.cpp
qcstringlist.cpp
qxml.cpp
qmap.cpp
-qthread.cpp
-qmutex.cpp
qutfcodec.cpp
)
@@ -35,9 +33,6 @@ list(APPEND qtools_src
qfile_unix.cpp
qdir_unix.cpp
qfileinfo_unix.cpp
-qthread_unix.cpp
-qmutex_unix.cpp
-qwaitcondition_unix.cpp
)
endif()
@@ -46,9 +41,6 @@ list(APPEND qtools_src
qfile_win32.cpp
qdir_win32.cpp
qfileinfo_win32.cpp
-qthread_win32.cpp
-qmutex_win32.cpp
-qwaitcondition_win32.cpp
)
endif()
diff --git a/qtools/Doxyfile b/qtools/Doxyfile
index 109d3dc..d3ab25a 100644
--- a/qtools/Doxyfile
+++ b/qtools/Doxyfile
@@ -28,7 +28,6 @@ INHERIT_DOCS = YES
SEPARATE_MEMBER_PAGES = NO
TAB_SIZE = 8
ALIASES =
-TCL_SUBST =
OPTIMIZE_OUTPUT_FOR_C = NO
OPTIMIZE_OUTPUT_JAVA = NO
OPTIMIZE_FOR_FORTRAN = NO
diff --git a/qtools/qasciidict.h b/qtools/qasciidict.h
index 29fcf2f..6a93a02 100644
--- a/qtools/qasciidict.h
+++ b/qtools/qasciidict.h
@@ -46,7 +46,7 @@
template<class type> class Q_EXPORT QAsciiDict : public QGDict
{
public:
- QAsciiDict(int size=17, bool caseSensitive=TRUE, bool copyKeys=TRUE )
+ QAsciiDict(uint size=17, bool caseSensitive=TRUE, bool copyKeys=TRUE )
: QGDict(size,AsciiKey,caseSensitive,copyKeys) {}
QAsciiDict( const QAsciiDict<type> &d ) : QGDict(d) {}
~QAsciiDict() { clear(); }
diff --git a/qtools/qcache.h b/qtools/qcache.h
index 39d4f7a..87f9866 100644
--- a/qtools/qcache.h
+++ b/qtools/qcache.h
@@ -46,7 +46,7 @@ template<class type> class Q_EXPORT QCache : public QGCache
{
public:
QCache( const QCache<type> &c ) : QGCache(c) {}
- QCache( int maxCost=100, int size=17, bool caseSensitive=TRUE )
+ QCache( int maxCost=100, uint size=17, bool caseSensitive=TRUE )
: QGCache( maxCost, size, AsciiKey, caseSensitive, TRUE ) {}
~QCache() { clear(); }
QCache<type> &operator=( const QCache<type> &c )
diff --git a/qtools/qcollection.cpp b/qtools/qcollection.cpp
index e70b64b..4f86227 100644
--- a/qtools/qcollection.cpp
+++ b/qtools/qcollection.cpp
@@ -60,7 +60,7 @@
*/
-/*! \enum QCollection::Item
+/*! \typedef QCollection::Item
This type is the generic "item" in a QCollection.
*/
diff --git a/qtools/qcstring.h b/qtools/qcstring.h
index c2a5dc3..ec57f17 100644
--- a/qtools/qcstring.h
+++ b/qtools/qcstring.h
@@ -21,6 +21,8 @@
#include "qarray.h"
#endif // QT_H
+#include <string>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -149,7 +151,7 @@ public:
/** creates a string with room for size characters
* @param[in] size the number of character to allocate (including the 0-terminator)
*/
- explicit QCString( int size ) : m_rep(size)
+ explicit QCString( uint size ) : m_rep(size)
{
}
@@ -269,7 +271,7 @@ public:
bool stripPrefix(const char *prefix);
QCString left( uint len ) const;
QCString right( uint len ) const;
- QCString mid( uint index, uint len=0xffffffff) const;
+ QCString mid( uint index, uint len=(uint)-1) const;
QCString lower() const;
QCString upper() const;
QCString stripWhiteSpace() const;
@@ -307,8 +309,8 @@ public:
QCString &operator+=( const char *str )
{
if (!str) return *this;
- int len1 = length();
- int len2 = (int)strlen(str);
+ uint len1 = length();
+ uint len2 = (uint)strlen(str);
resize(len1+len2+1);
memcpy(rawData()+len1,str,len2);
return *this;
@@ -317,7 +319,7 @@ public:
/** Appends character \a c to this string and returns a reference to the result. */
QCString &operator+=( char c )
{
- int len = length();
+ uint len = length();
resize(len+2);
rawData()[len]=c;
return *this;
@@ -361,7 +363,7 @@ public:
// ref counting string header
struct LSHeader
{
- int len; // length of string without 0 terminator
+ uint len; // length of string without 0 terminator
int refCount; // -1=leaked, 0=one ref & non-cost, n>0, n+1 refs, const
};
// ref counting string data and methods
@@ -374,7 +376,7 @@ public:
// creates a LSData item with room for size bytes (which includes the 0 terminator!)
// if size is zero, an empty string will be created.
- static LSData *create(int size)
+ static LSData *create(uint size)
{
LSData *data;
data = (LSData*)malloc(sizeof(LSHeader)+size);
@@ -391,7 +393,7 @@ public:
// resizes LSData so it can hold size bytes (which includes the 0 terminator!)
// Since this is for long strings only, size should be > SHORT_STR_CAPACITY
- static LSData *resize(LSData *d,int size)
+ static LSData *resize(LSData *d,uint size)
{
if (d->len>0 && d->refCount==0) // non-const, non-empty
{
@@ -403,7 +405,7 @@ public:
else // need to make a copy
{
LSData *newData = LSData::create(size);
- int len = d->len;
+ uint len = d->len;
if (len>=size) len=size-1;
memcpy(newData->toStr(),d->toStr(),len);
newData->toStr()[len]=0;
@@ -454,14 +456,14 @@ public:
u = s.u; // avoid uninitialized warning from gcc
}
}
- StringRep(int size)
+ StringRep(uint size)
{
u.s.isShort = size<=SHORT_STR_CAPACITY;
if (size<=SHORT_STR_CAPACITY) // init short string
{
if (size>0)
{
- u.s.len = size-1;
+ u.s.len = (uchar)(size-1);
u.s.str[size-1]='\0';
}
else
@@ -478,11 +480,11 @@ public:
{
if (str)
{
- int len = (int)strlen(str);
+ uint len = (uint)strlen(str);
u.s.isShort = len<SHORT_STR_CAPACITY;
if (len<SHORT_STR_CAPACITY)
{
- u.s.len = len;
+ u.s.len = (uchar)len;
qstrncpy(u.s.str,str,SHORT_STR_CAPACITY);
}
else
@@ -505,7 +507,7 @@ public:
u.s.isShort = len<=SHORT_STR_MAX_LEN;
if (u.s.isShort)
{
- u.s.len = len;
+ u.s.len = (uchar)len;
memcpy(u.s.str,str,len);
u.s.str[len]='\0';
}
@@ -554,11 +556,11 @@ public:
}
if (str)
{
- int len = (int)strlen(str);
+ uint len = (uint)strlen(str);
u.s.isShort = len<SHORT_STR_CAPACITY;
if (len<SHORT_STR_CAPACITY)
{
- u.s.len = len;
+ u.s.len = (uchar)len;
qstrncpy(u.s.str,str,SHORT_STR_CAPACITY);
}
else
@@ -605,7 +607,7 @@ public:
return u.l.d->len==0 ? 0 : u.l.d->toStr();
}
}
- char &at(int i) const
+ char &at(uint i) const
{
if (u.s.isShort)
{
@@ -622,7 +624,7 @@ public:
{
if (newlen>0)
{
- u.s.len = newlen-1;
+ u.s.len = (uchar)(newlen-1);
u.s.str[newlen-1]='\0';
}
else // string becomes empty
@@ -668,21 +670,21 @@ public:
}
bool fill( char c, int len )
{
- if (len<0) len=length();
+ uint ulen = len<0 ? length() : (uint)len;
if (!u.s.isShort) // detach from shared string
{
- resize(len+1);
+ resize(ulen+1);
}
- else if (len!=(int)length())
+ else if (ulen!=length())
{
- if (len>0)
+ if (ulen>0)
{
- resize(len+1);
+ resize(ulen+1);
}
}
- if (len>0)
+ if (ulen>0)
{
- memset(rawData(),c,len);
+ memset(rawData(),c,ulen);
}
return TRUE;
}
@@ -805,4 +807,9 @@ inline const char *qPrint(const QCString &s)
if (!s.isEmpty()) return s.data(); else return "";
}
+inline std::string toStdString(const QCString &s)
+{
+ if (!s.isEmpty()) return std::string(s.data()); else return std::string();
+}
+
#endif // QCSTRING_H
diff --git a/qtools/qdatastream.cpp b/qtools/qdatastream.cpp
index 5190b53..d539daf 100644
--- a/qtools/qdatastream.cpp
+++ b/qtools/qdatastream.cpp
@@ -730,7 +730,7 @@ QDataStream &QDataStream::operator<<( Q_INT16 i )
if ( printable ) { // printable data
char buf[16];
sprintf( buf, "%d\n", i );
- dev->writeBlock( buf, strlen(buf) );
+ dev->writeBlock( buf, (int)strlen(buf) );
} else if ( noswap ) { // no conversion needed
dev->writeBlock( (char *)&i, sizeof(Q_INT16) );
} else { // swap bytes
@@ -761,7 +761,7 @@ QDataStream &QDataStream::operator<<( Q_INT32 i )
if ( printable ) { // printable data
char buf[16];
sprintf( buf, "%d\n", i );
- dev->writeBlock( buf, strlen(buf) );
+ dev->writeBlock( buf, (int)strlen(buf) );
} else if ( noswap ) { // no conversion needed
dev->writeBlock( (char *)&i, sizeof(Q_INT32) );
} else { // swap bytes
@@ -793,7 +793,7 @@ QDataStream &QDataStream::operator<<( Q_INT64 i )
if ( printable ) { // printable data
char buf[20];
sprintf( buf, "%ld\n", i );
- dev->writeBlock( buf, strlen(buf) );
+ dev->writeBlock( buf, (int)strlen(buf) );
} else if ( noswap ) { // no conversion needed
dev->writeBlock( (char *)&i, sizeof(Q_INT64) );
} else { // swap bytes
@@ -815,13 +815,6 @@ QDataStream &QDataStream::operator<<( Q_INT64 i )
}
/*!
- \fn QDataStream &QDataStream::operator<<( uint i )
- Writes an unsigned integer to the stream as a 32-bit unsigned integer
- (Q_UINT32).
- Returns a reference to the stream.
-*/
-
-/*!
\fn QDataStream &QDataStream::operator<<( int i )
Writes a signed integer to the stream as a 32-bit signed integer (Q_INT32).
Returns a reference to the stream.
@@ -839,7 +832,7 @@ QDataStream &QDataStream::operator<<( float f )
if ( printable ) { // printable data
char buf[32];
sprintf( buf, "%g\n", (double)f );
- dev->writeBlock( buf, strlen(buf) );
+ dev->writeBlock( buf, (int)strlen(buf) );
} else {
float g = f; // fixes float-on-stack problem
if ( noswap ) { // no conversion needed
@@ -869,7 +862,7 @@ QDataStream &QDataStream::operator<<( double f )
if ( printable ) { // printable data
char buf[32];
sprintf( buf, "%g\n", f );
- dev->writeBlock( buf, strlen(buf) );
+ dev->writeBlock( buf, (int)strlen(buf) );
} else if ( noswap ) { // no conversion needed
dev->writeBlock( (char *)&f, sizeof(double) );
} else { // swap bytes
diff --git a/qtools/qfile.cpp b/qtools/qfile.cpp
index 98ed9a3..7939160 100644
--- a/qtools/qfile.cpp
+++ b/qtools/qfile.cpp
@@ -497,7 +497,7 @@ QCString QFile::encodeName( const QString &fileName )
}
/*!
- \enum QFile::EncoderFn
+ \typedef QFile::EncoderFn
This is used by QFile::setEncodingFunction().
*/
@@ -532,7 +532,7 @@ QString QFile::decodeName( const QCString &localFileName )
}
/*!
- \enum QFile::DecoderFn
+ \typedef QFile::DecoderFn
This is used by QFile::setDecodingFunction().
*/
diff --git a/qtools/qglobal.h b/qtools/qglobal.h
index d37bdf2..0deef5d 100644
--- a/qtools/qglobal.h
+++ b/qtools/qglobal.h
@@ -507,7 +507,6 @@ Q_EXPORT bool qSysInfo( int *wordSize, bool *bigEndian );
#pragma warning(disable: 4244)
#pragma warning(disable: 4275)
#pragma warning(disable: 4514)
-#pragma warning(disable: 4800)
#pragma warning(disable: 4097)
#pragma warning(disable: 4706)
#elif defined(_CC_BOR_)
diff --git a/qtools/qgstring.h b/qtools/qgstring.h
index 6934c93..0af1045 100644
--- a/qtools/qgstring.h
+++ b/qtools/qgstring.h
@@ -43,7 +43,7 @@ class QGString
bool truncate( uint pos ) { return resize(pos+1); }
operator const char *() const { return (const char *)data(); }
char &at( uint index ) const { return m_data[index]; }
- char &operator[]( int i ) const { return at(i); }
+ char &operator[]( uint i ) const { return at(i); }
private:
char * m_data;
diff --git a/qtools/qintdict.h b/qtools/qintdict.h
index ddc5fdf..0606ec8 100644
--- a/qtools/qintdict.h
+++ b/qtools/qintdict.h
@@ -46,7 +46,7 @@
template<class type> class Q_EXPORT QIntDict : public QGDict
{
public:
- QIntDict(int size=17) : QGDict(size,IntKey,0,0) {}
+ QIntDict(uint size=17) : QGDict(size,IntKey,0,0) {}
QIntDict( const QIntDict<type> &d ) : QGDict(d) {}
~QIntDict() { clear(); }
QIntDict<type> &operator=(const QIntDict<type> &d)
diff --git a/qtools/qmutex.cpp b/qtools/qmutex.cpp
deleted file mode 100644
index 08a13bc..0000000
--- a/qtools/qmutex.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <stdio.h>
-
-#include "qglobal.h"
-
-#include "qmutex.h"
-#include "qmutex_p.h"
-
-QMutex::QMutex() : d(new QMutexPrivate())
-{
-}
-
-QMutex::~QMutex()
-{
- delete d;
-}
-
-void QMutex::lock()
-{
- //printf("%p: QMutex::lock(): enter\n",this);
- bool isLocked;
- isLocked = d->contenders.testAndSet(0, 1);
- if (!isLocked)
- {
- isLocked = d->contenders.fetchAndAdd(1)==0;
- if (!isLocked)
- {
- // didn't get the lock, wait for it
- //printf("%p: QMutex::lock(): wait() %d\n",this,(int)d->contenders);
- d->wait();
-
- // release lock
- d->contenders.fetchAndAdd(-1);
- }
- }
- //printf("%p: QMutex::lock(): leave\n",this);
-}
-
-bool QMutex::tryLock()
-{
- bool isLocked = d->contenders.testAndSet(0, 1);
- return isLocked;
-}
-
-void QMutex::unlock()
-{
- //printf("%p: QMutex::unlock(): enter %d\n",this,(int)d->contenders);
- if (!d->contenders.testAndSet(1, 0))
- {
- //printf("%p: QMutex::unlock(): wakeUp()\n",this);
- d->wakeUp();
- }
- //printf("%p: QMutex::unlock(): leave\n",this);
-}
-
diff --git a/qtools/qmutex.h b/qtools/qmutex.h
deleted file mode 100644
index d3d2ac0..0000000
--- a/qtools/qmutex.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMUTEX_H
-#define QMUTEX_H
-
-#include "qglobal.h"
-
-class QMutexPrivate;
-
-class QMutex
-{
-public:
- QMutex();
- ~QMutex();
-
- void lock();
- bool tryLock();
- void unlock();
-
-private:
- QMutex(const QMutex &);
- QMutex &operator=(const QMutex &);
-
- QMutexPrivate *d;
-};
-
-class QMutexLocker
-{
- public:
- QMutexLocker(QMutex *m) : m_mutex(m)
- {
- m_mutex->lock();
- }
- ~QMutexLocker()
- {
- m_mutex->unlock();
- }
- QMutex *mutex() const { return m_mutex; }
-
- private:
- QMutex *m_mutex;
-};
-
-#endif // QMUTEX_H
diff --git a/qtools/qmutex_p.h b/qtools/qmutex_p.h
deleted file mode 100644
index a47b407..0000000
--- a/qtools/qmutex_p.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMUTEX_P_H
-#define QMUTEX_P_H
-
-#include "qglobal.h"
-
-#if defined(_OS_UNIX_) || defined(_OS_MAC_)
-#include <pthread.h>
-#elif defined(_OS_WIN32_)
-#include <windows.h>
-#endif
-
-class QAtomicInt
-{
- public:
- QAtomicInt(int v=0) : m_value(v) {}
- bool testAndSet(int expectedValue,int newValue);
- int fetchAndAdd(int valueToAdd);
- operator int () const { return m_value; }
- bool operator==(int value) const { return m_value == value; }
- bool operator!=(int value) const { return m_value != value; }
- bool operator!() const { return m_value == 0; }
-
- private:
- volatile int m_value;
-};
-
-class QMutexPrivate
-{
-public:
- QMutexPrivate();
- ~QMutexPrivate();
-
- void wait();
- void wakeUp();
-
- QAtomicInt contenders;
-
-#if defined(_OS_UNIX_) || defined(_OS_MAC_)
- volatile bool wakeup;
- pthread_mutex_t mutex;
- pthread_cond_t cond;
-#elif defined(_OS_WIN32_)
- HANDLE event;
-#else
-#error "unsupported platform"
-#endif
-};
-
-#endif // QMUTEX_P_H
diff --git a/qtools/qmutex_unix.cpp b/qtools/qmutex_unix.cpp
deleted file mode 100644
index 4fe9a58..0000000
--- a/qtools/qmutex_unix.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <errno.h>
-#include <pthread.h>
-
-#include "qglobal.h"
-#include "qmutex.h"
-#include "qmutex_p.h"
-
-static pthread_mutex_t qAtomicMutex = PTHREAD_MUTEX_INITIALIZER;
-
-static void report_error(int code, const char *where, const char *what)
-{
- if (code != 0)
- qWarning("%s: %s failure: %d", where, what, code);
-}
-
-
-QMutexPrivate::QMutexPrivate()
- : contenders(0), wakeup(FALSE)
-{
- report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init");
- report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init");
-}
-
-QMutexPrivate::~QMutexPrivate()
-{
- report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy");
- report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy");
-}
-
-void QMutexPrivate::wait()
-{
- report_error(pthread_mutex_lock(&mutex), "QMutex::lock", "mutex lock");
- int errorCode = 0;
- while (!wakeup)
- {
- errorCode = pthread_cond_wait(&cond, &mutex);
- if (errorCode)
- {
- report_error(errorCode, "QMutex::lock()", "cv wait");
- }
- }
- wakeup = FALSE;
- report_error(pthread_mutex_unlock(&mutex), "QMutex::lock", "mutex unlock");
-}
-
-void QMutexPrivate::wakeUp()
-{
- report_error(pthread_mutex_lock(&mutex), "QMutex::unlock", "mutex lock");
- wakeup = TRUE;
- report_error(pthread_cond_signal(&cond), "QMutex::unlock", "cv signal");
- report_error(pthread_mutex_unlock(&mutex), "QMutex::unlock", "mutex unlock");
-}
-
-bool QAtomicInt::testAndSet(int expectedValue,int newValue)
-{
- bool returnValue = false;
- pthread_mutex_lock(&qAtomicMutex);
- if (m_value == expectedValue)
- {
- m_value = newValue;
- returnValue = true;
- }
- pthread_mutex_unlock(&qAtomicMutex);
- return returnValue;
-}
-
-int QAtomicInt::fetchAndAdd(int valueToAdd)
-{
- int returnValue;
- pthread_mutex_lock(&qAtomicMutex);
- returnValue = m_value;
- m_value += valueToAdd;
- pthread_mutex_unlock(&qAtomicMutex);
- return returnValue;
-}
-
diff --git a/qtools/qmutex_win32.cpp b/qtools/qmutex_win32.cpp
deleted file mode 100644
index 2d662ea..0000000
--- a/qtools/qmutex_win32.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <windows.h>
-
-#include "qmutex.h"
-#include "qmutex_p.h"
-
-QMutexPrivate::QMutexPrivate()
- : contenders(0)
-{
- event = CreateEvent(0, FALSE, FALSE, 0);
- if (!event)
- qWarning("QMutexPrivate::QMutexPrivate: Cannot create event");
-}
-
-QMutexPrivate::~QMutexPrivate()
-{
- CloseHandle(event);
-}
-
-void QMutexPrivate::wait()
-{
- WaitForSingleObject(event, INFINITE);
-}
-
-void QMutexPrivate::wakeUp()
-{
- SetEvent(event);
-}
-
-//----------------------------------------------------------------------
-
-class QCriticalSection
-{
- public:
- QCriticalSection() { InitializeCriticalSection(&section); }
- ~QCriticalSection() { DeleteCriticalSection(&section); }
- void lock() { EnterCriticalSection(&section); }
- void unlock() { LeaveCriticalSection(&section); }
-
- private:
- CRITICAL_SECTION section;
-};
-
-static QCriticalSection qAtomicCriticalSection;
-
-bool QAtomicInt::testAndSet(int expectedValue,int newValue)
-{
- bool returnValue = false;
- qAtomicCriticalSection.lock();
- if (m_value == expectedValue)
- {
- m_value = newValue;
- returnValue = true;
- }
- qAtomicCriticalSection.unlock();
- return returnValue;
-}
-
-int QAtomicInt::fetchAndAdd(int valueToAdd)
-{
- int returnValue;
- qAtomicCriticalSection.lock();
- returnValue = m_value;
- m_value += valueToAdd;
- qAtomicCriticalSection.unlock();
- return returnValue;
-}
-
diff --git a/qtools/qptrdict.h b/qtools/qptrdict.h
index c075e30..df8bcb4 100644
--- a/qtools/qptrdict.h
+++ b/qtools/qptrdict.h
@@ -46,7 +46,7 @@
template<class type> class Q_EXPORT QPtrDict : public QGDict
{
public:
- QPtrDict(int size=17) : QGDict(size,PtrKey,0,0) {}
+ QPtrDict(uint size=17) : QGDict(size,PtrKey,0,0) {}
QPtrDict( const QPtrDict<type> &d ) : QGDict(d) {}
~QPtrDict() { clear(); }
QPtrDict<type> &operator=(const QPtrDict<type> &d)
diff --git a/qtools/qstring.h b/qtools/qstring.h
index d459132..293768f 100644
--- a/qtools/qstring.h
+++ b/qtools/qstring.h
@@ -147,8 +147,8 @@ public:
QString decomposition() const;
Decomposition decompositionTag() const;
- char latin1() const { return rw ? 0 : cl; }
- ushort unicode() const { return (rw << 8) | cl; }
+ char latin1() const { return rw ? 0 : (char)cl; }
+ ushort unicode() const { return (ushort)((rw << 8) | cl); }
#ifndef QT_NO_CAST_ASCII
// like all ifdef'd code this is undocumented
operator char() const { return latin1(); }
@@ -333,7 +333,7 @@ struct Q_EXPORT QStringData : public QShared {
QStringData() :
unicode(0), ascii(0), len(0), maxl(0), dirtyascii(0) { ref(); }
QStringData(QChar *u, uint l, uint m) :
- unicode(u), ascii(0), len(l), maxl(m), dirtyascii(0) { }
+ unicode(u), ascii(0), len(l), maxl(m&0x3FFFFFFF), dirtyascii(0) { }
~QStringData() { if ( unicode ) delete[] ((char*)unicode);
if ( ascii ) delete[] ascii; }
diff --git a/qtools/qtextcodec.cpp b/qtools/qtextcodec.cpp
index 8ce266d..13c3d51 100644
--- a/qtools/qtextcodec.cpp
+++ b/qtools/qtextcodec.cpp
@@ -1,5 +1,5 @@
/****************************************************************************
-**
+**
**
** Implementation of QTextCodec class
**
diff --git a/qtools/qthread.cpp b/qtools/qthread.cpp
deleted file mode 100644
index 02c99f2..0000000
--- a/qtools/qthread.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qthread.h"
-#include "qthread_p.h"
-
-QThread::QThread()
- : d(new QThreadPrivate)
-{
-}
-
-QThread::~QThread()
-{
- QMutexLocker locker(&d->mutex);
- if (d->running && !d->finished)
- qWarning("QThread: Destroyed while thread is still running");
- delete d;
-}
-
-bool QThread::isFinished() const
-{
- QMutexLocker locker(&d->mutex);
- return d->finished;
-}
-
-bool QThread::isRunning() const
-{
- QMutexLocker locker(&d->mutex);
- return d->running;
-}
-
-void QThread::setStackSize(unsigned int stackSize)
-{
- QMutexLocker locker(&d->mutex);
- if (d->running)
- {
- qWarning("QThread: Cannot change stack size while thread is running!");
- return;
- }
- d->stackSize = stackSize;
-}
-
-unsigned int QThread::stackSize() const
-{
- QMutexLocker locker(&d->mutex);
- return d->stackSize;
-}
-
diff --git a/qtools/qthread.h b/qtools/qthread.h
deleted file mode 100644
index 81868bd..0000000
--- a/qtools/qthread.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTHREAD_H
-#define QTHREAD_H
-
-class QThreadPrivate;
-
-class QThread
-{
- public:
- explicit QThread();
- virtual ~QThread();
-
- bool isFinished() const;
- bool isRunning() const;
-
- void start();
- void terminate();
- void wait();
- void setStackSize(unsigned int stackSize);
- unsigned int stackSize() const;
- static int idealThreadCount();
-
-protected:
- // events
- virtual void started() {}
- virtual void finished() {}
- virtual void terminated() {}
-
- // main loop
- virtual void run() {}
-
-private:
- QThreadPrivate *d;
- friend class QThreadPrivate;
-};
-
-#endif // QTHREAD_H
diff --git a/qtools/qthread_p.h b/qtools/qthread_p.h
deleted file mode 100644
index 87692aa..0000000
--- a/qtools/qthread_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTHREAD_P_H
-#define QTHREAD_P_H
-
-#include "qglobal.h"
-
-#if defined(_OS_UNIX_) || defined(_OS_MAC_)
-#include <pthread.h>
-#elif defined(_OS_WIN32_)
-#include <windows.h>
-#endif
-
-#include "qthread.h"
-#include "qmutex.h"
-#include "qwaitcondition.h"
-
-class QThreadPrivate
-{
-public:
- QThreadPrivate();
- ~QThreadPrivate();
-
- mutable QMutex mutex;
-
- bool running;
- bool finished;
- bool terminated;
- uint stackSize;
-
-#if defined(_OS_UNIX_) || defined(_OS_MAC_)
- pthread_t thread_id;
- QWaitCondition thread_done;
- static void *start(void *arg);
- static void finish(void *arg);
-#elif defined(_OS_WIN32_)
- HANDLE handle;
- static unsigned int __stdcall start(void *);
- static void finish(void *,bool lockAnyway=TRUE);
- int waiters;
-#else
-#error "unsupported platform!"
-#endif
-};
-
-#endif // QTHREAD_P_H
diff --git a/qtools/qthread_unix.cpp b/qtools/qthread_unix.cpp
deleted file mode 100644
index 5871605..0000000
--- a/qtools/qthread_unix.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qglobal.h"
-
-#if defined(_OS_HPUX_)
-#include <sys/pstat.h>
-#elif defined(_OS_MAC_)
-#undef DEBUG
-#include <CoreServices/CoreServices.h>
-#elif defined(_OS_BSDI_)
-#include <mach/mach_types.h>
-#include <sys/systm.h>
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#endif
-#include <signal.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#include "qthread.h"
-#include "qthread_p.h"
-
-
-/**************************************************************************
- ** QThreadPrivate
- *************************************************************************/
-
-QThreadPrivate::QThreadPrivate() :
- running(FALSE), finished(FALSE), terminated(FALSE), stackSize(0)
-{
- thread_id = 0;
-}
-
-QThreadPrivate::~QThreadPrivate()
-{
-}
-
-void *QThreadPrivate::start(void *arg)
-{
-#ifndef __ANDROID__
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
-#endif
- pthread_cleanup_push(QThreadPrivate::finish, arg);
-
- QThread *thr = reinterpret_cast<QThread *>(arg);
-
- thr->started();
-#ifndef __ANDROID__
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- pthread_testcancel();
-#endif
- thr->run();
-
- pthread_cleanup_pop(1);
- return 0;
-}
-
-void QThreadPrivate::finish(void *arg)
-{
- QThread *thr = reinterpret_cast<QThread *>(arg);
- QThreadPrivate *d = thr->d;
- QMutexLocker locker(&d->mutex);
-
- d->running = FALSE;
- d->finished = TRUE;
- if (d->terminated)
- thr->terminated();
- d->terminated = FALSE;
- thr->finished();
-
- d->thread_id = 0;
- d->thread_done.wakeAll();
-}
-
-
-
-
-/**************************************************************************
- ** QThread
- *************************************************************************/
-
-void QThread::start()
-{
- QMutexLocker locker(&d->mutex);
- if (d->running) return;
-
- // Block the SIGINT signal. The threads will inherit the signal mask.
- // This will avoid them catching SIGINT instead of this thread.
- sigset_t sigset, oldset;
- sigemptyset(&sigset);
- sigaddset(&sigset, SIGINT);
- pthread_sigmask(SIG_BLOCK, &sigset, &oldset);
-
- d->running = TRUE;
- d->finished = FALSE;
-
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
-#ifndef __ANDROID__
- pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
-#endif
- if (d->stackSize>0)
- {
-#if defined(_POSIX_THREAD_ATTR_STACKSIZE) && (_POSIX_THREAD_ATTR_STACKSIZE-0>0)
- pthread_attr_setstacksize(&attr,d->stackSize);
-#endif
- }
- int code = pthread_create(&d->thread_id, &attr, QThreadPrivate::start, this);
- pthread_attr_destroy(&attr);
-
- if (code)
- {
- qWarning("QThread::start: Thread creation error: %d", code);
-
- d->running = FALSE;
- d->finished = FALSE;
- d->thread_id = 0;
- }
- else
- {
- // Restore the old signal mask only for this thread.
- pthread_sigmask(SIG_SETMASK, &oldset, NULL);
- }
-}
-
-void QThread::terminate()
-{
- QMutexLocker locker(&d->mutex);
-#ifndef __ANDROID__
- if (!d->thread_id) return;
-
- int code = pthread_cancel(d->thread_id);
- if (code)
- {
- qWarning("QThread::start: Thread termination error: %d", code);
- }
- else
- {
- d->terminated = TRUE;
- }
-#endif
-}
-
-void QThread::wait()
-{
- QMutexLocker locker(&d->mutex);
- if (d->finished || !d->running) return;
-
- while (d->running)
- {
- d->thread_done.wait(locker.mutex());
- }
-}
-
-#if defined(QT_LINUXBASE) && !defined(_SC_NPROCESSORS_ONLN)
-// LSB doesn't define _SC_NPROCESSORS_ONLN.
-# define _SC_NPROCESSORS_ONLN 84
-#endif
-
-int QThread::idealThreadCount()
-{
- int cores = -1;
-#if defined(_OS_MAC_)
- // Mac OS X
- cores = (int)MPProcessorsScheduled();
-#elif defined(_OS_HPUX_)
- // HP-UX
- struct pst_dynamic psd;
- if (pstat_getdynamic(&psd, sizeof(psd), 1, 0) == -1)
- {
- perror("pstat_getdynamic");
- cores = -1;
- }
- else
- {
- cores = (int)psd.psd_proc_cnt;
- }
-#elif defined(_OS_BSDI_)
- // FreeBSD, OpenBSD, NetBSD, BSD/OS
- size_t len = sizeof(cores);
- int mib[2];
- mib[0] = CTL_HW;
- mib[1] = HW_NCPU;
-
- if (sysctl(mib, 2, &cores, &len, NULL, 0) != 0)
- {
- perror("sysctl");
- cores = -1;
- }
-#elif defined(_OS_IRIX_)
- // IRIX
- cores = (int)sysconf(_SC_NPROC_ONLN);
-#else
- // the rest: Linux, Solaris, AIX, Tru64
- cores = (int)sysconf(_SC_NPROCESSORS_ONLN);
-#endif
- return cores;
-}
-
diff --git a/qtools/qthread_win32.cpp b/qtools/qthread_win32.cpp
deleted file mode 100644
index 2c62e93..0000000
--- a/qtools/qthread_win32.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qthread.h"
-#include "qthread_p.h"
-
-/**************************************************************************
- ** QThreadPrivate
- *************************************************************************/
-
-QThreadPrivate::QThreadPrivate() :
- running(FALSE), finished(FALSE), terminated(FALSE), stackSize(0)
-{
- handle = NULL;
- waiters = 0;
-}
-
-QThreadPrivate::~QThreadPrivate()
-{
-}
-
-unsigned int __stdcall QThreadPrivate::start(void *arg)
-{
- QThread *thr = reinterpret_cast<QThread *>(arg);
- thr->started();
- thr->run();
- finish(arg);
- return 0;
-}
-
-void QThreadPrivate::finish(void *arg,bool lockAnyway)
-{
- QThread *thr = reinterpret_cast<QThread *>(arg);
- QThreadPrivate *d = thr->d;
-
- if (lockAnyway) d->mutex.lock();
-
- d->running = FALSE;
- d->finished = TRUE;
- if (d->terminated) thr->terminated();
- d->terminated = FALSE;
- thr->finished();
-
- if (!d->waiters)
- {
- CloseHandle(d->handle);
- d->handle = 0;
- }
-
- if (lockAnyway) d->mutex.unlock();
-}
-
-/**************************************************************************
- ** QThread
- *************************************************************************/
-
-void QThread::start()
-{
- QMutexLocker locker(&d->mutex);
-
- if (d->running) return;
-
- d->running = TRUE;
- d->finished = FALSE;
- d->terminated = FALSE;
-
- d->handle = CreateThread(NULL,d->stackSize,
- (LPTHREAD_START_ROUTINE)QThreadPrivate::start,this,0,NULL);
-
- if (!d->handle)
- {
- qWarning("QThread::start: Failed to create thread: errno=%d",errno);
- d->running = FALSE;
- d->finished = TRUE;
- return;
- }
-}
-
-void QThread::terminate()
-{
- QMutexLocker locker(&d->mutex);
- if (!d->running) return;
- TerminateThread(d->handle, 0);
- d->terminated = TRUE;
- QThreadPrivate::finish(this);
-}
-
-void QThread::wait()
-{
- QMutexLocker locker(&d->mutex);
- if (d->finished || !d->running) return;
-
- ++d->waiters;
- locker.mutex()->unlock();
-
- WaitForSingleObject(d->handle,INFINITE);
-
- locker.mutex()->lock();
- --d->waiters;
- if (!d->finished) // thread was terminated by someone else
- {
- d->terminated = TRUE;
- QThreadPrivate::finish(this);
- }
-
- if (d->finished && d->waiters)
- {
- CloseHandle(d->handle);
- d->handle = 0;
- }
-}
-
-int QThread::idealThreadCount()
-{
- SYSTEM_INFO sysinfo;
- GetSystemInfo(&sysinfo);
- return sysinfo.dwNumberOfProcessors;
-}
-
-
diff --git a/qtools/qtools.pro.in b/qtools/qtools.pro.in
index ba8a086..21d26cc 100644
--- a/qtools/qtools.pro.in
+++ b/qtools/qtools.pro.in
@@ -44,12 +44,7 @@ HEADERS = qarray.h \
qvaluestack.h \
qmap.h \
qmodules.h \
- qthread.h \
- qthread_p.h \
- qmutex.h \
- qmutex_p.h \
- qutfcodec.h \
- qwaitcondition.h
+ qutfcodec.h
SOURCES = qbuffer.cpp \
qcollection.cpp \
@@ -74,23 +69,15 @@ SOURCES = qbuffer.cpp \
qstringlist.cpp \
qxml.cpp \
qmap.cpp \
- qthread.cpp \
- qmutex.cpp \
qutfcodec.cpp
unix:SOURCES += qfile_unix.cpp \
qdir_unix.cpp \
- qfileinfo_unix.cpp \
- qthread_unix.cpp \
- qmutex_unix.cpp \
- qwaitcondition_unix.cpp
+ qfileinfo_unix.cpp
win32:SOURCES += qfile_win32.cpp \
qdir_win32.cpp \
- qfileinfo_win32.cpp \
- qthread_win32.cpp \
- qmutex_win32.cpp \
- qwaitcondition_win32.cpp
+ qfileinfo_win32.cpp
INCLUDEPATH = .
#TMAKE_CXXFLAGS += -DQT_NO_CODECS -DQT_LITE_UNICODE
diff --git a/qtools/qvaluelist.h b/qtools/qvaluelist.h
index a1014ed..eb827fe 100644
--- a/qtools/qvaluelist.h
+++ b/qtools/qvaluelist.h
@@ -43,10 +43,6 @@
#include "qdatastream.h"
#endif // QT_H
-#if defined(_CC_MSVC_)
-#pragma warning(disable:4284) // "return type for operator -> is not a UDT"
-#endif
-
template <class T>
class Q_EXPORT QValueListNode
{
diff --git a/qtools/qwaitcondition.h b/qtools/qwaitcondition.h
deleted file mode 100644
index 4d5b3bd..0000000
--- a/qtools/qwaitcondition.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWAITCONDITION_H
-#define QWAITCONDITION_H
-
-#include "qglobal.h"
-
-class QWaitConditionPrivate;
-class QMutex;
-
-class QWaitCondition
-{
-public:
- QWaitCondition();
- ~QWaitCondition();
-
- void wait(QMutex *mutex);
-
- void wakeOne();
- void wakeAll();
-
-private:
- QWaitCondition(const QWaitCondition &);
- QWaitCondition &operator=(const QWaitCondition &);
-
- QWaitConditionPrivate * d;
-};
-
-#endif // QWAITCONDITION_H
diff --git a/qtools/qwaitcondition_unix.cpp b/qtools/qwaitcondition_unix.cpp
deleted file mode 100644
index 0a6a09b..0000000
--- a/qtools/qwaitcondition_unix.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwaitcondition.h"
-#include "qmutex.h"
-#include <pthread.h>
-
-#define MIN(a,b) ((a)<(b)?(a):(b))
-
-static void report_error(int code, const char *where, const char *what)
-{
- if (code != 0)
- qWarning("%s: %s failure: %d", where, what, code);
-}
-
-class QWaitConditionPrivate
-{
- public:
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- int waiters;
- int wakeups;
-
- void wait()
- {
- int code;
- for (;;)
- {
- code = pthread_cond_wait(&cond, &mutex);
- if (code == 0 && wakeups == 0)
- {
- // many vendors warn of spurious wakeups from
- // pthread_cond_wait(), especially after signal delivery,
- // even though POSIX doesn't allow for it... sigh
- continue;
- }
- break;
- }
-
- --waiters;
- if (code == 0)
- {
- --wakeups;
- }
- else
- {
- report_error(code, "QWaitCondition::wait()", "cv wait");
- }
- report_error(pthread_mutex_unlock(&mutex), "QWaitCondition::wait()", "mutex unlock");
- }
-};
-
-
-QWaitCondition::QWaitCondition()
-{
- d = new QWaitConditionPrivate;
- report_error(pthread_mutex_init(&d->mutex, NULL), "QWaitCondition", "mutex init");
- report_error(pthread_cond_init(&d->cond, NULL), "QWaitCondition", "cv init");
- d->waiters = d->wakeups = 0;
-}
-
-
-QWaitCondition::~QWaitCondition()
-{
- report_error(pthread_cond_destroy(&d->cond), "QWaitCondition", "cv destroy");
- report_error(pthread_mutex_destroy(&d->mutex), "QWaitCondition", "mutex destroy");
- delete d;
-}
-
-void QWaitCondition::wakeOne()
-{
- report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wakeOne()", "mutex lock");
- d->wakeups = MIN(d->wakeups + 1, d->waiters);
- report_error(pthread_cond_signal(&d->cond), "QWaitCondition::wakeOne()", "cv signal");
- report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeOne()", "mutex unlock");
-}
-
-void QWaitCondition::wakeAll()
-{
- report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wakeAll()", "mutex lock");
- d->wakeups = d->waiters;
- report_error(pthread_cond_broadcast(&d->cond), "QWaitCondition::wakeAll()", "cv broadcast");
- report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeAll()", "mutex unlock");
-}
-
-void QWaitCondition::wait(QMutex *mutex)
-{
- if (!mutex) return;
-
- report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wait()", "mutex lock");
- ++d->waiters;
- mutex->unlock();
- d->wait();
- mutex->lock();
-}
-
diff --git a/qtools/qwaitcondition_win32.cpp b/qtools/qwaitcondition_win32.cpp
deleted file mode 100644
index 80b7b67..0000000
--- a/qtools/qwaitcondition_win32.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** 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, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, 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.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <windows.h>
-#include "qwaitcondition.h"
-#include "qmutex.h"
-#include "qinternallist.h"
-
-//***********************************************************************
-// QWaitConditionPrivate
-// **********************************************************************
-
-class QWaitConditionEvent
-{
-public:
- QWaitConditionEvent() : priority(0), wokenUp(false)
- {
- event = CreateEvent(NULL, TRUE, FALSE, NULL);
- }
- ~QWaitConditionEvent() { CloseHandle(event); }
- int priority;
- bool wokenUp;
- HANDLE event;
-};
-
-class EventQueue : public QInternalList<QWaitConditionEvent>
-{
- public:
- EventQueue() { setAutoDelete(TRUE); }
- ~EventQueue() {}
-};
-
-class QWaitConditionPrivate
-{
-public:
- QMutex mtx;
- EventQueue queue;
- EventQueue freeQueue;
-
- QWaitConditionEvent *pre();
- void wait(QWaitConditionEvent *wce);
- void post(QWaitConditionEvent *wce);
-};
-
-QWaitConditionEvent *QWaitConditionPrivate::pre()
-{
- mtx.lock();
- QWaitConditionEvent *wce =
- freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.take(0);
- wce->priority = GetThreadPriority(GetCurrentThread());
- wce->wokenUp = FALSE;
-
- // insert 'wce' into the queue (sorted by priority)
- uint index = 0;
- for (; index < queue.count(); ++index)
- {
- QWaitConditionEvent *current = queue.at(index);
- if (current->priority < wce->priority)
- break;
- }
- queue.insert(index, wce);
- mtx.unlock();
-
- return wce;
-}
-
-void QWaitConditionPrivate::wait(QWaitConditionEvent *wce)
-{
- WaitForSingleObject(wce->event, INFINITE);
-}
-
-void QWaitConditionPrivate::post(QWaitConditionEvent *wce)
-{
- mtx.lock();
-
- // remove 'wce' from the queue
- int idx = queue.find(wce);
- ASSERT(idx!=-1);
- queue.take(idx);
- ResetEvent(wce->event);
- freeQueue.append(wce);
-
- // wakeups delivered after the timeout should be forwarded to the next waiter
- if (wce->wokenUp && !queue.isEmpty())
- {
- QWaitConditionEvent *other = queue.getFirst();
- SetEvent(other->event);
- other->wokenUp = TRUE;
- }
-
- mtx.unlock();
-}
-
-//***********************************************************************
-// QWaitCondition implementation
-//***********************************************************************
-
-QWaitCondition::QWaitCondition()
-{
- d = new QWaitConditionPrivate;
-}
-
-QWaitCondition::~QWaitCondition()
-{
- if (!d->queue.isEmpty())
- {
- qWarning("QWaitCondition: Destroyed while threads are still waiting");
- }
- delete d;
-}
-
-void QWaitCondition::wait(QMutex *mutex)
-{
- if (!mutex) return;
-
- QWaitConditionEvent *wce = d->pre();
- mutex->unlock();
- d->wait(wce);
- mutex->lock();
- d->post(wce);
-}
-
-void QWaitCondition::wakeOne()
-{
- // wake up the first waiting thread in the queue
- QMutexLocker locker(&d->mtx);
- for (uint i = 0; i < d->queue.count(); ++i)
- {
- QWaitConditionEvent *current = d->queue.at(i);
- if (current->wokenUp) continue;
- SetEvent(current->event);
- current->wokenUp = TRUE;
- break;
- }
-}
-
-void QWaitCondition::wakeAll()
-{
- // wake up the all threads in the queue
- QMutexLocker locker(&d->mtx);
- for (uint i = 0; i < d->queue.count(); ++i)
- {
- QWaitConditionEvent *current = d->queue.at(i);
- SetEvent(current->event);
- current->wokenUp = TRUE;
- }
-}
-