示例#1
0
// ------------------
BigInt::Ulong BigInt::Rossi::toUlong () const
{
    ASSERTION (!m_units.empty());
    if (m_units.size() > 1)
    {
        std::ostringstream ossErr;
        ossErr  << ""
                << "BigInt::Ulong can't be obtained: m_units.size() too big"
                << std::endl
                << "m_units.size() = " 
                << m_units.size() 
                << std::endl
                << "Hex value = " 
                << toStrHex() 
                << std::endl
                << "Here m_units.size() must be = 1"
                << std::endl
                << std::endl;

        ERR_MSG (std::cerr, ossErr.str());

        ASSERTION (m_units.size() == 1);
    }
    ASSERTION (m_units.size() == 1);
    return m_units.front();
}
示例#2
0
	ThreadingModelMonitor::ThreadingModelMonitor( const char * szFuncName, const char * szFuncFile, const size_t nFuncFileLine, const void * oInst, const ThreadingModel entmThreadingModel ) 
		: mThreadingModel(entmThreadingModel), mThreadID(boost::this_thread::get_id()), mFuncID(buildFuncID(szFuncName, szFuncFile, nFuncFileLine)), mInst(oInst)
	{
		const char * szFuncID = mFuncID.c_str();
		if (mThreadingModel == ThrMdl_Main)
		{
			if (!gtmm_ThreadingModelManager.checkMainThread(szFuncID))
				OHT_LOG_FATAL("Only the MAIN thread may enter this block");

			ASSERTION(gtmm_ThreadingModelManager.checkMainThread(szFuncID), "Only the MAIN thread may enter this block");
		}
		else
		{
			const size_t nRefCount = gtmm_ThreadingModelManager.registerThread(szFuncID, oInst);

			if (!(!gtmm_ThreadingModelManager.checkMainThread(szFuncID) || mThreadingModel != ThrMdl_Background))
				OHT_LOG_FATAL("Only a BACKGROUND thread may enter this block");

			ASSERTION (!gtmm_ThreadingModelManager.checkMainThread(szFuncID) || mThreadingModel != ThrMdl_Background, "Only a BACKGROUND thread may enter this block");

			if (nRefCount > 1 && mThreadingModel == ThrMdl_Single)
			{
				if (mThreadingModel != ThrMdl_Any)
					OHT_LOG_FATAL("Threading model is SINGLE but this method is not synchronized");

				ASSERTION(mThreadingModel == ThrMdl_Any, "Threading model is SINGLE but this method is not synchronized");
			}
		}
	}
示例#3
0
// ------------------
bool BigInt::Vin::operator< (const BigInt::Vin& i_arg) const
{
    if (m_units.size() < i_arg.m_units.size())
    {
        return true;
    }
    if (i_arg.m_units.size() < m_units.size())
    {
        return false;
    }

    ASSERTION (m_units.size() == i_arg.m_units.size());
    for (std::size_t i = (m_units.size() - 1); i > 0; i--)
    {
        if (m_units[i] < i_arg.m_units[i])
        {
            return true;
        }

        if (i_arg.m_units[i] < m_units[i])
        {
            return false;
        }
    }
    return (m_units[0] < i_arg.m_units[0]);
}
示例#4
0
void MenuManager::hintText( WMenuItem *, const char * hint )
//----------------------------------------------------------
{
    ASSERTION( (_clientWin != NULL) );

    _clientWin->statusText( hint );
}
示例#5
0
// ------------------
// Constructor-3
BigInt::Rossi::Rossi (const BigInt::Vin& i_arg)
{
    std::ostringstream oss;
    oss << i_arg;
    const bool rc = initViaString (oss.str(), DEC_DIGIT);
    ASSERTION (rc);
}
示例#6
0
// ------------------
// Constructor-4
BigInt::Rossi::Rossi (const std::size_t i_noOfUnits, BigInt::Ulong i_internalUnits, BigInt::Ulong i_backUnit)
{
    ASSERTION (m_units.empty());

    try
    {
        m_units.resize (i_noOfUnits, i_internalUnits);      
    }
    catch(...)
    {
        std::ostringstream ossThrow;
        std::ostringstream ossErr;
        ossErr  << ""
                << "Unable to to do m_units.resize("
                << i_noOfUnits
                << ")"
                << std::endl;

	ERR_MSG (std::cerr, ossErr.str());
	ERR_MSG (ossThrow, ossErr.str());
	throw std::runtime_error (ossThrow.str().c_str());
    }

    m_units.back() = i_backUnit;
}
示例#7
0
void * MemoryPool::alloc()
//------------------------
{
    ASSERTION( _elemSize > 0 && _blockSize > 0 );

    #if DEBUG
        _numAllocs += 1;
    #endif

    if( _freeList != NULL ) {
        char * tmp;

        tmp = ( char * )_freeList;
        _freeList = * ((void **) _freeList );
        return( tmp );
    }

    if( _currElement == _lastElement ) {
        grow();
    }

    _currElement -= _elemSize;

    #if DEBUG
        memset( _currElement, ALLOCSIG, _elemSize );
    #endif

    return( _currElement );
}
示例#8
0
void MenuManager::registerForMenu( MenuHandler * hdlr, const MIMenuID & id, bool enable )
//---------------------------------------------------------------------------------------
{
    ASSERTION( !_receivers->contains( id ) );

    (*_receivers)[ id ] = hdlr;
    enableMenu( id, enable );
}
示例#9
0
文件: Memory.cpp 项目: GMAC-lib/gmac
int Memory::protect(hostptr_t addr, size_t count, GmacProtection prot)
{
    TRACE(GLOBAL, "Setting memory permisions to %d @ %p - %p", prot, addr, addr + count);
	DWORD old = 0;
    BOOL ret = VirtualProtect(addr, count, ProtBits[prot], &old);
    ASSERTION(ret == TRUE);
    return 0;
}
示例#10
0
void
Mapping::key ( int n )
{
    if ( n > 11 || n < 0 )
        ASSERTION( "key selection out of range: %d", n );

    _key = n;
}
示例#11
0
文件: main.C 项目: shanipribadi/non
void
setup_jack ( )
{
   const char *jack_name;

    jack_name = midi_init( instance_name );
    if ( ! jack_name )
        ASSERTION( "Could not initialize MIDI system! (is Jack running and with MIDI ports enabled?)" );

    if ( ! transport.valid )
    {
        if ( transport.master )
            ASSERTION( "The version of JACK you are using does not appear to be capable of passing BBT positional information." );
        else
            ASSERTION( "Either the version of JACK you are using does pass BBT information, or the current timebase master does not provide it." );
    }
}
示例#12
0
// ------------------
bool BigInt::Rossi::backUnitIsNull () const
{
    ASSERTION (!m_units.empty());
    if (m_units.size() == 1) 
    {
        return false;
    }
    return (m_units.back() == 0);
}
示例#13
0
// ------------------
void BigInt::Rossi::truncateUnits()
{
    while ((m_units.size() > 1) && (m_units.back() == 0))
    {
        m_units.pop_back();
    } 
    ASSERTION(!isEmpty());

}
示例#14
0
void MenuManager::unRegister( const MIMenuID & id )
//-------------------------------------------------
{
    bool found;

    enableMenu( id, FALSE );
    found = (bool) _receivers->remove( id );

    ASSERTION( found );
}
示例#15
0
 //
 // send_block_info
 //
 // Send specific information about block
 //
 void Monitor::send_block_info(Zone *zone, void *block) {
     if (zone->in_subzone_memory(block)) {
         Subzone *subzone = Subzone::subzone(block);
         return send_block_info(zone, subzone, subzone->quantum_index(block), block);
     } else if (zone->in_large_memory(block)) {
         return send_block_info(zone, Large::large(block), block);
     } else {
         ASSERTION(0 && "not a block");
     }
 }
示例#16
0
char * StringPool::alloc( size_t len )
//------------------------------------
{
    char * ret;

    #if DEBUG
        _numAllocs += 1;
    #endif

    if( _currPos + len >= _endOfCurrBlock ) {
        grow();
    }
    ASSERTION( len < _blockSize );
    ASSERTION( _currPos + len < _endOfCurrBlock );

    ret = _currPos;
    _currPos += len;

    return ret;
}
示例#17
0
文件: CThread.cpp 项目: weratyr/EmFW
/**
 * Constructor
 * @param runnableObj object that should be run in a thread
 * @param name name of the thread
 * @param staclSize size of the stack
 * @param prio thread priority
 * @param cpu/thread affinity
 * @param asMainThread whether thread is explicitly created or handled as main thread in this context
 */
CThread::CThread(IRunnable &  runnableObj, const char * name,
                 Int32	stackSize,
                 EPriority	prio,
                 Int32 Affinity,
                 bool asMainThread )
   : mRunnablePtr(&runnableObj),
     mName(name),
     mStackSize(stackSize),
     mPrio(prio),
     mAffinity(Affinity),
     mAsMainThread(asMainThread)
{
   ASSERTION(stackSize > 0);
   ASSERTION(mName != NULLPTR);

   // add this thread into the list
   sMutex.take();
   sThreads.add(this);
   sMutex.give();
}
示例#18
0
const char * Outline::getString( int index )
//------------------------------------------
{
    OutlineElement * elm;

    elm = element( index );

    ASSERTION( elm != NULL );

    return elm->_name;
}
示例#19
0
	ThreadingModelMonitor::~ThreadingModelMonitor()
	{
		if (mThreadingModel != ThrMdl_Main)
		{
			const size_t nRefCount = gtmm_ThreadingModelManager.deregisterThread(mFuncID.c_str(), mInst);
			if (!(nRefCount == 0 || mThreadingModel == ThrMdl_Any))
				OHT_LOG_FATAL("Threading model is SINGLE or MAIN but this method is not synchronized");

			ASSERTION(nRefCount == 0 || mThreadingModel == ThrMdl_Any, "Threading model is SINGLE or MAIN but this method is not synchronized");
		}
	}
示例#20
0
void MenuManager::menuPopup( WPopupMenu * pop )
//---------------------------------------------
{
    int i;

    ASSERTION( (_clientWin != NULL) );

    for( i = 0; i < MMNumMainMenus; i += 1 ) {
        if( pop == _topMenus[ i ] ) {
            _clientWin->statusText( MainMenuInfo[ i ].hint );
            break;
        }
    }
}
示例#21
0
void MemoryPool::setSize( size_t elemSize, int elemsPerBlock )
//------------------------------------------------------------
{
    ASSERTION( _elemSize == 0 || _elemSize == elemSize );

    _elemSize = elemSize;
    _elemsPerBlock = elemsPerBlock;

    if( _elemSize < sizeof( void * )) {
        _elemSize = sizeof( void * );
    }

    // Size of hunk of memory including "next-block" ptr
    _blockSize = elemSize * elemsPerBlock + sizeof( void * );
}
示例#22
0
void EnumStyleEdit::okButton( WWindow * )
//---------------------------------------
{
    int i;

    for( i = 0; i < EV_NumStyles; i += 1 ) {
        if( _buttons[ i ]->checked() ) {
            _current = (EnumViewStyle) i;
            break;
        }
    }

    ASSERTION( i < EV_NumStyles );

    quit( 1 );
}
示例#23
0
int GlobalViewList::count()
//-------------------------
{
    ASSERTION( full() );

    int           num;
    GBVListPage * page;

    num = (_pages->count() - 1) * (OFFSETMASK + 1);

    if( _pages->count() ) {
        page = (GBVListPage *) (*_pages)[ _pages->count() - 1 ];
        num += page->_symbols->count();
    }

    return num;
}
示例#24
0
static void
hash_grow(hash_t *hash) {
    int old_size = hash->size;
    uint32_t *old_codes = hash->codes;
    uint32_t *bucket;
    int i;

    ASSERTION(old_size < HASH_SIZE_MAX, "The hash has too much collision!");

    hash->size = old_size << 2;
    hash->codes = (uint32_t *)calloc(hash->size, sizeof(uint32_t));

    bucket = old_codes;
    for (i = 0; i < old_size; i++, bucket++) {
        if (*bucket != 0) {
            hash_put(hash, *bucket);
        }
    }

    free(old_codes);
}
示例#25
0
bool
Mapping::open ( enum map_type type, const char *name )
{
    switch ( type )
    {
        case INSTRUMENT:
            _instrument = Instrument::open( name );
            break;
        case SCALE:
            _scale = Scale::open( name );
            break;
        default:
            ASSERTION( "invalid mapping type ");
            break;
    }

    if ( ! _scale )
        return false;

    _type = type;

    return true;
}
示例#26
0
void GlobalViewList::findNext()
//-----------------------------
{
    Symbol * sym;
    BusyNotice busy( "Searching..." );

    ASSERTION( _lastFound >= 0 );

    for( _lastFound += 1; ; _lastFound += 1 ) {
        sym = getSymbol( _lastFound );
        if( sym == NULL || _findFilter->matches( sym ) ) {
            break;
        }
    }

    if( sym == NULL ) {
        errMessage( "No more matching symbols" );
        menuManager()->enableMenu( MIMenuID(MMLocate,LMFindNext), false );
        _lastFound = -1;
    } else {
        select( _lastFound );
    }
}
示例#27
0
SearchContext * Module::findSymbols( WVList *symbols, KeySymbol *filter,
                                      SearchContext * ctxt, int numItems )
//-------------------------------------------------------------------------
{
    bool        done;
    FindSymData info;
    unsigned    depth;

    ASSERTION( _dataFile->isInitialized() );

    depth = DR_DEPTH_FUNCTIONS;
    if( DRGetLanguage() == DR_LANG_CPLUSPLUS ) {
        depth |= DR_DEPTH_CLASSES;
    }

    info.keysym = filter;
    info.data = symbols;
    info.call_module = this;
    info.numItems = numItems;
    info.context = NULL;

    if( ctxt ) {
        done = DRResumeSymSearch( ctxt, DR_SEARCH_ALL, (dr_depth)depth,
                                  NULL, &info, searchHook);
    } else {
        done = DRSymSearch( DR_SEARCH_ALL, (dr_depth) depth,
                            NULL, &info, searchHook);
    }

    if( done ) {
        delete info.context;
        return NULL;
    } else {
        return info.context;
    }
}
示例#28
0
int mainBigInt(std::ostream& o_stream, const std::vector<std::string>& i_args) {

  showVersion(o_stream);

  BigInt::assertCheck();

  applicationSimpleSample(o_stream);

  if (!checkCommandLine(o_stream, i_args)) {
    return 1;
  }

  if (i_args.size() <= 1) {
    showHelp(o_stream, i_args);
    return 0;
  }

  // ----------------------
  ASSERTION(i_args.size() == 4);

  runRossiInteractiveSample(o_stream, i_args);

  return 0;
}
示例#29
0
文件: sequence.C 项目: nico202/non
void
sequence::unlock ( void )
{
    _history.push_back( const_cast<data *>( _rd ) );

    if ( _history.size() > MAX_UNDO + 1 )
    {
        data *d = _history.front();

        if ( d == _rw || d == _rd )
            ASSERTION( "something bad has happend." );

        delete d;

        _history.pop_front();
    }

    // swap the copy back in (atomically).
    _rd = _rw;

    _rw = NULL;

    song.set_dirty();
}
示例#30
0
static void runRossiInteractiveSample(std::ostream& o_stream,
                                      const std::vector<std::string>& i_args) {
  std::ostringstream oss;

  ASSERTION(i_args.size() == 4);

  const std::map<std::string, std::string> allowedOperations =
      getSampleAllowedOperation();
  ASSERTION(!allowedOperations.empty());

  // ---------------------------
  BigInt::Rossi rossiArg1(std::string(i_args[1]), BigInt::DEC_DIGIT);
  std::string op(i_args[2]);
  BigInt::Rossi rossiArg2(std::string(i_args[3]), BigInt::DEC_DIGIT);

  BigInt::Rossi rossiResult;

  ASSERTION(allowedOperations.count(op));

  BigInt::Vin vinArg1(rossiArg1);
  BigInt::Vin vinArg2(rossiArg2);

  // ---------------------------
  std::ostringstream ossFailure;
  if (op == "+") {
    rossiResult = rossiArg1 + rossiArg2;
  }

  if (op == "-") {
    if (rossiArg2 <= rossiArg1) {
      rossiResult = rossiArg1 - rossiArg2;
    } else {
      ossFailure << ""
                 << "Arguments are inconsistent for operator" << op << " : "
                 << " minuend = " << vinArg1 << ", "
                 << "subtracter = " << vinArg2 << ", i.e. minuend < subtracter";
    }
  }

  if (op == "x") {
    rossiResult = rossiArg1 * rossiArg2;
  }

  if (op == "/") {
    rossiResult = rossiArg1 / rossiArg2;
  }

  if (op == "%") {
    rossiResult = rossiArg1 % rossiArg2;
  }

  // ---------------------------
  BigInt::Vin vinResult(rossiResult);

  if (ossFailure.str().empty()) {
    oss << ""
        << "[Dec] " << vinArg1 << " " << op << " " << vinArg2 << " = "
        << vinResult << std::endl;

    oss << ""
        << "[Hex] " << rossiArg1 << " " << op << " " << rossiArg2 << " = "
        << rossiResult << std::endl;

  } else {
    oss << "" << ossFailure.str() << std::endl;
  }

  o_stream << std::flush << oss.str() << std::flush;
}