summaryrefslogtreecommitdiff
path: root/nsprpub/pr/src/cplus
diff options
context:
space:
mode:
Diffstat (limited to 'nsprpub/pr/src/cplus')
-rw-r--r--nsprpub/pr/src/cplus/rcascii.h2
-rw-r--r--nsprpub/pr/src/cplus/rcbase.cpp16
-rw-r--r--nsprpub/pr/src/cplus/rcbase.h8
-rw-r--r--nsprpub/pr/src/cplus/rccv.cpp11
-rw-r--r--nsprpub/pr/src/cplus/rccv.h2
-rw-r--r--nsprpub/pr/src/cplus/rcfileio.cpp140
-rw-r--r--nsprpub/pr/src/cplus/rcfileio.h40
-rw-r--r--nsprpub/pr/src/cplus/rcinrval.cpp22
-rw-r--r--nsprpub/pr/src/cplus/rcinrval.h106
-rw-r--r--nsprpub/pr/src/cplus/rcio.h39
-rw-r--r--nsprpub/pr/src/cplus/rclock.cpp4
-rw-r--r--nsprpub/pr/src/cplus/rclock.h14
-rw-r--r--nsprpub/pr/src/cplus/rcnetdb.cpp75
-rw-r--r--nsprpub/pr/src/cplus/rcnetdb.h14
-rw-r--r--nsprpub/pr/src/cplus/rcnetio.cpp128
-rw-r--r--nsprpub/pr/src/cplus/rcnetio.h34
-rwxr-xr-xnsprpub/pr/src/cplus/rcthread.cpp81
-rw-r--r--nsprpub/pr/src/cplus/rcthread.h22
-rw-r--r--nsprpub/pr/src/cplus/rctime.cpp40
-rw-r--r--nsprpub/pr/src/cplus/rctime.h58
-rw-r--r--nsprpub/pr/src/cplus/tests/Makefile.in22
-rw-r--r--nsprpub/pr/src/cplus/tests/ranfile.cpp205
-rw-r--r--nsprpub/pr/src/cplus/tests/switch.cpp168
-rw-r--r--nsprpub/pr/src/cplus/tests/thread.cpp6
-rw-r--r--nsprpub/pr/src/cplus/tests/tpd.cpp57
25 files changed, 860 insertions, 454 deletions
diff --git a/nsprpub/pr/src/cplus/rcascii.h b/nsprpub/pr/src/cplus/rcascii.h
index 7383d8d666..f8b59ce0f9 100644
--- a/nsprpub/pr/src/cplus/rcascii.h
+++ b/nsprpub/pr/src/cplus/rcascii.h
@@ -81,7 +81,7 @@ private:
** for this class.
*/
PRSize StuffFunction(void*, const char*, PRSize);
-
+
}; /* RCFormatBuffer */
/*
diff --git a/nsprpub/pr/src/cplus/rcbase.cpp b/nsprpub/pr/src/cplus/rcbase.cpp
index c258081d3c..7c12e6d3d4 100644
--- a/nsprpub/pr/src/cplus/rcbase.cpp
+++ b/nsprpub/pr/src/cplus/rcbase.cpp
@@ -11,13 +11,21 @@
RCBase::~RCBase() { }
-PRSize RCBase::GetErrorTextLength() { return PR_GetErrorTextLength(); }
-PRSize RCBase::CopyErrorText(char *text) { return PR_GetErrorText(text); }
+PRSize RCBase::GetErrorTextLength() {
+ return PR_GetErrorTextLength();
+}
+PRSize RCBase::CopyErrorText(char *text) {
+ return PR_GetErrorText(text);
+}
void RCBase::SetError(PRErrorCode error, PRInt32 oserror)
- { PR_SetError(error, oserror); }
+{
+ PR_SetError(error, oserror);
+}
void RCBase::SetErrorText(PRSize text_length, const char *text)
- { PR_SetErrorText(text_length, text); }
+{
+ PR_SetErrorText(text_length, text);
+}
/* rcbase.cpp */
diff --git a/nsprpub/pr/src/cplus/rcbase.h b/nsprpub/pr/src/cplus/rcbase.h
index 58df43c128..3cc91f8041 100644
--- a/nsprpub/pr/src/cplus/rcbase.h
+++ b/nsprpub/pr/src/cplus/rcbase.h
@@ -43,8 +43,12 @@ protected:
RCBase() { }
}; /* RCObject */
-inline PRErrorCode RCBase::GetError() { return PR_GetError(); }
-inline PRInt32 RCBase::GetOSError() { return PR_GetOSError(); }
+inline PRErrorCode RCBase::GetError() {
+ return PR_GetError();
+}
+inline PRInt32 RCBase::GetOSError() {
+ return PR_GetOSError();
+}
#endif /* defined(_RCRUNTIME_H) */
diff --git a/nsprpub/pr/src/cplus/rccv.cpp b/nsprpub/pr/src/cplus/rccv.cpp
index 32b84b1cb8..f124385350 100644
--- a/nsprpub/pr/src/cplus/rccv.cpp
+++ b/nsprpub/pr/src/cplus/rccv.cpp
@@ -22,7 +22,9 @@ RCCondition::RCCondition(class RCLock *lock): RCBase()
RCCondition::~RCCondition()
{
- if (NULL != cv) PR_DestroyCondVar(cv);
+ if (NULL != cv) {
+ PR_DestroyCondVar(cv);
+ }
} /* RCCondition::~RCCondition */
PRStatus RCCondition::Wait()
@@ -34,8 +36,9 @@ PRStatus RCCondition::Wait()
SetError(PR_INVALID_ARGUMENT_ERROR, 0);
rv = PR_FAILURE;
}
- else
+ else {
rv = PR_WaitCondVar(cv, timeout.interval);
+ }
return rv;
} /* RCCondition::Wait */
@@ -60,6 +63,8 @@ PRStatus RCCondition::SetTimeout(const RCInterval& tmo)
return PR_SUCCESS;
} /* RCCondition::SetTimeout */
-RCInterval RCCondition::GetTimeout() const { return timeout; }
+RCInterval RCCondition::GetTimeout() const {
+ return timeout;
+}
/* rccv.cpp */
diff --git a/nsprpub/pr/src/cplus/rccv.h b/nsprpub/pr/src/cplus/rccv.h
index e5c89135f2..afeec61614 100644
--- a/nsprpub/pr/src/cplus/rccv.h
+++ b/nsprpub/pr/src/cplus/rccv.h
@@ -41,7 +41,7 @@ public:
virtual PRStatus Broadcast(); /* perhaps ready many threads */
virtual PRStatus SetTimeout(const RCInterval&);
- /* set object's current timeout value */
+ /* set object's current timeout value */
private:
PRCondVar *cv;
diff --git a/nsprpub/pr/src/cplus/rcfileio.cpp b/nsprpub/pr/src/cplus/rcfileio.cpp
index cdf6318a0b..91c5fde6ff 100644
--- a/nsprpub/pr/src/cplus/rcfileio.cpp
+++ b/nsprpub/pr/src/cplus/rcfileio.cpp
@@ -13,24 +13,42 @@
RCFileIO::RCFileIO(): RCIO(RCIO::file) { }
-RCFileIO::~RCFileIO() { if (NULL != fd) (void)Close(); }
+RCFileIO::~RCFileIO() {
+ if (NULL != fd) {
+ (void)Close();
+ }
+}
PRInt64 RCFileIO::Available()
- { return fd->methods->available(fd); }
+{
+ return fd->methods->available(fd);
+}
PRStatus RCFileIO::Close()
- { PRStatus rv = fd->methods->close(fd); fd = NULL; return rv; }
+{
+ PRStatus rv = fd->methods->close(fd);
+ fd = NULL;
+ return rv;
+}
-PRStatus RCFileIO::Delete(const char* filename) { return PR_Delete(filename); }
+PRStatus RCFileIO::Delete(const char* filename) {
+ return PR_Delete(filename);
+}
PRStatus RCFileIO::FileInfo(RCFileInfo* info) const
- { return fd->methods->fileInfo64(fd, &info->info); }
+{
+ return fd->methods->fileInfo64(fd, &info->info);
+}
PRStatus RCFileIO::FileInfo(const char *name, RCFileInfo* info)
- { return PR_GetFileInfo64(name, &info->info); }
+{
+ return PR_GetFileInfo64(name, &info->info);
+}
PRStatus RCFileIO::Fsync()
- { return fd->methods->fsync(fd); }
+{
+ return fd->methods->fsync(fd);
+}
PRStatus RCFileIO::Open(const char *filename, PRIntn flags, PRIntn mode)
{
@@ -39,7 +57,9 @@ PRStatus RCFileIO::Open(const char *filename, PRIntn flags, PRIntn mode)
} /* RCFileIO::Open */
PRInt32 RCFileIO::Read(void *buf, PRSize amount)
- { return fd->methods->read(fd, buf, amount); }
+{
+ return fd->methods->read(fd, buf, amount);
+}
PRInt64 RCFileIO::Seek(PRInt64 offset, RCIO::Whence how)
{
@@ -55,11 +75,15 @@ PRInt64 RCFileIO::Seek(PRInt64 offset, RCIO::Whence how)
} /* RCFileIO::Seek */
PRInt32 RCFileIO::Write(const void *buf, PRSize amount)
- { return fd->methods->write(fd, buf, amount); }
+{
+ return fd->methods->write(fd, buf, amount);
+}
PRInt32 RCFileIO::Writev(
const PRIOVec *iov, PRSize size, const RCInterval& timeout)
- { return fd->methods->writev(fd, iov, size, timeout); }
+{
+ return fd->methods->writev(fd, iov, size, timeout);
+}
RCIO *RCFileIO::GetSpecialFile(RCFileIO::SpecialFile special)
{
@@ -78,7 +102,9 @@ RCIO *RCFileIO::GetSpecialFile(RCFileIO::SpecialFile special)
if (NULL != fd)
{
spec = new RCFileIO();
- if (NULL != spec) spec->fd = fd;
+ if (NULL != spec) {
+ spec->fd = fd;
+ }
}
return spec;
} /* RCFileIO::GetSpecialFile */
@@ -90,56 +116,104 @@ RCIO *RCFileIO::GetSpecialFile(RCFileIO::SpecialFile special)
** are not valid for this type of I/O class (normal and special file).
*/
PRStatus RCFileIO::Connect(const RCNetAddr&, const RCInterval&)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRStatus RCFileIO::GetLocalName(RCNetAddr*) const
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRStatus RCFileIO::GetPeerName(RCNetAddr*) const
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRStatus RCFileIO::GetSocketOption(PRSocketOptionData*) const
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRStatus RCFileIO::Listen(PRIntn)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRInt16 RCFileIO::Poll(PRInt16, PRInt16*)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return 0; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return 0;
+}
PRInt32 RCFileIO::Recv(void*, PRSize, PRIntn, const RCInterval&)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return -1; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return -1;
+}
PRInt32 RCFileIO::Recvfrom(void*, PRSize, PRIntn, RCNetAddr*, const RCInterval&)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return -1; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return -1;
+}
PRInt32 RCFileIO::Send(
const void*, PRSize, PRIntn, const RCInterval&)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return -1; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return -1;
+}
PRInt32 RCFileIO::Sendto(
const void*, PRSize, PRIntn, const RCNetAddr&, const RCInterval&)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return -1; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return -1;
+}
RCIO* RCFileIO::Accept(RCNetAddr*, const RCInterval&)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return NULL; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return NULL;
+}
PRStatus RCFileIO::Bind(const RCNetAddr&)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRInt32 RCFileIO::AcceptRead(
RCIO**, RCNetAddr**, void*, PRSize, const RCInterval&)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return -1; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return -1;
+}
PRStatus RCFileIO::SetSocketOption(const PRSocketOptionData*)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRStatus RCFileIO::Shutdown(RCIO::ShutdownHow)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRInt32 RCFileIO::TransmitFile(
RCIO*, const void*, PRSize, RCIO::FileDisposition, const RCInterval&)
-{ PR_SetError(PR_INVALID_METHOD_ERROR, 0); return -1; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return -1;
+}
/*
** Class implementation for file information object (ref: prio.h)
@@ -148,11 +222,17 @@ PRInt32 RCFileIO::TransmitFile(
RCFileInfo::~RCFileInfo() { }
RCFileInfo::RCFileInfo(const RCFileInfo& her): RCBase()
- { info = her.info; } /* RCFileInfo::RCFileInfo */
+{
+ info = her.info; /* RCFileInfo::RCFileInfo */
+}
-RCTime RCFileInfo::CreationTime() const { return RCTime(info.creationTime); }
+RCTime RCFileInfo::CreationTime() const {
+ return RCTime(info.creationTime);
+}
-RCTime RCFileInfo::ModifyTime() const { return RCTime(info.modifyTime); }
+RCTime RCFileInfo::ModifyTime() const {
+ return RCTime(info.modifyTime);
+}
RCFileInfo::FileType RCFileInfo::Type() const
{
diff --git a/nsprpub/pr/src/cplus/rcfileio.h b/nsprpub/pr/src/cplus/rcfileio.h
index d9c82582d4..9e28b36ace 100644
--- a/nsprpub/pr/src/cplus/rcfileio.h
+++ b/nsprpub/pr/src/cplus/rcfileio.h
@@ -41,8 +41,8 @@ public:
virtual PRInt64 Seek(PRInt64 offset, RCIO::Whence how);
virtual PRInt32 Write(const void *buf, PRSize amount);
virtual PRInt32 Writev(
- const PRIOVec *iov, PRSize size,
- const RCInterval& timeout);
+ const PRIOVec *iov, PRSize size,
+ const RCInterval& timeout);
private:
@@ -52,8 +52,8 @@ private:
RCIO* Accept(RCNetAddr* addr, const RCInterval& timeout);
PRInt32 AcceptRead(
- RCIO **newfd, RCNetAddr **address, void *buffer,
- PRSize amount, const RCInterval& timeout);
+ RCIO **newfd, RCNetAddr **address, void *buffer,
+ PRSize amount, const RCInterval& timeout);
PRStatus Bind(const RCNetAddr& addr);
PRStatus Connect(const RCNetAddr& addr, const RCInterval& timeout);
PRStatus GetLocalName(RCNetAddr *addr) const;
@@ -62,24 +62,24 @@ private:
PRStatus Listen(PRIntn backlog);
PRInt16 Poll(PRInt16 in_flags, PRInt16 *out_flags);
PRInt32 Recv(
- void *buf, PRSize amount, PRIntn flags,
- const RCInterval& timeout);
+ void *buf, PRSize amount, PRIntn flags,
+ const RCInterval& timeout);
PRInt32 Recvfrom(
- void *buf, PRSize amount, PRIntn flags,
- RCNetAddr* addr, const RCInterval& timeout);
+ void *buf, PRSize amount, PRIntn flags,
+ RCNetAddr* addr, const RCInterval& timeout);
PRInt32 Send(
- const void *buf, PRSize amount, PRIntn flags,
- const RCInterval& timeout);
+ const void *buf, PRSize amount, PRIntn flags,
+ const RCInterval& timeout);
PRInt32 Sendto(
- const void *buf, PRSize amount, PRIntn flags,
- const RCNetAddr& addr,
- const RCInterval& timeout);
+ const void *buf, PRSize amount, PRIntn flags,
+ const RCNetAddr& addr,
+ const RCInterval& timeout);
PRStatus SetSocketOption(const PRSocketOptionData *data);
PRStatus Shutdown(RCIO::ShutdownHow how);
PRInt32 TransmitFile(
- RCIO *source, const void *headers,
- PRSize hlen, RCIO::FileDisposition flags,
- const RCInterval& timeout);
+ RCIO *source, const void *headers,
+ PRSize hlen, RCIO::FileDisposition flags,
+ const RCInterval& timeout);
public:
/*
@@ -116,14 +116,16 @@ public:
RCTime ModifyTime() const;
RCFileInfo::FileType Type() const;
-friend PRStatus RCFileIO::FileInfo(RCFileInfo*) const;
-friend PRStatus RCFileIO::FileInfo(const char *name, RCFileInfo*);
+ friend PRStatus RCFileIO::FileInfo(RCFileInfo*) const;
+ friend PRStatus RCFileIO::FileInfo(const char *name, RCFileInfo*);
private:
PRFileInfo64 info;
}; /* RCFileInfo */
inline RCFileInfo::RCFileInfo(): RCBase() { }
-inline PRInt64 RCFileInfo::Size() const { return info.size; }
+inline PRInt64 RCFileInfo::Size() const {
+ return info.size;
+}
#endif /* defined(_RCFILEIO_H) */
diff --git a/nsprpub/pr/src/cplus/rcinrval.cpp b/nsprpub/pr/src/cplus/rcinrval.cpp
index cda5f8dfd2..3805a57663 100644
--- a/nsprpub/pr/src/cplus/rcinrval.cpp
+++ b/nsprpub/pr/src/cplus/rcinrval.cpp
@@ -20,17 +20,17 @@ RCInterval::RCInterval(RCInterval::RCReservedInterval special): RCBase()
{
switch (special)
{
- case RCInterval::now:
- interval = PR_IntervalNow();
- break;
- case RCInterval::no_timeout:
- interval = PR_INTERVAL_NO_TIMEOUT;
- break;
- case RCInterval::no_wait:
- interval = PR_INTERVAL_NO_WAIT;
- break;
- default:
- break;
+ case RCInterval::now:
+ interval = PR_IntervalNow();
+ break;
+ case RCInterval::no_timeout:
+ interval = PR_INTERVAL_NO_TIMEOUT;
+ break;
+ case RCInterval::no_wait:
+ interval = PR_INTERVAL_NO_WAIT;
+ break;
+ default:
+ break;
}
} /* RCInterval::RCInterval */
diff --git a/nsprpub/pr/src/cplus/rcinrval.h b/nsprpub/pr/src/cplus/rcinrval.h
index bcf755fa8b..333209e618 100644
--- a/nsprpub/pr/src/cplus/rcinrval.h
+++ b/nsprpub/pr/src/cplus/rcinrval.h
@@ -66,71 +66,125 @@ public:
private:
PRIntervalTime interval;
-
+
}; /* RCInterval */
inline RCInterval::RCInterval(): RCBase() { }
inline RCInterval::RCInterval(const RCInterval& his): RCBase()
- { interval = his.interval; }
+{
+ interval = his.interval;
+}
inline RCInterval::RCInterval(PRIntervalTime ticks): RCBase()
- { interval = ticks; }
+{
+ interval = ticks;
+}
-inline void RCInterval::SetToNow() { interval = PR_IntervalNow(); }
+inline void RCInterval::SetToNow() {
+ interval = PR_IntervalNow();
+}
inline void RCInterval::operator=(const RCInterval& his)
- { interval = his.interval; }
+{
+ interval = his.interval;
+}
inline void RCInterval::operator=(PRIntervalTime his)
- { interval = his; }
+{
+ interval = his;
+}
inline PRBool RCInterval::operator==(const RCInterval& his)
- { return (interval == his.interval) ? PR_TRUE : PR_FALSE; }
+{
+ return (interval == his.interval) ? PR_TRUE : PR_FALSE;
+}
inline PRBool RCInterval::operator<(const RCInterval& his)
- { return (interval < his.interval)? PR_TRUE : PR_FALSE; }
+{
+ return (interval < his.interval)? PR_TRUE : PR_FALSE;
+}
inline PRBool RCInterval::operator>(const RCInterval& his)
- { return (interval > his.interval) ? PR_TRUE : PR_FALSE; }
+{
+ return (interval > his.interval) ? PR_TRUE : PR_FALSE;
+}
inline PRBool RCInterval::operator<=(const RCInterval& his)
- { return (interval <= his.interval) ? PR_TRUE : PR_FALSE; }
+{
+ return (interval <= his.interval) ? PR_TRUE : PR_FALSE;
+}
inline PRBool RCInterval::operator>=(const RCInterval& his)
- { return (interval <= his.interval) ? PR_TRUE : PR_FALSE; }
+{
+ return (interval <= his.interval) ? PR_TRUE : PR_FALSE;
+}
inline RCInterval RCInterval::operator+(const RCInterval& his)
- { return RCInterval((PRIntervalTime)(interval + his.interval)); }
+{
+ return RCInterval((PRIntervalTime)(interval + his.interval));
+}
inline RCInterval RCInterval::operator-(const RCInterval& his)
- { return RCInterval((PRIntervalTime)(interval - his.interval)); }
+{
+ return RCInterval((PRIntervalTime)(interval - his.interval));
+}
inline RCInterval& RCInterval::operator+=(const RCInterval& his)
- { interval += his.interval; return *this; }
+{
+ interval += his.interval;
+ return *this;
+}
inline RCInterval& RCInterval::operator-=(const RCInterval& his)
- { interval -= his.interval; return *this; }
+{
+ interval -= his.interval;
+ return *this;
+}
inline RCInterval RCInterval::operator/(PRUint32 him)
- { return RCInterval((PRIntervalTime)(interval / him)); }
+{
+ return RCInterval((PRIntervalTime)(interval / him));
+}
inline RCInterval RCInterval::operator*(PRUint32 him)
- { return RCInterval((PRIntervalTime)(interval * him)); }
+{
+ return RCInterval((PRIntervalTime)(interval * him));
+}
inline RCInterval& RCInterval::operator/=(PRUint32 him)
- { interval /= him; return *this; }
+{
+ interval /= him;
+ return *this;
+}
inline RCInterval& RCInterval::operator*=(PRUint32 him)
- { interval *= him; return *this; }
+{
+ interval *= him;
+ return *this;
+}
inline PRUint32 RCInterval::ToSeconds() const
- { return PR_IntervalToSeconds(interval); }
+{
+ return PR_IntervalToSeconds(interval);
+}
inline PRUint32 RCInterval::ToMilliseconds() const
- { return PR_IntervalToMilliseconds(interval); }
+{
+ return PR_IntervalToMilliseconds(interval);
+}
inline PRUint32 RCInterval::ToMicroseconds() const
- { return PR_IntervalToMicroseconds(interval); }
-inline RCInterval::operator PRIntervalTime() const { return interval; }
+{
+ return PR_IntervalToMicroseconds(interval);
+}
+inline RCInterval::operator PRIntervalTime() const {
+ return interval;
+}
inline PRIntervalTime RCInterval::FromSeconds(PRUint32 seconds)
- { return PR_SecondsToInterval(seconds); }
+{
+ return PR_SecondsToInterval(seconds);
+}
inline PRIntervalTime RCInterval::FromMilliseconds(PRUint32 milli)
- { return PR_MillisecondsToInterval(milli); }
+{
+ return PR_MillisecondsToInterval(milli);
+}
inline PRIntervalTime RCInterval::FromMicroseconds(PRUint32 micro)
- { return PR_MicrosecondsToInterval(micro); }
+{
+ return PR_MicrosecondsToInterval(micro);
+}
#endif /* defined(_RCINTERVAL_H) */
diff --git a/nsprpub/pr/src/cplus/rcio.h b/nsprpub/pr/src/cplus/rcio.h
index a4278d2aea..1bd3ac4140 100644
--- a/nsprpub/pr/src/cplus/rcio.h
+++ b/nsprpub/pr/src/cplus/rcio.h
@@ -49,14 +49,14 @@ public:
virtual RCIO* Accept(RCNetAddr* addr, const RCInterval& timeout) = 0;
virtual PRInt32 AcceptRead(
- RCIO **nd, RCNetAddr **raddr, void *buf,
- PRSize amount, const RCInterval& timeout) = 0;
+ RCIO **nd, RCNetAddr **raddr, void *buf,
+ PRSize amount, const RCInterval& timeout) = 0;
virtual PRInt64 Available() = 0;
virtual PRStatus Bind(const RCNetAddr& addr) = 0;
virtual PRStatus Close() = 0;
virtual PRStatus Connect(
- const RCNetAddr& addr,
- const RCInterval& timeout) = 0;
+ const RCNetAddr& addr,
+ const RCInterval& timeout) = 0;
virtual PRStatus FileInfo(RCFileInfo *info) const = 0;
virtual PRStatus Fsync() = 0;
virtual PRStatus GetLocalName(RCNetAddr *addr) const = 0;
@@ -67,36 +67,37 @@ public:
virtual PRInt16 Poll(PRInt16 in_flags, PRInt16 *out_flags) = 0;
virtual PRInt32 Read(void *buf, PRSize amount) = 0;
virtual PRInt32 Recv(
- void *buf, PRSize amount, PRIntn flags,
- const RCInterval& timeout) = 0;
+ void *buf, PRSize amount, PRIntn flags,
+ const RCInterval& timeout) = 0;
virtual PRInt32 Recvfrom(
- void *buf, PRSize amount, PRIntn flags,
- RCNetAddr* addr, const RCInterval& timeout) = 0;
+ void *buf, PRSize amount, PRIntn flags,
+ RCNetAddr* addr, const RCInterval& timeout) = 0;
virtual PRInt64 Seek(PRInt64 offset, Whence how) = 0;
virtual PRInt32 Send(
- const void *buf, PRSize amount, PRIntn flags,
- const RCInterval& timeout) = 0;
+ const void *buf, PRSize amount, PRIntn flags,
+ const RCInterval& timeout) = 0;
virtual PRInt32 Sendto(
- const void *buf, PRSize amount, PRIntn flags,
- const RCNetAddr& addr,
- const RCInterval& timeout) = 0;
+ const void *buf, PRSize amount, PRIntn flags,
+ const RCNetAddr& addr,
+ const RCInterval& timeout) = 0;
virtual PRStatus SetSocketOption(const PRSocketOptionData *data) = 0;
virtual PRStatus Shutdown(ShutdownHow how) = 0;
virtual PRInt32 TransmitFile(
- RCIO *source, const void *headers,
- PRSize hlen, RCIO::FileDisposition flags,
- const RCInterval& timeout) = 0;
+ RCIO *source, const void *headers,
+ PRSize hlen, RCIO::FileDisposition flags,
+ const RCInterval& timeout) = 0;
virtual PRInt32 Write(const void *buf, PRSize amount) = 0;
virtual PRInt32 Writev(
- const PRIOVec *iov, PRSize size,
- const RCInterval& timeout) = 0;
+ const PRIOVec *iov, PRSize size,
+ const RCInterval& timeout) = 0;
protected:
typedef enum {
file = PR_DESC_FILE,
tcp = PR_DESC_SOCKET_TCP,
udp = PR_DESC_SOCKET_UDP,
- layered = PR_DESC_LAYERED} RCIOType;
+ layered = PR_DESC_LAYERED
+ } RCIOType;
RCIO(RCIOType);
diff --git a/nsprpub/pr/src/cplus/rclock.cpp b/nsprpub/pr/src/cplus/rclock.cpp
index 60d13b8870..8c106de088 100644
--- a/nsprpub/pr/src/cplus/rclock.cpp
+++ b/nsprpub/pr/src/cplus/rclock.cpp
@@ -18,7 +18,9 @@ RCLock::RCLock()
RCLock::~RCLock()
{
- if (NULL != lock) PR_DestroyLock(lock);
+ if (NULL != lock) {
+ PR_DestroyLock(lock);
+ }
lock = NULL;
} /* RCLock::~RCLock */
diff --git a/nsprpub/pr/src/cplus/rclock.h b/nsprpub/pr/src/cplus/rclock.h
index 511b6fa4bd..c86c2f17b6 100644
--- a/nsprpub/pr/src/cplus/rclock.h
+++ b/nsprpub/pr/src/cplus/rclock.h
@@ -53,13 +53,21 @@ private:
RCEnter(const RCEnter&);
void operator=(const RCEnter&);
- void *operator new(PRSize) { return NULL; }
+ void *operator new(PRSize) {
+ return NULL;
+ }
void operator delete(void*) { }
}; /* RCEnter */
-inline RCEnter::RCEnter(RCLock* ml) { lock = ml; lock->Acquire(); }
-inline RCEnter::~RCEnter() { lock->Release(); lock = NULL; }
+inline RCEnter::RCEnter(RCLock* ml) {
+ lock = ml;
+ lock->Acquire();
+}
+inline RCEnter::~RCEnter() {
+ lock->Release();
+ lock = NULL;
+}
#endif /* defined(_RCLOCK_H) */
diff --git a/nsprpub/pr/src/cplus/rcnetdb.cpp b/nsprpub/pr/src/cplus/rcnetdb.cpp
index 042943bc4b..19eb66540f 100644
--- a/nsprpub/pr/src/cplus/rcnetdb.cpp
+++ b/nsprpub/pr/src/cplus/rcnetdb.cpp
@@ -15,7 +15,9 @@
#include <string.h>
RCNetAddr::RCNetAddr(const RCNetAddr& his): RCBase()
- { address = his.address; }
+{
+ address = his.address;
+}
RCNetAddr::RCNetAddr(const RCNetAddr& his, PRUint16 port): RCBase()
{
@@ -42,12 +44,18 @@ RCNetAddr::RCNetAddr(RCNetAddr::HostValue host, PRUint16 port): RCBase()
RCNetAddr::~RCNetAddr() { }
-void RCNetAddr::operator=(const RCNetAddr& his) { address = his.address; }
+void RCNetAddr::operator=(const RCNetAddr& his) {
+ address = his.address;
+}
PRStatus RCNetAddr::FromString(const char* string)
- { return PR_StringToNetAddr(string, &address); }
+{
+ return PR_StringToNetAddr(string, &address);
+}
-void RCNetAddr::operator=(const PRNetAddr* addr) { address = *addr; }
+void RCNetAddr::operator=(const PRNetAddr* addr) {
+ address = *addr;
+}
PRBool RCNetAddr::operator==(const RCNetAddr& his) const
{
@@ -76,14 +84,14 @@ PRBool RCNetAddr::EqualHost(const RCNetAddr& his) const
rv = (address.inet.ip == his.address.inet.ip); break;
case PR_AF_INET6:
rv = (0 == memcmp(
- &address.ipv6.ip, &his.address.ipv6.ip,
- sizeof(address.ipv6.ip)));
+ &address.ipv6.ip, &his.address.ipv6.ip,
+ sizeof(address.ipv6.ip)));
break;
#if defined(XP_UNIX)
case PR_AF_LOCAL:
rv = (0 == strncmp(
- address.local.path, his.address.local.path,
- sizeof(address.local.path)));
+ address.local.path, his.address.local.path,
+ sizeof(address.local.path)));
break;
#endif
default: break;
@@ -92,7 +100,9 @@ PRBool RCNetAddr::EqualHost(const RCNetAddr& his) const
} /* RCNetAddr::operator== */
PRStatus RCNetAddr::ToString(char *string, PRSize size) const
- { return PR_NetAddrToString(&address, string, size); }
+{
+ return PR_NetAddrToString(&address, string, size);
+}
/*
** RCHostLookup
@@ -100,7 +110,9 @@ PRStatus RCNetAddr::ToString(char *string, PRSize size) const
RCHostLookup::~RCHostLookup()
{
- if (NULL != address) delete [] address;
+ if (NULL != address) {
+ delete [] address;
+ }
} /* RCHostLookup::~RCHostLookup */
RCHostLookup::RCHostLookup(): RCBase()
@@ -118,14 +130,18 @@ PRStatus RCHostLookup::ByName(const char* name)
RCNetAddr* vector = NULL;
RCNetAddr* old_vector = NULL;
void* buffer = PR_Malloc(PR_NETDB_BUF_SIZE);
- if (NULL == buffer) return PR_FAILURE;
+ if (NULL == buffer) {
+ return PR_FAILURE;
+ }
rv = PR_GetHostByName(name, (char*)buffer, PR_NETDB_BUF_SIZE, &hostentry);
if (PR_SUCCESS == rv)
{
for (max = 0, index = 0;; ++max)
{
index = PR_EnumerateHostEnt(index, &hostentry, 0, &addr);
- if (0 == index) break;
+ if (0 == index) {
+ break;
+ }
}
if (max > 0)
{
@@ -133,7 +149,9 @@ PRStatus RCHostLookup::ByName(const char* name)
while (--max > 0)
{
index = PR_EnumerateHostEnt(index, &hostentry, 0, &addr);
- if (0 == index) break;
+ if (0 == index) {
+ break;
+ }
vector[index] = &addr;
}
{
@@ -142,10 +160,14 @@ PRStatus RCHostLookup::ByName(const char* name)
address = vector;
max_index = max;
}
- if (NULL != old_vector) delete [] old_vector;
+ if (NULL != old_vector) {
+ delete [] old_vector;
+ }
}
}
- if (NULL != buffer) PR_DELETE(buffer);
+ if (NULL != buffer) {
+ PR_DELETE(buffer);
+ }
return PR_SUCCESS;
} /* RCHostLookup::ByName */
@@ -158,14 +180,18 @@ PRStatus RCHostLookup::ByAddress(const RCNetAddr& host_addr)
RCNetAddr* vector = NULL;
RCNetAddr* old_vector = NULL;
char *buffer = (char*)PR_Malloc(PR_NETDB_BUF_SIZE);
- if (NULL == buffer) return PR_FAILURE;
+ if (NULL == buffer) {
+ return PR_FAILURE;
+ }
rv = PR_GetHostByAddr(host_addr, buffer, PR_NETDB_BUF_SIZE, &hostentry);
if (PR_SUCCESS == rv)
{
for (max = 0, index = 0;; ++max)
{
index = PR_EnumerateHostEnt(index, &hostentry, 0, &addr);
- if (0 == index) break;
+ if (0 == index) {
+ break;
+ }
}
if (max > 0)
{
@@ -173,7 +199,9 @@ PRStatus RCHostLookup::ByAddress(const RCNetAddr& host_addr)
while (--max > 0)
{
index = PR_EnumerateHostEnt(index, &hostentry, 0, &addr);
- if (0 == index) break;
+ if (0 == index) {
+ break;
+ }
vector[index] = &addr;
}
{
@@ -182,18 +210,23 @@ PRStatus RCHostLookup::ByAddress(const RCNetAddr& host_addr)
address = vector;
max_index = max;
}
- if (NULL != old_vector) delete [] old_vector;
+ if (NULL != old_vector) {
+ delete [] old_vector;
+ }
}
}
- if (NULL != buffer) PR_DELETE(buffer);
+ if (NULL != buffer) {
+ PR_DELETE(buffer);
+ }
return PR_SUCCESS;
} /* RCHostLookup::ByAddress */
const RCNetAddr* RCHostLookup::operator[](PRUintn which)
{
RCNetAddr* addr = NULL;
- if (which < max_index)
+ if (which < max_index) {
addr = &address[which];
+ }
return addr;
} /* RCHostLookup::operator[] */
diff --git a/nsprpub/pr/src/cplus/rcnetdb.h b/nsprpub/pr/src/cplus/rcnetdb.h
index 8096113bd7..14e96ecd85 100644
--- a/nsprpub/pr/src/cplus/rcnetdb.h
+++ b/nsprpub/pr/src/cplus/rcnetdb.h
@@ -28,16 +28,16 @@ public:
RCNetAddr(const RCNetAddr&); /* copy constructor */
RCNetAddr(HostValue, PRUint16 port);/* init'd w/ 'special' assignments */
RCNetAddr(const RCNetAddr&, PRUint16 port);
- /* copy w/ port reassigment */
+ /* copy w/ port reassigment */
virtual ~RCNetAddr();
void operator=(const RCNetAddr&);
virtual PRBool operator==(const RCNetAddr&) const;
- /* compare of all relavent fields */
+ /* compare of all relavent fields */
virtual PRBool EqualHost(const RCNetAddr&) const;
- /* compare of just host field */
+ /* compare of just host field */
public:
@@ -45,9 +45,9 @@ public:
void operator=(const PRNetAddr*); /* construction from more primitive data */
operator const PRNetAddr*() const; /* extraction of underlying representation */
virtual PRStatus FromString(const char* string);
- /* initialization from an ASCII string */
+ /* initialization from an ASCII string */
virtual PRStatus ToString(char *string, PRSize size) const;
- /* convert internal fromat to a string */
+ /* convert internal fromat to a string */
private:
@@ -87,7 +87,9 @@ private:
};
inline RCNetAddr::RCNetAddr(): RCBase() { }
-inline RCNetAddr::operator const PRNetAddr*() const { return &address; }
+inline RCNetAddr::operator const PRNetAddr*() const {
+ return &address;
+}
#endif /* defined(_RCNETDB_H) */
diff --git a/nsprpub/pr/src/cplus/rcnetio.cpp b/nsprpub/pr/src/cplus/rcnetio.cpp
index f511d81dc0..e351345e43 100644
--- a/nsprpub/pr/src/cplus/rcnetio.cpp
+++ b/nsprpub/pr/src/cplus/rcnetio.cpp
@@ -12,13 +12,20 @@
#include <private/pprio.h>
RCNetStreamIO::~RCNetStreamIO()
- { PRStatus rv = (fd->methods->close)(fd); fd = NULL; }
+{
+ PRStatus rv = (fd->methods->close)(fd);
+ fd = NULL;
+}
RCNetStreamIO::RCNetStreamIO(): RCIO(RCIO::tcp)
- { fd = PR_NewTCPSocket(); }
+{
+ fd = PR_NewTCPSocket();
+}
RCNetStreamIO::RCNetStreamIO(PRIntn protocol): RCIO(RCIO::tcp)
- { fd = PR_Socket(PR_AF_INET, PR_SOCK_STREAM, protocol); }
+{
+ fd = PR_Socket(PR_AF_INET, PR_SOCK_STREAM, protocol);
+}
RCIO* RCNetStreamIO::Accept(RCNetAddr* addr, const RCInterval& timeout)
{
@@ -33,8 +40,9 @@ RCIO* RCNetStreamIO::Accept(RCNetAddr* addr, const RCInterval& timeout)
*addr = &peer;
rcio->fd = newfd;
}
- else
+ else {
(void)(newfd->methods->close)(newfd);
+ }
}
return rcio;
} /* RCNetStreamIO::Accept */
@@ -42,35 +50,48 @@ RCIO* RCNetStreamIO::Accept(RCNetAddr* addr, const RCInterval& timeout)
PRInt32 RCNetStreamIO::AcceptRead(
RCIO **nd, RCNetAddr **raddr, void *buf,
PRSize amount, const RCInterval& timeout)
-{
+{
PRNetAddr *from;
PRFileDesc *accepted;
PRInt32 rv = (fd->methods->acceptread)(
- fd, &accepted, &from, buf, amount, timeout);
+ fd, &accepted, &from, buf, amount, timeout);
if (rv >= 0)
{
RCNetStreamIO *ns = new RCNetStreamIO();
- if (NULL != *nd) ns->fd = accepted;
- else {PR_Close(accepted); rv = -1; }
+ if (NULL != *nd) {
+ ns->fd = accepted;
+ }
+ else {
+ PR_Close(accepted);
+ rv = -1;
+ }
*nd = ns;
}
return rv;
} /* RCNetStreamIO::AcceptRead */
PRInt64 RCNetStreamIO::Available()
- { return (fd->methods->available64)(fd); }
+{
+ return (fd->methods->available64)(fd);
+}
PRStatus RCNetStreamIO::Bind(const RCNetAddr& addr)
- { return (fd->methods->bind)(fd, addr); }
+{
+ return (fd->methods->bind)(fd, addr);
+}
PRStatus RCNetStreamIO::Connect(const RCNetAddr& addr, const RCInterval& timeout)
- { return (fd->methods->connect)(fd, addr, timeout); }
+{
+ return (fd->methods->connect)(fd, addr, timeout);
+}
PRStatus RCNetStreamIO::GetLocalName(RCNetAddr *addr) const
{
PRNetAddr local;
PRStatus rv = (fd->methods->getsockname)(fd, &local);
- if (PR_SUCCESS == rv) *addr = &local;
+ if (PR_SUCCESS == rv) {
+ *addr = &local;
+ }
return rv;
} /* RCNetStreamIO::GetLocalName */
@@ -78,25 +99,37 @@ PRStatus RCNetStreamIO::GetPeerName(RCNetAddr *addr) const
{
PRNetAddr peer;
PRStatus rv = (fd->methods->getpeername)(fd, &peer);
- if (PR_SUCCESS == rv) *addr = &peer;
+ if (PR_SUCCESS == rv) {
+ *addr = &peer;
+ }
return rv;
} /* RCNetStreamIO::GetPeerName */
PRStatus RCNetStreamIO::GetSocketOption(PRSocketOptionData *data) const
- { return (fd->methods->getsocketoption)(fd, data); }
+{
+ return (fd->methods->getsocketoption)(fd, data);
+}
PRStatus RCNetStreamIO::Listen(PRIntn backlog)
- { return (fd->methods->listen)(fd, backlog); }
+{
+ return (fd->methods->listen)(fd, backlog);
+}
PRInt16 RCNetStreamIO::Poll(PRInt16 in_flags, PRInt16 *out_flags)
- { return (fd->methods->poll)(fd, in_flags, out_flags); }
+{
+ return (fd->methods->poll)(fd, in_flags, out_flags);
+}
PRInt32 RCNetStreamIO::Read(void *buf, PRSize amount)
- { return (fd->methods->read)(fd, buf, amount); }
+{
+ return (fd->methods->read)(fd, buf, amount);
+}
PRInt32 RCNetStreamIO::Recv(
void *buf, PRSize amount, PRIntn flags, const RCInterval& timeout)
- { return (fd->methods->recv)(fd, buf, amount, flags, timeout); }
+{
+ return (fd->methods->recv)(fd, buf, amount, flags, timeout);
+}
PRInt32 RCNetStreamIO::Recvfrom(
void *buf, PRSize amount, PRIntn flags,
@@ -104,25 +137,35 @@ PRInt32 RCNetStreamIO::Recvfrom(
{
PRNetAddr peer;
PRInt32 rv = (fd->methods->recvfrom)(
- fd, buf, amount, flags, &peer, timeout);
- if (-1 != rv) *addr = &peer;
+ fd, buf, amount, flags, &peer, timeout);
+ if (-1 != rv) {
+ *addr = &peer;
+ }
return rv;
} /* RCNetStreamIO::Recvfrom */
PRInt32 RCNetStreamIO::Send(
const void *buf, PRSize amount, PRIntn flags, const RCInterval& timeout)
- { return (fd->methods->send)(fd, buf, amount, flags, timeout); }
+{
+ return (fd->methods->send)(fd, buf, amount, flags, timeout);
+}
PRInt32 RCNetStreamIO::Sendto(
const void *buf, PRSize amount, PRIntn flags,
const RCNetAddr& addr, const RCInterval& timeout)
- { return (fd->methods->sendto)(fd, buf, amount, flags, addr, timeout); }
+{
+ return (fd->methods->sendto)(fd, buf, amount, flags, addr, timeout);
+}
PRStatus RCNetStreamIO::SetSocketOption(const PRSocketOptionData *data)
- { return (fd->methods->setsocketoption)(fd, data); }
+{
+ return (fd->methods->setsocketoption)(fd, data);
+}
PRStatus RCNetStreamIO::Shutdown(RCIO::ShutdownHow how)
- { return (fd->methods->shutdown)(fd, (PRIntn)how); }
+{
+ return (fd->methods->shutdown)(fd, (PRIntn)how);
+}
PRInt32 RCNetStreamIO::TransmitFile(
RCIO *source, const void *headers, PRSize hlen,
@@ -130,33 +173,52 @@ PRInt32 RCNetStreamIO::TransmitFile(
{
RCNetStreamIO *src = (RCNetStreamIO*)source;
return (fd->methods->transmitfile)(
- fd, src->fd, headers, hlen, (PRTransmitFileFlags)flags, timeout); }
+ fd, src->fd, headers, hlen, (PRTransmitFileFlags)flags, timeout);
+}
PRInt32 RCNetStreamIO::Write(const void *buf, PRSize amount)
- { return (fd->methods->write)(fd, buf, amount); }
+{
+ return (fd->methods->write)(fd, buf, amount);
+}
PRInt32 RCNetStreamIO::Writev(
const PRIOVec *iov, PRSize size, const RCInterval& timeout)
- { return (fd->methods->writev)(fd, iov, size, timeout); }
-
+{
+ return (fd->methods->writev)(fd, iov, size, timeout);
+}
+
/*
** Invalid functions
*/
PRStatus RCNetStreamIO::Close()
- { PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRStatus RCNetStreamIO::FileInfo(RCFileInfo*) const
- { PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRStatus RCNetStreamIO::Fsync()
- { return (fd->methods->fsync)(fd); }
+{
+ return (fd->methods->fsync)(fd);
+}
PRStatus RCNetStreamIO::Open(const char*, PRIntn, PRIntn)
- { PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
PRInt64 RCNetStreamIO::Seek(PRInt64, RCIO::Whence)
- { PR_SetError(PR_INVALID_METHOD_ERROR, 0); return PR_FAILURE; }
+{
+ PR_SetError(PR_INVALID_METHOD_ERROR, 0);
+ return PR_FAILURE;
+}
/* RCNetStreamIO.cpp */
diff --git a/nsprpub/pr/src/cplus/rcnetio.h b/nsprpub/pr/src/cplus/rcnetio.h
index 44b8bf071b..7f6b669d55 100644
--- a/nsprpub/pr/src/cplus/rcnetio.h
+++ b/nsprpub/pr/src/cplus/rcnetio.h
@@ -37,12 +37,12 @@ public:
virtual RCIO* Accept(RCNetAddr* addr, const RCInterval& timeout);
virtual PRInt32 AcceptRead(
- RCIO **nd, RCNetAddr **raddr, void *buf,
- PRSize amount, const RCInterval& timeout);
+ RCIO **nd, RCNetAddr **raddr, void *buf,
+ PRSize amount, const RCInterval& timeout);
virtual PRInt64 Available();
virtual PRStatus Bind(const RCNetAddr& addr);
virtual PRStatus Connect(
- const RCNetAddr& addr, const RCInterval& timeout);
+ const RCNetAddr& addr, const RCInterval& timeout);
virtual PRStatus GetLocalName(RCNetAddr *addr) const;
virtual PRStatus GetPeerName(RCNetAddr *addr) const;
virtual PRStatus GetSocketOption(PRSocketOptionData *data) const;
@@ -50,28 +50,28 @@ public:
virtual PRInt16 Poll(PRInt16 in_flags, PRInt16 *out_flags);
virtual PRInt32 Read(void *buf, PRSize amount);
virtual PRInt32 Recv(
- void *buf, PRSize amount, PRIntn flags,
- const RCInterval& timeout);
+ void *buf, PRSize amount, PRIntn flags,
+ const RCInterval& timeout);
virtual PRInt32 Recvfrom(
- void *buf, PRSize amount, PRIntn flags,
- RCNetAddr* addr, const RCInterval& timeout);
+ void *buf, PRSize amount, PRIntn flags,
+ RCNetAddr* addr, const RCInterval& timeout);
virtual PRInt32 Send(
- const void *buf, PRSize amount, PRIntn flags,
- const RCInterval& timeout);
+ const void *buf, PRSize amount, PRIntn flags,
+ const RCInterval& timeout);
virtual PRInt32 Sendto(
- const void *buf, PRSize amount, PRIntn flags,
- const RCNetAddr& addr,
- const RCInterval& timeout);
+ const void *buf, PRSize amount, PRIntn flags,
+ const RCNetAddr& addr,
+ const RCInterval& timeout);
virtual PRStatus SetSocketOption(const PRSocketOptionData *data);
virtual PRStatus Shutdown(ShutdownHow how);
virtual PRInt32 TransmitFile(
- RCIO *source, const void *headers,
- PRSize hlen, RCIO::FileDisposition flags,
- const RCInterval& timeout);
+ RCIO *source, const void *headers,
+ PRSize hlen, RCIO::FileDisposition flags,
+ const RCInterval& timeout);
virtual PRInt32 Write(const void *buf, PRSize amount);
virtual PRInt32 Writev(
- const PRIOVec *iov, PRSize size,
- const RCInterval& timeout);
+ const PRIOVec *iov, PRSize size,
+ const RCInterval& timeout);
private:
/* functions unavailable to this clients of this class */
diff --git a/nsprpub/pr/src/cplus/rcthread.cpp b/nsprpub/pr/src/cplus/rcthread.cpp
index 3db00d3695..471e580a2c 100755
--- a/nsprpub/pr/src/cplus/rcthread.cpp
+++ b/nsprpub/pr/src/cplus/rcthread.cpp
@@ -18,11 +18,13 @@ static RCPrimordialThread *primordial = NULL;
void nas_Root(void *arg)
{
RCThread *him = (RCThread*)arg;
- while (RCThread::ex_unstarted == him->execution)
- (void)PR_Sleep(PR_INTERVAL_NO_TIMEOUT); /* wait for Start() */
+ while (RCThread::ex_unstarted == him->execution) {
+ (void)PR_Sleep(PR_INTERVAL_NO_TIMEOUT); /* wait for Start() */
+ }
him->RootFunction(); /* he gets a self reference */
- if (PR_UNJOINABLE_THREAD == PR_GetThreadState(him->identity))
+ if (PR_UNJOINABLE_THREAD == PR_GetThreadState(him->identity)) {
delete him;
+ }
} /* nas_Root */
RCThread::~RCThread() { }
@@ -40,9 +42,9 @@ RCThread::RCThread(
{
execution = ex_unstarted;
identity = PR_CreateThread(
- PR_USER_THREAD, nas_Root, this,
- PR_GetThreadPriority(PR_GetCurrentThread()),
- (PRThreadScope)scope, (PRThreadState)join, stackSize);
+ PR_USER_THREAD, nas_Root, this,
+ PR_GetThreadPriority(PR_GetCurrentThread()),
+ (PRThreadScope)scope, (PRThreadState)join, stackSize);
} /* RCThread::RCThread */
void RCThread::operator=(const RCThread&)
@@ -77,8 +79,12 @@ PRStatus RCThread::Join()
rv = PR_FAILURE;
PR_SetError(PR_INVALID_STATE_ERROR, 0);
}
- else rv = PR_JoinThread(identity);
- if (PR_SUCCESS == rv) delete this;
+ else {
+ rv = PR_JoinThread(identity);
+ }
+ if (PR_SUCCESS == rv) {
+ delete this;
+ }
return rv;
} /* RCThread::Join */
@@ -90,27 +96,41 @@ PRStatus RCThread::Interrupt()
rv = PR_FAILURE;
PR_SetError(PR_INVALID_STATE_ERROR, 0);
}
- else rv = PR_Interrupt(identity);
+ else {
+ rv = PR_Interrupt(identity);
+ }
return rv;
} /* RCThread::Interrupt */
-void RCThread::ClearInterrupt() { PR_ClearInterrupt(); }
+void RCThread::ClearInterrupt() {
+ PR_ClearInterrupt();
+}
void RCThread::SetPriority(RCThread::Priority new_priority)
- { PR_SetThreadPriority(identity, (PRThreadPriority)new_priority); }
+{
+ PR_SetThreadPriority(identity, (PRThreadPriority)new_priority);
+}
PRThread *RCThread::Self()
- { return PR_GetCurrentThread(); }
+{
+ return PR_GetCurrentThread();
+}
RCThread::Scope RCThread::GetScope() const
- { return (RCThread::Scope)PR_GetThreadScope(identity); }
+{
+ return (RCThread::Scope)PR_GetThreadScope(identity);
+}
RCThread::State RCThread::GetState() const
- { return (RCThread::State)PR_GetThreadState(identity); }
+{
+ return (RCThread::State)PR_GetThreadState(identity);
+}
RCThread::Priority RCThread::GetPriority() const
- { return (RCThread::Priority)PR_GetThreadPriority(identity); }
-
+{
+ return (RCThread::Priority)PR_GetThreadPriority(identity);
+}
+
static void _rc_PDDestructor(RCThreadPrivateData* privateData)
{
PR_ASSERT(NULL != privateData);
@@ -120,10 +140,14 @@ static void _rc_PDDestructor(RCThreadPrivateData* privateData)
static PRThreadPrivateDTOR _tpd_dtor = (PRThreadPrivateDTOR)_rc_PDDestructor;
PRStatus RCThread::NewPrivateIndex(PRUintn* index)
- { return PR_NewThreadPrivateIndex(index, _tpd_dtor); }
+{
+ return PR_NewThreadPrivateIndex(index, _tpd_dtor);
+}
PRStatus RCThread::SetPrivateData(PRUintn index)
- { return PR_SetThreadPrivate(index, NULL); }
+{
+ return PR_SetThreadPrivate(index, NULL);
+}
PRStatus RCThread::SetPrivateData(PRUintn index, RCThreadPrivateData* data)
{
@@ -131,10 +155,15 @@ PRStatus RCThread::SetPrivateData(PRUintn index, RCThreadPrivateData* data)
}
RCThreadPrivateData* RCThread::GetPrivateData(PRUintn index)
- { return (RCThreadPrivateData*)PR_GetThreadPrivate(index); }
+{
+ return (RCThreadPrivateData*)PR_GetThreadPrivate(index);
+}
PRStatus RCThread::Sleep(const RCInterval& ticks)
- { PRIntervalTime tmo = ticks; return PR_Sleep(tmo); }
+{
+ PRIntervalTime tmo = ticks;
+ return PR_Sleep(tmo);
+}
RCPrimordialThread *RCThread::WrapPrimordialThread()
{
@@ -155,7 +184,9 @@ RCPrimordialThread *RCThread::WrapPrimordialThread()
me->execution = RCThread::ex_started;
me->identity = PR_GetCurrentThread();
}
- else delete me; /* somebody beat us to it */
+ else {
+ delete me; /* somebody beat us to it */
+ }
}
return primordial;
} /* RCThread::WrapPrimordialThread */
@@ -166,10 +197,12 @@ RCPrimordialThread::~RCPrimordialThread() { }
void RCPrimordialThread::RootFunction()
{
- PR_NOT_REACHED("Primordial thread calling root function");
+ PR_NOT_REACHED("Primordial thread calling root function");
} /* RCPrimordialThread::RootFunction */
-
-PRStatus RCPrimordialThread::Cleanup() { return PR_Cleanup(); }
+
+PRStatus RCPrimordialThread::Cleanup() {
+ return PR_Cleanup();
+}
PRStatus RCPrimordialThread::SetVirtualProcessors(PRIntn count)
{
diff --git a/nsprpub/pr/src/cplus/rcthread.h b/nsprpub/pr/src/cplus/rcthread.h
index 8683c0a550..b7716d4b99 100644
--- a/nsprpub/pr/src/cplus/rcthread.h
+++ b/nsprpub/pr/src/cplus/rcthread.h
@@ -31,7 +31,7 @@ class PR_IMPLEMENT(RCThread): public RCBase
{
public:
- typedef enum
+ typedef enum
{
local = PR_LOCAL_THREAD, global = PR_GLOBAL_THREAD
} Scope;
@@ -68,12 +68,12 @@ public:
* the target thread returns from it's root function.
*/
virtual PRStatus Join();
-
+
/*
* The priority of a newly created thread is the same as the creator.
* The priority may be changed either by the new thread itself, by
* the creator or any other arbitrary thread.
- */
+ */
virtual void SetPriority(Priority newPriority);
@@ -82,14 +82,14 @@ public:
* is doing and return with a well known error code.
*/
virtual PRStatus Interrupt();
-
+
/*
* And in case a thread was interrupted and didn't get a chance
* to have the notification delivered, a way to cancel the pending
* status.
*/
static void ClearInterrupt();
-
+
/*
* Methods to discover the attributes of an existing thread.
*/
@@ -150,15 +150,15 @@ private:
/* There is no public default constructor or copy constructor */
RCThread();
RCThread(const RCThread&);
-
+
/* And there is no assignment operator */
void operator=(const RCThread&);
public:
- static RCPrimordialThread *WrapPrimordialThread();
+ static RCPrimordialThread *WrapPrimordialThread();
+
+};
- };
-
/*
** class RCPrimordialThread
*/
@@ -180,7 +180,7 @@ public:
*/
static PRStatus SetVirtualProcessors(PRIntn count=10);
-friend class RCThread;
+ friend class RCThread;
private:
/*
** None other than the runtime can create of destruct
@@ -192,4 +192,4 @@ private:
void RootFunction();
}; /* RCPrimordialThread */
- #endif /* defined(_RCTHREAD_H) */
+#endif /* defined(_RCTHREAD_H) */
diff --git a/nsprpub/pr/src/cplus/rctime.cpp b/nsprpub/pr/src/cplus/rctime.cpp
index d65510402b..2c9823e15b 100644
--- a/nsprpub/pr/src/cplus/rctime.cpp
+++ b/nsprpub/pr/src/cplus/rctime.cpp
@@ -11,24 +11,46 @@
RCTime::~RCTime() { }
-RCTime::RCTime(PRTime time): RCBase() { gmt = time; }
-RCTime::RCTime(const RCTime& his): RCBase() { gmt = his.gmt; }
-RCTime::RCTime(RCTime::Current): RCBase() { gmt = PR_Now(); }
+RCTime::RCTime(PRTime time): RCBase() {
+ gmt = time;
+}
+RCTime::RCTime(const RCTime& his): RCBase() {
+ gmt = his.gmt;
+}
+RCTime::RCTime(RCTime::Current): RCBase() {
+ gmt = PR_Now();
+}
RCTime::RCTime(const PRExplodedTime& time): RCBase()
-{ gmt = PR_ImplodeTime(&time); }
+{
+ gmt = PR_ImplodeTime(&time);
+}
void RCTime::operator=(const PRExplodedTime& time)
-{ gmt = PR_ImplodeTime(&time); }
+{
+ gmt = PR_ImplodeTime(&time);
+}
RCTime RCTime::operator+(const RCTime& his)
-{ RCTime sum(gmt + his.gmt); return sum; }
+{
+ RCTime sum(gmt + his.gmt);
+ return sum;
+}
RCTime RCTime::operator-(const RCTime& his)
-{ RCTime difference(gmt - his.gmt); return difference; }
+{
+ RCTime difference(gmt - his.gmt);
+ return difference;
+}
RCTime RCTime::operator/(PRUint64 his)
-{ RCTime quotient(gmt / gmt); return quotient; }
+{
+ RCTime quotient(gmt / gmt);
+ return quotient;
+}
RCTime RCTime::operator*(PRUint64 his)
-{ RCTime product(gmt * his); return product; }
+{
+ RCTime product(gmt * his);
+ return product;
+}
diff --git a/nsprpub/pr/src/cplus/rctime.h b/nsprpub/pr/src/cplus/rctime.h
index 4cf7b90422..3752a3d53d 100644
--- a/nsprpub/pr/src/cplus/rctime.h
+++ b/nsprpub/pr/src/cplus/rctime.h
@@ -39,7 +39,7 @@ public:
virtual ~RCTime();
/* assignment operators */
- void operator=(const RCTime&);
+ void operator=(const RCTime&);
void operator=(const PRExplodedTime&);
/* comparitive operators */
@@ -75,31 +75,61 @@ public:
inline RCTime::RCTime(): RCBase() { }
-inline void RCTime::Now() { gmt = PR_Now(); }
-inline RCTime::operator PRTime() const { return gmt; }
+inline void RCTime::Now() {
+ gmt = PR_Now();
+}
+inline RCTime::operator PRTime() const {
+ return gmt;
+}
-inline void RCTime::operator=(PRTime his) { gmt = his; }
-inline void RCTime::operator=(const RCTime& his) { gmt = his.gmt; }
+inline void RCTime::operator=(PRTime his) {
+ gmt = his;
+}
+inline void RCTime::operator=(const RCTime& his) {
+ gmt = his.gmt;
+}
inline PRBool RCTime::operator<(const RCTime& his)
- { return (gmt < his.gmt) ? PR_TRUE : PR_FALSE; }
+{
+ return (gmt < his.gmt) ? PR_TRUE : PR_FALSE;
+}
inline PRBool RCTime::operator>(const RCTime& his)
- { return (gmt > his.gmt) ? PR_TRUE : PR_FALSE; }
+{
+ return (gmt > his.gmt) ? PR_TRUE : PR_FALSE;
+}
inline PRBool RCTime::operator<=(const RCTime& his)
- { return (gmt <= his.gmt) ? PR_TRUE : PR_FALSE; }
+{
+ return (gmt <= his.gmt) ? PR_TRUE : PR_FALSE;
+}
inline PRBool RCTime::operator>=(const RCTime& his)
- { return (gmt >= his.gmt) ? PR_TRUE : PR_FALSE; }
+{
+ return (gmt >= his.gmt) ? PR_TRUE : PR_FALSE;
+}
inline PRBool RCTime::operator==(const RCTime& his)
- { return (gmt == his.gmt) ? PR_TRUE : PR_FALSE; }
+{
+ return (gmt == his.gmt) ? PR_TRUE : PR_FALSE;
+}
inline RCTime& RCTime::operator+=(const RCTime& his)
- { gmt += his.gmt; return *this; }
+{
+ gmt += his.gmt;
+ return *this;
+}
inline RCTime& RCTime::operator-=(const RCTime& his)
- { gmt -= his.gmt; return *this; }
+{
+ gmt -= his.gmt;
+ return *this;
+}
inline RCTime& RCTime::operator/=(PRUint64 his)
- { gmt /= his; return *this; }
+{
+ gmt /= his;
+ return *this;
+}
inline RCTime& RCTime::operator*=(PRUint64 his)
- { gmt *= his; return *this; }
+{
+ gmt *= his;
+ return *this;
+}
#endif /* defined(_RCTIME_H) */
diff --git a/nsprpub/pr/src/cplus/tests/Makefile.in b/nsprpub/pr/src/cplus/tests/Makefile.in
index c164238721..df48276569 100644
--- a/nsprpub/pr/src/cplus/tests/Makefile.in
+++ b/nsprpub/pr/src/cplus/tests/Makefile.in
@@ -49,24 +49,6 @@ LDOPTS = -L$(dist_libdir)
LIBPR = -lnspr$(MOD_MAJOR_VERSION)
LIBPL = -lplc$(MOD_MAJOR_VERSION)
-ifeq ($(OS_ARCH), IRIX)
- LDOPTS += -rpath $(PWD)/$(dist_libdir) -rdata_shared
- # For 6.x machines, include this flag
- ifeq ($(basename $(OS_RELEASE)),6)
- ifeq ($(USE_N32),1)
- LDOPTS += -n32
- else
- LDOPTS += -32
- endif
-
- ifeq ($(USE_PTHREADS), 1)
- ifeq ($(OS_RELEASE), 6.2)
- LDOPTS += -Wl,-woff,85
- endif
- endif
- endif
-endif
-
# Solaris
ifeq ($(OS_ARCH), SunOS)
ifdef NS_USE_GCC
@@ -103,10 +85,6 @@ ifneq ($(OS_ARCH), WINNT)
PWD = $(shell pwd)
endif
-ifeq ($(OS_ARCH), OSF1)
-LDOPTS += -rpath $(PWD)/$(dist_libdir)
-endif
-
ifeq ($(OS_ARCH), HP-UX)
LDOPTS += -Wl,+s,+b,$(PWD)/$(dist_libdir)
endif
diff --git a/nsprpub/pr/src/cplus/tests/ranfile.cpp b/nsprpub/pr/src/cplus/tests/ranfile.cpp
index c3ac0d3a43..0fb4c5d23a 100644
--- a/nsprpub/pr/src/cplus/tests/ranfile.cpp
+++ b/nsprpub/pr/src/cplus/tests/ranfile.cpp
@@ -12,12 +12,12 @@
** Description: Test to hammer on various components of NSPR
** Modification History:
** 20-May-97 AGarcia- Converted the test to accomodate the debug_mode flag.
-** The debug mode will print all of the printfs associated with this test.
-** The regress mode will be the default mode. Since the regress tool limits
+** The debug mode will print all of the printfs associated with this test.
+** The regress mode will be the default mode. Since the regress tool limits
** the output to a one line status:PASS or FAIL,all of the printf statements
-** have been handled with an if (debug_mode) statement.
+** have been handled with an if (debug_mode) statement.
** 04-June-97 AGarcia removed the Test_Result function. Regress tool has been updated to
-** recognize the return code from tha main program.
+** recognize the return code from tha main program.
***********************************************************************/
@@ -46,19 +46,21 @@ class HammerData
{
public:
typedef enum {
- sg_go, sg_stop, sg_done} Action;
+ sg_go, sg_stop, sg_done
+ } Action;
typedef enum {
- sg_okay, sg_open, sg_close, sg_delete, sg_write, sg_seek} Problem;
+ sg_okay, sg_open, sg_close, sg_delete, sg_write, sg_seek
+ } Problem;
- virtual ~HammerData();
- HammerData(RCLock* lock, RCCondition *cond, PRUint32 clip);
+ virtual ~HammerData();
+ HammerData(RCLock* lock, RCCondition *cond, PRUint32 clip);
virtual PRUint32 Random();
Action action;
Problem problem;
PRUint32 writes;
RCInterval timein;
-friend class Hammer;
+ friend class Hammer;
private:
RCLock *ml;
RCCondition *cv;
@@ -117,7 +119,7 @@ Hammer::~Hammer() { }
Hammer::Hammer(
RCThread::Scope scope, RCLock* lock, RCCondition *cond, PRUint32 clip):
- HammerData(lock, cond, clip), RCThread(scope, RCThread::joinable, 0) { }
+ HammerData(lock, cond, clip), RCThread(scope, RCThread::joinable, 0) { }
HammerData::~HammerData() { }
@@ -171,7 +173,9 @@ void Hammer::RootFunction()
(void)sprintf(filename, "%ssg%04p.dat", baseName, this);
- if (debug_mode) PR_fprintf(output, "Starting work on %s\n", filename);
+ if (debug_mode) {
+ PR_fprintf(output, "Starting work on %s\n", filename);
+ }
while (PR_TRUE)
{
@@ -182,52 +186,78 @@ void Hammer::RootFunction()
while (minor-- > 0)
{
problem = sg_okay;
- if (action != sg_go) goto finished;
+ if (action != sg_go) {
+ goto finished;
+ }
problem = sg_open;
rv = file.Open(filename, PR_RDWR|PR_CREATE_FILE, 0666);
- if (PR_FAILURE == rv) goto finished;
+ if (PR_FAILURE == rv) {
+ goto finished;
+ }
for (index = 0; index < pages; index++)
{
problem = sg_okay;
- if (action != sg_go) goto close;
+ if (action != sg_go) {
+ goto close;
+ }
problem = sg_seek;
bytes = file.Seek(pageSize * index, RCFileIO::set);
- if (bytes != pageSize * index) goto close;
+ if (bytes != pageSize * index) {
+ goto close;
+ }
problem = sg_write;
bytes = file.Write(&zero, sizeof(zero));
- if (bytes <= 0) goto close;
+ if (bytes <= 0) {
+ goto close;
+ }
writes += 1;
}
problem = sg_close;
rv = file.Close();
- if (rv != PR_SUCCESS) goto purge;
+ if (rv != PR_SUCCESS) {
+ goto purge;
+ }
problem = sg_okay;
- if (action != sg_go) goto purge;
+ if (action != sg_go) {
+ goto purge;
+ }
problem = sg_open;
rv = file.Open(filename, PR_RDWR, 0666);
- if (PR_FAILURE == rv) goto finished;
+ if (PR_FAILURE == rv) {
+ goto finished;
+ }
for (index = 0; index < pages; index++)
{
problem = sg_okay;
- if (action != sg_go) goto close;
+ if (action != sg_go) {
+ goto close;
+ }
problem = sg_seek;
bytes = file.Seek(pageSize * index, RCFileIO::set);
- if (bytes != pageSize * index) goto close;
+ if (bytes != pageSize * index) {
+ goto close;
+ }
problem = sg_write;
bytes = file.Write(&zero, sizeof(zero));
- if (bytes <= 0) goto close;
+ if (bytes <= 0) {
+ goto close;
+ }
writes += 1;
random = (random + 511) % pages;
}
problem = sg_close;
rv = file.Close();
- if (rv != PR_SUCCESS) goto purge;
+ if (rv != PR_SUCCESS) {
+ goto purge;
+ }
problem = sg_delete;
rv = file.Delete(filename);
- if (rv != PR_SUCCESS) goto finished;
- }
+ if (rv != PR_SUCCESS) {
+ goto finished;
+ }
+ }
}
close:
@@ -239,7 +269,9 @@ finished:
action = HammerData::sg_done;
cv->Notify();
- if (debug_mode) PR_fprintf(output, "Ending work on %s\n", filename);
+ if (debug_mode) {
+ PR_fprintf(output, "Ending work on %s\n", filename);
+ }
return;
} /* Hammer::RootFunction */
@@ -278,7 +310,7 @@ static Hammer* hammer[100];
PRIntn main (PRIntn argc, char *argv[])
{
RCLock ml;
- PLOptStatus os;
+ PLOptStatus os;
RCCondition cv(&ml);
PRUint32 writesMax = 0, durationTot = 0;
RCThread::Scope thread_scope = RCThread::local;
@@ -288,57 +320,65 @@ PRIntn main (PRIntn argc, char *argv[])
const char *where[] = {"okay", "open", "close", "delete", "write", "seek"};
- PLOptState *opt = PL_CreateOptState(argc, argv, "Gdl:t:i:");
- while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
+ PLOptState *opt = PL_CreateOptState(argc, argv, "Gdl:t:i:");
+ while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
{
- if (PL_OPT_BAD == os) continue;
+ if (PL_OPT_BAD == os) {
+ continue;
+ }
switch (opt->option)
{
- case 0:
- baseName = opt->value;
- break;
- case 'G': /* global threads */
- thread_scope = RCThread::global;
- break;
- case 'd': /* debug mode */
- debug_mode = 1;
- break;
- case 'l': /* limiting number */
- limit = atoi(opt->value);
- break;
- case 't': /* number of threads */
- threads = atoi(opt->value);
- break;
- case 'i': /* iteration counter */
- max_virtual_procs = atoi(opt->value);
- break;
- default:
- break;
+ case 0:
+ baseName = opt->value;
+ break;
+ case 'G': /* global threads */
+ thread_scope = RCThread::global;
+ break;
+ case 'd': /* debug mode */
+ debug_mode = 1;
+ break;
+ case 'l': /* limiting number */
+ limit = atoi(opt->value);
+ break;
+ case 't': /* number of threads */
+ threads = atoi(opt->value);
+ break;
+ case 'i': /* iteration counter */
+ max_virtual_procs = atoi(opt->value);
+ break;
+ default:
+ break;
}
}
- PL_DestroyOptState(opt);
+ PL_DestroyOptState(opt);
output = PR_GetSpecialFD(PR_StandardOutput);
- /* main test */
-
+ /* main test */
+
cv.SetTimeout(interleave);
-
- if (max_virtual_procs == 0) max_virtual_procs = 2;
- if (limit == 0) limit = 57;
- if (threads == 0) threads = 10;
+
+ if (max_virtual_procs == 0) {
+ max_virtual_procs = 2;
+ }
+ if (limit == 0) {
+ limit = 57;
+ }
+ if (threads == 0) {
+ threads = 10;
+ }
if (debug_mode) PR_fprintf(output,
- "%s: Using %d virtual processors, %d threads, limit = %d and %s threads\n",
- programName, max_virtual_procs, threads, limit,
- (thread_scope == RCThread::local) ? "LOCAL" : "GLOBAL");
+ "%s: Using %d virtual processors, %d threads, limit = %d and %s threads\n",
+ programName, max_virtual_procs, threads, limit,
+ (thread_scope == RCThread::local) ? "LOCAL" : "GLOBAL");
for (virtual_procs = 0; virtual_procs < max_virtual_procs; ++virtual_procs)
{
if (debug_mode)
- PR_fprintf(output,
- "%s: Setting number of virtual processors to %d\n",
- programName, virtual_procs + 1);
- RCPrimordialThread::SetVirtualProcessors(virtual_procs + 1);
+ PR_fprintf(output,
+ "%s: Setting number of virtual processors to %d\n",
+ programName, virtual_procs + 1);
+ RCPrimordialThread::SetVirtualProcessors(virtual_procs + 1);
for (active = 0; active < threads; active++)
{
hammer[active] = new Hammer(thread_scope, &ml, &cv, limit);
@@ -354,8 +394,9 @@ PRIntn main (PRIntn argc, char *argv[])
RCEnter scope(&ml);
for (poll = 0; poll < threads; poll++)
{
- if (hammer[poll]->action == HammerData::sg_go) /* don't overwrite done */
- hammer[poll]->action = HammerData::sg_stop; /* ask him to stop */
+ if (hammer[poll]->action == HammerData::sg_go) { /* don't overwrite done */
+ hammer[poll]->action = HammerData::sg_stop; /* ask him to stop */
+ }
}
}
@@ -364,24 +405,32 @@ PRIntn main (PRIntn argc, char *argv[])
for (poll = 0; poll < threads; poll++)
{
ml.Acquire();
- while (hammer[poll]->action < HammerData::sg_done) cv.Wait();
+ while (hammer[poll]->action < HammerData::sg_done) {
+ cv.Wait();
+ }
ml.Release();
if (hammer[poll]->problem == HammerData::sg_okay)
{
duration = RCInterval(RCInterval::now) - hammer[poll]->timein;
writes = hammer[poll]->writes * 1000 / duration;
- if (writes < writesMin) writesMin = writes;
- if (writes > writesMax) writesMax = writes;
+ if (writes < writesMin) {
+ writesMin = writes;
+ }
+ if (writes > writesMax) {
+ writesMax = writes;
+ }
writesTot += hammer[poll]->writes;
durationTot += duration;
}
else
{
if (debug_mode) PR_fprintf(output,
- "%s: test failed %s after %ld seconds\n",
- programName, where[hammer[poll]->problem], duration);
- else failed_already=1;
+ "%s: test failed %s after %ld seconds\n",
+ programName, where[hammer[poll]->problem], duration);
+ else {
+ failed_already=1;
+ }
}
active -= 1; /* this is another one down */
(void)hammer[poll]->Join();
@@ -389,12 +438,12 @@ PRIntn main (PRIntn argc, char *argv[])
}
}
if (debug_mode) PR_fprintf(output,
- "%s: [%ld [%ld] %ld] writes/sec average\n",
- programName, writesMin,
- writesTot * 1000 / durationTot, writesMax);
+ "%s: [%ld [%ld] %ld] writes/sec average\n",
+ programName, writesMin,
+ writesTot * 1000 / durationTot, writesMax);
}
- failed_already |= (PR_FAILURE == RCPrimordialThread::Cleanup());
- PR_fprintf(output, "%s\n", (failed_already) ? "FAIL\n" : "PASS\n");
- return failed_already;
+ failed_already |= (PR_FAILURE == RCPrimordialThread::Cleanup());
+ PR_fprintf(output, "%s\n", (failed_already) ? "FAIL\n" : "PASS\n");
+ return failed_already;
} /* main */
diff --git a/nsprpub/pr/src/cplus/tests/switch.cpp b/nsprpub/pr/src/cplus/tests/switch.cpp
index 4cb14c48fb..00de8e3064 100644
--- a/nsprpub/pr/src/cplus/tests/switch.cpp
+++ b/nsprpub/pr/src/cplus/tests/switch.cpp
@@ -70,8 +70,12 @@ void Shared::RootFunction()
while (PR_SUCCESS == status)
{
RCEnter entry(ml);
- while (twiddle && (PR_SUCCESS == status)) status = Wait();
- if (verbosity) PR_fprintf(debug_out, "+");
+ while (twiddle && (PR_SUCCESS == status)) {
+ status = Wait();
+ }
+ if (verbosity) {
+ PR_fprintf(debug_out, "+");
+ }
twiddle = PR_TRUE;
next->twiddle = PR_FALSE;
next->Notify();
@@ -83,11 +87,11 @@ static void Help(void)
debug_out = PR_STDOUT;
PR_fprintf(
- debug_out, "Usage: >./switch [-d] [-c n] [-t n] [-T n] [-G]\n");
+ debug_out, "Usage: >./switch [-d] [-c n] [-t n] [-T n] [-G]\n");
PR_fprintf(
- debug_out, "-c n\tloops at thread level (default: %d)\n", DEFAULT_LOOPS);
+ debug_out, "-c n\tloops at thread level (default: %d)\n", DEFAULT_LOOPS);
PR_fprintf(
- debug_out, "-t n\tnumber of threads (default: %d)\n", DEFAULT_THREADS);
+ debug_out, "-t n\tnumber of threads (default: %d)\n", DEFAULT_THREADS);
PR_fprintf(debug_out, "-d\tturn on debugging output (default: FALSE)\n");
PR_fprintf(debug_out, "-v\tturn on verbose output (default: FALSE)\n");
PR_fprintf(debug_out, "-G n\tglobal threads only (default: FALSE)\n");
@@ -96,59 +100,63 @@ static void Help(void)
PRIntn main(PRIntn argc, char **argv)
{
- PLOptStatus os;
+ PLOptStatus os;
PRStatus status;
PRBool help = PR_FALSE;
PRUintn concurrency = 1;
RCThread::Scope thread_scope = RCThread::local;
PRUintn thread_count, inner_count, loop_count, average;
PRUintn thread_limit = DEFAULT_THREADS, loop_limit = DEFAULT_LOOPS;
- PLOptState *opt = PL_CreateOptState(argc, argv, "hdvc:t:C:G");
- while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
+ PLOptState *opt = PL_CreateOptState(argc, argv, "hdvc:t:C:G");
+ while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
{
- if (PL_OPT_BAD == os) continue;
+ if (PL_OPT_BAD == os) {
+ continue;
+ }
switch (opt->option)
{
- case 'v': /* verbose mode */
- verbosity = PR_TRUE;
- case 'd': /* debug mode */
- debug_mode = PR_TRUE;
- break;
- case 'c': /* loop counter */
- loop_limit = atoi(opt->value);
- break;
- case 't': /* thread limit */
- thread_limit = atoi(opt->value);
- break;
- case 'C': /* Concurrency limit */
- concurrency = atoi(opt->value);
- break;
- case 'G': /* global threads only */
- thread_scope = RCThread::global;
- break;
- case 'h': /* help message */
- Help();
- help = PR_TRUE;
- break;
- default:
- break;
+ case 'v': /* verbose mode */
+ verbosity = PR_TRUE;
+ case 'd': /* debug mode */
+ debug_mode = PR_TRUE;
+ break;
+ case 'c': /* loop counter */
+ loop_limit = atoi(opt->value);
+ break;
+ case 't': /* thread limit */
+ thread_limit = atoi(opt->value);
+ break;
+ case 'C': /* Concurrency limit */
+ concurrency = atoi(opt->value);
+ break;
+ case 'G': /* global threads only */
+ thread_scope = RCThread::global;
+ break;
+ case 'h': /* help message */
+ Help();
+ help = PR_TRUE;
+ break;
+ default:
+ break;
}
}
- PL_DestroyOptState(opt);
-
- if (help) return -1;
-
- if (PR_TRUE == debug_mode)
- {
- debug_out = PR_STDOUT;
- PR_fprintf(debug_out, "Test parameters\n");
- PR_fprintf(debug_out, "\tThreads involved: %d\n", thread_limit);
- PR_fprintf(debug_out, "\tIteration limit: %d\n", loop_limit);
- PR_fprintf(debug_out, "\tConcurrency: %d\n", concurrency);
- PR_fprintf(
- debug_out, "\tThread type: %s\n",
- (PR_GLOBAL_THREAD == thread_scope) ? "GLOBAL" : "LOCAL");
- }
+ PL_DestroyOptState(opt);
+
+ if (help) {
+ return -1;
+ }
+
+ if (PR_TRUE == debug_mode)
+ {
+ debug_out = PR_STDOUT;
+ PR_fprintf(debug_out, "Test parameters\n");
+ PR_fprintf(debug_out, "\tThreads involved: %d\n", thread_limit);
+ PR_fprintf(debug_out, "\tIteration limit: %d\n", loop_limit);
+ PR_fprintf(debug_out, "\tConcurrency: %d\n", concurrency);
+ PR_fprintf(
+ debug_out, "\tThread type: %s\n",
+ (PR_GLOBAL_THREAD == thread_scope) ? "GLOBAL" : "LOCAL");
+ }
/*
** The interesting part starts here
@@ -165,62 +173,68 @@ PRIntn main(PRIntn argc, char **argv)
shared = new Shared(thread_scope, link, &lock);
shared->Start(); /* make it run */
link = (Home*)shared;
- }
+ }
/* Pass the message around the horn a few times */
for (loop_count = 1; loop_count <= loop_limit; ++loop_count)
{
- timein.SetToNow();
- for (inner_count = 0; inner_count < INNER_LOOPS; ++inner_count)
- {
- RCEnter entry(&lock);
- home.twiddle = PR_TRUE;
- shared->twiddle = PR_FALSE;
- shared->Notify();
- while (home.twiddle)
+ timein.SetToNow();
+ for (inner_count = 0; inner_count < INNER_LOOPS; ++inner_count)
+ {
+ RCEnter entry(&lock);
+ home.twiddle = PR_TRUE;
+ shared->twiddle = PR_FALSE;
+ shared->Notify();
+ while (home.twiddle)
{
- failed = (PR_FAILURE == home.Wait()) ? PR_TRUE : PR_FALSE;
+ failed = (PR_FAILURE == home.Wait()) ? PR_TRUE : PR_FALSE;
}
- }
- timeout += (RCInterval(RCInterval::now) - timein);
- }
+ }
+ timeout += (RCInterval(RCInterval::now) - timein);
+ }
/* Figure out how well we did */
- if (debug_mode)
- {
- average = timeout.ToMicroseconds()
- / (INNER_LOOPS * loop_limit * thread_count);
- PR_fprintf(
- debug_out, "Average switch times %d usecs for %d threads\n",
+ if (debug_mode)
+ {
+ average = timeout.ToMicroseconds()
+ / (INNER_LOOPS * loop_limit * thread_count);
+ PR_fprintf(
+ debug_out, "Average switch times %d usecs for %d threads\n",
average, thread_limit);
- }
+ }
/* Start reclamation process */
link = shared;
for (thread_count = 1; thread_count <= thread_limit; ++thread_count)
{
- if (&home == link) break;
+ if (&home == link) {
+ break;
+ }
status = ((Shared*)link)->Interrupt();
- if (PR_SUCCESS != status)
+ if (PR_SUCCESS != status)
{
failed = PR_TRUE;
- if (debug_mode)
- PL_FPrintError(debug_out, "Failed to interrupt");
+ if (debug_mode) {
+ PL_FPrintError(debug_out, "Failed to interrupt");
+ }
}
- link = link->next;
+ link = link->next;
}
for (thread_count = 1; thread_count <= thread_limit; ++thread_count)
{
link = shared->next;
status = shared->Join();
- if (PR_SUCCESS != status)
- {
+ if (PR_SUCCESS != status)
+ {
failed = PR_TRUE;
- if (debug_mode)
- PL_FPrintError(debug_out, "Failed to join");
+ if (debug_mode) {
+ PL_FPrintError(debug_out, "Failed to join");
+ }
+ }
+ if (&home == link) {
+ break;
}
- if (&home == link) break;
shared = (Shared*)link;
}
diff --git a/nsprpub/pr/src/cplus/tests/thread.cpp b/nsprpub/pr/src/cplus/tests/thread.cpp
index 442c534d0b..ff01402d8d 100644
--- a/nsprpub/pr/src/cplus/tests/thread.cpp
+++ b/nsprpub/pr/src/cplus/tests/thread.cpp
@@ -28,7 +28,9 @@ private:
TestThread::~TestThread() { }
TestThread::TestThread(RCThread::State state, PRIntn count):
- RCThread(RCThread::global, state, 0) { mydata = count; }
+ RCThread(RCThread::global, state, 0) {
+ mydata = count;
+}
void TestThread::RootFunction()
{
@@ -46,7 +48,7 @@ public:
PRIntn data;
};
-Foo1::Foo1()
+Foo1::Foo1()
{
data = 0xafaf;
thread = new TestThread(RCThread::joinable, 0xafaf);
diff --git a/nsprpub/pr/src/cplus/tests/tpd.cpp b/nsprpub/pr/src/cplus/tests/tpd.cpp
index 42290ab118..2a18c9cb11 100644
--- a/nsprpub/pr/src/cplus/tests/tpd.cpp
+++ b/nsprpub/pr/src/cplus/tests/tpd.cpp
@@ -68,8 +68,9 @@ static void PrintProgress(PRIntn line)
static void MyAssert(const char *expr, const char *file, PRIntn line)
{
- if (debug > 0)
+ if (debug > 0) {
(void)PR_fprintf(fout, "'%s' in file: %s: %d\n", expr, file, line);
+ }
} /* MyAssert */
#define MY_ASSERT(_expr) \
@@ -86,14 +87,16 @@ int main(PRIntn argc, char *argv[])
RCThread *primordial = RCThread::WrapPrimordialThread();
while (PL_OPT_EOL != (os = PL_GetNextOpt(opt)))
{
- if (PL_OPT_BAD == os) continue;
+ if (PL_OPT_BAD == os) {
+ continue;
+ }
switch (opt->option)
{
- case 'd': /* debug mode */
- debug = PR_TRUE;
- break;
- default:
- break;
+ case 'd': /* debug mode */
+ debug = PR_TRUE;
+ break;
+ default:
+ break;
}
}
PL_DestroyOptState(opt);
@@ -103,8 +106,9 @@ int main(PRIntn argc, char *argv[])
MyPrivateData extension = MyPrivateData("EXTENSION");
MyPrivateData key_string[] = {
"Key #0", "Key #1", "Key #2", "Key #3",
- "Bogus #5", "Bogus #6", "Bogus #7", "Bogus #8"};
-
+ "Bogus #5", "Bogus #6", "Bogus #7", "Bogus #8"
+ };
+
did = should = PR_FALSE;
for (keys = 0; keys < 4; ++keys)
@@ -133,7 +137,7 @@ int main(PRIntn argc, char *argv[])
}
PrintProgress(__LINE__);
- /* re-assign the private data, albeit the same content */
+ /* re-assign the private data, albeit the same content */
did = PR_FALSE; should = PR_TRUE;
for (keys = 0; keys < 4; ++keys)
{
@@ -190,13 +194,21 @@ int main(PRIntn argc, char *argv[])
MY_ASSERT(PR_SUCCESS == rv);
}
- if (debug) PR_fprintf(fout, "Creating thread\n");
+ if (debug) {
+ PR_fprintf(fout, "Creating thread\n");
+ }
thread = new MyThread();
- if (debug) PR_fprintf(fout, "Starting thread\n");
+ if (debug) {
+ PR_fprintf(fout, "Starting thread\n");
+ }
thread->Start();
- if (debug) PR_fprintf(fout, "Joining thread\n");
+ if (debug) {
+ PR_fprintf(fout, "Joining thread\n");
+ }
(void)thread->Join();
- if (debug) PR_fprintf(fout, "Joined thread\n");
+ if (debug) {
+ PR_fprintf(fout, "Joined thread\n");
+ }
failed |= (PR_FAILURE == RCPrimordialThread::Cleanup());
@@ -237,8 +249,12 @@ MyPrivateData::MyPrivateData(const MyPrivateData& him): RCThreadPrivateData(him)
void MyPrivateData::Release()
{
- if (should) did = PR_TRUE;
- else failed = PR_TRUE;
+ if (should) {
+ did = PR_TRUE;
+ }
+ else {
+ failed = PR_TRUE;
+ }
} /* MyPrivateData::operator= */
/*
@@ -253,12 +269,13 @@ void MyThread::RootFunction()
PRStatus rv;
PRUintn keys;
const RCThreadPrivateData *pd;
-
+
MyPrivateData extension = MyPrivateData("EXTENSION");
MyPrivateData key_string[] = {
"Key #0", "Key #1", "Key #2", "Key #3",
- "Bogus #5", "Bogus #6", "Bogus #7", "Bogus #8"};
-
+ "Bogus #5", "Bogus #6", "Bogus #7", "Bogus #8"
+ };
+
did = should = PR_FALSE;
for (keys = 0; keys < 8; ++keys)
{
@@ -284,7 +301,7 @@ void MyThread::RootFunction()
}
PrintProgress(__LINE__);
#endif
-
+
did = PR_FALSE; should = PR_TRUE;
for (keys = 0; keys < 4; ++keys)
{