+++ /dev/null
-{
- extern "C" {
- "qt_startup_hook";
- "qt_addObject";
- "qt_removeObject";
- };
- extern "C++" {
- "QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>)";
- };
-};
#include <langinfo.h>
#endif
-#if defined(Q_OS_WINCE)
-# define QT_NO_SETLOCALE
-#endif
-
-
-
// enabling this is not exception safe!
// #define Q_DEBUG_TEXTCODEC
static QTextCodec * ru_RU_hack(const char * i) {
QTextCodec * ru_RU_codec = 0;
-#if !defined(QT_NO_SETLOCALE)
- QByteArray origlocale(setlocale(LC_CTYPE, i));
-#else
- QByteArray origlocale(i);
-#endif
+ const QByteArray origlocale(setlocale(LC_CTYPE, i));
// unicode koi8r latin5 name
// 0x044E 0xC0 0xEE CYRILLIC SMALL LETTER YU
// 0x042E 0xE0 0xCE CYRILLIC CAPITAL LETTER YU
qWarning("QTextCodec: Using KOI8-R, probe failed (%02x %02x %s)",
koi8r, latin5, i);
}
-#if !defined(QT_NO_SETLOCALE)
setlocale(LC_CTYPE, origlocale);
-#endif
return ru_RU_codec;
}
// First part is getting that locale name. First try setlocale() which
// definitely knows it, but since we cannot fully trust it, get ready
// to fall back to environment variables.
-#if !defined(QT_NO_SETLOCALE)
const QByteArray ctype = setlocale(LC_CTYPE, 0);
-#else
- const QByteArray ctype;
-#endif
// Get the first nonempty value from $LC_ALL, $LC_CTYPE, and $LANG
// environment variables.
# endif // Q_WS_X11
-#if !defined(Q_OS_INTEGRITY)
# if defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED) && !defined(QT_CODEC_PLUGINS)
// no asian codecs when bootstrapping, sorry
(void)new QGb18030Codec;
(void)new QBig5Codec;
(void)new QBig5hkscsCodec;
# endif // QT_NO_ICONV && !QT_BOOTSTRAPPED && !QT_CODEC_PLUGINS
-#endif //Q_OS_INTEGRITY
#endif // QT_NO_CODECS
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- (void) new QWindowsLocalCodec;
-#endif // Q_OS_WIN32
-
(void)new QUtf16Codec;
(void)new QUtf16BECodec;
(void)new QUtf16LECodec;
(void)new QLatin1Codec;
(void)new QUtf8Codec;
-#if !defined(Q_OS_INTEGRITY) && defined(Q_OS_UNIX) && !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
+#if !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
// QIconvCodec depends on the UTF-16 codec, so it needs to be created last
(void) new QIconvCodec();
#endif
#ifndef QT_NO_TEXTCODEC
#include "qtextcodec.h"
#endif
-#ifndef Q_OS_WINCE
#include <locale.h>
-#endif
#include "qlocale_p.h"
#include <stdlib.h>
// read raw data into a temporary buffer
char buf[QTEXTSTREAM_BUFFERSIZE];
qint64 bytesRead = 0;
-#if defined(Q_OS_WIN)
- // On Windows, there is no non-blocking stdin - so we fall back to reading
- // lines instead. If there is no QOBJECT, we read lines for all sequential
- // devices; otherwise, we read lines only for stdin.
- QFile *file = 0;
- Q_UNUSED(file);
- if (device->isSequential()
-#if !defined(QT_NO_QOBJECT)
- && (file = qobject_cast<QFile *>(device)) && file->handle() == 0
-#endif
- ) {
- if (maxBytes != -1)
- bytesRead = device->readLine(buf, qMin<qint64>(sizeof(buf), maxBytes));
- else
- bytesRead = device->readLine(buf, sizeof(buf));
- } else
-#endif
- {
- if (maxBytes != -1)
- bytesRead = device->read(buf, qMin<qint64>(sizeof(buf), maxBytes));
- else
- bytesRead = device->read(buf, sizeof(buf));
- }
+ if (maxBytes != -1)
+ bytesRead = device->read(buf, qMin<qint64>(sizeof(buf), maxBytes));
+ else
+ bytesRead = device->read(buf, sizeof(buf));
#ifndef QT_NO_TEXTCODEC
// codec auto detection, explicitly defaults to locale encoding if the
if (writeBuffer.isEmpty())
return;
-#if defined (Q_OS_WIN)
- // handle text translation and bypass the Text flag in the device.
- bool textModeEnabled = device->isTextModeEnabled();
- if (textModeEnabled) {
- device->setTextModeEnabled(false);
- writeBuffer.replace(QLatin1Char('\n'), QLatin1String("\r\n"));
- }
-#endif
-
#ifndef QT_NO_TEXTCODEC
if (!codec)
codec = QTextCodec::codecForLocale();
return;
}
-#if defined (Q_OS_WIN)
- // replace the text flag
- if (textModeEnabled)
- device->setTextModeEnabled(true);
-#endif
-
// flush the file
#ifndef QT_NO_QOBJECT
QFile *file = qobject_cast<QFile *>(device);
#include "qthread_p.h"
#include "qcoreapplication_p.h"
-/*
-#ifdef Q_OS_WIN32
-# include "qt_windows.h"
-#else
-# include <unistd.h>
-# include <netinet/in.h>
-# include <sys/utsname.h>
-# include <sys/socket.h>
-*/
-/*
-# elif defined(Q_OS_HPUX)
-# include <sys/pstat.h>
-# elif defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD) || defined(Q_OS_MAC)
-# include <sys/sysctl.h>
-# endif
-#endif
-*/
-
QT_BEGIN_NAMESPACE
/*
isInFinish(false), exited(false), returnCode(-1),
stackSize(0), priority(QThread::InheritPriority), data(d)
{
-#if defined (Q_OS_UNIX)
- thread_id = 0;
-#elif defined (Q_WS_WIN)
- handle = 0;
- id = 0;
- waiters = 0;
-#endif
-#if defined (Q_WS_WIN)
- terminationEnabled = true;
- terminatePending = false;
-#endif
-
if (!data)
data = new QThreadData;
}
class Q_CORE_EXPORT QThread : public QObject
{
public:
- static Qt::HANDLE currentThreadId();
static QThread *currentThread();
+ static Qt::HANDLE currentThreadId();
static int idealThreadCount();
static void yieldCurrentThread();
class Q_CORE_EXPORT QThread : public QObject
{
public:
- static Qt::HANDLE currentThreadId() { return Qt::HANDLE(currentThread()); }
static QThread* currentThread();
-
+ static inline Qt::HANDLE currentThreadId()
+ { return Qt::HANDLE(currentThread()); }
+
protected:
QThread(QThreadPrivate &dd, QObject *parent = 0);
static QThread *threadForId(int id);
-#ifdef Q_OS_UNIX
pthread_t thread_id;
QWaitCondition thread_done;
static void *start(void *arg);
static void finish(void *);
-#endif // Q_OS_UNIX
-
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- HANDLE handle;
- unsigned int id;
- int waiters;
-
- static unsigned int __stdcall start(void *);
- static void finish(void *, bool lockAnyway=true);
-#endif // Q_OS_WIN32
-
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
- bool terminationEnabled, terminatePending;
-# endif
QThreadData *data;
static void createEventDispatcher(QThreadData *data);
#ifndef QT_NO_THREAD
-#if (defined(Q_OS_LINUX) || (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) || defined(Q_OS_QNX))
+#if defined(Q_OS_LINUX)
static void setCurrentThreadName(pthread_t threadId, const char *name)
{
-# if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
+#if defined(Q_OS_LINUX) && !defined(QT_LINUXBASE)
Q_UNUSED(threadId);
prctl(PR_SET_NAME, (unsigned long)name, 0, 0, 0);
-# elif (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
- Q_UNUSED(threadId);
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6)
- pthread_setname_np(name);
-# elif defined(Q_OS_QNX)
- pthread_setname_np(threadId, name);
-# endif
+#endif
}
#endif
// ### TODO: allow the user to create a custom event dispatcher
createEventDispatcher(data);
-#if (defined(Q_OS_LINUX) || (defined(Q_OS_MAC) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6) || defined(Q_OS_QNX))
+#if defined(Q_OS_LINUX)
// sets the name of the current thread.
QString objectName = thr->objectName();
{
int cores = -1;
-#if defined(Q_OS_MAC)
- // Mac OS X
- cores = MPProcessorsScheduled();
-#elif defined(Q_OS_HPUX)
+#if defined(Q_OS_HPUX)
// HP-UX
struct pst_dynamic psd;
if (pstat_getdynamic(&psd, sizeof(psd), 1, 0) == -1) {
#elif defined(Q_OS_IRIX)
// IRIX
cores = (int)sysconf(_SC_NPROC_ONLN);
-#elif defined(Q_OS_INTEGRITY)
-#if (__INTEGRITY_MAJOR_VERSION >= 10)
- // Integrity V10+ does support multicore CPUs
- Value processorCount;
- if (GetProcessorCount(CurrentTask(), &processorCount) == 0)
- cores = processorCount;
- else
-#endif
- cores = 1;
-#elif defined(Q_OS_VXWORKS)
- // VxWorks
-# if defined(QT_VXWORKS_HAS_CPUSET)
- cpuset_t cpus = vxCpuEnabledGet();
- cores = 0;
-
- // 128 cores should be enough for everyone ;)
- for (int i = 0; i < 128 && !CPUSET_ISZERO(cpus); ++i) {
- if (CPUSET_ISSET(cpus, i)) {
- CPUSET_CLR(cpus, i);
- cores++;
- }
- }
-# else
- // as of aug 2008 VxWorks < 6.6 only supports one single core CPU
- cores = 1;
-# endif
#else
// the rest: Linux, Solaris, AIX, Tru64
cores = (int)sysconf(_SC_NPROCESSORS_ONLN);
// sched_priority is OUT only
static bool calculateUnixPriority(int priority, int *sched_policy, int *sched_priority)
{
-#ifdef Q_OS_QNX
- // without Round Robin drawn intensive apps will hog the cpu
- // and make the system appear frozen
- *sched_policy = SCHED_RR;
-#endif
#ifdef SCHED_IDLE
if (priority == QThread::IdlePriority) {
*sched_policy = SCHED_IDLE;
#endif
const int highestPriority = QThread::TimeCriticalPriority;
- int prio_min;
- int prio_max;
-#if defined(Q_OS_VXWORKS) && defined(VXWORKS_DKM)
- // for other scheduling policies than SCHED_RR or SCHED_FIFO
- prio_min = SCHED_FIFO_LOW_PRI;
- prio_max = SCHED_FIFO_HIGH_PRI;
-
- if ((*sched_policy == SCHED_RR) || (*sched_policy == SCHED_FIFO))
-#endif
- {
- prio_min = sched_get_priority_min(*sched_policy);
- prio_max = sched_get_priority_max(*sched_policy);
- }
-
+ const int prio_min = sched_get_priority_min(*sched_policy);
+ const int prio_max = sched_get_priority_max(*sched_policy);
if (prio_min == -1 || prio_max == -1)
return false;