int main() {
  struct gameState g;

  int k[10] = {smithy,adventurer,gardens,embargo,cutpurse,mine,ambassador,
	       outpost,baron,tribute};

  initializeGame(2, k, 5, &g);

  int count = fullDeckCount(1, copper, &g);

  myassert(count == 7, "there should be 7 copper");
  
  count = fullDeckCount(1, estate, &g);
  myassert(count == 3, "there should be 3 esatete");

  count = fullDeckCount(1, curse, &g);
  myassert(count ==0,  "there should be no curse");

  if (failed == 0){
     printf("test completed successfully!");
  }
  printf("%d\n", count);

  return 0;
}
Exemple #2
0
void ActionOutfile( cmdline_t *cmd, char *buf, uint file_num ) {
/************************************************************/

    char        sp_buf[ _MAX_PATH2 ];
    char        *drive;
    char        *dir;
    char        fname[ _MAX_FNAME ];
    const char *output;

/**/myassert( cmd != NULL );
/**/myassert( cmd->need_output );
/**/myassert( cmd->action != NULL );
/**/myassert( file_num < cmd->action->num_files );
    output = cmd->action->output;
    _splitpath2( ( output == NULL || output[0] == 0 ) ?
                cmd->action->files[ file_num ] : output,
                sp_buf, &drive, &dir, NULL, NULL );
    fname[0] = '_';
    fname[1] = 'W';
    for(;;) {
        StrDec( &fname[2], tempFileNum++ );
        _makepath( buf, drive, dir, fname, "TMP" );
        if( access( buf, 0 ) == -1 ) {
            break;
        }
    }
}
void ColumnBundle::setSub(int colStart, const ColumnBundle& Y)
{	myassert(colStart>=0);
	myassert(colStart<nCols());
	myassert(colLength()==Y.colLength());
	int nColsSub = std::min(Y.nCols(), nCols()-colStart);
	callPref(eblas_copy)(dataPref()+colStart*colLength(), Y.dataPref(), nColsSub*colLength());
}
int main(){
	struct gameState g;
	int test;
		
	int k1[10] = {smithy,
				smithy, 	//extra smithy
				gardens,
				gardens,	//extra gardens
				cutpurse,
				mine,
				ambassador,
				outpost,
				baron,
				tribute};

	//test 1 = no duplicate cards
	test = initializeGame(2, k, 9, &g);
	myassert(test==0, "2 players, no duplicate cards.\n\t(SHOULD PASS...)");
	
	//test 2 = duplicate cards	
	test = initializeGame(2, k1, 9, &g);
	myassert(test==0, "2 players, duplicate cards.\n\t(SHOUDLD NOT PASS...)");
	
	// test 3 = multiplayers
	test = initializeGame(4, k, 9, &g);
	myassert(test==0, "4 players, no duplicate cards.\n\t(SHOULD PASS...)");
	
	// test 4 = multiplayers
	test = initializeGame(10, k, 9, &g);
	myassert(test==0, "10 players, no duplicate cards.\n\t(SHOULD NOT PASS...)");

	checkasserts();
	return 0;
}
// tests the shuffle function
int main() {

	struct gameState g,g2;
	int cards[10] = {
		estate,
		duchy,
		province,
		copper,
		silver,
		gold,
		adventurer,
		great_hall,
		minion,
		steward
    };

	initializeGame(2, cards, 3, &g);

	int tester = shuffle(0, &g);
	myassert(tester == 0, "No P1 shuffle");
	tester = shuffle(1, &g);
	myassert(tester == 0, "No P1 shuffle");

	int cards2[1] = {estate};
	initializeGame(2, cards2, 3, &g2);
	tester = shuffle(1, &g2);
	myassert(tester == -1, "NO SHUFFLE");

	good_assert();

	return 0;
}
Exemple #6
0
struct asm_tok *PushInputStatus( struct input_status *oldstat )
/*************************************************************/
{
    oldstat->token_stringbuf = token_stringbuf;
    oldstat->token_count = Token_Count;
    oldstat->currsource = CurrSource;
    /* if there's a comment, attach it to current source */
    if ( ModuleInfo.CurrComment ) {
        int i = strlen( CurrSource );
        oldstat->CurrComment = CurrSource + i;
        strcpy( oldstat->CurrComment, ModuleInfo.CurrComment );
    } else
        oldstat->CurrComment = NULL;
    oldstat->line_flags = ModuleInfo.line_flags; /* v2.08 */
#ifdef __I86__
    oldstat->tokenarray = ModuleInfo.tokenarray;
    oldstat->stringbufferend = StringBufferEnd;
    CurrSource = MemAlloc( MAX_LINE_LEN + SIZE_TOKENARRAY + SIZE_STRINGBUFFER );
    ModuleInfo.tokenarray = (struct asm_tok *)( CurrSource + MAX_LINE_LEN );
    token_stringbuf = CurrSource + MAX_LINE_LEN + SIZE_TOKENARRAY;
#else
    token_stringbuf = StringBufferEnd;
    ModuleInfo.tokenarray += Token_Count + 1;
    CurrSource = GetAlignedPointer( CurrSource, strlen( CurrSource ) );
    /**/myassert( ( CurrSource + MAX_LINE_LEN ) <= (char *)ModuleInfo.tokenarray );
    /**/myassert( ( ModuleInfo.tokenarray + sizeof( struct asm_tok ) * MAX_TOKEN ) <= end_tokenarray );
    /**/myassert( ( token_stringbuf + 2 * MAX_LINE_LEN ) <= end_stringbuf );
#endif
    DebugMsg1(("PushInputStatus() stringbuf-tokencnt-currsrc old=%X-%u-%X new=%X-%X-%X\n",
               oldstat->token_stringbuf, oldstat->token_count, oldstat->currsource,
               token_stringbuf, ModuleInfo.tokenarray, CurrSource ));
    return( ModuleInfo.tokenarray );
}
int testPeople(int* failed) {
    
  struct gameState g;

  int k[10] = {smithy,adventurer,gardens,embargo,cutpurse,mine,ambassador,
	       outpost,baron,tribute};

  int r = initializeGame(2, k, 5, &g);

  myassert(failed, r == 0, "No duplicates, 2 players, should succeed");

  int k2[10] = {smithy,adventurer,gardens,embargo,cutpurse,mine,ambassador,
	       outpost,baron,adventurer};

  r = initializeGame(2, k2, 5, &g);

  myassert(failed, r == -1,"Duplicate card in setup, should fail");

  r = initializeGame(200, k, 5, &g);

  myassert(failed, r == 0,"I should be allowed to play with a lot of people!");

  return 0;

}
Exemple #8
0
STATIC int writeLedata( obj_rec *objr, pobj_state *state ) {

    OBJ_WFILE   *out;
    uint_16     save;
    uint_8      *ptr;
    uint_16     len;
    int         is32;

    /**/myassert( objr != NULL );
    /**/myassert( objr->command == CMD_LEDATA );
    /**/myassert( state != NULL );
    /**/myassert( state->pass == POBJ_WRITE_PASS );
#if ( _WOMP_OPT & _WOMP_WATFOR ) == 0
    LifixDestroy( &lifList );
    LifixInit( &lifList );
#endif
    out = state->file_out;
    is32 = objr->is_32 || objr->is_phar;
    ObjWBegRec( out, is32 ? CMD_LEDA32 : CMD_LEDATA );
    ObjWriteIndex( out, objr->d.ledata.idx );
    if( is32 ) {
        ObjWrite32( out, objr->d.ledata.offset );
    } else {
        ObjWrite16( out, (uint_16)objr->d.ledata.offset );
    }
    save = ObjRTell( objr );
    len = ObjRemain( objr );
    ptr = ObjGet( objr, len );
    /**/myassert( len <= 1024 );
    ObjWrite( out, ptr, len );
    ObjWEndRec( out );
    ObjRSeek( objr, save );
    return( 0 );
}
Exemple #9
0
STATIC int writeMisc32( obj_rec *objr, pobj_state *state ) {
    /*
        For 32-bit records which are the same under Intel, PharLap, and MS OMFs
    */
    uint_8  *ptr;
    uint_16 len;
    uint_8  cmd;
    uint_16 save;

    /**/myassert( objr != NULL );
    /**/myassert( objr->data != NULL );
    /**/myassert( state != NULL );
    /**/myassert( state->pass == POBJ_WRITE_PASS );
    save = ObjRTell( objr );
    ObjRSeek( objr, 0 );
    len = ObjRemain( objr );
    ptr = ObjGet( objr, len );
    cmd = objr->command;
    if( objr->is_32 || objr->is_phar ) {
        cmd |= 0x01;
    }
    ObjWriteRec( state->file_out, cmd, len, ptr );
    ObjRSeek( objr, save );
    return( 0 );
}
Exemple #10
0
void diagMatrix::set(int iStart, int iStop, const diagMatrix& m)
{	myassert(iStart>=0 && iStart<nRows());
	myassert(iStop>iStart && iStop<=nRows());
	int iDelta = iStop-iStart;
	myassert(iDelta==m.nRows());
	for(int i=0; i<iDelta; i++) at(i+iStart) = m[i];
}
Exemple #11
0
value push_stack_fragment(value ekfragment)
{
    const mlsize_t size = Wosize_val(ekfragment);
    value *p, *new_sp, *new_trapsp;

    /*
    print_gl_stack("push_stack_fragment");
    print_exc_trace("push_stack_fragment: before");
    */

    myassert(caml_extern_sp >= caml_stack_low);
    myassert(caml_extern_sp <= caml_stack_high);
    myassert(caml_trapsp    < caml_stack_high);
    myassert(caml_trapsp    > caml_extern_sp);

    if( caml_extern_sp - size < caml_stack_threshold )
    {
        print_gl_stack("push_stack_fregment: no stack space! Have I forgotten"
                       " to call ensure_stack_space?");
        myassert(0);
#if 0
        /* Old way, pre 3.11: */
        print_gl_stack("Reallocating OCaml stack!");
        caml_realloc_stack(Stack_threshold / sizeof(value));
        */
        return push_stack_fragment(ekfragment); /* Redo */
#endif
    }
Exemple #12
0
int main() {
    int p = 1; //player 1
    int r;
    int k[10] = {adventurer, council_room, feast, gardens, mine
               , remodel, smithy, village, baron, great_hall};
    struct gameState G;
    
    printf ("\n*****TESTING discardCard():*****\n");
    r = initializeGame(2, k, 1, &G);
    printf("initializeGame() returned %d, Expected %d\n", r, 0);
    myassert(r == 0, __LINE__);   

    int origHandCount = G.handCount[p];
    int origDiscCount = G.discardCount[p];
    
    r = discardCard(0, p, &G, 0);

    printf ("discardCount = %d, Expected %d\n", G.discardCount[p], origDiscCount + 1);
    myassert (G.discardCount[p] == origDiscCount + 1, __LINE__);
        
    printf ("handCount = %d, Expected %d\n", G.handCount[p], origHandCount - 1);
    myassert (G.handCount[p] == origHandCount - 1, __LINE__);

    printf("discardCard test complete!\n");
    return 0;
}
int main (int argc, char** argv)
{
  struct gameState state;

  state.whoseTurn = 0;
  state.numActions = 1;
  state.handCount[0] = 1;
  state.hand[0][0] = great_hall;
  state.deckCount[0] = 1;
  state.deck[0][0] = province;
  state.discardCount[0] = 0;

  printf("Playing Great hall card.\n");
  playCard( 0, 0, 0, 0, &state);
  printf("Checking hand count... ");
  myassert(state.handCount[0] == 1);
  printf("Checking # of actions... ");
  myassert(state.numActions == 1);
  printf("Next two tests should fail because the Great Hall card has purposely been changed\n");
  printf("Checking deck size... ");
  myassert(state.deckCount[0] == 0);
  printf("Checking hand cards... ");
  myassert(state.hand[0][0] == province);

  return 0;
}
ColumnBundle operator*(const scaled<ColumnBundle> &sY, const matrixScaledTransOp &Mst)
{	static StopWatch watch("Y*M");
	watch.start();
	const ColumnBundle& Y = sY.data;
	double scaleFac = sY.scale * Mst.scale;
	bool spinorMode = (2*Y.nCols() == Mst.nRows()); //treat each column of non-spinor Y as two identical consecutive spinor ones with opposite spins
	myassert(Y.nCols()==Mst.nRows() || spinorMode);
	CBLAS_TRANSPOSE Mop; const matrix* M; ColumnBundle YM; matrix Mtmp;
	if(spinorMode)
	{	matrix mIn(Mst); Mop=CblasNoTrans; //pre-apply the op in this case
		Mtmp.init(Y.nCols(), 2*mIn.nCols(), isGpuEnabled());
		Mtmp.set(0,1,Y.nCols(), 0,2,Mtmp.nCols(), mIn(0,2,mIn.nRows(), 0,1,mIn.nCols()));
		Mtmp.set(0,1,Y.nCols(), 1,2,Mtmp.nCols(), mIn(1,2,mIn.nRows(), 0,1,mIn.nCols()));
		M = &Mtmp;
		myassert(!Y.isSpinor());
		YM.init(mIn.nCols(), Y.colLength()*2, Y.basis, Y.qnum, isGpuEnabled());
	}
	else
	{	Mop = Mst.op;
		M = &Mst.mat;
		YM = Y.similar(Mst.nCols());
	}
	callPref(eblas_zgemm)(CblasNoTrans, Mop, Y.colLength(), M->nCols(), Y.nCols(),
		scaleFac, Y.dataPref(), Y.colLength(), M->dataPref(), M->nRows(),
		0.0, YM.dataPref(), Y.colLength());
	watch.stop();
	return YM;
}
Exemple #15
0
diagMatrix diagMatrix::operator()(int iStart, int iStop) const
{	myassert(iStart>=0 && iStart<nRows());
	myassert(iStop>iStart && iStop<=nRows());
	int iDelta = iStop-iStart;
	diagMatrix ret(iDelta);
	for(int i=0; i<iDelta; i++) ret[i] = at(i+iStart);
	return ret;
}
Exemple #16
0
/* Get the current value of trapsp (relative to caml_stack_high)
*/
value get_trapsp(value unit)
{
    myassert(caml_extern_sp >= caml_stack_low);
    myassert(caml_extern_sp <= caml_stack_high);
    myassert(caml_trapsp    <= caml_stack_high);

    return Val_long(caml_stack_high - caml_trapsp);
}
Exemple #17
0
STATIC int readTheadr( obj_rec *objr, pobj_state *state ) {

/**/myassert( objr != NULL && objr->command == CMD_THEADR );
/**/myassert( state != NULL && state->pass == POBJ_READ_PASS );
    objr = objr;
    state = state;
    QInit( &libQueue );
    return( 0 );
}
ColumnBundle ColumnBundle::getSub(int colStart, int colStop) const
{	myassert(colStart>=0);
	myassert(colStop<=nCols());
	int nColsSub = colStop - colStart;
	myassert(nColsSub>0);
	ColumnBundle ret = this->similar(nColsSub);
	callPref(eblas_copy)(ret.dataPref(), dataPref()+colStart*colLength(), nColsSub*colLength());
	return ret;
}
int main()
{
	extern int numViolated;
	int p = 0;	
	int status;
	int count = 0;

	// Setup
	struct gameState G;

	int k[10] = {adventurer, gardens, embargo, village, minion, mine, cutpurse, sea_hag, tribute, smithy};

	status = initializeGame(2, k, 1317, &G);
	if (myassert(status == 0, "Failed to initialize, fullDeckCount test aborted", &numViolated))
	{
		return 1;
	}

	// Run the function to be tested
	count = fullDeckCount(0, copper, &G);	
	if (myassert(count >= 0, "fullDeckCount failed to run, abort test", &numViolated))
	{
		return 1;
	}
              	
	// Check if it performed as expected	
	int i;
	int count2 = 0;
	for (i = 0; i < G.deckCount[p]; i++) 
	{
		if (G.deck[p][i] == copper)
		{
			count2++;
		}
	}

	for (i = 0; i < G.handCount[p]; i++)
	{
		if (G.hand[p][i] == copper)
		{
			count2++;
		}
	}

	for (i = 0; i < G.discardCount[p]; i++)
	{
		if (G.discard[p][i] == copper)
		{
			count2++;
		}
	}

	status = myassert (count == count2, "fullDeckCount failed to count correctly", &numViolated);
	printf("fullDeckCount result: %d\n", status);
	return status;
}	
Exemple #20
0
STATIC int writeFixup( obj_rec *objr, pobj_state *state ) {

    OBJ_WFILE   *out;
    int         is32;
    fixup       *walk;
    uint_8      buf[ FIX_GEN_MAX ];
    uint_16     len;
    uint_16     len_written;
    uint_8      cmd1;
    uint_8      cmd2;

    /**/myassert( objr != NULL );
    /**/myassert( objr->command == CMD_FIXUP );
    /**/myassert( state != NULL );
    /**/myassert( state->pass == POBJ_WRITE_PASS );
    walk = objr->d.fixup.fixup;
    if( walk == NULL ) {
        /* huh? this shouldn't really happen... */
        return( 0 );
    }
    out = state->file_out;
    is32 = objr->is_32 || objr->is_phar;
    cmd1 = is32 ? CMD_FIXU32 : CMD_FIXUP;
    cmd2 = is32 ? FIX_GEN_MS386 : FIX_GEN_INTEL;
    /* we don't want to write FIXUP records that are too large, so we limit
       our records to approximately 1024 bytes */
    do {
        len_written = 0;
        ObjWBegRec( out, cmd1 );
        while( walk != NULL && len_written < 1024 - FIX_GEN_MAX ) {
            walk->loc_offset += LifixDelta( &lifList, (uint_16)walk->loc_offset );
#if _WOMP_OPT & _WOMP_WOMP
            if( Can2MsOS2Flat() &&
                    ( walk->loc_method == FIX_OFFSET386
                      || walk->loc_method == FIX_POINTER386 ) ) {
                /* zap FIXUPs for OS/2 2.0 linker 21-mar-91 AFS */
                switch( walk->lr.frame ) {
                case FRAME_SEG:
                case FRAME_GRP:
                case FRAME_TARG:
                    walk->lr.frame = FRAME_GRP;
                    walk->lr.frame_datum = ObjFLATIndex;
                    break;
                }
            }
#endif
            len = FixGenFix( walk, buf, cmd2 );
            ObjWrite( out, buf, len );
            walk = walk->next;
            len_written += len;
        }
        ObjWEndRec( out );
    } while( walk != NULL );
    return( 0 );
}
void ColumnBundleTransform::scatterAxpy(complex alpha, const ColumnBundle& C_C, int bC, ColumnBundle& C_D, int bD) const
{	//Check inputs:
	myassert(C_C.colLength() == nSpinor*basisC.nbasis); myassert(bC >= 0 && bC < C_C.nCols());
	myassert(C_D.colLength() == nSpinor*basisD.nbasis); myassert(bD >= 0 && bD < C_D.nCols());
	//Scatter:
	for(int sD=0; sD<nSpinor; sD++)
		for(int sC=0; sC<nSpinor; sC++)
			callPref(eblas_scatter_zaxpy)(index.size(), alpha*spinorRot(sD,sC), indexPref,
				C_C.dataPref() + C_C.index(bC, sC*C_C.basis->nbasis),
				C_D.dataPref() + C_D.index(bD, sD*C_D.basis->nbasis), invert<0 );
}
Exemple #22
0
STATIC int writeTheadr( obj_rec *objr, pobj_state *state ) {

/**/myassert( objr != NULL && objr->command == CMD_THEADR );
/**/myassert( state != NULL && state->pass == POBJ_WRITE_PASS );
    state = state;
    objr = objr;
    if( libQueue.head != NULL ) {
        PObjJoinQueue( &libQueue );
    }
    return( 0 );
}
Exemple #23
0
STATIC int readComent( obj_rec *objr, pobj_state *state ) {

/**/myassert( objr != NULL && objr->command == CMD_COMENT );
/**/myassert( state != NULL && state->pass == POBJ_READ_PASS );
    state = state;
    if( objr->d.coment.class == CMT_DEFAULT_LIBRARY ) {
        QEnqueue( &libQueue, objr );
        return( -1 );
    }
    return( 0 );
}
Exemple #24
0
void 
mySpinUnlock(pthread_mutex_t *mutex)
{
  int rval = pthread_mutex_trylock(mutex);
  if (rval != EBUSY) {
    dprintLine("Trying to unlock %p but it wasn't locked? %d\n", mutex, rval);
    myassert(0, "blah");
  }
  int retval = pthread_mutex_unlock(mutex);
  myassert(retval == 0, "Failure to unlock mutex: %d [%s]\n", retval, strerror(retval));
}
int main(int argc, char* argv[]){
   if(argc < 2){printf("Usage: %s loops [seed]\n", argv[0]); return 1;}
   int loops = atoi(argv[1]);
   if(argc == 2) srand(time(NULL));
   else srand(atoi(argv[2]));

   struct gameState g;
   struct gameState *game = &g;
   int numPlayers = 2, i, randNum, temp1, temp2;

   initializeGame(numPlayers, (int *)kCards, rand(), game);

   printf("Starting test...\n");

   i = 0;
   while(i < loops){
      randNum = rand() % (_end + 1);
      switch(randNum){
	 case(_buy):
	    if(display) printf("buying a card\n");
	    randNum = rand() % 10;
	    temp1 = game->supplyCount[randNum];
	    temp2 = totalCards(game);
	    if(buyCard(randNum, game)) break;
	    myassert(game->supplyCount[randNum] != temp1 - 1, "Buy Phase: Did not reduce supply Count\n");
	    myassert(totalCards(game) != temp2 + 1, "Buy Phase: Player did not gain card\n");
	    break;
	 case(_action):
	    if(display) printf("using a card\n");
	    temp1 = game->handCount[game->whoseTurn];
	    temp2 = playCard(rand() % game->handCount[game->whoseTurn], 0, 0, 0, game);
	    if(temp2 == -1) break;
	    myassert(game->handCount[game->whoseTurn] != temp1 - 1, "Action Phase: Played Card is still in players hand\n");
	    break;
	 case(_end):
	    if(display) printf("ending turn\n");
	    temp1 = game->whoseTurn;
	    temp1++;
	    if(temp1 > numPlayers - 1) temp1 = 0;
	    temp2 = endTurn(game);
	    if(temp2) break;
	    myassert(game->whoseTurn != temp1, "End Phase: Players turn did not end correctly\n");
	    break;
	 default:
	    myassert(1, "Error in test harness\n");
      }
      i++;
   }

   (numFails()) ? printf("Test failed %d times\n", numFails()) : printf("Test successful\n");

   return 0;
}
Exemple #26
0
//Reshaping
void matrix::reshape(int nrows, int ncols)
{	myassert(nrows>=0);
	myassert(ncols>=0);
	size_t nProd = nr * nc; //current size
	//Fill in missing dimensions if any:
	if(!nrows) { myassert(ncols); nrows = nProd / ncols; }
	if(!ncols) { myassert(nrows); ncols = nProd / nrows; }
	//Update dimensions:
	myassert(nrows * ncols == int(nProd));
	nr = nrows;
	nc = ncols;
}
void ColumnBundleTransform::gatherAxpy(complex alpha, const ColumnBundle& C_D, int bD, ColumnBundle& C_C, int bC) const
{	//Check inputs:
	myassert(C_C.colLength() == nSpinor*basisC.nbasis); myassert(bC >= 0 && bC < C_C.nCols());
	myassert(C_D.colLength() == nSpinor*basisD.nbasis); myassert(bD >= 0 && bD < C_D.nCols());
	//Gather:
	matrix spinorRotInv = (invert<0) ? transpose(spinorRot) : dagger(spinorRot);
	for(int sD=0; sD<nSpinor; sD++)
		for(int sC=0; sC<nSpinor; sC++)
			callPref(eblas_gather_zaxpy)(index.size(), alpha*spinorRotInv(sC,sD), indexPref,
				C_D.dataPref() + C_D.index(bD, sD*C_D.basis->nbasis),
				C_C.dataPref() + C_C.index(bC, sC*C_C.basis->nbasis), invert<0 );
}
Exemple #28
0
STATIC int writeComdat( obj_rec *objr, pobj_state *state ) {

    OBJ_WFILE   *out;
    uint_8      *ptr;
    uint_16     len;
    uint_16     save;
    int         is32;

    /**/myassert( objr != NULL );
    /**/myassert( objr->command == CMD_COMDAT );
    /**/myassert( state != NULL );
    /**/myassert( state->pass == POBJ_WRITE_PASS );
    save = ObjRTell( objr );
    is32 = objr->is_32 || objr->is_phar;
    if( is32 ) {
        objr->command |= 1;
    }
    out = state->file_out;
    ObjWBegRec( out, objr->command );
    ObjWrite8( out, objr->d.comdat.flags );
    ObjWrite8( out, objr->d.comdat.attributes );
    ObjWrite8( out, objr->d.comdat.align );
    if( is32 ) {
        ObjWrite32( out, objr->d.comdat.offset );
    } else {
        ObjWrite16( out, (uint_16)objr->d.comdat.offset );
    }
    ObjWriteIndex( out, objr->d.comdat.type_idx );
    if( ( objr->d.comdat.attributes & COMDAT_ALLOC_MASK ) == COMDAT_EXPLICIT ) {
        writeBase( objr, out );
    }
    ObjWriteIndex( out, objr->d.comdat.public_name_idx );
    if( ( objr->d.comdat.flags & COMDAT_ITERATED ) == 0 || objr->is_phar == 0 ) {
        /* record is already in ms omf format */
        len = ObjRemain( objr );
        ptr = ObjGet( objr, len );
        /**/    myassert( len <= 1024 );
        ObjWrite( out, ptr, len );
    } else {
        int_16 delta;
        uint_16 first_block_offset;

        delta = 0;  /* id32Block needs to play with this */
        first_block_offset = ObjRTell( objr );
        while( !ObjEOR( objr ) ) {
            id32Block( objr, out, &delta, first_block_offset );
        }
    }
    ObjWEndRec( out );
    ObjRSeek( objr, save );
    return( 0 );
}
Exemple #29
0
STATIC int writeTheadr( obj_rec *objr, pobj_state *state ) {

    /**/myassert( objr != NULL );
    /**/myassert( objr->command == CMD_THEADR );
    /**/myassert( state != NULL );
    /**/myassert( state->pass == POBJ_WRITE_PASS );
    /* here's our initialization code */
#if ( _WOMP_OPT & _WOMP_WATFOR ) == 0
    LifixInit( &lifList );
#endif

    return( writeMisc( objr, state ) );
}
Exemple #30
0
void matrix::set(int i, int j, complex m)
{	myassert(i<nr and i>=0);
	myassert(j<nc and j>=0);
	if(isOnGpu())
	{
		#ifdef GPU_ENABLED
		cudaMemcpy(dataGpu()+index(i,j), &m, sizeof(complex), cudaMemcpyHostToDevice);
		#else
		myassert(!"onGpu=true without GPU_ENABLED");
		#endif
	}
	else data()[index(i,j)] = m;
}