added new operators

This commit is contained in:
Jeff Hill
1996-07-09 23:01:04 +00:00
parent 1df41d2964
commit d4f77948a0

View File

@@ -29,6 +29,9 @@
*
* History
* $Log$
* Revision 1.1 1996/06/26 22:14:11 jhill
* added new src files
*
* Revision 1.2 1996/06/21 02:03:40 jhill
* added stdio.h include
*
@@ -59,6 +62,12 @@ class osiTime {
(const osiTime &lhs, const osiTime &rhs);
static friend int operator>=
(const osiTime &lhs, const osiTime &rhs);
static friend int operator>
(const osiTime &lhs, const osiTime &rhs);
static friend int operator<=
(const osiTime &lhs, const osiTime &rhs);
static friend int operator<
(const osiTime &lhs, const osiTime &rhs);
public:
osiTime () : sec(0u), nSec(0u) {}
osiTime (const osiTime &t) : sec(t.sec), nSec(t.nSec) {}
@@ -190,7 +199,53 @@ inline osiTime osiTime::operator-= (const osiTime &rhs)
return *this;
}
inline int operator>= (const osiTime &lhs, const osiTime &rhs)
inline int operator <= (const osiTime &lhs, const osiTime &rhs)
{
int rc;
//
// Sun's CC -O generates bad code when this was rearranged
//
if (lhs.sec<rhs.sec) {
rc = 1;
}
else if (lhs.sec>rhs.sec) {
rc = 0;
}
else {
if (lhs.nSec<=rhs.nSec) {
rc = 1;
}
else {
rc = 0;
}
}
return rc;
}
inline int operator < (const osiTime &lhs, const osiTime &rhs)
{
int rc;
//
// Sun's CC -O generates bad code when this was rearranged
//
if (lhs.sec<rhs.sec) {
rc = 1;
}
else if (lhs.sec>rhs.sec) {
rc = 0;
}
else {
if (lhs.nSec<rhs.nSec) {
rc = 1;
}
else {
rc = 0;
}
}
return rc;
}
inline int operator >= (const osiTime &lhs, const osiTime &rhs)
{
int rc;
//
@@ -227,5 +282,28 @@ inline int operator>= (const osiTime &lhs, const osiTime &rhs)
return rc;
}
inline int operator > (const osiTime &lhs, const osiTime &rhs)
{
int rc;
//
// Sun's CC -O generates bad code when this was rearranged
//
if (lhs.sec>rhs.sec) {
rc = 1;
}
else if (lhs.sec<rhs.sec) {
rc = 0;
}
else {
if (lhs.nSec>rhs.nSec) {
rc = 1;
}
else {
rc = 0;
}
}
return rc;
}
#endif // osiTimehInclude