Exemplo n.º 1
0
static inline int remove_space_profiling (word *from, word *to)
{
  byte *p = (byte*) from;
  register byte *q = (byte*) to;
  register int replace_cmp = 0, replace_call = 0;

  for( ; p < q ; ) { 
    if (p[0] == CMP_BYTE_1 &&
	((p[1] & CMP_BYTE_2_MASK) == CMP_BYTE_2_TEST) &&
	p[2] == PROF_CMP_BYTE_3) {
      replace_cmp++;
      p[2] = CMP_BYTE_3;
    } else if (p[0] == CALL_BYTE_1 &&
	       p[1] == CALL_BYTE_2 &&
	       p[2] == PROF_CALL_BYTE_3) {
      replace_call++;
      p[2] = CALL_BYTE_3;
    }
    if (!read_instr(&p))
      error("Code replacement from 0x%08x to 0x%08x "
	    "found unreadable code at 0x%08x", from, to, p);
  }
  if (replace_cmp != replace_call)
    error("Code replacement from 0x%08x to 0x%08x found %d/%d mismatch",
	  from, to, replace_cmp, replace_call);

  return replace_cmp;
}
Exemplo n.º 2
0
void Model::init()
      {
      read_instr ();
      read_presets ();

      // init audio
      Divis* D = _divis;
      for (int d = 0; d < _ndivis; d++, D++) {
            M_new_divis* M = new M_new_divis ();
            M->_flags = D->_flags;
            M->_dmask = D->_dmask;
            M->_asect = D->_asect;
            M->_swell = D->_param [Divis::SWELL].fval();
            M->_tfreq = D->_param [Divis::TFREQ].fval();
            M->_tmodd = D->_param [Divis::TMODD].fval();
            _aeolus->newDivis(M);
            }

      init_iface();
      init_ranks(MT_LOAD_RANK);
      init_ranks(MT_SAVE_RANK);
      }
Exemplo n.º 3
0
void
main(int argc, char** argv)
{
  if (argc < 3)
    notif_error("Missing argument(s)\n");

  mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH;
  if ((entry = open(argv[1], O_RDONLY)) == -1)
    notif_error("Cannot open entry file");
  if ((outfile = open(argv[2], O_WRONLY | O_TRUNC | O_CREAT, mode)) == -1)
    notif_error("Cannot open output file");

  ln = 1;
  store_line();

  while (1) {
    read_instr();
    inter_instr();
  }

  close(entry);
  close(outfile);
}
Exemplo n.º 4
0
PCFState * load_pcf_file(const char * fname, void * key0, void * key1, void *(*copy_key)(void*))
{
  FILE * input;
  PCFState * ret;
  char line[LINE_MAX];
  uint32_t icount = 0;
  uint32_t i = 0;

  ret = (PCFState*)malloc(sizeof(struct PCFState));
  check_alloc(ret);

  ret->alice_outputs = 0;
  ret->bob_outputs = 0;
  ret->inp_i = 0;
  ret->constant_keys[0] = copy_key(key0);
  ret->constant_keys[1] = copy_key(key1);
  ret->copy_key = copy_key;
  ret->call_stack = 0;
  ret->done = 0;
  ret->labels = (struct hsearch_data *)malloc(sizeof(struct hsearch_data));
  check_alloc(ret->labels);

  ret->wires = (struct wire *)malloc(1000000 * sizeof(struct wire));
  check_alloc(ret->wires);

  for(i = 0; i < 200000; i++)
    {
      ret->wires[i].flags = KNOWN_WIRE;
      ret->wires[i].value = 0;
      ret->wires[i].keydata = copy_key(key0);
    }

  memset(ret->labels, 0, sizeof(struct hsearch_data));

  ret->done = 0;
  ret->base = 1;
  ret->PC = 0;

  fprintf(stderr, "%s\n", fname);
  input = fopen(fname, "r");
  if(input == 0)
    {
      fprintf(stderr, "%s: %s\n", fname, strerror(errno));
      assert(0);
    }

  while(!feof(input))
    {
      fgets(line, LINE_MAX-1, input);
      icount++;
    }

  if(hcreate_r(icount, ret->labels) == 0)
    {
      fprintf(stderr, "Unable to allocate hash table: %s\n", strerror(errno));
      abort();
      //      exit(-1);
    }

  ret->icount = icount;
  ret->ops = (PCFOP*)malloc(icount * sizeof(PCFOP));
  check_alloc(ret->ops);

  assert(fseek(input, 0, SEEK_SET) == 0);

  icount = 0;

  while(!feof(input))
    {
      PCFOP * op;
      fgets(line, LINE_MAX-1, input);
      op = read_instr(ret, line, icount);
      ret->ops[icount] = *op;
      free(op);
      icount++;
    }

  fclose(input);

  ret->wires[0].value = 1;
  ret->wires[0].keydata = ret->copy_key(ret->constant_keys[1]);
  ret->wires[0].flags = KNOWN_WIRE;

  return ret;
}