/* Initialize Davinci MMC controller */ static int dmmc_init(struct mmc *mmc) { struct davinci_mmc *host = mmc->priv; struct davinci_mmc_regs *regs = host->reg_base; /* Clear status registers explicitly - soft reset doesn't clear it * If Uboot is invoked from UBL with SDMMC Support, the status * registers can have uncleared bits */ get_val(®s->mmcst0); get_val(®s->mmcst1); /* Hold software reset */ set_bit(®s->mmcctl, MMCCTL_DATRST); set_bit(®s->mmcctl, MMCCTL_CMDRST); udelay(10); set_val(®s->mmcclk, 0x0); set_val(®s->mmctor, 0x1FFF); set_val(®s->mmctod, 0xFFFF); /* Clear software reset */ clear_bit(®s->mmcctl, MMCCTL_DATRST); clear_bit(®s->mmcctl, MMCCTL_CMDRST); udelay(10); /* Reset FIFO - Always use the maximum fifo threshold */ set_val(®s->mmcfifoctl, (MMCFIFOCTL_FIFOLEV | MMCFIFOCTL_FIFORST)); set_val(®s->mmcfifoctl, MMCFIFOCTL_FIFOLEV); return 0; }
/* * Set the pred and succ of the given free block * Since the whole memory space is 2^32 bytes * I can compress the 8 bytes address into 4 bytes * by computing its offest to heap_listp */ static inline void set_ptr(uint32_t* const block, uint32_t* const pred_block, uint32_t* const succ_block) { REQUIRES(block != NULL); REQUIRES(in_heap(block)); unsigned int pred_offest; unsigned int succ_offest; if (pred_block == NULL) pred_offest = 0; else pred_offest = pred_block - heap_listp; if (succ_block == NULL) succ_offest = 0; else succ_offest = succ_block - heap_listp; //printf("pred_off = %d, succ_off = %d\n", pred_offest, succ_offest); set_val(block + 1 , pred_offest); set_val(block + 2 , succ_offest); ENSURES(block_pred(block) == pred_block); ENSURES(block_succ(block) == succ_block); }
/* Set davinci clock prescalar value based on the required clock in HZ */ static void dmmc_set_clock(struct mmc *mmc, uint clock) { struct davinci_mmc *host = mmc->priv; struct davinci_mmc_regs *regs = host->reg_base; uint clkrt, sysclk2, act_clock; if (clock < mmc->f_min) clock = mmc->f_min; if (clock > mmc->f_max) clock = mmc->f_max; set_val(®s->mmcclk, 0); sysclk2 = host->input_clk; clkrt = (sysclk2 / (2 * clock)) - 1; /* Calculate the actual clock for the divider used */ if (clkrt != -1) act_clock = (sysclk2 / (2 * (clkrt + 1))); else act_clock = clock + 1; /* Adjust divider if actual clock exceeds the required clock */ if (act_clock > clock) clkrt++; /* check clock divider boundary and correct it */ if (clkrt > 0xFF) clkrt = 0xFF; #ifdef MMC_DEBUG printf("eMMC clock =%lu\n", (sysclk2 / (2 * (clkrt + 1)))); #endif set_val(®s->mmcclk, (clkrt | MMCCLK_CLKEN)); }
template <typename T, typename X> void permutation_matrix<T, X>::transpose_from_right(unsigned i, unsigned j) { // the result will be this = this * (i,j) lean_assert(i < size() && j < size() && i != j); auto pi = m_permutation[i]; auto pj = m_permutation[j]; set_val(i, pj); set_val(j, pi); }
inline body_type * alloc_body(std::size_t capacity, const char * first, std::size_t len) { auto * body = alloc_body<body_type>(capacity); set_val(body->capacity, capacity); set_val(body->size, len); std::memcpy(body->buffer, first, len); return body; }
template <typename T, typename X> void permutation_matrix<T, X>::transpose_from_left(unsigned i, unsigned j) { // the result will be this = (i,j)*this lean_assert(i < size() && j < size() && i != j); auto pi = m_rev[i]; auto pj = m_rev[j]; set_val(pi, j); set_val(pj, i); }
inline body_type * alloc_body_nothrow(std::size_t capacity, const char * first, std::size_t len) { auto * body = alloc_body_nothrow<body_type>(capacity); if (body == nullptr) return nullptr; set_val(body->capacity, capacity); set_val(body->size, len); std::memcpy(body->buffer, first, len); return body; }
inline typename std::enable_if<std::is_same<body_type, other_body_type>::value, body_type>::type * realloc_body(other_body_type * other, std::size_t newcap) { auto * body = static_cast<body_type *>(::realloc(other, sizeof(body_type) + newcap)); if (body == nullptr) throw std::bad_alloc(); set_val(body->capacity, newcap); if (body->size > newcap) set_val(body->size, newcap); return body; }
void Range::set_unit_value(double p_value) { if (shared->exp_unit_value && get_min()>0) { double exp_min = Math::log(get_min())/Math::log(2); double exp_max = Math::log(get_max())/Math::log(2); double v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value); set_val( v ); } else { set_val( (get_max() - get_min()) * p_value + get_min() ); } }
inline typename std::enable_if< ! std::is_same<body_type, other_body_type>::value, body_type>::type * realloc_body_nothrow(other_body_type * other, std::size_t newcap) { std::size_t size = std::min<std::size_t>(other->size, newcap); auto * body = static_cast<body_type *>(::realloc(other, sizeof(body_type) + newcap)); if (body == nullptr) return nullptr; std::memmove(body->buffer, other->buffer, size); set_val(body->size, size); set_val(body->capacity, newcap); return body; }
/* * Update callback function * db: the database * key: key dbt of the kv pair * old_val: old_val of the key dbt, if its null, we must create val * extra: the struct we pass to db->update function * set_val: set value function, should be provided by tokudb * set_extra: argument for set_val callback */ static int env_update_cb(DB *db, const DBT *key, const DBT *old_val, const DBT *extra, void (*set_val)(const DBT *newval, void *set_extra), void *set_extra) { int ret; DBT val; size_t newval_size; void *newval; BUG_ON(db == NULL || key == NULL || extra == NULL || extra->data == NULL); // there is no meta update currently BUG_ON(IS_META_KEY_DBT(key)); ret = block_update_cb(&newval, &newval_size, old_val, extra->data); if (!ret) { dbt_init(&val, newval, newval_size); set_val(&val, set_extra); kfree(newval); } return ret; }
JNIEXPORT jint JNICALL Java_edu_berkeley_bid_CUMAT_setval (JNIEnv *env, jobject obj, jobject jA, jfloat vv, jint length) { float *nativeA = (float*)getPointer(env, jA); return set_val(nativeA, vv, length); }
void Range::set_min(double p_min) { shared->min=p_min; set_val(shared->val); shared->emit_changed("range/min"); }
void Range::set_page(double p_page) { shared->page=p_page; set_val(shared->val); shared->emit_changed("range/page"); }
void IF2Group::check_thresholds() { auryn_vector_float_clip( mem, e_rev ); AurynState * thr_ptr = thr->data; for ( AurynState * i = mem->data ; i != mem->data+get_rank_size() ; ++i ) { // it's important to use rank_size here otherwise there might be spikes from units that do not exist if ( *i > ( thr_rest + *thr_ptr ) ) { NeuronID unit = i-mem->data; push_spike(unit); set_val (mem, unit, e_rest); // reset set_val (thr, unit, dthr); //refractory } thr_ptr++; } }
int exec_step_dovr(struct band_list_el *bll){ unsigned char *adrs; long double val; void *ptr; int tip, size, artsin, sayqac; tip = bll->tip; size = bll->size; ptr = pop_from_stek(&adrstk); adrs = (unsigned char *)ptr; val = get_value(adrs, tip, size); sayqac = (int)val; /* !!! do not free ptr popped from adrstk */ ptr = pop_from_stek(&valstk); val = *(long double *)ptr; artsin = (int)val; free(ptr); if (artsin) sayqac++; else sayqac--; val = (long double)sayqac; set_val(adrs, val, tip); return bll->head_pos; }
JNIEXPORT jint JNICALL Java_edu_berkeley_bid_CUMATD_setval (JNIEnv *env, jobject obj, jobject jA, jdouble vv, jint length) { double *nativeA = (double*)getPointer(env, jA); return set_val(nativeA, vv, length); }
void Range::set_max(double p_max) { shared->max=p_max; set_val(shared->val); shared->emit_changed("range/max"); }
// Set the size of the given block in multiples of 4 bytes static inline void set_size(uint32_t* const block, unsigned int size) { REQUIRES(block != NULL); REQUIRES(in_heap(block)); REQUIRES(size % 2 == 0); set_val(block, size); }
template <typename T, typename X> void permutation_matrix<T, X>::multiply_by_reverse_from_right(permutation_matrix<T, X> & q){ // todo : condensed permutations ? auto clone = clone_m_permutation(); // the result is this = this*q(-1) unsigned i = size(); while (i-- > 0) { set_val(i, q.m_rev[clone[i]]); // we have m(P)*m(Q) = m(QP), where m is the matrix of the permutation } delete [] clone; }
// this is multiplication in the matrix sense template <typename T, typename X> void permutation_matrix<T, X>::multiply_by_permutation_from_right(permutation_matrix<T, X> & p) { auto clone = clone_m_permutation(); lean_assert(p.size() == size()); unsigned i = size(); while (i-- > 0) { set_val(i, p[clone[i]]); // we have m(P)*m(Q) = m(QP), where m is the matrix of the permutation } delete [] clone; }
/* * Set values for sequence */ int SetValGTM(char *seqname, GTM_Sequence nextval, bool iscalled) { GTM_SequenceKeyData seqkey; #ifdef XCP char *coordName = IS_PGXC_COORDINATOR ? PGXCNodeName : MyCoordName; int coordPid = IS_PGXC_COORDINATOR ? MyProcPid : MyCoordPid; #endif CheckConnection(); seqkey.gsk_keylen = strlen(seqname) + 1; seqkey.gsk_key = seqname; #ifdef XCP return conn ? set_val(conn, &seqkey, coordName, coordPid, nextval, iscalled) : -1; #else return conn ? set_val(conn, &seqkey, nextval, iscalled) : -1; #endif }
void do_sh_range(double *ystart, double *yend) { double parlo, parhi, dpar, temp; int npar, i, j, ierr; int side, cycle, icol, color; char bob[50]; if (set_up_sh_range() == 0) return; swap_color(&color, 0); parhi = shoot_range.phigh; parlo = shoot_range.plow; npar = shoot_range.steps; dpar = (parhi - parlo) / (double)npar; side = shoot_range.side; cycle = shoot_range.cycle; storind = 0; icol = 0; if (shoot_range.movie == 1) reset_film(); for (i = 0; i <= npar; i++) { temp = parlo + dpar * (double)i; set_val(shoot_range.item, temp); sprintf(bob, "%s=%.16g", shoot_range.item, temp); x11_status_bar_set_text(main_status_bar, bob); if (shoot_range.movie == 1) clr_scrn(); bvshoot(ystart, yend, BVP_TOL, BVP_EPS, BVP_MAXIT, &ierr, NODE, 0, 0, 0, 0, 0.0); if (ierr == ABORT) continue; if (ierr < 0) { bad_shoot(ierr); set_browser_data(storage, storind, NEQ + 1); swap_color(&color, 1); return; } storage[0][storind] = temp; if (side == 0) for (j = 0; j < NODE; j++) storage[j + 1][storind] = ystart[j]; else for (j = 0; j < NODE; j++) storage[j + 1][storind] = yend[j]; storind++; set_cycle(cycle, &icol); get_ic(0, ystart); last_shot(0); if (shoot_range.movie == 1) film_clip(); ping(); } set_browser_data(storage, storind, NEQ + 1); auto_freeze_it(); swap_color(&color, 1); }
template <typename T, typename X> void permutation_matrix<T, X>::multiply_by_permutation_reverse_from_left(permutation_matrix<T, X> & r){ // todo : condensed permutations? // the result is this = r(-1)*this auto clone = clone_m_permutation(); // the result is this = this*q(-1) unsigned i = size(); while (i-- > 0) { set_val(i, clone[r.m_rev[i]]); } delete [] clone; }
/* * Set values for sequence */ int SetValGTM(char *seqname, GTM_Sequence nextval, bool iscalled) { GTM_SequenceKeyData seqkey; CheckConnection(); seqkey.gsk_keylen = strlen(seqname) + 1; seqkey.gsk_key = seqname; return conn ? set_val(conn, &seqkey, nextval, iscalled) : -1; }
Demo_Subject2::Demo_Subject2(demo_subject_2_key_t key_2, demo_subject_2_value_t val_2) : cache_entry_subject<key_class<demo_subject_2_key_t>, demo_subject_2_value_t>(key_class<demo_subject_2_key_t>(key_2)) { set_val(val_2); printf("new subject of type 1: \n"); printf("\t key = %d, value = %d\n", key_2, val_2); }
Demo_Subject1::Demo_Subject1(demo_subject_1_key_t key_1, demo_subject_1_value_t val_1) : cache_entry_subject<key_class<demo_subject_1_key_t>, demo_subject_1_value_t>(key_class<demo_subject_1_key_t>(key_1)) { set_val(val_1); printf("new subject of type 1: \n"); printf("\t key = %c, value = %d\n", key_1, val_1); }
int do_calc(char *temp, double *z) { char val[15]; int ok; int i; double newz; if (strlen(temp) == 0) { *z = 0.0; return (1); } if (has_eq(temp, val, &i)) { newz = calculate(&temp[i], &ok); /* calculate quantity */ if (ok == 0) return (-1); i = find_user_name(PARAMBOX, val); if (i > -1) { set_val(val, newz); /* a parameter set to value */ *z = newz; redraw_params(); } else { i = find_user_name(ICBOX, val); if (i < 0) { err_msg("No such name!"); return (-1); } set_val(val, newz); last_ic[i] = newz; *z = newz; redraw_ics(); } return (0); } newz = calculate(temp, &ok); if (ok == 0) return (-1); *z = newz; return (1); }
int main(int argc, char* argv[]) { float b[10]; unsigned int i; for (i = 0; i < 10; ++i) { set_val(&b[i], 30000); } return 0; }
void HasValueMap:: copy_value( AstInterfaceImpl& fa, const AstNodePtr& orig, const AstNodePtr& copy) { HasValueDescriptor desc; if (has_value( orig, &desc)) { set_val(copy, desc); if (DebugValuePropogate()) { std::cerr << "copying ast: " << AstInterface::AstToString(copy) << copy.get_ptr() << " to have value " << desc.toString() << std::endl; } } }