/* ** open parts that may cause memory-allocation errors */ static void f_luaopen (lua_State *L, void *ud) { global_State *g = G(L); UNUSED(ud); stack_init(L, L); /* init stack */ sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ sethvalue(L, registryuser1(L), luaH_new(L, 0, 2)); /* registry for user custom purposes */ sethvalue(L, registryuser2(L), luaH_new(L, 0, 2)); /* registry for user custom purposes */ sethvalue(L, registryuser3(L), luaH_new(L, 0, 2)); /* registry for user custom purposes */ luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ luaT_init(L); luaX_init(L); luaS_fix(luaS_newliteral(L, MEMERRMSG)); g->GCthreshold = 4*g->totalbytes; }
static void preinit_state (lua_State *L, global_State *g) { G(L) = g; L->stack = NULL; L->stacksize = 0; L->errorJmp = NULL; L->hook = NULL; L->hookmask = 0; L->basehookcount = 0; L->allowhook = 1; resethookcount(L); L->openupval = NULL; L->size_ci = 0; L->nCcalls = L->baseCcalls = 0; L->status = 0; L->base_ci = L->ci = NULL; L->savedpc = NULL; L->errfunc = 0; #if LUA_REFCOUNT L->ref = 0; setnilvalue2n(L, gt(L)); #else setnilvalue(gt(L)); #endif /* LUA_REFCOUNT */ }
static void traversestack (global_State *g, lua_State *l) { StkId o, lim; CallInfo *ci; markvalue(g, gt(l)); lim = l->top; for (ci = l->base_ci; ci <= l->ci; ci++) { lua_assert(ci->top <= l->stack_last); if (lim < ci->top) lim = ci->top; } for (o = l->stack; o < l->top; o++) markvalue(g, o); for (; o <= lim; o++) setnilvalue(o); checkstacksizes(l, lim); }
static inline A0_n acos(const A0_n a0_n) { const A0 a0 = { a0_n }; A0 x = nt2::abs(a0); A0 z2 = {asin(a0)}; bA0 isgtxh = gt(x, Half<A0>()); if (nt2::any(isgtxh)) { const A0 as = {asin(sqrt(oneminus(x)*Half<A0>()))}; const A0 z1 = as*Two<A0>(); z2 = select(isgtxh, z1, z2); } z2 = select(lt(a0, -Half<A0>()), Pi<A0>()-z2, z2); return select(isgtxh, z2, Pio_2<A0>()-z2); }
int split_get_file(split_info_t *s, u32 lba, u32 *sec_count, int fill) { int fd; if (lba >= s->total_sec) { fprintf(stderr, "SPLIT: invalid sector %u / %u\n", lba, (u32)s->total_sec); return -1; } int idx; idx = lba / s->split_sec; if (idx >= s->max_split) { fprintf(stderr, "SPLIT: invalid split %d / %d\n", idx, s->max_split - 1); return -1; } fd = s->fd[idx]; if (fd<0) { // opening new, make sure all previous are full int i; for (i=0; i<idx; i++) { if (split_fill(s, i, s->split_size)) { printf(gt("FILL %d"), i); printf("\n"); } } fd = split_open_file(s, idx); } if (fd<0) { fprintf(stderr, "SPLIT %d: no file\n", idx); return -1; } u32 sec = lba % s->split_sec; // inside file off64_t off = (off64_t)sec * 512; // num sectors till end of file u32 to_end = s->split_sec - sec; if (*sec_count > to_end) *sec_count = to_end; if (s->create_mode) { if (fill) { // extend, so that read will be succesfull split_fill(s, idx, off + 512 * (*sec_count)); } else { // fill up so that write continues from end of file // shouldn't be necessary, but libfat looks buggy // and this is faster split_fill(s, idx, off); } } lseek(fd, off, SEEK_SET); return fd; }
Term &YAPListTerm::operator[](arity_t i) { BACKUP_MACHINE_REGS(); Term t0 = gt(); Term tf = 0; while (IsPairTerm(t0)) { if (i == 0) { tf = HeadOfTerm(t0); break; } else { t0 = TailOfTerm(t0); i--; } } RECOVER_MACHINE_REGS(); return RepPair(tf)[i]; }
static void preinit_state (lua_State *L) { L->stack = NULL; L->stacksize = 0; L->errorJmp = NULL; L->hook = NULL; L->hookmask = L->hookinit = 0; L->basehookcount = 0; L->allowhook = 1; resethookcount(L); L->openupval = NULL; L->size_ci = 0; L->nCcalls = 0; L->base_ci = L->ci = NULL; L->errfunc = 0; setnilvalue(gt(L)); }
static void test_maximize(opt::model_based_opt& mbo, ast_manager& m, unsigned num_vars, expr_ref_vector const& fmls, app* t) { qe::arith_project_plugin plugin(m); model mdl(m); arith_util a(m); for (unsigned i = 0; i < num_vars; ++i) { app_ref var(m); mk_var(i, var); rational val = mbo.get_value(i); mdl.register_decl(var->get_decl(), a.mk_numeral(val, false)); } expr_ref ge(m), gt(m); opt::inf_eps value1 = plugin.maximize(fmls, mdl, t, ge, gt); opt::inf_eps value2 = mbo.maximize(); std::cout << "optimal: " << value1 << " " << value2 << "\n"; mbo.display(std::cout); }
/* mark root set */ static void markroot (lua_State *L) { global_State *g = G(L); g->gray = NULL; g->grayagain = NULL; g->weak = NULL; markobject(g, g->mainthread); /* make global table be traversed before main stack */ markvalue(g, gt(g->mainthread)); markvalue(g, registry(L)); markmt(g); #if LUAPLUS_EXTENSIONS if (G(L)->userGCFunction) G(L)->userGCFunction(L); #endif /* LUAPLUS_EXTENSIONS */ g->gcstate = GCSpropagate; }
void* bset::_larger_member(const void* x, bsetnode* rt) { if ( gt(x, rt -> v_element) == true ) { if ( rt -> v_right ) return _larger_member(x, rt -> v_right); else return 0; } if ( (*f_cmp_func_eq)(x, rt -> v_element) == true || rt -> v_left == 0 ) return rt -> v_element; return _larger_member(x, rt -> v_left); }
static void vma_close(struct vm_area_struct *vma){ unsigned long len=0; if(likely(vma->vm_private_data)){ len=((unsigned long*)vma->vm_private_data)[0]; if(likely(len)){ memset(vma->vm_private_data, 0, len*sizeof(unsigned long)); } kfree(vma->vm_private_data); } gt(printk("<0>" "Closing vma: %lx , with pd: %lx, len: %lx\n", (unsigned long)vma, (unsigned long)vma->vm_private_data, len)); return; }
interface uniformize_interface(interface inter) { interface result; result.len=inter.len; result.points=(double complex*)malloc(inter.len*sizeof(double complex)); memcpy(result.points, inter.points, inter.len*sizeof(double complex)); long i,j; for (i=0; i<result.len; i++) for (j=i+1;j<result.len;j++) result.points[j]=gt(result.points[i],result.points[j]); /* res.points[j]=creal(res.points[i])+ sqrt_upper((res.points[j]-creal(res.points[i]))*(res.points[j]-creal(res.points[i]))+ cimag(res.points[i])*cimag(res.points[i])); */ return result; }
TEST(ExpressionAlgoIsSubsetOf, Compare_NaN) { ParsedMatchExpression nan("{x: NaN}"); ParsedMatchExpression lt("{x: {$lt: 5}}"); ParsedMatchExpression lte("{x: {$lte: 5}}"); ParsedMatchExpression gte("{x: {$gte: 5}}"); ParsedMatchExpression gt("{x: {$gt: 5}}"); ASSERT_TRUE(expression::isSubsetOf(nan.get(), nan.get())); ASSERT_FALSE(expression::isSubsetOf(nan.get(), lt.get())); ASSERT_FALSE(expression::isSubsetOf(lt.get(), nan.get())); ASSERT_FALSE(expression::isSubsetOf(nan.get(), lte.get())); ASSERT_FALSE(expression::isSubsetOf(lte.get(), nan.get())); ASSERT_FALSE(expression::isSubsetOf(nan.get(), gte.get())); ASSERT_FALSE(expression::isSubsetOf(gte.get(), nan.get())); ASSERT_FALSE(expression::isSubsetOf(nan.get(), gt.get())); ASSERT_FALSE(expression::isSubsetOf(gt.get(), nan.get())); }
static void traversestack (GCState *st, lua_State *L1) { StkId o, lim; CallInfo *ci; markobject(st, gt(L1)); lim = L1->top; for (ci = L1->base_ci; ci <= L1->ci; ci++) { lua_assert(ci->top <= L1->stack_last); lua_assert(ci->state & (CI_C | CI_HASFRAME | CI_SAVEDPC)); if (lim < ci->top) lim = ci->top; } for (o = L1->stack; o < L1->top; o++) markobject(st, o); for (; o <= lim; o++) setnilvalue(o); checkstacksizes(L1, lim); }
static void traversestack (global_State *g, lua_State *l) { StkId o, lim; CallInfo *ci; markvalue(g, gt(l)); lim = l->top; if(l->stack == NULL) return; /* no stack to traverse */ for (ci = l->base_ci; ci <= l->ci; ci++) { lua_assert(ci->top <= l->stack_last); if (lim < ci->top) lim = ci->top; } for (o = l->stack; o < l->top; o++) markvalue(g, o); for (; o <= lim; o++) setnilvalue(o); if (!isfixedstack(l)) /* if stack size is fixed, can't resize it. */ checkstacksizes(l, lim); }
/* weet: * 1. 用负值索引找栈中的对象 * 2. 可以看出一些栈的设计思路 * */ static TObject *negindex (lua_State *L, int idx) { if (idx > LUA_REGISTRYINDEX) { api_check(L, idx != 0 && -idx <= L->top - L->base); return L->top+idx; } else switch (idx) { /* pseudo-indices */ case LUA_REGISTRYINDEX: return registry(L); case LUA_GLOBALSINDEX: return gt(L); default: { TObject *func = (L->base - 1); idx = LUA_GLOBALSINDEX - idx; lua_assert(iscfunction(func)); return (idx <= clvalue(func)->c.nupvalues) /* (weet: 哈哈, 原来lua把闭包变量放在这个地方!! */ ? &clvalue(func)->c.upvalue[idx-1] : NULL; } } }
/* ** open parts that may cause memory-allocation errors */ static void f_luaopen (lua_State *L, void *ud) { global_State *g = G(L); UNUSED(ud); stack_init(L, L); /* init stack */ #if LUA_MEMORY_STATS luaM_setname(L, "lua.globals"); #endif /* LUA_MEMORY_STATS */ sethvalue(L, gt(L), luaH_new(L, 0, 2)); /* table of globals */ #if LUA_MEMORY_STATS luaM_setname(L, "lua.registry"); #endif /* LUA_MEMORY_STATS */ sethvalue(L, registry(L), luaH_new(L, 0, 2)); /* registry */ luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ luaT_init(L); luaX_init(L); luaS_fix(luaS_newliteral(L, MEMERRMSG)); g->GCthreshold = 4*g->totalbytes; }
static void preinit_state (lua_State *L, global_State *g) { G(L) = g; L->stack = NULL; L->stacksize = 0; L->hook = NULL; L->hookmask = 0; L->basehookcount = 0; L->allowhook = 1; resethookcount(L); L->openupval = NULL; L->size_ci = 0; L->nCcalls = L->baseCcalls = 0; L->status = 0; L->base_ci = L->ci = NULL; L->savedpc = NULL; L->errfunc = 0; setnilvalue(gt(L)); }
void Foam::myHeatFluxFvPatchVectorField::updateCoeffs() { if (this->updated()) { return; } // VARIABLEN/FELDER scalarField sn(patch().size()), st(patch().size()), sct(patch().size()), gt(patch().size()); vectorField t(patch().size()), n(patch().size()); vectorField& s = *this; // Berechnung von Richtungen n = this->patch().nf(); t = g0/mag(g0); // Betrag in normalen Richtung n const volScalarField& internalTheta = db().lookupObject<volScalarField>("Theta"); //const label patchID = patch().boundaryMesh().findPatchID(patch().name()); const label patchID = patch().index(); scalarField boundaryTheta = internalTheta.boundaryField()[patchID]; boundaryTheta = OFinterpolate(patch(), db(), boundaryTheta, patch().nf()); sn = alpha * (boundaryTheta - Theta_wall); // Betrag in tangentiale Richtung t (Approximation durch einseitige FD) vector e1(1,0,0); vector e2(0,1,0); vector e3(0,0,1); vectorField sc = this->patchInternalField(); scalarField d = 1.0/this->patch().deltaCoeffs(); gt = ( (g0 ^ n) & e2 ); sct = ( (sc ^ n) & e2 ); st = ( sct - d*gt ) / ( 1 + d*gamma ); // gesamter Wärmestrom s s = sn*n + st*t; fixedValueFvPatchVectorField::updateCoeffs(); }
YAP_tag_t YAPTerm::tag() { Term tt = gt(); if (IsVarTerm(tt)) { CELL *pt = VarOfTerm(tt); if (IsUnboundVar(pt)) { CACHE_REGS if (IsAttVar(pt)) return YAP_TAG_ATT; return YAP_TAG_UNBOUND; } return YAP_TAG_REF; } if (IsPairTerm(tt)) return YAP_TAG_PAIR; if (IsAtomOrIntTerm(tt)) { if (IsAtomTerm(tt)) return YAP_TAG_ATOM; return YAP_TAG_INT; } else { Functor f = FunctorOfTerm(tt); if (IsExtensionFunctor(f)) { if (f == FunctorDBRef) { return YAP_TAG_DBREF; } if (f == FunctorLongInt) { return YAP_TAG_LONG_INT; } if (f == FunctorBigInt) { big_blob_type bt = (big_blob_type)RepAppl(tt)[1]; switch (bt) { case BIG_INT: return YAP_TAG_BIG_INT; case BIG_RATIONAL: return YAP_TAG_RATIONAL; default: return YAP_TAG_OPAQUE; } } } return YAP_TAG_APPL; } }
TEST( ElemMatchValueMatchExpression, MatchesElementMultiple ) { BSONObj baseOperand1 = BSON( "$gt" << 1 ); BSONObj baseOperand2 = BSON( "$lt" << 10 ); BSONObj notMatch1 = BSON( "a" << BSON_ARRAY( 0 << 1 ) ); BSONObj notMatch2 = BSON( "a" << BSON_ARRAY( 10 << 11 ) ); BSONObj match = BSON( "a" << BSON_ARRAY( 0 << 5 << 11 ) ); auto_ptr<ComparisonMatchExpression> gt( new ComparisonMatchExpression() ); ASSERT( gt->init( "", ComparisonMatchExpression::GT, baseOperand1[ "$gt" ] ).isOK() ); auto_ptr<ComparisonMatchExpression> lt( new ComparisonMatchExpression() ); ASSERT( lt->init( "", ComparisonMatchExpression::LT, baseOperand2[ "$lt" ] ).isOK() ); ElemMatchValueMatchExpression op; ASSERT( op.init( "a" ).isOK() ); op.add( gt.release() ); op.add( lt.release() ); ASSERT( !op.matchesSingleElement( notMatch1[ "a" ] ) ); ASSERT( !op.matchesSingleElement( notMatch2[ "a" ] ) ); ASSERT( op.matchesSingleElement( match[ "a" ] ) ); }
Term &YAPTerm::operator[](arity_t i) { BACKUP_MACHINE_REGS(); Term t0 = gt(); Term *tf = nullptr; if (IsApplTerm(t0)) { // Functor f = FunctorOfTerm(t0); // if (IsExtensionFunctor(f)) // return 0; tf = RepAppl(t0) + (i + 1); } else if (IsPairTerm(t0)) { if (i == 0) tf = RepPair(t0); else if (i == 1) tf = RepPair(t0) + 1; RECOVER_MACHINE_REGS(); } else { throw YAPError(SOURCE(), TYPE_ERROR_COMPOUND, t0, ""); } RECOVER_MACHINE_REGS(); return *tf; }
Term &YAPTerm::operator[](arity_t i) { BACKUP_MACHINE_REGS(); Term t0 = gt(); Term tf = 0; if (IsApplTerm(t0)) { // Functor f = FunctorOfTerm(t0); // if (IsExtensionFunctor(f)) // return 0; tf = RepAppl(t0)[(i + 1)]; } else if (IsPairTerm(t0)) { if (i == 0) tf = HeadOfTerm(t0); else if (i == 1) tf = TailOfTerm(t0); RECOVER_MACHINE_REGS(); tf = RepPair(tf)[i]; } RECOVER_MACHINE_REGS(); Yap_Error(TYPE_ERROR_COMPOUND, tf, ""); throw YAPError(); }
Term YAPTerm::getArg(arity_t i) { BACKUP_MACHINE_REGS(); Term tf = 0; Term t0 = gt(); if (IsApplTerm(t0)) { if (i > ArityOfFunctor(FunctorOfTerm(t0))) throw YAPError(SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()"); tf = (ArgOfTerm(i, t0)); } else if (IsPairTerm(t0)) { if (i == 1) tf = (HeadOfTerm(t0)); else if (i == 2) tf = (TailOfTerm(t0)); else throw YAPError(SOURCE(), DOMAIN_ERROR_OUT_OF_RANGE, t0, "t0.getArg()"); } else { throw YAPError(SOURCE(), TYPE_ERROR_COMPOUND, t0, "t0.getArg()"); } RECOVER_MACHINE_REGS(); return tf; }
LUALIB_API int load_compiled_protos(lua_State *L, jit_proto *p) { Closure *cl; Proto *tf; int i; // load compiled lua code. luaC_checkGC(L); set_block_gc(L); /* stop collector during jit function loading. */ tf = load_jit_proto(L, p); #if DUMP_PROTOS luaU_dump_proto(tf,2); #endif cl = luaF_newLclosure(L, tf->nups, hvalue(gt(L))); cl->l.p = tf; for (i = 0; i < tf->nups; i++) /* initialize eventual upvalues */ cl->l.upvals[i] = luaF_newupval(L); setclvalue(L, L->top, cl); incr_top(L); unset_block_gc(L); return 0; }
void menu_window_end(struct Menu *m, int cols) { int pos = m->line_count - m->window_begin; char str[20] = ""; int len; printf(" %s ", CFG.cursor_space); if (pos > m->window_pos + m->window_size) { printf("+"); } else { printf(" "); } if (m->window_size < m->window_items) sprintf(str, "%s: %d/%d", gt("page"), (m->current - m->window_begin) / m->window_size + 1, (m->window_items-1) / m->window_size + 1); len = strlen(str); printf("%*.*s", cols-6-len, cols-6-len, str); printf("\n"); // debug //printf("c:%d s:%d b:%d i:%d p:%d\n", m->current, m->window_size, // m->window_begin, m->window_items, m->window_pos); }
void Foam::myHeatFluxFvPatchVectorField::updateCoeffs() { if (this->updated()) { return; } // VARIABLEN/FELDER scalarField sn(patch().size()), st(patch().size()), sct(patch().size()), gt(patch().size()); vectorField t(patch().size()), n(patch().size()); vectorField& s = *this; // Berechnung von Richtungen n = this->patch().nf(); t = g0/mag(g0); // Betrag in normalen Richtung n fvPatchField<scalar> boundaryTheta = interpolateBoundaryTheta(); sn = alpha * (boundaryTheta - Theta_wall); // Betrag in tangentiale Richtung t (Approximation durch einseitige FD) vector e1(1,0,0); vector e2(0,1,0); vector e3(0,0,1); vectorField sc = this->patchInternalField(); scalarField d = 1.0/this->patch().deltaCoeffs(); gt = ( (g0 ^ n) & e2 ); sct = ( (sc ^ n) & e2 ); st = ( sct - d*gt ) / ( 1 + d*gamma ); // gesamter Wärmestrom s s = sn*n + st*t; fixedValueFvPatchVectorField::updateCoeffs(); }
TObject *negindex (lua_State *L, int idx) { if (idx > LUA_REGISTRYINDEX) { api_check(L, idx != 0 && -idx <= L->top - L->base); return L->top+idx; } else if (idx < -40000) { return (TObject*)luaH_getnum(hvalue(registry(L)), -idx - 40000); } else switch (idx) { /* pseudo-indices */ case LUA_REGISTRYINDEX: return registry(L); case LUA_GLOBALSINDEX: return gt(L); default: { TObject *func = (L->base - 1); idx = LUA_GLOBALSINDEX - idx; lua_assert(iscfunction(func)); return (idx <= clvalue(func)->c.nupvalues) ? &clvalue(func)->c.upvalue[idx-1] : NULL; } } }
static void traversestack (global_State *g, lua_State *l) { StkId o, lim; CallInfo *ci; markvalue(g, gt(l)); lim = l->top; for (ci = l->base_ci; ci <= l->ci; ci++) { lua_assert(ci->top <= l->stack_last); if (lim < ci->top) lim = ci->top; } for (o = l->stack; o < l->top; o++) markvalue(g, o); #if LUA_REFCOUNT for (; o <= lim; o++) { if (iscollectable(o)) o->value.gc->gch.ref--; setnilvalue2n(l, o); } #else for (; o <= lim; o++) setnilvalue(o); #endif /* LUA_REFCOUNT */ checkstacksizes(l, lim); }
void ColMsg::place_in_internal(ColMsgList & l) { ColMsgList * pl = &l; int ndots = hierarchical_rank.count('.'); //[lgfreitas] contains now returns a bool for (;;) { Q3PtrListIterator<ColMsg> it(*pl); ColMsg * m; unsigned index = pl->count(); for (it.toLast(), index = pl->count(); (m = it.current()) != 0; --it, index -= 1) if (gt(hierarchical_rank, m->hierarchical_rank)) break; if ((m == 0) || // must be the first one (m->hierarchical_rank.contains('.') == ndots)) { // must be placed after m pl->insert(index, this); return; } // must be placed in a sub tree of m pl = &m->msgs; } }