bool socialServerStart(SocialServer *self) { special("======================"); special("==== Social server ==="); special("======================"); if (!(serverStart(self->server))) { error("Cannot start the Server."); return false; } return true; }
int main (int argc, char *argv[]) { tests_start_mpfr (); special (); test_specialz (mpfr_add_z, mpz_add, "add"); test_specialz (mpfr_sub_z, mpz_sub, "sub"); test_specialz (mpfr_mul_z, mpz_mul, "mul"); test_genericz (2, 100, 100, mpfr_add_z, "add"); test_genericz (2, 100, 100, mpfr_sub_z, "sub"); test_genericz (2, 100, 100, mpfr_mul_z, "mul"); test_genericz (2, 100, 100, mpfr_div_z, "div"); test_genericq (2, 100, 100, mpfr_add_q, "add"); test_genericq (2, 100, 100, mpfr_sub_q, "sub"); test_genericq (2, 100, 100, mpfr_mul_q, "mul"); test_genericq (2, 100, 100, mpfr_div_q, "div"); test_specialq (2, 100, 100, mpfr_mul_q, mpq_mul, "mul"); test_specialq (2, 100, 100, mpfr_div_q, mpq_div, "div"); test_specialq (2, 100, 100, mpfr_add_q, mpq_add, "add"); test_specialq (2, 100, 100, mpfr_sub_q, mpq_sub, "sub"); test_cmp_z (2, 100, 100); test_cmp_q (2, 100, 100); test_cmp_f (2, 100, 100); check_for_zero (); tests_end_mpfr (); return 0; }
int main(int argc, char *argv[]) { int *pr_arr, pr_len, n_found; int max = 1; /* max number of prime search. this grows '*10' */ int i, tmp; long sum; n_found = 0; sum = 0L; tmp = 4; /* for skip 2,3,5,7 */ while (1) { /* we grow search range to 10,100,1000.. */ max *= 10; if (primes_under(max, &pr_arr, &pr_len)) errx(1, "fail primes_under(%d)", max); for (i = tmp; i < pr_len; i++) { if (special(pr_arr[i], pr_arr, pr_len)) { sum += pr_arr[i]; n_found++; if (n_found == NEED_NFOUND) break; /* out to for-loop */ } } if (n_found == NEED_NFOUND) break; /* out to while-loop */ tmp = pr_len; /* skip already checked for next loop */ free(pr_arr); } printf("%ld\n", sum); return 0; }
int main (int argc, char **argv) { mpfr_t x; tests_start_mpfr (); special (); check_inexact (); check("1.0", 3, MPFR_RNDN, "3.3333333333333331483e-1"); check("1.0", 3, MPFR_RNDZ, "3.3333333333333331483e-1"); check("1.0", 3, MPFR_RNDU, "3.3333333333333337034e-1"); check("1.0", 3, MPFR_RNDD, "3.3333333333333331483e-1"); check("1.0", 2116118, MPFR_RNDN, "4.7256343927890600483e-7"); check("1.098612288668109782", 5, MPFR_RNDN, "0.21972245773362195087"); mpfr_init2 (x, 53); mpfr_set_ui (x, 3, MPFR_RNDD); mpfr_log (x, x, MPFR_RNDD); mpfr_div_ui (x, x, 5, MPFR_RNDD); if (mpfr_cmp_str1 (x, "0.21972245773362189536")) { printf ("Error in mpfr_div_ui for x=ln(3), u=5\n"); exit (1); } mpfr_clear (x); test_generic_ui (2, 200, 100); tests_end_mpfr (); return 0; }
int main (int argc, char *argv[]) { mp_prec_t p; unsigned k; tests_start_mpfr (); check_nans (); special (); for (p=2; p<100; p++) for (k=0; k<100; k++) check_two_sum (p); check(1196426492, "1.4218093058435347e-3", GMP_RNDN, "1.1964264919985781e9"); check(1092583421, "-1.0880649218158844e9", GMP_RNDN, "2.1806483428158845901e9"); check(948002822, "1.22191250737771397120e+20", GMP_RNDN, "-1.2219125073682338611e20"); check(832100416, "4.68311314939691330000e-215", GMP_RNDD, "8.3210041599999988079e8"); check(1976245324, "1.25296395864546893357e+232", GMP_RNDZ, "-1.2529639586454686577e232"); check(2128997392, "-1.08496826129284207724e+187", GMP_RNDU, "1.0849682612928422704e187"); check(293607738, "-1.9967571564050541e-5", GMP_RNDU, "2.9360773800002003e8"); check(354270183, "2.9469161763489528e3", GMP_RNDN, "3.5426723608382362e8"); tests_end_mpfr (); return 0; }
glui32 fillstruct(strid_t stream, const unsigned *info, glui32 *dest, glui32 (*special)(strid_t)) { unsigned char buffer[4]; unsigned e; glui32 len = 0;; for(e = 0; info[e]; e++) { if(info[e] == 0x8000) { *dest++ = special(stream); len++; } else if(info[e] > 4) { unsigned i; for(i = 0; i < info[e]; i++) { *dest++ = glk_get_char_stream(stream); len++; } } else { glk_get_buffer_stream(stream, (char *) buffer, info[e]); switch(info[e]) { case 1: *dest = MSBdecode1(buffer); break; case 2: *dest = MSBdecode2(buffer); break; case 3: *dest = MSBdecode3(buffer); break; case 4: *dest = MSBdecode4(buffer); break; } dest++; len+=info[e]; } } return len; }
ReservedSpace ReservedSpace::last_part(size_t partition_size, size_t alignment) { assert(partition_size <= size(), "partition failed"); ReservedSpace result(base() + partition_size, size() - partition_size, alignment, special(), executable()); return result; }
//! This function is called once per simulation step, allowing the //! constraint to be "motorized" according to some response. void OscHinge2ODE::simulationCallback() { ODEConstraint& me = *static_cast<ODEConstraint*>(special()); dReal angle1 = dJointGetHinge2Angle1(me.joint()); dReal rate1 = dJointGetHinge2Angle1Rate(me.joint()); dReal addtorque1 = - m_response->m_stiffness.m_value*angle1 - m_response->m_damping.m_value*rate1; #if 0 // TODO: dJointGetHinge2Angle2 is not yet available in ODE. dReal angle2 = dJointGetHinge2Angle2(me.joint()); #else dReal angle2 = 0; #endif dReal rate2 = dJointGetHinge2Angle2Rate(me.joint()); dReal addtorque2 = - m_response->m_stiffness.m_value*angle2 - m_response->m_damping.m_value*rate2; m_torque1.m_value = addtorque1; m_torque2.m_value = addtorque2; dJointAddHinge2Torques(me.joint(), addtorque1, addtorque2); }
void OscFreeODE::simulationCallback() { ODEConstraint& me = *static_cast<ODEConstraint*>(special()); const dReal *pos1 = dBodyGetPosition(me.body1()); const dReal *pos2 = dBodyGetPosition(me.body2()); const dReal *vel1 = dBodyGetLinearVel(me.body1()); const dReal *vel2 = dBodyGetLinearVel(me.body2()); dReal force[3]; force[0] = - ((pos2[0]-pos1[0]-m_initial_distance[0]) * m_response->m_stiffness.m_value) - (vel2[0]-vel1[0]) * m_response->m_damping.m_value; force[1] = - ((pos2[1]-pos1[1]-m_initial_distance[1]) * m_response->m_stiffness.m_value) - (vel2[1]-vel1[1]) * m_response->m_damping.m_value; force[2] = - ((pos2[2]-pos1[2]-m_initial_distance[2]) * m_response->m_stiffness.m_value) - (vel2[2]-vel1[2]) * m_response->m_damping.m_value; dBodyAddForce(me.body1(), -force[0], -force[1], -force[2]); dBodyAddForce(me.body2(), force[0], force[1], force[2]); }
int main (void) { mp_prec_t p; MPFR_TEST_USE_RANDS (); tests_start_mpfr (); special (); particular_cases (); check_pow_ui (); check_pow_si (); check_special_pow_si (); pow_si_long_min (); for (p = 2; p < 100; p++) check_inexact (p); underflows (); overflows (); x_near_one (); test_generic (2, 100, 100); test_generic_ui (2, 100, 100); test_generic_si (2, 100, 100); data_check ("data/pow275", mpfr_pow275, "mpfr_pow275"); tests_end_mpfr (); return 0; }
size_t VirtualSpace::actual_committed_size() const { // Special VirtualSpaces commit all reserved space up front. if (special()) { return reserved_size(); } size_t committed_low = pointer_delta(_lower_high, _low_boundary, sizeof(char)); size_t committed_middle = pointer_delta(_middle_high, _lower_high_boundary, sizeof(char)); size_t committed_high = pointer_delta(_upper_high, _middle_high_boundary, sizeof(char)); #ifdef ASSERT size_t lower = pointer_delta(_lower_high_boundary, _low_boundary, sizeof(char)); size_t middle = pointer_delta(_middle_high_boundary, _lower_high_boundary, sizeof(char)); size_t upper = pointer_delta(_upper_high_boundary, _middle_high_boundary, sizeof(char)); if (committed_high > 0) { assert(committed_low == lower, "Must be"); assert(committed_middle == middle, "Must be"); } if (committed_middle > 0) { assert(committed_low == lower, "Must be"); } if (committed_middle < middle) { assert(committed_high == 0, "Must be"); } if (committed_low < lower) { assert(committed_high == 0, "Must be"); assert(committed_middle == 0, "Must be"); } #endif return committed_low + committed_middle + committed_high; }
size_t PSVirtualSpaceHighToLow::expand_into(PSVirtualSpace* other_space, size_t bytes) { assert(is_aligned(bytes), "arg not aligned"); assert(grows_down(), "this space must grow down"); assert(other_space->grows_up(), "other space must grow up"); assert(reserved_low_addr() == other_space->reserved_high_addr(), "spaces not contiguous"); assert(special() == other_space->special(), "one space is special in memory, the other is not"); DEBUG_ONLY(PSVirtualSpaceVerifier this_verifier(this)); DEBUG_ONLY(PSVirtualSpaceVerifier other_verifier(other_space)); size_t bytes_needed = bytes; // First use the uncommitted region in this space. size_t tmp_bytes = MIN2(uncommitted_size(), bytes_needed); if (tmp_bytes > 0) { if (expand_by(tmp_bytes)) { bytes_needed -= tmp_bytes; } else { return 0; } } // Next take from the uncommitted region in the other space, and commit it. tmp_bytes = MIN2(other_space->uncommitted_size(), bytes_needed); if (tmp_bytes > 0) { char* const commit_base = committed_low_addr() - tmp_bytes; if (other_space->special() || os::commit_memory(commit_base, tmp_bytes, alignment(), !ExecMem)) { // Reduce the reserved region in the other space. other_space->set_reserved(other_space->reserved_low_addr(), other_space->reserved_high_addr() - tmp_bytes, other_space->special()); // Grow both reserved and committed in this space. _reserved_low_addr -= tmp_bytes; _committed_low_addr -= tmp_bytes; bytes_needed -= tmp_bytes; } else { return bytes - bytes_needed; } } // Finally take from the already committed region in the other space. tmp_bytes = bytes_needed; if (tmp_bytes > 0) { // Reduce both committed and reserved in the other space. other_space->set_committed(other_space->committed_low_addr(), other_space->committed_high_addr() - tmp_bytes); other_space->set_reserved(other_space->reserved_low_addr(), other_space->reserved_high_addr() - tmp_bytes, other_space->special()); // Grow both reserved and committed in this space. _reserved_low_addr -= tmp_bytes; _committed_low_addr -= tmp_bytes; } return bytes; }
OscFreeODE::OscFreeODE(dWorldID odeWorld, dSpaceID odeSpace, const char *name, OscBase* parent, OscObject *object1, OscObject *object2) : OscFree(name, parent, object1, object2) { m_response = new OscResponse("response",this); // The "Free" constraint is not actually an ODE constraint. // However, we need an ODEConstraint to remember the objects so // that they can receive forces and torques. m_pSpecial = new ODEConstraint(this, NULL, odeWorld, odeSpace, object1, object2); ODEConstraint& cons = *static_cast<ODEConstraint*>(special()); const dReal *pos1 = dBodyGetPosition(cons.body1()); const dReal *pos2 = dBodyGetPosition(cons.body2()); m_initial_distance[0] = pos2[0] - pos1[0]; m_initial_distance[1] = pos2[1] - pos1[1]; m_initial_distance[2] = pos2[2] - pos1[2]; printf("[%s] Free constraint created between %s and %s.\n", simulation()->type_str(), object1->c_name(), object2->c_name()); }
int main(int argc, char ** argv){ int option = -1; if( argc <= 1 || ( (option = atoi(argv[1])) < 0 ) ){ print_usage(); } int count = 0; if(argc >= 3) count = atoi(argv[2]); printf("Welcome to effectTest, option %d, count %d\n", option, count); switch(option){ case 0: functional(count); break; case 1: left(); break; case 2: right(); break; case 3: duplicate(); break; case 4: invalid(); break; case 5: special(); break; case 9: other(); break; } return 0; }
void OscSphereODE::on_density() { ODEObject *ode_object = static_cast<ODEObject*>(special()); dMassSetSphere(&ode_object->mass(), m_density.m_value, m_radius.m_value); dBodySetMass(ode_object->body(), &ode_object->mass()); m_mass.m_value = ode_object->mass().mass; }
void G1PageBasedVirtualSpace::print_on(outputStream* out) { out->print ("Virtual space:"); if (special()) out->print(" (pinned in memory)"); out->cr(); out->print_cr(" - committed: " SIZE_FORMAT, committed_size()); out->print_cr(" - reserved: " SIZE_FORMAT, reserved_size()); out->print_cr(" - [low_b, high_b]: [" INTPTR_FORMAT ", " INTPTR_FORMAT "]", p2i(_low_boundary), p2i(_high_boundary)); }
void menu(int value) { if(value < 0) special(-value, 0, 0); else key((unsigned char) value, 0, 0); }
void testSpecial() { int x = 10; for ( int i = 1; i < x; i+=2 ) { special( i ); } }
void OscPrismODE::on_density() { ODEObject *ode_object = static_cast<ODEObject*>(special()); dMassSetBox(&ode_object->mass(), m_density.m_value, m_size.x, m_size.y, m_size.z); dBodySetMass(ode_object->body(), &ode_object->mass()); m_mass.m_value = ode_object->mass().mass; }
void VirtualSpace::print() { tty->print ("Virtual space:"); if (special()) tty->print(" (pinned in memory)"); tty->cr(); tty->print_cr(" - committed: " SIZE_FORMAT, committed_size()); tty->print_cr(" - reserved: " SIZE_FORMAT, reserved_size()); tty->print_cr(" - [low, high]: [" INTPTR_FORMAT ", " INTPTR_FORMAT "]", low(), high()); tty->print_cr(" - [low_b, high_b]: [" INTPTR_FORMAT ", " INTPTR_FORMAT "]", low_boundary(), high_boundary()); }
void OscSphereODE::on_mass() { ODEObject *ode_object = static_cast<ODEObject*>(special()); dMassSetSphereTotal(&ode_object->mass(), m_mass.m_value, m_radius.m_value); dBodySetMass(ode_object->body(), &ode_object->mass()); dReal volume = 4*M_PI*m_radius.m_value*m_radius.m_value*m_radius.m_value/3; m_density.m_value = m_mass.m_value / volume; }
ReservedSpace ReservedSpace::first_part(size_t partition_size, size_t alignment, bool split, bool realloc) { assert(partition_size <= size(), "partition failed"); if (split) { os::split_reserved_memory(base(), size(), partition_size, realloc); } ReservedSpace result(base(), partition_size, alignment, special(), executable()); return result; }
void OscSphereODE::on_radius() { ODEObject *ode_object = static_cast<ODEObject*>(special()); dGeomSphereSetRadius(ode_object->geom(), m_radius.m_value); // reset the mass to maintain same density dMassSetSphere(&ode_object->mass(), m_density.m_value, m_radius.m_value); m_mass.m_value = ode_object->mass().mass; }
void htmlencode(std::ostream &out, const std::wstring &value) { for (size_t i=0; i<value.length(); ++i) { if (special(value[i])) { out << "&#" << (int) value[i] << ";"; } else { out << (char) value[i]; } } }
void OscPrismODE::on_mass() { ODEObject *ode_object = static_cast<ODEObject*>(special()); dMassSetBoxTotal(&ode_object->mass(), m_mass.m_value, m_size.x, m_size.y, m_size.z); dBodySetMass(ode_object->body(), &ode_object->mass()); dReal volume = m_size.x * m_size.y * m_size.z; m_density.m_value = m_mass.m_value / volume; }
/* Evaluate an S-expression */ long l_eval(long s) { long v, f, a, av[2]; int n; switch(D_GET_TAG(s)){ case TAG_NIL: /* self-evaluating objects */ case TAG_T: case TAG_INT: v = s; break; case TAG_SYMB: /* symbol ... refer to the symbol table */ if ((v = t_symb_val[D_GET_DATA(s)]) == TAG_UNDEF) return err_msg(errmsg_sym_undef, 1, s); break; case TAG_CONS: /* cons ... function call */ f = l_car(s); /* function name or lambda exp */ a = l_cdr(s); /* actual argument list */ #ifndef minimalistic if ((D_GET_TAG(f) == TAG_CONS) && (D_GET_TAG(l_car(f)) == TAG_SYMB) && ((D_GET_DATA(l_car(f)) == KW_LAMBDA))){ /* lambda exp */ if (eval_args(f, a, av, FTYPE_ANY_ARGS) < 0) return -1; v = apply(l_cdr(f), av[0], list_len(l_car(l_cdr(f)))); } else #endif if (D_GET_TAG(f) == TAG_SYMB){ n = FTYPE_GET_NARGS(t_symb_ftype[D_GET_DATA(f)]); switch (FTYPE_GET_TYPE(t_symb_ftype[D_GET_DATA(f)])){ case FTYPE_UNDEF: return err_msg(errmsg_func_undef, 1, f); case FTYPE_SPECIAL: v = special(f, a); break; case FTYPE_SYS: if (eval_args(f, a, av, n) < 0) return -1; v = fcall(f, av/*, n*/); break; case FTYPE_USER: if (eval_args(f, a, av, FTYPE_ANY_ARGS) < 0) return -1; v = apply(f, av[0], n); } } else { return err_msg(errmsg_ill_call, 1, s); } break; } return v; }
void Arg::dump(PrintStream& out) const { switch (m_kind) { case Invalid: out.print("<invalid>"); return; case Tmp: out.print(tmp()); return; case Imm: out.print("$", m_offset); return; case Imm64: out.printf("$0x%llx", static_cast<long long unsigned>(m_offset)); return; case Addr: if (offset()) out.print(offset()); out.print("(", base(), ")"); return; case Index: if (offset()) out.print(offset()); out.print("(", base(), ",", index()); if (scale() != 1) out.print(",", scale()); out.print(")"); return; case Stack: if (offset()) out.print(offset()); out.print("(", pointerDump(stackSlot()), ")"); return; case CallArg: if (offset()) out.print(offset()); out.print("(callArg)"); return; case RelCond: out.print(asRelationalCondition()); return; case ResCond: out.print(asResultCondition()); return; case DoubleCond: out.print(asDoubleCondition()); return; case Special: out.print(pointerDump(special())); return; } RELEASE_ASSERT_NOT_REACHED(); }
static void unsetspec(struct tbl *vp) { /* * AT&T ksh man page says OPTIND, OPTARG and _ lose special * meaning, but OPTARG does not (still set by getopts) and _ is * also still set in various places. Don't know what AT&T does * for HISTSIZE, HISTFILE. Unsetting these in AT&T ksh does not * loose the 'specialness': IFS, COLUMNS, PATH, TMPDIR */ switch (special(vp->name)) { #ifdef __OS2__ case V_BEGINLIBPATH: case V_ENDLIBPATH: case V_LIBPATHSTRICT: setextlibpath(vp->name, ""); return; #endif #if HAVE_PERSISTENT_HISTORY case V_HISTFILE: sethistfile(NULL); return; #endif case V_IFS: set_ifs(TC_IFSWS); break; case V_PATH: afree(path, APERM); strdupx(path, def_path, APERM); /* clear tracked aliases */ flushcom(true); break; #ifndef MKSH_NO_CMDLINE_EDITING case V_TERM: x_initterm(null); return; #endif case V_TMPDIR: /* should not become unspecial */ if (tmpdir) { afree(tmpdir, APERM); tmpdir = NULL; } break; case V_LINENO: case V_RANDOM: case V_SECONDS: case V_TMOUT: /* AT&T ksh leaves previous value in place */ unspecial(vp->name); break; } }
int main (void) { tests_start_mpfr (); special (); test_generic (2, 100, 2); tests_end_mpfr (); return 0; }
int main (void) { test (ecvt_tests, ecvt, "ecvt"); test (fcvt_tests, fcvt, "fcvt"); test_r (ecvt_tests, ecvt_r, "ecvt_r"); test_r (fcvt_tests, fcvt_r, "fcvt_r"); special (); return error_count; }