From c48a31d94f5a5dc84ed337414bc6e2efeb1fafb6 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Sun, 5 Aug 2012 20:59:41 +0100 Subject: Unify the "#if (!)defined" handling into "#if(n)def" Change-Id: I580a62dd52b4151f511042f7a382d9a4c1532fc9 Reviewed-by: Denis Shienkov --- examples/terminal/settingsdialog.cpp | 2 +- src/serialport.cpp | 10 +-- src/serialportengine_p.h | 4 +- src/serialportengine_symbian.cpp | 6 +- src/serialportengine_unix.cpp | 116 +++++++++++++++++------------------ src/serialportengine_unix_p.h | 6 +- src/serialportengine_win.cpp | 80 ++++++++++++------------ src/serialportengine_win_p.h | 14 ++--- src/serialportinfo_symbian.cpp | 6 +- src/serialportinfo_unix.cpp | 4 +- src/serialportinfo_win.cpp | 8 +-- src/ttylocker_unix.cpp | 8 +-- 12 files changed, 132 insertions(+), 132 deletions(-) diff --git a/examples/terminal/settingsdialog.cpp b/examples/terminal/settingsdialog.cpp index 9609e51..c045d4d 100644 --- a/examples/terminal/settingsdialog.cpp +++ b/examples/terminal/settingsdialog.cpp @@ -134,7 +134,7 @@ void SettingsDialog::fillPortsParameters() // fill stop bits ui->stopBitsBox->addItem(QLatin1String("1"), SerialPort::OneStop); -#if defined (Q_OS_WIN) +#ifdef Q_OS_WIN ui->stopBitsBox->addItem(QLatin1String("1.5"), SerialPort::OneAndHalfStop); #endif ui->stopBitsBox->addItem(QLatin1String("2"), SerialPort::TwoStop); diff --git a/src/serialport.cpp b/src/serialport.cpp index 1ec7ed1..ab089b3 100755 --- a/src/serialport.cpp +++ b/src/serialport.cpp @@ -206,7 +206,7 @@ bool SerialPortPrivate::canReadNotification() { Q_Q(SerialPort); -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE engine->lockNotification(SerialPortEngine::CanReadLocker, true); #endif // Prevent recursive calls. @@ -277,11 +277,11 @@ bool SerialPortPrivate::canReadNotification() */ bool SerialPortPrivate::canWriteNotification() { -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE engine->lockNotification(SerialPortEngine::CanWriteLocker, true); #endif -#if defined (Q_OS_WIN) +#ifdef Q_OS_WIN if (engine->isWriteNotificationEnabled()) engine->setWriteNotificationEnabled(false); #endif @@ -289,7 +289,7 @@ bool SerialPortPrivate::canWriteNotification() const int tmp = writeBuffer.size(); flush(); -#if defined (Q_OS_WIN) +#ifdef Q_OS_WIN if (!writeBuffer.isEmpty()) engine->setWriteNotificationEnabled(true); #else @@ -307,7 +307,7 @@ bool SerialPortPrivate::canWriteNotification() */ bool SerialPortPrivate::canErrorNotification() { -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE engine->lockNotification(SerialPortEngine::CanErrorLocker, true); #endif return engine->processIOErrors(); diff --git a/src/serialportengine_p.h b/src/serialportengine_p.h index f198e30..32cbb08 100755 --- a/src/serialportengine_p.h +++ b/src/serialportengine_p.h @@ -51,7 +51,7 @@ class SerialPortEngine { public: -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE // FIXME // Only for WinCE. enum NotificationLockerType { @@ -105,7 +105,7 @@ public: virtual bool processIOErrors() = 0; -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE // FIXME virtual void lockNotification(NotificationLockerType type, bool uselocker) = 0; virtual void unlockNotification(NotificationLockerType type) = 0; diff --git a/src/serialportengine_symbian.cpp b/src/serialportengine_symbian.cpp index dc8379a..2b2dcdf 100755 --- a/src/serialportengine_symbian.cpp +++ b/src/serialportengine_symbian.cpp @@ -72,7 +72,7 @@ #include // Physical device driver. -#if defined (__WINS__) +#ifdef __WINS__ _LIT(KPddName, "ECDRV"); #else // defined (__EPOC32__) _LIT(KPddName, "EUART"); @@ -92,7 +92,7 @@ _LIT(KACMModuleName, "ECACM"); static bool loadDevices() { TInt r = KErrNone; -#if defined (__WINS__) +#ifdef __WINS__ RFs fileServer; r = User::LeaveIfError(fileServer.Connect()); if (r != KErrNone) @@ -108,7 +108,7 @@ static bool loadDevices() if (r != KErrNone && r != KErrAlreadyExists) return false; //User::Leave(r); -#if !defined (__WINS__) +#ifndef __WINS__ r = StartC32(); if (r != KErrNone && r != KErrAlreadyExists) return false; //User::Leave(r); diff --git a/src/serialportengine_unix.cpp b/src/serialportengine_unix.cpp index 4297b61..e3e522d 100755 --- a/src/serialportengine_unix.cpp +++ b/src/serialportengine_unix.cpp @@ -79,7 +79,7 @@ #include #include -#if defined (Q_OS_MAC) +#ifdef Q_OS_MAC # if defined (MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4) # include # endif @@ -183,7 +183,7 @@ bool UnixSerialPortEngine::open(const QString &location, QIODevice::OpenMode mod } // Try set exclusive mode. -#if defined (TIOCEXCL) +#ifdef TIOCEXCL ::ioctl(m_descriptor, TIOCEXCL); #endif @@ -217,14 +217,14 @@ void UnixSerialPortEngine::close(const QString &location) // Restore saved port settings. if (dptr->options.restoreSettingsOnClose) { ::tcsetattr(m_descriptor, TCSANOW, &m_restoredTermios); -#if defined (Q_OS_LINUX) +#ifdef Q_OS_LINUX if (m_isCustomRateSupported) ::ioctl(m_descriptor, TIOCSSERIAL, &m_restoredSerialInfo); #endif } // Try clean exclusive mode. -#if defined (TIOCNXCL) +#ifdef TIOCNXCL ::ioctl(m_descriptor, TIOCNXCL); #endif @@ -273,45 +273,45 @@ SerialPort::Lines UnixSerialPortEngine::lines() const if (::ioctl(m_descriptor, TIOCMGET, &arg) == -1) return ret; -#if defined (TIOCLE) +#ifdef TIOCLE if (arg & TIOCLE) ret |= SerialPort::Le; #endif -#if defined (TIOCDTR) +#ifdef TIOCDTR if (arg & TIOCDTR) ret |= SerialPort::Dtr; #endif -#if defined (TIOCRTS) +#ifdef TIOCRTS if (arg & TIOCRTS) ret |= SerialPort::Rts; #endif -#if defined (TIOCST) +#ifdef TIOCST if (arg & TIOCST) ret |= SerialPort::St; #endif -#if defined (TIOCSR) +#ifdef TIOCSR if (arg & TIOCSR) ret |= SerialPort::Sr; #endif -#if defined (TIOCCTS) +#ifdef TIOCCTS if (arg & TIOCCTS) ret |= SerialPort::Cts; #endif -#if defined (TIOCCAR) +#ifdef TIOCCAR if (arg & TIOCCAR) ret |= SerialPort::Dcd; #elif defined (TIOCCD) if (arg & TIOCCD) ret |= SerialPort::Dcd; #endif -#if defined (TIOCRNG) +#ifdef TIOCRNG if (arg & TIOCRNG) ret |= SerialPort::Ri; #elif defined (TIOCRI) if (arg & TIOCRI) ret |= SerialPort::Ri; #endif -#if defined (TIOCDSR) +#ifdef TIOCDSR if (arg & TIOCDSR) ret |= SerialPort::Dsr; #endif @@ -412,7 +412,7 @@ bool UnixSerialPortEngine::setBreak(bool set) qint64 UnixSerialPortEngine::bytesAvailable() const { int nbytes = 0; -#if defined (TIOCINQ) +#ifdef TIOCINQ if (::ioctl(m_descriptor, TIOCINQ, &nbytes) == -1) return -1; #endif @@ -426,7 +426,7 @@ qint64 UnixSerialPortEngine::bytesAvailable() const qint64 UnixSerialPortEngine::bytesToWrite() const { int nbytes = 0; -#if defined (TIOCOUTQ) +#ifdef TIOCOUTQ if (::ioctl(m_descriptor, TIOCOUTQ, &nbytes) == -1) return -1; #endif @@ -447,7 +447,7 @@ qint64 UnixSerialPortEngine::bytesToWrite() const qint64 UnixSerialPortEngine::read(char *data, qint64 len) { qint64 bytesRead = 0; -#if defined (CMSPAR) +#ifdef CMSPAR if (dptr->options.parity == SerialPort::NoParity || dptr->options.policy != SerialPort::StopReceivingPolicy) { #else @@ -496,7 +496,7 @@ qint64 UnixSerialPortEngine::read(char *data, qint64 len) qint64 UnixSerialPortEngine::write(const char *data, qint64 len) { qint64 bytesWritten = 0; -#if defined (CMSPAR) +#ifdef CMSPAR bytesWritten = ::write(m_descriptor, data, len); #else if (dptr->options.parity != SerialPort::MarkParity @@ -600,7 +600,7 @@ bool UnixSerialPortEngine::setRate(qint32 rate, SerialPort::Directions dir) const qint32 unixRate = SerialPortPrivate::settingFromRate(rate); if (unixRate > 0) { // try prepate to set standard baud rate -#if defined (Q_OS_LINUX) +#ifdef Q_OS_LINUX // prepare to forcefully reset the custom mode if (m_isCustomRateSupported) { //m_currentSerialInfo.flags |= ASYNC_SPD_MASK; @@ -613,7 +613,7 @@ bool UnixSerialPortEngine::setRate(qint32 rate, SerialPort::Directions dir) || ((dir & SerialPort::Output) && ::cfsetospeed(&m_currentTermios, unixRate) < 0)); } else { // try prepate to set custom baud rate -#if defined (Q_OS_LINUX) +#ifdef Q_OS_LINUX // prepare to forcefully set the custom mode if (m_isCustomRateSupported) { m_currentSerialInfo.flags &= ~ASYNC_SPD_MASK; @@ -648,7 +648,7 @@ bool UnixSerialPortEngine::setRate(qint32 rate, SerialPort::Directions dir) // finally section -#if defined (Q_OS_LINUX) +#ifdef Q_OS_LINUX if (ret && m_isCustomRateSupported) // finally, set or reset the custom mode ret = ::ioctl(m_descriptor, TIOCSSERIAL, &m_currentSerialInfo) != -1; #endif @@ -706,7 +706,7 @@ bool UnixSerialPortEngine::setParity(SerialPort::Parity parity) switch (parity) { -#if defined (CMSPAR) +#ifdef CMSPAR // Here Installation parity only for GNU/Linux where the macro CMSPAR. case SerialPort::SpaceParity: m_currentTermios.c_cflag &= ~PARODD; @@ -935,7 +935,7 @@ void UnixSerialPortEngine::detectDefaultSettings() const speed_t outputUnixRate = ::cfgetospeed(&m_currentTermios); bool isCustomRateCurrentSet = false; -#if defined (Q_OS_LINUX) +#ifdef Q_OS_LINUX // try detect the ability to support custom rate m_isCustomRateSupported = ::ioctl(m_descriptor, TIOCGSERIAL, &m_currentSerialInfo) != -1 && ::ioctl(m_descriptor, TIOCSSERIAL, &m_currentSerialInfo) != -1; @@ -988,7 +988,7 @@ void UnixSerialPortEngine::detectDefaultSettings() } // Detect parity. -#if defined (CMSPAR) +#ifdef CMSPAR if (m_currentTermios.c_cflag & CMSPAR) { dptr->options.parity = m_currentTermios.c_cflag & PARODD ? SerialPort::MarkParity : SerialPort::SpaceParity; @@ -1000,7 +1000,7 @@ void UnixSerialPortEngine::detectDefaultSettings() } else { dptr->options.parity = SerialPort::NoParity; } -#if defined (CMSPAR) +#ifdef CMSPAR } #endif @@ -1107,7 +1107,7 @@ static inline bool evenParity(quint8 c) return c & 1; //(c7 ^ c3)(c5 ^ c1)(c6 ^ c2)(c4 ^ c0) } -#if !defined (CMSPAR) +#ifndef CMSPAR /*! For platforms that do not have the support of parities mark and space @@ -1227,7 +1227,7 @@ SerialPortEngine *SerialPortEngine::create(SerialPortPrivate *d) /* Public static the SerialPortPrivate methods */ -#if defined (Q_OS_MAC) +#ifdef Q_OS_MAC static const QLatin1String defaultPathPrefix("/dev/cu."); static const QLatin1String notUsedPathPrefix("/dev/tty."); #else @@ -1242,7 +1242,7 @@ QString SerialPortPrivate::portNameToSystemLocation(const QString &port) { QString ret = port; -#if defined (Q_OS_MAC) +#ifdef Q_OS_MAC ret.remove(notUsedPathPrefix); #endif @@ -1259,7 +1259,7 @@ QString SerialPortPrivate::portNameFromSystemLocation(const QString &location) { QString ret = location; -#if defined (Q_OS_MAC) +#ifdef Q_OS_MAC ret.remove(notUsedPathPrefix); #endif @@ -1280,94 +1280,94 @@ struct RatePair static const RatePair standardRatesTable[] = { - #if defined (B50) + #ifdef B50 { 50, B50 }, #endif - #if defined (B75) + #ifdef B75 { 75, B75 }, #endif - #if defined (B110) + #ifdef B110 { 110, B110 }, #endif - #if defined (B134) + #ifdef B134 { 134, B134 }, #endif - #if defined (B150) + #ifdef B150 { 150, B150 }, #endif - #if defined (B200) + #ifdef B200 { 200, B200 }, #endif - #if defined (B300) + #ifdef B300 { 300, B300 }, #endif - #if defined (B600) + #ifdef B600 { 600, B600 }, #endif - #if defined (B1200) + #ifdef B1200 { 1200, B1200 }, #endif - #if defined (B1800) + #ifdef B1800 { 1800, B1800 }, #endif - #if defined (B2400) + #ifdef B2400 { 2400, B2400 }, #endif - #if defined (B4800) + #ifdef B4800 { 4800, B4800 }, #endif - #if defined (B9600) + #ifdef B9600 { 9600, B9600 }, #endif - #if defined (B19200) + #ifdef B19200 { 19200, B19200 }, #endif - #if defined (B38400) + #ifdef B38400 { 38400, B38400 }, #endif - #if defined (B57600) + #ifdef B57600 { 57600, B57600 }, #endif - #if defined (B115200) + #ifdef B115200 { 115200, B115200 }, #endif - #if defined (B230400) + #ifdef B230400 { 230400, B230400 }, #endif - #if defined (B460800) + #ifdef B460800 { 460800, B460800 }, #endif - #if defined (B500000) + #ifdef B500000 { 500000, B500000 }, #endif - #if defined (B576000) + #ifdef B576000 { 576000, B576000 }, #endif - #if defined (B921600) + #ifdef B921600 { 921600, B921600 }, #endif - #if defined (B1000000) + #ifdef B1000000 { 1000000, B1000000 }, #endif - #if defined (B1152000) + #ifdef B1152000 { 1152000, B1152000 }, #endif - #if defined (B1500000) + #ifdef B1500000 { 1500000, B1500000 }, #endif - #if defined (B2000000) + #ifdef B2000000 { 2000000, B2000000}, #endif - #if defined (B2500000) + #ifdef B2500000 { 2500000, B2500000 }, #endif - #if defined (B3000000) + #ifdef B3000000 { 3000000, B3000000 }, #endif - #if defined (B3500000) + #ifdef B3500000 { 3500000, B3500000 }, #endif - #if defined (B4000000) + #ifdef B4000000 { 4000000, B4000000 } #endif }; diff --git a/src/serialportengine_unix_p.h b/src/serialportengine_unix_p.h index 76e04e8..f180ba8 100755 --- a/src/serialportengine_unix_p.h +++ b/src/serialportengine_unix_p.h @@ -46,7 +46,7 @@ #include "serialportengine_p.h" #include -#if defined (Q_OS_LINUX) +#ifdef Q_OS_LINUX # include #endif @@ -109,7 +109,7 @@ protected: private: bool updateTermios(); -#if !defined (CMSPAR) +#ifndef CMSPAR qint64 writePerChar(const char *data, qint64 maxSize); #endif qint64 readPerChar(char *data, qint64 maxSize); @@ -117,7 +117,7 @@ private: private: struct termios m_currentTermios; struct termios m_restoredTermios; -#if defined (Q_OS_LINUX) +#ifdef Q_OS_LINUX struct serial_struct m_currentSerialInfo; struct serial_struct m_restoredSerialInfo; #endif diff --git a/src/serialportengine_win.cpp b/src/serialportengine_win.cpp index 90db821..11cd3ec 100755 --- a/src/serialportengine_win.cpp +++ b/src/serialportengine_win.cpp @@ -81,7 +81,7 @@ #include "serialportengine_win_p.h" #include -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE # include #endif @@ -129,7 +129,7 @@ WinSerialPortEngine::WinSerialPortEngine(SerialPortPrivate *d) , m_flagErrorFromCommEvent(false) , m_currentMask(0) , m_desiredMask(0) -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE , m_running(true) #endif { @@ -140,7 +140,7 @@ WinSerialPortEngine::WinSerialPortEngine(SerialPortPrivate *d) ::memset(&m_currentCommTimeouts, 0, sizeof(m_currentCommTimeouts)); ::memset(&m_restoredCommTimeouts, 0, sizeof(m_restoredCommTimeouts)); -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE ::memset(&m_readOverlapped, 0, sizeof(m_readOverlapped)); ::memset(&m_writeOverlapped, 0, sizeof(m_writeOverlapped)); ::memset(&m_selectOverlapped, 0, sizeof(m_selectOverlapped)); @@ -153,7 +153,7 @@ WinSerialPortEngine::WinSerialPortEngine(SerialPortPrivate *d) */ WinSerialPortEngine::~WinSerialPortEngine() { -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE m_running = false; ::SetCommMask(m_descriptor, 0); //terminate(); @@ -188,7 +188,7 @@ bool WinSerialPortEngine::open(const QString &location, QIODevice::OpenMode mode bool rxflag = false; bool txflag = false; -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE flagsAndAttributes |= FILE_FLAG_OVERLAPPED; #endif @@ -246,7 +246,7 @@ bool WinSerialPortEngine::open(const QString &location, QIODevice::OpenMode mode if (!updateCommTimeouts()) return false; -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE if (!createEvents(rxflag, txflag)) { dptr->setError(decodeSystemError()); return false; @@ -265,7 +265,7 @@ void WinSerialPortEngine::close(const QString &location) { Q_UNUSED(location); -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE ::CancelIo(m_descriptor); #endif @@ -276,7 +276,7 @@ void WinSerialPortEngine::close(const QString &location) ::CloseHandle(m_descriptor); -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE closeEvents(); #endif m_descriptor = INVALID_HANDLE_VALUE; @@ -429,7 +429,7 @@ qint64 WinSerialPortEngine::bytesToWrite() const return cs.cbOutQue; } -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE // Clear overlapped structure, but does not affect the event. static void clear_overlapped(OVERLAPPED *overlapped) { @@ -459,7 +459,7 @@ static void clear_overlapped(OVERLAPPED *overlapped) */ qint64 WinSerialPortEngine::read(char *data, qint64 len) { -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE clear_overlapped(&m_readOverlapped); #endif @@ -470,7 +470,7 @@ qint64 WinSerialPortEngine::read(char *data, qint64 len) if (dptr->options.policy != SerialPort::IgnorePolicy) len = 1; -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE sucessResult = ::ReadFile(m_descriptor, data, len, &readBytes, 0); #else if (::ReadFile(m_descriptor, data, len, &readBytes, &m_readOverlapped)) { @@ -512,14 +512,14 @@ qint64 WinSerialPortEngine::read(char *data, qint64 len) */ qint64 WinSerialPortEngine::write(const char *data, qint64 len) { -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE clear_overlapped(&m_writeOverlapped); #endif DWORD writeBytes = 0; bool sucessResult = false; -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE sucessResult = ::WriteFile(m_descriptor, data, len, &writeBytes, 0); #else if (::WriteFile(m_descriptor, data, len, &writeBytes, &m_writeOverlapped)) { @@ -576,7 +576,7 @@ bool WinSerialPortEngine::select(int timeout, return true; } -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE clear_overlapped(&m_selectOverlapped); #endif @@ -603,7 +603,7 @@ bool WinSerialPortEngine::select(int timeout, currEventMask = 0; bool sucessResult = false; -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE if (::WaitCommEvent(m_descriptor, &currEventMask, &m_selectOverlapped)) { sucessResult = true; } else if (::GetLastError() == ERROR_IO_PENDING) { @@ -870,7 +870,7 @@ bool WinSerialPortEngine::processIOErrors() return ret; } -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE void WinSerialPortEngine::lockNotification(NotificationLockerType type, bool uselocker) { @@ -1016,7 +1016,7 @@ SerialPort::PortError WinSerialPortEngine::decodeSystemError() const return error; } -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE /*! Embedded-based (WinCE) event loop for the notification subsystem. @@ -1090,7 +1090,7 @@ bool WinSerialPortEngine::event(QEvent *e) #endif -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE /*! For Windows NT-based OS, creates event handles for OVERLAPPED @@ -1147,7 +1147,7 @@ void WinSerialPortEngine::closeEvents() bool WinSerialPortEngine::isNotificationEnabled(DWORD mask) const { bool enabled; -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE enabled = isRunning(); #else enabled = isEnabled(); @@ -1160,7 +1160,7 @@ bool WinSerialPortEngine::isNotificationEnabled(DWORD mask) const void WinSerialPortEngine::setNotificationEnabled(bool enable, DWORD mask) { -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE m_setCommMaskMutex.lock(); ::GetCommMask(m_descriptor, &m_currentMask); #endif @@ -1173,7 +1173,7 @@ void WinSerialPortEngine::setNotificationEnabled(bool enable, DWORD mask) ::SetCommMask(m_descriptor, m_desiredMask); -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE m_setCommMaskMutex.unlock(); if (enable && !isRunning()) @@ -1202,7 +1202,7 @@ void WinSerialPortEngine::setNotificationEnabled(bool enable, DWORD mask) */ bool WinSerialPortEngine::updateDcb() { -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE // Grab a mutex, in order after exit WaitCommEvent // block the flow of run() notifier until there is a change DCB. QMutexLocker locker(&m_settingsChangeMutex); @@ -1241,7 +1241,7 @@ SerialPortEngine *SerialPortEngine::create(SerialPortPrivate *d) /* Public static the SerialPortPrivate methods */ -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE static const QLatin1String defaultPathPrefix("\\\\.\\"); #else static const QLatin1String defaultPathPostfix(":"); @@ -1254,7 +1254,7 @@ static const QLatin1String defaultPathPostfix(":"); QString SerialPortPrivate::portNameToSystemLocation(const QString &port) { QString ret = port; -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE if (!ret.contains(defaultPathPrefix)) ret.prepend(defaultPathPrefix); #else @@ -1271,7 +1271,7 @@ QString SerialPortPrivate::portNameToSystemLocation(const QString &port) QString SerialPortPrivate::portNameFromSystemLocation(const QString &location) { QString ret = location; -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE if (ret.contains(defaultPathPrefix)) ret.remove(defaultPathPrefix); #else @@ -1286,49 +1286,49 @@ QString SerialPortPrivate::portNameFromSystemLocation(const QString &location) static const qint32 standardRatesTable[] = { - #if defined (CBR_110) + #ifdef CBR_110 CBR_110, #endif - #if defined (CBR_300) + #ifdef CBR_300 CBR_300, #endif - #if defined (CBR_600) + #ifdef CBR_600 CBR_600, #endif - #if defined (CBR_1200) + #ifdef CBR_1200 CBR_1200, #endif - #if defined (CBR_2400) + #ifdef CBR_2400 CBR_2400, #endif - #if defined (CBR_4800) + #ifdef CBR_4800 CBR_4800, #endif - #if defined (CBR_9600) + #ifdef CBR_9600 CBR_9600, #endif - #if defined (CBR_14400) + #ifdef CBR_14400 CBR_14400, #endif - #if defined (CBR_19200) + #ifdef CBR_19200 CBR_19200, #endif - #if defined (CBR_38400) + #ifdef CBR_38400 CBR_38400, #endif - #if defined (CBR_56000) + #ifdef CBR_56000 CBR_56000, #endif - #if defined (CBR_57600) + #ifdef CBR_57600 CBR_57600, #endif - #if defined (CBR_115200) + #ifdef CBR_115200 CBR_115200, #endif - #if defined (CBR_128000) + #ifdef CBR_128000 CBR_128000, #endif - #if defined (CBR_256000) + #ifdef CBR_256000 CBR_256000 #endif }; diff --git a/src/serialportengine_win_p.h b/src/serialportengine_win_p.h index 9602603..bc293f6 100755 --- a/src/serialportengine_win_p.h +++ b/src/serialportengine_win_p.h @@ -47,7 +47,7 @@ #include "serialportengine_p.h" #include -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE # include # include # include @@ -61,7 +61,7 @@ QT_BEGIN_NAMESPACE_SERIALPORT -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE class WinCeWaitCommEventBreaker : public QThread { @@ -103,7 +103,7 @@ private: }; #endif -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE class WinSerialPortEngine : public QThread, public SerialPortEngine #else class WinSerialPortEngine : public QWinEventNotifier, public SerialPortEngine @@ -154,7 +154,7 @@ public: virtual bool processIOErrors(); -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE // FIXME virtual void lockNotification(NotificationLockerType type, bool uselocker); virtual void unlockNotification(NotificationLockerType type); @@ -164,7 +164,7 @@ protected: virtual void detectDefaultSettings(); virtual SerialPort::PortError decodeSystemError() const; -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE virtual void run(); #else virtual bool event(QEvent *e); @@ -172,7 +172,7 @@ protected: private: -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE bool createEvents(bool rx, bool tx); void closeEvents(); #endif @@ -193,7 +193,7 @@ private: DWORD m_currentMask; DWORD m_desiredMask; -#if defined (Q_OS_WINCE) +#ifdef Q_OS_WINCE QMutex m_readNotificationMutex; QMutex m_writeNotificationMutex; QMutex m_errorNotificationMutex; diff --git a/src/serialportinfo_symbian.cpp b/src/serialportinfo_symbian.cpp index b878ff6..8ab8d11 100755 --- a/src/serialportinfo_symbian.cpp +++ b/src/serialportinfo_symbian.cpp @@ -54,7 +54,7 @@ // Physical device driver. -#if defined (__WINS__) +#ifdef __WINS__ _LIT(KPddName, "ECDRV"); #else // defined (__EPOC32__) _LIT(KPddName, "EUART"); @@ -73,7 +73,7 @@ _LIT(KACMModuleName, "ECACM"); static bool loadDevices() { TInt r = KErrNone; -#if defined (__WINS__) +#ifdef __WINS__ RFs fileServer; r = User::LeaveIfError(fileServer.Connect()); if (r != KErrNone) @@ -89,7 +89,7 @@ static bool loadDevices() if (r != KErrNone && r != KErrAlreadyExists) return false; //User::Leave(r); -#if !defined (__WINS__) +#ifndef __WINS__ r = StartC32(); if (r != KErrNone && r != KErrAlreadyExists) return false; //User::Leave(r); diff --git a/src/serialportinfo_unix.cpp b/src/serialportinfo_unix.cpp index 1b7c8ca..5f454c6 100755 --- a/src/serialportinfo_unix.cpp +++ b/src/serialportinfo_unix.cpp @@ -53,7 +53,7 @@ #include #include -#if defined (Q_OS_LINUX) +#ifdef Q_OS_LINUX # include #endif @@ -88,7 +88,7 @@ static QStringList generateFiltersOfDevices() { QStringList l; -# if defined (Q_OS_LINUX) +# ifdef Q_OS_LINUX l << QLatin1String("ttyS*") // Standart UART 8250 and etc. << QLatin1String("ttyUSB*") // Usb/serial converters PL2303 and etc. << QLatin1String("ttyACM*") // CDC_ACM converters (i.e. Mobile Phones). diff --git a/src/serialportinfo_win.cpp b/src/serialportinfo_win.cpp index 237c6fc..6664590 100755 --- a/src/serialportinfo_win.cpp +++ b/src/serialportinfo_win.cpp @@ -48,7 +48,7 @@ #include #include #include -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE # include #endif @@ -58,7 +58,7 @@ static const GUID guidsArray[] = { - #if !defined (Q_OS_WINCE) + #ifndef Q_OS_WINCE // Windows Ports Class GUID { 0x4D36E978, 0xE325, 0x11CE, { 0xBF, 0xC1, 0x08, 0x00, 0x2B, 0xE1, 0x03, 0x18 } }, // Virtual Ports Class GUID (i.e. com0com and etc) @@ -74,7 +74,7 @@ static const GUID guidsArray[] = #endif }; -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE static QVariant getDeviceRegistryProperty(HDEVINFO deviceInfoSet, PSP_DEVINFO_DATA deviceInfoData, @@ -275,7 +275,7 @@ QList SerialPortInfo::availablePorts() QList ports; static const int guidCount = sizeof(guidsArray)/sizeof(guidsArray[0]); -#if !defined (Q_OS_WINCE) +#ifndef Q_OS_WINCE for (int i = 0; i < guidCount; ++i) { const HDEVINFO deviceInfoSet = ::SetupDiGetClassDevs(&guidsArray[i], 0, 0, DIGCF_PRESENT); diff --git a/src/ttylocker_unix.cpp b/src/ttylocker_unix.cpp index 5ffd7f7..67f3611 100644 --- a/src/ttylocker_unix.cpp +++ b/src/ttylocker_unix.cpp @@ -41,7 +41,7 @@ #include "ttylocker_unix_p.h" -#if defined (HAVE_BAUDBOY_H) +#ifdef HAVE_BAUDBOY_H # include # include #elif defined (HAVE_LOCKDEV_H) @@ -103,7 +103,7 @@ QT_BEGIN_NAMESPACE_SERIALPORT // Try lock serial device. However, other processes can not access it. bool TtyLocker::lock(const char *portName) { -#if defined (HAVE_BAUDBOY_H) +#ifdef HAVE_BAUDBOY_H if (::ttylock(portName) ::ttywait(portName); return ::ttylock(portName) != -1; @@ -127,7 +127,7 @@ bool TtyLocker::lock(const char *portName) // Try unlock serial device. However, other processes can access it. bool TtyLocker::unlock(const char *portName) { -#if defined (HAVE_BAUDBOY_H) +#ifdef HAVE_BAUDBOY_H return ::ttyunlock(portName != -1; #elif defined (HAVE_LOCKDEV_H) return ::dev_unlock(portName, ::getpid()) != -1; @@ -146,7 +146,7 @@ bool TtyLocker::isLocked(const char *portName, bool *currentPid) *currentPid = false; -#if defined (HAVE_BAUDBOY_H) +#ifdef HAVE_BAUDBOY_H return ::ttylocked(portName) != -1; #elif defined (HAVE_LOCKDEV_H) return ::dev_testlock(portName) != -1; -- cgit v1.2.1