bool SymmetricCipherSalsa20::processInPlace(QByteArray& data)
{
    Q_ASSERT((data.size() < blockSize()) || ((data.size() % blockSize()) == 0));

    ECRYPT_encrypt_bytes(&m_ctx, reinterpret_cast<const u8*>(data.constData()),
                         reinterpret_cast<u8*>(data.data()), data.size());

    return true;
}
bool SymmetricCipherSalsa20::processInPlace(QByteArray& data, quint64 rounds)
{
    Q_ASSERT((data.size() < blockSize()) || ((data.size() % blockSize()) == 0));

    for (quint64 i = 0; i != rounds; ++i) {
        ECRYPT_encrypt_bytes(&m_ctx, reinterpret_cast<const u8*>(data.constData()),
                             reinterpret_cast<u8*>(data.data()), data.size());
    }

    return true;
}
QByteArray SymmetricCipherSalsa20::process(const QByteArray& data, bool* ok)
{
    Q_ASSERT((data.size() < blockSize()) || ((data.size() % blockSize()) == 0));

    QByteArray result;
    result.resize(data.size());

    ECRYPT_encrypt_bytes(&m_ctx, reinterpret_cast<const u8*>(data.constData()),
                         reinterpret_cast<u8*>(result.data()), data.size());

    *ok = true;
    return result;
}
Example #4
0
void Context::runVertexShader( ocull::Mesh *pMesh, const ocull::Matrix4x4 &modelMatrix)
{
  /// Map constants parameters (like GLSL's uniforms)
  FW::Constants& c = *(FW::Constants*)
                      m_cudaModule->getGlobal("c_constants").getMutablePtrDiscard();


  // Compute the ModelViewProjection matrix
  const Matrix4x4 &viewProj = m_pQuery->m_camera.getViewProjMatrix();
  Matrix4x4 mvp = viewProj * modelMatrix;

  // Translate custom matrix as CudaRaster Framework matrix (yeah.. what ?)
# define COPY_MAT(i,j)  c.posToClip.m##i##j = mvp[j][i]
  COPY_MAT(0, 0); COPY_MAT(0, 1); COPY_MAT(0, 2); COPY_MAT(0, 3);
  COPY_MAT(1, 0); COPY_MAT(1, 1); COPY_MAT(1, 2); COPY_MAT(1, 3);
  COPY_MAT(2, 0); COPY_MAT(2, 1); COPY_MAT(2, 2); COPY_MAT(2, 3);
  COPY_MAT(3, 0); COPY_MAT(3, 1); COPY_MAT(3, 2); COPY_MAT(3, 3);
# undef COPY_MAT

  //-------
    
  /// Set input parameters
  int ofs = 0;
  ofs += m_cudaModule->setParamPtr( m_vsKernel, ofs, pMesh->vertex.buffer.getCudaPtr());
  ofs += m_cudaModule->setParamPtr( m_vsKernel, ofs, m_outVertices.getMutableCudaPtrDiscard());
  ofs += m_cudaModule->setParami  ( m_vsKernel, ofs, pMesh->vertex.count);  
  // XXX TODO set vertex stride & offset XXX

  //-------
  
  /// Run the vertex shader kernel
  FW::Vec2i blockSize(32, 4);
  int numBlocks = (pMesh->vertex.count - 1u) / (blockSize.x * blockSize.y) + 1;
  m_cudaModule->launchKernel( m_vsKernel, blockSize, numBlocks);
}
void testHelperFunctions( const std::string & meshFile, const uint_t numTotalBlocks )
{
   auto mesh = make_shared<MeshType>();
   mesh::readAndBroadcast( meshFile, *mesh);
   auto triDist = make_shared< mesh::TriangleDistance<MeshType> >( mesh );
   auto distanceOctree = make_shared< DistanceOctree< MeshType > >( triDist );

   const real_t meshVolume  = real_c( computeVolume( *mesh ) );
   const real_t blockVolume = meshVolume / real_c( numTotalBlocks );
   static const real_t cellsPersBlock = real_t(1000);
   const real_t cellVolume = blockVolume / cellsPersBlock;
   const real_t dx = std::pow( cellVolume, real_t(1) / real_t(3) );

   WALBERLA_LOG_INFO_ON_ROOT( "Creating SBF with createStructuredBlockStorageInsideMesh with block size" );
   auto sbf0 = mesh::createStructuredBlockStorageInsideMesh( distanceOctree, dx, numTotalBlocks );
   
   WALBERLA_LOG_INFO_ON_ROOT( "Creating SBF with createStructuredBlockStorageInsideMesh with block size" );
   Vector3<uint_t> blockSize( sbf0->getNumberOfXCells(), sbf0->getNumberOfYCells(), sbf0->getNumberOfZCells() );
   auto sbf1 = mesh::createStructuredBlockStorageInsideMesh( distanceOctree, dx, blockSize );

   auto exteriorAabb = computeAABB( *mesh ).getScaled( real_t(2) );

   WALBERLA_LOG_INFO_ON_ROOT( "Creating SBF with createStructuredBlockStorageInsideMesh with block size" );
   auto sbf2 = mesh::createStructuredBlockStorageOutsideMesh( exteriorAabb, distanceOctree, dx, numTotalBlocks );

   WALBERLA_LOG_INFO_ON_ROOT( "Creating SBF with createStructuredBlockStorageInsideMesh with block size" );
   blockSize = Vector3<uint_t>( sbf2->getNumberOfXCells(), sbf2->getNumberOfYCells(), sbf2->getNumberOfZCells() );
   auto sbf3 = mesh::createStructuredBlockStorageOutsideMesh( exteriorAabb, distanceOctree, dx, blockSize );
}
Partition ClusteringGenerator::makeContinuousBalancedClustering(Graph& G, count k) {
	count n = G.upperNodeIdBound(); 
	Partition clustering(n);
	clustering.setUpperBound(k);

	std::vector<count> blockSize(k, 0);

	// compute block sizes
	for (index block = 0; block < k; ++block) {
		blockSize[block] = n / k + (n % k > block);
	}

	// compute prefix sums of block sizes
	for (index block = 1; block < k; ++block) {
		blockSize[block] += blockSize[block-1];
	}

	// fill clustering according to blocks
	node v = 0;
	for (index block = 0; block < k; ++block) {
		while (v < blockSize[block]) {
			clustering.addToSubset(block,v);
			++v;
		}
	}

	return clustering;
}
Example #7
0
bool CipherFileIO::writeOneBlock(const IORequest &req) {

  if (haveHeader && fsConfig->reverseEncryption) {
    VLOG(1)
        << "writing to a reverse mount with per-file IVs is not implemented";
    return false;
  }

  int bs = blockSize();
  off_t blockNum = req.offset / bs;

  if (haveHeader && fileIV == 0) initHeader();

  bool ok;
  if (req.dataLen != bs) {
    ok = streamWrite(req.data, (int)req.dataLen, blockNum ^ fileIV);
  } else {
    ok = blockWrite(req.data, (int)req.dataLen, blockNum ^ fileIV);
  }

  if (ok) {
    if (haveHeader) {
      IORequest tmpReq = req;
      tmpReq.offset += HEADER_SIZE;
      ok = base->write(tmpReq);
    } else
      ok = base->write(req);
  } else {
    VLOG(1) << "encodeBlock failed for block " << blockNum << ", size "
            << req.dataLen;
    ok = false;
  }
  return ok;
}
Example #8
0
/**
 * Read block from backing ciphertext file, decrypt it (normal mode)
 * or
 * Read block from backing plaintext file, then encrypt it (reverse mode)
 */
ssize_t CipherFileIO::readOneBlock(const IORequest &req) const {
  int bs = blockSize();
  off_t blockNum = req.offset / bs;

  ssize_t readSize = 0;
  IORequest tmpReq = req;

  // adjust offset if we have a file header
  if (haveHeader && !fsConfig->reverseEncryption) {
    tmpReq.offset += HEADER_SIZE;
  }
  readSize = base->read(tmpReq);

  bool ok;
  if (readSize > 0) {
    if (haveHeader && fileIV == 0)
      const_cast<CipherFileIO *>(this)->initHeader();

    if (readSize != bs) {
      rDebug("streamRead(data, %d, IV)", (int)readSize);
      ok = streamRead(tmpReq.data, (int)readSize, blockNum ^ fileIV);
    } else {
      ok = blockRead(tmpReq.data, (int)readSize, blockNum ^ fileIV);
    }

    if (!ok) {
      rDebug("decodeBlock failed for block %" PRIi64 ", size %i", blockNum,
             (int)readSize);
      readSize = -1;
    }
  } else
    rDebug("readSize zero for offset %" PRIi64, req.offset);

  return readSize;
}
Example #9
0
void vectFlashErase(unsigned char chip, unsigned char blockNum)
{
	/*unsigned char totalBlocks = bootBlockStartNum+4;

    if(blockNum >= totalBlocks)
        blockNum = totalBlocks-1;*/

    //this needs to be modified to take into account boot block areas (less than 64k)
    unsigned long blockAddr = blockNumToAddr(chip, blockNum);
	unsigned long numBytes = blockSize(blockNum);

#ifdef DEBUG_FLASH
    if(debugFile != NULL)
    {
        fprintf(debugFile, "vectFlashErase: chip=%d blockNum=%d\n", chip, blockNum);
    }
#endif

    //memset block to 0xFF
    //memset(&mainrom[blockAddr], 0xFF, numBytes);
	while(numBytes--)
	{
		flashWriteByte(blockAddr, 0xFF, FLASH_ERASE);
		blockAddr++;
	}
}
Example #10
0
std::pair<bool, bool>
MemoryType::checkAndMergeMemType(Location addr, const RsType* type)
{
  const size_t ofs = byte_offset(startAddress, addr, blockSize(), 0);

  return checkAndMergeMemType(ofs, type);
}
Example #11
0
void MainWindow::processIncommingMessage()
{
    if(socket == nullptr || socket->state() != QAbstractSocket::ConnectedState)
    {
        return;
    }

    QDataStream in(socket);
    in.setVersion(QDataStream::Qt_4_0);

    // This is flag which might be used somewhere else;
    // Zero it if you want to block the rest of server message
    quint16 blockSize(0);

    if (blockSize == 0)
    {

        // Check how many bytes are waiting to be read;
        // We are getting data in quint16
        if (socket->bytesAvailable() < (int)sizeof(quint16))
            return;
        in >> blockSize;
    }

    // If there are less than already available then this is not
    // what we should read;
    if (socket->bytesAvailable() < blockSize)
        return;

    QString message;
    in >> message;

    ui->displayTextEdit->append("Server says: " + message);
}
Example #12
0
void bspmarkmultiples(int p, int s, ulong n, ulong k, ulong *x)
{
    // mark all multiples of k as non-prime in x
    /*
     * if (!(low_value % prime)) first = 0;
     * else first = prime - (low_value % prime);
     */

    ulong i;
    ulong first;

    if(k * k > blockLow(p,s,n)) // k is in our block, or beyond
        first = k * k - blockLow(p,s,n);
    else // k falls before our block; 
    {
        if(!(blockLow(p,s,n) % k)) // first element in our block is divisible by k
            first = 0;
        else
            first = k - (blockLow(p,s,n) % k); // start at first multiple of k in block
    }

    for (i=first; i < blockSize(p,s,n); i+= k)
    {
        x[i] = 0; //not a prime
    }


} /* end bspmarkmultiples */
Example #13
0
int main(int argc, char **argv){

    bsp_init(bspsieve, argc, argv);

    /* sequential part */
    if (argc != 2)
    {
        printf("Usage: %s N\n", argv[0]);
        bsp_abort("Incorrect invocation.\n");
    }
    sscanf(argv[1], "%lld", &N);

    printf("max prime requested = %lld\n", N);
    P = bsp_nprocs(); // maximum amount of procs

    if ( blockSize(P, 0, N) < sqrt(N))
        printf("WARNING: such a large P (%d) with relatively small N (%lld) is inefficient. \n Choosing a lower P is recommended.\n\n", P, N);

    printf("Using %d processors. \n", P);

    /* SPMD part */
    bspsieve();

    /* sequential part */
    exit(0);

} /* end main */
Example #14
0
ulong nextPrime(int p, int s, ulong n, ulong k, ulong *x)
{
    // find minimal i s.t. i > k and i unmarked

    ulong newK = k+1;
    ulong local = MAX(
                    localIdx(p,s,n,newK),
                    0); // do not consider primes outside our range

    while(local < blockSize(p,s,n)-1 && x[local] == 0)
    {
        local++;
    }

    if(x[local] == 0)
    {
        return LLONG_MAX; // no primes for this processor. This is possible.
    }
    else
    {
        // if we get here we assume we found a prime!

        return globalIdx(p,s,n,local);
    }

} /* end nextPrime */
Example #15
0
//***************************************************************************
Kwave::PitchShiftFilter::PitchShiftFilter()
    :Kwave::SampleSource(0), m_buffer(blockSize()),
     m_speed(1.0), m_frequency(0.5), m_dbuffer(),
     m_lfopos(0), m_b1pos(0), m_b2pos(0), m_b1inc(0), m_b2inc(0),
     m_b1reset(false), m_b2reset(false), m_dbpos(0)
{
    initFilter();
}
Example #16
0
int main (int argc, char **argv)
{
    MPI_Init (&argc, &argv);	/* starts MPI */
    MPI_Comm_rank (MPI_COMM_WORLD, &rank);	/* get current process id */
    MPI_Comm_size (MPI_COMM_WORLD, &size);	/* get number of processes */

    char logFileName[30];
    sprintf(logFileName, "log/mpi_lab3-proc%d.log", rank);
    isach_mpi::Logger::addLogger(rank, logFileName);

    char* fileName = argv[1];

    isach_mpi::read_matrix_from_file(fileName, MPI_COMM_WORLD, &n, &m, &matrix_part);

    int bockSizeN = blockSize(n, rank, size);
    int bockSizeM = blockSize(m, rank, size);

    isach_mpi::Logger::getLogger(rank)->log("Before:\n");
    for(int i = 0; i < bockSizeN; ++i) {
        for(int j = 0; j < m; ++j) {
            char logmsg[20];
            sprintf(logmsg, COLOR_GREEN"%d ", matrix_part[i*m + j]);
            isach_mpi::Logger::getLogger(rank)->log(logmsg);
        }
        isach_mpi::Logger::getLogger(rank)->log("\n");
    }

    isach_mpi::transposition(&matrix_part, n, m, MPI_COMM_WORLD);


    isach_mpi::Logger::getLogger(rank)->log(COLOR_RESET"After:\n");
    for(int i = 0; i < bockSizeM ; ++i) {
        for(int j = 0; j < n; ++j) {
            char logmsg[20];
            sprintf(logmsg, COLOR_RED"%d ", matrix_part[i*n + j]);
            isach_mpi::Logger::getLogger(rank)->log(logmsg);
        }
        isach_mpi::Logger::getLogger(rank)->log(COLOR_RESET"\n");
    }

    MPI_Finalize();
    return 0;
}
Example #17
0
gpmr::EmitConfiguration IntCountMapper::getEmitConfiguration(gpmr::Chunk * const chunk) const
{
  gpmr::PreLoadedFixedSizeChunk * fsChunk = static_cast<gpmr::PreLoadedFixedSizeChunk * >(chunk);
  dim3 blockSize(fsChunk->getElementCount(), 1, 1);
  dim3 gridSize(1, 1, 1);
  return gpmr::EmitConfiguration::createGridConfiguration(fsChunk->getElementCount() * sizeof(int),
                                                          fsChunk->getElementCount() * sizeof(int),
                                                          gridSize,     blockSize, 1,
                                                          sizeof(int),  sizeof(int));
}
Example #18
0
File: Mul.cpp Project: KDE/kwave
Kwave::Mul::Mul()
    :Kwave::SampleSource(),
     m_queue_a(), m_queue_b(),
     m_sem_a(0), m_sem_b(0),
     m_a(), m_b(),
     m_buffer_x(blockSize()),
     m_a_is_const(false), m_b_is_const(false),
     m_value_a(0), m_value_b(0),
     m_lock()
{
}
Example #19
0
bool MemoryType::isInitialized(Location addr, size_t len) const
{
    const size_t           offset = byte_offset(startAddress, addr, blockSize(), 0);
    const size_t           limit = offset + len;

    for (size_t i = offset; i < limit; ++i)
    {
        if ( !byteInitialized(i) ) return false;
    }

    return true;
}
Example #20
0
        virtual uint8_t *encode(uint8_t *buffer)
    	{
            buffer = encodeExtA(buffer, extendAValue());
            buffer = encodeExtB(buffer, extendBValue());

    		*buffer++ = BytecodeSet::PushClosure;
    		*buffer++ =
                ((numExtensions & BytecodeSet::PushClosure_NumExtensionsMask) << BytecodeSet::PushClosure_NumExtensionsShift) |
                ((numArgs & BytecodeSet::PushClosure_NumArgsMask) << BytecodeSet::PushClosure_NumArgsShift) |
                ((numCopied & BytecodeSet::PushClosure_NumCopiedMask) << BytecodeSet::PushClosure_NumCopiedShift);
            *buffer++ = blockSize() & 0xFF;
    		return buffer;
    	}
Example #21
0
LODNodeSample deserializeDataSample( const ::zeq::Event& event )
{
    LODNodeSample sample;
    sample.first = event.getType();

    auto data = GetLODNode( event.getData( ));
    sample.second = livre::LODNode(
        NodeId( data->nodeId( )),
        _deserializeVector3< int32_t >( data->blockSize( )),
        Boxf( _deserializeVector3< float >( data->worldBoxMin( )),
              _deserializeVector3< float >( data->worldBoxMax( ))));

    return sample;
}
Example #22
0
Region RegionFactory::
        operator()(const Reference& ref) const
{
    Position a, b;
    // For integers 'i': "2 to the power of 'i'" == powf(2.f, i) == ldexpf(1.f, i)
    Position blockSize( block_size_.texels_per_row () * ldexpf(1.f,ref.log2_samples_size[0]),
                        block_size_.texels_per_column () * ldexpf(1.f,ref.log2_samples_size[1]));
    a.time = blockSize.time * ref.block_index[0];
    a.scale = blockSize.scale * ref.block_index[1];
    b.time = a.time + blockSize.time;
    b.scale = a.scale + blockSize.scale;

    return Region(a,b);
}
Example #23
0
char ttCanMoveDown(tetris_table* t)
{
        block* b = t->next_block[0];
        for (uint16_t s = 0; s < blockSize(b); ++s)
        {
                position p = blockPosition(b, s);
                p.x += t->currentPos.x;
                p.y += t->currentPos.y + 1;

                if (p.x < t->size.x && p.y >= 0 && p.x >= 0)
                        if (p.y >= t->size.y || !t->tab[p.y][p.x].empty)
                                return 0;
        }
        return 1;
}
Example #24
0
char ttCanMove(tetris_table* t, char right)
{
        block* b = t->next_block[0];
        for (uint16_t s = 0; s < blockSize(b); ++s)
        {
                position p = blockPosition(b, s);
                p.x += t->currentPos.x + ((right)?1:-1);
                p.y += t->currentPos.y;

                if (p.y < t->size.y && p.y >= 0)
                        if (p.x >= t->size.x || p.x < 0 || !t->tab[p.y][p.x].empty)
                                return 0;
        }
        return 1;
}
Example #25
0
void ttFillWithCurrentBlock(tetris_table* t)
{
        block* b = t->next_block[0];
        for (uint16_t s = 0; s < blockSize(b); ++s)
        {
                position p = blockPosition(b, s);
                p.x += t->currentPos.x;
                p.y += t->currentPos.y;

                if (p.x < t->size.x && p.y < t->size.y && p.x >= 0 && p.y >= 0)
                {
                        t->tab[p.y][p.x].type = blockType(b);
                        t->tab[p.y][p.x].empty = 0;
                }
        }
}
//_________________________
uint8_t ADM_aviUISetMuxer(  void )
{

//	return DIA_setUserMuxParam ((int *) &muxMode, (int *) &muxParam, (int *) &muxSize);
    uint32_t mux_n_frame=muxParam;
    uint32_t mux_size_block=muxParam;
    uint32_t mux_mode=(uint32_t)muxMode;


    diaMenuEntry muxingType[]= {
        {MUX_REGULAR,QT_TR_NOOP("Normal")},
        {MUX_N_FRAMES,QT_TR_NOOP("Mux every N video frames")},
        {MUX_N_BYTES,QT_TR_NOOP("Mux by packet size")}
    };

    diaElemMenu      mux(&(mux_mode),QT_TR_NOOP("Muxing _type:"),3,muxingType);
    diaElemUInteger blockSize(&(muxSize),QT_TR_NOOP("_Split every MB:"),1,9000);

    diaElemUInteger n_frames(&(mux_n_frame),QT_TR_NOOP("Mux _every x video frames:"),1,100);
    diaElemUInteger n_block(&(mux_size_block),QT_TR_NOOP("Mux in _blocks of x bytes:"),1,50000);


    mux.link(&(muxingType[1]),1,&n_frames);
    mux.link(&(muxingType[2]),1,&n_block);

    diaElem *elems[4]= {&mux,&n_frames,&n_block,&blockSize};
    if( diaFactoryRun(QT_TR_NOOP("AVI Muxer Options"),4,elems))
    {
        muxMode=(PARAM_MUX)mux_mode;
        switch(muxMode)
        {
        case MUX_REGULAR:
            muxParam=1;
            break;
        case MUX_N_FRAMES:
            muxParam=mux_n_frame;
            break;
        case MUX_N_BYTES:
            muxParam=mux_size_block;
            break;
        default:
            ADM_assert(0);
        }
        return 1;
    }
    return 0;
};
Example #27
0
static cv::Mat patchImage(const cv::Mat &image, int patchSize, bool reduceMean=false)
{
    vector<int> blockSize(2, patchSize);
    vector<int> stepSize(2, 1);
    cv::Mat temp = im2col(image, blockSize, stepSize);
    if (! reduceMean)
        return temp;

    cv::Mat mean;
    cv::reduce(temp, mean, 0, cv::REDUCE_AVG);
    cv::Mat res;
    for (int i=0; i<temp.rows; i++)
    {
        cv::Mat temp2 = (temp.row(i) - mean.row(0));
        res.push_back(temp2.row(0));
    }
    return res;
}
void test(const shared_ptr< DistanceOctree< MeshType > > & distanceOctree, const MeshType & mesh, const AABB & domainAABB, Vector3<uint_t> numBlocks)
{
   Vector3<real_t> blockSize(domainAABB.xSize() / real_c(numBlocks[0]),
      domainAABB.ySize() / real_c(numBlocks[1]),
      domainAABB.zSize() / real_c(numBlocks[2]));

   real_t maxError = blockSize.min() / real_t(10);

   SetupBlockForest setupBlockforest;
   setupBlockforest.addRootBlockExclusionFunction(F(distanceOctree, maxError));
   setupBlockforest.addWorkloadMemorySUIDAssignmentFunction(blockforest::uniformWorkloadAndMemoryAssignment);


   setupBlockforest.init(domainAABB, numBlocks[0], numBlocks[1], numBlocks[2], false, false, false);
   WALBERLA_LOG_DEVEL(setupBlockforest.toString());


   std::vector< Vector3<real_t> > vertexPositions;
   vertexPositions.reserve(mesh.n_vertices());
   for (auto vIt = mesh.vertices_begin(); vIt != mesh.vertices_end(); ++vIt)
   {
      vertexPositions.push_back(toWalberla(mesh.point(*vIt)));
   }

   std::vector< const blockforest::SetupBlock* > setupBlocks;
   setupBlockforest.getBlocks(setupBlocks);

   // Check wether all vertices are located in allocated blocks
   std::vector< Vector3<real_t> > uncoveredVertices(vertexPositions);

   for (auto bIt = setupBlocks.begin(); bIt != setupBlocks.end(); ++bIt)
   {
      const AABB & aabb = (*bIt)->getAABB();

      uncoveredVertices.erase(std::remove_if(uncoveredVertices.begin(), uncoveredVertices.end(), PointInAABB(aabb)), uncoveredVertices.end());
   }

   WALBERLA_CHECK(uncoveredVertices.empty(), "Not all vertices of the mesh are located in allocated blocks!");

   //setupBlockforest.assignAllBlocksToRootProcess();
   //setupBlockforest.writeVTKOutput( "setupblockforest" );
}
Example #29
0
bool MemoryType::registerMemType(Location addr, size_t ofs, const RsType* type)
{
    // \pp addr = beginAddress() + ofs
    //     however, in UPC the conversion is quite involved when shared
    //     memory and blocking factors are in use, thus the interface
    //     supports both.
    const std::pair<bool, bool> mergeRes = checkAndMergeMemType(ofs, type);
    bool                        statuschange = mergeRes.second;

    if ( diagnostics::message(diagnostics::memory) )
    {
      std::stringstream msg;
      msg << "++ registerMemType at offset: " << ofs << " (base = " << startAddress << ")\n"
          << "++ type: " << type->getName() << '\n'
          << "++ types_merged: " << mergeRes;

      RuntimeSystem::instance().printMessage(msg.str());
    }

    if ( !mergeRes.first )
    {
        // type wasn't merged, some previously unknown portion of this
        // MemoryType has been registered with type
        assert(type);

        insert( typedata, TypeData::value_type(ofs, type) );

        // since we have knowledge about the type in memory, we also need to update the
        // information about "dereferentiable" memory regions i.e. pointer
        PointerManager& pm = rtedRTS(this).getPointerManager();

        pm.createPointer(addr, type, blockSize());
        statuschange = true;
    }

    if ( diagnostics::message(diagnostics::memory) )
    {
      RuntimeSystem::instance().printMessage("   ++ registerMemType done.");
    }

    return statuschange;
}
Example #30
0
char ttCanTurn(tetris_table* t, char right)
{
        block b;
        blockInitWithBlock(&b, t->next_block[0]);
        blockRotate(&b, right);

        for (uint16_t i = 0; i < blockSize(&b); ++i)
        {
                position p = blockPosition(&b, i);
                p.x += t->currentPos.x;
                p.y += t->currentPos.y;

                if (p.x < 0 || p.y >= t->size.y || p.x >= t->size.x || (p.y >= 0 && !t->tab[p.y][p.x].empty))
                {
                        blockFree(&b);
                        return 0;
                }
        }

        blockFree(&b);
        return 1;
}