void Insert_Spline_Entry(GenericSpline * sp, DBL p, const EXPRESS& v) { SplineEntryList::size_type i; int k; /* Reset the Coeffs_Computed flag. Inserting a new point invalidates * pre-computed coefficients */ sp->Coeffs_Computed = false; i = findt(sp, p); /* If p is already in spline, replace */ /* The clause after the || is needed because findt returns sp->SplineEntries.size() * if p is greater than OR EQUAL TO the highest par in the spline */ if(!sp->SplineEntries.empty() && ((sp->SplineEntries[i].par == p) || (i == sp->SplineEntries.size() && sp->SplineEntries[i-1].par == p))) { for(k=0; k<5; k++) sp->SplineEntries[i].vec[k] = v[k]; } else { mkfree(sp, i); sp->SplineEntries[i].par = p; for(k=0; k<5; k++) sp->SplineEntries[i].vec[k] = v[k]; } }
void write_reg(int pid, int reg, int value, int type) { MKNode *lroot = root; while( ((Process *) lroot->value)-> pid != pid ) lroot = lroot->next; ((Process *) lroot->value)->shared_regs[reg] = value; ((Process *) lroot->value)->type[reg] = type; ((Process *) lroot->value)->genesis[reg] = current_process(); lroot = NULL; mkfree(lroot); }
void kill(int pid) { MKNode *lroot = root; if( root != NULL ) { while( ( (Process *) lroot->next->value )->pid != pid ) lroot = lroot->next; lroot->next = lroot->next->next; } lroot = NULL; mkfree(lroot); }
int current_process() { MKNode *lroot = root; int pid; while( ( (Process *) lroot->value)->executing != 1) lroot = lroot->next; pid = ((Process *) lroot->value)->pid; lroot = NULL; mkfree(lroot); return pid; }
int read_genesis(int reg) { int pid = current_process(); int r_genesis; MKNode *lroot = root; while( ((Process *) lroot->value)-> pid != pid ) lroot = lroot->next; r_genesis = ((Process *) lroot->value)->genesis[reg]; lroot = NULL; mkfree(lroot); return r_genesis; }
int read_type(int reg) { int pid = current_process(); int r_type; MKNode *lroot = root; while( ((Process *) lroot->value)-> pid != pid ) lroot = lroot->next; r_type = ((Process *) lroot->value)->type[reg]; lroot = NULL; mkfree(lroot); return r_type; }
int read_reg(int reg) { int pid = current_process(); int r_reg; MKNode *lroot = root; while( ((Process *) lroot->value)-> pid != pid ) lroot = lroot->next; r_reg = ((Process *) lroot->value)->shared_regs[reg]; lroot = NULL; mkfree(lroot); return r_reg; }
void push(MKNode *node) { MKNode *lroot = root; if(root != NULL){ while(lroot->next != NULL) lroot = lroot->next; lroot->next = node; }else root = node; lroot = NULL; mkfree(lroot); }
void Insert_Spline_Entry(SPLINE * sp, DBL p, EXPRESS v) { int i, k; /* Reset the Coeffs_Computed flag. Inserting a new point invalidates * pre-computed coefficients */ sp->Coeffs_Computed = false; sp->Cache_Valid = false; /* If all space is used, reallocate */ if(sp->Number_Of_Entries >= sp->Max_Entries) { sp->Max_Entries += INIT_SPLINE_SIZE; sp->SplineEntries = (SPLINE_ENTRY *)POV_REALLOC(sp->SplineEntries, sp->Max_Entries * sizeof(SPLINE_ENTRY), "Temporary Spline Entries"); for (i = sp->Number_Of_Entries; i < sp->Max_Entries; i++) { sp->SplineEntries[i].par=-1e6; } } i = findt(sp, p); /* If p is already in spline, replace */ /* The clause after the || is needed because findt returns sp->Number_Of_Entries * if p is greater than OR EQUAL TO the highest par in the spline */ if(sp->Number_Of_Entries != 0 && ((sp->SplineEntries[i].par == p) || (i == sp->Number_Of_Entries && sp->SplineEntries[i-1].par == p))) { for(k=0; k<5; k++) sp->SplineEntries[i].vec[k] = v[k]; } else { mkfree(sp, i); sp->SplineEntries[i].par = p; for(k=0; k<5; k++) sp->SplineEntries[i].vec[k] = v[k]; sp->Number_Of_Entries += 1; } }