Example #1
0
static void dup_level(int levToInsert, int val) {
	int n;
    for (n = 2; n < bddnodesize; n++) {
    	int lev, lo, hi, newLev;
        int n_low, n_high;
        int hash, r, r2, NEXT_r;
        if (LOW(n) == INVALID_BDD) continue;
        lev = LEVEL(n);
        if (lev != levToInsert || lev == bddvarnum-1) {
            continue;
        }
        lo = LOW(n);
        hi = HIGH(n);
        bdd_addref(n);
        n_low = bdd_makenode(levToInsert+1, val<=0 ? lo : 0, val<=0 ? 0 : lo);
        n_high = bdd_makenode(levToInsert+1, val==0 ? hi : 0, val==0 ? 0 : hi);
        bdd_delref(n);
        newLev = lev;
        SETLOW(n, n_low);
        SETHIGH(n, n_high);
        hash = NODEHASH(lev, lo, hi);
        r = HASH(hash);
        r2 = 0;
        while (r != n && r != 0) {
            r2 = r;
            r = NEXT(r);
        }
        NEXT_r = NEXT(r);
        if (r2 == 0) {
            SETHASH(hash, NEXT_r);
        } else {
            SETNEXT(r2, NEXT_r);
        }
        SETLEVEL(n, newLev);
        lo = LOW(n); hi = HIGH(n);
        hash = NODEHASH(newLev, lo, hi);
        r = HASH(hash);
        SETHASH(hash, n);
        SETNEXT(n, r);
    }
}
Example #2
0
/*
NAME   {* bdd\_init *}
SECTION {* kernel *}
SHORT  {* initializes the BDD package *}
PROTO  {* int bdd_init(int nodesize, int cachesize) *}
DESCR  {* This function initiates the bdd package and {\em must} be called
          before any bdd operations are done. The argument {\tt nodesize}
	  is the initial number of nodes in the nodetable and {\tt cachesize}
	  is the fixed size of the internal caches. Typical values for
	  {\tt nodesize} are 10000 nodes for small test examples and up to
	  1000000 nodes for large examples. A cache size of 10000 seems to
	  work good even for large examples, but lesser values should do it
	  for smaller examples.

	  The number of cache entries can also be set to depend on the size
	  of the nodetable using a call to {\tt bdd\_setcacheratio}.
	  
	  The initial number of nodes is not critical for any bdd operation
	  as the table will be resized whenever there are to few nodes left
	  after a garbage collection. But it does have some impact on the
	  efficency of the operations. *}
RETURN {* If no errors occur then 0 is returned, otherwise
          a negative error code. *}
ALSO   {* bdd\_done, bdd\_resize\_hook *}
*/
int bdd_init(int initnodesize, int cs)
{
   /* Check to see if tracing is enabled */
   char * str;
   if( (str = getenv("BUDDY_TRACE_FILE")) != NULL) {
     trace_enable = 1;
     trace_init(str);
   }

   {
     int n, err;
     BUDDY_PROLOGUE;
     ADD_ARG1(T_INT,initnodesize);
     ADD_ARG1(T_INT,cs);
     
     srand48( SRAND48SEED ) ;
     
     if (bddrunning)
       RETURN(bdd_error(BDD_RUNNING));
     
     bddnodesize = bdd_prime_gte(initnodesize);
     
     if ((MAX_ALLOC_NODES == 0) ||
	 (alloced=(BddNode*)malloc(sizeof(BddNode)*MAX_ALLOC_NODES)) == NULL) {
       if ((alloced=(BddNode*)malloc(sizeof(BddNode)*bddnodesize)) == NULL) {
	 RETURN(bdd_error(BDD_MEMORY));
       }
       MAX_ALLOC_NODES = bddnodesize;
     }
     bddnodes = alloced;
     
     bddresized = 0;
     
     for (n=0 ; n<bddnodesize ; n++) {
       INIT_NODE(n);
     }
     SETNEXT(bddnodesize-1, 0);
     
     SETMAXREF(0);
     SETMAXREF(1);
     SETLOW(0,0); SETHIGH(0,0);
     SETLOW(1,1); SETHIGH(1,1);
     
     if ((err=bdd_operator_init(cs)) < 0) {
       bdd_done();
       RETURN(err);
     }
     
     bddfreepos = 2;
     bddfreenum = bddnodesize-2;
     bddrunning = 1;
     bddvarnum = 0;
     gbcollectnum = 0;
     gbcclock = 0;
     cachesize = cs;
     usednodes_nextreorder = bddnodesize;
     bddmaxnodeincrease = DEFAULTMAXNODEINC;
     bddincreasefactor = 2;
     
     bdderrorcond = 0;
     
     bddcachestats.uniqueAccess = 0;
     bddcachestats.uniqueChain = 0;
     bddcachestats.uniqueHit = 0;
     bddcachestats.uniqueMiss = 0;
     bddcachestats.opHit = 0;
     bddcachestats.opMiss = 0;
     bddcachestats.swapCount = 0;
     
     bdd_gbc_hook(bdd_default_gbchandler);
     bdd_error_hook(bdd_default_errhandler);
     bdd_resize_hook(NULL);
     bdd_pairs_init();
     bdd_reorder_init();
     bdd_fdd_init();
     
     if (setjmp(bddexception) != 0)
       assert(0);
     
     RETURN(0);
   }
}
Example #3
0
int emumouse_main(int argc, char *argv[])
{
  struct vm86_regs regs;
  int i, value;

  if (argc == 1)
    return usage();

  switch (argv[1][0]) {
    case '?':
    case 'H':
    case 'h':
      return usage();
      break;
    default:
      break;
  }


  if (!detectInternalMouse()) return 1;

  i = 1;

  while (i < argc)
  {
    switch(argv[i][0]) {

      case 'A':
      case 'a':
	printf("Fixed speed settings.\n");
	SETLOW(&regs.ecx, 0x0001);
	SETWORD(&regs.ebx, 0x0006);
	mouse_helper(&regs);
	break;

      case 'B':
      case 'b':
	printf("Variable speed settings.\n");
	SETLOW(&regs.ecx, 0x0000);
	SETWORD(&regs.ebx, 0x0006);
	mouse_helper(&regs);
	break;

      case 'R':
      case 'r':
	printf("Resetting iret.\n");
	SETWORD(&regs.ebx, 0x0000);
	mouse_helper(&regs);
	break;

      case 'I':
      case 'i':
	printf("\nCurrent mouse setting:\n");
	SETWORD(&regs.ebx, 0x0003);
	mouse_helper(&regs);
	if (HIGH(regs.ebx) == 0x10)
	  printf("  2 button mouse mode (Microsoft)\n");
	else
	  printf("  3 button mouse mode (e.g. Mousesystems, PS2)\n");
	printf  ("  Horizontal Speed (X) - %ld\n", LOW(regs.ecx));
	printf  ("  Vertical Speed   (Y) - %ld\n", HIGH(regs.ecx));
	printf  ("  Speed Setting        - %s\n\n", LOW(regs.edx) ? "fixed" : "variable");
	SETWORD(&regs.ebx, 0x0007);
	mouse_helper(&regs);
	if (WORD(regs.eax) == 0) {
	  printf  ("  Minimum Internal Horizontal Resolution - %ld\n", WORD(regs.ecx));
          printf  ("  Minimum Internal Vertical Resolution   - %ld\n", WORD(regs.edx));
	}
	break;

      case '3':
	printf("Selecting 3 button mouse mode (e.g. Mousesystems, PS2).\n");
	SETWORD(&regs.ebx, 0x0002);
	mouse_helper(&regs);
	if (LOW(regs.eax) == 0xff) {
	  printf("ERROR! Cannot select 3 button mouse mode, \"emulate3buttons\" not set\n");
	  printf("       in /etc/dosemu.conf, try e.g.\n");
	  printf("       'mouse { ps2 device /dev/mouse internaldriver emulate3buttons }'\n");
	  return (1);
	}
	break;

      case '2':
	printf("Selecting 2 button mouse mode (Microsoft).\n");
	SETWORD(&regs.ebx, 0x0001);
	mouse_helper(&regs);
	break;

      case 'Y':
      case 'y':
	i++;
	if (i == argc) {
	  printf("ERROR! No value for \"y\" found.\n");
	  return(1);
	}
	value = atoi(argv[i]);
	printf("Selecting vertical speed to %d.\n", value);
	SETWORD(&regs.ebx, 0x0004);
	SETLOW(&regs.ecx, value);
	mouse_helper(&regs);
	if (WORD(regs.eax) == 1) {
	  printf("ERROR! Selected speed is out of range. Unable to set speed.\n");
	  return(1);
	}
	break;

      case 'X':
      case 'x':
	i++;
	if (i == argc) {
	  printf("ERROR! No value for \"x\" found.\n");
	  return(1);
	}
	value = atoi(argv[i]);
	printf("Selecting horizontal speed to %d.\n", value);
	SETWORD(&regs.ebx, 0x0005);
	SETLOW(&regs.ecx, value);
	mouse_helper(&regs);
	if (WORD(regs.eax) == 1) {
	  printf("ERROR! Selected speed is out of range. Unable to set speed.\n");
	  return(1);
	}
	break;

      case 'M':
      case 'm':
        switch (argv[i][1]) {
	case 'X':
	case 'x':
	  i++;
	  if (i == argc) {
	    printf("ERROR! No value for \"Mx\" found.\n");
	    return(1);
	  }
	  value = atoi(argv[i]);
	  printf("Selecting minimum horizontal resolution to %d.\n", value);
	  SETWORD(&regs.ebx, 0x0007);
	  mouse_helper(&regs);
	  if (WORD(regs.eax) == 1) {
	    printf("ERROR! Setting minimum horizontal resolution not supported.\n");
	    break;
	  }
	  SETWORD(&regs.ebx, 0x0008);
	  SETWORD(&regs.ecx, value);
	  mouse_helper(&regs);
	  if (WORD(regs.eax) == 1) {
	    printf("ERROR! Setting minimum horizontal resolution not supported.\n");
	    break;
	  }
	  break;

	case 'Y':
	case 'y':
	  i++;
	  if (i == argc) {
	    printf("ERROR! No value for \"My\" found.\n");
	    return(1);
	  }
	  value = atoi(argv[i]);
	  printf("Selecting minimum vertical resolution to %d.\n", value);
	  SETWORD(&regs.ebx, 0x0007);
	  mouse_helper(&regs);
	  if (WORD(regs.eax) == 1) {
	    printf("ERROR! Setting minimum vertical resolution not supported.\n");
	    break;
	  }
	  SETWORD(&regs.ebx, 0x0008);
	  SETWORD(&regs.edx, value);
	  mouse_helper(&regs);
	  if (WORD(regs.eax) == 1) {
	    printf("ERROR! Setting minimum vertical resolution not supported.\n");
	    break;
	  }
	  break;

	default:
          printf("ERROR! Unknown option \"%s\".\n\n", argv[i]);
	  return usage();
	  /* never reached */
	  break;
	}
	break;

      default:
	printf("ERROR! Unknown option \"%s\".\n\n", argv[i]);
	return usage();
	/* never reached */
	break;

    } /* switch */
    i++;
  } /* while */
  return (0);
}
Example #4
0
/*
 * Initialize the vnode associated with a new inode, handle aliased
 * vnodes.
 */
int
ufs_vinit(struct mount *mntp, struct vops *specops, struct vops *fifoops,
    struct vnode **vpp)
{
	struct inode *ip;
	struct vnode *vp, *nvp;
	struct timeval mtv;

	vp = *vpp;
	ip = VTOI(vp);
	switch(vp->v_type = IFTOVT(DIP(ip, mode))) {
	case VCHR:
	case VBLK:
		vp->v_op = specops;
		if ((nvp = checkalias(vp, DIP(ip, rdev), mntp)) != NULL) {
			/*
			 * Discard unneeded vnode, but save its inode.
			 * Note that the lock is carried over in the inode
			 * to the replacement vnode.
			 */
			nvp->v_data = vp->v_data;
			vp->v_data = NULL;
			vp->v_op = &spec_vops;
#ifdef VFSLCKDEBUG
			vp->v_flag &= ~VLOCKSWORK;
#endif
			vrele(vp);
			vgone(vp);
			/*
			 * Reinitialize aliased inode.
			 */
			vp = nvp;
			ip->i_vnode = vp;
		}
		break;
	case VFIFO:
#ifdef FIFO
		vp->v_op = fifoops;
		break;
#else
		return (EOPNOTSUPP);
#endif
	case VNON:
	case VBAD:
	case VSOCK:
	case VLNK:
	case VDIR:
	case VREG:
		break;
	}
	if (ip->i_number == ROOTINO)
                vp->v_flag |= VROOT;
	/*
	 * Initialize modrev times
	 */
	getmicrouptime(&mtv);
	SETHIGH(ip->i_modrev, mtv.tv_sec);
	SETLOW(ip->i_modrev, mtv.tv_usec * 4294);
	*vpp = vp;
	return (0);
}