/* extract a =HHHxWWW size from the input stream */ static int linkysize(MMIOT *f, int *heightp, int *widthp) { int height=0, width=0; int c; *heightp = 0; *widthp = 0; if ( (c = eatspace(f)) != '=' ) return (c != EOF); pull(f); /* eat '=' */ for ( c = pull(f); isdigit(c); c = pull(f)) width = (width * 10) + (c - '0'); if ( c == 'x' ) { for ( c = pull(f); isdigit(c); c = pull(f)) height = (height*10) + (c - '0'); if ( c != EOF ) { if ( !isspace(c) ) shift(f, -1); *heightp = height; *widthp = width; return 1; } } return 0; }
/* * process embedded links and images */ static int linkylinky(int image, MMIOT *f) { int start = mmiottell(f); Cstring name; Footnote key, *ref; int status = 0; CREATE(name); memset(&key, 0, sizeof key); if ( linkylabel(f, &name) ) { if ( peek(f,1) == '(' ) { pull(f); if ( linkyurl(f, image, &key) ) status = linkyformat(f, name, image, &key); } else { int goodlink, implicit_mark = mmiottell(f); if ( isspace(peek(f,1)) ) pull(f); if ( peek(f,1) == '[' ) { pull(f); /* consume leading '[' */ goodlink = linkylabel(f, &key.tag); } else { /* new markdown implicit name syntax doesn't * require a second [] */ mmiotseek(f, implicit_mark); goodlink = !(f->flags & MKD_1_COMPAT); } if ( goodlink ) { if ( !S(key.tag) ) { DELETE(key.tag); T(key.tag) = T(name); S(key.tag) = S(name); } if ( ref = bsearch(&key, T(*f->footnotes), S(*f->footnotes), sizeof key, (stfu)__mkd_footsort) ) status = linkyformat(f, name, image, ref); else if ( f->flags & IS_LABEL ) status = linkyformat(f, name, image, &imaget); } } } DELETE(name); ___mkd_freefootnote(&key); if ( status == 0 ) mmiotseek(f, start); return status; }
/* extract a =HHHxWWW size from the input stream */ static int linkysize(MMIOT *f, Footnote *ref) { int height=0, width=0; int whence = mmiottell(f); int c; if ( isspace(peek(f,0)) ) { pull(f); /* eat '=' */ for ( c = pull(f); isdigit(c); c = pull(f)) width = (width * 10) + (c - '0'); if ( c == 'x' ) { for ( c = pull(f); isdigit(c); c = pull(f)) height = (height*10) + (c - '0'); if ( isspace(c) ) c = eatspace(f); if ( (c == ')') || ((c == '\'' || c == '"') && linkytitle(f, c, ref)) ) { ref->height = height; ref->width = width; return 1; } } } mmiotseek(f, whence); return 0; }
/* extract a )-terminated title from the input stream. */ static char* linkytitle(MMIOT *f, int *sizep) { int countq=0, qc, c, size; char *ret, *lastqc = 0; eatspace(f); if ( (qc=pull(f)) != '"' && qc != '\'' && qc != '(' ) return 0; if ( qc == '(' ) qc = ')'; for ( ret = cursor(f); (c = pull(f)) != EOF; ) { if ( (c == ')') && countq ) { size = (lastqc ? lastqc : cursor(f)) - ret; *sizep = size-1; return ret; } else if ( c == qc ) { lastqc = cursor(f); countq++; } } return 0; }
static unsigned long ExecIO_Write_From_Queue ( PLL pll) /* Pointer to file linked list item */ { /* Local function variables */ char * Item; /* Item pulled from the queue */ long items; /* process request */ if (ExecIO_Options.lRcdCnt == 0) { return 0; } /* start at the proper place in the queue */ while (ExecIO_Options.lStartRcd > 1 && queued() > 0) { Item = pull(); if (Item != NULL) { RexxFreeMemory(Item); } ExecIO_Options.lStartRcd--; } if (ExecIO_Options.lRcdCnt == -1) { /* process an "*" record count */ items = queued(); while (items > 0) { Item = pull(); if (Item != NULL) { fputs(Item, pll -> pFile); fputs("\n", pll -> pFile); RexxFreeMemory(Item); } else { goto return_point; } items--; } } else { /* process a specific record count */ while (ExecIO_Options.lRcdCnt > 0) { if (queued() == 0) break; Item = pull(); if (Item != NULL) { fputs(Item, pll -> pFile); fputs("\n", pll -> pFile); RexxFreeMemory(Item); } else { goto return_point; } ExecIO_Options.lRcdCnt--; } } return_point: fflush (pll -> pFile); /* return with successful return code */ return 0; }
static void test_add_message (CamelFolder *folder, gint j) { CamelMimeMessage *msg; gchar *content; gchar *subject; GError *error = NULL; push ("creating message %d\n", j); msg = test_message_create_simple (); content = g_strdup_printf ("Test message %08x contents\n\n", j); test_message_set_content_simple ( (CamelMimePart *) msg, 0, "text/plain", content, strlen (content)); test_free (content); subject = g_strdup_printf ("Test message %08x subject", j); camel_mime_message_set_subject (msg, subject); pull (); push ("appending simple message %d", j); camel_folder_append_message_sync ( folder, msg, NULL, NULL, NULL, &error); check_msg (error == NULL, "%s", error->message); g_clear_error (&error); pull (); check_unref (msg, 1); }
/* extract a (-prefixed url from the input stream. * the label is either of the format `<link>`, where I * extract until I find a >, or it is of the format * `text`, where I extract until I reach a ')' or * whitespace. */ static char* linkyurl(MMIOT *f, int *sizep) { int size = 0; char *ptr; int c; if ( (c = eatspace(f)) == EOF ) return 0; ptr = cursor(f); if ( c == '<' ) { pull(f); ptr++; if ( (size = parenthetical('<', '>', f)) == EOF ) return 0; } else { for ( ; ((c=pull(f)) != ')') && !isspace(c); size++) if ( c == EOF ) return 0; if ( c == ')' ) shift(f, -1); } *sizep = size; return ptr; }
MetadataList CreateASTMetadataHLSL(TIntermNode *root, const CallDAG &callDag) { MetadataList metadataList(callDag.size()); // Compute all the information related to when gradient operations are used. // We want to know for each function and control flow operation if they have // a gradient operation in their call graph (shortened to "using a gradient" // in the rest of the file). // // This computation is logically split in three steps: // 1 - For each function compute if it uses a gradient in its body, ignoring // calls to other user-defined functions. // 2 - For each function determine if it uses a gradient in its call graph, // using the result of step 1 and the CallDAG to know its callees. // 3 - For each control flow statement of each function, check if it uses a // gradient in the function's body, or if it calls a user-defined function that // uses a gradient. // // We take advantage of the call graph being a DAG and instead compute 1, 2 and 3 // for leaves first, then going down the tree. This is correct because 1 doesn't // depend on other functions, and 2 and 3 depend only on callees. for (size_t i = 0; i < callDag.size(); i++) { PullGradient pull(&metadataList, i, callDag); pull.traverse(callDag.getRecordFromIndex(i).node); } // Compute which loops are discontinuous and which function are called in // these loops. The same way computing gradient usage is a "pull" process, // computing "bing used in a discont. loop" is a push process. However we also // need to know what ifs have a discontinuous loop inside so we do the same type // of callgraph analysis as for the gradient. // First compute which loops are discontinuous (no specific order) and pull // the ifs and functions using a discontinuous loop. for (size_t i = 0; i < callDag.size(); i++) { PullComputeDiscontinuousLoops pull(&metadataList, i, callDag); pull.traverse(callDag.getRecordFromIndex(i).node); } // Then push the information to callees, either from the a local discontinuous // loop or from the caller being called in a discontinuous loop already for (size_t i = callDag.size(); i-- > 0;) { PushDiscontinuousLoops push(&metadataList, i, callDag); push.traverse(callDag.getRecordFromIndex(i).node); } // We create "Lod0" version of functions with the gradient operations replaced // by non-gradient operations so that the D3D compiler is happier with discont // loops. for (auto &metadata : metadataList) { metadata.mNeedsLod0 = metadata.mCalledInDiscontinuousLoop && metadata.mUsesGradient; } return metadataList; }
/* check message not present */ void test_folder_not_message (CamelFolder *folder, const gchar *uid) { CamelMimeMessage *msg; CamelMessageInfo *info; GPtrArray *s; gint i; gint found; GError *error = NULL; push ("uid '%s' is not in folder", uid); /* first try getting info */ push ("no message info"); info = camel_folder_get_message_info (folder, uid); check (info == NULL); pull (); /* then, getting message */ push ("no message"); msg = camel_folder_get_message_sync (folder, uid, NULL, &error); check (error != NULL); check (msg == NULL); g_clear_error (&error); pull (); /* see if it is not in the summary (only once) */ push ("not in summary list"); s = camel_folder_get_summary (folder); check (s != NULL); found = 0; for (i = 0; i < s->len; i++) { info = s->pdata[i]; if (strcmp (camel_message_info_get_uid (info), uid) == 0) found++; } check (found == 0); camel_folder_free_summary (folder, s); pull (); /* check it is not in the uid list */ push ("not in uid list"); s = camel_folder_get_uids (folder); check (s != NULL); found = 0; for (i = 0; i < s->len; i++) { if (strcmp (s->pdata[i], uid) == 0) found++; } check (found == 0); camel_folder_free_uids (folder, s); pull (); g_clear_error (&error); pull (); }
void macro9(){ int n_toys=10000; int n_tot_entries=100; int n_bins=40; cout << "Performing Pull Experiment with chi2 \n"; pull(n_toys,n_tot_entries,n_bins,true); cout << "Performing Pull Experiment with Log Likelihood\n"; pull(n_toys,n_tot_entries,n_bins,false); }
static void retr(void) { UINT8 i=pull(); R.PC.w.l = ((i & 0x0f) << 8) | pull(); /*change_pc(R.PC.w.l);*/ R.irq_executing = I8039_IGNORE_INT; // R.A11 = R.A11ff; /* NS990113 */ R.PSW = (R.PSW & 0x0f) | (i & 0xf0); /* Stack is already changed by pull */ regPTR = ((M_By) ? 24 : 0); }
/* Виртуальная машина */ int do_command(unsigned char cop) { double op1, op2; //операнды char name[SIZENAME]; switch(cop) { case CNOP: break; case CPUSH: push(get_value()); break; case CIN: fscanf(vmin, "%lf", &op1); push(op1); break; case COUT: fprintf(vmout, "%g", pull()); break; case CNVAR: get_name(name); add_var(name); break; case CGVAR: get_name(name); push(get_var(name)); break; case CSVAR: get_name(name); set_var(name, pull()); break; case CADD: push(pull()+pull()); break; case CSUB: op1 = pull(); op2 = pull(); push(op2-op1); break; case CMULT: push(pull()*pull()); break; case CDIV: op1 = pull(); op2 = pull(); if (op1==0.0) cerror("divide by zero"); push(op2/op1); break; case CHALT: return 0; default: cerror("undefined command"); } return 1; }
inline void DoRestoreFrame(VM32Cpu * cpu) { unsigned int returnVal; cpu->pc++; // Get the return value returnVal = pull(cpu); cpu->sp = cpu->fp; // Restore the sp cpu->fp = pull(cpu); // Restore the fp from there push(cpu, returnVal); // Now put the returnVal in preparation for a return }
bool SimpleDeadlockDetector::moveBackwards(BoardState& s, int index) { bool moved = false; if (pull(MOVE_LEFT, s, index)) moved = true; if (pull(MOVE_RIGHT, s, index)) moved = true; if (pull(MOVE_UP, s, index)) moved = true; if (pull(MOVE_DOWN, s, index)) moved = true; return moved; }
void PartShop::pull<ComponentDefinition>(std::string uri, Document& doc, bool recursive) { pull(uri, doc); ComponentDefinition& cd = doc.get<ComponentDefinition>(uri); if (recursive) { pull(cd.sequences.get(), doc); for (auto & c : cd.components) pull(c.definition.get(), doc); } };
void split(Treap *t, int k, Treap *&a, Treap *&b) { if(!t) a = b = NULL; else if(t->val <= k){ a = t; split(t->r, k, a->r, b); pull(a); } else{ b = t; split(t->l, k, a, b->l); pull(b); } }
Treap *merge(Treap *a, Treap *b) { if(!a || !b) return a ? a : b; if(a->pri > b->pri){ a->r = merge(a->r, b); pull(a); return a; } else{ b->l = merge(a, b->l); pull(b); return b; } }
void split( Treap *t , int k , Treap*&a , Treap*&b ){ if( !t ){ a = b = NULL; return; } push( t ); if( Size( t->l ) + 1 <= k ){ a = t; split( t->r , k - Size( t->l ) - 1 , a->r , b ); pull( a ); }else{ b = t; split( t->l , k , a , b->l ); pull( b ); } }
void FArc::writetojbmp(ImageType *j,int cx,int cy,float scale,ColourType c) { #ifdef DEBUG printf("arc rad %f scale %f\n",r,scale); #endif bool first=true; V2d o,i; if (ab<aa) ab+=2*pi; // for (float a=aa-0.001;a<=ab+0.001;a+=diff(ab,aa)/16.1) { //int sps=32*moddiff(ab,aa,2*pi)/pi; int sps=16.0*diff(ab,aa)/pi; for (int k=0;k<=sps;k++) { float a=pull(aa,(float)k/(float)sps,ab); V2d no=V2d(cx,cy)+scale*V2d(x+(r+w/2.0)*sin(a),-y-(r+w/2.0)*cos(a)); V2d ni=V2d(cx,cy)+scale*V2d(x+(r-w/2.0)*sin(a),-y-(r-w/2.0)*cos(a)); if (first) first=false; else { j->intertri(o,i,ni,c,c,c); j->intertri(o,ni,no,c,c,c); //j->fillquad(o,i,ni,no,c); } if (k==0 || k==sps) j->filledcircle((no+ni)/2.0,w/2.0,c); o=no; i=ni; } }
static int handle(struct device *dv) { signed short pcm[FRAME * DEVICE_CHANNELS]; int samples; struct oss *oss = (struct oss*)dv->local; /* Check input buffer for recording */ if (oss->pe->revents & POLLIN) { samples = pull(oss->fd, pcm, FRAME); if (samples == -1) return -1; device_submit(dv, pcm, samples); } /* Check the output buffer for playback */ if (oss->pe->revents & POLLOUT) { device_collect(dv, pcm, FRAME); samples = push(oss->fd, pcm, FRAME); if (samples == -1) return -1; } return 0; }
void runInfoThread(zmq::context_t& c, const json& settings) { int linger = 0; int timeout = 500; zmq::socket_t pull(c, ZMQ_PULL); zmq::socket_t pub(c, ZMQ_PUB); pull.setsockopt(ZMQ_LINGER, &linger, sizeof(int)); pub.setsockopt(ZMQ_LINGER, &linger, sizeof(int)); pull.setsockopt(ZMQ_RCVTIMEO, &timeout, sizeof(int)); pull.bind("inproc://infologger"); pub.bind("tcp://*:" + std::to_string(int(settings["infoSocket"]["port"]))); while (!interruptedBySignal) { std::vector<std::string> msg; bool newMsg = receive(pull, msg); if (newMsg) { LOG(INFO) << msg; send(pub, msg); } } pull.close(); pub.close(); }
bool match_pattern(type_checker & tc, expr const & pattern, declaration const & d, unsigned max_steps, bool cheap) { name_generator ngen = tc.mk_ngen(); buffer<level> ls; unsigned num_ls = d.get_num_univ_params(); for (unsigned i = 0; i < num_ls; i++) ls.push_back(mk_meta_univ(ngen.next())); expr dt = instantiate_type_univ_params(d, to_list(ls.begin(), ls.end())); unsigned num_e = get_expect_num_args(tc, pattern); unsigned num_d = get_expect_num_args(tc, dt); if (num_e > num_d) return false; for (unsigned i = 0; i < num_d - num_e; i++) { dt = tc.whnf(dt).first; expr local = mk_local(ngen.next(), binding_domain(dt)); dt = instantiate(binding_body(dt), local); } try { unifier_config cfg; cfg.m_max_steps = max_steps; cfg.m_kind = cheap ? unifier_kind::Cheap : unifier_kind::Liberal; cfg.m_ignore_context_check = true; auto r = unify(tc.env(), pattern, dt, tc.mk_ngen(), substitution(), cfg); return static_cast<bool>(r.pull()); } catch (exception&) { return false; } }
void GLidle(void) { VMSetupCall(Cpu, (uint32) GLidleObj, (uint32) GLidleMethod); VMRun(Cpu, 1); // Remove the returned result pull(Cpu); }
void GLdisplay(void) { VMSetupCall(Cpu, (uint32) GLdispObj, (uint32) GLdispMethod); VMRun(Cpu, 1); // Remove the returned result pull(Cpu); }
void user_choice_manager::process(events::pump_info&) { if(waiting()) { pull(); } }
void writetojbmp(RGBmp *j,int cx,int cy,float scale,myRGB c) { bool first=true; V2d o,i; if (ab<aa) ab+=2*pi; // for (float a=aa-0.001;a<=ab+0.001;a+=diff(ab,aa)/16.1) { //int sps=32*moddiff(ab,aa,2*pi)/pi; int sps=16.0*diff(ab,aa)/pi; for (int k=0;k<=sps;k++) { float a=pull(aa,(float)k/(float)sps,ab); V2d no=V2d(cx,cy)+scale*V2d(x+(r+w/2.0)*sin(a),-y-(r+w/2.0)*cos(a)); V2d ni=V2d(cx,cy)+scale*V2d(x+(r-w/2.0)*sin(a),-y-(r-w/2.0)*cos(a)); if (first) first=false; else { j->intertri(o,i,ni,c,c,c); j->intertri(o,ni,no,c,c,c); //j->fillquad(o,i,ni,no,c); } if (k==0 || k==sps) j->filledcircle((no+ni)/2.0,w/2.0,c); o=no; i=ni; } }
optional<expr> mk_class_instance(environment const & env, io_state const & ios, local_context const & ctx, name const & prefix, expr const & type, bool relax_opaque, bool use_local_instances, unifier_config const & cfg) { auto C = std::make_shared<class_instance_context>(env, ios, prefix, relax_opaque, use_local_instances); if (!is_ext_class(C->tc(), type)) return none_expr(); expr meta = ctx.mk_meta(C->m_ngen, some_expr(type), type.get_tag()); unsigned depth = 0; constraint c = mk_class_instance_cnstr(C, ctx, meta, depth); unifier_config new_cfg(cfg); new_cfg.m_discard = true; new_cfg.m_use_exceptions = true; new_cfg.m_pattern = true; new_cfg.m_kind = C->m_conservative ? unifier_kind::VeryConservative : unifier_kind::Liberal; try { auto seq = unify(env, 1, &c, C->m_ngen.mk_child(), substitution(), new_cfg); while (true) { auto p = seq.pull(); lean_assert(p); substitution s = p->first.first; expr r = s.instantiate_all(meta); if (!has_expr_metavar_relaxed(r)) return some_expr(r); seq = p->second; } } catch (exception &) { return none_expr(); } }
void GLkeyboard(unsigned char key, int x, int y) { Proto tmp; Proto pArray[3]; char tmpStr[2]; GCOFF(); tmpStr[0] = key; tmpStr[1] = 0; tmp = (Proto) stringToAtom(tmpStr); pArray[0] = tmp; tmp = objectNewInteger(x); pArray[1] = tmp; tmp = objectNewInteger(y); pArray[2] = tmp; VMSetupCallWithArgs(Cpu, (uint32) GLkeybObj, (uint32) GLkeybMethod, 3, (unsigned int *) pArray); VMRun(Cpu, 1); // Remove the returned result pull(Cpu); GCON(); }
/* Encoding is <blockhdr> <varint-num-txs> <tx>... */ struct bitcoin_block *bitcoin_block_from_hex(const tal_t *ctx, const char *hex, size_t hexlen) { struct bitcoin_block *b; u8 *linear_tx; const u8 *p; size_t len, i, num; if (hexlen && hex[hexlen-1] == '\n') hexlen--; /* Set up the block for success. */ b = tal(ctx, struct bitcoin_block); /* De-hex the array. */ len = hex_data_size(hexlen); p = linear_tx = tal_arr(ctx, u8, len); if (!hex_decode(hex, hexlen, linear_tx, len)) return tal_free(b); pull(&p, &len, &b->hdr, sizeof(b->hdr)); num = pull_varint(&p, &len); b->tx = tal_arr(b, struct bitcoin_tx *, num); for (i = 0; i < num; i++) b->tx[i] = pull_bitcoin_tx(b->tx, &p, &len); /* We should end up not overrunning, nor have extra */ if (!p || len) return tal_free(b); tal_free(linear_tx); return b; }
void AsyncCallExecutorImpl::run() { while (!do_stop) { AsyncCall* pending_call = pull(); if (pending_call == NULL) { SSLOG_DEBUG(_T("thread [") << GetCurrentThreadId() << _T("] is sleep.")); ::WaitForSingleObject(this->evtNotEmpty, INFINITE); SSLOG_DEBUG(_T("thread [") << GetCurrentThreadId() << _T("] wake up.")); continue; } SSLOG_DEBUG(_T("starting call: ") << pending_call->get_index()); try { pending_call->call(); } catch(...) { SSLOG_ERROR(_T("exception happened in async call thread [") << GetCurrentThreadId() << _T("].")); } SSLOG_DEBUG(_T("finished call: ") << pending_call->get_index()); pending_call->dispose(); } // 通知其他阻塞的同伴退出 ::SetEvent(this->evtNotEmpty); SSLOG_DEBUG(_T("thread [") << GetCurrentThreadId() << _T("] is exited.")); }