static char * id_to_name(int id) { int offset; static struct prentry pre; char *name; name = check_core(id); if (name) return (name); offset = ntohl(prh.idHash[IDHash(id)]); while (offset) { lseek(dbase_fd, offset + HDRSIZE, L_SET); if (read(dbase_fd, &pre, sizeof(struct prentry)) < 0) { fprintf(stderr, "pt_util: read i/o error: %s\n", strerror(errno)); exit(1); } pre.id = ntohl(pre.id); if (pre.id == id) { name = checkin(&pre); return (name); } offset = ntohl(pre.nextID); } return 0; }
bool checker::check(expr * n, bool is_true) { bool r; if (n->get_ref_count() > 1 && m_is_true_cache[is_true].find(n, r)) return r; r = check_core(n, is_true); if (n->get_ref_count() > 1) m_is_true_cache[is_true].insert(n, r); return r; }
int main(void) { struct io_pollfd ifd; struct io_pollfd *rfds; unsigned long len; char buf[4]; check_core(); init_core(&iop); test_assert(io_poll_size(&iop) == 0); verify(&iop); test_assert(pipe(pfd) != -1); test_assert(nonblock(pfd[1]) != -1); test_assert(nonblock(pfd[0]) != -1); /* test for readability */ ifd.events = IO_POLL_READ; ifd.fd = pfd[0]; test_assert(io_poll_add(&iop, &ifd) == 1); /* pipe gets readability */ test_assert(write(pfd[1], "AAAA", 4) == 4); test_assert(io_poll_wait(&iop, 0) == 1); io_poll_rfds(&iop, &rfds, &len); test_assert(len == 1); test_assert(rfds[0].fd == ifd.fd); test_assert(io_poll_got_read(&rfds[0]) == 1); test_assert(read(rfds[0].fd, buf, 4) == 4); test_assert(bin_same(buf, "AAAA", 4) == 1); /* send EOF */ test_assert(close(pfd[1]) != -1); test_assert(io_poll_wait(&iop, 0) == 1); io_poll_rfds(&iop, &rfds, &len); test_assert(len == 1); test_assert(rfds[0].fd == ifd.fd); test_assert(read(rfds[0].fd, buf, 4) == 0 || io_poll_got_eof(&rfds[0]) == 1); test_assert(io_poll_rm(&iop, &ifd) == 1); test_assert(close(pfd[0]) != -1); test_assert(io_poll_free(&iop)); return 0; }