Example #1
0
void
GovConfig::load(void) {
    try {
        YAMLGen::Interpreter interpreter;
        interpreter.read(m_filename.toStdString().c_str());

        YAMLGen::Postprocessor postproc(interpreter.config());
        postproc.run();

        YAMLGen::OBLDC::ModuleConfigBuilder builder;
        builder.parse(postproc.config());

        m_modules     = builder.modules();
        m_target_name = QString::fromStdString(builder.target_name());

    } catch(YAMLGen::ParserException pe) {
        QMessageBox::critical( 0, "GovConf",
          QString("Syntax error in configuration:\n\n") + pe.what()
        );
    } catch(YAMLGen::InterpreterException ie) {
        QMessageBox::critical( 0, "GovConf",
          QString("Error in target configuration syntax:\n\n") + ie.what()
        );
    } catch(YAMLGen::ConfigException ce) {
        QMessageBox::critical( 0, "GovConf",
          QString("Error in target configuration:\n\n") + ce.what()
        );
    }
}
Example #2
0
void
npic(int start) {
	ndraw = start && (tlp || utf8);
	if (coords.root) {
		postproc(coords.root);
		free_node(coords.root);
		coords.root = NULL;
	}
}
Example #3
0
static int
fileproc(const char *filename)
{
	int fd;
	ssize_t len, l;
	u_char *p, *ep;
	struct sadb_msg *msg;
	u_char rbuf[1024 * 32];	/* XXX: Enough ? Should I do MSG_PEEK ? */

	fd = open(filename, O_RDONLY);
	if (fd < 0)
		return -1;

	l = 0;
	while (1) {
		len = read(fd, rbuf + l, sizeof(rbuf) - l);
		if (len < 0) {
			close(fd);
			return -1;
		} else if (len == 0)
			break;
		l += len;
	}

	if (l < sizeof(struct sadb_msg)) {
		close(fd);
		errno = EINVAL;
		return -1;
	}
	close(fd);

	p = rbuf;
	ep = rbuf + l;

	while (p < ep) {
		msg = (struct sadb_msg *)p;
		len = PFKEY_UNUNIT64(msg->sadb_msg_len);
		if (f_verbose) {
			kdebug_sadb((struct sadb_msg *)msg);
			printf("\n");
		}
		postproc(msg, len);
		p += len;
	}

	return 0;
}
Example #4
0
/* general syntax node traversing method */
void traverse(struct syntaxnode *node, int depth,
			void (*preproc)(struct syntaxnode *, int),
			void (*postproc)(struct syntaxnode *, int))
{
	int i;
	while (node) {
		/* itself: pre */
		preproc(node, depth);
		/* children */
		for (i = 0; node->child[i]; i++)
			traverse(node->child[i], depth + 1,
						preproc, postproc);
		/* itself: post */
		postproc(node, depth);
		/* next sibling */
		node = node->sibling;
	}
}
Example #5
0
sacnmul()

{  unsigned t, t1;
   int i,
       fst;		/* Index to first entry in current row 
  row is like @00xx, where 0 empty; x occupied; @ index to first, here 3 */
   unsigned orig_tag, /* Tag of address in smallest caches */
	    atag,	/* Tag removed from previous level */
	    tag,	/* Tag removed from previous entry in row */
	    depth,	/* Current level */
	    entry,	/* (arr_ptr + entry) points to current row */
	    set_no,	/* GBT number */
	    addr;	/* Current trace address */
   unsigned depths;	/* hitarr index */
   short hit;		/* Flag */
   unsigned *arr_ptr,	/* Pointer to top of current GBF */
	   *slot_ptr;	/* Pointer to current row */
   int hitarr0;		/* hitarr[0]; to avoid an array access */
   
   unsigned *buffer;	/* Input buffer */
   unsigned l, nr;		/* Ints related to buffer handling */

   hitarr0 = 0;
   
   while (nr = trace(&buffer)) {
     for (l = 0; l < nr; l++) {
     ++t_entries;
     if ((t_entries % P_INTERVAL) == 0)
       fprintf(stderr, "libcheetah: addresses processed %d\n", t_entries);

       addr = *(buffer + l);
       /*  while (fscanf(stdin, "%d", &addr) != EOF) { */
       /*	if ((t_entries % 10000) == 0)
		printf("t_entries  %d\n", t_entries); */
       addr >>= L;
       set_no = addr & SET_MASK;
       arr_ptr = arr + set_no * SIZE_OF_TREE;
       orig_tag = addr >> A;
#ifdef PERF
	++compares;
#endif
       if (*(arr_ptr + 1) == orig_tag)
	/* Hit at root */
         ++hitarr0;
       else {
         atag = orig_tag;
         depth = 0;
	 depths = 0;
	 hit = 0;
	 fst = 1;
	 slot_ptr = arr_ptr;
	 while (depth <= MAX_DEPTH) {
	    for (i=fst; i<=TWO_PWR_N; i++) {
#ifdef PERF
	    ++compares;
#endif
	      if ((t1 = *(slot_ptr + i)) == orig_tag) {
	/* Hit at a node below the root */
		 *(slot_ptr+i) = tag;
		 hit = 1;
		 break;
	      }
	      t = rm_arr[(orig_tag ^ t1) & DIFF_SET_MASK];
	      depths += base_pwr_array[t];
	      *(slot_ptr + i) = tag;
	      tag = t1;
	    }
	    ++*slot_ptr;
	    entry = (((ONE << depth) + (atag & ((ONE << depth) - 1))) - 1) * BASE;
	    slot_ptr = arr_ptr + entry;
	    --*slot_ptr;
	    slot_ptr[*slot_ptr] = atag;
	    if (hit==1) {
	       ++hitarr[depths];
	       break;
	    }
	    ++depth;
	    atag = tag;
	    entry = (((ONE << depth) + (orig_tag & ((ONE << depth) - 1))) - 1) * BASE;
	/* Skipping levels */
	    while ((depth <= MAX_DEPTH) && (*(arr_ptr + entry) > TWO_PWR_N)) {
		++depth;
	        entry = (((ONE << depth) + (orig_tag & ((ONE << depth) - 1))) - 1) * BASE;
	    }
	    if (depth <= MAX_DEPTH) {
	      slot_ptr = arr_ptr + entry;
	      fst = *slot_ptr;
	    }
	 }
       }
     }
     if (t_entries > T)
       break;
   }

   *hitarr = hitarr0;
   postproc();
}
Example #6
0
static void
postproc(struct bst_node *n) {
	if (n->left ) postproc(n->left );
	chkcoord(n->key.u64);
	if (n->right) postproc(n->right);
}
int Framework::run(size_t width, size_t height, const std::string& caption) {
    return ::run(width, height, caption, [=](GLFWwindow* window) {
        _window = window;

        std::vector<glm::dvec4> buffer;
        std::atomic<int> bufferWidth, bufferHeight;
        std::atomic<bool> trigger, done, quit;
        std::atomic<double> elapsed;
        std::mutex workerMutex;
        std::condition_variable workerCondition;
        std::condition_variable quitCondition;

        trigger = false;
        done = true;
        quit = false;
        elapsed = 0.0;

        auto worker = std::thread([&]() {
            while (!quit) {
                double start = haste::high_resolution_time();

                while (!trigger) {
                    std::unique_lock<std::mutex> lock(workerMutex);
                    workerCondition.wait(lock);
                }

                if (!quit) {
                    trigger = false;
                    render(bufferWidth, bufferHeight, buffer.data());
                    done = true;
                }

                elapsed = haste::high_resolution_time() - start;
            }

            quitCondition.notify_all();
        });

        loop(window, [&](int width, int height, float& scale, void* image) {
            scale = _scale;

            if (done) {
                if (bufferWidth == width && bufferHeight == height) {
                    postproc((glm::vec4*)image, buffer.data(), width, height);
                }
                else {
                    buffer.resize(width * height);
                    std::memset(buffer.data(), 0, buffer.size() * sizeof(buffer[0]));
                    bufferWidth = width;
                    bufferHeight = height;
                }

                trigger = true;
                if (updateScene()) {
                    std::memset(buffer.data(), 0, buffer.size() * sizeof(buffer[0]));
                }

                done = false;
                workerCondition.notify_all();
            }

            updateUI(width, height, (glm::vec4*)image, elapsed);

            std::this_thread::sleep_for(std::chrono::milliseconds(10));
        });

        quit = true;
        trigger = true;
        workerCondition.notify_all();

        std::unique_lock<std::mutex> lock(workerMutex);
        if (quitCondition.wait_for(lock, std::chrono::seconds(2)) != std::cv_status::timeout) {
            worker.join();
        }
    });

    _window = nullptr;

    return 0;
}
Example #8
0
int
sendkeymsg(char *buf, size_t len)
{
	u_char rbuf[1024 * 32];	/* XXX: Enough ? Should I do MSG_PEEK ? */
	ssize_t l;
	struct sadb_msg *msg;

	if (f_notreally) {
		goto end;
	}

    {
	struct timeval tv;
	tv.tv_sec = 1;
	tv.tv_usec = 0;
	if (setsockopt(so, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {
		perror("setsockopt");
		goto end;
	}
    }

	if (f_forever)
		shortdump_hdr();
again:
	if (f_verbose) {
		kdebug_sadb((struct sadb_msg *)buf);
		printf("\n");
	}
	if (f_hexdump) {
		int i;
		for (i = 0; i < len; i++) {
			if (i % 16 == 0)
				printf("%08x: ", i);
			printf("%02x ", buf[i] & 0xff);
			if (i % 16 == 15)
				printf("\n");
		}
		if (len % 16)
			printf("\n");
	}

	if ((l = send(so, buf, len, 0)) < 0) {
		perror("send");
		goto end;
	}

	msg = (struct sadb_msg *)rbuf;
	do {
		if ((l = recv(so, rbuf, sizeof(rbuf), 0)) < 0) {
			perror("recv");
			goto end;
		}

		if (PFKEY_UNUNIT64(msg->sadb_msg_len) != l) {
			warnx("invalid keymsg length");
			break;
		}

		if (f_verbose) {
			kdebug_sadb(msg);
			printf("\n");
		}
		if (postproc(msg, l) < 0)
			break;
	} while (msg->sadb_msg_errno || msg->sadb_msg_seq);

	if (f_forever) {
		fflush(stdout);
		sleep(1);
		goto again;
	}

end:
	return 0;
}