Commit f16e5a0a authored by joreland@mysql.com's avatar joreland@mysql.com

Removed some macros

and moved some code.
Improve portability
parent 664329b5
...@@ -21,20 +21,10 @@ ...@@ -21,20 +21,10 @@
#include <ndb_limits.h> #include <ndb_limits.h>
#include <kernel_types.h> #include <kernel_types.h>
#ifndef NDB_ASSERT #define ASSERT_BOOL(flag, message) assert(flag<=1)
#ifdef VM_TRACE
#define NDB_ASSERT(test, message) { if(!(test)) { printf(message); exit(-1); }}
#else
#define NDB_ASSERT(test, message)
#endif
#endif
// Useful ASSERT macros...
#define ASSERT_BOOL(flag, message) NDB_ASSERT( (flag<=1), (message) )
#define ASSERT_RANGE(value, min, max, message) \ #define ASSERT_RANGE(value, min, max, message) \
NDB_ASSERT((value) >= (min) && (value) <= (max), (message)) assert((value) >= (min) && (value) <= (max))
#define ASSERT_MAX(value, max, message) \ #define ASSERT_MAX(value, max, message) assert((value) <= (max))
NDB_ASSERT((value) <= (max), (message))
#define SECTION(x) STATIC_CONST(x) #define SECTION(x) STATIC_CONST(x)
......
...@@ -63,12 +63,6 @@ ...@@ -63,12 +63,6 @@
// Returns: - // Returns: -
//**************************************************************************** //****************************************************************************
#ifndef NDB_ASSERT
#define NDB_ASSERT(trueToContinue, message) \
if ( !(trueToContinue) ) { \
ndbout << "ASSERT FAILED. FILE: " << __FILE__ << ", LINE: " << __LINE__ << ", MSG: " << message << endl;exit(-1);}
#endif
#define MGM_REQUIRE(x) \ #define MGM_REQUIRE(x) \
if (!(x)) { ndbout << __FILE__ << " " << __LINE__ \ if (!(x)) { ndbout << __FILE__ << " " << __LINE__ \
<< ": Warning! Requirement failed" << endl; } << ": Warning! Requirement failed" << endl; }
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
#include <ndb_global.h> #include <ndb_global.h>
#ifndef NDB_ASSERT
#define NDB_ASSERT(x, s) \
do { if (!(x)) { printf("%s\n", s); abort(); } } while (0)
#endif
/** /**
* Bitmask implementation. Size is given explicitly * Bitmask implementation. Size is given explicitly
* (as first argument). All methods are static. * (as first argument). All methods are static.
...@@ -140,7 +135,7 @@ public: ...@@ -140,7 +135,7 @@ public:
inline bool inline bool
BitmaskImpl::get(unsigned size, const Uint32 data[], unsigned n) BitmaskImpl::get(unsigned size, const Uint32 data[], unsigned n)
{ {
NDB_ASSERT(n < (size << 5), "bit get out of range"); assert(n < (size << 5));
return (data[n >> 5] & (1 << (n & 31))) != 0; return (data[n >> 5] & (1 << (n & 31))) != 0;
} }
...@@ -153,7 +148,7 @@ BitmaskImpl::set(unsigned size, Uint32 data[], unsigned n, bool value) ...@@ -153,7 +148,7 @@ BitmaskImpl::set(unsigned size, Uint32 data[], unsigned n, bool value)
inline void inline void
BitmaskImpl::set(unsigned size, Uint32 data[], unsigned n) BitmaskImpl::set(unsigned size, Uint32 data[], unsigned n)
{ {
NDB_ASSERT(n < (size << 5), "bit set out of range"); assert(n < (size << 5));
data[n >> 5] |= (1 << (n & 31)); data[n >> 5] |= (1 << (n & 31));
} }
...@@ -176,7 +171,7 @@ BitmaskImpl::assign(unsigned size, Uint32 dst[], const Uint32 src[]) ...@@ -176,7 +171,7 @@ BitmaskImpl::assign(unsigned size, Uint32 dst[], const Uint32 src[])
inline void inline void
BitmaskImpl::clear(unsigned size, Uint32 data[], unsigned n) BitmaskImpl::clear(unsigned size, Uint32 data[], unsigned n)
{ {
NDB_ASSERT(n < (size << 5), "bit clear out of range"); assert(n < (size << 5));
data[n >> 5] &= ~(1 << (n & 31)); data[n >> 5] &= ~(1 << (n & 31));
} }
......
...@@ -487,31 +487,6 @@ SignalLoggerManager::printLinearSection(FILE * output, ...@@ -487,31 +487,6 @@ SignalLoggerManager::printLinearSection(FILE * output,
putc('\n', output); putc('\n', output);
} }
void
SignalLoggerManager::printSegmentedSection(FILE * output,
const SignalHeader & sh,
const SegmentedSectionPtr ptr[3],
unsigned i)
{
fprintf(output, "SECTION %u type=segmented", i);
if (i >= 3) {
fprintf(output, " *** invalid ***\n");
return;
}
const Uint32 len = ptr[i].sz;
SectionSegment * ssp = ptr[i].p;
Uint32 pos = 0;
fprintf(output, " size=%u\n", (unsigned)len);
while (pos < len) {
if (pos > 0 && pos % SectionSegment::DataLength == 0) {
ssp = g_sectionSegmentPool.getPtr(ssp->m_nextSegment);
}
printDataWord(output, pos, ssp->theData[pos % SectionSegment::DataLength]);
}
if (len > 0)
putc('\n', output);
}
void void
SignalLoggerManager::printDataWord(FILE * output, Uint32 & pos, const Uint32 data) SignalLoggerManager::printDataWord(FILE * output, Uint32 & pos, const Uint32 data)
{ {
......
...@@ -143,7 +143,7 @@ NDB_MAIN(ndb_kernel){ ...@@ -143,7 +143,7 @@ NDB_MAIN(ndb_kernel){
// Set thread concurrency for Solaris' light weight processes // Set thread concurrency for Solaris' light weight processes
int status; int status;
status = NdbThread_SetConcurrencyLevel(30); status = NdbThread_SetConcurrencyLevel(30);
NDB_ASSERT(status == 0, "Can't set appropriate concurrency level."); assert(status == 0);
#ifdef VM_TRACE #ifdef VM_TRACE
// Create a signal logger // Create a signal logger
...@@ -168,7 +168,7 @@ NDB_MAIN(ndb_kernel){ ...@@ -168,7 +168,7 @@ NDB_MAIN(ndb_kernel){
globalEmulatorData.theThreadConfig->doStart(NodeState::SL_STARTING); globalEmulatorData.theThreadConfig->doStart(NodeState::SL_STARTING);
break; break;
default: default:
NDB_ASSERT(0, "Illegal state globalData.theRestartFlag"); assert("Illegal state globalData.theRestartFlag" == 0);
} }
globalTransporterRegistry.startSending(); globalTransporterRegistry.startSending();
......
...@@ -924,7 +924,7 @@ Dbtux::TreeHead::getSize(AccSize acc) const ...@@ -924,7 +924,7 @@ Dbtux::TreeHead::getSize(AccSize acc) const
case AccFull: case AccFull:
return m_nodeSize; return m_nodeSize;
} }
REQUIRE(false, "invalid Dbtux::AccSize"); abort();
return 0; return 0;
} }
......
...@@ -229,7 +229,7 @@ AsyncFile::run() ...@@ -229,7 +229,7 @@ AsyncFile::run()
endReq(); endReq();
return; return;
default: default:
THREAD_REQUIRE(false, "Using default switch in AsyncFile::run"); abort();
break; break;
}//switch }//switch
theReportTo->writeChannel(request); theReportTo->writeChannel(request);
......
...@@ -120,8 +120,7 @@ template <class T> void MemoryChannel<T>::writeChannel( T *t) ...@@ -120,8 +120,7 @@ template <class T> void MemoryChannel<T>::writeChannel( T *t)
{ {
NdbMutex_Lock(theMutexPtr); NdbMutex_Lock(theMutexPtr);
REQUIRE(!full(theWriteIndex, theReadIndex), "Memory Channel Full"); if(full(theWriteIndex, theReadIndex) || theChannel == NULL) abort();
REQUIRE(theChannel != NULL, "Memory Channel Full");
theChannel[theWriteIndex]= t; theChannel[theWriteIndex]= t;
++theWriteIndex; ++theWriteIndex;
NdbMutex_Unlock(theMutexPtr); NdbMutex_Unlock(theMutexPtr);
......
...@@ -215,7 +215,6 @@ protected: ...@@ -215,7 +215,6 @@ protected:
T** tList = theList; T** tList = theList;
int i; int i;
theList = new T*[aSize+theCurrentSize]; theList = new T*[aSize+theCurrentSize];
REQUIRE(theList != 0, "Allocate in Pool.hpp failed");
// allocate full list // allocate full list
for (i = 0; i < theTop; i++) { for (i = 0; i < theTop; i++) {
theList[i] = tList[i]; theList[i] = tList[i];
......
...@@ -23,35 +23,6 @@ ...@@ -23,35 +23,6 @@
#include "Error.hpp" #include "Error.hpp"
#include <Emulator.hpp> #include <Emulator.hpp>
#ifdef ASSERT
#undef ASSERT
#endif
#define REQUIRE(trueToContinue, message) \
if ( (trueToContinue) ) { } else { \
ErrorReporter::handleAssert(message, __FILE__, __LINE__); }
#define THREAD_REQUIRE(trueToContinue, message) \
if ( (trueToContinue) ) { } else { \
ErrorReporter::handleThreadAssert(message, __FILE__, __LINE__); }
#ifdef NDEBUG
#define NDB_ASSERT(trueToContinue, message)
#else
#define NDB_ASSERT(trueToContinue, message) \
if ( !(trueToContinue) ) { \
ErrorReporter::handleAssert(message, __FILE__, __LINE__); }
#endif
// Description:
// This macro is used to report programming errors.
// Parameters:
// trueToContinue IN An expression. If it evaluates to 0
// execution is stopped.
// message IN A message from the programmer
// explaining what went wrong.
class ErrorReporter class ErrorReporter
{ {
public: public:
......
...@@ -47,7 +47,7 @@ MetaData::MetaData(SimulatedBlock* block) : ...@@ -47,7 +47,7 @@ MetaData::MetaData(SimulatedBlock* block) :
MetaData::~MetaData() MetaData::~MetaData()
{ {
for (int i = false; i <= true; i++) { for (int i = false; i <= true; i++) {
NDB_ASSERT(m_common.m_lock[i] >= m_lock[i], "invalid lock count"); assert(m_common.m_lock[i] >= m_lock[i]);
m_common.m_lock[i] -= m_lock[i]; m_common.m_lock[i] -= m_lock[i];
m_lock[i] = 0; m_lock[i] = 0;
} }
......
...@@ -136,12 +136,12 @@ SimulatedBlock::installSimulatedBlockFunctions(){ ...@@ -136,12 +136,12 @@ SimulatedBlock::installSimulatedBlockFunctions(){
void void
SimulatedBlock::addRecSignalImpl(GlobalSignalNumber gsn, SimulatedBlock::addRecSignalImpl(GlobalSignalNumber gsn,
ExecFunction f, bool force){ ExecFunction f, bool force){
REQUIRE(gsn <= MAX_GSN, "Illegal signal added in block (GSN too high)"); if(gsn > MAX_GSN || (!force && theExecArray[gsn] != 0)){
char probData[255]; char errorMsg[255];
snprintf(probData, 255, snprintf(errorMsg, 255,
"Signal (%d) already added in block", "Illeagal signal (%d %d)", gsn, MAX_GSN);
gsn); ERROR_SET(fatal, ERR_ERROR_PRGERR, errorMsg, errorMsg);
REQUIRE(force || theExecArray[gsn] == 0, probData); }
theExecArray[gsn] = f; theExecArray[gsn] = f;
} }
......
...@@ -458,11 +458,11 @@ SimulatedBlock::executeFunction(GlobalSignalNumber gsn, Signal* signal){ ...@@ -458,11 +458,11 @@ SimulatedBlock::executeFunction(GlobalSignalNumber gsn, Signal* signal){
char errorMsg[255]; char errorMsg[255];
if (!(gsn <= MAX_GSN)) { if (!(gsn <= MAX_GSN)) {
snprintf(errorMsg, 255, "Illegal signal received (GSN %d too high)", gsn); snprintf(errorMsg, 255, "Illegal signal received (GSN %d too high)", gsn);
REQUIRE(false, errorMsg); ERROR_SET(fatal, ERR_ERROR_PRGERR, errorMsg, errorMsg);
} }
if (!(theExecArray[gsn] != 0)) { if (!(theExecArray[gsn] != 0)) {
snprintf(errorMsg, 255, "Illegal signal received (GSN %d not added)", gsn); snprintf(errorMsg, 255, "Illegal signal received (GSN %d not added)", gsn);
REQUIRE(false, errorMsg); ERROR_SET(fatal, ERR_ERROR_PRGERR, errorMsg, errorMsg);
} }
ndbrequire(false); ndbrequire(false);
} }
......
...@@ -434,5 +434,28 @@ reportDisconnect(void * callbackObj, NodeId nodeId, Uint32 errNo){ ...@@ -434,5 +434,28 @@ reportDisconnect(void * callbackObj, NodeId nodeId, Uint32 errNo){
globalScheduler.execute(&signal, JBA, CMVMI, GSN_DISCONNECT_REP); globalScheduler.execute(&signal, JBA, CMVMI, GSN_DISCONNECT_REP);
} }
void
SignalLoggerManager::printSegmentedSection(FILE * output,
const SignalHeader & sh,
const SegmentedSectionPtr ptr[3],
unsigned i)
{
fprintf(output, "SECTION %u type=segmented", i);
if (i >= 3) {
fprintf(output, " *** invalid ***\n");
return;
}
const Uint32 len = ptr[i].sz;
SectionSegment * ssp = ptr[i].p;
Uint32 pos = 0;
fprintf(output, " size=%u\n", (unsigned)len);
while (pos < len) {
if (pos > 0 && pos % SectionSegment::DataLength == 0) {
ssp = g_sectionSegmentPool.getPtr(ssp->m_nextSegment);
}
printDataWord(output, pos, ssp->theData[pos % SectionSegment::DataLength]);
}
if (len > 0)
putc('\n', output);
}
...@@ -1478,7 +1478,7 @@ CommandInterpreter::executeSet(int /*processId*/, ...@@ -1478,7 +1478,7 @@ CommandInterpreter::executeSet(int /*processId*/,
<< endl; << endl;
} }
else { else {
NDB_ASSERT(false, ""); assert(false);
} }
} }
else { else {
...@@ -1497,7 +1497,7 @@ CommandInterpreter::executeSet(int /*processId*/, ...@@ -1497,7 +1497,7 @@ CommandInterpreter::executeSet(int /*processId*/,
} }
else { else {
// The primary is not tried to write if the write of backup file fails // The primary is not tried to write if the write of backup file fails
NDB_ASSERT(false, ""); abort();
} }
} }
free(newpar); free(newpar);
......
...@@ -1698,7 +1698,7 @@ MgmtSrvr::setSignalLoggingMode(int processId, LogMode mode, ...@@ -1698,7 +1698,7 @@ MgmtSrvr::setSignalLoggingMode(int processId, LogMode mode,
logSpec = TestOrd::InputOutputSignals; logSpec = TestOrd::InputOutputSignals;
break; break;
default: default:
NDB_ASSERT(false, "Unexpected value, MgmtSrvr::setSignalLoggingMode"); assert("Unexpected value, MgmtSrvr::setSignalLoggingMode" == 0);
} }
NdbApiSignal* signal = getSignal(); NdbApiSignal* signal = getSignal();
......
...@@ -162,13 +162,6 @@ setSignalLog(){ ...@@ -162,13 +162,6 @@ setSignalLog(){
} }
#endif #endif
// These symbols are needed, but not used in the API
int g_sectionSegmentPool;
struct ErrorReporter {
void handleAssert(const char*, const char*, int);
};
void ErrorReporter::handleAssert(const char* message, const char* file, int line) {}
/** /**
* The execute function : Handle received signal * The execute function : Handle received signal
*/ */
...@@ -314,6 +307,14 @@ execute(void * callbackObj, SignalHeader * const header, ...@@ -314,6 +307,14 @@ execute(void * callbackObj, SignalHeader * const header,
} }
} }
// These symbols are needed, but not used in the API
void
SignalLoggerManager::printSegmentedSection(FILE *, const SignalHeader &,
const SegmentedSectionPtr ptr[3],
unsigned i){
abort();
}
void void
copy(Uint32 * & insertPtr, copy(Uint32 * & insertPtr,
class SectionSegmentPool & thePool, const SegmentedSectionPtr & _ptr){ class SectionSegmentPool & thePool, const SegmentedSectionPtr & _ptr){
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment