v1.2b1
parent
b1a42eb629
commit
718455beb5
|
|
@ -79,6 +79,7 @@ class NormApp : public NormController, public ProtoApp
|
||||||
char* address; // session address
|
char* address; // session address
|
||||||
UINT16 port; // session port number
|
UINT16 port; // session port number
|
||||||
UINT8 ttl;
|
UINT8 ttl;
|
||||||
|
char* interface_name; // for multi-home hosts
|
||||||
double tx_rate; // bits/sec
|
double tx_rate; // bits/sec
|
||||||
bool cc_enable;
|
bool cc_enable;
|
||||||
|
|
||||||
|
|
@ -120,7 +121,8 @@ NormApp::NormApp()
|
||||||
push_stream(false), msg_flush_mode(NormStreamObject::FLUSH_PASSIVE),
|
push_stream(false), msg_flush_mode(NormStreamObject::FLUSH_PASSIVE),
|
||||||
input_messaging(false), input_msg_length(0), input_msg_index(0),
|
input_messaging(false), input_msg_length(0), input_msg_index(0),
|
||||||
output_index(0), output_messaging(false), output_msg_length(0), output_msg_sync(false),
|
output_index(0), output_messaging(false), output_msg_length(0), output_msg_sync(false),
|
||||||
address(NULL), port(0), ttl(3), tx_rate(64000.0), cc_enable(false),
|
address(NULL), port(0), ttl(3), interface_name(NULL),
|
||||||
|
tx_rate(64000.0), cc_enable(false),
|
||||||
segment_size(1024), ndata(32), nparity(16), auto_parity(0), extra_parity(0),
|
segment_size(1024), ndata(32), nparity(16), auto_parity(0), extra_parity(0),
|
||||||
backoff_factor(NormSession::DEFAULT_BACKOFF_FACTOR),
|
backoff_factor(NormSession::DEFAULT_BACKOFF_FACTOR),
|
||||||
tx_buffer_size(1024*1024),
|
tx_buffer_size(1024*1024),
|
||||||
|
|
@ -161,6 +163,7 @@ const char* const NormApp::cmd_list[] =
|
||||||
"+rxloss", // rx packet loss percent (for testing)
|
"+rxloss", // rx packet loss percent (for testing)
|
||||||
"+address", // session destination address
|
"+address", // session destination address
|
||||||
"+ttl", // multicast hop count scope
|
"+ttl", // multicast hop count scope
|
||||||
|
"+interface", // multicast interface name to use
|
||||||
"+cc", // congestion control on/off
|
"+cc", // congestion control on/off
|
||||||
"+rate", // tx date rate (bps)
|
"+rate", // tx date rate (bps)
|
||||||
"-push", // push stream writes for real-time messaging
|
"-push", // push stream writes for real-time messaging
|
||||||
|
|
@ -350,6 +353,17 @@ bool NormApp::OnCommand(const char* cmd, const char* val)
|
||||||
}
|
}
|
||||||
ttl = ttlTemp;
|
ttl = ttlTemp;
|
||||||
}
|
}
|
||||||
|
else if (!strncmp("interface", cmd, len))
|
||||||
|
{
|
||||||
|
if (interface_name) delete[] interface_name;
|
||||||
|
if (!(interface_name = new char[strlen(val)+1]))
|
||||||
|
{
|
||||||
|
DMSG(0, "NormApp::OnCommand(interface) error allocating string: %s\n",
|
||||||
|
GetErrorString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
strcpy(interface_name, val);
|
||||||
|
}
|
||||||
else if (!strncmp("rate", cmd, len))
|
else if (!strncmp("rate", cmd, len))
|
||||||
{
|
{
|
||||||
double txRate = atof(val);
|
double txRate = atof(val);
|
||||||
|
|
@ -1273,11 +1287,11 @@ bool NormApp::OnStartup(int argc, const char*const* argv)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (control_remote) return false;
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
signal(SIGCHLD, SignalHandler);
|
signal(SIGCHLD, SignalHandler);
|
||||||
#endif // UNIX
|
#endif // UNIX
|
||||||
|
|
||||||
if (control_remote) return false;
|
|
||||||
|
|
||||||
// Validate our application settings
|
// Validate our application settings
|
||||||
if (!address)
|
if (!address)
|
||||||
|
|
@ -1309,7 +1323,7 @@ bool NormApp::OnStartup(int argc, const char*const* argv)
|
||||||
session->ServerSetBaseObjectId(baseId);
|
session->ServerSetBaseObjectId(baseId);
|
||||||
|
|
||||||
session->SetCongestionControl(cc_enable);
|
session->SetCongestionControl(cc_enable);
|
||||||
if (!session->StartServer(tx_buffer_size, segment_size, ndata, nparity))
|
if (!session->StartServer(tx_buffer_size, segment_size, ndata, nparity, interface_name))
|
||||||
{
|
{
|
||||||
DMSG(0, "NormApp::OnStartup() start server error!\n");
|
DMSG(0, "NormApp::OnStartup() start server error!\n");
|
||||||
session_mgr.Destroy();
|
session_mgr.Destroy();
|
||||||
|
|
@ -1335,7 +1349,7 @@ bool NormApp::OnStartup(int argc, const char*const* argv)
|
||||||
// StartClient(bufferMax (per-sender))
|
// StartClient(bufferMax (per-sender))
|
||||||
session->SetUnicastNacks(unicast_nacks);
|
session->SetUnicastNacks(unicast_nacks);
|
||||||
session->ClientSetSilent(silent_client);
|
session->ClientSetSilent(silent_client);
|
||||||
if (!session->StartClient(rx_buffer_size))
|
if (!session->StartClient(rx_buffer_size, interface_name))
|
||||||
{
|
{
|
||||||
DMSG(0, "NormApp::OnStartup() start client error!\n");
|
DMSG(0, "NormApp::OnStartup() start client error!\n");
|
||||||
session_mgr.Destroy();
|
session_mgr.Destroy();
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ NormBitmask::~NormBitmask()
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NormBitmask::Init(unsigned long numBits)
|
bool NormBitmask::Init(UINT32 numBits)
|
||||||
{
|
{
|
||||||
if (mask) Destroy();
|
if (mask) Destroy();
|
||||||
// Allocate memory for mask
|
// Allocate memory for mask
|
||||||
|
|
@ -199,13 +199,13 @@ void NormBitmask::Destroy()
|
||||||
} // end NormBitmask::Destroy()
|
} // end NormBitmask::Destroy()
|
||||||
|
|
||||||
|
|
||||||
bool NormBitmask::GetNextSet(unsigned long& index) const
|
bool NormBitmask::GetNextSet(UINT32& index) const
|
||||||
{
|
{
|
||||||
//TRACE("NormBitmask::GetNextSet(%lu) first_set:%lu num_bits:%lu\n",
|
//TRACE("NormBitmask::GetNextSet(%lu) first_set:%lu num_bits:%lu\n",
|
||||||
// index, first_set, num_bits);
|
// index, first_set, num_bits);
|
||||||
if (index >= num_bits) return false;
|
if (index >= num_bits) return false;
|
||||||
if (index < first_set) return GetFirstSet(index);
|
if (index < first_set) return GetFirstSet(index);
|
||||||
unsigned long maskIndex = index >> 3;
|
UINT32 maskIndex = index >> 3;
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
{
|
{
|
||||||
int w = WEIGHT[mask[maskIndex]];
|
int w = WEIGHT[mask[maskIndex]];
|
||||||
|
|
@ -231,11 +231,11 @@ bool NormBitmask::GetNextSet(unsigned long& index) const
|
||||||
return false;
|
return false;
|
||||||
} // end NormBitmask::NextSet()
|
} // end NormBitmask::NextSet()
|
||||||
|
|
||||||
bool NormBitmask::GetPrevSet(unsigned long& index) const
|
bool NormBitmask::GetPrevSet(UINT32& index) const
|
||||||
{
|
{
|
||||||
if (index >= num_bits) index = num_bits - 1;
|
if (index >= num_bits) index = num_bits - 1;
|
||||||
if (index < first_set) return false;
|
if (index < first_set) return false;
|
||||||
unsigned long maskIndex = index >> 3;
|
UINT32 maskIndex = index >> 3;
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
{
|
{
|
||||||
int w = WEIGHT[mask[maskIndex]] - 1;
|
int w = WEIGHT[mask[maskIndex]] - 1;
|
||||||
|
|
@ -251,7 +251,7 @@ bool NormBitmask::GetPrevSet(unsigned long& index) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maskIndex--;
|
maskIndex--;
|
||||||
unsigned long startIndex = first_set >> 3;
|
UINT32 startIndex = first_set >> 3;
|
||||||
for (; maskIndex >= startIndex; maskIndex--)
|
for (; maskIndex >= startIndex; maskIndex--)
|
||||||
{
|
{
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
|
|
@ -264,11 +264,11 @@ bool NormBitmask::GetPrevSet(unsigned long& index) const
|
||||||
return false; // (nothing prior was set)
|
return false; // (nothing prior was set)
|
||||||
} // end NormBitmask::PrevSet()
|
} // end NormBitmask::PrevSet()
|
||||||
|
|
||||||
bool NormBitmask::GetNextUnset(unsigned long& index) const
|
bool NormBitmask::GetNextUnset(UINT32& index) const
|
||||||
{
|
{
|
||||||
if (index >= num_bits) return false;
|
if (index >= num_bits) return false;
|
||||||
unsigned long next = index;
|
UINT32 next = index;
|
||||||
unsigned long maskIndex = next >> 3;
|
UINT32 maskIndex = next >> 3;
|
||||||
unsigned char bit = 0x80 >> (next & 0x07);
|
unsigned char bit = 0x80 >> (next & 0x07);
|
||||||
while (next < num_bits)
|
while (next < num_bits)
|
||||||
{
|
{
|
||||||
|
|
@ -298,11 +298,11 @@ bool NormBitmask::GetNextUnset(unsigned long& index) const
|
||||||
} // end NormBitmask::NextUnset()
|
} // end NormBitmask::NextUnset()
|
||||||
|
|
||||||
|
|
||||||
bool NormBitmask::SetBits(unsigned long index, unsigned long count)
|
bool NormBitmask::SetBits(UINT32 index, UINT32 count)
|
||||||
{
|
{
|
||||||
if (0 == count) return true;
|
if (0 == count) return true;
|
||||||
if ((index+count) > num_bits) return false;
|
if ((index+count) > num_bits) return false;
|
||||||
unsigned long maskIndex = index >> 3;
|
UINT32 maskIndex = index >> 3;
|
||||||
// To set appropriate bits in first byte
|
// To set appropriate bits in first byte
|
||||||
unsigned int bitIndex = index & 0x07;
|
unsigned int bitIndex = index & 0x07;
|
||||||
unsigned int bitRemainder = 8 - bitIndex;
|
unsigned int bitRemainder = 8 - bitIndex;
|
||||||
|
|
@ -315,7 +315,7 @@ bool NormBitmask::SetBits(unsigned long index, unsigned long count)
|
||||||
{
|
{
|
||||||
mask[maskIndex] |= 0x00ff >> bitIndex;
|
mask[maskIndex] |= 0x00ff >> bitIndex;
|
||||||
count -= bitRemainder;
|
count -= bitRemainder;
|
||||||
unsigned long nbytes = count >> 3;
|
UINT32 nbytes = count >> 3;
|
||||||
memset(&mask[++maskIndex], 0xff, nbytes);
|
memset(&mask[++maskIndex], 0xff, nbytes);
|
||||||
count &= 0x07;
|
count &= 0x07;
|
||||||
if (count)
|
if (count)
|
||||||
|
|
@ -326,16 +326,16 @@ bool NormBitmask::SetBits(unsigned long index, unsigned long count)
|
||||||
} // end NormBitmask::SetBits()
|
} // end NormBitmask::SetBits()
|
||||||
|
|
||||||
|
|
||||||
bool NormBitmask::UnsetBits(unsigned long index, unsigned long count)
|
bool NormBitmask::UnsetBits(UINT32 index, UINT32 count)
|
||||||
{
|
{
|
||||||
if ((index >= num_bits)|| (0 == count)) return true;
|
if ((index >= num_bits)|| (0 == count)) return true;
|
||||||
unsigned long end = index + count;
|
UINT32 end = index + count;
|
||||||
if (end > num_bits)
|
if (end > num_bits)
|
||||||
{
|
{
|
||||||
end = num_bits;
|
end = num_bits;
|
||||||
count = end - index;
|
count = end - index;
|
||||||
}
|
}
|
||||||
unsigned long maskIndex = index >> 3;
|
UINT32 maskIndex = index >> 3;
|
||||||
// To unset appropriate bits in first byte
|
// To unset appropriate bits in first byte
|
||||||
unsigned int bitIndex = index & 0x07;
|
unsigned int bitIndex = index & 0x07;
|
||||||
unsigned int bitRemainder = 8 - bitIndex;
|
unsigned int bitRemainder = 8 - bitIndex;
|
||||||
|
|
@ -348,7 +348,7 @@ bool NormBitmask::UnsetBits(unsigned long index, unsigned long count)
|
||||||
{
|
{
|
||||||
mask[maskIndex] &= 0x00ff << bitRemainder;
|
mask[maskIndex] &= 0x00ff << bitRemainder;
|
||||||
count -= bitRemainder;
|
count -= bitRemainder;
|
||||||
unsigned long nbytes = count >> 3;
|
UINT32 nbytes = count >> 3;
|
||||||
memset(&mask[++maskIndex], 0, nbytes);
|
memset(&mask[++maskIndex], 0, nbytes);
|
||||||
count &= 0x07;
|
count &= 0x07;
|
||||||
if (count) mask[maskIndex+nbytes] &= 0xff >> count;
|
if (count) mask[maskIndex+nbytes] &= 0xff >> count;
|
||||||
|
|
@ -385,8 +385,8 @@ bool NormBitmask::Add(const NormBitmask& b)
|
||||||
// this = this & ~b
|
// this = this & ~b
|
||||||
bool NormBitmask::Subtract(const NormBitmask& b)
|
bool NormBitmask::Subtract(const NormBitmask& b)
|
||||||
{
|
{
|
||||||
unsigned long len = (mask_len < b.mask_len) ? mask_len : b.mask_len;
|
UINT32 len = (mask_len < b.mask_len) ? mask_len : b.mask_len;
|
||||||
for(unsigned long i = 0; i < len; i++)
|
for(UINT32 i = 0; i < len; i++)
|
||||||
mask[i] &= ~b.mask[i];
|
mask[i] &= ~b.mask[i];
|
||||||
if (first_set >= b.first_set)
|
if (first_set >= b.first_set)
|
||||||
{
|
{
|
||||||
|
|
@ -421,7 +421,7 @@ bool NormBitmask::XCopy(const NormBitmask& b)
|
||||||
// this = this & b
|
// this = this & b
|
||||||
bool NormBitmask::Multiply(const NormBitmask& b)
|
bool NormBitmask::Multiply(const NormBitmask& b)
|
||||||
{
|
{
|
||||||
unsigned long len = (mask_len < b.mask_len) ? mask_len : b.mask_len;
|
UINT32 len = (mask_len < b.mask_len) ? mask_len : b.mask_len;
|
||||||
for(unsigned int i = 0; i < len; i++)
|
for(unsigned int i = 0; i < len; i++)
|
||||||
mask[i] |= b.mask[i];
|
mask[i] |= b.mask[i];
|
||||||
if (len < mask_len) memset(&mask[len], 0, mask_len - len);
|
if (len < mask_len) memset(&mask[len], 0, mask_len - len);
|
||||||
|
|
@ -452,8 +452,8 @@ bool NormBitmask::Xor(const NormBitmask& b)
|
||||||
|
|
||||||
void NormBitmask::Display(FILE* stream)
|
void NormBitmask::Display(FILE* stream)
|
||||||
{
|
{
|
||||||
unsigned long index = 0;
|
UINT32 index = 0;
|
||||||
for (unsigned long i = 0; i < num_bits; i++)
|
for (UINT32 i = 0; i < num_bits; i++)
|
||||||
{
|
{
|
||||||
if (Test(index++)) fprintf(stream, "1"); else fprintf(stream, "0");
|
if (Test(index++)) fprintf(stream, "1"); else fprintf(stream, "0");
|
||||||
if (0x07 == (i & 0x07)) fprintf(stream, " ");
|
if (0x07 == (i & 0x07)) fprintf(stream, " ");
|
||||||
|
|
@ -478,12 +478,12 @@ NormSlidingMask::~NormSlidingMask()
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NormSlidingMask::Init(long numBits, UINT32 rangeMask)
|
bool NormSlidingMask::Init(INT32 numBits, UINT32 rangeMask)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (mask) Destroy();
|
if (mask) Destroy();
|
||||||
if (numBits <= 0) return false;
|
if (numBits <= 0) return false;
|
||||||
unsigned long len = (numBits + 7) >> 3;
|
UINT32 len = (numBits + 7) >> 3;
|
||||||
if ((mask = new unsigned char[len]))
|
if ((mask = new unsigned char[len]))
|
||||||
{
|
{
|
||||||
range_mask = rangeMask;
|
range_mask = rangeMask;
|
||||||
|
|
@ -509,13 +509,13 @@ void NormSlidingMask::Destroy()
|
||||||
}
|
}
|
||||||
} // end NormSlidingMask::Destroy()
|
} // end NormSlidingMask::Destroy()
|
||||||
|
|
||||||
bool NormSlidingMask::CanSet(unsigned long index) const
|
bool NormSlidingMask::CanSet(UINT32 index) const
|
||||||
{
|
{
|
||||||
if (IsSet())
|
if (IsSet())
|
||||||
{
|
{
|
||||||
// Determine position with respect to current start
|
// Determine position with respect to current start
|
||||||
// and end, given the "offset" of the current start
|
// and end, given the "offset" of the current start
|
||||||
long pos = Delta(index, offset);
|
INT32 pos = Delta(index, offset);
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
{
|
{
|
||||||
// Precedes start.
|
// Precedes start.
|
||||||
|
|
@ -555,14 +555,14 @@ bool NormSlidingMask::CanSet(unsigned long index) const
|
||||||
}
|
}
|
||||||
} // end NormSlidingMask::CanSet()
|
} // end NormSlidingMask::CanSet()
|
||||||
|
|
||||||
bool NormSlidingMask::Set(unsigned long index)
|
bool NormSlidingMask::Set(UINT32 index)
|
||||||
{
|
{
|
||||||
ASSERT(CanSet(index));
|
ASSERT(CanSet(index));
|
||||||
if (IsSet())
|
if (IsSet())
|
||||||
{
|
{
|
||||||
// Determine position with respect to current start
|
// Determine position with respect to current start
|
||||||
// and end, given the "offset" of the current start
|
// and end, given the "offset" of the current start
|
||||||
long pos = Delta(index , offset);
|
INT32 pos = Delta(index , offset);
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
{
|
{
|
||||||
// Precedes start.
|
// Precedes start.
|
||||||
|
|
@ -607,7 +607,7 @@ bool NormSlidingMask::Set(unsigned long index)
|
||||||
return false; // out of range
|
return false; // out of range
|
||||||
}
|
}
|
||||||
ASSERT((pos >> 3) >= 0);
|
ASSERT((pos >> 3) >= 0);
|
||||||
ASSERT((pos >> 3) < (long)mask_len);
|
ASSERT((pos >> 3) < (INT32)mask_len);
|
||||||
mask[(pos >> 3)] |= (0x80 >> (pos & 0x07));
|
mask[(pos >> 3)] |= (0x80 >> (pos & 0x07));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -619,12 +619,12 @@ bool NormSlidingMask::Set(unsigned long index)
|
||||||
return true;
|
return true;
|
||||||
} // end NormSlidingMask::Set()
|
} // end NormSlidingMask::Set()
|
||||||
|
|
||||||
bool NormSlidingMask::Unset(unsigned long index)
|
bool NormSlidingMask::Unset(UINT32 index)
|
||||||
{
|
{
|
||||||
//ASSERT(CanSet(index));
|
//ASSERT(CanSet(index));
|
||||||
if (IsSet())
|
if (IsSet())
|
||||||
{
|
{
|
||||||
long pos = Delta(index, offset);
|
INT32 pos = Delta(index, offset);
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
{
|
{
|
||||||
return true; // out-of-range
|
return true; // out-of-range
|
||||||
|
|
@ -645,7 +645,7 @@ bool NormSlidingMask::Unset(unsigned long index)
|
||||||
// Yes, it was in range.
|
// Yes, it was in range.
|
||||||
// Unset the corresponding bit
|
// Unset the corresponding bit
|
||||||
ASSERT((pos >> 3) >= 0);
|
ASSERT((pos >> 3) >= 0);
|
||||||
ASSERT((pos >> 3) < (long)mask_len);
|
ASSERT((pos >> 3) < (INT32)mask_len);
|
||||||
mask[(pos >> 3)] &= ~(0x80 >> (pos & 0x07));
|
mask[(pos >> 3)] &= ~(0x80 >> (pos & 0x07));
|
||||||
if (start == end)
|
if (start == end)
|
||||||
{
|
{
|
||||||
|
|
@ -655,9 +655,9 @@ bool NormSlidingMask::Unset(unsigned long index)
|
||||||
}
|
}
|
||||||
if (start == pos)
|
if (start == pos)
|
||||||
{
|
{
|
||||||
unsigned long next = index;
|
UINT32 next = index;
|
||||||
if (!GetNextSet(next)) ASSERT(0);
|
if (!GetNextSet(next)) ASSERT(0);
|
||||||
long delta = Delta(next, offset);
|
INT32 delta = Delta(next, offset);
|
||||||
ASSERT(delta >= 0);
|
ASSERT(delta >= 0);
|
||||||
start += delta;
|
start += delta;
|
||||||
if (start >= num_bits) start -= num_bits;
|
if (start >= num_bits) start -= num_bits;
|
||||||
|
|
@ -665,9 +665,9 @@ bool NormSlidingMask::Unset(unsigned long index)
|
||||||
}
|
}
|
||||||
if (pos == end)
|
if (pos == end)
|
||||||
{
|
{
|
||||||
unsigned long prev = index;
|
UINT32 prev = index;
|
||||||
if (!GetPrevSet(prev)) ASSERT(0);
|
if (!GetPrevSet(prev)) ASSERT(0);
|
||||||
long delta = Delta(prev, offset);
|
INT32 delta = Delta(prev, offset);
|
||||||
ASSERT(delta >= 0);
|
ASSERT(delta >= 0);
|
||||||
end = start + delta;
|
end = start + delta;
|
||||||
if (end >= num_bits) end -= num_bits;
|
if (end >= num_bits) end -= num_bits;
|
||||||
|
|
@ -681,16 +681,16 @@ bool NormSlidingMask::Unset(unsigned long index)
|
||||||
return true;
|
return true;
|
||||||
} // end NormSlidingMask::Unset()
|
} // end NormSlidingMask::Unset()
|
||||||
|
|
||||||
bool NormSlidingMask::SetBits(unsigned long index, long count)
|
bool NormSlidingMask::SetBits(UINT32 index, INT32 count)
|
||||||
{
|
{
|
||||||
ASSERT(CanSet(index));
|
ASSERT(CanSet(index));
|
||||||
ASSERT(CanSet(index+count-1));
|
ASSERT(CanSet(index+count-1));
|
||||||
if (count < 0) return false;
|
if (count < 0) return false;
|
||||||
if (0 == count) return true;
|
if (0 == count) return true;
|
||||||
long firstPos, lastPos;
|
INT32 firstPos, lastPos;
|
||||||
if (IsSet())
|
if (IsSet())
|
||||||
{
|
{
|
||||||
long last = index + count - 1;
|
INT32 last = index + count - 1;
|
||||||
if (!CanSet(index)) return false;
|
if (!CanSet(index)) return false;
|
||||||
if (!CanSet(last)) return false;
|
if (!CanSet(last)) return false;
|
||||||
// Calculate first set bit position
|
// Calculate first set bit position
|
||||||
|
|
@ -733,29 +733,29 @@ bool NormSlidingMask::SetBits(unsigned long index, long count)
|
||||||
{
|
{
|
||||||
// Set bits from firstPos to num_bits
|
// Set bits from firstPos to num_bits
|
||||||
count = num_bits - firstPos;
|
count = num_bits - firstPos;
|
||||||
long maskIndex = firstPos >> 3;
|
INT32 maskIndex = firstPos >> 3;
|
||||||
int bitIndex = firstPos & 0x07;
|
int bitIndex = firstPos & 0x07;
|
||||||
int bitRemainder = 8 - bitIndex;
|
int bitRemainder = 8 - bitIndex;
|
||||||
ASSERT(maskIndex >= 0);
|
ASSERT(maskIndex >= 0);
|
||||||
if (count <= bitRemainder)
|
if (count <= bitRemainder)
|
||||||
{
|
{
|
||||||
ASSERT(maskIndex < (long)mask_len);
|
ASSERT(maskIndex < (INT32)mask_len);
|
||||||
mask[maskIndex] |= (0x00ff >> bitIndex) &
|
mask[maskIndex] |= (0x00ff >> bitIndex) &
|
||||||
(0x00ff << (bitRemainder - count));
|
(0x00ff << (bitRemainder - count));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(maskIndex < (long)mask_len);
|
ASSERT(maskIndex < (INT32)mask_len);
|
||||||
mask[maskIndex] |= 0x00ff >> bitIndex;
|
mask[maskIndex] |= 0x00ff >> bitIndex;
|
||||||
count -= bitRemainder;
|
count -= bitRemainder;
|
||||||
long nbytes = count >> 3;
|
INT32 nbytes = count >> 3;
|
||||||
ASSERT((maskIndex+1+nbytes) <= (long)mask_len);
|
ASSERT((maskIndex+1+nbytes) <= (INT32)mask_len);
|
||||||
memset(&mask[++maskIndex], 0xff, nbytes);
|
memset(&mask[++maskIndex], 0xff, nbytes);
|
||||||
count &= 0x07;
|
count &= 0x07;
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
ASSERT((maskIndex+nbytes) >= 0);
|
ASSERT((maskIndex+nbytes) >= 0);
|
||||||
ASSERT((maskIndex+nbytes) < (long)mask_len);
|
ASSERT((maskIndex+nbytes) < (INT32)mask_len);
|
||||||
mask[maskIndex+nbytes] |= 0xff << (8-count);
|
mask[maskIndex+nbytes] |= 0xff << (8-count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -766,51 +766,51 @@ bool NormSlidingMask::SetBits(unsigned long index, long count)
|
||||||
{
|
{
|
||||||
if (count > num_bits) return false;
|
if (count > num_bits) return false;
|
||||||
start = firstPos = 0;
|
start = firstPos = 0;
|
||||||
end = lastPos = (long)(count - 1);
|
end = lastPos = (INT32)(count - 1);
|
||||||
offset = index;
|
offset = index;
|
||||||
}
|
}
|
||||||
// Set bits from firstPos to lastPos
|
// Set bits from firstPos to lastPos
|
||||||
count = lastPos - firstPos + 1;
|
count = lastPos - firstPos + 1;
|
||||||
long maskIndex = firstPos >> 3;
|
INT32 maskIndex = firstPos >> 3;
|
||||||
int bitIndex = firstPos & 0x07;
|
int bitIndex = firstPos & 0x07;
|
||||||
int bitRemainder = 8 - bitIndex;
|
int bitRemainder = 8 - bitIndex;
|
||||||
ASSERT(maskIndex >= 0);
|
ASSERT(maskIndex >= 0);
|
||||||
if (count <= bitRemainder)
|
if (count <= bitRemainder)
|
||||||
{
|
{
|
||||||
ASSERT(maskIndex < (long)mask_len);
|
ASSERT(maskIndex < (INT32)mask_len);
|
||||||
mask[maskIndex] |= (0x00ff >> bitIndex) &
|
mask[maskIndex] |= (0x00ff >> bitIndex) &
|
||||||
(0x00ff << (bitRemainder - count));
|
(0x00ff << (bitRemainder - count));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(maskIndex < (long)mask_len);
|
ASSERT(maskIndex < (INT32)mask_len);
|
||||||
mask[maskIndex] |= 0x00ff >> bitIndex;
|
mask[maskIndex] |= 0x00ff >> bitIndex;
|
||||||
count -= bitRemainder;
|
count -= bitRemainder;
|
||||||
long nbytes = count >> 3;
|
INT32 nbytes = count >> 3;
|
||||||
ASSERT((maskIndex+1+nbytes) <= (long)mask_len);
|
ASSERT((maskIndex+1+nbytes) <= (INT32)mask_len);
|
||||||
memset(&mask[++maskIndex], 0xff, nbytes);
|
memset(&mask[++maskIndex], 0xff, nbytes);
|
||||||
count &= 0x07;
|
count &= 0x07;
|
||||||
if (count)
|
if (count)
|
||||||
{
|
{
|
||||||
ASSERT((maskIndex+nbytes) >= 0);
|
ASSERT((maskIndex+nbytes) >= 0);
|
||||||
ASSERT((maskIndex+nbytes) < (long)mask_len);
|
ASSERT((maskIndex+nbytes) < (INT32)mask_len);
|
||||||
mask[maskIndex+nbytes] |= 0xff << (8-count);
|
mask[maskIndex+nbytes] |= 0xff << (8-count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} // end NormSlidingMask::SetBits()
|
} // end NormSlidingMask::SetBits()
|
||||||
|
|
||||||
bool NormSlidingMask::UnsetBits(unsigned long index, long count)
|
bool NormSlidingMask::UnsetBits(UINT32 index, INT32 count)
|
||||||
{
|
{
|
||||||
//ASSERT(CanSet(index));
|
//ASSERT(CanSet(index));
|
||||||
//ASSERT(CanSet(index+count-1));
|
//ASSERT(CanSet(index+count-1));
|
||||||
if (IsSet())
|
if (IsSet())
|
||||||
{
|
{
|
||||||
// Trim to fit as needed.
|
// Trim to fit as needed.
|
||||||
long firstPos;
|
INT32 firstPos;
|
||||||
if (count <= 0) return true;
|
if (count <= 0) return true;
|
||||||
if (count > num_bits) count = num_bits;
|
if (count > num_bits) count = num_bits;
|
||||||
long delta = Delta(index , offset);
|
INT32 delta = Delta(index , offset);
|
||||||
if (delta >= num_bits)
|
if (delta >= num_bits)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -829,7 +829,7 @@ bool NormSlidingMask::UnsetBits(unsigned long index, long count)
|
||||||
UINT32 lastSet;
|
UINT32 lastSet;
|
||||||
if (!GetLastSet(lastSet)) ASSERT(0);
|
if (!GetLastSet(lastSet)) ASSERT(0);
|
||||||
delta = Delta((index+count-1), lastSet);
|
delta = Delta((index+count-1), lastSet);
|
||||||
long lastPos;
|
INT32 lastPos;
|
||||||
if (delta < 0)
|
if (delta < 0)
|
||||||
{
|
{
|
||||||
lastPos = firstPos + count - 1;
|
lastPos = firstPos + count - 1;
|
||||||
|
|
@ -839,26 +839,26 @@ bool NormSlidingMask::UnsetBits(unsigned long index, long count)
|
||||||
{
|
{
|
||||||
lastPos = end;
|
lastPos = end;
|
||||||
}
|
}
|
||||||
long startPos;
|
INT32 startPos;
|
||||||
if (lastPos < firstPos)
|
if (lastPos < firstPos)
|
||||||
{
|
{
|
||||||
// Set bits from firstPos to num_bits
|
// Set bits from firstPos to num_bits
|
||||||
count = num_bits - firstPos;
|
count = num_bits - firstPos;
|
||||||
long maskIndex = firstPos >> 3;
|
INT32 maskIndex = firstPos >> 3;
|
||||||
int bitIndex = firstPos & 0x07;
|
int bitIndex = firstPos & 0x07;
|
||||||
int bitRemainder = 8 - bitIndex;
|
int bitRemainder = 8 - bitIndex;
|
||||||
if (count <= bitRemainder)
|
if (count <= bitRemainder)
|
||||||
{
|
{
|
||||||
ASSERT(maskIndex < (long)mask_len);
|
ASSERT(maskIndex < (INT32)mask_len);
|
||||||
mask[maskIndex] &= (0x00ff << bitRemainder) |
|
mask[maskIndex] &= (0x00ff << bitRemainder) |
|
||||||
(0x00ff >> (bitIndex + count));
|
(0x00ff >> (bitIndex + count));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(maskIndex < (long)mask_len);
|
ASSERT(maskIndex < (INT32)mask_len);
|
||||||
mask[maskIndex] &= 0x00ff << bitRemainder;
|
mask[maskIndex] &= 0x00ff << bitRemainder;
|
||||||
count -= bitRemainder;
|
count -= bitRemainder;
|
||||||
unsigned long nbytes = count >> 3;
|
UINT32 nbytes = count >> 3;
|
||||||
ASSERT((maskIndex+1+nbytes) <= mask_len);
|
ASSERT((maskIndex+1+nbytes) <= mask_len);
|
||||||
memset(&mask[++maskIndex], 0, nbytes);
|
memset(&mask[++maskIndex], 0, nbytes);
|
||||||
count &= 0x07;
|
count &= 0x07;
|
||||||
|
|
@ -876,21 +876,21 @@ bool NormSlidingMask::UnsetBits(unsigned long index, long count)
|
||||||
}
|
}
|
||||||
// Unset bits from firstPos to lastPos
|
// Unset bits from firstPos to lastPos
|
||||||
count = lastPos - startPos + 1;
|
count = lastPos - startPos + 1;
|
||||||
long maskIndex = startPos >> 3;
|
INT32 maskIndex = startPos >> 3;
|
||||||
int bitIndex = startPos & 0x07;
|
int bitIndex = startPos & 0x07;
|
||||||
int bitRemainder = 8 - bitIndex;
|
int bitRemainder = 8 - bitIndex;
|
||||||
if (count <= bitRemainder)
|
if (count <= bitRemainder)
|
||||||
{
|
{
|
||||||
ASSERT(maskIndex < (long)mask_len);
|
ASSERT(maskIndex < (INT32)mask_len);
|
||||||
mask[maskIndex] &= (0x00ff << bitRemainder) |
|
mask[maskIndex] &= (0x00ff << bitRemainder) |
|
||||||
(0x00ff >> (bitIndex + count));
|
(0x00ff >> (bitIndex + count));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(maskIndex < (long)mask_len);
|
ASSERT(maskIndex < (INT32)mask_len);
|
||||||
mask[maskIndex] &= 0x00ff << bitRemainder;
|
mask[maskIndex] &= 0x00ff << bitRemainder;
|
||||||
count -= bitRemainder;
|
count -= bitRemainder;
|
||||||
unsigned long nbytes = count >> 3;
|
UINT32 nbytes = count >> 3;
|
||||||
ASSERT((maskIndex+1+nbytes) <= mask_len);
|
ASSERT((maskIndex+1+nbytes) <= mask_len);
|
||||||
memset(&mask[++maskIndex], 0, nbytes);
|
memset(&mask[++maskIndex], 0, nbytes);
|
||||||
count &= 0x07;
|
count &= 0x07;
|
||||||
|
|
@ -922,11 +922,11 @@ bool NormSlidingMask::UnsetBits(unsigned long index, long count)
|
||||||
return true;
|
return true;
|
||||||
} // end NormSlidingMask::UnsetBits()
|
} // end NormSlidingMask::UnsetBits()
|
||||||
|
|
||||||
bool NormSlidingMask::Test(unsigned long index) const
|
bool NormSlidingMask::Test(UINT32 index) const
|
||||||
{
|
{
|
||||||
if (IsSet())
|
if (IsSet())
|
||||||
{
|
{
|
||||||
long pos = Delta(index , offset);
|
INT32 pos = Delta(index , offset);
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
{
|
{
|
||||||
// Is it in range?
|
// Is it in range?
|
||||||
|
|
@ -950,12 +950,12 @@ bool NormSlidingMask::Test(unsigned long index) const
|
||||||
} // end NormSlidingMask::Test()
|
} // end NormSlidingMask::Test()
|
||||||
|
|
||||||
|
|
||||||
bool NormSlidingMask::GetNextSet(unsigned long& index) const
|
bool NormSlidingMask::GetNextSet(UINT32& index) const
|
||||||
{
|
{
|
||||||
if (IsSet())
|
if (IsSet())
|
||||||
{
|
{
|
||||||
unsigned long next = index;
|
UINT32 next = index;
|
||||||
long pos = Delta(next, offset);
|
INT32 pos = Delta(next, offset);
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
{
|
{
|
||||||
// Is it in range?
|
// Is it in range?
|
||||||
|
|
@ -972,7 +972,7 @@ bool NormSlidingMask::GetNextSet(unsigned long& index) const
|
||||||
if ((pos < start) || (pos > end)) return false;
|
if ((pos < start) || (pos > end)) return false;
|
||||||
}
|
}
|
||||||
// Seek next set bit
|
// Seek next set bit
|
||||||
unsigned long maskIndex = pos >> 3;
|
UINT32 maskIndex = pos >> 3;
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
{
|
{
|
||||||
int w = WEIGHT[mask[maskIndex]];
|
int w = WEIGHT[mask[maskIndex]];
|
||||||
|
|
@ -1006,7 +1006,7 @@ bool NormSlidingMask::GetNextSet(unsigned long& index) const
|
||||||
}
|
}
|
||||||
maskIndex = 0;
|
maskIndex = 0;
|
||||||
}
|
}
|
||||||
unsigned long endIndex = end >> 3;
|
UINT32 endIndex = end >> 3;
|
||||||
for (; maskIndex <= endIndex; maskIndex++)
|
for (; maskIndex <= endIndex; maskIndex++)
|
||||||
{
|
{
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
|
|
@ -1027,12 +1027,12 @@ bool NormSlidingMask::GetNextSet(unsigned long& index) const
|
||||||
return false; // indicates nothing was set
|
return false; // indicates nothing was set
|
||||||
} // end NormSlidingMask::GetNextSet()
|
} // end NormSlidingMask::GetNextSet()
|
||||||
|
|
||||||
bool NormSlidingMask::GetPrevSet(unsigned long& index) const
|
bool NormSlidingMask::GetPrevSet(UINT32& index) const
|
||||||
{
|
{
|
||||||
if (IsSet())
|
if (IsSet())
|
||||||
{
|
{
|
||||||
unsigned long prev = index;
|
UINT32 prev = index;
|
||||||
long pos = Delta(prev, offset);
|
INT32 pos = Delta(prev, offset);
|
||||||
if (pos >= 0)
|
if (pos >= 0)
|
||||||
{
|
{
|
||||||
// Is it in range?
|
// Is it in range?
|
||||||
|
|
@ -1051,7 +1051,7 @@ bool NormSlidingMask::GetPrevSet(unsigned long& index) const
|
||||||
if ((pos < start) || (pos > end)) return false;
|
if ((pos < start) || (pos > end)) return false;
|
||||||
}
|
}
|
||||||
// Seek prev set bits, starting with index
|
// Seek prev set bits, starting with index
|
||||||
long maskIndex = pos >> 3;
|
INT32 maskIndex = pos >> 3;
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
{
|
{
|
||||||
int w = WEIGHT[mask[maskIndex]] - 1;
|
int w = WEIGHT[mask[maskIndex]] - 1;
|
||||||
|
|
@ -1087,7 +1087,7 @@ bool NormSlidingMask::GetPrevSet(unsigned long& index) const
|
||||||
}
|
}
|
||||||
maskIndex = mask_len - 1;
|
maskIndex = mask_len - 1;
|
||||||
}
|
}
|
||||||
long startIndex = start >> 3;
|
INT32 startIndex = start >> 3;
|
||||||
for (; maskIndex >= startIndex; maskIndex--)
|
for (; maskIndex >= startIndex; maskIndex--)
|
||||||
{
|
{
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
|
|
@ -1105,10 +1105,10 @@ bool NormSlidingMask::GetPrevSet(unsigned long& index) const
|
||||||
return false; // indicates nothing prior was set
|
return false; // indicates nothing prior was set
|
||||||
} // end NormSlidingMask::GetPrevSet()
|
} // end NormSlidingMask::GetPrevSet()
|
||||||
|
|
||||||
/*unsigned long NormSlidingMask::RawNextSet(const char* mask, long index, long end)
|
/*UINT32 NormSlidingMask::RawNextSet(const char* mask, INT32 index, INT32 end)
|
||||||
{
|
{
|
||||||
// Seek next set bit
|
// Seek next set bit
|
||||||
unsigned long maskIndex = index >> 3;
|
UINT32 maskIndex = index >> 3;
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
{
|
{
|
||||||
int w = WEIGHT[mask[maskIndex]];
|
int w = WEIGHT[mask[maskIndex]];
|
||||||
|
|
@ -1121,7 +1121,7 @@ bool NormSlidingMask::GetPrevSet(unsigned long& index) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maskIndex++;
|
maskIndex++;
|
||||||
unsigned long endIndex = end >> 3;
|
UINT32 endIndex = end >> 3;
|
||||||
for (; maskIndex <= endIndex; maskIndex++)
|
for (; maskIndex <= endIndex; maskIndex++)
|
||||||
{
|
{
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
|
|
@ -1130,10 +1130,10 @@ bool NormSlidingMask::GetPrevSet(unsigned long& index) const
|
||||||
return (index-1); // (nothing was set)
|
return (index-1); // (nothing was set)
|
||||||
} // end NormSlidingMask::RawNextSet()
|
} // end NormSlidingMask::RawNextSet()
|
||||||
|
|
||||||
unsigned long NormSlidingMask::RawPrevSet(const char* mask, long index, long start)
|
UINT32 NormSlidingMask::RawPrevSet(const char* mask, INT32 index, INT32 start)
|
||||||
{
|
{
|
||||||
// Seek prev set bits, starting with index
|
// Seek prev set bits, starting with index
|
||||||
unsigned long maskIndex = index >> 3;
|
UINT32 maskIndex = index >> 3;
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
{
|
{
|
||||||
int w = WEIGHT[mask[maskIndex]] - 1;
|
int w = WEIGHT[mask[maskIndex]] - 1;
|
||||||
|
|
@ -1148,7 +1148,7 @@ unsigned long NormSlidingMask::RawPrevSet(const char* mask, long index, long sta
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
maskIndex--;
|
maskIndex--;
|
||||||
unsigned long startIndex = start >> 3;
|
UINT32 startIndex = start >> 3;
|
||||||
for (; maskIndex >= startIndex; maskIndex--)
|
for (; maskIndex >= startIndex; maskIndex--)
|
||||||
{
|
{
|
||||||
if (mask[maskIndex])
|
if (mask[maskIndex])
|
||||||
|
|
@ -1164,7 +1164,7 @@ bool NormSlidingMask::Copy(const NormSlidingMask& b)
|
||||||
{
|
{
|
||||||
if (b.IsSet())
|
if (b.IsSet())
|
||||||
{
|
{
|
||||||
long range = b.end - b.start;
|
INT32 range = b.end - b.start;
|
||||||
if (range < 0) range += b.num_bits;
|
if (range < 0) range += b.num_bits;
|
||||||
if (range <= num_bits)
|
if (range <= num_bits)
|
||||||
{
|
{
|
||||||
|
|
@ -1176,8 +1176,8 @@ bool NormSlidingMask::Copy(const NormSlidingMask& b)
|
||||||
end = bLastSet - bFirstSet + start;
|
end = bLastSet - bFirstSet + start;
|
||||||
offset = b.offset;
|
offset = b.offset;
|
||||||
// Copy start to mask_len
|
// Copy start to mask_len
|
||||||
long startIndex = b.start >> 3;
|
INT32 startIndex = b.start >> 3;
|
||||||
long endIndex = b.end >> 3;
|
INT32 endIndex = b.end >> 3;
|
||||||
if (b.end < b.start)
|
if (b.end < b.start)
|
||||||
{
|
{
|
||||||
ASSERT((b.mask_len - startIndex) <= mask_len);
|
ASSERT((b.mask_len - startIndex) <= mask_len);
|
||||||
|
|
@ -1193,14 +1193,14 @@ bool NormSlidingMask::Copy(const NormSlidingMask& b)
|
||||||
remainder = end & 0x7;
|
remainder = end & 0x7;
|
||||||
if (remainder)
|
if (remainder)
|
||||||
{
|
{
|
||||||
ASSERT((startIndex+endIndex) < (long)mask_len);
|
ASSERT((startIndex+endIndex) < (INT32)mask_len);
|
||||||
mask[startIndex+endIndex] &= 0xff << (8 - remainder);
|
mask[startIndex+endIndex] &= 0xff << (8 - remainder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT((endIndex-startIndex+1) <= (long)mask_len);
|
ASSERT((endIndex-startIndex+1) <= (INT32)mask_len);
|
||||||
memcpy(mask, b.mask+startIndex, endIndex-startIndex+1);
|
memcpy(mask, b.mask+startIndex, endIndex-startIndex+1);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1230,11 +1230,11 @@ bool NormSlidingMask::Add(const NormSlidingMask& b)
|
||||||
UINT32 bLastSet;
|
UINT32 bLastSet;
|
||||||
b.GetFirstSet(bLastSet);
|
b.GetFirstSet(bLastSet);
|
||||||
if (!CanSet(bLastSet)) return false;
|
if (!CanSet(bLastSet)) return false;
|
||||||
long range = b.end - b.start;
|
INT32 range = b.end - b.start;
|
||||||
if (range < 0) range += b.num_bits;
|
if (range < 0) range += b.num_bits;
|
||||||
unsigned long index;
|
UINT32 index;
|
||||||
b.GetFirstSet(index);
|
b.GetFirstSet(index);
|
||||||
for (long i = 0; i < range; i++)
|
for (INT32 i = 0; i < range; i++)
|
||||||
{
|
{
|
||||||
// (TBD) Improve performance by getting/setting
|
// (TBD) Improve performance by getting/setting
|
||||||
// ranges of set bits.
|
// ranges of set bits.
|
||||||
|
|
@ -1259,10 +1259,10 @@ bool NormSlidingMask::Subtract(const NormSlidingMask& b)
|
||||||
{
|
{
|
||||||
if (IsSet())
|
if (IsSet())
|
||||||
{
|
{
|
||||||
unsigned long index = offset;
|
UINT32 index = offset;
|
||||||
long range = end - start;
|
INT32 range = end - start;
|
||||||
if (range < 0) range += num_bits;
|
if (range < 0) range += num_bits;
|
||||||
for (long i = 0; i < range; i++)
|
for (INT32 i = 0; i < range; i++)
|
||||||
{
|
{
|
||||||
if (Test(index) && b.Test(index)) Unset(index);
|
if (Test(index) && b.Test(index)) Unset(index);
|
||||||
index++;
|
index++;
|
||||||
|
|
@ -1286,11 +1286,11 @@ bool NormSlidingMask::XCopy(const NormSlidingMask& b)
|
||||||
UINT32 bLastSet;
|
UINT32 bLastSet;
|
||||||
b.GetFirstSet(bLastSet);
|
b.GetFirstSet(bLastSet);
|
||||||
if (!CanSet(bLastSet)) return false;
|
if (!CanSet(bLastSet)) return false;
|
||||||
unsigned long index;
|
UINT32 index;
|
||||||
b.GetFirstSet(index);
|
b.GetFirstSet(index);
|
||||||
long range = b.end - b.start;
|
INT32 range = b.end - b.start;
|
||||||
if (range < 0) range += b.num_bits;
|
if (range < 0) range += b.num_bits;
|
||||||
for (long i = 0; i < range; i++)
|
for (INT32 i = 0; i < range; i++)
|
||||||
{
|
{
|
||||||
if (Test(index))
|
if (Test(index))
|
||||||
Unset(index);
|
Unset(index);
|
||||||
|
|
@ -1318,10 +1318,10 @@ bool NormSlidingMask::Multiply(const NormSlidingMask& b)
|
||||||
{
|
{
|
||||||
if (IsSet())
|
if (IsSet())
|
||||||
{
|
{
|
||||||
unsigned long index = offset;
|
UINT32 index = offset;
|
||||||
long range = end - start;
|
INT32 range = end - start;
|
||||||
if (range < 0) range += num_bits;
|
if (range < 0) range += num_bits;
|
||||||
for (long i = 0; i < range; i++)
|
for (INT32 i = 0; i < range; i++)
|
||||||
{
|
{
|
||||||
if (Test(index) && !b.Test(index)) Unset(index);
|
if (Test(index) && !b.Test(index)) Unset(index);
|
||||||
index++;
|
index++;
|
||||||
|
|
@ -1347,11 +1347,11 @@ bool NormSlidingMask::Xor(const NormSlidingMask& b)
|
||||||
UINT32 bLastSet;
|
UINT32 bLastSet;
|
||||||
b.GetFirstSet(bLastSet);
|
b.GetFirstSet(bLastSet);
|
||||||
if (!CanSet(bLastSet)) return false;
|
if (!CanSet(bLastSet)) return false;
|
||||||
unsigned long index;
|
UINT32 index;
|
||||||
b.GetFirstSet(index);
|
b.GetFirstSet(index);
|
||||||
long range = b.end - b.start;
|
INT32 range = b.end - b.start;
|
||||||
if (range < 0) range += b.num_bits;
|
if (range < 0) range += b.num_bits;
|
||||||
for (long i = 0; i < range; i++)
|
for (INT32 i = 0; i < range; i++)
|
||||||
{
|
{
|
||||||
if (b.Test(index)) Invert(index);
|
if (b.Test(index)) Invert(index);
|
||||||
index++;
|
index++;
|
||||||
|
|
@ -1362,8 +1362,8 @@ bool NormSlidingMask::Xor(const NormSlidingMask& b)
|
||||||
|
|
||||||
void NormSlidingMask::Display(FILE* stream)
|
void NormSlidingMask::Display(FILE* stream)
|
||||||
{
|
{
|
||||||
unsigned long index = offset;
|
UINT32 index = offset;
|
||||||
for (long i = 0; i < num_bits; i++)
|
for (INT32 i = 0; i < num_bits; i++)
|
||||||
{
|
{
|
||||||
if (Test(index++)) fprintf(stream, "1"); else fprintf(stream, "0");
|
if (Test(index++)) fprintf(stream, "1"); else fprintf(stream, "0");
|
||||||
if (0x07 == (i & 0x07)) fprintf(stream, " ");
|
if (0x07 == (i & 0x07)) fprintf(stream, " ");
|
||||||
|
|
@ -1371,12 +1371,12 @@ void NormSlidingMask::Display(FILE* stream)
|
||||||
}
|
}
|
||||||
} // end NormSlidingMask::Display()
|
} // end NormSlidingMask::Display()
|
||||||
|
|
||||||
void NormSlidingMask::Debug(long theCount)
|
void NormSlidingMask::Debug(INT32 theCount)
|
||||||
{
|
{
|
||||||
unsigned long index = offset;
|
UINT32 index = offset;
|
||||||
theCount = MIN(theCount, num_bits);
|
theCount = MIN(theCount, num_bits);
|
||||||
DMSG(0, "NormSlidingMask::Debug() offset:%lu\n ", index);
|
DMSG(0, "NormSlidingMask::Debug() offset:%lu\n ", index);
|
||||||
long i;
|
INT32 i;
|
||||||
for (i = 0; i < theCount; i++)
|
for (i = 0; i < theCount; i++)
|
||||||
{
|
{
|
||||||
if (Test(index++)) DMSG(0, "1"); else DMSG(0, "0");
|
if (Test(index++)) DMSG(0, "1"); else DMSG(0, "0");
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,9 @@ class NormBitmask
|
||||||
NormBitmask();
|
NormBitmask();
|
||||||
~NormBitmask();
|
~NormBitmask();
|
||||||
|
|
||||||
bool Init(unsigned long numBits);
|
bool Init(UINT32 numBits);
|
||||||
void Destroy();
|
void Destroy();
|
||||||
unsigned long Size() {return num_bits;}
|
UINT32 Size() {return num_bits;}
|
||||||
void Clear() // set to all zero's
|
void Clear() // set to all zero's
|
||||||
{
|
{
|
||||||
memset(mask, 0, mask_len);
|
memset(mask, 0, mask_len);
|
||||||
|
|
@ -37,27 +37,27 @@ class NormBitmask
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsSet() const {return (first_set < num_bits);}
|
bool IsSet() const {return (first_set < num_bits);}
|
||||||
bool GetFirstSet(unsigned long& index) const
|
bool GetFirstSet(UINT32& index) const
|
||||||
{
|
{
|
||||||
index = first_set;
|
index = first_set;
|
||||||
return IsSet();
|
return IsSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetLastSet(unsigned long& index) const
|
bool GetLastSet(UINT32& index) const
|
||||||
{
|
{
|
||||||
index = num_bits - 1;
|
index = num_bits - 1;
|
||||||
return GetPrevSet(index);
|
return GetPrevSet(index);
|
||||||
}
|
}
|
||||||
bool Test(unsigned long index) const
|
bool Test(UINT32 index) const
|
||||||
{
|
{
|
||||||
return ((index < num_bits) ?
|
return ((index < num_bits) ?
|
||||||
(0 != (mask[(index >> 3)] & (0x80 >> (index & 0x07)))) :
|
(0 != (mask[(index >> 3)] & (0x80 >> (index & 0x07)))) :
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
bool CanSet(unsigned long index) const
|
bool CanSet(UINT32 index) const
|
||||||
{return (index < num_bits);}
|
{return (index < num_bits);}
|
||||||
|
|
||||||
bool Set(unsigned long index)
|
bool Set(UINT32 index)
|
||||||
{
|
{
|
||||||
if (index < num_bits)
|
if (index < num_bits)
|
||||||
{
|
{
|
||||||
|
|
@ -70,7 +70,7 @@ class NormBitmask
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bool Unset(unsigned long index)
|
bool Unset(UINT32 index)
|
||||||
{
|
{
|
||||||
if (index < num_bits)
|
if (index < num_bits)
|
||||||
{
|
{
|
||||||
|
|
@ -79,15 +79,15 @@ class NormBitmask
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
bool Invert(unsigned long index)
|
bool Invert(UINT32 index)
|
||||||
{return (Test(index) ? Unset(index) : Set(index));}
|
{return (Test(index) ? Unset(index) : Set(index));}
|
||||||
|
|
||||||
bool SetBits(unsigned long baseIndex, unsigned long count);
|
bool SetBits(UINT32 baseIndex, UINT32 count);
|
||||||
bool UnsetBits(unsigned long baseIndex, unsigned long count);
|
bool UnsetBits(UINT32 baseIndex, UINT32 count);
|
||||||
|
|
||||||
bool GetNextSet(unsigned long& index) const;
|
bool GetNextSet(UINT32& index) const;
|
||||||
bool GetPrevSet(unsigned long& index) const;
|
bool GetPrevSet(UINT32& index) const;
|
||||||
bool GetNextUnset(unsigned long& index) const;
|
bool GetNextUnset(UINT32& index) const;
|
||||||
|
|
||||||
bool Copy(const NormBitmask &b); // this = b
|
bool Copy(const NormBitmask &b); // this = b
|
||||||
bool Add(const NormBitmask & b); // this = this | b
|
bool Add(const NormBitmask & b); // this = this | b
|
||||||
|
|
@ -101,9 +101,9 @@ class NormBitmask
|
||||||
// Members
|
// Members
|
||||||
private:
|
private:
|
||||||
unsigned char* mask;
|
unsigned char* mask;
|
||||||
unsigned long mask_len;
|
UINT32 mask_len;
|
||||||
unsigned long num_bits;
|
UINT32 num_bits;
|
||||||
unsigned long first_set; // index of lowest _set_ bit
|
UINT32 first_set; // index of lowest _set_ bit
|
||||||
}; // end class NormBitmask
|
}; // end class NormBitmask
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -125,16 +125,16 @@ class NormSlidingMask
|
||||||
|
|
||||||
const char* GetMask() const {return (const char*)mask;}
|
const char* GetMask() const {return (const char*)mask;}
|
||||||
|
|
||||||
bool Init(long numBits, UINT32 rangeMax);
|
bool Init(INT32 numBits, UINT32 rangeMax);
|
||||||
void Destroy();
|
void Destroy();
|
||||||
long Size() const {return num_bits;}
|
INT32 Size() const {return num_bits;}
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
memset(mask, 0, mask_len);
|
memset(mask, 0, mask_len);
|
||||||
start = end = num_bits;
|
start = end = num_bits;
|
||||||
offset = 0;
|
offset = 0;
|
||||||
}
|
}
|
||||||
void Reset(unsigned long index = 0)
|
void Reset(UINT32 index = 0)
|
||||||
{
|
{
|
||||||
ASSERT(num_bits);
|
ASSERT(num_bits);
|
||||||
memset(mask, 0xff, mask_len);
|
memset(mask, 0xff, mask_len);
|
||||||
|
|
@ -144,38 +144,34 @@ class NormSlidingMask
|
||||||
offset = index;
|
offset = index;
|
||||||
}
|
}
|
||||||
bool IsSet() const {return (start < num_bits);}
|
bool IsSet() const {return (start < num_bits);}
|
||||||
bool GetFirstSet(unsigned long& index) const
|
bool GetFirstSet(UINT32& index) const
|
||||||
{
|
{
|
||||||
index = offset;
|
index = offset;
|
||||||
return IsSet();
|
return IsSet();
|
||||||
}
|
}
|
||||||
bool GetLastSet(unsigned long& index) const
|
bool GetLastSet(UINT32& index) const
|
||||||
{
|
{
|
||||||
long n = end - start;
|
INT32 n = end - start;
|
||||||
n = (n < 0) ? (n + num_bits) : n;
|
n = (n < 0) ? (n + num_bits) : n;
|
||||||
index = offset + n;
|
index = offset + n;
|
||||||
return IsSet();
|
return IsSet();
|
||||||
}
|
}
|
||||||
bool Test(unsigned long index) const;
|
bool Test(UINT32 index) const;
|
||||||
bool CanSet(unsigned long index) const;
|
bool CanSet(UINT32 index) const;
|
||||||
|
|
||||||
bool Set(unsigned long index);
|
bool Set(UINT32 index);
|
||||||
bool Unset(unsigned long index);
|
bool Unset(UINT32 index);
|
||||||
bool Invert(unsigned long index)
|
bool Invert(UINT32 index)
|
||||||
{return (Test(index) ? Unset(index): Set(index));}
|
{return (Test(index) ? Unset(index): Set(index));}
|
||||||
|
|
||||||
bool SetBits(unsigned long index, long count);
|
bool SetBits(UINT32 index, INT32 count);
|
||||||
bool UnsetBits(unsigned long index, long count);
|
bool UnsetBits(UINT32 index, INT32 count);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// These return "false" when finding nothing
|
// These return "false" when finding nothing
|
||||||
bool GetNextSet(unsigned long& index) const;
|
bool GetNextSet(UINT32& index) const;
|
||||||
bool GetPrevSet(unsigned long& index) const;
|
bool GetPrevSet(UINT32& index) const;
|
||||||
|
|
||||||
//static unsigned long RawNextSet(const char* mask, long index, long start);
|
|
||||||
//static unsigned long RawPrevSet(const char* mask, long index, long end);
|
|
||||||
|
|
||||||
|
|
||||||
bool Copy(const NormSlidingMask& b); // this = b
|
bool Copy(const NormSlidingMask& b); // this = b
|
||||||
bool Add(const NormSlidingMask & b); // this = this | b
|
bool Add(const NormSlidingMask & b); // this = this | b
|
||||||
|
|
@ -185,13 +181,13 @@ class NormSlidingMask
|
||||||
bool Xor(const NormSlidingMask & b); // this = this ^ b
|
bool Xor(const NormSlidingMask & b); // this = this ^ b
|
||||||
|
|
||||||
void Display(FILE* stream);
|
void Display(FILE* stream);
|
||||||
void Debug(long theCount);
|
void Debug(INT32 theCount);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Calculate "circular" delta between two indices
|
// Calculate "circular" delta between two indices
|
||||||
long Delta(unsigned long a, unsigned long b) const
|
INT32 Delta(UINT32 a, UINT32 b) const
|
||||||
{
|
{
|
||||||
long result = a - b;
|
INT32 result = a - b;
|
||||||
return ((0 == (result & range_sign)) ?
|
return ((0 == (result & range_sign)) ?
|
||||||
(result & range_mask) :
|
(result & range_mask) :
|
||||||
(((result != range_sign) || (a < b)) ?
|
(((result != range_sign) || (a < b)) ?
|
||||||
|
|
@ -200,13 +196,13 @@ class NormSlidingMask
|
||||||
|
|
||||||
|
|
||||||
unsigned char* mask;
|
unsigned char* mask;
|
||||||
unsigned long mask_len;
|
UINT32 mask_len;
|
||||||
unsigned long range_mask;
|
UINT32 range_mask;
|
||||||
long range_sign;
|
INT32 range_sign;
|
||||||
long num_bits;
|
INT32 num_bits;
|
||||||
long start;
|
INT32 start;
|
||||||
long end;
|
INT32 end;
|
||||||
unsigned long offset;
|
UINT32 offset;
|
||||||
}; // end class NormSlidingMask
|
}; // end class NormSlidingMask
|
||||||
|
|
||||||
#endif // _NORM_BITMASK_
|
#endif // _NORM_BITMASK_
|
||||||
|
|
|
||||||
|
|
@ -1601,7 +1601,7 @@ bool NormFileObject::WriteSegment(NormBlockId blockId,
|
||||||
segmentOffset = segmentOffset + small_block_length*smallBlockIndex +
|
segmentOffset = segmentOffset + small_block_length*smallBlockIndex +
|
||||||
segmentSize*segmentId;
|
segmentSize*segmentId;
|
||||||
}
|
}
|
||||||
off_t offsetScaleMSB = 0xffffffff + 1;
|
off_t offsetScaleMSB = 0xffffffff + 1; // yuk! can't we do better?
|
||||||
off_t offset = (off_t)segmentOffset.LSB() + ((off_t)segmentOffset.MSB() * offsetScaleMSB);
|
off_t offset = (off_t)segmentOffset.LSB() + ((off_t)segmentOffset.MSB() * offsetScaleMSB);
|
||||||
if (offset != file.GetOffset())
|
if (offset != file.GetOffset())
|
||||||
{
|
{
|
||||||
|
|
@ -1644,7 +1644,7 @@ UINT16 NormFileObject::ReadSegment(NormBlockId blockId,
|
||||||
segmentOffset = segmentOffset + small_block_length*smallBlockIndex +
|
segmentOffset = segmentOffset + small_block_length*smallBlockIndex +
|
||||||
segmentSize*segmentId;
|
segmentSize*segmentId;
|
||||||
}
|
}
|
||||||
off_t offsetScaleMSB = 0xffffffff + 1;
|
off_t offsetScaleMSB = 0xffffffff + 1; // yuk! can't we do better
|
||||||
off_t offset = (off_t)segmentOffset.LSB() + ((off_t)segmentOffset.MSB() * offsetScaleMSB);
|
off_t offset = (off_t)segmentOffset.LSB() + ((off_t)segmentOffset.MSB() * offsetScaleMSB);
|
||||||
if (offset != file.GetOffset())
|
if (offset != file.GetOffset())
|
||||||
{
|
{
|
||||||
|
|
@ -1674,7 +1674,7 @@ NormStreamObject::~NormStreamObject()
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NormStreamObject::Open(unsigned long bufferSize,
|
bool NormStreamObject::Open(UINT32 bufferSize,
|
||||||
const char* infoPtr,
|
const char* infoPtr,
|
||||||
UINT16 infoLen)
|
UINT16 infoLen)
|
||||||
{
|
{
|
||||||
|
|
@ -1701,7 +1701,7 @@ bool NormStreamObject::Open(unsigned long bufferSize,
|
||||||
ASSERT(0 == numBlocks.MSB());
|
ASSERT(0 == numBlocks.MSB());
|
||||||
// Buffering requires at least 2 blocks
|
// Buffering requires at least 2 blocks
|
||||||
numBlocks = MAX(2, numBlocks.LSB());
|
numBlocks = MAX(2, numBlocks.LSB());
|
||||||
unsigned long numSegments = numBlocks.LSB() * numData;
|
UINT32 numSegments = numBlocks.LSB() * numData;
|
||||||
|
|
||||||
if (!block_pool.Init(numBlocks.LSB(), numData))
|
if (!block_pool.Init(numBlocks.LSB(), numData))
|
||||||
{
|
{
|
||||||
|
|
@ -1742,7 +1742,7 @@ bool NormStreamObject::Open(unsigned long bufferSize,
|
||||||
return true;
|
return true;
|
||||||
} // end NormStreamObject::Open()
|
} // end NormStreamObject::Open()
|
||||||
|
|
||||||
bool NormStreamObject::Accept(unsigned long bufferSize)
|
bool NormStreamObject::Accept(UINT32 bufferSize)
|
||||||
{
|
{
|
||||||
if (Open(bufferSize))
|
if (Open(bufferSize))
|
||||||
{
|
{
|
||||||
|
|
@ -2168,10 +2168,10 @@ bool NormStreamObject::Read(char* buffer, unsigned int* buflen, bool findMsgStar
|
||||||
return true;
|
return true;
|
||||||
} // end NormStreamObject::Read()
|
} // end NormStreamObject::Read()
|
||||||
|
|
||||||
unsigned long NormStreamObject::Write(const char* buffer, unsigned long len,
|
UINT32 NormStreamObject::Write(const char* buffer, UINT32 len,
|
||||||
FlushType flushType, bool eom, bool push)
|
FlushType flushType, bool eom, bool push)
|
||||||
{
|
{
|
||||||
unsigned long nBytes = 0;
|
UINT32 nBytes = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
NormBlock* block = stream_buffer.Find(write_index.block);
|
NormBlock* block = stream_buffer.Find(write_index.block);
|
||||||
|
|
|
||||||
|
|
@ -72,28 +72,28 @@ class NormObject
|
||||||
bool IsPendingInfo() {return pending_info;}
|
bool IsPendingInfo() {return pending_info;}
|
||||||
bool GetFirstPending(NormBlockId& blockId) const
|
bool GetFirstPending(NormBlockId& blockId) const
|
||||||
{
|
{
|
||||||
unsigned long index = 0;
|
UINT32 index = 0;
|
||||||
bool result = pending_mask.GetFirstSet(index);
|
bool result = pending_mask.GetFirstSet(index);
|
||||||
blockId = NormBlockId(index);
|
blockId = NormBlockId(index);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
bool GetNextPending(NormBlockId& blockId) const
|
bool GetNextPending(NormBlockId& blockId) const
|
||||||
{
|
{
|
||||||
unsigned long index = (UINT32)blockId;
|
UINT32 index = (UINT32)blockId;
|
||||||
bool result = pending_mask.GetNextSet(index);
|
bool result = pending_mask.GetNextSet(index);
|
||||||
blockId = NormBlockId(index);
|
blockId = NormBlockId(index);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
bool GetLastPending(NormBlockId& blockId) const
|
bool GetLastPending(NormBlockId& blockId) const
|
||||||
{
|
{
|
||||||
unsigned long index = 0;
|
UINT32 index = 0;
|
||||||
bool result = pending_mask.GetLastSet(index);
|
bool result = pending_mask.GetLastSet(index);
|
||||||
blockId = NormBlockId(index);
|
blockId = NormBlockId(index);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
bool GetFirstRepair(NormBlockId& blockId) const
|
bool GetFirstRepair(NormBlockId& blockId) const
|
||||||
{
|
{
|
||||||
unsigned long index = 0;
|
UINT32 index = 0;
|
||||||
bool result = repair_mask.GetFirstSet(index);
|
bool result = repair_mask.GetFirstSet(index);
|
||||||
blockId = NormBlockId(index);
|
blockId = NormBlockId(index);
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -101,14 +101,14 @@ class NormObject
|
||||||
|
|
||||||
bool GetNextRepair(NormBlockId& blockId) const
|
bool GetNextRepair(NormBlockId& blockId) const
|
||||||
{
|
{
|
||||||
unsigned long index = (UINT32)blockId;
|
UINT32 index = (UINT32)blockId;
|
||||||
bool result = repair_mask.GetNextSet(index);
|
bool result = repair_mask.GetNextSet(index);
|
||||||
blockId = NormBlockId(index);
|
blockId = NormBlockId(index);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
bool GetLastRepair(NormBlockId& blockId) const
|
bool GetLastRepair(NormBlockId& blockId) const
|
||||||
{
|
{
|
||||||
unsigned long index = 0;
|
UINT32 index = 0;
|
||||||
bool result = repair_mask.GetLastSet(index);
|
bool result = repair_mask.GetLastSet(index);
|
||||||
blockId = NormBlockId(index);
|
blockId = NormBlockId(index);
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -263,11 +263,11 @@ class NormStreamObject : public NormObject
|
||||||
const NormObjectId& objectId);
|
const NormObjectId& objectId);
|
||||||
~NormStreamObject();
|
~NormStreamObject();
|
||||||
|
|
||||||
bool Open(unsigned long bufferSize,
|
bool Open(UINT32 bufferSize,
|
||||||
const char* infoPtr = NULL,
|
const char* infoPtr = NULL,
|
||||||
UINT16 infoLen = 0);
|
UINT16 infoLen = 0);
|
||||||
void Close();
|
void Close();
|
||||||
bool Accept(unsigned long bufferSize);
|
bool Accept(UINT32 bufferSize);
|
||||||
|
|
||||||
enum FlushType
|
enum FlushType
|
||||||
{
|
{
|
||||||
|
|
@ -276,7 +276,7 @@ class NormStreamObject : public NormObject
|
||||||
FLUSH_ACTIVE // pending queued data is transmitted, _and_ active CMD(FLUSH)
|
FLUSH_ACTIVE // pending queued data is transmitted, _and_ active CMD(FLUSH)
|
||||||
};
|
};
|
||||||
bool Read(char* buffer, unsigned int* buflen, bool findMsgStart = false);
|
bool Read(char* buffer, unsigned int* buflen, bool findMsgStart = false);
|
||||||
unsigned long Write(const char* buffer, unsigned long len, FlushType flushType, bool eom, bool push);
|
UINT32 Write(const char* buffer, UINT32 len, FlushType flushType, bool eom, bool push);
|
||||||
|
|
||||||
|
|
||||||
bool StreamUpdateStatus(NormBlockId blockId);
|
bool StreamUpdateStatus(NormBlockId blockId);
|
||||||
|
|
@ -343,7 +343,7 @@ class NormSimObject : public NormObject
|
||||||
const NormObjectId& objectId);
|
const NormObjectId& objectId);
|
||||||
~NormSimObject();
|
~NormSimObject();
|
||||||
|
|
||||||
bool Open(unsigned long objectSize,
|
bool Open(UINT32 objectSize,
|
||||||
const char* infoPtr = NULL,
|
const char* infoPtr = NULL,
|
||||||
UINT16 infoLen = 0)
|
UINT16 infoLen = 0)
|
||||||
{
|
{
|
||||||
|
|
@ -382,7 +382,7 @@ class NormObjectTable
|
||||||
NormObjectId RangeLo() const {return range_lo;}
|
NormObjectId RangeLo() const {return range_lo;}
|
||||||
NormObjectId RangeHi() const {return range_hi;}
|
NormObjectId RangeHi() const {return range_hi;}
|
||||||
bool IsEmpty() const {return (0 == range);}
|
bool IsEmpty() const {return (0 == range);}
|
||||||
unsigned long Count() const {return count;}
|
UINT32 Count() const {return count;}
|
||||||
const NormObjectSize& Size() const {return size;}
|
const NormObjectSize& Size() const {return size;}
|
||||||
|
|
||||||
class Iterator
|
class Iterator
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ NormSession::~NormSession()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool NormSession::Open()
|
bool NormSession::Open(const char* interfaceName)
|
||||||
{
|
{
|
||||||
ASSERT(address.IsValid());
|
ASSERT(address.IsValid());
|
||||||
if (!tx_socket.IsOpen())
|
if (!tx_socket.IsOpen())
|
||||||
|
|
@ -106,7 +106,7 @@ bool NormSession::Open()
|
||||||
|
|
||||||
if (address.IsMulticast())
|
if (address.IsMulticast())
|
||||||
{
|
{
|
||||||
if (!rx_socket.JoinGroup(address))
|
if (!rx_socket.JoinGroup(address, interfaceName))
|
||||||
{
|
{
|
||||||
DMSG(0, "NormSession::Open() rx_socket join group error\n");
|
DMSG(0, "NormSession::Open() rx_socket join group error\n");
|
||||||
Close();
|
Close();
|
||||||
|
|
@ -118,6 +118,11 @@ bool NormSession::Open()
|
||||||
Close();
|
Close();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (interfaceName)
|
||||||
|
{
|
||||||
|
rx_socket.SetMulticastInterface(interfaceName);
|
||||||
|
tx_socket.SetMulticastInterface(interfaceName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < DEFAULT_MESSAGE_POOL_DEPTH; i++)
|
for (unsigned int i = 0; i < DEFAULT_MESSAGE_POOL_DEPTH; i++)
|
||||||
{
|
{
|
||||||
|
|
@ -158,11 +163,12 @@ void NormSession::Close()
|
||||||
bool NormSession::StartServer(unsigned long bufferSpace,
|
bool NormSession::StartServer(unsigned long bufferSpace,
|
||||||
UINT16 segmentSize,
|
UINT16 segmentSize,
|
||||||
UINT16 numData,
|
UINT16 numData,
|
||||||
UINT16 numParity)
|
UINT16 numParity,
|
||||||
|
const char* interfaceName)
|
||||||
{
|
{
|
||||||
if (!IsOpen())
|
if (!IsOpen())
|
||||||
{
|
{
|
||||||
if (!Open()) return false;
|
if (!Open(interfaceName)) return false;
|
||||||
}
|
}
|
||||||
// (TBD) parameterize the object history depth
|
// (TBD) parameterize the object history depth
|
||||||
if (!tx_table.Init(256))
|
if (!tx_table.Init(256))
|
||||||
|
|
@ -255,11 +261,11 @@ void NormSession::StopServer()
|
||||||
if (!IsClient()) Close();
|
if (!IsClient()) Close();
|
||||||
} // end NormSession::StopServer()
|
} // end NormSession::StopServer()
|
||||||
|
|
||||||
bool NormSession::StartClient(unsigned long bufferSize)
|
bool NormSession::StartClient(unsigned long bufferSize, const char* interfaceName)
|
||||||
{
|
{
|
||||||
if (!IsOpen())
|
if (!IsOpen())
|
||||||
{
|
{
|
||||||
if (!Open()) return false;
|
if (!Open(interfaceName)) return false;
|
||||||
}
|
}
|
||||||
is_client = true;
|
is_client = true;
|
||||||
remote_server_buffer_size = bufferSize;
|
remote_server_buffer_size = bufferSize;
|
||||||
|
|
@ -921,10 +927,6 @@ void NormSession::HandleReceiveMessage(NormMsg& msg, bool wasUnicast)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (IsClient()) ClientHandleNackMessage((NormNackMsg&)msg);
|
if (IsClient()) ClientHandleNackMessage((NormNackMsg&)msg);
|
||||||
if ((3 == LocalNodeId()) && (currentTime.tv_sec > 26))
|
|
||||||
{
|
|
||||||
int x = 5;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case NormMsg::ACK:
|
case NormMsg::ACK:
|
||||||
if (IsServer() && (((NormAckMsg&)msg).GetServerId() == LocalNodeId()))
|
if (IsServer() && (((NormAckMsg&)msg).GetServerId() == LocalNodeId()))
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,7 @@ class NormSessionMgr
|
||||||
|
|
||||||
class NormSession* NewSession(const char* sessionAddress,
|
class NormSession* NewSession(const char* sessionAddress,
|
||||||
UINT16 sessionPort,
|
UINT16 sessionPort,
|
||||||
NormNodeId localNodeId =
|
NormNodeId localNodeId = NORM_NODE_ANY);
|
||||||
NORM_NODE_ANY);
|
|
||||||
void DeleteSession(class NormSession* theSession);
|
void DeleteSession(class NormSession* theSession);
|
||||||
|
|
||||||
void Notify(NormController::Event event,
|
void Notify(NormController::Event event,
|
||||||
|
|
@ -88,7 +87,7 @@ class NormSession
|
||||||
|
|
||||||
// General methods
|
// General methods
|
||||||
const NormNodeId& LocalNodeId() {return local_node_id;}
|
const NormNodeId& LocalNodeId() {return local_node_id;}
|
||||||
bool Open();
|
bool Open(const char* interfaceName = NULL);
|
||||||
void Close();
|
void Close();
|
||||||
bool IsOpen() {return (rx_socket.IsOpen() || tx_socket.IsOpen());}
|
bool IsOpen() {return (rx_socket.IsOpen() || tx_socket.IsOpen());}
|
||||||
const ProtoAddress& Address() {return address;}
|
const ProtoAddress& Address() {return address;}
|
||||||
|
|
@ -134,7 +133,8 @@ class NormSession
|
||||||
bool StartServer(unsigned long bufferSpace,
|
bool StartServer(unsigned long bufferSpace,
|
||||||
UINT16 segmentSize,
|
UINT16 segmentSize,
|
||||||
UINT16 numData,
|
UINT16 numData,
|
||||||
UINT16 numParity);
|
UINT16 numParity,
|
||||||
|
const char* interfaceName = NULL);
|
||||||
void StopServer();
|
void StopServer();
|
||||||
NormStreamObject* QueueTxStream(UINT32 bufferSize,
|
NormStreamObject* QueueTxStream(UINT32 bufferSize,
|
||||||
const char* infoPtr = NULL,
|
const char* infoPtr = NULL,
|
||||||
|
|
@ -210,7 +210,8 @@ class NormSession
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client methods
|
// Client methods
|
||||||
bool StartClient(unsigned long bufferSpace);
|
bool StartClient(unsigned long bufferSpace,
|
||||||
|
const char* interfaceName = NULL);
|
||||||
void StopClient();
|
void StopClient();
|
||||||
bool IsClient() {return is_client;}
|
bool IsClient() {return is_client;}
|
||||||
unsigned long RemoteServerBufferSize()
|
unsigned long RemoteServerBufferSize()
|
||||||
|
|
@ -293,7 +294,7 @@ class NormSession
|
||||||
|
|
||||||
// General session parameters
|
// General session parameters
|
||||||
NormNodeId local_node_id;
|
NormNodeId local_node_id;
|
||||||
ProtoAddress address; // session destination address
|
ProtoAddress address; // session destination address & port
|
||||||
UINT8 ttl; // session multicast ttl
|
UINT8 ttl; // session multicast ttl
|
||||||
double tx_rate; // bytes per second
|
double tx_rate; // bytes per second
|
||||||
double backoff_factor;
|
double backoff_factor;
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,6 @@
|
||||||
|
|
||||||
#ifndef _NORM_VERSION
|
#ifndef _NORM_VERSION
|
||||||
#define _NORM_VERSION
|
#define _NORM_VERSION
|
||||||
#define VERSION "1.1b9"
|
#define VERSION "1.2b1"
|
||||||
#endif // _NORM_VERSION
|
#endif // _NORM_VERSION
|
||||||
|
|
||||||
|
|
|
||||||
BIN
win32/Norm.opt
BIN
win32/Norm.opt
Binary file not shown.
|
|
@ -43,7 +43,7 @@ RSC=rc.exe
|
||||||
# PROP Ignore_Export_Lib 0
|
# PROP Ignore_Export_Lib 0
|
||||||
# PROP Target_Dir ""
|
# PROP Target_Dir ""
|
||||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||||
# ADD CPP /nologo /MD /W3 /vmg /GX /O2 /I "..\..\common" /I "..\..\protolib\common" /I "..\..\protolib\win32" /D "NDEBUG" /D "PROTO_DEBUG" /D "HAVE_IPV6" /D "HAVE_ASSERT" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
# ADD CPP /nologo /MD /W3 /vmg /GX /O2 /I "..\..\common" /I "..\..\protolib\common" /I "..\..\protolib\win32" /D "NDEBUG" /D "PROTO_DEBUG" /D "HAVE_IPV6" /D "HAVE_ASSERT" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /FR /YX /FD /c
|
||||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue