Exemple #1
0
static void composite_pulse(double width, codeint phasetable, double rx1, double rx2, codeint phase)
{
  getelem(phasetable,ct,phase); /* Extract observe phase from table */
  incr(phase); rgpulse(width,phase,rx1,rx1);  /*  Y  */
  incr(phase); rgpulse(width,phase,rx1,rx1);  /* -X  */
  incr(phase); rgpulse(width,phase,rx1,rx1);  /* -Y  */
  incr(phase); rgpulse(width,phase,rx1,rx2);  /*  X  */
} 
Exemple #2
0
// Three levels with 65535 entries each gives
// 65535^3 = 281,462,092,005,375 data entries
// recommend a filesystem with lots of inodes?
// Hmm, but ext3 only allows 32000 subdirs, although that many files are OK.
static int dpth_incr(struct dpth *dpth)
{
	if(incr(&dpth->tert, MAX_FILES_PER_DIR)
	  || incr(&dpth->seco, MAX_STORAGE_SUBDIRS)
	  || incr(&dpth->prim, MAX_STORAGE_SUBDIRS))
		return 0;
	logp("No free data file entries out of the %d*%d*%d available!\n",
		MAX_FILES_PER_DIR, MAX_STORAGE_SUBDIRS, MAX_STORAGE_SUBDIRS);
	logp("Maybe move the storage directory aside and start again.\n");
	return -1;
}
Exemple #3
0
int main() {
  int *a = (int*)malloc(sizeof(int));
  int *b = (int*)malloc(sizeof(int));

  *a = *b = 0;

  incr(a);
  incr(b);

  __SMACK_assert(*a == 1);
  __SMACK_assert(*b == 1);

  return 0;
}
Exemple #4
0
// CONVERT: concatenates three strings ( a-n-e ).
void tex::pack_file_name(str n, str a, str e)
	{
	str	s;
	
	name_str = name_of_file;
	for (s = a; *s; incr(s))
		append_to_name(*s);
	for (s = n; *s; incr(s))
		append_to_name(*s);
	for (s = e; *s; incr(s))
		append_to_name(*s);
	append_to_name(NUL);
	name_length = name_str - name_of_file;
	}
Exemple #5
0
void tex::scan_math(ptr p)
	{
	int	c;

restart:
	get_nbrx_token();

reswitch:
	switch (cur_cmd)
	{
	case LETTER:
	case OTHER_CHAR:
	case CHAR_GIVEN:
		c = math_code(cur_chr);
		if (c == 0100000) {
			cur_cs = active_base[cur_chr];
			cur_cmd = eq_type(cur_cs);
			cur_chr = equiv(cur_cs);
			x_token();
			back_input();
			goto restart;
		}
		break;
	
	case CHAR_NUM:
		scan_char_num();
		cur_chr = cur_val;
		cur_cmd = CHAR_GIVEN;
		goto reswitch;
	
	case MATH_CHAR_NUM:
		scan_fifteen_bit_int();
		c = cur_val;
		break;

	case MATH_GIVEN:
		c = cur_chr;
		break;
		
	case DELIM_NUM:
		scan_twenty_seven_bit_int();
		c = cur_val / 010000;
		break;

	default:
		back_input();
		scan_left_brace();
		saved(0) = p;
		incr(save_ptr);
		push_math(MATH_GROUP);
		return;
	}
	math_type(p) = MATH_CHAR;
	character(p) = c % 256;
	if (c >= VAR_CODE && fam_in_range()) {
		fam(p) = cur_fam;
	} else {
		fam(p) = c / 256 % 16;
	}
	}
void Player::update(Uint32 ticks) { 
  advanceFrame(ticks);

  //Vector2f incr = getVelocity() * static_cast<float>(ticks) * 0.001;
  Vector2f incr(0.0, 12.0);
  setPosition(getPosition() + incr);
  //timeSinceLastBullet += ticks;
  //bullets.update(ticks);
  /*
  if ( Y() < 0) {
    velocityY( abs( velocityY() ) );
    velocityY(0);
  }
  if ( Y() > worldHeight-frameHeight) {
    velocityY( -abs( velocityY() ) );
    velocityY(0);
  }

  if ( X() < 0) {
    velocityX( abs( velocityX() ) );
    velocityX(0);
  }
  if ( X() > worldWidth-frameWidth) {
    velocityX( -abs( velocityX() ) );
    velocityX(0);
  }  
  */
}
Exemple #7
0
int main ()
{  /*  hailstone numbers  */

    int iter,r;
    big x,y,mx;
    mirsys(400,10);
    x=mirvar(0);
    y=mirvar(0);
    mx=mirvar(0);
    iter=0;
    printf("number = \n");
    innum(x,stdin);
    do
    { /* main loop */
        if (compare(x,mx)>0) copy(x,mx);
        r=subdiv(x,2,y);
        if (r!=0)
        { /* what goes up ... */
            premult(x,3,x);
            incr(x,1,x);
        }
        /* ... must come down */
        else copy(y,x);
        otnum(x,stdout);
        iter++;
    } while (size(x)!=1);
    printf("path length = %d \n",iter);
    printf("maximum = \n");
    otnum(mx,stdout);
    return 0;
}
Exemple #8
0
void	ft_print_combn(int len)
{
	char str[len];
	int i;
	int j;

	j = 0;
	i = 1;
	init_tab(str, len);

	while (i)
	{
		i = incr(str, len);
		if (good(str, len))
		{
			ft_putstr(str);
			if (i)
			{
				ft_putchar(',');
				ft_putchar(' ');
			}
			else
				ft_putchar('\n');
		}
	}
}
bool nwxXmlContainer::Load(wxXmlNode *pNode)
{
  wxString sName;
  wxString sValue;
  wxString sText;
  wxXmlNode *pChild;
  wxXmlProperty *pAttr;
  mapPERSIST::iterator itr;
  mapPERSIST::iterator itrEnd = m_map.end();
  mapPERSISTstr::iterator itrs;
  mapPERSISTstr::iterator itrsEnd = m_mapAttr.end();
  bool bRtn = true;
  wxXmlNodeType nType;
  Init();
  CIncrementer incr(m_nInitRecursion);

  // Nodes

  for(pChild = pNode->GetChildren();
      bRtn && (pChild != NULL);
      pChild = pChild->GetNext())
  {
    nType = pChild->GetType();
    if(nType == wxXML_ELEMENT_NODE)
    {
      sName = pChild->GetName();
      itr = m_map.find(sName);
      if(itr != itrEnd)
      {
        PERSIST *pp(itr->second);
        bRtn = pp->pPersist->LoadFromNode(pChild,pp->pObj);
      }
    }
    else if(nType == wxXML_TEXT_NODE || nType == wxXML_CDATA_SECTION_NODE)
    {
      sText.Append(pChild->GetContent());
    }
  }

  itrsEnd = m_mapAttr.end();
  for(pAttr = pNode->GetProperties();
    bRtn && (pAttr != NULL);
    pAttr = pAttr->GetNext())
  {
    sName = pAttr->GetName();
    itrs = m_mapAttr.find(sName);
    if(itrs != itrsEnd)
    {
      sValue = pAttr->GetValue();
      PERSISTstr *pp(itrs->second);
      bRtn = pp->pPersist->LoadFromString(sValue,pp->pObj);
    }
  }

  if( (m_pPersistText != NULL) && (!sText.IsEmpty()) )
  {
    m_pPersistText->pPersist->LoadFromString(sText,m_pPersistText->pObj);
  }
  return bRtn;
}
int main(void) {
  int x = __VERIFIER_nondet_int();
  int y = x;
  x = incr(x);
  assert(x == y + 1);
  return 0;
}
Exemple #11
0
void tex::delete_last ()
	{
	int	m;
	ptr	p=0, q;
	
	if (mode == VMODE && tail == head) {
		if (cur_chr != GLUE_NODE
			 || last_glue != null) {
			you_cant();
			if (cur_chr == KERN_NODE) {
				help_delete_last_kern();
			} else if (cur_chr == GLUE_NODE) {
				help_delete_last_skip();
			} else {
				help_delete_last_pen(); 
			}
			error();
		}
	} else if (!is_char_node(tail) && type(tail) == cur_chr) {
		for (q = head; q != tail; q = link(p)) {
			p = q;
			if (!is_char_node(q) && type(q) == DISC_NODE) {
				for (m = 1; m <= replace_count(q); incr(m))
					p = link(p);
				if (p == tail)
					return;
			}
		}
		link(p) = null;
		flush_node_list(tail);
		tail = p;
		}
	}
Exemple #12
0
/* bbincr - build tree to increment execution point at *cp */
static void bbincr(Symbol yycounts, Coordinate* cp, Tree* e) {
    struct map* mp = maplist->x;
    Tree t;

    /* append *cp to source map */
    if (mp->size >= NELEMS(mp->u)) {
        NEW(mp, PERM);
        mp->size = 0;
        maplist = append(mp, maplist);
    }
    if (IR->little_endian) {
        mp->u[mp->size].le.x = cp->x;
        mp->u[mp->size].le.y = cp->y;
        mp->u[mp->size++].le.index = bbfile(cp->file);
    } else {
        mp->u[mp->size].be.x = cp->x;
        mp->u[mp->size].be.y = cp->y;
        mp->u[mp->size++].be.index = bbfile(cp->file);
    }
    t = incr('+', rvalue((*optree['+'])(ADD, pointer(idtree(yycounts)),
                                        consttree(npoints++, inttype))), consttree(1, inttype));
    if (*e)
        *e = tree(RIGHT, (*e)->type, t, *e);
    else
        *e = t;
}
Exemple #13
0
int main()
{
  arr[count++] = incr ();
  if (count != 2 || arr[count] != 3)
    abort ();
  return 0;
}
Exemple #14
0
void NewPoissonOp::residual(  FArrayBox& a_lhs, const FArrayBox& a_phi,
                              const FArrayBox& a_rhs, bool a_homogeneous)
{
  applyOp(a_lhs, a_phi, a_homogeneous);
  a_lhs*=-1.0;
  incr(a_lhs, a_rhs, 1);
}
Exemple #15
0
/* sec 0321 */
void push_input(void)
{
  if (input_ptr > max_in_stack)
  {
    max_in_stack = input_ptr;

#ifdef ALLOCATEINPUTSTACK
    if (input_ptr == current_stack_size)
      input_stack = realloc_input_stack(increment_stack_size);
    
    if (input_ptr == current_stack_size)
    {
      overflow("input stack size", current_stack_size);
      return;
    }
#else
    if (input_ptr == stack_size)
    {
      overflow("input stack size", stack_size);
      return;
    }
#endif
  }
  
  input_stack[input_ptr] = cur_input;
  incr(input_ptr);
}
int Preimager::find_preimage()
{
    const int bytes= (int) std::ceil(digest_size / 8.0);
    byte digest[20]={0};
    long max_tries = std::pow(2,digest_size)*5;
    int tries=0;

    byte message[bytes], preimage_raw[bytes];
    for(int i =0; i < bytes; i ++){
        preimage_raw[i]= message[i] =(byte)rand();
    }

    SHA1(message,bytes,digest);
    std::string preimage = to_b_str(digest, digest_size);

    while(max_tries--){
        incr(message,bytes);
        SHA1(message,bytes,digest);

        std::string dg=to_b_str(digest,digest_size);

        if(dg == preimage)
        {
            std::cout<<to_str(preimage_raw,bytes)<<"\t";
            std::cout<<to_str(message,bytes)<<"\t";
            std::cout<<dg<<"\t";

            return tries;
        }
        tries++;
    }

    return tries;
}
Exemple #17
0
void tex::begin_insert_or_adjust ()
	{
	if (cur_cmd == VADJUST) {
		cur_val = 255;
		} 
	else {
		scan_eight_bit_int();
		if (cur_val == 255) {
			print_err("You can't ");
			print_esc("insert");
			print_int(255);
			help_insert_255();
			error();
			cur_val = 0;
			}
		}
	saved(0) = cur_val;
	incr(save_ptr);
	new_save_level(INSERT_GROUP);
	scan_left_brace();
	normal_paragraph();
	push_nest();
	mode = -VMODE;
	prev_depth = IGNORE_DEPTH;
	}
Exemple #18
0
pulsesequence()
{   
  double cycles,
	 bigtau = getval("bigtau"),
	 tau = getval("tau"),
  	  satdly = getval("satdly");
  char  satmode[MAXSTR],
        sspul[MAXSTR];

  getstr("satmode",satmode);
  getstr("sspul",sspul);

  settable(t1,4,phs1);
  settable(t2,8,phs2);
  settable(t3,4,phs3);
  getelem(t1,ct,v1);
  getelem(t2,ct,v2);
  getelem(t3,ct,v4);
  assign(v1,oph);

/* calculate 'big tau' values */
   cycles = bigtau/(2.0*tau);
   cycles = (double)((int)((cycles/2.0) + 0.5)) * 2.0;
   initval(cycles,v3);


/* equilibration period */
   status(A);

   delay(5.0e-5);
   if (sspul[0] == 'y')
        steadystate();

   if (satmode[0] == 'y')
     {
        if ((d1-satdly) > 0.02)
                delay(d1-satdly);
        else
                delay(0.02);
        satpulse(satdly,v2,rof1,rof1);
     }
   else
        delay(d1);

/* calculate exact delay and phases */
   mod2(oph,v5);  
   incr(v5); 

/* spin-echo loop */
   status(B);
   rgpulse(pw,v1,rof1,0.0);
   starthardloop(v3);
      delay(tau - p1/2.0 - rof2);
      rgpulse(p1,v5,rof2,rof2); 
      delay(tau - p1/2.0 - rof2);
   endhardloop();

/* observation period */
   status(C);
} 
Exemple #19
0
void nwxXmlContainer::Init()
{
  if(!m_nInitRecursion)
  {
    CIncrementer incr(m_nInitRecursion);
    PERSIST *pP;
    PERSISTstr *pPS;
    for(vector<PERSIST *>::iterator itr = m_list.begin();
      itr != m_list.end();
      ++itr)
    {
      pP = *itr;
      pP->pPersist->Init(pP->pObj);
    }
    for(vector<PERSISTstr *>::iterator itrs = m_listAttr.begin();
      itrs != m_listAttr.end();
      ++itrs)
    {
      pPS = *itrs;
      pPS->pPersist->Init(pPS->pObj);
    }
    if(m_pPersistText != NULL)
    {
      m_pPersistText->pPersist->Init(m_pPersistText->pObj);
    }
  }
}
Exemple #20
0
void main()
{
  BinaryPredicateType<short, short>* nbpp;
  UnaryPredicateType<short>* nupp;
  UnaryFunctionType<short, short> uf(square);
  BinaryFunctionType<short, short, short> bf = add;
  UnaryPredicateType<short> up = even;
  BinaryPredicateType<short, short> bp = lesser;
  Negate<short> neg(up);
  Negate2<short, short> neg2(bp);
  Bind1st<short, short, short> bind1(bf, 26);
  Bind2nd<Boolean, short, short> bind2(bp, 35);
  Generator<short> gen(10);
  Incrementor<short> incr(25);
  Decrementor<short> decr(45);

  int val1, val2;
//  clrscr();

  nupp = &neg(up);
  nbpp = &neg2(bp);

  val1 = uf(5);
  val2 = bf(uf(6), 3);

  cout <<val1 <<"\t" <<val2 <<endl;

  val1++;
  cout <<up(val1) <<"\t" <<up(val2) <<endl;
  cout <<(*nupp)(val1) <<"\t" <<(*nupp)(val2) <<endl;
  val2++;
  val1++;
  cout <<up(val1) <<"\t" <<up(val2) <<endl;
  cout <<bp(val1, val2) <<"\t" <<bp(val2, val1) <<endl;
  cout <<(*nbpp)(val1, val2) <<"\t" <<(*nbpp)(val2, val1) <<endl;
  cout <<val1 <<"\t" <<val2 <<endl;

  cout <<bind1(val1) <<"\t" <<bind1(val2) <<endl;
  cout <<bind2(val1) <<"\t" <<bind2(val2) <<endl;

  cout <<gen() <<"\t";
  cout <<gen() <<endl;
  cout <<incr() <<"\t";
  cout <<incr() <<endl;
  cout <<decr() <<"\t";
  cout <<decr() <<endl;
}                       
int main (int argc, char** argv)
{
    gchar *filename;

    // open the file
    if (argc > 1) {
	filename = argv[1];
    } else {
	filename = "emma.txt";
    }

    FILE *fp = g_fopen(filename, "r");
    if (fp == NULL) {
	perror (filename);
	exit (-10);
    }
    /* string array is a (two-L) NULL terminated array of pointers to
       (one-L) NUL terminated strings */

    gchar **array;
    gchar line[128];

    GHashTable* hash = g_hash_table_new_full (g_str_hash, 
					      g_str_equal,
					      g_free,
					      g_free);

    int i;

    // read lines from the file and build the hash table
    while (1) {
	gchar *res = fgets (line, sizeof(line), fp);
	if (res == NULL) break;

	array = g_strsplit (line, " ", 0);
	for (i=0; array[i] != NULL; i++) {
	    incr (hash, array[i]);
	}
	g_strfreev (array);
    }
    fclose (fp);

    // print the hash table
    // g_hash_table_foreach (hash,  (GHFunc) kv_printor, "Word %s freq %d\n");

    // iterate the hash table and build the sequence
    GSequence *seq = g_sequence_new ((GDestroyNotify) pair_destructor);
    g_hash_table_foreach (hash,  (GHFunc) accumulator, (gpointer) seq);

    // iterate the sequence and print the pairs
    g_sequence_foreach (seq,  (GFunc) pair_printor, NULL);

    // free everything
    g_hash_table_destroy (hash);

    g_sequence_free (seq);
    
    return 0;
}
Exemple #22
0
int main()
{ /* program to find a trap-door prime */
    BOOL found;
    int i,spins;
    long seed;
    big pp[NPRIMES],q,p,t;
    FILE *fp;
    mirsys(50,0);
    for (i=0;i<NPRIMES;i++) pp[i]=mirvar(0);
    q=mirvar(0);
    t=mirvar(0);
    p=mirvar(0);
    printf("Enter 9 digit seed= ");
    scanf("%ld",&seed);
    getchar();
    irand(seed);
    printf("Enter 4 digit seed= ");
    scanf("%d",&spins);
    getchar();
    for (i=0;i<spins;i++) brand();
    convert(2,pp[0]);
    do
    {  /* find prime p = 2.pp[1].pp[2]....+1 */
        convert(2,p);
        for (i=1;i<NPRIMES-1;i++)
        { /* generate all but last prime */
            bigdig(i+6,10,q);
            nxprime(q,pp[i]);
            multiply(p,pp[i],p);
        }
        do
        { /* find last prime component such that p is prime */
            nxprime(q,q);
            copy(q,pp[NPRIMES-1]);
            multiply(p,pp[NPRIMES-1],t);
            incr(t,1,t);
        } while(!isprime(t));
        copy(t,p);
        found=TRUE;
        for (i=0;i<NPRIMES;i++)
        { /* check that PROOT is a primitive root */
            decr(p,1,q);
            divide(q,pp[i],q);
            powltr(PROOT,q,p,t);
            if (size(t)==1) 
            {
                found=FALSE;
                break;
            }
        }
    } while (!found);
    fp=fopen("prime.dat","wt");
    fprintf(fp,"%d\n",NPRIMES);
    for (i=0;i<NPRIMES;i++) cotnum(pp[i],fp);
    fclose(fp);
    printf("prime= \n");
    cotnum(p,stdout);
    return 0;
}
Exemple #23
0
void tex::append_choices ()
	{
	tail_append(new_choice());
	incr(save_ptr);
	saved(-1) = 0;
	scan_left_brace();
	push_math(MATH_CHOICE_GROUP);
	}
Exemple #24
0
int main(void) {
  int a;

  a = 1;
  a = incr(a);
  __SMACK_assert(a == 2);
  return a;
}
Exemple #25
0
//Enqueue (insert) an element into the circular queue
void Queue::enqueue(ElementTypePtr e) {
    
    if(incr(rear) == front) {
        return;
    }
    
    if(isEmpty()) {
        queue[front] = e;
        return;
    }
    
    rear = incr(rear);
    queue[rear] = e;

    return;
    
}
Exemple #26
0
 void incr(F&& f)
 {
   incr();
   if (blocked())
   {
     f(*this);
   }
 }
Exemple #27
0
/* sec 0598 */
void dvi_out_(ASCII_code op)
{
  dvi_buf[dvi_ptr] = op;
  incr(dvi_ptr);

  if (dvi_ptr == dvi_limit)
    dvi_swap();
}
Exemple #28
0
tex::glue_t::glue_t(glue_t *q)
	{
	tex::type(this) = GLUE_NODE;
	tex::subtype(this) = NORMAL;
	leader_ptr(this) = 0;
	glue_ptr(this) = q;
	incr(glue_ref_count(q));
	}
bool
doResolve(JSObject *obj, jsid id, uintN flags, JSObject **objp)
{
    CHECK_EQUAL(resolveExitCount, 0);
    AutoIncrCounters incr(this);
    CHECK_EQUAL(obj, obj1 || obj == obj2);
    
    CHECK(JSID_IS_STRING(id));
    
    JSFlatString *str = JS_FlattenString(cx, JSID_TO_STRING(id));
    CHECK(str);
    jsval v;
    if (JS_FlatStringEqualsAscii(str, "x")) {
        if (obj == obj1) {
            /* First resolve hook invocation. */
            CHECK_EQUAL(resolveEntryCount, 1);
            EVAL("obj2.y = true", &v);
            CHECK_SAME(v, JSVAL_TRUE);
            CHECK(JS_DefinePropertyById(cx, obj, id, JSVAL_FALSE, NULL, NULL, 0));
            *objp = obj;
            return true;
        }
        if (obj == obj2) {
            CHECK_EQUAL(resolveEntryCount, 4);
            *objp = NULL;
            return true;
        }
    } else if (JS_FlatStringEqualsAscii(str, "y")) {
        if (obj == obj2) {
            CHECK_EQUAL(resolveEntryCount, 2);
            CHECK(JS_DefinePropertyById(cx, obj, id, JSVAL_NULL, NULL, NULL, 0));
            EVAL("obj1.x", &v);
            CHECK(JSVAL_IS_VOID(v));
            EVAL("obj1.y", &v);
            CHECK_SAME(v, JSVAL_ZERO);
            *objp = obj;
            return true;
        }
        if (obj == obj1) {
            CHECK_EQUAL(resolveEntryCount, 3);
            EVAL("obj1.x", &v);
            CHECK(JSVAL_IS_VOID(v));
            EVAL("obj1.y", &v);
            CHECK(JSVAL_IS_VOID(v));
            EVAL("obj2.y", &v);
            CHECK(JSVAL_IS_NULL(v));
            EVAL("obj2.x", &v);
            CHECK(JSVAL_IS_VOID(v));
            EVAL("obj1.y = 0", &v);
            CHECK_SAME(v, JSVAL_ZERO);
            *objp = obj;
            return true;
        }
    }
    CHECK(false);
    return false;
}
Exemple #30
0
static void increment_wait_stats(ulonglong waited,int ret)
{
  uint i;
  if ((ret) == ETIMEDOUT)
    i= WT_WAIT_STATS;
  else
    for (i= 0; i < WT_WAIT_STATS && waited/10 > wt_wait_table[i]; i++) ;
  incr(wt_wait_stats[i], wait_stats_lock);
}