static void wrrd_after_unlink(const atf_tc_t *tc, const char *mp) { int value = 0x11; int v2; int fd; FSTEST_ENTER(); RL(fd = rump_sys_open("file", O_RDWR|O_CREAT, 0666)); RL(rump_sys_unlink("file")); RL(rump_sys_pwrite(fd, &value, sizeof(value), 654321)); /* * We can't easily invalidate the buffer since we hold a * reference, but try to get them to flush anyway. */ RL(rump_sys_fsync(fd)); RL(rump_sys_pread(fd, &v2, sizeof(v2), 654321)); rump_sys_close(fd); ATF_REQUIRE_EQ(value, v2); FSTEST_EXIT(); }
ATF_TC_BODY(bigenough, tc) { struct stat sb; RZ(system("rump_server " RUMPSERV)); RL(setenv("RUMP_SERVER", RUMPSERV, 1)); RL(dup2(0, 10)); RL(dup2(1, 11)); RL(dup2(2, 12)); RL(close(0)); RL(close(1)); RL(close(2)); RL(rumpclient_init()); RL(rump_sys_getpid()); ATF_REQUIRE_ERRNO(EBADF, fstat(0, &sb) == -1); ATF_REQUIRE_ERRNO(EBADF, fstat(1, &sb) == -1); ATF_REQUIRE_ERRNO(EBADF, fstat(2, &sb) == -1); RL(rump_sys_getpid()); /* restore these. does it help? */ dup2(10, 0); dup2(11, 1); dup2(12, 2); }
static zend_rsrc_list_entry *zend_list_id_to_entry(int id TSRMLS_DC) { if (id < RL().size()) { return RL().at(id); } else { return NULL; } }
static void holywrite(const atf_tc_t *tc, const char *mp) { char buf[1024]; char *b2, *b3; size_t therange = getpagesize()+1; int fd; FSTEST_ENTER(); RL(fd = rump_sys_open("file", O_RDWR|O_CREAT|O_TRUNC, 0666)); memset(buf, 'A', sizeof(buf)); RL(rump_sys_pwrite(fd, buf, 1, getpagesize())); memset(buf, 'B', sizeof(buf)); RL(rump_sys_pwrite(fd, buf, 2, getpagesize()-1)); REQUIRE_LIBC(b2 = malloc(2 * getpagesize()), NULL); REQUIRE_LIBC(b3 = malloc(2 * getpagesize()), NULL); RL(rump_sys_pread(fd, b2, therange, 0)); memset(b3, 0, therange); memset(b3 + getpagesize() - 1, 'B', 2); ATF_REQUIRE_EQ(memcmp(b2, b3, therange), 0); rump_sys_close(fd); FSTEST_EXIT(); }
ATF_TC_BODY(OOSIOCGIFBRDADDR, tc) { int fd, ifnum; struct oifreq ifreq; struct sockaddr_in *sin; int rv; memset(&ifreq,'\0',sizeof ifreq); rump_init(); /* create an interface and give it netmask 0xffff0000 */ rv = rump_pub_shmif_create("bus", &ifnum); if (rv) atf_tc_fail("failed to create shmif: %s", strerror(rv)); sprintf(ifreq.ifr_name, "shmif%d", ifnum); netcfg_rump_if(ifreq.ifr_name, "1.7.64.10", "255.255.0.0"); /* query kernel for iface bcast */ RL(fd = rump_sys_socket(AF_INET, SOCK_DGRAM, 0)); RL(rump_sys_ioctl(fd, OOSIOCGIFBRDADDR, &ifreq)); /* make sure we got what we deserve */ sin = (struct sockaddr_in *)&ifreq.ifr_broadaddr; ATF_REQUIRE_EQ(sin->sin_addr.s_addr, htonl(0x0107ffff)); rump_sys_close(fd); }
ATF_TC_BODY(proccreds, tc) { struct lwp *l1, *l2; rump_init(); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); l1 = rump_pub_lwproc_curlwp(); RZ(rump_pub_lwproc_newlwp(rump_sys_getpid())); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); l2 = rump_pub_lwproc_curlwp(); RL(rump_sys_setuid(22)); ATF_REQUIRE_EQ(rump_sys_getuid(), 22); rump_pub_lwproc_switch(l1); ATF_REQUIRE_EQ(rump_sys_getuid(), 0); /* from parent, proc0 */ RL(rump_sys_setuid(11)); ATF_REQUIRE_EQ(rump_sys_getuid(), 11); rump_pub_lwproc_switch(l2); ATF_REQUIRE_EQ(rump_sys_getuid(), 22); rump_pub_lwproc_newlwp(rump_sys_getpid()); ATF_REQUIRE_EQ(rump_sys_getuid(), 22); }
static void read_after_unlink(const atf_tc_t *tc, const char *mp) { char buf[TBSIZE], buf2[TBSIZE]; int fd; FSTEST_ENTER(); /* create file and put some content into it */ RL(fd = rump_sys_open("file", O_RDWR|O_CREAT, 0666)); memset(buf, 'D', TBSIZE); ATF_REQUIRE_EQ(rump_sys_write(fd, buf, TBSIZE), TBSIZE); rump_sys_close(fd); /* flush buffers from UBC to file system */ ATF_REQUIRE_ERRNO(EBUSY, rump_sys_unmount(mp, 0) == -1); RL(fd = rump_sys_open("file", O_RDWR)); RL(rump_sys_unlink("file")); ATF_REQUIRE_EQ(rump_sys_read(fd, buf2, TBSIZE), TBSIZE); ATF_REQUIRE_EQ(memcmp(buf, buf2, TBSIZE), 0); rump_sys_close(fd); FSTEST_EXIT(); }
ZEND_API int zend_list_insert(void *ptr, int type TSRMLS_DC) { zend_rsrc_list_entry* le = new zend_rsrc_list_entry(ptr, type); le->incRefCount(); RL().push_back(le); int id = RL().size() - 1; le->id = id; return id; }
static void child(bool master) { char ifname[IFNAMSIZ]; struct carpreq cr; struct ifreq ifr; const char *carpif; int s; /* helps reading carp debug output */ if (master) carpif = "carp0"; else carpif = "carp1"; /* * Should use sysctl, bug debug is dabug. */ { //extern int rumpns_carp_opts[]; /* XXX */ //rumpns_carp_opts[CARPCTL_LOG] = 1; } rump_init(); memset(&ifr, 0, sizeof(ifr)); strlcpy(ifr.ifr_name, carpif, sizeof(ifr.ifr_name)); RL(s = rump_sys_socket(PF_INET, SOCK_DGRAM, 0)); RL(rump_sys_ioctl(s, SIOCIFCREATE, &ifr)); netcfg_rump_makeshmif(THEBUS, ifname); if (master) netcfg_rump_if(ifname, "10.1.1.1", "255.255.255.0"); else netcfg_rump_if(ifname, "10.1.1.2", "255.255.255.0"); /* configure the carp interface */ ifr.ifr_data = &cr; RL(rump_sys_ioctl(s, SIOCGVH, &ifr)); strlcpy(cr.carpr_carpdev, ifname, sizeof(cr.carpr_carpdev)); cr.carpr_vhid = 175; if (master) cr.carpr_advskew = 0; else cr.carpr_advskew = 200; cr.carpr_advbase = 1; strcpy((char *)cr.carpr_key, "s3cret"); RL(rump_sys_ioctl(s, SIOCSVH, &ifr)); netcfg_rump_if(carpif, "10.1.1.100", "255.255.255.0"); /* tassa pause()en enka muuta voi */ pause(); }
static void symlink_root(const atf_tc_t *tc, const char *mp) { USES_SYMLINKS; RL(rump_sys_chdir(mp)); RL(rump_sys_symlink("/", "foo")); RL(rump_sys_chdir("foo")); }
static void symlink_zerolen(const atf_tc_t *tc, const char *mp) { USES_SYMLINKS; RL(rump_sys_chdir(mp)); RL(rump_sys_symlink("", "afile")); RL(rump_sys_chdir("/")); }
static void shrinkfile(const atf_tc_t *tc, const char *mp) { int fd; FSTEST_ENTER(); RL(fd = rump_sys_open("file", O_RDWR|O_CREAT|O_TRUNC, 0666)); RL(rump_sys_ftruncate(fd, 2)); RL(rump_sys_ftruncate(fd, 1)); rump_sys_close(fd); FSTEST_EXIT(); }
ATF_TC_BODY(pipe1, tc) { struct kevent event[1]; int fds[2]; int kq, n; RL(pipe(fds)); RL(kq = kqueue()); RL(close(fds[0])); EV_SET(&event[0], fds[1], EVFILT_WRITE, EV_ADD|EV_ENABLE, 0, 0, 0); ATF_REQUIRE_EQ_MSG((n = kevent(kq, event, 1, NULL, 0, NULL)), -1, "got: %d", n); ATF_REQUIRE_EQ_MSG(errno, EBADF, "got: %s", strerror(errno)); }
void InitCPU(void) /* 68K state when powered on */ { ssp=*sp=RL(&theROM[0]); SetPC(RL(&theROM[1])); if(V3)printf("initial PC=%x SP=%x\n",(void*)pc-(void*)theROM,ssp); iMask=7; supervisor=true; trace=doTrace=false; exception=0; extraFlag=false; pendingInterrupt=0; stopped=false; badCodeAddress=false; }
static void read_fault(const atf_tc_t *tc, const char *mp) { char ch = 123; int fd; FSTEST_ENTER(); RL(fd = rump_sys_open("file", O_CREAT | O_RDWR, 0777)); ATF_REQUIRE_EQ(rump_sys_write(fd, &ch, 1), 1); RL(rump_sys_close(fd)); RL(fd = rump_sys_open("file", O_RDONLY | O_SYNC | O_RSYNC)); ATF_REQUIRE_ERRNO(EFAULT, rump_sys_read(fd, NULL, 1) == -1); RL(rump_sys_close(fd)); FSTEST_EXIT(); }
void GEMENI_charsent() { unsigned long r = s->log[s->lc]; if (UCA0IFG & UCTXIFG) { s->nch++; switch (s->nch) { case 1: UCA0TXBUF = SL(r) << 5 |TL(r)<<4|KL(r)<<3|PL(r)<<2|WL(r)<<1|HL(r); break; case 2: UCA0TXBUF = RL(r)<<6 | AL(r)<<5 | OL(r)<<4 | STAR(r)<<3; break; case 3: UCA0TXBUF = ER(r)<<3 | UR(r)<<2 | FR(r)<<1 | RR(r); break; case 4: UCA0TXBUF = PR(r)<<6 | BR(r)<<5 | LR(r)<<4 | GR(r)<<3 | TR(r)<<2 | SR(r)<<1 | DRS(r); break; case 5: UCA0TXBUF = POUND(r)<<1 | ZRS(r); break; default: s->lc++; if (s->lc != s->nc-1) { s->nch = 0; UCA0TXBUF = 1 << 7; // first packet, no fn or '#' } else { s->flags &= ~CSEND; } } } }
ATF_TC_BODY(makecn, tc) { struct componentname *cn; char pathstr[MAXPATHLEN] = TESTFILE; struct vnode *vp; extern struct vnode *rumpns_rootvnode; rump_init(); /* * Strategy is to create a componentname, edit the passed * string, and then do a lookup with the componentname. */ RL(rump_sys_mkdir("/" TESTFILE, 0777)); /* need stable lwp for componentname */ RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); /* try it once with the right path */ cn = rump_pub_makecn(RUMP_NAMEI_LOOKUP, 0, pathstr, strlen(pathstr), rump_pub_cred_create(0, 0, 0, NULL), rump_pub_lwproc_curlwp()); RZ(RUMP_VOP_LOOKUP(rumpns_rootvnode, &vp, cn)); rump_pub_freecn(cn, RUMPCN_FREECRED); /* and then with modification-in-the-middle */ cn = rump_pub_makecn(RUMP_NAMEI_LOOKUP, 0, pathstr, strlen(pathstr), rump_pub_cred_create(0, 0, 0, NULL), rump_pub_lwproc_curlwp()); strcpy(pathstr, "/muuta"); RZ(RUMP_VOP_LOOKUP(rumpns_rootvnode, &vp, cn)); rump_pub_freecn(cn, RUMPCN_FREECRED); }
void REGP1 SetPCX(int i) { #ifdef BACKTRACE Ptr p=pc; #endif pc=(uw16*)((Ptr)theROM+(RL(&theROM[i])&ADDR_MASK)); #ifdef TRACE CheckTrace(); #ifdef BACKTRACE AddBackTrace(p,-i); #endif #endif if(((char)(int)pc&1)!=0) { exception=3; extraFlag=true; nInst2=nInst; nInst=0; readOrWrite=16; badAddress=(Ptr)pc-(Ptr)theROM; badCodeAddress=true; } }
ATF_TC_BODY(lwps, tc) { struct lwp *l[LOOPS]; pid_t mypid; struct lwp *l_orig; int i; rump_init(); RZ(rump_pub_lwproc_rfork(RUMP_RFCFDG)); mypid = rump_sys_getpid(); RL(rump_sys_setuid(375)); l_orig = rump_pub_lwproc_curlwp(); for (i = 0; i < LOOPS; i++) { mypid = rump_sys_getpid(); ATF_REQUIRE(mypid != -1 && mypid != 0); RZ(rump_pub_lwproc_newlwp(mypid)); l[i] = rump_pub_lwproc_curlwp(); ATF_REQUIRE_EQ(rump_sys_getuid(), 375); } rump_pub_lwproc_switch(l_orig); rump_pub_lwproc_releaselwp(); for (i = 0; i < LOOPS; i++) { rump_pub_lwproc_switch(l[i]); ATF_REQUIRE_EQ(rump_sys_getpid(), mypid); ATF_REQUIRE_EQ(rump_sys_getuid(), 375); rump_pub_lwproc_releaselwp(); ATF_REQUIRE_EQ(rump_sys_getpid(), 1); ATF_REQUIRE_EQ(rump_sys_getuid(), 0); } ATF_REQUIRE_EQ(rump_pub_lwproc_newlwp(mypid), ESRCH); }
avltree insert(avltree root,Elemtype data) { if(!root) { root=(pnode)malloc(sizeof(node)); root->data=data; root->left=root->right=0; root->height=0; } else if(data < root->data) //插到左边 { root->left=insert(root->left,data); if(HEIGHT(root->left)-HEIGHT(root->right)==2) //失去平衡 { if(data < root->left->data) root=LL(root); else root=LR(root); } } else if(data >root->data) //插到右边 { root->right=insert(root->right,data); if(HEIGHT(root->right)-HEIGHT(root->left)==2) //失去平衡 { if(data > root->right->data) root=RR(root); else root=RL(root); } } //data在树中已存在时什么事也不做 root->height=MAX(HEIGHT(root->left),HEIGHT(root->right))+1; return root; }
node *insertNode(node *root, int cont){ if(root==NULL){ return createNode(cont); } else if(cont>root->data) { root->right=insertNode(root->right,cont); if(BF(root)==-2){ if(cont>root->right->data) root=RR(root); else root=RL(root); } } else if(cont<root->data) { root->left=insertNode(root->left,cont); if(BF(root)==2){ if(cont < root->left->data) root=LL(root); else root=LR(root); } } /*else{ if(cont==root->data) printf("the node %d already exists in the tree",cont); return root; }*/ root->ht=height(root); return(root); }
node * insert(node *T,int x) { if(T==NULL) { T=(node*)malloc(sizeof(node)); T->data=x; T->left=NULL; T->right=NULL; } else if(x > T->data) // insert in right subtree { T->right=insert(T->right,x); if(BF(T)==-2) if(x>T->right->data) T=RR(T); else T=RL(T); } else if(x<T->data) { T->left=insert(T->left,x); if(BF(T)==2) if(x < T->left->data) T=LL(T); else T=LR(T); } T->ht=height(T); return(T); }
/* Insert sessid and socket pair in AVL Tree */ AVLTree_Node* insertion(AVLTree_Node *T,uint16_t x, struct node *head) { if(T==NULL) { T=(AVLTree_Node*)malloc(sizeof(AVLTree_Node)); T->data=x; T->head = head; T->left=NULL; T->right=NULL; } else if(x > T->data) // insert in right subtree { T->right=insertion(T->right,x,head); if(BF(T)==-2) if(x>T->right->data) T=RR(T); else T=RL(T); } else if(x<T->data) { T->left=insertion(T->left,x,head); if(BF(T)==2) if(x < T->left->data) T=LL(T); else T=LR(T); } T->ht=height(T); //root=T; return(T); }
std::vector<int> min_for_window(std::vector<int> arr, int w){ int size = arr.size(); int n_windows = size - w+1; std::vector<int> LR(size); std::vector<int> RL(size); std::vector<int> res(n_windows); for(int i = 0; i < size; ++i){ // filling out LR if(!(i % w)){ LR[i] = arr[i]; } else{ LR[i] = std::min(LR[i-1], arr[i]); } } std::cout << "Printing Left-Right array: " << std::endl; print_vector(LR); for(int i = size-1; i >= 0; --i){ // filling out RL if(i == size-1 || i % w == w-1){ RL[i] = arr[i]; } else{ RL[i] = std::min(RL[i+1], arr[i]); } } std::cout << "Printing Right-Left array: " << std::endl; print_vector(RL); for(int i = 0; i < n_windows; ++i){ // filling out result array res[i] = std::min(RL[i], LR[i+w-1]); } return res; }
ATF_TC_BODY(file, tc) { char buffer[128]; struct kevent event[1]; pid_t pid; int fd, kq, n, num, status; RL(pid = fork()); if (pid == 0) { child(); /* NOTREACHED */ } RL(fd = open(FILENAME, O_RDONLY|O_CREAT, 0644)); #if 1 /* XXX: why was this disabled? */ RL(lseek(fd, 0, SEEK_END)); #endif RL(kq = kqueue()); EV_SET(&event[0], fd, EVFILT_READ, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); for (num = 0; num < NLINES;) { RL(n = kevent(kq, NULL, 0, event, 1, NULL)); num += n; (void)printf("kevent num %d flags: %#x, fflags: %#x, data: " #ifdef __FreeBSD__ "%" PRIdPTR "\n", n, event[0].flags, event[0].fflags, #else "%" PRId64 "\n", n, event[0].flags, event[0].fflags, #endif event[0].data); if (event[0].data < 0) #if 1 /* XXXLUKEM */ RL(lseek(fd, 0, SEEK_END)); #else RL(lseek(fd, event[0].data, SEEK_END)); #endif RL(n = read(fd, buffer, 128)); buffer[n] = '\0'; (void)printf("file(%d): %s", num, buffer); } (void)waitpid(pid, &status, 0); (void)printf("read: successful end\n"); }
ATF_TC_BODY(pipe3, tc) { struct kevent event[1]; int fds[2]; int kq; RL(pipe(fds)); RL(kq = kqueue()); EV_SET(&event[0], fds[1], EVFILT_WRITE, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); /* close 'read' end first, then 'write' */ RL(close(fds[0])); RL(close(fds[1])); }
ATF_TC_BODY(clock_gettime_real, tc) { char name[128], cbuf[512], ctrbuf[10240]; size_t cbufsiz = sizeof(cbuf); size_t ctrbufsiz = sizeof(ctrbuf); const char *p; char *save; int quality, n; if (sysctlbyname(TC_HARDWARE, cbuf, &cbufsiz, NULL, 0) != 0) { (void)printf("\nChecking legacy time implementation " "for %d seconds\n", TIMEOUT); check_timecounter(); return; /* NOTREACHED */ } (void)printf("%s = %s\n", TC_HARDWARE, cbuf); REQUIRE_LIBC(save = strdup(cbuf), NULL); RL(sysctlbyname(TC_CHOICE, ctrbuf, &ctrbufsiz, NULL, 0)); (void)printf("%s = %s\n", TC_CHOICE, ctrbuf); for (p = ctrbuf, n = 0; sscanf(p, "%127[^(](q=%d, f=%*u Hz)%*[ ]%n", name, &quality, &n) == 2; p += n) { struct timespec ts; int ret; if (quality < 0) continue; (void)printf("\nChecking %s for %d seconds\n", name, TIMEOUT); CHECK_LIBC(ret = sysctlbyname(TC_HARDWARE, NULL, 0, name, strlen(name)), -1); if (ret == -1) continue; /* wait a bit to select new counter in clockinterrupt */ ts.tv_sec = 0; ts.tv_nsec = 100000000; (void)nanosleep(&ts, NULL); check_timecounter(); } RL(sysctlbyname(TC_HARDWARE, NULL, 0, save, strlen(save))); }
ATF_TC_BODY(pipe2, tc) { struct kevent event[1]; char buffer[128]; int fds[2]; int kq, n; int status; pid_t child; RL(pipe(fds)); RL(kq = kqueue()); EV_SET(&event[0], fds[1], EVFILT_WRITE, EV_ADD|EV_ENABLE, 0, 0, 0); RL(kevent(kq, event, 1, NULL, 0, NULL)); /* spawn child reader */ RL(child = fork()); if (child == 0) { int sz = read(fds[0], buffer, 128); if (sz > 0) (void)printf("pipe: child read '%.*s'\n", sz, buffer); exit(sz <= 0); } RL(n = kevent(kq, NULL, 0, event, 1, NULL)); (void)printf("kevent num %d flags: %#x, fflags: %#x, data: " "%" PRId64 "\n", n, event[0].flags, event[0].fflags, event[0].data); RL(n = write(fds[1], "foo", 3)); RL(close(fds[1])); (void)waitpid(child, &status, 0); }
static Node NodeDelete(Node rootnode , Node delnode){ if (delnode == NULL || rootnode == NULL){ return NULL; } //node in the left if (delnode -> data < rootnode -> data){ rootnode -> left = NodeDelete(rootnode -> left , delnode); //lose balance if (Height(rootnode -> right) == Height(rootnode -> right) + 2){ Node right = rootnode -> right; if (Height(right -> left) > Height(right -> right)){ rootnode = RL(rootnode); }else{ rootnode = RR(rootnode); } } } //node in the right if (delnode -> data > rootnode -> data){ rootnode -> right = NodeDelete(rootnode -> right , delnode); //lose balance if (Height(rootnode -> left) == Height(rootnode -> right) + 2){ Node left = rootnode -> left; if (Height(left -> right) > Height(left -> left)){ rootnode = LR(rootnode); }else{ rootnode = LL(rootnode); } } } //delnode is rootnode if (delnode -> data == rootnode -> data){ if ((rootnode -> left != NULL) && (rootnode -> right != NULL)){ //left is lager than right if (Height(rootnode -> left) > Height(rootnode -> right)){ Node max = FindMax(rootnode -> left); rootnode -> data = max -> data; rootnode -> left = NodeDelete(rootnode -> left , max); }else{ //right is lager than left Node min = FindMin(rootnode -> right); rootnode -> data = min -> data; rootnode -> right = NodeDelete(rootnode -> right , min); } }else{ //left || right in null Node tmp = rootnode; if (rootnode -> left != NULL){ rootnode = rootnode -> left; }else{ rootnode = rootnode -> right; } free(tmp); } } return rootnode; }
void CSharpTabCodeGen::LOCATE_TRANS() { out << " _keys = " << KO() + "[" + vCS() + "]" << ";\n" " _trans = " << CAST(transType) << IO() << "[" << vCS() << "];\n" "\n" " _klen = " << SL() << "[" << vCS() << "];\n" " if ( _klen > 0 ) {\n" " " << signedKeysType << " _lower = _keys;\n" " " << signedKeysType << " _mid;\n" " " << signedKeysType << " _upper = " << CAST(signedKeysType) << " (_keys + _klen - 1);\n" " while (true) {\n" " if ( _upper < _lower )\n" " break;\n" "\n" " _mid = " << CAST(signedKeysType) << " (_lower + ((_upper-_lower) >> 1));\n" " if ( " << GET_WIDE_KEY() << " < " << K() << "[_mid] )\n" " _upper = " << CAST(signedKeysType) << " (_mid - 1);\n" " else if ( " << GET_WIDE_KEY() << " > " << K() << "[_mid] )\n" " _lower = " << CAST(signedKeysType) << " (_mid + 1);\n" " else {\n" " _trans += " << CAST(transType) << " (_mid - _keys);\n" " goto _match;\n" " }\n" " }\n" " _keys += " << CAST(keysType) << " _klen;\n" " _trans += " << CAST(transType) << " _klen;\n" " }\n" "\n" " _klen = " << RL() << "[" << vCS() << "];\n" " if ( _klen > 0 ) {\n" " " << signedKeysType << " _lower = _keys;\n" " " << signedKeysType << " _mid;\n" " " << signedKeysType << " _upper = " << CAST(signedKeysType) << " (_keys + (_klen<<1) - 2);\n" " while (true) {\n" " if ( _upper < _lower )\n" " break;\n" "\n" " _mid = " << CAST(signedKeysType) << " (_lower + (((_upper-_lower) >> 1) & ~1));\n" " if ( " << GET_WIDE_KEY() << " < " << K() << "[_mid] )\n" " _upper = " << CAST(signedKeysType) << " (_mid - 2);\n" " else if ( " << GET_WIDE_KEY() << " > " << K() << "[_mid+1] )\n" " _lower = " << CAST(signedKeysType) << " (_mid + 2);\n" " else {\n" " _trans += " << CAST(transType) << "((_mid - _keys)>>1);\n" " goto _match;\n" " }\n" " }\n" " _trans += " << CAST(transType) << " _klen;\n" " }\n" "\n"; }