/* * Find the user function with the specified name, and return its index. * If the function does not exist, its name is added to the function table * and an error will be generated when it is called if it is still undefined. * * given: * name name of function */ long adduserfunc(char *name) { long index; /* index of function */ index = findstr(&funcnames, name); if (index >= 0) return index; if (funccount >= funcavail) { functions = (FUNC **) realloc(functions, sizeof(FUNC *) * (funcavail + FUNCALLOCSIZE)); if (functions == NULL) { math_error("Failed to reallocate function table"); /*NOTREACHED*/ } funcavail += FUNCALLOCSIZE; } if (addstr(&funcnames, name) == NULL) { math_error("Cannot save function name"); /*NOTREACHED*/ } index = funccount++; functions[index] = NULL; return index; }
/* * Return the value of a constant number given its index. * Returns address of the number, or NULL if the index is illegal * or points to freed position. */ NUMBER * constvalue(unsigned long index) { if (index >= constcount) { math_error("Bad index value for constvalue"); /*NOTREACHED*/ } if (consttable[index]->links == 0) { math_error("Constvalue has been freed!!!"); /*NOTREACHED*/ } return consttable[index]; }
/* * Initialize the table of user defined functions. */ void initfunctions() { initstr(&funcnames); maxopcodes = OPCODEALLOCSIZE; functemplate = (FUNC *) malloc(funcsize(maxopcodes)); if (functemplate == NULL) math_error("Cannot allocate function template"); functions = (FUNC **) malloc(sizeof(FUNC *) * FUNCALLOCSIZE); if (functions == NULL) math_error("Cannot allocate function table"); funccount = 0; funcavail = FUNCALLOCSIZE; }
/* * hash_init - initialize a hash state * * given: * type - hash type (see hash.h) * state - the state to initialize, or NULL to malloc it * * returns: * initialized state */ HASH * hash_init(int type, HASH *state) { int i; /* * malloc if needed */ if (state == NULL) { state = (HASH *)malloc(sizeof(HASH)); if (state == NULL) { math_error("hash_init: cannot malloc HASH"); /*NOTREACHED*/ } } /* * clear hash value */ memset((void*)state, 0, sizeof(HASH)); state->bytes = TRUE; /* * search for the hash_setup function */ for (i=0; htbl[i].init_state != NULL; ++i) { /* if we found the state that we were looking for */ if (type == htbl[i].type) { /* initialize state and return */ (htbl[i].init_state)(state); /* firewall - MAX_CHUNKSIZE must be >= chunksize */ if (state->chunksize > MAX_CHUNKSIZE) { math_error( "internal error: MAX_CHUNKSIZE is too small"); /*NOTREACHED*/ } return state; } } /* * no such hash state */ math_error("internal error: hash type not found in htbl[]"); return NULL; }
// log(x[, base]) STATIC mp_obj_t mp_math_log(size_t n_args, const mp_obj_t *args) { mp_float_t x = mp_obj_get_float(args[0]); if (x <= (mp_float_t)0.0) { math_error(); } mp_float_t l = MICROPY_FLOAT_C_FUN(log)(x); if (n_args == 1) { return mp_obj_new_float(l); } else { mp_float_t base = mp_obj_get_float(args[1]); if (base <= (mp_float_t)0.0) { math_error(); } return mp_obj_new_float(l / MICROPY_FLOAT_C_FUN(log)(base)); } }
/* * Copy an object value */ OBJECT * objcopy(OBJECT *op) { VALUE *v1, *v2; OBJECT *np; int i; i = op->o_actions->oa_count; if (i < USUAL_ELEMENTS) i = USUAL_ELEMENTS; if (i == USUAL_ELEMENTS) np = (OBJECT *) malloc(sizeof(OBJECT)); else np = (OBJECT *) malloc(objectsize(i)); if (np == NULL) { math_error("Cannot allocate object"); /*NOTREACHED*/ } np->o_actions = op->o_actions; v1 = op->o_table; v2 = np->o_table; for (i = op->o_actions->oa_count; i-- > 0; v1++, v2++) { if (v1->v_type == V_NUM) { v2->v_num = qlink(v1->v_num); v2->v_type = V_NUM; } else { copyvalue(v1, v2); } v2->v_subtype = V_NOSUBTYPE; } return np; }
/* * Note that on a 486, we don't want to do a SIGFPE on a irq13 * as the irq is unreliable, and exception 16 works correctly * (ie as explained in the intel literature). On a 386, you * can't use exception 16 due to bad IBM design, so we have to * rely on the less exact irq13. * * Careful.. Not only is IRQ13 unreliable, but it is also * leads to races. IBM designers who came up with it should * be shot. */ static void math_error_irq(int cpl, struct pt_regs *regs) { outb(0,0xF0); if (ignore_irq13 || !hard_math) return; math_error(); }
/* * Note that on a 486, we don't want to do a SIGFPE on a irq13 * as the irq is unreliable, and exception 16 works correctly * (ie as explained in the intel litterature). On a 386, you * can't use exception 16 due to bad IBM design, so we have to * rely on the less exact irq13. * * Careful.. Not only is IRQ13 unreliable, but it is also * leads to races. IBM designers who came up with it should * be shot. */ static void math_error_irq(int cpl) { outb(0,0xF0); if (ignore_irq13) return; math_error(); }
/* * Free memory used to store function and its constants */ void freefunc(FUNC *fp) { long index; unsigned long i; if (fp == NULL) return; if (fp == curfunc) { index = newindex; } else { for (index = 0; index < funccount; index++) { if (functions[index] == fp) break; } if (index == funccount) { math_error("Bad call to freefunc!!!"); /*NOTREACHED*/ } } if (newname[0] != '*' && (conf->traceflags & TRACE_FNCODES)) { printf("Freeing function \"%s\"\n",namestr(&funcnames,index)); dumpnames = FALSE; for (i = 0; i < fp->f_opcodecount; ) { printf("%ld: ", i); i += dumpop(&fp->f_opcodes[i]); } } freenumbers(fp); if (fp != functemplate) free(fp); }
/* * Initialize a function for definition. * Newflag is TRUE if we should allocate a new function structure, * instead of the usual overwriting of the template function structure. * The new structure is returned in the global curfunc variable. * * given: * name name of function * newflag TRUE if need new structure */ void beginfunc(char *name, BOOL newflag) { register FUNC *fp; /* current function */ newindex = adduserfunc(name); maxopcodes = OPCODEALLOCSIZE; fp = functemplate; if (newflag) { fp = (FUNC *) malloc(funcsize(maxopcodes)); if (fp == NULL) { math_error("Cannot allocate temporary function"); /*NOTREACHED*/ } } fp->f_next = NULL; fp->f_localcount = 0; fp->f_opcodecount = 0; fp->f_savedvalue.v_type = V_NULL; fp->f_savedvalue.v_subtype = V_NOSUBTYPE; newname = namestr(&funcnames, newindex); fp->f_name = newname; curfunc = fp; initlocals(); initlabels(); oldop = OP_NOP; oldoldop = OP_NOP; debugline = 0; errorcount = 0; }
/* * Copy an object value */ OBJECT * objcopy(OBJECT *op) { VALUE *v1, *v2; OBJECT *np; int i; i = op->o_actions->oa_count; if (i < USUAL_ELEMENTS) i = USUAL_ELEMENTS; if (i == USUAL_ELEMENTS) np = (OBJECT *) malloc(sizeof(OBJECT)); else np = (OBJECT *) malloc(objectsize(i)); if (np == NULL) { math_error("Cannot allocate object"); /*NOTREACHED*/ } np->o_actions = op->o_actions; v1 = op->o_table; v2 = np->o_table; for (i = op->o_actions->oa_count; i-- > 0; v1++, v2++) { copyvalue(v1, v2); } return np; }
static irqreturn_t math_error_irq(int cpl, void *dev_id) { outb(0, 0xF0); if (ignore_fpu_irq || !boot_cpu_data.hard_math) return IRQ_NONE; math_error(get_irq_regs(), 0, X86_TRAP_MF); return IRQ_HANDLED; }
static irqreturn_t math_error_irq(int cpl, void *dev_id) { outb(0, 0xF0); if (ignore_fpu_irq || !boot_cpu_data.hard_math) return IRQ_NONE; math_error((void __user *)get_irq_regs()->ip); return IRQ_HANDLED; }
/*ARGSUSED*/ VALUE custom(char *name, int count, VALUE **vals) { #if defined(CUSTOM) CONST struct custom *p; /* current function */ /* * search the custom interface table for a function */ for (p = cust; p->name != NULL; ++p) { /* look for the first match */ if (strcmp(name, p->name) == 0) { /* arg count check */ if (count < p->minargs) { math_error("Too few arguments for custom " "function \"%s\"", p->name); /*NOTREACHED*/ } if (count > p->maxargs) { math_error("Too many arguments for custom " "function \"%s\"", p->name); /*NOTREACHED*/ } /* call the custom function */ return p->func(name, count, vals); } } /* * no such custom function */ return error_value(E_UNK_CUSTOM); #else /* CUSTOM */ fprintf(stderr, "%sCalc was built with custom functions disabled\n", (conf->tab_ok ? "\t" : "")); return error_value(E_NO_CUSTOM); #endif /* CUSTOM */ }
/* * Find a function structure given its index. */ FUNC * findfunc(long index) { if (index >= funccount) { math_error("Undefined function"); /*NOTREACHED*/ } return functions[index]; }
void freeconstant(unsigned long index) { NUMBER *q; if (index >= constcount) { math_error("Bad index value for freeconst"); /*NOTREACHED*/ } q = consttable[index]; if (q->links == 0) { math_error("Attempting to free freed const location"); /*NOTREACHED*/ } qfree(q); if (index == constcount - 1) { trimconstants(); } }
/* * Commit the just defined function for use. * This replaces any existing definition for the function. * This should only be called for normal user-defined functions. */ void endfunc(void) { register FUNC *fp; /* function just finished */ unsigned long size; /* size of just created function */ unsigned long index; if (oldop != OP_RETURN) { addop(OP_UNDEF); addop(OP_RETURN); } checklabels(); if (errorcount) { printf("\"%s\": %ld error%s\n", newname, errorcount, ((errorcount == 1) ? "" : "s")); return; } size = funcsize(curfunc->f_opcodecount); fp = (FUNC *) malloc(size); if (fp == NULL) { math_error("Cannot commit function"); /*NOTREACHED*/ } memcpy((char *) fp, (char *) curfunc, size); if (curfunc != functemplate) free(curfunc); if (newname[0] != '*' && (conf->traceflags & TRACE_FNCODES)) { dumpnames = TRUE; for (size = 0; size < fp->f_opcodecount; ) { printf("%ld: ", (long)size); size += dumpop(&fp->f_opcodes[size]); } } if ((inputisterminal() && conf->resource_debug & RSCDBG_STDIN_FUNC) || (!inputisterminal() && conf->resource_debug & RSCDBG_FILE_FUNC)) { printf("%s(", newname); for (index = 0; index < fp->f_paramcount; index++) { if (index) putchar(','); printf("%s", paramname(index)); } printf(") "); if (functions[newindex]) printf("re"); printf("defined\n"); } if (functions[newindex]) { freenumbers(functions[newindex]); free(functions[newindex]); } functions[newindex] = fp; }
dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code) { conditional_sti(regs); #ifdef CONFIG_X86_32 ignore_fpu_irq = 1; #else if (!user_mode(regs) && kernel_math_error(regs, "kernel x87 math error", 16)) return; #endif math_error((void __user *)regs->ip); }
/* * Allocate a new object structure with the specified index. */ OBJECT * objalloc(long index) { OBJECTACTIONS *oap; OBJECT *op; VALUE *vp; int i; if (index < 0 || index > maxobjcount) { math_error("Allocating bad object index"); /*NOTREACHED*/ } oap = objects[index]; if (oap == NULL) { math_error("Object type not defined"); /*NOTREACHED*/ } i = oap->oa_count; if (i < USUAL_ELEMENTS) i = USUAL_ELEMENTS; if (i == USUAL_ELEMENTS) op = (OBJECT *) malloc(sizeof(OBJECT)); else op = (OBJECT *) malloc(objectsize(i)); if (op == NULL) { math_error("Cannot allocate object"); /*NOTREACHED*/ } op->o_actions = oap; vp = op->o_table; for (i = oap->oa_count; i-- > 0; vp++) { vp->v_num = qlink(&_qzero_); vp->v_type = V_NUM; vp->v_subtype = V_NOSUBTYPE; } return op; }
/* * Allocate a new complex number. */ COMPLEX * comalloc(void) { COMPLEX *r; r = (COMPLEX *) malloc(sizeof(COMPLEX)); if (r == NULL) { math_error("Cannot allocate complex number"); /*NOTREACHED*/ } r->links = 1; r->real = qlink(&_qzero_); r->imag = qlink(&_qzero_); return r; }
void initconstants(void) { int i; consttable = (NUMBER **) malloc(sizeof(NUMBER *) * CONSTALLOCSIZE); if (consttable == NULL) { math_error("Unable to allocate constant table"); /*NOTREACHED*/ } for (i = 0; i < INITCONSTCOUNT; i++) consttable[i] = initnumbs[i]; consttable[INITCONSTCOUNT] = NULL; /* firewall */ constcount = INITCONSTCOUNT; constavail = CONSTALLOCSIZE - INITCONSTCOUNT; }
static PyObject * math_1(PyObject *args, Py_complex (*func)(Py_complex)) { Py_complex x; if (!PyArg_ParseTuple(args, "D", &x)) return NULL; errno = 0; PyFPE_START_PROTECT("complex function", return 0) x = (*func)(x); PyFPE_END_PROTECT(x) Py_ADJUST_ERANGE2(x.real, x.imag); if (errno != 0) return math_error(); else return PyComplex_FromCComplex(x); }
/* * Define a (possibly) new element name for an object. * Returns an index which identifies the element name. */ int addelement(char *name) { STRINGHEAD *hp; int index; hp = &elements; if (hp->h_list == NULL) initstr(hp); index = findstr(hp, name); if (index >= 0) return index; if (addstr(hp, name) == NULL) { math_error("Cannot allocate element name"); /*NOTREACHED*/ } return findstr(hp, name); }
/*ARGSUSED*/ void customhelp(char *name) { #if defined(CUSTOM) char *customname; /* a string of the form: custom/name */ /* * firewall */ if (name == NULL) { name = "help"; } /* * form the custom help name */ customname = (char *)malloc(sizeof("custhelp")+strlen(name)+1); if (customname == NULL) { math_error("bad malloc of customname"); /*NOTREACHED*/ } sprintf(customname, "custhelp/%s", name); /* * give help directly to the custom file */ givehelp(customname); /* * all done */ free(customname); #else /* CUSTOM */ fprintf(stderr, "%sCalc was built with custom functions disabled\n", (conf->tab_ok ? "\t" : "")); #endif /* CUSTOM */ }
/* * hash_copy - copy a hash state * * given: * state - the state to copy * * returns: * pointer to copy of state */ HASH * hash_copy(HASH *state) { HASH *hnew; /* copy of state */ /* * malloc new state */ hnew = (HASH *)malloc(sizeof(HASH)); if (hnew == NULL) { math_error("hash_init: cannot malloc HASH"); /*NOTREACHED*/ } /* * duplicate state */ memcpy((void *)hnew, (void *)state, sizeof(HASH)); return hnew; }
static PyObject * cmath_log(PyObject *self, PyObject *args) { Py_complex x; Py_complex y; if (!PyArg_ParseTuple(args, "D|D", &x, &y)) return NULL; errno = 0; PyFPE_START_PROTECT("complex function", return 0) x = c_log(x); if (PyTuple_GET_SIZE(args) == 2) x = c_quot(x, c_log(y)); PyFPE_END_PROTECT(x) if (errno != 0) return math_error(); Py_ADJUST_ERANGE2(x.real, x.imag); return PyComplex_FromCComplex(x); }
/* * Divide a complex number by a real number. */ COMPLEX * cdivq(COMPLEX *c, NUMBER *q) { COMPLEX *r; if (qiszero(q)) { math_error("Division by zero"); /*NOTREACHED*/ } if (qisone(q)) return clink(c); if (qisnegone(q)) return cneg(c); r = comalloc(); qfree(r->real); qfree(r->imag); r->real = qqdiv(c->real, q); r->imag = qqdiv(c->imag, q); return r; }
/* * To store in a table a static variable whose scope is being ended */ void addstatic(GLOBAL *sp) { GLOBAL **stp; if (staticavail <= 0) { if (staticcount <= 0) stp = (GLOBAL **) malloc(20 * sizeof(GLOBAL *)); else stp = (GLOBAL **) realloc(statictable, (20 + staticcount) * sizeof(GLOBAL *)); if (stp == NULL) { math_error("Cannot allocate static-variable table"); /*NOTREACHED*/ } statictable = stp; staticavail = 20; } statictable[staticcount++] = sp; staticavail--; }
/* * Invert a complex number. */ COMPLEX * cinv(COMPLEX *c) { COMPLEX *r; NUMBER *q1, *q2, *den; if (ciszero(c)) { math_error("Inverting zero"); /*NOTREACHED*/ } r = comalloc(); if (cisreal(c)) { qfree(r->real); r->real = qinv(c->real); return r; } if (cisimag(c)) { q1 = qinv(c->imag); qfree(r->imag); r->imag = qneg(q1); qfree(q1); return r; } q1 = qsquare(c->real); q2 = qsquare(c->imag); den = qqadd(q1, q2); qfree(q1); qfree(q2); qfree(r->real); r->real = qqdiv(c->real, den); q1 = qqdiv(c->imag, den); qfree(r->imag); r->imag = qneg(q1); qfree(q1); qfree(den); return r; }
/* * hash_value - hash a value * * given: * type - hash type (see hash.h) * v - the value * state - the state to hash or NULL * * returns: * the new state */ HASH * hash_value(int type, void *v, HASH *state) { LISTELEM *ep; /* list element pointer */ ASSOCELEM **assochead; /* association chain head */ ASSOCELEM *aep; /* current association value */ ASSOCELEM *nextaep; /* next association value */ VALUE *value = (VALUE *)v; /* v cast to a VALUE */ VALUE *vp; /* pointer to next OBJ table value */ ZVALUE fileval; /* size, position, dev, inode of a file */ int i; /* * initialize if state is NULL */ if (state == NULL) { state = hash_init(type, NULL); } /* * process the value type */ switch (value->v_type) { case V_NULL: (state->chkpt)(state); state->bytes = TRUE; break; case V_INT: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash as if we have a 64 bit value */ state = hash_int(type, value->v_int, state); break; case V_NUM: /* hash this type */ state = hash_number(type, value->v_num, state); break; case V_COM: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash this type */ state = hash_complex(type, value->v_com, state); break; case V_ADDR: /* there is nothing to setup, simply hash what we point at */ state = hash_value(type, value->v_addr, state); break; case V_STR: /* strings have no setup */ /* hash this type */ state = hash_STR(type, value->v_str, state); break; case V_MAT: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); state->bytes = TRUE; /* hash all the elements of the matrix */ for (i=0; i < value->v_mat->m_size; ++i) { /* hash the next matrix value */ state = hash_value(type, value->v_mat->m_table+i, state); state->bytes = FALSE; /* as if reading words */ } break; case V_LIST: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash all the elements of the list */ for (i=0, ep = value->v_list->l_first; ep != NULL && i < value->v_list->l_count; ++i, ep = ep->e_next) { /* hash the next list value */ state = hash_value(type, &ep->e_value, state); state->bytes = FALSE; /* as if reading words */ } break; case V_ASSOC: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); state->bytes = TRUE; /* hash the association */ assochead = value->v_assoc->a_table; for (i = 0; i < value->v_assoc->a_size; i++) { nextaep = *assochead; while (nextaep) { aep = nextaep; nextaep = aep->e_next; /* hash the next association value */ state = hash_value(type, &aep->e_value, state); state->bytes = FALSE; /* as if reading words */ } assochead++; } break; case V_OBJ: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); state->bytes = TRUE; /* reading bytes */ /* hash the object name and then the element values */ state = hash_str(type, objtypename( value->v_obj->o_actions->oa_index), state); (state->chkpt)(state); for (i=value->v_obj->o_actions->oa_count, vp=value->v_obj->o_table; i-- > 0; vp++) { /* hash the next object value */ state = hash_value(type, vp, state); state->bytes = FALSE; /* as if reading words */ } break; case V_FILE: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash file length if possible */ if (getsize(value->v_file, &fileval) == 0) { state = hash_zvalue(type, fileval, state); zfree(fileval); } else { /* hash -1 for invalid length */ state = hash_long(type, (long)-1, state); } /* hash the file position if possible */ if (getloc(value->v_file, &fileval) == 0) { state = hash_zvalue(type, fileval, state); zfree(fileval); } else { /* hash -1 for invalid location */ state = hash_long(type, (long)-1, state); } /* hash the file device if possible */ if (get_device(value->v_file, &fileval) == 0) { state = hash_zvalue(type, fileval, state); zfree(fileval); } else { /* hash -1 for invalid device */ state = hash_long(type, (long)-1, state); } /* hash the file inode if possible */ if (get_inode(value->v_file, &fileval) == 0) { state = hash_zvalue(type, fileval, state); zfree(fileval); } else { /* hash -1 for invalid inode */ state = hash_long(type, (long)-1, state); } break; case V_RAND: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash the RAND state */ state = hash_int(type, value->v_rand->seeded, state); state = hash_int(type, value->v_rand->bits, state); (state->update)(state, (USB8 *)value->v_rand->buffer, SLEN*FULL_BITS/8); state = hash_int(type, value->v_rand->j, state); state = hash_int(type, value->v_rand->k, state); state = hash_int(type, value->v_rand->need_to_skip, state); (state->update)(state, (USB8 *)value->v_rand->slot, SCNT*FULL_BITS/8); (state->update)(state, (USB8*)value->v_rand->shuf, SHUFLEN*FULL_BITS/8); state->bytes = FALSE; /* as if reading words */ break; case V_RANDOM: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash the RANDOM state */ state = hash_int(type, value->v_random->seeded, state); state = hash_int(type, value->v_random->bits, state); (state->update)(state, (USB8 *)&(value->v_random->buffer), BASEB/8); state = hash_zvalue(type, value->v_random->r, state); state = hash_zvalue(type, value->v_random->n, state); state->bytes = FALSE; /* as if reading words */ break; case V_CONFIG: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash the CONFIG state */ state = hash_int(type, value->v_config->outmode, state); state = hash_int(type, value->v_config->outmode2, state); state = hash_long(type,(long)value->v_config->outdigits, state); state = hash_number(type, value->v_config->epsilon, state); state = hash_long(type, (long)value->v_config->epsilonprec, state); state = hash_flag(type, value->v_config->traceflags, state); state = hash_long(type, (long)value->v_config->maxprint, state); state = hash_len(type, value->v_config->mul2, state); state = hash_len(type, value->v_config->sq2, state); state = hash_len(type, value->v_config->pow2, state); state = hash_len(type, value->v_config->redc2, state); state = hash_bool(type, value->v_config->tilde_ok, state); state = hash_bool(type, value->v_config->tab_ok, state); state = hash_long(type, (long)value->v_config->quomod, state); state = hash_long(type, (long)value->v_config->quo, state); state = hash_long(type, (long)value->v_config->mod, state); state = hash_long(type, (long)value->v_config->sqrt, state); state = hash_long(type, (long)value->v_config->appr, state); state = hash_long(type, (long)value->v_config->cfappr, state); state = hash_long(type, (long)value->v_config->cfsim, state); state = hash_long(type, (long)value->v_config->outround, state); state = hash_long(type, (long)value->v_config->round, state); state = hash_bool(type, value->v_config->leadzero, state); state = hash_bool(type, value->v_config->fullzero, state); state = hash_long(type, (long)value->v_config->maxscancount, state); state = hash_str(type, value->v_config->prompt1, state); state->bytes = FALSE; /* as if just read words */ state = hash_str(type, value->v_config->prompt2, state); state->bytes = FALSE; /* as if just read words */ state = hash_int(type, value->v_config->blkmaxprint, state); state = hash_bool(type, value->v_config->blkverbose, state); state = hash_int(type, value->v_config->blkbase, state); state = hash_int(type, value->v_config->blkfmt, state); state = hash_long(type, (long)value->v_config->resource_debug, state); state = hash_long(type, (long)value->v_config->calc_debug, state); state = hash_long(type, (long)value->v_config->user_debug, state); state = hash_bool(type, value->v_config->verbose_quit, state); state = hash_int(type, value->v_config->ctrl_d, state); state = hash_str(type, value->v_config->program, state); state = hash_str(type, value->v_config->base_name, state); state = hash_bool(type, value->v_config->windows, state); state = hash_bool(type, value->v_config->cygwin, state); state = hash_bool(type, value->v_config->compile_custom, state); if (value->v_config->allow_custom != NULL && *(value->v_config->allow_custom)) { state = hash_bool(type, TRUE, state); } else { state = hash_bool(type, FALSE, state); } state = hash_str(type, value->v_config->version, state); state = hash_int(type, value->v_config->baseb, state); state = hash_bool(type, value->v_config->redecl_warn, state); state = hash_bool(type, value->v_config->dupvar_warn, state); break; case V_HASH: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash the HASH state */ state = hash_int(type, value->v_hash->type, state); state = hash_bool(type, value->v_hash->bytes,state); state = hash_int(type, value->v_hash->base, state); state = hash_int(type, value->v_hash->chunksize, state); state = hash_int(type, value->v_hash->unionsize, state); (state->update)(state, value->v_hash->h_union.data, state->unionsize); state->bytes = FALSE; /* as if reading words */ break; case V_BLOCK: /* there is no setup for a BLOCK */ /* hash the octets in the BLOCK */ if (value->v_block->datalen > 0) { state = hash_usb8(type, value->v_block->data, value->v_block->datalen, state); } break; case V_OCTET: /* there is no setup for an OCTET */ /* hash the OCTET */ state = hash_usb8(type, value->v_octet, 1, state); break; case V_NBLOCK: /* there is no setup for a NBLOCK */ /* hash the octets in the NBLOCK */ if (value->v_nblock->blk->datalen > 0) { state = hash_usb8(type, value->v_nblock->blk->data, value->v_nblock->blk->datalen, state); } break; default: math_error("hashing an unknown value"); /*NOTREACHED*/ } return state; }