rem
stringlengths 0
83.5k
| add
stringlengths 0
223k
| context
stringlengths 10
471k
| meta
stringlengths 120
236
|
---|---|---|---|
lx=lg(x); if (lx!=lg(x[1])) err(mattype1,"gtrace"); if (lx==1) return gzero;/*now lx>=2*/ | lx=lg(x); if (lx==1) return gzero;/*now lx>=2*/ if (lx!=lg(x[1])) err(mattype1,"gtrace"); | gtrace(GEN x){ long i,l,n,tx=typ(x),lx,tetpil; GEN y,p1,p2; switch(tx) { case t_INT: case t_REAL: case t_FRAC: case t_FRACN: return gmul2n(x,1); case t_COMPLEX: return gmul2n((GEN)x[1],1); case t_QUAD: p1=(GEN)x[1]; if (!gcmp0((GEN) p1[3])) { l=avma; p2=gmul2n((GEN)x[2],1); tetpil=avma; return gerepile(l,tetpil,gadd((GEN)x[3],p2)); } return gmul2n((GEN)x[2],1); case t_POL: lx=lgef(x); y=cgetg(lx,tx); y[1]=x[1]; for (i=2; i<lx; i++) y[i]=ltrace((GEN)x[i]); return y; case t_SER: lx=lg(x); y=cgetg(lx,tx); y[1]=x[1]; for (i=2; i<lx; i++) y[i]=ltrace((GEN)x[i]); return y; case t_POLMOD: l=avma; n=(lgef(x[1])-4); p1=polsym((GEN)x[1],n); p2=gzero; for (i=0; i<=n; i++) p2=gadd(p2,gmul(truecoeff((GEN)x[2],i),(GEN)p1[i+1])); return gerepileupto(l,p2); case t_RFRAC: case t_RFRACN: return gadd(x,gconj(x)); case t_VEC: case t_COL: lx=lg(x); y=cgetg(lx,tx); for (i=1; i<lx; i++) y[i]=ltrace((GEN)x[i]); return y; case t_MAT: lx=lg(x); if (lx!=lg(x[1])) err(mattype1,"gtrace"); if (lx==1) return gzero;/*now lx>=2*/ l=avma; p1=gcoeff(x,1,1); if (lx==2) return gcopy(p1); for (i=2; i<lx-1; i++) p1=gadd(p1,gcoeff(x,i,i)); tetpil=avma; return gerepile(l,tetpil,gadd(p1,gcoeff(x,i,i))); } err(typeer,"gtrace"); return NULL; /* not reached */} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/63bc2786542482ff71839b462010206e67ec0b53/alglin2.c/buggy/src/basemath/alglin2.c |
case 12: /* checkrnf(x); */ return (GEN)x[11]; case 6: /* rnf[11]. FIXME: change the rnf struct */ | case 14: /* checkrnf(x); */ return (GEN)x[11]; | _checkrnfeq(GEN x){ if (typ(x) == t_VEC) switch(lg(x)) { case 12: /* checkrnf(x); */ return (GEN)x[11]; case 6: /* rnf[11]. FIXME: change the rnf struct */ case 4: return x; } return NULL;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59f511650949bd335c0ea3ba14f6dd6ce94d3308/base5.c/clean/src/basemath/base5.c |
unsigned int ret, noparen, has_pointer=0; | unsigned int ret, noparen, ind_pointer=0; | identifier(void){ long m, i, matchcomma, deriv; pari_sp av; char *ch1; entree *ep; GEN res, newfun, ptr; mark.identifier = analyseur; ep = entry(); if (EpVALENCE(ep)==EpVAR || EpVALENCE(ep)==EpGVAR) { /* optimized for simple variables */ switch (*analyseur) { case ')': case ',': return (GEN)ep->value; case '.': { long len, v; analyseur++; ch1 = analyseur; if ((res = read_member((GEN)ep->value))) { if (*analyseur == '[') { matcomp c; res = matcell(res, &c); } return res; } /* define a new member function */ v = varn(initial_value(ep)); len = analyseur - ch1; analyseur++; /* skip = */ ep = installep(NULL,ch1,len,EpMEMBER,0, members_hash + hashvalue(ch1)); ch1 = analyseur; skipseq(); len = analyseur-ch1; newfun=ptr= (GEN) newbloc(2 + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ *newfun++ = v; /* record text */ strncpy((char *)newfun, ch1, len); ((char *) newfun)[len] = 0; ep->value = (void *)ptr; return gnil; } } if (*analyseur != '[') { /* whole variable, no component */ F2GEN fun = affect_block(&res); if (res) { if (fun) res = fun((GEN)ep->value, res); changevalue(ep,res); } return (GEN)ep->value; } return matrix_block((GEN)ep->value); } ep = do_alias(ep);#ifdef STACK_CHECK if (PARI_stack_limit && (void*) &ptr <= PARI_stack_limit) err(talker2, "deep recursion", mark.identifier, mark.start);#endif if (ep->code) { char *s = ep->code, *oldanalyseur = NULL, *buf, *limit, *bp; unsigned int ret, noparen, has_pointer=0; long fake; void *call = ep->value; GEN argvec[9]; matcomp *init[9]; char *flags = NULL; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; if (*analyseur == '(') { analyseur++; noparen=0; /* expect matching ')' */ } else { /* if no mandatory argument, no () needed */ if (EpVALENCE(ep)) match('('); /* error */ if (!*s || (!s[1] && *s == 'p')) return ((GEN (*)(long))call)(prec); noparen=1; /* no argument, but valence is ok */ } /* return type */ if (*s < 'a') ret = RET_GEN; else if (*s == 'v') { ret = RET_VOID; s++; } else if (*s == 'i') { ret = RET_INT; s++; } else if (*s == 'l') { ret = RET_LONG; s++; } else ret = RET_GEN; /* Optimized for G and p. */ i = 0; matchcomma = 0; while (*s == 'G') { s++; match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); } if (*s == 'p') { argvec[i++] = (GEN) prec; s++; } while (*s && *s != '\n') switch (*s++) { case 'G': /* GEN */ match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); break; case 'L': /* long */ match_comma(); argvec[i++] = (GEN) readlong(); break; case 'n': /* var number */ match_comma(); argvec[i++] = (GEN) readvar(); break; case 'S': /* symbol */ match_comma(); mark.symbol=analyseur; argvec[i++] = (GEN)entry(); break; case 'V': /* variable */ match_comma(); mark.symbol=analyseur; { entree *e = entry(); long v = EpVALENCE(e); if (v != EpVAR && v != EpGVAR) err(talker2,"not a variable:",mark.symbol,mark.start); argvec[i++] = (GEN)e; break; } case '&': /* *GEN */ match_comma(); match('&'); mark.symbol=analyseur; { matcomp *c = (matcomp*)malloc(sizeof(matcomp)); entree *ep = entry(); if (*analyseur == '[') (void)matcell((GEN)ep->value, c); else { c->parent = NULL; c->ptcell = (GEN*)&ep->value; c->extra = (GEN*)ep->value; } has_pointer |= (1 << i); init[i] = c; argvec[i++] = (GEN)c->ptcell; break; } /* Input position */ case 'E': /* expr */ case 'I': /* seq */ match_comma(); argvec[i++] = (GEN) analyseur; skipseq(); break; case 'r': /* raw */ match_comma(); mark.raw = analyseur; bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; if (*analyseur == '"') bp = readstring_i(bp, &buf,&limit); else { if (bp > limit) bp = realloc_buf(bp,1, &buf,&limit); *bp++ = *analyseur++; } } *bp++ = 0; argvec[i++] = (GEN) buf; break; case 'M': /* Mnemonic flag */ match_comma(); ch1 = analyseur; argvec[i] = expr(); NO_BREAK("here (reading arguments)", ch1); if (typ(argvec[i]) == t_STR) { if (!flags) flags = ep->code; flags = strchr(flags, '\n'); /* Skip to the following '\n' */ if (!flags) err(talker, "not enough flags in string function signature"); flags++; argvec[i] = (GEN) parse_option_string((char*)(argvec[i] + 1), flags, PARSEMNU_ARG_WHITESP | PARSEMNU_TEMPL_TERM_NL, NULL, NULL); } else argvec[i] = (GEN)itos(argvec[i]); i++; break; case 's': /* expanded string; empty arg yields "" */ match_comma(); if (*s == '*') /* any number of string objects */ { argvec[i++] = any_string(); s++; break; } bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; bp = expand_string(bp, &buf,&limit); } *bp++ = 0; argvec[i++] = (GEN)buf; break; case 'p': /* precision */ argvec[i++] = (GEN) prec; break; case '=': match('='); matchcomma = 0; break; case 'D': /* Has a default value */ if (do_switch(noparen,matchcomma)) switch (*s) { case 'G': case '&': case 'I': case 'V': matchcomma=1; argvec[i++]=DFT_GEN; s++; break; case 'n': matchcomma=1; argvec[i++]=DFT_VAR; s++; break; default: oldanalyseur = analyseur; analyseur = s; matchcomma = 0; while (*s++ != ','); } else switch (*s) { case 'G': case '&': case 'I': case 'V': case 'n': break; default: while (*s++ != ','); } break; case 'P': /* series precision */ argvec[i++] = (GEN) precdl; break; case 'f': /* Fake *long argument */ argvec[i++] = (GEN) &fake; break; case 'x': /* Foreign function */ argvec[i++] = (GEN) ep; call = foreignHandler; break; case ',': /* Clean up default */ if (oldanalyseur) { analyseur = oldanalyseur; oldanalyseur = NULL; matchcomma=1; } break; default: err(bugparier,"identifier (unknown code)"); }#if 0 /* uncomment if using purify: UMR otherwise */ for ( ; i<9; i++) argvec[i]=NULL;#endif{ char *oldname = gp_function_name; gp_function_name = ep->name; if (deriv) { if (!i || (ep->code)[0] != 'G') err(talker2, "can't derive this", mark.identifier, mark.start); res = num_deriv(call, argvec); } else switch (ret) { case RET_GEN: res = ((PFGEN)call)(_ARGS_); break; case RET_INT: m = (long)((int (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_LONG: m = ((long (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_VOID: ((void (*)(ANYARG))call)(_ARGS_); res = gnil; break; } gp_function_name = oldname;} if (has_pointer) check_pointers(has_pointer,init); if (!noparen) match(')'); return res; } if (EpPREDEFINED(ep)) { if (*analyseur != '(') { if (EpVALENCE(ep) == 88) return global0(); match('('); /* error */ } analyseur++; ch1 = analyseur; switch(EpVALENCE(ep)) { case 50: /* O */ res = truc(); NO_BREAK("in O()", ch1); if (*analyseur=='^') { analyseur++; m = readlong(); } else m = 1; res = ggrando(res,m); break; case 80: /* if then else */ av = avma; res = expr(); NO_BREAK("in test expression", ch1); m = gcmp0(res); avma = av; match(','); if (m) /* false */ { skipseq(); if (*analyseur == ')') res = gnil; else { match(','); res = seq(); if (br_status) { res = NULL; skipseq(); } } } else /* true */ { res = seq(); if (br_status) { res = NULL; skipseq(); } if (*analyseur != ')') { match(','); skipseq(); } } break; case 81: /* while do */ av = avma; for(;;) { res = expr(); NO_BREAK("in test expression", ch1); if (gcmp0(res)) { match(','); break; } avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; } avma = av; skipseq(); res = gnil; break; case 82: /* repeat until */ av = avma; skipexpr(); for(;;) { avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; res = expr(); NO_BREAK("in test expression", ch1); if (!gcmp0(res)) { match(','); break; } } avma = av; skipseq(); res = gnil; break; case 88: /* global */ if (*analyseur == ')') return global0(); matchcomma = 0; while (*analyseur != ')') { match_comma(); ch1 = analyseur; check_var_name(); ep = skipentry(); switch(EpVALENCE(ep)) { case EpGVAR: case EpVAR: break; default: err(talker2,"symbol already in use",ch1,mark.start); } analyseur = ch1; ep = entry(); if (*analyseur == '=') { pari_sp av=avma; analyseur++; ch1 = analyseur; res = expr(); NO_BREAK("here (defining global var)", ch1); changevalue(ep, res); avma=av; } ep->valence = EpGVAR; } res = gnil; break; default: err(valencer1); return NULL; /* not reached */ } match(')'); return res; } switch (EpVALENCE(ep)) { GEN *defarg; /* = default args, and values for local variables */ GEN *arglist; gp_args *f; case EpUSER: /* user-defined functions */ f = (gp_args*)ep->args; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; arglist = (GEN*) new_chunk(f->narg); if (*analyseur != '(') /* no args */ { if (*analyseur != '=' || analyseur[1] == '=') { for (i=0; i<f->narg; i++) arglist[i] = make_arg(f->arg[i]); return call_fun((GEN)ep->value, arglist, f); } match('('); /* ==> error */ } analyseur++; /* skip '(' */ ch1 = analyseur; skip_arg_block(f); if (*analyseur == ')' && (analyseur[1] != '=' || analyseur[2] == '=')) { matchcomma = 0; analyseur = ch1; for (i=0; i<f->narg; i++) { if (do_switch(0,matchcomma)) { /* default arg */ arglist[i] = make_arg(f->arg[i]); matchcomma = 1; } else { /* user supplied */ char *old; match_comma(); old = analyseur; arglist[i] = expr(); NO_BREAK("here (reading function args)", old); } } analyseur++; /* skip ')' */ if (deriv) { if (!f->narg) err(talker2, "can't derive this", mark.identifier, mark.start); return num_derivU((GEN)ep->value, arglist, f); } return call_fun((GEN)ep->value, arglist, f); } /* REDEFINE function */ if (*analyseur != ',' && *analyseur != ')') skipexpr(); while (*analyseur == ',') { analyseur++; skipexpr(); } match(')'); if (*analyseur != '=' || analyseur[1] == '=') err(talker2,"too many parameters in user-defined function call", mark.identifier,mark.start); analyseur = ch1-1; /* points to '(' */ free_args((gp_args*)ep->args); free(ep->args); ep->args = NULL; ep->valence = EpNEW; /* Fall through */ case EpNEW: /* new function */ { GEN tmpargs = (GEN)avma; char *start; long len, narg, nloc; check_new_fun = ep; /* checking arguments */ narg = check_args(); nloc = 0; /* Dirty, but don't want to define a local() function */ if (*analyseur != '=' && strcmp(ep->name, "local") == 0) err(talker2, "local() bloc must appear before any other expression", mark.identifier,mark.start); match('='); { /* checking function definition */ skipping_fun_def++; while (strncmp(analyseur,"local(",6) == 0) { analyseur += 5; /* on '(' */ nloc += check_args(); while(separe(*analyseur)) analyseur++; } start = analyseur; skipseq(); len = analyseur-start; skipping_fun_def--; } /* function is ok. record it */ /* record default args */ f = (gp_args*) gpmalloc((narg+nloc)*sizeof(GEN) + sizeof(gp_args)); ep->args = (void*) f; f->nloc = nloc; f->narg = narg; f->arg = defarg = (GEN*)(f + 1); narg += nloc; /* record default args and local variables */ newfun = ptr = (GEN) newbloc(1 + narg + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ for (i = 1; i <= narg; i++) { GEN cell = tmpargs-(i<<1); *newfun++ = cell[0]; *defarg++ = (GEN)cell[1]; } if (narg > 1) { /* check for duplicates */ GEN x = new_chunk(narg), v = ptr+1; long k; for (i=0; i<narg; i++) x[i] = v[i]; qsort(x,narg,sizeof(long),(QSCOMP)pari_compare_long); for (k=x[0],i=1; i<narg; k=x[i],i++) if (x[i] == k) err(talker,"user function %s: variable %Z declared twice", ep->name, polx[k]); } /* record text */ strncpy((char *)newfun, start, len); ((char *) newfun)[len] = 0; /* wait till here for gunclone because of strncopy above. In pathological * cases, e.g. (f()=f()=x), new text is given by value of old one! */ if (EpVALENCE(ep) == EpUSER) gunclone((GEN)ep->value); ep->value = (void *)ptr; ep->valence = EpUSER; check_new_fun=NULL; avma = (pari_sp)tmpargs; return gnil; } } err(valencer1); return NULL; /* not reached */} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d6bc6f7c8515f98a50f281cca0bb8c335aed5b17/anal.c/clean/src/language/anal.c |
matcomp *init[9]; | gp_pointer ptrs[9]; | identifier(void){ long m, i, matchcomma, deriv; pari_sp av; char *ch1; entree *ep; GEN res, newfun, ptr; mark.identifier = analyseur; ep = entry(); if (EpVALENCE(ep)==EpVAR || EpVALENCE(ep)==EpGVAR) { /* optimized for simple variables */ switch (*analyseur) { case ')': case ',': return (GEN)ep->value; case '.': { long len, v; analyseur++; ch1 = analyseur; if ((res = read_member((GEN)ep->value))) { if (*analyseur == '[') { matcomp c; res = matcell(res, &c); } return res; } /* define a new member function */ v = varn(initial_value(ep)); len = analyseur - ch1; analyseur++; /* skip = */ ep = installep(NULL,ch1,len,EpMEMBER,0, members_hash + hashvalue(ch1)); ch1 = analyseur; skipseq(); len = analyseur-ch1; newfun=ptr= (GEN) newbloc(2 + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ *newfun++ = v; /* record text */ strncpy((char *)newfun, ch1, len); ((char *) newfun)[len] = 0; ep->value = (void *)ptr; return gnil; } } if (*analyseur != '[') { /* whole variable, no component */ F2GEN fun = affect_block(&res); if (res) { if (fun) res = fun((GEN)ep->value, res); changevalue(ep,res); } return (GEN)ep->value; } return matrix_block((GEN)ep->value); } ep = do_alias(ep);#ifdef STACK_CHECK if (PARI_stack_limit && (void*) &ptr <= PARI_stack_limit) err(talker2, "deep recursion", mark.identifier, mark.start);#endif if (ep->code) { char *s = ep->code, *oldanalyseur = NULL, *buf, *limit, *bp; unsigned int ret, noparen, has_pointer=0; long fake; void *call = ep->value; GEN argvec[9]; matcomp *init[9]; char *flags = NULL; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; if (*analyseur == '(') { analyseur++; noparen=0; /* expect matching ')' */ } else { /* if no mandatory argument, no () needed */ if (EpVALENCE(ep)) match('('); /* error */ if (!*s || (!s[1] && *s == 'p')) return ((GEN (*)(long))call)(prec); noparen=1; /* no argument, but valence is ok */ } /* return type */ if (*s < 'a') ret = RET_GEN; else if (*s == 'v') { ret = RET_VOID; s++; } else if (*s == 'i') { ret = RET_INT; s++; } else if (*s == 'l') { ret = RET_LONG; s++; } else ret = RET_GEN; /* Optimized for G and p. */ i = 0; matchcomma = 0; while (*s == 'G') { s++; match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); } if (*s == 'p') { argvec[i++] = (GEN) prec; s++; } while (*s && *s != '\n') switch (*s++) { case 'G': /* GEN */ match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); break; case 'L': /* long */ match_comma(); argvec[i++] = (GEN) readlong(); break; case 'n': /* var number */ match_comma(); argvec[i++] = (GEN) readvar(); break; case 'S': /* symbol */ match_comma(); mark.symbol=analyseur; argvec[i++] = (GEN)entry(); break; case 'V': /* variable */ match_comma(); mark.symbol=analyseur; { entree *e = entry(); long v = EpVALENCE(e); if (v != EpVAR && v != EpGVAR) err(talker2,"not a variable:",mark.symbol,mark.start); argvec[i++] = (GEN)e; break; } case '&': /* *GEN */ match_comma(); match('&'); mark.symbol=analyseur; { matcomp *c = (matcomp*)malloc(sizeof(matcomp)); entree *ep = entry(); if (*analyseur == '[') (void)matcell((GEN)ep->value, c); else { c->parent = NULL; c->ptcell = (GEN*)&ep->value; c->extra = (GEN*)ep->value; } has_pointer |= (1 << i); init[i] = c; argvec[i++] = (GEN)c->ptcell; break; } /* Input position */ case 'E': /* expr */ case 'I': /* seq */ match_comma(); argvec[i++] = (GEN) analyseur; skipseq(); break; case 'r': /* raw */ match_comma(); mark.raw = analyseur; bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; if (*analyseur == '"') bp = readstring_i(bp, &buf,&limit); else { if (bp > limit) bp = realloc_buf(bp,1, &buf,&limit); *bp++ = *analyseur++; } } *bp++ = 0; argvec[i++] = (GEN) buf; break; case 'M': /* Mnemonic flag */ match_comma(); ch1 = analyseur; argvec[i] = expr(); NO_BREAK("here (reading arguments)", ch1); if (typ(argvec[i]) == t_STR) { if (!flags) flags = ep->code; flags = strchr(flags, '\n'); /* Skip to the following '\n' */ if (!flags) err(talker, "not enough flags in string function signature"); flags++; argvec[i] = (GEN) parse_option_string((char*)(argvec[i] + 1), flags, PARSEMNU_ARG_WHITESP | PARSEMNU_TEMPL_TERM_NL, NULL, NULL); } else argvec[i] = (GEN)itos(argvec[i]); i++; break; case 's': /* expanded string; empty arg yields "" */ match_comma(); if (*s == '*') /* any number of string objects */ { argvec[i++] = any_string(); s++; break; } bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; bp = expand_string(bp, &buf,&limit); } *bp++ = 0; argvec[i++] = (GEN)buf; break; case 'p': /* precision */ argvec[i++] = (GEN) prec; break; case '=': match('='); matchcomma = 0; break; case 'D': /* Has a default value */ if (do_switch(noparen,matchcomma)) switch (*s) { case 'G': case '&': case 'I': case 'V': matchcomma=1; argvec[i++]=DFT_GEN; s++; break; case 'n': matchcomma=1; argvec[i++]=DFT_VAR; s++; break; default: oldanalyseur = analyseur; analyseur = s; matchcomma = 0; while (*s++ != ','); } else switch (*s) { case 'G': case '&': case 'I': case 'V': case 'n': break; default: while (*s++ != ','); } break; case 'P': /* series precision */ argvec[i++] = (GEN) precdl; break; case 'f': /* Fake *long argument */ argvec[i++] = (GEN) &fake; break; case 'x': /* Foreign function */ argvec[i++] = (GEN) ep; call = foreignHandler; break; case ',': /* Clean up default */ if (oldanalyseur) { analyseur = oldanalyseur; oldanalyseur = NULL; matchcomma=1; } break; default: err(bugparier,"identifier (unknown code)"); }#if 0 /* uncomment if using purify: UMR otherwise */ for ( ; i<9; i++) argvec[i]=NULL;#endif{ char *oldname = gp_function_name; gp_function_name = ep->name; if (deriv) { if (!i || (ep->code)[0] != 'G') err(talker2, "can't derive this", mark.identifier, mark.start); res = num_deriv(call, argvec); } else switch (ret) { case RET_GEN: res = ((PFGEN)call)(_ARGS_); break; case RET_INT: m = (long)((int (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_LONG: m = ((long (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_VOID: ((void (*)(ANYARG))call)(_ARGS_); res = gnil; break; } gp_function_name = oldname;} if (has_pointer) check_pointers(has_pointer,init); if (!noparen) match(')'); return res; } if (EpPREDEFINED(ep)) { if (*analyseur != '(') { if (EpVALENCE(ep) == 88) return global0(); match('('); /* error */ } analyseur++; ch1 = analyseur; switch(EpVALENCE(ep)) { case 50: /* O */ res = truc(); NO_BREAK("in O()", ch1); if (*analyseur=='^') { analyseur++; m = readlong(); } else m = 1; res = ggrando(res,m); break; case 80: /* if then else */ av = avma; res = expr(); NO_BREAK("in test expression", ch1); m = gcmp0(res); avma = av; match(','); if (m) /* false */ { skipseq(); if (*analyseur == ')') res = gnil; else { match(','); res = seq(); if (br_status) { res = NULL; skipseq(); } } } else /* true */ { res = seq(); if (br_status) { res = NULL; skipseq(); } if (*analyseur != ')') { match(','); skipseq(); } } break; case 81: /* while do */ av = avma; for(;;) { res = expr(); NO_BREAK("in test expression", ch1); if (gcmp0(res)) { match(','); break; } avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; } avma = av; skipseq(); res = gnil; break; case 82: /* repeat until */ av = avma; skipexpr(); for(;;) { avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; res = expr(); NO_BREAK("in test expression", ch1); if (!gcmp0(res)) { match(','); break; } } avma = av; skipseq(); res = gnil; break; case 88: /* global */ if (*analyseur == ')') return global0(); matchcomma = 0; while (*analyseur != ')') { match_comma(); ch1 = analyseur; check_var_name(); ep = skipentry(); switch(EpVALENCE(ep)) { case EpGVAR: case EpVAR: break; default: err(talker2,"symbol already in use",ch1,mark.start); } analyseur = ch1; ep = entry(); if (*analyseur == '=') { pari_sp av=avma; analyseur++; ch1 = analyseur; res = expr(); NO_BREAK("here (defining global var)", ch1); changevalue(ep, res); avma=av; } ep->valence = EpGVAR; } res = gnil; break; default: err(valencer1); return NULL; /* not reached */ } match(')'); return res; } switch (EpVALENCE(ep)) { GEN *defarg; /* = default args, and values for local variables */ GEN *arglist; gp_args *f; case EpUSER: /* user-defined functions */ f = (gp_args*)ep->args; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; arglist = (GEN*) new_chunk(f->narg); if (*analyseur != '(') /* no args */ { if (*analyseur != '=' || analyseur[1] == '=') { for (i=0; i<f->narg; i++) arglist[i] = make_arg(f->arg[i]); return call_fun((GEN)ep->value, arglist, f); } match('('); /* ==> error */ } analyseur++; /* skip '(' */ ch1 = analyseur; skip_arg_block(f); if (*analyseur == ')' && (analyseur[1] != '=' || analyseur[2] == '=')) { matchcomma = 0; analyseur = ch1; for (i=0; i<f->narg; i++) { if (do_switch(0,matchcomma)) { /* default arg */ arglist[i] = make_arg(f->arg[i]); matchcomma = 1; } else { /* user supplied */ char *old; match_comma(); old = analyseur; arglist[i] = expr(); NO_BREAK("here (reading function args)", old); } } analyseur++; /* skip ')' */ if (deriv) { if (!f->narg) err(talker2, "can't derive this", mark.identifier, mark.start); return num_derivU((GEN)ep->value, arglist, f); } return call_fun((GEN)ep->value, arglist, f); } /* REDEFINE function */ if (*analyseur != ',' && *analyseur != ')') skipexpr(); while (*analyseur == ',') { analyseur++; skipexpr(); } match(')'); if (*analyseur != '=' || analyseur[1] == '=') err(talker2,"too many parameters in user-defined function call", mark.identifier,mark.start); analyseur = ch1-1; /* points to '(' */ free_args((gp_args*)ep->args); free(ep->args); ep->args = NULL; ep->valence = EpNEW; /* Fall through */ case EpNEW: /* new function */ { GEN tmpargs = (GEN)avma; char *start; long len, narg, nloc; check_new_fun = ep; /* checking arguments */ narg = check_args(); nloc = 0; /* Dirty, but don't want to define a local() function */ if (*analyseur != '=' && strcmp(ep->name, "local") == 0) err(talker2, "local() bloc must appear before any other expression", mark.identifier,mark.start); match('='); { /* checking function definition */ skipping_fun_def++; while (strncmp(analyseur,"local(",6) == 0) { analyseur += 5; /* on '(' */ nloc += check_args(); while(separe(*analyseur)) analyseur++; } start = analyseur; skipseq(); len = analyseur-start; skipping_fun_def--; } /* function is ok. record it */ /* record default args */ f = (gp_args*) gpmalloc((narg+nloc)*sizeof(GEN) + sizeof(gp_args)); ep->args = (void*) f; f->nloc = nloc; f->narg = narg; f->arg = defarg = (GEN*)(f + 1); narg += nloc; /* record default args and local variables */ newfun = ptr = (GEN) newbloc(1 + narg + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ for (i = 1; i <= narg; i++) { GEN cell = tmpargs-(i<<1); *newfun++ = cell[0]; *defarg++ = (GEN)cell[1]; } if (narg > 1) { /* check for duplicates */ GEN x = new_chunk(narg), v = ptr+1; long k; for (i=0; i<narg; i++) x[i] = v[i]; qsort(x,narg,sizeof(long),(QSCOMP)pari_compare_long); for (k=x[0],i=1; i<narg; k=x[i],i++) if (x[i] == k) err(talker,"user function %s: variable %Z declared twice", ep->name, polx[k]); } /* record text */ strncpy((char *)newfun, start, len); ((char *) newfun)[len] = 0; /* wait till here for gunclone because of strncopy above. In pathological * cases, e.g. (f()=f()=x), new text is given by value of old one! */ if (EpVALENCE(ep) == EpUSER) gunclone((GEN)ep->value); ep->value = (void *)ptr; ep->valence = EpUSER; check_new_fun=NULL; avma = (pari_sp)tmpargs; return gnil; } } err(valencer1); return NULL; /* not reached */} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d6bc6f7c8515f98a50f281cca0bb8c335aed5b17/anal.c/clean/src/language/anal.c |
matcomp *c = (matcomp*)malloc(sizeof(matcomp)); | identifier(void){ long m, i, matchcomma, deriv; pari_sp av; char *ch1; entree *ep; GEN res, newfun, ptr; mark.identifier = analyseur; ep = entry(); if (EpVALENCE(ep)==EpVAR || EpVALENCE(ep)==EpGVAR) { /* optimized for simple variables */ switch (*analyseur) { case ')': case ',': return (GEN)ep->value; case '.': { long len, v; analyseur++; ch1 = analyseur; if ((res = read_member((GEN)ep->value))) { if (*analyseur == '[') { matcomp c; res = matcell(res, &c); } return res; } /* define a new member function */ v = varn(initial_value(ep)); len = analyseur - ch1; analyseur++; /* skip = */ ep = installep(NULL,ch1,len,EpMEMBER,0, members_hash + hashvalue(ch1)); ch1 = analyseur; skipseq(); len = analyseur-ch1; newfun=ptr= (GEN) newbloc(2 + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ *newfun++ = v; /* record text */ strncpy((char *)newfun, ch1, len); ((char *) newfun)[len] = 0; ep->value = (void *)ptr; return gnil; } } if (*analyseur != '[') { /* whole variable, no component */ F2GEN fun = affect_block(&res); if (res) { if (fun) res = fun((GEN)ep->value, res); changevalue(ep,res); } return (GEN)ep->value; } return matrix_block((GEN)ep->value); } ep = do_alias(ep);#ifdef STACK_CHECK if (PARI_stack_limit && (void*) &ptr <= PARI_stack_limit) err(talker2, "deep recursion", mark.identifier, mark.start);#endif if (ep->code) { char *s = ep->code, *oldanalyseur = NULL, *buf, *limit, *bp; unsigned int ret, noparen, has_pointer=0; long fake; void *call = ep->value; GEN argvec[9]; matcomp *init[9]; char *flags = NULL; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; if (*analyseur == '(') { analyseur++; noparen=0; /* expect matching ')' */ } else { /* if no mandatory argument, no () needed */ if (EpVALENCE(ep)) match('('); /* error */ if (!*s || (!s[1] && *s == 'p')) return ((GEN (*)(long))call)(prec); noparen=1; /* no argument, but valence is ok */ } /* return type */ if (*s < 'a') ret = RET_GEN; else if (*s == 'v') { ret = RET_VOID; s++; } else if (*s == 'i') { ret = RET_INT; s++; } else if (*s == 'l') { ret = RET_LONG; s++; } else ret = RET_GEN; /* Optimized for G and p. */ i = 0; matchcomma = 0; while (*s == 'G') { s++; match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); } if (*s == 'p') { argvec[i++] = (GEN) prec; s++; } while (*s && *s != '\n') switch (*s++) { case 'G': /* GEN */ match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); break; case 'L': /* long */ match_comma(); argvec[i++] = (GEN) readlong(); break; case 'n': /* var number */ match_comma(); argvec[i++] = (GEN) readvar(); break; case 'S': /* symbol */ match_comma(); mark.symbol=analyseur; argvec[i++] = (GEN)entry(); break; case 'V': /* variable */ match_comma(); mark.symbol=analyseur; { entree *e = entry(); long v = EpVALENCE(e); if (v != EpVAR && v != EpGVAR) err(talker2,"not a variable:",mark.symbol,mark.start); argvec[i++] = (GEN)e; break; } case '&': /* *GEN */ match_comma(); match('&'); mark.symbol=analyseur; { matcomp *c = (matcomp*)malloc(sizeof(matcomp)); entree *ep = entry(); if (*analyseur == '[') (void)matcell((GEN)ep->value, c); else { c->parent = NULL; c->ptcell = (GEN*)&ep->value; c->extra = (GEN*)ep->value; } has_pointer |= (1 << i); init[i] = c; argvec[i++] = (GEN)c->ptcell; break; } /* Input position */ case 'E': /* expr */ case 'I': /* seq */ match_comma(); argvec[i++] = (GEN) analyseur; skipseq(); break; case 'r': /* raw */ match_comma(); mark.raw = analyseur; bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; if (*analyseur == '"') bp = readstring_i(bp, &buf,&limit); else { if (bp > limit) bp = realloc_buf(bp,1, &buf,&limit); *bp++ = *analyseur++; } } *bp++ = 0; argvec[i++] = (GEN) buf; break; case 'M': /* Mnemonic flag */ match_comma(); ch1 = analyseur; argvec[i] = expr(); NO_BREAK("here (reading arguments)", ch1); if (typ(argvec[i]) == t_STR) { if (!flags) flags = ep->code; flags = strchr(flags, '\n'); /* Skip to the following '\n' */ if (!flags) err(talker, "not enough flags in string function signature"); flags++; argvec[i] = (GEN) parse_option_string((char*)(argvec[i] + 1), flags, PARSEMNU_ARG_WHITESP | PARSEMNU_TEMPL_TERM_NL, NULL, NULL); } else argvec[i] = (GEN)itos(argvec[i]); i++; break; case 's': /* expanded string; empty arg yields "" */ match_comma(); if (*s == '*') /* any number of string objects */ { argvec[i++] = any_string(); s++; break; } bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; bp = expand_string(bp, &buf,&limit); } *bp++ = 0; argvec[i++] = (GEN)buf; break; case 'p': /* precision */ argvec[i++] = (GEN) prec; break; case '=': match('='); matchcomma = 0; break; case 'D': /* Has a default value */ if (do_switch(noparen,matchcomma)) switch (*s) { case 'G': case '&': case 'I': case 'V': matchcomma=1; argvec[i++]=DFT_GEN; s++; break; case 'n': matchcomma=1; argvec[i++]=DFT_VAR; s++; break; default: oldanalyseur = analyseur; analyseur = s; matchcomma = 0; while (*s++ != ','); } else switch (*s) { case 'G': case '&': case 'I': case 'V': case 'n': break; default: while (*s++ != ','); } break; case 'P': /* series precision */ argvec[i++] = (GEN) precdl; break; case 'f': /* Fake *long argument */ argvec[i++] = (GEN) &fake; break; case 'x': /* Foreign function */ argvec[i++] = (GEN) ep; call = foreignHandler; break; case ',': /* Clean up default */ if (oldanalyseur) { analyseur = oldanalyseur; oldanalyseur = NULL; matchcomma=1; } break; default: err(bugparier,"identifier (unknown code)"); }#if 0 /* uncomment if using purify: UMR otherwise */ for ( ; i<9; i++) argvec[i]=NULL;#endif{ char *oldname = gp_function_name; gp_function_name = ep->name; if (deriv) { if (!i || (ep->code)[0] != 'G') err(talker2, "can't derive this", mark.identifier, mark.start); res = num_deriv(call, argvec); } else switch (ret) { case RET_GEN: res = ((PFGEN)call)(_ARGS_); break; case RET_INT: m = (long)((int (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_LONG: m = ((long (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_VOID: ((void (*)(ANYARG))call)(_ARGS_); res = gnil; break; } gp_function_name = oldname;} if (has_pointer) check_pointers(has_pointer,init); if (!noparen) match(')'); return res; } if (EpPREDEFINED(ep)) { if (*analyseur != '(') { if (EpVALENCE(ep) == 88) return global0(); match('('); /* error */ } analyseur++; ch1 = analyseur; switch(EpVALENCE(ep)) { case 50: /* O */ res = truc(); NO_BREAK("in O()", ch1); if (*analyseur=='^') { analyseur++; m = readlong(); } else m = 1; res = ggrando(res,m); break; case 80: /* if then else */ av = avma; res = expr(); NO_BREAK("in test expression", ch1); m = gcmp0(res); avma = av; match(','); if (m) /* false */ { skipseq(); if (*analyseur == ')') res = gnil; else { match(','); res = seq(); if (br_status) { res = NULL; skipseq(); } } } else /* true */ { res = seq(); if (br_status) { res = NULL; skipseq(); } if (*analyseur != ')') { match(','); skipseq(); } } break; case 81: /* while do */ av = avma; for(;;) { res = expr(); NO_BREAK("in test expression", ch1); if (gcmp0(res)) { match(','); break; } avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; } avma = av; skipseq(); res = gnil; break; case 82: /* repeat until */ av = avma; skipexpr(); for(;;) { avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; res = expr(); NO_BREAK("in test expression", ch1); if (!gcmp0(res)) { match(','); break; } } avma = av; skipseq(); res = gnil; break; case 88: /* global */ if (*analyseur == ')') return global0(); matchcomma = 0; while (*analyseur != ')') { match_comma(); ch1 = analyseur; check_var_name(); ep = skipentry(); switch(EpVALENCE(ep)) { case EpGVAR: case EpVAR: break; default: err(talker2,"symbol already in use",ch1,mark.start); } analyseur = ch1; ep = entry(); if (*analyseur == '=') { pari_sp av=avma; analyseur++; ch1 = analyseur; res = expr(); NO_BREAK("here (defining global var)", ch1); changevalue(ep, res); avma=av; } ep->valence = EpGVAR; } res = gnil; break; default: err(valencer1); return NULL; /* not reached */ } match(')'); return res; } switch (EpVALENCE(ep)) { GEN *defarg; /* = default args, and values for local variables */ GEN *arglist; gp_args *f; case EpUSER: /* user-defined functions */ f = (gp_args*)ep->args; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; arglist = (GEN*) new_chunk(f->narg); if (*analyseur != '(') /* no args */ { if (*analyseur != '=' || analyseur[1] == '=') { for (i=0; i<f->narg; i++) arglist[i] = make_arg(f->arg[i]); return call_fun((GEN)ep->value, arglist, f); } match('('); /* ==> error */ } analyseur++; /* skip '(' */ ch1 = analyseur; skip_arg_block(f); if (*analyseur == ')' && (analyseur[1] != '=' || analyseur[2] == '=')) { matchcomma = 0; analyseur = ch1; for (i=0; i<f->narg; i++) { if (do_switch(0,matchcomma)) { /* default arg */ arglist[i] = make_arg(f->arg[i]); matchcomma = 1; } else { /* user supplied */ char *old; match_comma(); old = analyseur; arglist[i] = expr(); NO_BREAK("here (reading function args)", old); } } analyseur++; /* skip ')' */ if (deriv) { if (!f->narg) err(talker2, "can't derive this", mark.identifier, mark.start); return num_derivU((GEN)ep->value, arglist, f); } return call_fun((GEN)ep->value, arglist, f); } /* REDEFINE function */ if (*analyseur != ',' && *analyseur != ')') skipexpr(); while (*analyseur == ',') { analyseur++; skipexpr(); } match(')'); if (*analyseur != '=' || analyseur[1] == '=') err(talker2,"too many parameters in user-defined function call", mark.identifier,mark.start); analyseur = ch1-1; /* points to '(' */ free_args((gp_args*)ep->args); free(ep->args); ep->args = NULL; ep->valence = EpNEW; /* Fall through */ case EpNEW: /* new function */ { GEN tmpargs = (GEN)avma; char *start; long len, narg, nloc; check_new_fun = ep; /* checking arguments */ narg = check_args(); nloc = 0; /* Dirty, but don't want to define a local() function */ if (*analyseur != '=' && strcmp(ep->name, "local") == 0) err(talker2, "local() bloc must appear before any other expression", mark.identifier,mark.start); match('='); { /* checking function definition */ skipping_fun_def++; while (strncmp(analyseur,"local(",6) == 0) { analyseur += 5; /* on '(' */ nloc += check_args(); while(separe(*analyseur)) analyseur++; } start = analyseur; skipseq(); len = analyseur-start; skipping_fun_def--; } /* function is ok. record it */ /* record default args */ f = (gp_args*) gpmalloc((narg+nloc)*sizeof(GEN) + sizeof(gp_args)); ep->args = (void*) f; f->nloc = nloc; f->narg = narg; f->arg = defarg = (GEN*)(f + 1); narg += nloc; /* record default args and local variables */ newfun = ptr = (GEN) newbloc(1 + narg + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ for (i = 1; i <= narg; i++) { GEN cell = tmpargs-(i<<1); *newfun++ = cell[0]; *defarg++ = (GEN)cell[1]; } if (narg > 1) { /* check for duplicates */ GEN x = new_chunk(narg), v = ptr+1; long k; for (i=0; i<narg; i++) x[i] = v[i]; qsort(x,narg,sizeof(long),(QSCOMP)pari_compare_long); for (k=x[0],i=1; i<narg; k=x[i],i++) if (x[i] == k) err(talker,"user function %s: variable %Z declared twice", ep->name, polx[k]); } /* record text */ strncpy((char *)newfun, start, len); ((char *) newfun)[len] = 0; /* wait till here for gunclone because of strncopy above. In pathological * cases, e.g. (f()=f()=x), new text is given by value of old one! */ if (EpVALENCE(ep) == EpUSER) gunclone((GEN)ep->value); ep->value = (void *)ptr; ep->valence = EpUSER; check_new_fun=NULL; avma = (pari_sp)tmpargs; return gnil; } } err(valencer1); return NULL; /* not reached */} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d6bc6f7c8515f98a50f281cca0bb8c335aed5b17/anal.c/clean/src/language/anal.c |
|
if (*analyseur == '[') (void)matcell((GEN)ep->value, c); | gp_pointer *g = &ptrs[ind_pointer++]; if (*analyseur == '[') { (void)matcell((GEN)ep->value, &(g->c)); g->ep = NULL; } | identifier(void){ long m, i, matchcomma, deriv; pari_sp av; char *ch1; entree *ep; GEN res, newfun, ptr; mark.identifier = analyseur; ep = entry(); if (EpVALENCE(ep)==EpVAR || EpVALENCE(ep)==EpGVAR) { /* optimized for simple variables */ switch (*analyseur) { case ')': case ',': return (GEN)ep->value; case '.': { long len, v; analyseur++; ch1 = analyseur; if ((res = read_member((GEN)ep->value))) { if (*analyseur == '[') { matcomp c; res = matcell(res, &c); } return res; } /* define a new member function */ v = varn(initial_value(ep)); len = analyseur - ch1; analyseur++; /* skip = */ ep = installep(NULL,ch1,len,EpMEMBER,0, members_hash + hashvalue(ch1)); ch1 = analyseur; skipseq(); len = analyseur-ch1; newfun=ptr= (GEN) newbloc(2 + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ *newfun++ = v; /* record text */ strncpy((char *)newfun, ch1, len); ((char *) newfun)[len] = 0; ep->value = (void *)ptr; return gnil; } } if (*analyseur != '[') { /* whole variable, no component */ F2GEN fun = affect_block(&res); if (res) { if (fun) res = fun((GEN)ep->value, res); changevalue(ep,res); } return (GEN)ep->value; } return matrix_block((GEN)ep->value); } ep = do_alias(ep);#ifdef STACK_CHECK if (PARI_stack_limit && (void*) &ptr <= PARI_stack_limit) err(talker2, "deep recursion", mark.identifier, mark.start);#endif if (ep->code) { char *s = ep->code, *oldanalyseur = NULL, *buf, *limit, *bp; unsigned int ret, noparen, has_pointer=0; long fake; void *call = ep->value; GEN argvec[9]; matcomp *init[9]; char *flags = NULL; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; if (*analyseur == '(') { analyseur++; noparen=0; /* expect matching ')' */ } else { /* if no mandatory argument, no () needed */ if (EpVALENCE(ep)) match('('); /* error */ if (!*s || (!s[1] && *s == 'p')) return ((GEN (*)(long))call)(prec); noparen=1; /* no argument, but valence is ok */ } /* return type */ if (*s < 'a') ret = RET_GEN; else if (*s == 'v') { ret = RET_VOID; s++; } else if (*s == 'i') { ret = RET_INT; s++; } else if (*s == 'l') { ret = RET_LONG; s++; } else ret = RET_GEN; /* Optimized for G and p. */ i = 0; matchcomma = 0; while (*s == 'G') { s++; match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); } if (*s == 'p') { argvec[i++] = (GEN) prec; s++; } while (*s && *s != '\n') switch (*s++) { case 'G': /* GEN */ match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); break; case 'L': /* long */ match_comma(); argvec[i++] = (GEN) readlong(); break; case 'n': /* var number */ match_comma(); argvec[i++] = (GEN) readvar(); break; case 'S': /* symbol */ match_comma(); mark.symbol=analyseur; argvec[i++] = (GEN)entry(); break; case 'V': /* variable */ match_comma(); mark.symbol=analyseur; { entree *e = entry(); long v = EpVALENCE(e); if (v != EpVAR && v != EpGVAR) err(talker2,"not a variable:",mark.symbol,mark.start); argvec[i++] = (GEN)e; break; } case '&': /* *GEN */ match_comma(); match('&'); mark.symbol=analyseur; { matcomp *c = (matcomp*)malloc(sizeof(matcomp)); entree *ep = entry(); if (*analyseur == '[') (void)matcell((GEN)ep->value, c); else { c->parent = NULL; c->ptcell = (GEN*)&ep->value; c->extra = (GEN*)ep->value; } has_pointer |= (1 << i); init[i] = c; argvec[i++] = (GEN)c->ptcell; break; } /* Input position */ case 'E': /* expr */ case 'I': /* seq */ match_comma(); argvec[i++] = (GEN) analyseur; skipseq(); break; case 'r': /* raw */ match_comma(); mark.raw = analyseur; bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; if (*analyseur == '"') bp = readstring_i(bp, &buf,&limit); else { if (bp > limit) bp = realloc_buf(bp,1, &buf,&limit); *bp++ = *analyseur++; } } *bp++ = 0; argvec[i++] = (GEN) buf; break; case 'M': /* Mnemonic flag */ match_comma(); ch1 = analyseur; argvec[i] = expr(); NO_BREAK("here (reading arguments)", ch1); if (typ(argvec[i]) == t_STR) { if (!flags) flags = ep->code; flags = strchr(flags, '\n'); /* Skip to the following '\n' */ if (!flags) err(talker, "not enough flags in string function signature"); flags++; argvec[i] = (GEN) parse_option_string((char*)(argvec[i] + 1), flags, PARSEMNU_ARG_WHITESP | PARSEMNU_TEMPL_TERM_NL, NULL, NULL); } else argvec[i] = (GEN)itos(argvec[i]); i++; break; case 's': /* expanded string; empty arg yields "" */ match_comma(); if (*s == '*') /* any number of string objects */ { argvec[i++] = any_string(); s++; break; } bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; bp = expand_string(bp, &buf,&limit); } *bp++ = 0; argvec[i++] = (GEN)buf; break; case 'p': /* precision */ argvec[i++] = (GEN) prec; break; case '=': match('='); matchcomma = 0; break; case 'D': /* Has a default value */ if (do_switch(noparen,matchcomma)) switch (*s) { case 'G': case '&': case 'I': case 'V': matchcomma=1; argvec[i++]=DFT_GEN; s++; break; case 'n': matchcomma=1; argvec[i++]=DFT_VAR; s++; break; default: oldanalyseur = analyseur; analyseur = s; matchcomma = 0; while (*s++ != ','); } else switch (*s) { case 'G': case '&': case 'I': case 'V': case 'n': break; default: while (*s++ != ','); } break; case 'P': /* series precision */ argvec[i++] = (GEN) precdl; break; case 'f': /* Fake *long argument */ argvec[i++] = (GEN) &fake; break; case 'x': /* Foreign function */ argvec[i++] = (GEN) ep; call = foreignHandler; break; case ',': /* Clean up default */ if (oldanalyseur) { analyseur = oldanalyseur; oldanalyseur = NULL; matchcomma=1; } break; default: err(bugparier,"identifier (unknown code)"); }#if 0 /* uncomment if using purify: UMR otherwise */ for ( ; i<9; i++) argvec[i]=NULL;#endif{ char *oldname = gp_function_name; gp_function_name = ep->name; if (deriv) { if (!i || (ep->code)[0] != 'G') err(talker2, "can't derive this", mark.identifier, mark.start); res = num_deriv(call, argvec); } else switch (ret) { case RET_GEN: res = ((PFGEN)call)(_ARGS_); break; case RET_INT: m = (long)((int (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_LONG: m = ((long (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_VOID: ((void (*)(ANYARG))call)(_ARGS_); res = gnil; break; } gp_function_name = oldname;} if (has_pointer) check_pointers(has_pointer,init); if (!noparen) match(')'); return res; } if (EpPREDEFINED(ep)) { if (*analyseur != '(') { if (EpVALENCE(ep) == 88) return global0(); match('('); /* error */ } analyseur++; ch1 = analyseur; switch(EpVALENCE(ep)) { case 50: /* O */ res = truc(); NO_BREAK("in O()", ch1); if (*analyseur=='^') { analyseur++; m = readlong(); } else m = 1; res = ggrando(res,m); break; case 80: /* if then else */ av = avma; res = expr(); NO_BREAK("in test expression", ch1); m = gcmp0(res); avma = av; match(','); if (m) /* false */ { skipseq(); if (*analyseur == ')') res = gnil; else { match(','); res = seq(); if (br_status) { res = NULL; skipseq(); } } } else /* true */ { res = seq(); if (br_status) { res = NULL; skipseq(); } if (*analyseur != ')') { match(','); skipseq(); } } break; case 81: /* while do */ av = avma; for(;;) { res = expr(); NO_BREAK("in test expression", ch1); if (gcmp0(res)) { match(','); break; } avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; } avma = av; skipseq(); res = gnil; break; case 82: /* repeat until */ av = avma; skipexpr(); for(;;) { avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; res = expr(); NO_BREAK("in test expression", ch1); if (!gcmp0(res)) { match(','); break; } } avma = av; skipseq(); res = gnil; break; case 88: /* global */ if (*analyseur == ')') return global0(); matchcomma = 0; while (*analyseur != ')') { match_comma(); ch1 = analyseur; check_var_name(); ep = skipentry(); switch(EpVALENCE(ep)) { case EpGVAR: case EpVAR: break; default: err(talker2,"symbol already in use",ch1,mark.start); } analyseur = ch1; ep = entry(); if (*analyseur == '=') { pari_sp av=avma; analyseur++; ch1 = analyseur; res = expr(); NO_BREAK("here (defining global var)", ch1); changevalue(ep, res); avma=av; } ep->valence = EpGVAR; } res = gnil; break; default: err(valencer1); return NULL; /* not reached */ } match(')'); return res; } switch (EpVALENCE(ep)) { GEN *defarg; /* = default args, and values for local variables */ GEN *arglist; gp_args *f; case EpUSER: /* user-defined functions */ f = (gp_args*)ep->args; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; arglist = (GEN*) new_chunk(f->narg); if (*analyseur != '(') /* no args */ { if (*analyseur != '=' || analyseur[1] == '=') { for (i=0; i<f->narg; i++) arglist[i] = make_arg(f->arg[i]); return call_fun((GEN)ep->value, arglist, f); } match('('); /* ==> error */ } analyseur++; /* skip '(' */ ch1 = analyseur; skip_arg_block(f); if (*analyseur == ')' && (analyseur[1] != '=' || analyseur[2] == '=')) { matchcomma = 0; analyseur = ch1; for (i=0; i<f->narg; i++) { if (do_switch(0,matchcomma)) { /* default arg */ arglist[i] = make_arg(f->arg[i]); matchcomma = 1; } else { /* user supplied */ char *old; match_comma(); old = analyseur; arglist[i] = expr(); NO_BREAK("here (reading function args)", old); } } analyseur++; /* skip ')' */ if (deriv) { if (!f->narg) err(talker2, "can't derive this", mark.identifier, mark.start); return num_derivU((GEN)ep->value, arglist, f); } return call_fun((GEN)ep->value, arglist, f); } /* REDEFINE function */ if (*analyseur != ',' && *analyseur != ')') skipexpr(); while (*analyseur == ',') { analyseur++; skipexpr(); } match(')'); if (*analyseur != '=' || analyseur[1] == '=') err(talker2,"too many parameters in user-defined function call", mark.identifier,mark.start); analyseur = ch1-1; /* points to '(' */ free_args((gp_args*)ep->args); free(ep->args); ep->args = NULL; ep->valence = EpNEW; /* Fall through */ case EpNEW: /* new function */ { GEN tmpargs = (GEN)avma; char *start; long len, narg, nloc; check_new_fun = ep; /* checking arguments */ narg = check_args(); nloc = 0; /* Dirty, but don't want to define a local() function */ if (*analyseur != '=' && strcmp(ep->name, "local") == 0) err(talker2, "local() bloc must appear before any other expression", mark.identifier,mark.start); match('='); { /* checking function definition */ skipping_fun_def++; while (strncmp(analyseur,"local(",6) == 0) { analyseur += 5; /* on '(' */ nloc += check_args(); while(separe(*analyseur)) analyseur++; } start = analyseur; skipseq(); len = analyseur-start; skipping_fun_def--; } /* function is ok. record it */ /* record default args */ f = (gp_args*) gpmalloc((narg+nloc)*sizeof(GEN) + sizeof(gp_args)); ep->args = (void*) f; f->nloc = nloc; f->narg = narg; f->arg = defarg = (GEN*)(f + 1); narg += nloc; /* record default args and local variables */ newfun = ptr = (GEN) newbloc(1 + narg + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ for (i = 1; i <= narg; i++) { GEN cell = tmpargs-(i<<1); *newfun++ = cell[0]; *defarg++ = (GEN)cell[1]; } if (narg > 1) { /* check for duplicates */ GEN x = new_chunk(narg), v = ptr+1; long k; for (i=0; i<narg; i++) x[i] = v[i]; qsort(x,narg,sizeof(long),(QSCOMP)pari_compare_long); for (k=x[0],i=1; i<narg; k=x[i],i++) if (x[i] == k) err(talker,"user function %s: variable %Z declared twice", ep->name, polx[k]); } /* record text */ strncpy((char *)newfun, start, len); ((char *) newfun)[len] = 0; /* wait till here for gunclone because of strncopy above. In pathological * cases, e.g. (f()=f()=x), new text is given by value of old one! */ if (EpVALENCE(ep) == EpUSER) gunclone((GEN)ep->value); ep->value = (void *)ptr; ep->valence = EpUSER; check_new_fun=NULL; avma = (pari_sp)tmpargs; return gnil; } } err(valencer1); return NULL; /* not reached */} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d6bc6f7c8515f98a50f281cca0bb8c335aed5b17/anal.c/clean/src/language/anal.c |
{ c->parent = NULL; c->ptcell = (GEN*)&ep->value; c->extra = (GEN*)ep->value; } has_pointer |= (1 << i); init[i] = c; argvec[i++] = (GEN)c->ptcell; break; | g->ep = ep; argvec[i++] = (GEN)&(g->x); break; | identifier(void){ long m, i, matchcomma, deriv; pari_sp av; char *ch1; entree *ep; GEN res, newfun, ptr; mark.identifier = analyseur; ep = entry(); if (EpVALENCE(ep)==EpVAR || EpVALENCE(ep)==EpGVAR) { /* optimized for simple variables */ switch (*analyseur) { case ')': case ',': return (GEN)ep->value; case '.': { long len, v; analyseur++; ch1 = analyseur; if ((res = read_member((GEN)ep->value))) { if (*analyseur == '[') { matcomp c; res = matcell(res, &c); } return res; } /* define a new member function */ v = varn(initial_value(ep)); len = analyseur - ch1; analyseur++; /* skip = */ ep = installep(NULL,ch1,len,EpMEMBER,0, members_hash + hashvalue(ch1)); ch1 = analyseur; skipseq(); len = analyseur-ch1; newfun=ptr= (GEN) newbloc(2 + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ *newfun++ = v; /* record text */ strncpy((char *)newfun, ch1, len); ((char *) newfun)[len] = 0; ep->value = (void *)ptr; return gnil; } } if (*analyseur != '[') { /* whole variable, no component */ F2GEN fun = affect_block(&res); if (res) { if (fun) res = fun((GEN)ep->value, res); changevalue(ep,res); } return (GEN)ep->value; } return matrix_block((GEN)ep->value); } ep = do_alias(ep);#ifdef STACK_CHECK if (PARI_stack_limit && (void*) &ptr <= PARI_stack_limit) err(talker2, "deep recursion", mark.identifier, mark.start);#endif if (ep->code) { char *s = ep->code, *oldanalyseur = NULL, *buf, *limit, *bp; unsigned int ret, noparen, has_pointer=0; long fake; void *call = ep->value; GEN argvec[9]; matcomp *init[9]; char *flags = NULL; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; if (*analyseur == '(') { analyseur++; noparen=0; /* expect matching ')' */ } else { /* if no mandatory argument, no () needed */ if (EpVALENCE(ep)) match('('); /* error */ if (!*s || (!s[1] && *s == 'p')) return ((GEN (*)(long))call)(prec); noparen=1; /* no argument, but valence is ok */ } /* return type */ if (*s < 'a') ret = RET_GEN; else if (*s == 'v') { ret = RET_VOID; s++; } else if (*s == 'i') { ret = RET_INT; s++; } else if (*s == 'l') { ret = RET_LONG; s++; } else ret = RET_GEN; /* Optimized for G and p. */ i = 0; matchcomma = 0; while (*s == 'G') { s++; match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); } if (*s == 'p') { argvec[i++] = (GEN) prec; s++; } while (*s && *s != '\n') switch (*s++) { case 'G': /* GEN */ match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); break; case 'L': /* long */ match_comma(); argvec[i++] = (GEN) readlong(); break; case 'n': /* var number */ match_comma(); argvec[i++] = (GEN) readvar(); break; case 'S': /* symbol */ match_comma(); mark.symbol=analyseur; argvec[i++] = (GEN)entry(); break; case 'V': /* variable */ match_comma(); mark.symbol=analyseur; { entree *e = entry(); long v = EpVALENCE(e); if (v != EpVAR && v != EpGVAR) err(talker2,"not a variable:",mark.symbol,mark.start); argvec[i++] = (GEN)e; break; } case '&': /* *GEN */ match_comma(); match('&'); mark.symbol=analyseur; { matcomp *c = (matcomp*)malloc(sizeof(matcomp)); entree *ep = entry(); if (*analyseur == '[') (void)matcell((GEN)ep->value, c); else { c->parent = NULL; c->ptcell = (GEN*)&ep->value; c->extra = (GEN*)ep->value; } has_pointer |= (1 << i); init[i] = c; argvec[i++] = (GEN)c->ptcell; break; } /* Input position */ case 'E': /* expr */ case 'I': /* seq */ match_comma(); argvec[i++] = (GEN) analyseur; skipseq(); break; case 'r': /* raw */ match_comma(); mark.raw = analyseur; bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; if (*analyseur == '"') bp = readstring_i(bp, &buf,&limit); else { if (bp > limit) bp = realloc_buf(bp,1, &buf,&limit); *bp++ = *analyseur++; } } *bp++ = 0; argvec[i++] = (GEN) buf; break; case 'M': /* Mnemonic flag */ match_comma(); ch1 = analyseur; argvec[i] = expr(); NO_BREAK("here (reading arguments)", ch1); if (typ(argvec[i]) == t_STR) { if (!flags) flags = ep->code; flags = strchr(flags, '\n'); /* Skip to the following '\n' */ if (!flags) err(talker, "not enough flags in string function signature"); flags++; argvec[i] = (GEN) parse_option_string((char*)(argvec[i] + 1), flags, PARSEMNU_ARG_WHITESP | PARSEMNU_TEMPL_TERM_NL, NULL, NULL); } else argvec[i] = (GEN)itos(argvec[i]); i++; break; case 's': /* expanded string; empty arg yields "" */ match_comma(); if (*s == '*') /* any number of string objects */ { argvec[i++] = any_string(); s++; break; } bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; bp = expand_string(bp, &buf,&limit); } *bp++ = 0; argvec[i++] = (GEN)buf; break; case 'p': /* precision */ argvec[i++] = (GEN) prec; break; case '=': match('='); matchcomma = 0; break; case 'D': /* Has a default value */ if (do_switch(noparen,matchcomma)) switch (*s) { case 'G': case '&': case 'I': case 'V': matchcomma=1; argvec[i++]=DFT_GEN; s++; break; case 'n': matchcomma=1; argvec[i++]=DFT_VAR; s++; break; default: oldanalyseur = analyseur; analyseur = s; matchcomma = 0; while (*s++ != ','); } else switch (*s) { case 'G': case '&': case 'I': case 'V': case 'n': break; default: while (*s++ != ','); } break; case 'P': /* series precision */ argvec[i++] = (GEN) precdl; break; case 'f': /* Fake *long argument */ argvec[i++] = (GEN) &fake; break; case 'x': /* Foreign function */ argvec[i++] = (GEN) ep; call = foreignHandler; break; case ',': /* Clean up default */ if (oldanalyseur) { analyseur = oldanalyseur; oldanalyseur = NULL; matchcomma=1; } break; default: err(bugparier,"identifier (unknown code)"); }#if 0 /* uncomment if using purify: UMR otherwise */ for ( ; i<9; i++) argvec[i]=NULL;#endif{ char *oldname = gp_function_name; gp_function_name = ep->name; if (deriv) { if (!i || (ep->code)[0] != 'G') err(talker2, "can't derive this", mark.identifier, mark.start); res = num_deriv(call, argvec); } else switch (ret) { case RET_GEN: res = ((PFGEN)call)(_ARGS_); break; case RET_INT: m = (long)((int (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_LONG: m = ((long (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_VOID: ((void (*)(ANYARG))call)(_ARGS_); res = gnil; break; } gp_function_name = oldname;} if (has_pointer) check_pointers(has_pointer,init); if (!noparen) match(')'); return res; } if (EpPREDEFINED(ep)) { if (*analyseur != '(') { if (EpVALENCE(ep) == 88) return global0(); match('('); /* error */ } analyseur++; ch1 = analyseur; switch(EpVALENCE(ep)) { case 50: /* O */ res = truc(); NO_BREAK("in O()", ch1); if (*analyseur=='^') { analyseur++; m = readlong(); } else m = 1; res = ggrando(res,m); break; case 80: /* if then else */ av = avma; res = expr(); NO_BREAK("in test expression", ch1); m = gcmp0(res); avma = av; match(','); if (m) /* false */ { skipseq(); if (*analyseur == ')') res = gnil; else { match(','); res = seq(); if (br_status) { res = NULL; skipseq(); } } } else /* true */ { res = seq(); if (br_status) { res = NULL; skipseq(); } if (*analyseur != ')') { match(','); skipseq(); } } break; case 81: /* while do */ av = avma; for(;;) { res = expr(); NO_BREAK("in test expression", ch1); if (gcmp0(res)) { match(','); break; } avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; } avma = av; skipseq(); res = gnil; break; case 82: /* repeat until */ av = avma; skipexpr(); for(;;) { avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; res = expr(); NO_BREAK("in test expression", ch1); if (!gcmp0(res)) { match(','); break; } } avma = av; skipseq(); res = gnil; break; case 88: /* global */ if (*analyseur == ')') return global0(); matchcomma = 0; while (*analyseur != ')') { match_comma(); ch1 = analyseur; check_var_name(); ep = skipentry(); switch(EpVALENCE(ep)) { case EpGVAR: case EpVAR: break; default: err(talker2,"symbol already in use",ch1,mark.start); } analyseur = ch1; ep = entry(); if (*analyseur == '=') { pari_sp av=avma; analyseur++; ch1 = analyseur; res = expr(); NO_BREAK("here (defining global var)", ch1); changevalue(ep, res); avma=av; } ep->valence = EpGVAR; } res = gnil; break; default: err(valencer1); return NULL; /* not reached */ } match(')'); return res; } switch (EpVALENCE(ep)) { GEN *defarg; /* = default args, and values for local variables */ GEN *arglist; gp_args *f; case EpUSER: /* user-defined functions */ f = (gp_args*)ep->args; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; arglist = (GEN*) new_chunk(f->narg); if (*analyseur != '(') /* no args */ { if (*analyseur != '=' || analyseur[1] == '=') { for (i=0; i<f->narg; i++) arglist[i] = make_arg(f->arg[i]); return call_fun((GEN)ep->value, arglist, f); } match('('); /* ==> error */ } analyseur++; /* skip '(' */ ch1 = analyseur; skip_arg_block(f); if (*analyseur == ')' && (analyseur[1] != '=' || analyseur[2] == '=')) { matchcomma = 0; analyseur = ch1; for (i=0; i<f->narg; i++) { if (do_switch(0,matchcomma)) { /* default arg */ arglist[i] = make_arg(f->arg[i]); matchcomma = 1; } else { /* user supplied */ char *old; match_comma(); old = analyseur; arglist[i] = expr(); NO_BREAK("here (reading function args)", old); } } analyseur++; /* skip ')' */ if (deriv) { if (!f->narg) err(talker2, "can't derive this", mark.identifier, mark.start); return num_derivU((GEN)ep->value, arglist, f); } return call_fun((GEN)ep->value, arglist, f); } /* REDEFINE function */ if (*analyseur != ',' && *analyseur != ')') skipexpr(); while (*analyseur == ',') { analyseur++; skipexpr(); } match(')'); if (*analyseur != '=' || analyseur[1] == '=') err(talker2,"too many parameters in user-defined function call", mark.identifier,mark.start); analyseur = ch1-1; /* points to '(' */ free_args((gp_args*)ep->args); free(ep->args); ep->args = NULL; ep->valence = EpNEW; /* Fall through */ case EpNEW: /* new function */ { GEN tmpargs = (GEN)avma; char *start; long len, narg, nloc; check_new_fun = ep; /* checking arguments */ narg = check_args(); nloc = 0; /* Dirty, but don't want to define a local() function */ if (*analyseur != '=' && strcmp(ep->name, "local") == 0) err(talker2, "local() bloc must appear before any other expression", mark.identifier,mark.start); match('='); { /* checking function definition */ skipping_fun_def++; while (strncmp(analyseur,"local(",6) == 0) { analyseur += 5; /* on '(' */ nloc += check_args(); while(separe(*analyseur)) analyseur++; } start = analyseur; skipseq(); len = analyseur-start; skipping_fun_def--; } /* function is ok. record it */ /* record default args */ f = (gp_args*) gpmalloc((narg+nloc)*sizeof(GEN) + sizeof(gp_args)); ep->args = (void*) f; f->nloc = nloc; f->narg = narg; f->arg = defarg = (GEN*)(f + 1); narg += nloc; /* record default args and local variables */ newfun = ptr = (GEN) newbloc(1 + narg + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ for (i = 1; i <= narg; i++) { GEN cell = tmpargs-(i<<1); *newfun++ = cell[0]; *defarg++ = (GEN)cell[1]; } if (narg > 1) { /* check for duplicates */ GEN x = new_chunk(narg), v = ptr+1; long k; for (i=0; i<narg; i++) x[i] = v[i]; qsort(x,narg,sizeof(long),(QSCOMP)pari_compare_long); for (k=x[0],i=1; i<narg; k=x[i],i++) if (x[i] == k) err(talker,"user function %s: variable %Z declared twice", ep->name, polx[k]); } /* record text */ strncpy((char *)newfun, start, len); ((char *) newfun)[len] = 0; /* wait till here for gunclone because of strncopy above. In pathological * cases, e.g. (f()=f()=x), new text is given by value of old one! */ if (EpVALENCE(ep) == EpUSER) gunclone((GEN)ep->value); ep->value = (void *)ptr; ep->valence = EpUSER; check_new_fun=NULL; avma = (pari_sp)tmpargs; return gnil; } } err(valencer1); return NULL; /* not reached */} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d6bc6f7c8515f98a50f281cca0bb8c335aed5b17/anal.c/clean/src/language/anal.c |
if (has_pointer) check_pointers(has_pointer,init); | if (ind_pointer) check_pointers(ptrs, ind_pointer); | identifier(void){ long m, i, matchcomma, deriv; pari_sp av; char *ch1; entree *ep; GEN res, newfun, ptr; mark.identifier = analyseur; ep = entry(); if (EpVALENCE(ep)==EpVAR || EpVALENCE(ep)==EpGVAR) { /* optimized for simple variables */ switch (*analyseur) { case ')': case ',': return (GEN)ep->value; case '.': { long len, v; analyseur++; ch1 = analyseur; if ((res = read_member((GEN)ep->value))) { if (*analyseur == '[') { matcomp c; res = matcell(res, &c); } return res; } /* define a new member function */ v = varn(initial_value(ep)); len = analyseur - ch1; analyseur++; /* skip = */ ep = installep(NULL,ch1,len,EpMEMBER,0, members_hash + hashvalue(ch1)); ch1 = analyseur; skipseq(); len = analyseur-ch1; newfun=ptr= (GEN) newbloc(2 + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ *newfun++ = v; /* record text */ strncpy((char *)newfun, ch1, len); ((char *) newfun)[len] = 0; ep->value = (void *)ptr; return gnil; } } if (*analyseur != '[') { /* whole variable, no component */ F2GEN fun = affect_block(&res); if (res) { if (fun) res = fun((GEN)ep->value, res); changevalue(ep,res); } return (GEN)ep->value; } return matrix_block((GEN)ep->value); } ep = do_alias(ep);#ifdef STACK_CHECK if (PARI_stack_limit && (void*) &ptr <= PARI_stack_limit) err(talker2, "deep recursion", mark.identifier, mark.start);#endif if (ep->code) { char *s = ep->code, *oldanalyseur = NULL, *buf, *limit, *bp; unsigned int ret, noparen, has_pointer=0; long fake; void *call = ep->value; GEN argvec[9]; matcomp *init[9]; char *flags = NULL; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; if (*analyseur == '(') { analyseur++; noparen=0; /* expect matching ')' */ } else { /* if no mandatory argument, no () needed */ if (EpVALENCE(ep)) match('('); /* error */ if (!*s || (!s[1] && *s == 'p')) return ((GEN (*)(long))call)(prec); noparen=1; /* no argument, but valence is ok */ } /* return type */ if (*s < 'a') ret = RET_GEN; else if (*s == 'v') { ret = RET_VOID; s++; } else if (*s == 'i') { ret = RET_INT; s++; } else if (*s == 'l') { ret = RET_LONG; s++; } else ret = RET_GEN; /* Optimized for G and p. */ i = 0; matchcomma = 0; while (*s == 'G') { s++; match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); } if (*s == 'p') { argvec[i++] = (GEN) prec; s++; } while (*s && *s != '\n') switch (*s++) { case 'G': /* GEN */ match_comma(); ch1 = analyseur; argvec[i++] = expr(); NO_BREAK("here (reading arguments)", ch1); break; case 'L': /* long */ match_comma(); argvec[i++] = (GEN) readlong(); break; case 'n': /* var number */ match_comma(); argvec[i++] = (GEN) readvar(); break; case 'S': /* symbol */ match_comma(); mark.symbol=analyseur; argvec[i++] = (GEN)entry(); break; case 'V': /* variable */ match_comma(); mark.symbol=analyseur; { entree *e = entry(); long v = EpVALENCE(e); if (v != EpVAR && v != EpGVAR) err(talker2,"not a variable:",mark.symbol,mark.start); argvec[i++] = (GEN)e; break; } case '&': /* *GEN */ match_comma(); match('&'); mark.symbol=analyseur; { matcomp *c = (matcomp*)malloc(sizeof(matcomp)); entree *ep = entry(); if (*analyseur == '[') (void)matcell((GEN)ep->value, c); else { c->parent = NULL; c->ptcell = (GEN*)&ep->value; c->extra = (GEN*)ep->value; } has_pointer |= (1 << i); init[i] = c; argvec[i++] = (GEN)c->ptcell; break; } /* Input position */ case 'E': /* expr */ case 'I': /* seq */ match_comma(); argvec[i++] = (GEN) analyseur; skipseq(); break; case 'r': /* raw */ match_comma(); mark.raw = analyseur; bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; if (*analyseur == '"') bp = readstring_i(bp, &buf,&limit); else { if (bp > limit) bp = realloc_buf(bp,1, &buf,&limit); *bp++ = *analyseur++; } } *bp++ = 0; argvec[i++] = (GEN) buf; break; case 'M': /* Mnemonic flag */ match_comma(); ch1 = analyseur; argvec[i] = expr(); NO_BREAK("here (reading arguments)", ch1); if (typ(argvec[i]) == t_STR) { if (!flags) flags = ep->code; flags = strchr(flags, '\n'); /* Skip to the following '\n' */ if (!flags) err(talker, "not enough flags in string function signature"); flags++; argvec[i] = (GEN) parse_option_string((char*)(argvec[i] + 1), flags, PARSEMNU_ARG_WHITESP | PARSEMNU_TEMPL_TERM_NL, NULL, NULL); } else argvec[i] = (GEN)itos(argvec[i]); i++; break; case 's': /* expanded string; empty arg yields "" */ match_comma(); if (*s == '*') /* any number of string objects */ { argvec[i++] = any_string(); s++; break; } bp = init_buf(256, &buf,&limit); while (*analyseur) { if (*analyseur == ',' || *analyseur == ')') break; bp = expand_string(bp, &buf,&limit); } *bp++ = 0; argvec[i++] = (GEN)buf; break; case 'p': /* precision */ argvec[i++] = (GEN) prec; break; case '=': match('='); matchcomma = 0; break; case 'D': /* Has a default value */ if (do_switch(noparen,matchcomma)) switch (*s) { case 'G': case '&': case 'I': case 'V': matchcomma=1; argvec[i++]=DFT_GEN; s++; break; case 'n': matchcomma=1; argvec[i++]=DFT_VAR; s++; break; default: oldanalyseur = analyseur; analyseur = s; matchcomma = 0; while (*s++ != ','); } else switch (*s) { case 'G': case '&': case 'I': case 'V': case 'n': break; default: while (*s++ != ','); } break; case 'P': /* series precision */ argvec[i++] = (GEN) precdl; break; case 'f': /* Fake *long argument */ argvec[i++] = (GEN) &fake; break; case 'x': /* Foreign function */ argvec[i++] = (GEN) ep; call = foreignHandler; break; case ',': /* Clean up default */ if (oldanalyseur) { analyseur = oldanalyseur; oldanalyseur = NULL; matchcomma=1; } break; default: err(bugparier,"identifier (unknown code)"); }#if 0 /* uncomment if using purify: UMR otherwise */ for ( ; i<9; i++) argvec[i]=NULL;#endif{ char *oldname = gp_function_name; gp_function_name = ep->name; if (deriv) { if (!i || (ep->code)[0] != 'G') err(talker2, "can't derive this", mark.identifier, mark.start); res = num_deriv(call, argvec); } else switch (ret) { case RET_GEN: res = ((PFGEN)call)(_ARGS_); break; case RET_INT: m = (long)((int (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_LONG: m = ((long (*)(ANYARG))call)(_ARGS_); res = stoi(m); break; case RET_VOID: ((void (*)(ANYARG))call)(_ARGS_); res = gnil; break; } gp_function_name = oldname;} if (has_pointer) check_pointers(has_pointer,init); if (!noparen) match(')'); return res; } if (EpPREDEFINED(ep)) { if (*analyseur != '(') { if (EpVALENCE(ep) == 88) return global0(); match('('); /* error */ } analyseur++; ch1 = analyseur; switch(EpVALENCE(ep)) { case 50: /* O */ res = truc(); NO_BREAK("in O()", ch1); if (*analyseur=='^') { analyseur++; m = readlong(); } else m = 1; res = ggrando(res,m); break; case 80: /* if then else */ av = avma; res = expr(); NO_BREAK("in test expression", ch1); m = gcmp0(res); avma = av; match(','); if (m) /* false */ { skipseq(); if (*analyseur == ')') res = gnil; else { match(','); res = seq(); if (br_status) { res = NULL; skipseq(); } } } else /* true */ { res = seq(); if (br_status) { res = NULL; skipseq(); } if (*analyseur != ')') { match(','); skipseq(); } } break; case 81: /* while do */ av = avma; for(;;) { res = expr(); NO_BREAK("in test expression", ch1); if (gcmp0(res)) { match(','); break; } avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; } avma = av; skipseq(); res = gnil; break; case 82: /* repeat until */ av = avma; skipexpr(); for(;;) { avma = av; match(','); (void)seq(); if (loop_break()) break; analyseur = ch1; res = expr(); NO_BREAK("in test expression", ch1); if (!gcmp0(res)) { match(','); break; } } avma = av; skipseq(); res = gnil; break; case 88: /* global */ if (*analyseur == ')') return global0(); matchcomma = 0; while (*analyseur != ')') { match_comma(); ch1 = analyseur; check_var_name(); ep = skipentry(); switch(EpVALENCE(ep)) { case EpGVAR: case EpVAR: break; default: err(talker2,"symbol already in use",ch1,mark.start); } analyseur = ch1; ep = entry(); if (*analyseur == '=') { pari_sp av=avma; analyseur++; ch1 = analyseur; res = expr(); NO_BREAK("here (defining global var)", ch1); changevalue(ep, res); avma=av; } ep->valence = EpGVAR; } res = gnil; break; default: err(valencer1); return NULL; /* not reached */ } match(')'); return res; } switch (EpVALENCE(ep)) { GEN *defarg; /* = default args, and values for local variables */ GEN *arglist; gp_args *f; case EpUSER: /* user-defined functions */ f = (gp_args*)ep->args; deriv = (*analyseur == '\'' && analyseur[1] == '(') && analyseur++; arglist = (GEN*) new_chunk(f->narg); if (*analyseur != '(') /* no args */ { if (*analyseur != '=' || analyseur[1] == '=') { for (i=0; i<f->narg; i++) arglist[i] = make_arg(f->arg[i]); return call_fun((GEN)ep->value, arglist, f); } match('('); /* ==> error */ } analyseur++; /* skip '(' */ ch1 = analyseur; skip_arg_block(f); if (*analyseur == ')' && (analyseur[1] != '=' || analyseur[2] == '=')) { matchcomma = 0; analyseur = ch1; for (i=0; i<f->narg; i++) { if (do_switch(0,matchcomma)) { /* default arg */ arglist[i] = make_arg(f->arg[i]); matchcomma = 1; } else { /* user supplied */ char *old; match_comma(); old = analyseur; arglist[i] = expr(); NO_BREAK("here (reading function args)", old); } } analyseur++; /* skip ')' */ if (deriv) { if (!f->narg) err(talker2, "can't derive this", mark.identifier, mark.start); return num_derivU((GEN)ep->value, arglist, f); } return call_fun((GEN)ep->value, arglist, f); } /* REDEFINE function */ if (*analyseur != ',' && *analyseur != ')') skipexpr(); while (*analyseur == ',') { analyseur++; skipexpr(); } match(')'); if (*analyseur != '=' || analyseur[1] == '=') err(talker2,"too many parameters in user-defined function call", mark.identifier,mark.start); analyseur = ch1-1; /* points to '(' */ free_args((gp_args*)ep->args); free(ep->args); ep->args = NULL; ep->valence = EpNEW; /* Fall through */ case EpNEW: /* new function */ { GEN tmpargs = (GEN)avma; char *start; long len, narg, nloc; check_new_fun = ep; /* checking arguments */ narg = check_args(); nloc = 0; /* Dirty, but don't want to define a local() function */ if (*analyseur != '=' && strcmp(ep->name, "local") == 0) err(talker2, "local() bloc must appear before any other expression", mark.identifier,mark.start); match('='); { /* checking function definition */ skipping_fun_def++; while (strncmp(analyseur,"local(",6) == 0) { analyseur += 5; /* on '(' */ nloc += check_args(); while(separe(*analyseur)) analyseur++; } start = analyseur; skipseq(); len = analyseur-start; skipping_fun_def--; } /* function is ok. record it */ /* record default args */ f = (gp_args*) gpmalloc((narg+nloc)*sizeof(GEN) + sizeof(gp_args)); ep->args = (void*) f; f->nloc = nloc; f->narg = narg; f->arg = defarg = (GEN*)(f + 1); narg += nloc; /* record default args and local variables */ newfun = ptr = (GEN) newbloc(1 + narg + nchar2nlong(len+1)); newfun++; /* this bloc is no GEN, leave the first cell alone ( = 0) */ for (i = 1; i <= narg; i++) { GEN cell = tmpargs-(i<<1); *newfun++ = cell[0]; *defarg++ = (GEN)cell[1]; } if (narg > 1) { /* check for duplicates */ GEN x = new_chunk(narg), v = ptr+1; long k; for (i=0; i<narg; i++) x[i] = v[i]; qsort(x,narg,sizeof(long),(QSCOMP)pari_compare_long); for (k=x[0],i=1; i<narg; k=x[i],i++) if (x[i] == k) err(talker,"user function %s: variable %Z declared twice", ep->name, polx[k]); } /* record text */ strncpy((char *)newfun, start, len); ((char *) newfun)[len] = 0; /* wait till here for gunclone because of strncopy above. In pathological * cases, e.g. (f()=f()=x), new text is given by value of old one! */ if (EpVALENCE(ep) == EpUSER) gunclone((GEN)ep->value); ep->value = (void *)ptr; ep->valence = EpUSER; check_new_fun=NULL; avma = (pari_sp)tmpargs; return gnil; } } err(valencer1); return NULL; /* not reached */} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d6bc6f7c8515f98a50f281cca0bb8c335aed5b17/anal.c/clean/src/language/anal.c |
y=x; j=1+bfffo(m); m<<=j; j = BITS_IN_LONG-j; | y=x; j=1+bfffo((ulong)m); m<<=j; j = BITS_IN_LONG-j; | Kronecker_powmod(GEN x, GEN mod, GEN n){ long lim,av,av0 = avma, i,j,m,v = varn(x); GEN y, p1, p = NULL, pol = NULL; for (i=lgef(mod)-1; i>1; i--) { p1 = (GEN)mod[i]; if (typ(p1) == t_POLMOD) { pol = (GEN)p1[1] ; break; } } if (!pol) err(talker,"need POLMOD coeffs in Kronecker_powmod"); for (i=lgef(pol)-1; i>1; i--) { p1 = (GEN)pol[i]; if (typ(p1) == t_INTMOD) { p = (GEN)p1[1] ; break; } } if (!p) err(talker,"need Fq coeffs in Kronecker_powmod"); x = lift_intern(to_Kronecker(x,pol)); /* adapted from powgi */ av=avma; lim=stack_lim(av,1); p1 = n+2; m = *p1; y=x; j=1+bfffo(m); m<<=j; j = BITS_IN_LONG-j; for (i=lgefint(n)-2;;) { for (; j; m<<=1,j--) { y = gsqr(y); y = from_Kronecker(FpX(y,p), pol); setvarn(y, v); y = gres(y, mod); y = lift_intern(to_Kronecker(y,pol)); if (m<0) { y = gmul(y,x); y = from_Kronecker(FpX(y,p), pol); setvarn(y, v); y = gres(y, mod); y = lift_intern(to_Kronecker(y,pol)); } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"Kronecker_powmod"); y = gerepilecopy(av, y); } } if (--i == 0) break; m = *++p1; j = BITS_IN_LONG; } y = from_Kronecker(FpX(y,p),pol); setvarn(y, v); return gerepileupto(av0, y);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/6f0450eaf26bb1653fbb257487c2cbc116d69406/polarit1.c/clean/src/basemath/polarit1.c |
bnf=bnfinit0(pol,signe(D)>1?1:0,NULL,prec); | bnf=bnfinit0(pol,signe(D)>0?1:0,NULL,prec); | quadray(GEN D, GEN f, GEN flag, long prec){ long av=avma,tetpil; GEN bnr,y,p1,pol,bnf,flagnew; if (typ(D)!=t_INT) { bnf = checkbnf(D); if (degree(gmael(bnf,7,1))!=2) err(talker,"not a polynomial of degree 2 in quadray"); D=gmael(bnf,7,3); } else { if (!isfundamental(D)) err(talker,"quadray needs a fundamental discriminant"); pol=quadpoly(D); setvarn(pol, fetch_user_var("y")); bnf=bnfinit0(pol,signe(D)>1?1:0,NULL,prec); } bnr=bnrinit0(bnf,f,1,prec); if (gcmp1(gmael(bnr,5,1))) { avma=av; if (!flag || gcmp0(flag)) return polx[0]; y=cgetg(2,t_VEC); p1=cgetg(3,t_VEC); y[1]=(long)p1; p1[1]=(long)idmat(2); p1[2]=(long)polx[0]; return y; } tetpil=avma; if (signe(D)>0) { if (flag && !gcmp0(flag)) err(warner,"ignoring flag in quadray"); y=bnrstark(bnr,gzero,1,prec); } else { if (!flag) flag = gzero; flagnew=flag; if (typ(flagnew)==t_INT) { flagnew=absi(flagnew); if (cmpis(flagnew,1)<=0) y=quadrayimagsigma(bnr,flagnew,prec); else y=quadrayimagwei(bnr,mpodd(flagnew) ? gun : gzero,prec); } else { if (typ(flagnew)!=t_VEC || lg(flagnew)<=2) err(flagerr,"quadray"); y=computeP2(bnr,(GEN)flagnew[1],(GEN)flagnew[2],prec); } if (typ(y)==t_VEC && lg(y)==1) { prec=(prec<<1)-2; avma=av; if (DEBUGLEVEL) err(warnprec,"quadray",prec); return quadray(D,f,flag,prec); } } return gerepile(av,tetpil,y);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/b90f3d485515f205afdb440e0ceb58e1f0482995/buch1.c/clean/src/basemath/buch1.c |
minSFB = (expi(D) > 10)? 3: 2; | minSFB = (expi(D) > 20)? 3: 2; | subFBquad(GEN D, double PROD, long KC){ long i, j, minSFB, lgsub = 1, ino = 1, lv = KC+1; double prod = 1.; pari_sp av; GEN no; minSFB = (expi(D) > 10)? 3: 2; vperm = cgetg(lv, t_VECSMALL); av = avma; no = cgetg(lv, t_VECSMALL); for (j = 1; j < lv; j++) { ulong p = FB[j]; if (!umodiu(D, p)) no[ino++] = j; /* ramified */ else { vperm[lgsub++] = j; prod *= p; if (lgsub > minSFB && prod > PROD) break; } } if (j == lv) return NULL; i = lgsub; for (j = 1; j < ino;i++,j++) vperm[i] = no[j]; for ( ; i < lv; i++) vperm[i] = i; if (DEBUGLEVEL) msgtimer("subFBquad (%ld elt.)", lgsub-1); no = gclone(vecslice(vperm, 1, lgsub-1)); avma = av; return no;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/6fef9e81fcafd84a90bad80fc21f166d8479c5f1/buch1.c/buggy/src/basemath/buch1.c |
if (DEBUGLEVEL>=3) | if (DEBUGLEVEL>5) | dbasis(GEN p, GEN f, long mf, GEN alpha, GEN U){ long n=degpol(f),dU,i; GEN b,ha,pd,pdp; if (n == 1) return gscalmat(gun, 1); if (DEBUGLEVEL>=3) { fprintferr(" entering Dedekind Basis "); if (DEBUGLEVEL>5) { fprintferr("with parameters p=%Z\n",p); fprintferr(" f = %Z,\n alpha = %Z",f,alpha); } fprintferr("\n"); } ha = pd = gpowgs(p,mf/2); pdp = mulii(pd,p); dU = typ(U)==t_POL? degpol(U): 0; b = cgetg(n,t_MAT); /* Z[a] + U/p Z[a] is maximal */ /* skip first column = gscalcol(pd,n) */ for (i=1; i<n; i++) { if (i == dU) { ha = gdiv(gmul(pd,RX_RXQ_compo(U,alpha,f)),p); ha = polmodi(ha,pdp); } else { GEN d, mod; ha = gmul(ha,alpha); ha = Q_remove_denom(ha, &d); mod = d? mulii(pdp,d): pdp; ha = FpX_res(ha, f, mod); if (d) ha = gdivexact(ha,d); } b[i] = (long)pol_to_vec(ha,n); } b = hnfmodid(b,pd); if (DEBUGLEVEL>5) fprintferr(" new order: %Z\n",b); return gdiv(b, pd);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/b53c2a08405189f6a07ca394dfaa0e9f4c997cf7/base2.c/clean/src/basemath/base2.c |
fprintferr(" entering Dedekind Basis "); if (DEBUGLEVEL>5) { fprintferr("with parameters p=%Z\n",p); fprintferr(" f = %Z,\n alpha = %Z",f,alpha); } fprintferr("\n"); | fprintferr(" entering Dedekind Basis with parameters p=%Z\n",p); fprintferr(" f = %Z,\n alpha = %Z\n",f,alpha); | dbasis(GEN p, GEN f, long mf, GEN alpha, GEN U){ long n=degpol(f),dU,i; GEN b,ha,pd,pdp; if (n == 1) return gscalmat(gun, 1); if (DEBUGLEVEL>=3) { fprintferr(" entering Dedekind Basis "); if (DEBUGLEVEL>5) { fprintferr("with parameters p=%Z\n",p); fprintferr(" f = %Z,\n alpha = %Z",f,alpha); } fprintferr("\n"); } ha = pd = gpowgs(p,mf/2); pdp = mulii(pd,p); dU = typ(U)==t_POL? degpol(U): 0; b = cgetg(n,t_MAT); /* Z[a] + U/p Z[a] is maximal */ /* skip first column = gscalcol(pd,n) */ for (i=1; i<n; i++) { if (i == dU) { ha = gdiv(gmul(pd,RX_RXQ_compo(U,alpha,f)),p); ha = polmodi(ha,pdp); } else { GEN d, mod; ha = gmul(ha,alpha); ha = Q_remove_denom(ha, &d); mod = d? mulii(pdp,d): pdp; ha = FpX_res(ha, f, mod); if (d) ha = gdivexact(ha,d); } b[i] = (long)pol_to_vec(ha,n); } b = hnfmodid(b,pd); if (DEBUGLEVEL>5) fprintferr(" new order: %Z\n",b); return gdiv(b, pd);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/b53c2a08405189f6a07ca394dfaa0e9f4c997cf7/base2.c/clean/src/basemath/base2.c |
rtems_libio_fcntl_flags(unsigned32 fcntl_flags) | unsigned32 rtems_libio_fcntl_flags( unsigned32 fcntl_flags ) | rtems_libio_fcntl_flags(unsigned32 fcntl_flags){ unsigned32 flags = 0; unsigned32 access_modes; /* * Access mode is a small integer */ access_modes = fcntl_flags & O_ACCMODE; fcntl_flags &= ~O_ACCMODE; flags = rtems_assoc_local_by_remote(access_modes_assoc, access_modes); /* * Everything else is single bits */ flags |= rtems_assoc_local_by_remote_bitfield(status_flags_assoc, fcntl_flags); return flags;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
unsigned32 flags = 0; unsigned32 access_modes; | unsigned32 flags = 0; unsigned32 access_modes; | rtems_libio_fcntl_flags(unsigned32 fcntl_flags){ unsigned32 flags = 0; unsigned32 access_modes; /* * Access mode is a small integer */ access_modes = fcntl_flags & O_ACCMODE; fcntl_flags &= ~O_ACCMODE; flags = rtems_assoc_local_by_remote(access_modes_assoc, access_modes); /* * Everything else is single bits */ flags |= rtems_assoc_local_by_remote_bitfield(status_flags_assoc, fcntl_flags); return flags;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
/* * Access mode is a small integer */ access_modes = fcntl_flags & O_ACCMODE; fcntl_flags &= ~O_ACCMODE; flags = rtems_assoc_local_by_remote(access_modes_assoc, access_modes); | /* * Access mode is a small integer */ access_modes = fcntl_flags & O_ACCMODE; fcntl_flags &= ~O_ACCMODE; flags = rtems_assoc_local_by_remote( access_modes_assoc, access_modes ); | rtems_libio_fcntl_flags(unsigned32 fcntl_flags){ unsigned32 flags = 0; unsigned32 access_modes; /* * Access mode is a small integer */ access_modes = fcntl_flags & O_ACCMODE; fcntl_flags &= ~O_ACCMODE; flags = rtems_assoc_local_by_remote(access_modes_assoc, access_modes); /* * Everything else is single bits */ flags |= rtems_assoc_local_by_remote_bitfield(status_flags_assoc, fcntl_flags); return flags;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
/* * Everything else is single bits */ | /* * Everything else is single bits */ | rtems_libio_fcntl_flags(unsigned32 fcntl_flags){ unsigned32 flags = 0; unsigned32 access_modes; /* * Access mode is a small integer */ access_modes = fcntl_flags & O_ACCMODE; fcntl_flags &= ~O_ACCMODE; flags = rtems_assoc_local_by_remote(access_modes_assoc, access_modes); /* * Everything else is single bits */ flags |= rtems_assoc_local_by_remote_bitfield(status_flags_assoc, fcntl_flags); return flags;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
flags |= rtems_assoc_local_by_remote_bitfield(status_flags_assoc, fcntl_flags); return flags; | flags |= rtems_assoc_local_by_remote_bitfield(status_flags_assoc, fcntl_flags); return flags; | rtems_libio_fcntl_flags(unsigned32 fcntl_flags){ unsigned32 flags = 0; unsigned32 access_modes; /* * Access mode is a small integer */ access_modes = fcntl_flags & O_ACCMODE; fcntl_flags &= ~O_ACCMODE; flags = rtems_assoc_local_by_remote(access_modes_assoc, access_modes); /* * Everything else is single bits */ flags |= rtems_assoc_local_by_remote_bitfield(status_flags_assoc, fcntl_flags); return flags;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
rtems_libio_allocate(void) | rtems_libio_t *rtems_libio_allocate( void ) | rtems_libio_allocate(void){ rtems_libio_t *iop; rtems_status_code rc; rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); for (iop = rtems_libio_iops; iop <= rtems_libio_last_iop; iop++) if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) { /* * Got one; create a semaphore for it */ rc = rtems_semaphore_create( RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops), 1, RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, RTEMS_NO_PRIORITY, &iop->sem ); if (rc != RTEMS_SUCCESSFUL) goto failed; iop->flags = LIBIO_FLAGS_OPEN; goto done; } failed: iop = 0; done: rtems_semaphore_release(rtems_libio_semaphore); return iop;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
rtems_libio_t *iop; rtems_status_code rc; | rtems_libio_t *iop; rtems_status_code rc; rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); for (iop = rtems_libio_iops; iop <= rtems_libio_last_iop; iop++) if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) { /* * Got an IOP -- create a semaphore for it. */ rc = rtems_semaphore_create( RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops), 1, RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, RTEMS_NO_PRIORITY, &iop->sem ); if ( rc != RTEMS_SUCCESSFUL ) goto failed; | rtems_libio_allocate(void){ rtems_libio_t *iop; rtems_status_code rc; rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); for (iop = rtems_libio_iops; iop <= rtems_libio_last_iop; iop++) if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) { /* * Got one; create a semaphore for it */ rc = rtems_semaphore_create( RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops), 1, RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, RTEMS_NO_PRIORITY, &iop->sem ); if (rc != RTEMS_SUCCESSFUL) goto failed; iop->flags = LIBIO_FLAGS_OPEN; goto done; } failed: iop = 0; done: rtems_semaphore_release(rtems_libio_semaphore); return iop;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); for (iop = rtems_libio_iops; iop <= rtems_libio_last_iop; iop++) if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) { /* * Got one; create a semaphore for it */ rc = rtems_semaphore_create( RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops), 1, RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, RTEMS_NO_PRIORITY, &iop->sem ); if (rc != RTEMS_SUCCESSFUL) goto failed; iop->flags = LIBIO_FLAGS_OPEN; goto done; } | iop->flags = LIBIO_FLAGS_OPEN; goto done; } | rtems_libio_allocate(void){ rtems_libio_t *iop; rtems_status_code rc; rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); for (iop = rtems_libio_iops; iop <= rtems_libio_last_iop; iop++) if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) { /* * Got one; create a semaphore for it */ rc = rtems_semaphore_create( RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops), 1, RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, RTEMS_NO_PRIORITY, &iop->sem ); if (rc != RTEMS_SUCCESSFUL) goto failed; iop->flags = LIBIO_FLAGS_OPEN; goto done; } failed: iop = 0; done: rtems_semaphore_release(rtems_libio_semaphore); return iop;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
iop = 0; | iop = 0; | rtems_libio_allocate(void){ rtems_libio_t *iop; rtems_status_code rc; rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); for (iop = rtems_libio_iops; iop <= rtems_libio_last_iop; iop++) if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) { /* * Got one; create a semaphore for it */ rc = rtems_semaphore_create( RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops), 1, RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, RTEMS_NO_PRIORITY, &iop->sem ); if (rc != RTEMS_SUCCESSFUL) goto failed; iop->flags = LIBIO_FLAGS_OPEN; goto done; } failed: iop = 0; done: rtems_semaphore_release(rtems_libio_semaphore); return iop;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
rtems_semaphore_release(rtems_libio_semaphore); return iop; | rtems_semaphore_release( rtems_libio_semaphore ); return iop; | rtems_libio_allocate(void){ rtems_libio_t *iop; rtems_status_code rc; rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); for (iop = rtems_libio_iops; iop <= rtems_libio_last_iop; iop++) if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) { /* * Got one; create a semaphore for it */ rc = rtems_semaphore_create( RTEMS_LIBIO_IOP_SEM(iop - rtems_libio_iops), 1, RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY, RTEMS_NO_PRIORITY, &iop->sem ); if (rc != RTEMS_SUCCESSFUL) goto failed; iop->flags = LIBIO_FLAGS_OPEN; goto done; } failed: iop = 0; done: rtems_semaphore_release(rtems_libio_semaphore); return iop;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
rtems_libio_free(rtems_libio_t *iop) | void rtems_libio_free( rtems_libio_t *iop ) | rtems_libio_free(rtems_libio_t *iop){ rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (iop->sem) rtems_semaphore_delete(iop->sem); (void) memset(iop, 0, sizeof(*iop)); rtems_semaphore_release(rtems_libio_semaphore);} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); | rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT ); | rtems_libio_free(rtems_libio_t *iop){ rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (iop->sem) rtems_semaphore_delete(iop->sem); (void) memset(iop, 0, sizeof(*iop)); rtems_semaphore_release(rtems_libio_semaphore);} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
if (iop->sem) rtems_semaphore_delete(iop->sem); (void) memset(iop, 0, sizeof(*iop)); | if (iop->sem) rtems_semaphore_delete(iop->sem); | rtems_libio_free(rtems_libio_t *iop){ rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (iop->sem) rtems_semaphore_delete(iop->sem); (void) memset(iop, 0, sizeof(*iop)); rtems_semaphore_release(rtems_libio_semaphore);} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
rtems_semaphore_release(rtems_libio_semaphore); | (void) memset(iop, 0, sizeof(*iop)); rtems_semaphore_release( rtems_libio_semaphore ); | rtems_libio_free(rtems_libio_t *iop){ rtems_semaphore_obtain(rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT); if (iop->sem) rtems_semaphore_delete(iop->sem); (void) memset(iop, 0, sizeof(*iop)); rtems_semaphore_release(rtems_libio_semaphore);} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/libio.c/clean/c/src/exec/libcsupport/src/libio.c |
#if 0 | #if !defined(__rtems__) | res_send(buf, buflen, ans, anssiz) const u_char *buf; int buflen; u_char *ans; int anssiz;{ HEADER *hp = (HEADER *) buf; HEADER *anhp = (HEADER *) ans; int gotsomewhere, connreset, terrno, try, v_circuit, resplen, ns, n; u_int badns; /* XXX NSMAX can't exceed #/bits in this variable */ if ((_res.options & RES_INIT) == 0 && res_init() == -1) { /* errno should have been set by res_init() in this case. */ return (-1); } if (anssiz < HFIXEDSZ) { errno = EINVAL; return (-1); } DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_QUERY), (stdout, ";; res_send()\n"), buf, buflen); v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ; gotsomewhere = 0; connreset = 0; terrno = ETIMEDOUT; badns = 0; /* * Send request, RETRY times, or until successful */ for (try = 0; try < _res.retry; try++) { for (ns = 0; ns < _res.nscount; ns++) { struct sockaddr_in *nsap = &_res.nsaddr_list[ns]; same_ns: if (badns & (1 << ns)) { res_close(); goto next_ns; } if (Qhook) { int done = 0, loops = 0; do { res_sendhookact act; act = (*Qhook)(&nsap, &buf, &buflen, ans, anssiz, &resplen); switch (act) { case res_goahead: done = 1; break; case res_nextns: res_close(); goto next_ns; case res_done: return (resplen); case res_modified: /* give the hook another try */ if (++loops < 42) /*doug adams*/ break; /*FALLTHROUGH*/ case res_error: /*FALLTHROUGH*/ default: return (-1); } } while (!done); } Dprint(_res.options & RES_DEBUG, (stdout, ";; Querying server (# %d) address = %s\n", ns + 1, inet_ntoa(nsap->sin_addr))); if (v_circuit) { int truncated; struct iovec iov[2]; u_short len; u_char *cp; /* * Use virtual circuit; * at most one attempt per server. */ try = _res.retry; truncated = 0; if (s < 0 || !vc || hp->opcode == ns_o_update) { if (s >= 0) res_close(); s = socket(PF_INET, SOCK_STREAM, 0); if (s < 0) { terrno = errno; Perror(stderr, "socket(vc)", errno); return (-1); } errno = 0; if (connect(s, (struct sockaddr *)nsap, sizeof *nsap) < 0) { terrno = errno; Aerror(stderr, "connect/vc", errno, *nsap); badns |= (1 << ns); res_close(); goto next_ns; } vc = 1; } /* * Send length & message */ putshort((u_short)buflen, (u_char*)&len);#if 0 iov[0].iov_base = (caddr_t)&len; iov[0].iov_len = INT16SZ; iov[1].iov_base = (caddr_t)buf; iov[1].iov_len = buflen; if (writev(s, iov, 2) != (INT16SZ + buflen)) {#else /* * RTEMS doesn't have writev (yet) */ if ((write (s, len, INT16SZ) != INT16SZ) || (write (s, buf, buflen) != buflen)) {#endif terrno = errno; Perror(stderr, "write failed", errno); badns |= (1 << ns); res_close(); goto next_ns; } /* * Receive length & response */read_len: cp = ans; len = INT16SZ; while ((n = read(s, (char *)cp, (int)len)) > 0) { cp += n; if ((len -= n) <= 0) break; } if (n <= 0) { terrno = errno; Perror(stderr, "read failed", errno); res_close(); /* * A long running process might get its TCP * connection reset if the remote server was * restarted. Requery the server instead of * trying a new one. When there is only one * server, this means that a query might work * instead of failing. We only allow one reset * per query to prevent looping. */ if (terrno == ECONNRESET && !connreset) { connreset = 1; res_close(); goto same_ns; } res_close(); goto next_ns; } resplen = ns_get16(ans); if (resplen > anssiz) { Dprint(_res.options & RES_DEBUG, (stdout, ";; response truncated\n") ); truncated = 1; len = anssiz; } else len = resplen; if (len < HFIXEDSZ) { /* * Undersized message. */ Dprint(_res.options & RES_DEBUG, (stdout, ";; undersized: %d\n", len)); terrno = EMSGSIZE; badns |= (1 << ns); res_close(); goto next_ns; } cp = ans; while (len != 0 && (n = read(s, (char *)cp, (int)len)) > 0) { cp += n; len -= n; } if (n <= 0) { terrno = errno; Perror(stderr, "read(vc)", errno); res_close(); goto next_ns; } if (truncated) { /* * Flush rest of answer * so connection stays in synch. */ anhp->tc = 1; len = resplen - anssiz; while (len != 0) { char junk[PACKETSZ]; n = (len > sizeof(junk) ? sizeof(junk) : len); if ((n = read(s, junk, n)) > 0) len -= n; else break; } } /* * The calling applicating has bailed out of * a previous call and failed to arrange to have * the circuit closed or the server has got * itself confused. Anyway drop the packet and * wait for the correct one. */ if (hp->id != anhp->id) { DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ";; old answer (unexpected):\n"), ans, (resplen>anssiz)?anssiz:resplen); goto read_len; } } else { /* * Use datagrams. */#ifndef NOPOLL struct pollfd pfd; int msec;#endif struct timeval timeout; fd_set dsmask, *dsmaskp; int dsmasklen; struct sockaddr_in from; int fromlen; if ((s < 0) || vc) { if (vc) res_close(); s = socket(PF_INET, SOCK_DGRAM, 0); if (s < 0) {#ifndef CAN_RECONNECT bad_dg_sock:#endif terrno = errno; Perror(stderr, "socket(dg)", errno); return (-1); } connected = 0; }#ifndef CANNOT_CONNECT_DGRAM /* * On a 4.3BSD+ machine (client and server, * actually), sending to a nameserver datagram * port with no nameserver will cause an * ICMP port unreachable message to be returned. * If our datagram socket is "connected" to the * server, we get an ECONNREFUSED error on the next * socket operation, and select returns if the * error message is received. We can thus detect * the absence of a nameserver without timing out. * If we have sent queries to at least two servers, * however, we don't want to remain connected, * as we wish to receive answers from the first * server to respond. */ if (_res.nscount == 1 || (try == 0 && ns == 0)) { /* * Connect only if we are sure we won't * receive a response from another server. */ if (!connected) { if (connect(s, (struct sockaddr *)nsap, sizeof *nsap ) < 0) { Aerror(stderr, "connect(dg)", errno, *nsap); badns |= (1 << ns); res_close(); goto next_ns; } connected = 1; } if (send(s, (char*)buf, buflen, 0) != buflen) { Perror(stderr, "send", errno); badns |= (1 << ns); res_close(); goto next_ns; } } else { /* * Disconnect if we want to listen * for responses from more than one server. */ if (connected) {#ifdef CAN_RECONNECT struct sockaddr_in no_addr; no_addr.sin_family = AF_INET; no_addr.sin_addr.s_addr = INADDR_ANY; no_addr.sin_port = 0; (void) connect(s, (struct sockaddr *) &no_addr, sizeof no_addr);#else int s1 = socket(PF_INET, SOCK_DGRAM,0); if (s1 < 0) goto bad_dg_sock; (void) dup2(s1, s); (void) close(s1); Dprint(_res.options & RES_DEBUG, (stdout, ";; new DG socket\n"))#endif /* CAN_RECONNECT */ connected = 0; errno = 0; }#endif /* !CANNOT_CONNECT_DGRAM */ if (sendto(s, (char*)buf, buflen, 0, (struct sockaddr *)nsap, sizeof *nsap) != buflen) { Aerror(stderr, "sendto", errno, *nsap); badns |= (1 << ns); res_close(); goto next_ns; }#ifndef CANNOT_CONNECT_DGRAM }#endif /* !CANNOT_CONNECT_DGRAM */ /* * Wait for reply */#ifndef NOPOLL othersyscall: if (use_poll) { msec = (_res.retrans << try) * 1000; if (try > 0) msec /= _res.nscount; if (msec <= 0) msec = 1000; } else {#endif timeout.tv_sec = (_res.retrans << try); if (try > 0) timeout.tv_sec /= _res.nscount; if ((long) timeout.tv_sec <= 0) timeout.tv_sec = 1; timeout.tv_usec = 0;#ifndef NOPOLL }#endif wait: if (s < 0) { Perror(stderr, "s out-of-bounds", EMFILE); res_close(); goto next_ns; }#ifndef NOPOLL if (use_poll) { struct sigaction sa, osa; int sigsys_installed = 0; pfd.fd = s; pfd.events = POLLIN; if (use_poll == 1) { bzero(&sa, sizeof(sa)); sa.sa_handler = SIG_IGN; if (sigaction(SIGSYS, &sa, &osa) >= 0) sigsys_installed = 1; } n = poll(&pfd, 1, msec); if (sigsys_installed == 1) { int oerrno = errno; sigaction(SIGSYS, &osa, NULL); errno = oerrno; } /* XXX why does nosys() return EINVAL? */ if (n < 0 && (errno == ENOSYS || errno == EINVAL)) { use_poll = 0; goto othersyscall; } else if (use_poll == 1) use_poll = 2; if (n < 0) { if (errno == EINTR) goto wait; Perror(stderr, "poll", errno); res_close(); goto next_ns; } } else {#endif#ifndef NOSELECT dsmasklen = howmany(s + 1, NFDBITS) * sizeof(fd_mask); if (dsmasklen > sizeof(fd_set)) { dsmaskp = (fd_set *)malloc(dsmasklen); if (dsmaskp == NULL) { res_close(); goto next_ns; } } else dsmaskp = &dsmask; /* only zero what we need */ bzero((char *)dsmaskp, dsmasklen); FD_SET(s, dsmaskp); n = select(s + 1, dsmaskp, (fd_set *)NULL, (fd_set *)NULL, &timeout); if (dsmaskp != &dsmask) free(dsmaskp); if (n < 0) { if (errno == EINTR) goto wait; Perror(stderr, "select", errno); res_close(); goto next_ns; }#endif#ifndef NOPOLL }#endif#ifdef NOSELECT setsockopt (s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout);#else if (n == 0) { /* * timeout */ Dprint(_res.options & RES_DEBUG, (stdout, ";; timeout\n")); gotsomewhere = 1; res_close(); goto next_ns; }#endif errno = 0; fromlen = sizeof(struct sockaddr_in); resplen = recvfrom(s, (char*)ans, anssiz, 0, (struct sockaddr *)&from, &fromlen); if (resplen <= 0) {#ifdef NOSELECT if (errno == ETIMEDOUT) { Dprint(_res.options & RES_DEBUG, (stdout, ";; timeout\n")); gotsomewhere = 1; res_close(); goto next_ns; }#endif Perror(stderr, "recvfrom", errno); res_close(); goto next_ns; } gotsomewhere = 1; if (resplen < HFIXEDSZ) { /* * Undersized message. */ Dprint(_res.options & RES_DEBUG, (stdout, ";; undersized: %d\n", resplen)); terrno = EMSGSIZE; badns |= (1 << ns); res_close(); goto next_ns; } if (hp->id != anhp->id) { /* * response from old query, ignore it. * XXX - potential security hazard could * be detected here. */ DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ";; old answer:\n"), ans, (resplen>anssiz)?anssiz:resplen); goto wait; }#ifdef CHECK_SRVR_ADDR if (!(_res.options & RES_INSECURE1) && !res_isourserver(&from)) { /* * response from wrong server? ignore it. * XXX - potential security hazard could * be detected here. */ DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ";; not our server:\n"), ans, (resplen>anssiz)?anssiz:resplen); goto wait; }#endif if (!(_res.options & RES_INSECURE2) && !res_queriesmatch(buf, buf + buflen, ans, ans + anssiz)) { /* * response contains wrong query? ignore it. * XXX - potential security hazard could * be detected here. */ DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ";; wrong query name:\n"), ans, (resplen>anssiz)?anssiz:resplen); goto wait; } if (anhp->rcode == SERVFAIL || anhp->rcode == NOTIMP || anhp->rcode == REFUSED) { DprintQ(_res.options & RES_DEBUG, (stdout, "server rejected query:\n"), ans, (resplen>anssiz)?anssiz:resplen); badns |= (1 << ns); res_close(); /* don't retry if called from dig */ if (!_res.pfcode) goto next_ns; } if (!(_res.options & RES_IGNTC) && anhp->tc) { /* * get rest of answer; * use TCP with same server. */ Dprint(_res.options & RES_DEBUG, (stdout, ";; truncated answer\n")); v_circuit = 1; res_close(); goto same_ns; } } /*if vc/dg*/ Dprint((_res.options & RES_DEBUG) || ((_res.pfcode & RES_PRF_REPLY) && (_res.pfcode & RES_PRF_HEAD1)), (stdout, ";; got answer:\n")); DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ""), ans, (resplen>anssiz)?anssiz:resplen); /* * If using virtual circuits, we assume that the first server * is preferred over the rest (i.e. it is on the local * machine) and only keep that one open. * If we have temporarily opened a virtual circuit, * or if we haven't been asked to keep a socket open, * close the socket. */ if ((v_circuit && (!(_res.options & RES_USEVC) || ns != 0)) || !(_res.options & RES_STAYOPEN)) { res_close(); } if (Rhook) { int done = 0, loops = 0; do { res_sendhookact act; act = (*Rhook)(nsap, buf, buflen, ans, anssiz, &resplen); switch (act) { case res_goahead: case res_done: done = 1; break; case res_nextns: res_close(); goto next_ns; case res_modified: /* give the hook another try */ if (++loops < 42) /*doug adams*/ break; /*FALLTHROUGH*/ case res_error: /*FALLTHROUGH*/ default: return (-1); } } while (!done); } return (resplen); next_ns: ; } /*foreach ns*/ } /*foreach retry*/ res_close(); if (!v_circuit) { if (!gotsomewhere) errno = ECONNREFUSED; /* no nameservers found */ else errno = ETIMEDOUT; /* no answer obtained */ } else errno = terrno; return (-1);} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/res_send.c/buggy/c/src/libnetworking/libc/res_send.c |
#endif | res_send(buf, buflen, ans, anssiz) const u_char *buf; int buflen; u_char *ans; int anssiz;{ HEADER *hp = (HEADER *) buf; HEADER *anhp = (HEADER *) ans; int gotsomewhere, connreset, terrno, try, v_circuit, resplen, ns, n; u_int badns; /* XXX NSMAX can't exceed #/bits in this variable */ if ((_res.options & RES_INIT) == 0 && res_init() == -1) { /* errno should have been set by res_init() in this case. */ return (-1); } if (anssiz < HFIXEDSZ) { errno = EINVAL; return (-1); } DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_QUERY), (stdout, ";; res_send()\n"), buf, buflen); v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ; gotsomewhere = 0; connreset = 0; terrno = ETIMEDOUT; badns = 0; /* * Send request, RETRY times, or until successful */ for (try = 0; try < _res.retry; try++) { for (ns = 0; ns < _res.nscount; ns++) { struct sockaddr_in *nsap = &_res.nsaddr_list[ns]; same_ns: if (badns & (1 << ns)) { res_close(); goto next_ns; } if (Qhook) { int done = 0, loops = 0; do { res_sendhookact act; act = (*Qhook)(&nsap, &buf, &buflen, ans, anssiz, &resplen); switch (act) { case res_goahead: done = 1; break; case res_nextns: res_close(); goto next_ns; case res_done: return (resplen); case res_modified: /* give the hook another try */ if (++loops < 42) /*doug adams*/ break; /*FALLTHROUGH*/ case res_error: /*FALLTHROUGH*/ default: return (-1); } } while (!done); } Dprint(_res.options & RES_DEBUG, (stdout, ";; Querying server (# %d) address = %s\n", ns + 1, inet_ntoa(nsap->sin_addr))); if (v_circuit) { int truncated; struct iovec iov[2]; u_short len; u_char *cp; /* * Use virtual circuit; * at most one attempt per server. */ try = _res.retry; truncated = 0; if (s < 0 || !vc || hp->opcode == ns_o_update) { if (s >= 0) res_close(); s = socket(PF_INET, SOCK_STREAM, 0); if (s < 0) { terrno = errno; Perror(stderr, "socket(vc)", errno); return (-1); } errno = 0; if (connect(s, (struct sockaddr *)nsap, sizeof *nsap) < 0) { terrno = errno; Aerror(stderr, "connect/vc", errno, *nsap); badns |= (1 << ns); res_close(); goto next_ns; } vc = 1; } /* * Send length & message */ putshort((u_short)buflen, (u_char*)&len);#if 0 iov[0].iov_base = (caddr_t)&len; iov[0].iov_len = INT16SZ; iov[1].iov_base = (caddr_t)buf; iov[1].iov_len = buflen; if (writev(s, iov, 2) != (INT16SZ + buflen)) {#else /* * RTEMS doesn't have writev (yet) */ if ((write (s, len, INT16SZ) != INT16SZ) || (write (s, buf, buflen) != buflen)) {#endif terrno = errno; Perror(stderr, "write failed", errno); badns |= (1 << ns); res_close(); goto next_ns; } /* * Receive length & response */read_len: cp = ans; len = INT16SZ; while ((n = read(s, (char *)cp, (int)len)) > 0) { cp += n; if ((len -= n) <= 0) break; } if (n <= 0) { terrno = errno; Perror(stderr, "read failed", errno); res_close(); /* * A long running process might get its TCP * connection reset if the remote server was * restarted. Requery the server instead of * trying a new one. When there is only one * server, this means that a query might work * instead of failing. We only allow one reset * per query to prevent looping. */ if (terrno == ECONNRESET && !connreset) { connreset = 1; res_close(); goto same_ns; } res_close(); goto next_ns; } resplen = ns_get16(ans); if (resplen > anssiz) { Dprint(_res.options & RES_DEBUG, (stdout, ";; response truncated\n") ); truncated = 1; len = anssiz; } else len = resplen; if (len < HFIXEDSZ) { /* * Undersized message. */ Dprint(_res.options & RES_DEBUG, (stdout, ";; undersized: %d\n", len)); terrno = EMSGSIZE; badns |= (1 << ns); res_close(); goto next_ns; } cp = ans; while (len != 0 && (n = read(s, (char *)cp, (int)len)) > 0) { cp += n; len -= n; } if (n <= 0) { terrno = errno; Perror(stderr, "read(vc)", errno); res_close(); goto next_ns; } if (truncated) { /* * Flush rest of answer * so connection stays in synch. */ anhp->tc = 1; len = resplen - anssiz; while (len != 0) { char junk[PACKETSZ]; n = (len > sizeof(junk) ? sizeof(junk) : len); if ((n = read(s, junk, n)) > 0) len -= n; else break; } } /* * The calling applicating has bailed out of * a previous call and failed to arrange to have * the circuit closed or the server has got * itself confused. Anyway drop the packet and * wait for the correct one. */ if (hp->id != anhp->id) { DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ";; old answer (unexpected):\n"), ans, (resplen>anssiz)?anssiz:resplen); goto read_len; } } else { /* * Use datagrams. */#ifndef NOPOLL struct pollfd pfd; int msec;#endif struct timeval timeout; fd_set dsmask, *dsmaskp; int dsmasklen; struct sockaddr_in from; int fromlen; if ((s < 0) || vc) { if (vc) res_close(); s = socket(PF_INET, SOCK_DGRAM, 0); if (s < 0) {#ifndef CAN_RECONNECT bad_dg_sock:#endif terrno = errno; Perror(stderr, "socket(dg)", errno); return (-1); } connected = 0; }#ifndef CANNOT_CONNECT_DGRAM /* * On a 4.3BSD+ machine (client and server, * actually), sending to a nameserver datagram * port with no nameserver will cause an * ICMP port unreachable message to be returned. * If our datagram socket is "connected" to the * server, we get an ECONNREFUSED error on the next * socket operation, and select returns if the * error message is received. We can thus detect * the absence of a nameserver without timing out. * If we have sent queries to at least two servers, * however, we don't want to remain connected, * as we wish to receive answers from the first * server to respond. */ if (_res.nscount == 1 || (try == 0 && ns == 0)) { /* * Connect only if we are sure we won't * receive a response from another server. */ if (!connected) { if (connect(s, (struct sockaddr *)nsap, sizeof *nsap ) < 0) { Aerror(stderr, "connect(dg)", errno, *nsap); badns |= (1 << ns); res_close(); goto next_ns; } connected = 1; } if (send(s, (char*)buf, buflen, 0) != buflen) { Perror(stderr, "send", errno); badns |= (1 << ns); res_close(); goto next_ns; } } else { /* * Disconnect if we want to listen * for responses from more than one server. */ if (connected) {#ifdef CAN_RECONNECT struct sockaddr_in no_addr; no_addr.sin_family = AF_INET; no_addr.sin_addr.s_addr = INADDR_ANY; no_addr.sin_port = 0; (void) connect(s, (struct sockaddr *) &no_addr, sizeof no_addr);#else int s1 = socket(PF_INET, SOCK_DGRAM,0); if (s1 < 0) goto bad_dg_sock; (void) dup2(s1, s); (void) close(s1); Dprint(_res.options & RES_DEBUG, (stdout, ";; new DG socket\n"))#endif /* CAN_RECONNECT */ connected = 0; errno = 0; }#endif /* !CANNOT_CONNECT_DGRAM */ if (sendto(s, (char*)buf, buflen, 0, (struct sockaddr *)nsap, sizeof *nsap) != buflen) { Aerror(stderr, "sendto", errno, *nsap); badns |= (1 << ns); res_close(); goto next_ns; }#ifndef CANNOT_CONNECT_DGRAM }#endif /* !CANNOT_CONNECT_DGRAM */ /* * Wait for reply */#ifndef NOPOLL othersyscall: if (use_poll) { msec = (_res.retrans << try) * 1000; if (try > 0) msec /= _res.nscount; if (msec <= 0) msec = 1000; } else {#endif timeout.tv_sec = (_res.retrans << try); if (try > 0) timeout.tv_sec /= _res.nscount; if ((long) timeout.tv_sec <= 0) timeout.tv_sec = 1; timeout.tv_usec = 0;#ifndef NOPOLL }#endif wait: if (s < 0) { Perror(stderr, "s out-of-bounds", EMFILE); res_close(); goto next_ns; }#ifndef NOPOLL if (use_poll) { struct sigaction sa, osa; int sigsys_installed = 0; pfd.fd = s; pfd.events = POLLIN; if (use_poll == 1) { bzero(&sa, sizeof(sa)); sa.sa_handler = SIG_IGN; if (sigaction(SIGSYS, &sa, &osa) >= 0) sigsys_installed = 1; } n = poll(&pfd, 1, msec); if (sigsys_installed == 1) { int oerrno = errno; sigaction(SIGSYS, &osa, NULL); errno = oerrno; } /* XXX why does nosys() return EINVAL? */ if (n < 0 && (errno == ENOSYS || errno == EINVAL)) { use_poll = 0; goto othersyscall; } else if (use_poll == 1) use_poll = 2; if (n < 0) { if (errno == EINTR) goto wait; Perror(stderr, "poll", errno); res_close(); goto next_ns; } } else {#endif#ifndef NOSELECT dsmasklen = howmany(s + 1, NFDBITS) * sizeof(fd_mask); if (dsmasklen > sizeof(fd_set)) { dsmaskp = (fd_set *)malloc(dsmasklen); if (dsmaskp == NULL) { res_close(); goto next_ns; } } else dsmaskp = &dsmask; /* only zero what we need */ bzero((char *)dsmaskp, dsmasklen); FD_SET(s, dsmaskp); n = select(s + 1, dsmaskp, (fd_set *)NULL, (fd_set *)NULL, &timeout); if (dsmaskp != &dsmask) free(dsmaskp); if (n < 0) { if (errno == EINTR) goto wait; Perror(stderr, "select", errno); res_close(); goto next_ns; }#endif#ifndef NOPOLL }#endif#ifdef NOSELECT setsockopt (s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof timeout);#else if (n == 0) { /* * timeout */ Dprint(_res.options & RES_DEBUG, (stdout, ";; timeout\n")); gotsomewhere = 1; res_close(); goto next_ns; }#endif errno = 0; fromlen = sizeof(struct sockaddr_in); resplen = recvfrom(s, (char*)ans, anssiz, 0, (struct sockaddr *)&from, &fromlen); if (resplen <= 0) {#ifdef NOSELECT if (errno == ETIMEDOUT) { Dprint(_res.options & RES_DEBUG, (stdout, ";; timeout\n")); gotsomewhere = 1; res_close(); goto next_ns; }#endif Perror(stderr, "recvfrom", errno); res_close(); goto next_ns; } gotsomewhere = 1; if (resplen < HFIXEDSZ) { /* * Undersized message. */ Dprint(_res.options & RES_DEBUG, (stdout, ";; undersized: %d\n", resplen)); terrno = EMSGSIZE; badns |= (1 << ns); res_close(); goto next_ns; } if (hp->id != anhp->id) { /* * response from old query, ignore it. * XXX - potential security hazard could * be detected here. */ DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ";; old answer:\n"), ans, (resplen>anssiz)?anssiz:resplen); goto wait; }#ifdef CHECK_SRVR_ADDR if (!(_res.options & RES_INSECURE1) && !res_isourserver(&from)) { /* * response from wrong server? ignore it. * XXX - potential security hazard could * be detected here. */ DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ";; not our server:\n"), ans, (resplen>anssiz)?anssiz:resplen); goto wait; }#endif if (!(_res.options & RES_INSECURE2) && !res_queriesmatch(buf, buf + buflen, ans, ans + anssiz)) { /* * response contains wrong query? ignore it. * XXX - potential security hazard could * be detected here. */ DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ";; wrong query name:\n"), ans, (resplen>anssiz)?anssiz:resplen); goto wait; } if (anhp->rcode == SERVFAIL || anhp->rcode == NOTIMP || anhp->rcode == REFUSED) { DprintQ(_res.options & RES_DEBUG, (stdout, "server rejected query:\n"), ans, (resplen>anssiz)?anssiz:resplen); badns |= (1 << ns); res_close(); /* don't retry if called from dig */ if (!_res.pfcode) goto next_ns; } if (!(_res.options & RES_IGNTC) && anhp->tc) { /* * get rest of answer; * use TCP with same server. */ Dprint(_res.options & RES_DEBUG, (stdout, ";; truncated answer\n")); v_circuit = 1; res_close(); goto same_ns; } } /*if vc/dg*/ Dprint((_res.options & RES_DEBUG) || ((_res.pfcode & RES_PRF_REPLY) && (_res.pfcode & RES_PRF_HEAD1)), (stdout, ";; got answer:\n")); DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_REPLY), (stdout, ""), ans, (resplen>anssiz)?anssiz:resplen); /* * If using virtual circuits, we assume that the first server * is preferred over the rest (i.e. it is on the local * machine) and only keep that one open. * If we have temporarily opened a virtual circuit, * or if we haven't been asked to keep a socket open, * close the socket. */ if ((v_circuit && (!(_res.options & RES_USEVC) || ns != 0)) || !(_res.options & RES_STAYOPEN)) { res_close(); } if (Rhook) { int done = 0, loops = 0; do { res_sendhookact act; act = (*Rhook)(nsap, buf, buflen, ans, anssiz, &resplen); switch (act) { case res_goahead: case res_done: done = 1; break; case res_nextns: res_close(); goto next_ns; case res_modified: /* give the hook another try */ if (++loops < 42) /*doug adams*/ break; /*FALLTHROUGH*/ case res_error: /*FALLTHROUGH*/ default: return (-1); } } while (!done); } return (resplen); next_ns: ; } /*foreach ns*/ } /*foreach retry*/ res_close(); if (!v_circuit) { if (!gotsomewhere) errno = ECONNREFUSED; /* no nameservers found */ else errno = ETIMEDOUT; /* no answer obtained */ } else errno = terrno; return (-1);} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/res_send.c/buggy/c/src/libnetworking/libc/res_send.c |
|
++_CPU_spurious_count; _CPU_last_spurious = v; | static void ppc_spurious(int v, CPU_Interrupt_frame *i){#if 0 printf("Spurious interrupt on vector %d from %08.8x\n", v, i->pc);#endif#ifdef ppc403 if (v == PPC_IRQ_EXTERNAL) { register int r = 0; asm volatile("mtdcr 0x42, %0" : "=&r" ((r)) : "0" ((r))); /* EXIER */ } else if (v == PPC_IRQ_PIT) { register int r = 0x08000000; asm volatile("mtspr 0x3d8, %0" : "=&r" ((r)) : "0" ((r))); /* TSR */ } else if (v == PPC_IRQ_FIT) { register int r = 0x04000000; asm volatile("mtspr 0x3d8, %0" : "=&r" ((r)) : "0" ((r))); /* TSR */ }#endif} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/8ef38186faea3d9b5e6f0f1242f668cb7e7a3d52/cpu.c/buggy/c/src/lib/libcpu/powerpc/old-exceptions/cpu.c |
|
GEN z,L,P,p,q,qfp,qfq,up,uq,u; | GEN z,L,P,p,q,qfp,u; | quadhilbertimag(GEN D, GEN flag){ long h, i, e, prec; pari_sp av=avma; GEN z,L,P,p,q,qfp,qfq,up,uq,u; int raw = ((typ(flag)==t_INT && signe(flag))); if (DEBUGLEVEL>=2) (void)timer2(); if (gcmpgs(D,-11) >= 0) return polx[0]; L = getallforms(D,&h,&z); if (DEBUGLEVEL>=2) msgtimer("class number = %ld",h); if (h == 1) { avma=av; return polx[0]; } get_pq(D, z, flag, &p, &q); e = 24 / cgcd((smodis(p,24)-1) * (smodis(q,24)-1), 24); if(DEBUGLEVEL>=2) fprintferr("p = %Z, q = %Z, e = %ld\n",p,q,e); qfp = primeform(D,p,0); up = gmodulcp((GEN)qfp[2],shifti(p,1)); if (egalii(p,q)) { u = (GEN)compimagraw(qfp,qfp)[2]; u = gmodulcp(u, shifti(mulii(p,q),1)); } else { qfq = primeform(D,q,0); uq = gmodulcp((GEN)qfq[2],shifti(q,1)); u = chinois(up,uq); } prec = raw? DEFAULTPREC: 3; for(;;) { long ex, exmax = 0; pari_sp av0 = avma; GEN lead, sqd = gsqrt(negi(D),prec); P = cgetg(h+1,t_VEC); for (i=1; i<=h; i++) { GEN v, s = gpq((GEN)L[i], p, q, e, sqd, u, prec); if (raw) { v = cgetg(3,t_VEC); P[i] = (long)v; v[1] = L[i]; v[2] = (long)s; } else P[i] = (long)s; ex = gexpo(s); if (ex > 0) exmax += ex; } if (DEBUGLEVEL>=2) msgtimer("roots"); if (raw) { P = gcopy(P); break; } /* to avoid integer overflow (1 + 0.) */ lead = (exmax < bit_accuracy(prec))? gun: realun(prec); P = greal(roots_to_pol_intern(lead,P,0,0)); P = grndtoi(P,&exmax); if (DEBUGLEVEL>=2) msgtimer("product, error bits = %ld",exmax); if (exmax <= -10) { if (typ(flag)==t_VEC && !issquarefree(P)) { avma=av; return gzero; } break; } avma = av0; prec += (DEFAULTPREC-2) + (1 + (exmax >> TWOPOTBITS_IN_LONG)); if (DEBUGLEVEL) err(warnprec,"quadhilbertimag",prec); } return gerepileupto(av,P);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d662c209e9e84c40e8e75b7a08e434d671788268/buch1.c/clean/src/basemath/buch1.c |
if (DEBUGLEVEL>=2) (void)timer2(); | if (DEBUGLEVEL>1) (void)timer2(); | quadhilbertimag(GEN D, GEN flag){ long h, i, e, prec; pari_sp av=avma; GEN z,L,P,p,q,qfp,qfq,up,uq,u; int raw = ((typ(flag)==t_INT && signe(flag))); if (DEBUGLEVEL>=2) (void)timer2(); if (gcmpgs(D,-11) >= 0) return polx[0]; L = getallforms(D,&h,&z); if (DEBUGLEVEL>=2) msgtimer("class number = %ld",h); if (h == 1) { avma=av; return polx[0]; } get_pq(D, z, flag, &p, &q); e = 24 / cgcd((smodis(p,24)-1) * (smodis(q,24)-1), 24); if(DEBUGLEVEL>=2) fprintferr("p = %Z, q = %Z, e = %ld\n",p,q,e); qfp = primeform(D,p,0); up = gmodulcp((GEN)qfp[2],shifti(p,1)); if (egalii(p,q)) { u = (GEN)compimagraw(qfp,qfp)[2]; u = gmodulcp(u, shifti(mulii(p,q),1)); } else { qfq = primeform(D,q,0); uq = gmodulcp((GEN)qfq[2],shifti(q,1)); u = chinois(up,uq); } prec = raw? DEFAULTPREC: 3; for(;;) { long ex, exmax = 0; pari_sp av0 = avma; GEN lead, sqd = gsqrt(negi(D),prec); P = cgetg(h+1,t_VEC); for (i=1; i<=h; i++) { GEN v, s = gpq((GEN)L[i], p, q, e, sqd, u, prec); if (raw) { v = cgetg(3,t_VEC); P[i] = (long)v; v[1] = L[i]; v[2] = (long)s; } else P[i] = (long)s; ex = gexpo(s); if (ex > 0) exmax += ex; } if (DEBUGLEVEL>=2) msgtimer("roots"); if (raw) { P = gcopy(P); break; } /* to avoid integer overflow (1 + 0.) */ lead = (exmax < bit_accuracy(prec))? gun: realun(prec); P = greal(roots_to_pol_intern(lead,P,0,0)); P = grndtoi(P,&exmax); if (DEBUGLEVEL>=2) msgtimer("product, error bits = %ld",exmax); if (exmax <= -10) { if (typ(flag)==t_VEC && !issquarefree(P)) { avma=av; return gzero; } break; } avma = av0; prec += (DEFAULTPREC-2) + (1 + (exmax >> TWOPOTBITS_IN_LONG)); if (DEBUGLEVEL) err(warnprec,"quadhilbertimag",prec); } return gerepileupto(av,P);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d662c209e9e84c40e8e75b7a08e434d671788268/buch1.c/clean/src/basemath/buch1.c |
if (DEBUGLEVEL>=2) msgtimer("class number = %ld",h); | if (DEBUGLEVEL>1) msgtimer("class number = %ld",h); | quadhilbertimag(GEN D, GEN flag){ long h, i, e, prec; pari_sp av=avma; GEN z,L,P,p,q,qfp,qfq,up,uq,u; int raw = ((typ(flag)==t_INT && signe(flag))); if (DEBUGLEVEL>=2) (void)timer2(); if (gcmpgs(D,-11) >= 0) return polx[0]; L = getallforms(D,&h,&z); if (DEBUGLEVEL>=2) msgtimer("class number = %ld",h); if (h == 1) { avma=av; return polx[0]; } get_pq(D, z, flag, &p, &q); e = 24 / cgcd((smodis(p,24)-1) * (smodis(q,24)-1), 24); if(DEBUGLEVEL>=2) fprintferr("p = %Z, q = %Z, e = %ld\n",p,q,e); qfp = primeform(D,p,0); up = gmodulcp((GEN)qfp[2],shifti(p,1)); if (egalii(p,q)) { u = (GEN)compimagraw(qfp,qfp)[2]; u = gmodulcp(u, shifti(mulii(p,q),1)); } else { qfq = primeform(D,q,0); uq = gmodulcp((GEN)qfq[2],shifti(q,1)); u = chinois(up,uq); } prec = raw? DEFAULTPREC: 3; for(;;) { long ex, exmax = 0; pari_sp av0 = avma; GEN lead, sqd = gsqrt(negi(D),prec); P = cgetg(h+1,t_VEC); for (i=1; i<=h; i++) { GEN v, s = gpq((GEN)L[i], p, q, e, sqd, u, prec); if (raw) { v = cgetg(3,t_VEC); P[i] = (long)v; v[1] = L[i]; v[2] = (long)s; } else P[i] = (long)s; ex = gexpo(s); if (ex > 0) exmax += ex; } if (DEBUGLEVEL>=2) msgtimer("roots"); if (raw) { P = gcopy(P); break; } /* to avoid integer overflow (1 + 0.) */ lead = (exmax < bit_accuracy(prec))? gun: realun(prec); P = greal(roots_to_pol_intern(lead,P,0,0)); P = grndtoi(P,&exmax); if (DEBUGLEVEL>=2) msgtimer("product, error bits = %ld",exmax); if (exmax <= -10) { if (typ(flag)==t_VEC && !issquarefree(P)) { avma=av; return gzero; } break; } avma = av0; prec += (DEFAULTPREC-2) + (1 + (exmax >> TWOPOTBITS_IN_LONG)); if (DEBUGLEVEL) err(warnprec,"quadhilbertimag",prec); } return gerepileupto(av,P);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d662c209e9e84c40e8e75b7a08e434d671788268/buch1.c/clean/src/basemath/buch1.c |
if(DEBUGLEVEL>=2) fprintferr("p = %Z, q = %Z, e = %ld\n",p,q,e); qfp = primeform(D,p,0); up = gmodulcp((GEN)qfp[2],shifti(p,1)); | if(DEBUGLEVEL>1) fprintferr("p = %Z, q = %Z, e = %ld\n",p,q,e); qfp = primeform(D,p,0); | quadhilbertimag(GEN D, GEN flag){ long h, i, e, prec; pari_sp av=avma; GEN z,L,P,p,q,qfp,qfq,up,uq,u; int raw = ((typ(flag)==t_INT && signe(flag))); if (DEBUGLEVEL>=2) (void)timer2(); if (gcmpgs(D,-11) >= 0) return polx[0]; L = getallforms(D,&h,&z); if (DEBUGLEVEL>=2) msgtimer("class number = %ld",h); if (h == 1) { avma=av; return polx[0]; } get_pq(D, z, flag, &p, &q); e = 24 / cgcd((smodis(p,24)-1) * (smodis(q,24)-1), 24); if(DEBUGLEVEL>=2) fprintferr("p = %Z, q = %Z, e = %ld\n",p,q,e); qfp = primeform(D,p,0); up = gmodulcp((GEN)qfp[2],shifti(p,1)); if (egalii(p,q)) { u = (GEN)compimagraw(qfp,qfp)[2]; u = gmodulcp(u, shifti(mulii(p,q),1)); } else { qfq = primeform(D,q,0); uq = gmodulcp((GEN)qfq[2],shifti(q,1)); u = chinois(up,uq); } prec = raw? DEFAULTPREC: 3; for(;;) { long ex, exmax = 0; pari_sp av0 = avma; GEN lead, sqd = gsqrt(negi(D),prec); P = cgetg(h+1,t_VEC); for (i=1; i<=h; i++) { GEN v, s = gpq((GEN)L[i], p, q, e, sqd, u, prec); if (raw) { v = cgetg(3,t_VEC); P[i] = (long)v; v[1] = L[i]; v[2] = (long)s; } else P[i] = (long)s; ex = gexpo(s); if (ex > 0) exmax += ex; } if (DEBUGLEVEL>=2) msgtimer("roots"); if (raw) { P = gcopy(P); break; } /* to avoid integer overflow (1 + 0.) */ lead = (exmax < bit_accuracy(prec))? gun: realun(prec); P = greal(roots_to_pol_intern(lead,P,0,0)); P = grndtoi(P,&exmax); if (DEBUGLEVEL>=2) msgtimer("product, error bits = %ld",exmax); if (exmax <= -10) { if (typ(flag)==t_VEC && !issquarefree(P)) { avma=av; return gzero; } break; } avma = av0; prec += (DEFAULTPREC-2) + (1 + (exmax >> TWOPOTBITS_IN_LONG)); if (DEBUGLEVEL) err(warnprec,"quadhilbertimag",prec); } return gerepileupto(av,P);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d662c209e9e84c40e8e75b7a08e434d671788268/buch1.c/clean/src/basemath/buch1.c |
u = gmodulcp(u, shifti(mulii(p,q),1)); | u = gmodulcp(u, shifti(sqri(p),1)); | quadhilbertimag(GEN D, GEN flag){ long h, i, e, prec; pari_sp av=avma; GEN z,L,P,p,q,qfp,qfq,up,uq,u; int raw = ((typ(flag)==t_INT && signe(flag))); if (DEBUGLEVEL>=2) (void)timer2(); if (gcmpgs(D,-11) >= 0) return polx[0]; L = getallforms(D,&h,&z); if (DEBUGLEVEL>=2) msgtimer("class number = %ld",h); if (h == 1) { avma=av; return polx[0]; } get_pq(D, z, flag, &p, &q); e = 24 / cgcd((smodis(p,24)-1) * (smodis(q,24)-1), 24); if(DEBUGLEVEL>=2) fprintferr("p = %Z, q = %Z, e = %ld\n",p,q,e); qfp = primeform(D,p,0); up = gmodulcp((GEN)qfp[2],shifti(p,1)); if (egalii(p,q)) { u = (GEN)compimagraw(qfp,qfp)[2]; u = gmodulcp(u, shifti(mulii(p,q),1)); } else { qfq = primeform(D,q,0); uq = gmodulcp((GEN)qfq[2],shifti(q,1)); u = chinois(up,uq); } prec = raw? DEFAULTPREC: 3; for(;;) { long ex, exmax = 0; pari_sp av0 = avma; GEN lead, sqd = gsqrt(negi(D),prec); P = cgetg(h+1,t_VEC); for (i=1; i<=h; i++) { GEN v, s = gpq((GEN)L[i], p, q, e, sqd, u, prec); if (raw) { v = cgetg(3,t_VEC); P[i] = (long)v; v[1] = L[i]; v[2] = (long)s; } else P[i] = (long)s; ex = gexpo(s); if (ex > 0) exmax += ex; } if (DEBUGLEVEL>=2) msgtimer("roots"); if (raw) { P = gcopy(P); break; } /* to avoid integer overflow (1 + 0.) */ lead = (exmax < bit_accuracy(prec))? gun: realun(prec); P = greal(roots_to_pol_intern(lead,P,0,0)); P = grndtoi(P,&exmax); if (DEBUGLEVEL>=2) msgtimer("product, error bits = %ld",exmax); if (exmax <= -10) { if (typ(flag)==t_VEC && !issquarefree(P)) { avma=av; return gzero; } break; } avma = av0; prec += (DEFAULTPREC-2) + (1 + (exmax >> TWOPOTBITS_IN_LONG)); if (DEBUGLEVEL) err(warnprec,"quadhilbertimag",prec); } return gerepileupto(av,P);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d662c209e9e84c40e8e75b7a08e434d671788268/buch1.c/clean/src/basemath/buch1.c |
qfq = primeform(D,q,0); uq = gmodulcp((GEN)qfq[2],shifti(q,1)); | GEN qfq = primeform(D,q,0); GEN up = gmodulcp((GEN)qfp[2], shifti(p,1)); GEN uq = gmodulcp((GEN)qfq[2], shifti(q,1)); | quadhilbertimag(GEN D, GEN flag){ long h, i, e, prec; pari_sp av=avma; GEN z,L,P,p,q,qfp,qfq,up,uq,u; int raw = ((typ(flag)==t_INT && signe(flag))); if (DEBUGLEVEL>=2) (void)timer2(); if (gcmpgs(D,-11) >= 0) return polx[0]; L = getallforms(D,&h,&z); if (DEBUGLEVEL>=2) msgtimer("class number = %ld",h); if (h == 1) { avma=av; return polx[0]; } get_pq(D, z, flag, &p, &q); e = 24 / cgcd((smodis(p,24)-1) * (smodis(q,24)-1), 24); if(DEBUGLEVEL>=2) fprintferr("p = %Z, q = %Z, e = %ld\n",p,q,e); qfp = primeform(D,p,0); up = gmodulcp((GEN)qfp[2],shifti(p,1)); if (egalii(p,q)) { u = (GEN)compimagraw(qfp,qfp)[2]; u = gmodulcp(u, shifti(mulii(p,q),1)); } else { qfq = primeform(D,q,0); uq = gmodulcp((GEN)qfq[2],shifti(q,1)); u = chinois(up,uq); } prec = raw? DEFAULTPREC: 3; for(;;) { long ex, exmax = 0; pari_sp av0 = avma; GEN lead, sqd = gsqrt(negi(D),prec); P = cgetg(h+1,t_VEC); for (i=1; i<=h; i++) { GEN v, s = gpq((GEN)L[i], p, q, e, sqd, u, prec); if (raw) { v = cgetg(3,t_VEC); P[i] = (long)v; v[1] = L[i]; v[2] = (long)s; } else P[i] = (long)s; ex = gexpo(s); if (ex > 0) exmax += ex; } if (DEBUGLEVEL>=2) msgtimer("roots"); if (raw) { P = gcopy(P); break; } /* to avoid integer overflow (1 + 0.) */ lead = (exmax < bit_accuracy(prec))? gun: realun(prec); P = greal(roots_to_pol_intern(lead,P,0,0)); P = grndtoi(P,&exmax); if (DEBUGLEVEL>=2) msgtimer("product, error bits = %ld",exmax); if (exmax <= -10) { if (typ(flag)==t_VEC && !issquarefree(P)) { avma=av; return gzero; } break; } avma = av0; prec += (DEFAULTPREC-2) + (1 + (exmax >> TWOPOTBITS_IN_LONG)); if (DEBUGLEVEL) err(warnprec,"quadhilbertimag",prec); } return gerepileupto(av,P);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d662c209e9e84c40e8e75b7a08e434d671788268/buch1.c/clean/src/basemath/buch1.c |
if (DEBUGLEVEL>=2) msgtimer("roots"); | if (DEBUGLEVEL>1) msgtimer("roots"); | quadhilbertimag(GEN D, GEN flag){ long h, i, e, prec; pari_sp av=avma; GEN z,L,P,p,q,qfp,qfq,up,uq,u; int raw = ((typ(flag)==t_INT && signe(flag))); if (DEBUGLEVEL>=2) (void)timer2(); if (gcmpgs(D,-11) >= 0) return polx[0]; L = getallforms(D,&h,&z); if (DEBUGLEVEL>=2) msgtimer("class number = %ld",h); if (h == 1) { avma=av; return polx[0]; } get_pq(D, z, flag, &p, &q); e = 24 / cgcd((smodis(p,24)-1) * (smodis(q,24)-1), 24); if(DEBUGLEVEL>=2) fprintferr("p = %Z, q = %Z, e = %ld\n",p,q,e); qfp = primeform(D,p,0); up = gmodulcp((GEN)qfp[2],shifti(p,1)); if (egalii(p,q)) { u = (GEN)compimagraw(qfp,qfp)[2]; u = gmodulcp(u, shifti(mulii(p,q),1)); } else { qfq = primeform(D,q,0); uq = gmodulcp((GEN)qfq[2],shifti(q,1)); u = chinois(up,uq); } prec = raw? DEFAULTPREC: 3; for(;;) { long ex, exmax = 0; pari_sp av0 = avma; GEN lead, sqd = gsqrt(negi(D),prec); P = cgetg(h+1,t_VEC); for (i=1; i<=h; i++) { GEN v, s = gpq((GEN)L[i], p, q, e, sqd, u, prec); if (raw) { v = cgetg(3,t_VEC); P[i] = (long)v; v[1] = L[i]; v[2] = (long)s; } else P[i] = (long)s; ex = gexpo(s); if (ex > 0) exmax += ex; } if (DEBUGLEVEL>=2) msgtimer("roots"); if (raw) { P = gcopy(P); break; } /* to avoid integer overflow (1 + 0.) */ lead = (exmax < bit_accuracy(prec))? gun: realun(prec); P = greal(roots_to_pol_intern(lead,P,0,0)); P = grndtoi(P,&exmax); if (DEBUGLEVEL>=2) msgtimer("product, error bits = %ld",exmax); if (exmax <= -10) { if (typ(flag)==t_VEC && !issquarefree(P)) { avma=av; return gzero; } break; } avma = av0; prec += (DEFAULTPREC-2) + (1 + (exmax >> TWOPOTBITS_IN_LONG)); if (DEBUGLEVEL) err(warnprec,"quadhilbertimag",prec); } return gerepileupto(av,P);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d662c209e9e84c40e8e75b7a08e434d671788268/buch1.c/clean/src/basemath/buch1.c |
if (DEBUGLEVEL>=2) msgtimer("product, error bits = %ld",exmax); | if (DEBUGLEVEL>1) msgtimer("product, error bits = %ld",exmax); | quadhilbertimag(GEN D, GEN flag){ long h, i, e, prec; pari_sp av=avma; GEN z,L,P,p,q,qfp,qfq,up,uq,u; int raw = ((typ(flag)==t_INT && signe(flag))); if (DEBUGLEVEL>=2) (void)timer2(); if (gcmpgs(D,-11) >= 0) return polx[0]; L = getallforms(D,&h,&z); if (DEBUGLEVEL>=2) msgtimer("class number = %ld",h); if (h == 1) { avma=av; return polx[0]; } get_pq(D, z, flag, &p, &q); e = 24 / cgcd((smodis(p,24)-1) * (smodis(q,24)-1), 24); if(DEBUGLEVEL>=2) fprintferr("p = %Z, q = %Z, e = %ld\n",p,q,e); qfp = primeform(D,p,0); up = gmodulcp((GEN)qfp[2],shifti(p,1)); if (egalii(p,q)) { u = (GEN)compimagraw(qfp,qfp)[2]; u = gmodulcp(u, shifti(mulii(p,q),1)); } else { qfq = primeform(D,q,0); uq = gmodulcp((GEN)qfq[2],shifti(q,1)); u = chinois(up,uq); } prec = raw? DEFAULTPREC: 3; for(;;) { long ex, exmax = 0; pari_sp av0 = avma; GEN lead, sqd = gsqrt(negi(D),prec); P = cgetg(h+1,t_VEC); for (i=1; i<=h; i++) { GEN v, s = gpq((GEN)L[i], p, q, e, sqd, u, prec); if (raw) { v = cgetg(3,t_VEC); P[i] = (long)v; v[1] = L[i]; v[2] = (long)s; } else P[i] = (long)s; ex = gexpo(s); if (ex > 0) exmax += ex; } if (DEBUGLEVEL>=2) msgtimer("roots"); if (raw) { P = gcopy(P); break; } /* to avoid integer overflow (1 + 0.) */ lead = (exmax < bit_accuracy(prec))? gun: realun(prec); P = greal(roots_to_pol_intern(lead,P,0,0)); P = grndtoi(P,&exmax); if (DEBUGLEVEL>=2) msgtimer("product, error bits = %ld",exmax); if (exmax <= -10) { if (typ(flag)==t_VEC && !issquarefree(P)) { avma=av; return gzero; } break; } avma = av0; prec += (DEFAULTPREC-2) + (1 + (exmax >> TWOPOTBITS_IN_LONG)); if (DEBUGLEVEL) err(warnprec,"quadhilbertimag",prec); } return gerepileupto(av,P);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d662c209e9e84c40e8e75b7a08e434d671788268/buch1.c/clean/src/basemath/buch1.c |
p2 = get_Char(chi,cyc, prec); | p2 = get_Char(get_chic(chi,cyc), prec); | bnrrootnumber(GEN bnr, GEN chi, long flag, long prec){ long av = avma, l; GEN cond, condc, bnrc, cyc, p1, p2, dtcr; if (flag < 0 || flag > 1) err(flagerr,"bnrrootnumber"); checkbnr(bnr); cond = gmael(bnr, 2, 1); l = lg(gmael(bnr, 5, 2)); if ((typ(chi) != t_VEC) || (lg(chi) != l)) err(talker, "incorrect character in bnrrootnumber"); if (!flag) { condc = bnrconductorofchar(bnr, chi); if (gegal(cond, condc)) flag = 1; } else condc = cond; if (flag) bnrc = bnr; else bnrc = buchrayinitgen((GEN)bnr[1], condc); cyc = gmael(bnr, 5, 2); p2 = get_Char(chi,cyc, prec); dtcr = cgetg(9, t_VEC); dtcr[1] = (long)chi; dtcr[2] = zero; dtcr[3] = (long)bnrc; dtcr[4] = (long)bnr; dtcr[5] = (long)p2; dtcr[6] = zero; dtcr[7] = (long)condc; p1 = GetPrimChar(chi, bnr, bnrc, prec); if (!p1) dtcr[8] = (long)p2; else dtcr[8] = p1[1]; return gerepileupto(av, ComputeArtinNumber(dtcr, 0, prec));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/e16b8bd33064cef7dd46a1c0c12eaacdf514c615/stark.c/clean/src/modules/stark.c |
finda(Cache *Cp, GEN N, int pk, int p) | finda(Cache *Cp, GEN N, long pk, long p) | finda(Cache *Cp, GEN N, int pk, int p){ GEN a, pv; if (Cp && Cp->avite) { a = Cp->avite; pv = Cp->pkvite; } else { GEN gp = utoipos(p), ph, b, q; ulong u = 2; int v = Z_pvalrem(addis(N,-1), gp, &q); ph = gpowgs(gp, v-1); pv = mulis(ph, p); /* N - 1 = p^v q */ if (p > 2) { for (;;u++) { a = Fp_pow(utoipos(u), q, N); b = Fp_pow(a, ph, N); if (!gcmp1(b)) break; } } else { while (krosi(u,N) >= 0) u++; a = Fp_pow(utoipos(u), q, N); b = Fp_pow(a, ph, N); } /* checking b^p = 1 mod N done economically in caller */ b = gcdii(addis(b,-1), N); if (!gcmp1(b)) err(invmoder,"%Z",gmodulcp(b,N)); /* trap this! */ if (Cp) { Cp->avite = a; /* a has order p^v */ Cp->pkvite = pv; } } return Fp_pow(a, divis(pv, pk), N);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/b03001ef86c74799b6280212f7a40aee0823ed89/aprcl.c/clean/src/modules/aprcl.c |
int v = Z_pvalrem(addis(N,-1), gp, &q); | long v = Z_pvalrem(addis(N,-1), gp, &q); | finda(Cache *Cp, GEN N, int pk, int p){ GEN a, pv; if (Cp && Cp->avite) { a = Cp->avite; pv = Cp->pkvite; } else { GEN gp = utoipos(p), ph, b, q; ulong u = 2; int v = Z_pvalrem(addis(N,-1), gp, &q); ph = gpowgs(gp, v-1); pv = mulis(ph, p); /* N - 1 = p^v q */ if (p > 2) { for (;;u++) { a = Fp_pow(utoipos(u), q, N); b = Fp_pow(a, ph, N); if (!gcmp1(b)) break; } } else { while (krosi(u,N) >= 0) u++; a = Fp_pow(utoipos(u), q, N); b = Fp_pow(a, ph, N); } /* checking b^p = 1 mod N done economically in caller */ b = gcdii(addis(b,-1), N); if (!gcmp1(b)) err(invmoder,"%Z",gmodulcp(b,N)); /* trap this! */ if (Cp) { Cp->avite = a; /* a has order p^v */ Cp->pkvite = pv; } } return Fp_pow(a, divis(pv, pk), N);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/b03001ef86c74799b6280212f7a40aee0823ed89/aprcl.c/clean/src/modules/aprcl.c |
long i, j, lx, lz; | long i, j, lz, l = lg(L); | bnrclassnolist(GEN bnf,GEN L){ pari_sp av = avma; long i, j, lx, lz; GEN v, z, V, h; bnf = checkbnf(bnf); h = gmael3(bnf,8,1,1); if (typ(L) != t_VEC) err(typeer,"bnrclassnolist"); lx = lg(L); V = cgetg(lx,t_VEC); for (i = 1; i < lx; i++) { z = gel(L,i); lz = lg(z); gel(V,i) = v = cgetg(lz,t_VEC); for (j=1; j<lz; j++) gel(v,j) = get_classno(gel(z,j), h); } return gerepilecopy(av, V);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/a1492eb1f9a7a31e99dc16dab3f6a29df8a9b9f0/buch3.c/buggy/src/basemath/buch3.c |
if (typ(L) != t_VEC) err(typeer,"bnrclassnolist"); lx = lg(L); V = cgetg(lx,t_VEC); for (i = 1; i < lx; i++) | V = cgetg(l,t_VEC); for (i = 1; i < l; i++) | bnrclassnolist(GEN bnf,GEN L){ pari_sp av = avma; long i, j, lx, lz; GEN v, z, V, h; bnf = checkbnf(bnf); h = gmael3(bnf,8,1,1); if (typ(L) != t_VEC) err(typeer,"bnrclassnolist"); lx = lg(L); V = cgetg(lx,t_VEC); for (i = 1; i < lx; i++) { z = gel(L,i); lz = lg(z); gel(V,i) = v = cgetg(lz,t_VEC); for (j=1; j<lz; j++) gel(v,j) = get_classno(gel(z,j), h); } return gerepilecopy(av, V);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/a1492eb1f9a7a31e99dc16dab3f6a29df8a9b9f0/buch3.c/buggy/src/basemath/buch3.c |
rtems_unsigned32 task; | uint32_t task; | void destory_all_tasks( const char *who){ rtems_unsigned32 task; /* * If the id is not zero, signal the task to delete. */ for (task = 0; task < MAX_TASKS; task++) if (task_id[task]) { printf(" %s : signal task %08x to delete, ", who, task_id[task]); fflush(stdout); rtems_event_send(task_id[task], 1); task_id[task] = 0; }} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/4c84d7b760ceb1e140c1cfc0fa64289ca4d243ed/init.c/clean/testsuites/samples/unlimited/init.c |
prec++; | /*prec++;*/ | galoisborne(GEN T, GEN dn, struct galois_borne *gb, long ppp){ ulong ltop = avma, av2; GEN borne, borneroots, borneabs; int i, j; int n; GEN L, M, z, prep, den; long prec; n = lgef(T) - 3; prec = 1; for (i = 2; i < lgef(T); i++) if (lg(T[i]) > prec) prec = lg(T[i]); prec++; if (DEBUGLEVEL>=4) gentimer(3); L = roots(T, prec); if (DEBUGLEVEL>=4) genmsgtimer(3,"roots"); for (i = 1; i <= n; i++) { z = (GEN) L[i]; if (signe(z[2])) break; L[i] = z[1]; } if (DEBUGLEVEL>=4) gentimer(3); prep=vandermondeinverseprep(T, L); if (!dn) { GEN res = divide_conquer_prod(gabs(prep,prec), mpmul); GEN dis; disable_dbg(0); dis = ZX_disc_all(T, 1+mylogint(res,gdeux,prec)); disable_dbg(-1); den = gclone(indexpartial(T,dis)); } else den=dn; M = vandermondeinverse(L, gmul(T, realun(prec)), den, prep); if (DEBUGLEVEL>=4) genmsgtimer(3,"vandermondeinverse"); borne = realzero(prec); for (i = 1; i <= n; i++) { z = gzero; for (j = 1; j <= n; j++) z = gadd(z, gabs(gcoeff(M,i,j), prec)); if (gcmp(z, borne) > 0) borne = z; } borneroots = realzero(prec); for (i = 1; i <= n; i++) { z = gabs((GEN) L[i], prec); if (gcmp(z, borneroots) > 0) borneroots = z; } borneabs = addsr(1, gmulsg(n, gpowgs(borneroots, n/ppp))); /*if (ppp == 1) borneabs = addsr(1, gmulsg(n, gpowgs(borneabs, 2)));*/ borneroots = addsr(1, gmul(borne, borneroots)); av2 = avma; /*We use d-1 test, so we must overlift to 2^BITS_IN_LONG*/ gb->valsol = mylogint(gmul2n(borneroots,2+BITS_IN_LONG), gb->l, prec); gb->valabs = mylogint(gmul2n(borneabs,2), gb->l, prec); gb->valabs = max(gb->valsol,gb->valabs); if (DEBUGLEVEL >= 4) fprintferr("GaloisConj:val1=%ld val2=%ld\n", gb->valsol, gb->valabs); avma = av2; gb->bornesol = gerepileupto(ltop, myceil(borneroots)); if (DEBUGLEVEL >= 9) fprintferr("GaloisConj: Bound %Z\n",borneroots); gb->ladicsol = gpowgs(gb->l, gb->valsol); gb->ladicabs = gpowgs(gb->l, gb->valabs); gb->lbornesol = subii(gb->ladicsol,gb->bornesol); if (!dn) { dn=forcecopy(den); gunclone(den); } return dn;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/9630bffbbb08f310df71f67ed69d2bf6544c7cef/galconj.c/clean/src/basemath/galconj.c |
if (T->subq) p1 = mulis(p1,lg(T->subqpart)-1); if (cmpis(p1,T->countsub)) | if (T->fun != list_fun || !((sublist_t*)(T->fundata))->listKer) | dopsub(subgp_iter *T, GEN p, GEN indexsubq){ long *M, *L = T->L; long w,i,j,k, wG = weight(L), wmin = 0, wmax = wG, n = len(L); if (DEBUGLEVEL) { fprintferr("\ngroup:"); printtyp(L); } T->count = 0; switch(T->boundtype) { case b_MAX: /* upper bound */ wmin = (long) (wG - (log(gtodouble(T->bound)) / log(gtodouble(p)))); if (cmpii(gpowgs(p, wG - wmin), T->bound) > 0) wmin++; break; case b_EXACT: /* exact value */ wmin = wmax = wG - ggval(T->bound, p); break; } T->M = M = new_chunk(n+1); M[1] = -1; for (i=2; i<=n; i++) M[i]=0; for(;;) /* go through all vectors mu_{i+1} <= mu_i <= lam_i */ { M[1]++; if (M[1] > L[1]) { for (j=2; j<=n; j++) if (M[j] < L[j] && M[j] < M[j-1]) break; if (j > n) return; M[j]++; for (k=1; k<j; k++) M[k]=M[j]; } for (j=1; j<=n; j++) if (!M[j]) break; setlen(M, j-1); w = weight(M); if (w >= wmin && w <= wmax) { GEN p1 = gun; if (T->subq) /* G not a p-group */ { if (T->bound) { GEN indexH = gpowgs(p, wG - w); GEN B = divii(T->bound, indexH); long k, l = lg(T->subq); T->subqpart = cgetg(l, t_VEC); k = 1; for (i=1; i<l; i++) if (cmpii((GEN)indexsubq[i], B) <= 0) T->subqpart[k++] = T->subq[i]; setlg(T->subqpart, k); } else T->subqpart = T->subq; } if (DEBUGLEVEL) { long *Lp = conjugate(L); long *Mp = conjugate(M); GEN BINMAT = matqpascal(len(L)+1, p); if (DEBUGLEVEL > 3) { fprintferr(" lambda = "); printtyp(L); fprintferr(" lambda'= "); printtyp(Lp); fprintferr(" mu = "); printtyp(M); fprintferr(" mu'= "); printtyp(Mp); } for (j=1; j<=len(Mp); j++) { p1 = mulii(p1, gpuigs(p, Mp[j+1]*(Lp[j]-Mp[j]))); p1 = mulii(p1, gcoeff(BINMAT, Lp[j]-Mp[j+1]+1, Mp[j]-Mp[j+1]+1)); } fprintferr(" alpha_lambda(mu,p) = %Z\n",p1); } T->countsub = 0; dopsubtyp(T); T->count += T->countsub; if (DEBUGLEVEL) { fprintferr(" countsub = %ld\n", T->countsub); msgtimer("for this type"); if (T->subq) p1 = mulis(p1,lg(T->subqpart)-1); if (cmpis(p1,T->countsub)) { fprintferr(" alpha = %Z\n",p1); err(bugparier,"forsubgroup (alpha != countsub)"); } } } }} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/860e6cb37514ea57d6d0574849d34c2a3ce841a0/subgroup.c/clean/src/basemath/subgroup.c |
fprintferr(" alpha = %Z\n",p1); err(bugparier,"forsubgroup (alpha != countsub)"); | if (T->subq) p1 = mulis(p1,lg(T->subqpart)-1); if (cmpis(p1,T->countsub)) { fprintferr(" alpha = %Z\n",p1); err(bugparier,"forsubgroup (alpha != countsub)"); } | dopsub(subgp_iter *T, GEN p, GEN indexsubq){ long *M, *L = T->L; long w,i,j,k, wG = weight(L), wmin = 0, wmax = wG, n = len(L); if (DEBUGLEVEL) { fprintferr("\ngroup:"); printtyp(L); } T->count = 0; switch(T->boundtype) { case b_MAX: /* upper bound */ wmin = (long) (wG - (log(gtodouble(T->bound)) / log(gtodouble(p)))); if (cmpii(gpowgs(p, wG - wmin), T->bound) > 0) wmin++; break; case b_EXACT: /* exact value */ wmin = wmax = wG - ggval(T->bound, p); break; } T->M = M = new_chunk(n+1); M[1] = -1; for (i=2; i<=n; i++) M[i]=0; for(;;) /* go through all vectors mu_{i+1} <= mu_i <= lam_i */ { M[1]++; if (M[1] > L[1]) { for (j=2; j<=n; j++) if (M[j] < L[j] && M[j] < M[j-1]) break; if (j > n) return; M[j]++; for (k=1; k<j; k++) M[k]=M[j]; } for (j=1; j<=n; j++) if (!M[j]) break; setlen(M, j-1); w = weight(M); if (w >= wmin && w <= wmax) { GEN p1 = gun; if (T->subq) /* G not a p-group */ { if (T->bound) { GEN indexH = gpowgs(p, wG - w); GEN B = divii(T->bound, indexH); long k, l = lg(T->subq); T->subqpart = cgetg(l, t_VEC); k = 1; for (i=1; i<l; i++) if (cmpii((GEN)indexsubq[i], B) <= 0) T->subqpart[k++] = T->subq[i]; setlg(T->subqpart, k); } else T->subqpart = T->subq; } if (DEBUGLEVEL) { long *Lp = conjugate(L); long *Mp = conjugate(M); GEN BINMAT = matqpascal(len(L)+1, p); if (DEBUGLEVEL > 3) { fprintferr(" lambda = "); printtyp(L); fprintferr(" lambda'= "); printtyp(Lp); fprintferr(" mu = "); printtyp(M); fprintferr(" mu'= "); printtyp(Mp); } for (j=1; j<=len(Mp); j++) { p1 = mulii(p1, gpuigs(p, Mp[j+1]*(Lp[j]-Mp[j]))); p1 = mulii(p1, gcoeff(BINMAT, Lp[j]-Mp[j+1]+1, Mp[j]-Mp[j+1]+1)); } fprintferr(" alpha_lambda(mu,p) = %Z\n",p1); } T->countsub = 0; dopsubtyp(T); T->count += T->countsub; if (DEBUGLEVEL) { fprintferr(" countsub = %ld\n", T->countsub); msgtimer("for this type"); if (T->subq) p1 = mulis(p1,lg(T->subqpart)-1); if (cmpis(p1,T->countsub)) { fprintferr(" alpha = %Z\n",p1); err(bugparier,"forsubgroup (alpha != countsub)"); } } } }} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/860e6cb37514ea57d6d0574849d34c2a3ce841a0/subgroup.c/clean/src/basemath/subgroup.c |
char *tmp, *s = analyseur; long len, alloc; | char *tmp; long len; int alloc = 1; | expand_string(char *bp, char **ptbuf, char **ptlimit){ char *tmp, *s = analyseur; long len, alloc; while (is_keyword_char(*s)) s++; if ((*s == '"' || *s == ',' || *s == ')') && !is_entry(analyseur)) { /* Do not create new user variable. Consider as a literal */ tmp = analyseur; len = s - analyseur; analyseur = s; alloc = 0; } else { gpmem_t av = avma; GEN p1 = expr(); if (br_status) err(breaker,"here (expanding string)"); tmp = GENtostr0(p1, &DFLT_OUTPUT, &gen_output); len = strlen(tmp); avma = av; alloc = 1; } if (ptlimit && bp + len > *ptlimit) bp = realloc_buf(bp, len, ptbuf,ptlimit); memcpy(bp,tmp,len); /* ignore trailing \0 */ if (alloc) free(tmp); return bp + len;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/62a31d7cdb146350310e18b922ba1239df4ca90e/anal.c/buggy/src/language/anal.c |
while (is_keyword_char(*s)) s++; | if (is_keyword_char(*analyseur)) { char *s = analyseur; do s++; while (is_keyword_char(*s)); | expand_string(char *bp, char **ptbuf, char **ptlimit){ char *tmp, *s = analyseur; long len, alloc; while (is_keyword_char(*s)) s++; if ((*s == '"' || *s == ',' || *s == ')') && !is_entry(analyseur)) { /* Do not create new user variable. Consider as a literal */ tmp = analyseur; len = s - analyseur; analyseur = s; alloc = 0; } else { gpmem_t av = avma; GEN p1 = expr(); if (br_status) err(breaker,"here (expanding string)"); tmp = GENtostr0(p1, &DFLT_OUTPUT, &gen_output); len = strlen(tmp); avma = av; alloc = 1; } if (ptlimit && bp + len > *ptlimit) bp = realloc_buf(bp, len, ptbuf,ptlimit); memcpy(bp,tmp,len); /* ignore trailing \0 */ if (alloc) free(tmp); return bp + len;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/62a31d7cdb146350310e18b922ba1239df4ca90e/anal.c/buggy/src/language/anal.c |
if ((*s == '"' || *s == ',' || *s == ')') && !is_entry(analyseur)) { /* Do not create new user variable. Consider as a literal */ tmp = analyseur; len = s - analyseur; analyseur = s; alloc = 0; | if ((*s == '"' || *s == ',' || *s == ')') && !is_entry(analyseur)) { /* Do not create new user variable. Consider as a literal */ tmp = analyseur; len = s - analyseur; analyseur = s; alloc = 0; } | expand_string(char *bp, char **ptbuf, char **ptlimit){ char *tmp, *s = analyseur; long len, alloc; while (is_keyword_char(*s)) s++; if ((*s == '"' || *s == ',' || *s == ')') && !is_entry(analyseur)) { /* Do not create new user variable. Consider as a literal */ tmp = analyseur; len = s - analyseur; analyseur = s; alloc = 0; } else { gpmem_t av = avma; GEN p1 = expr(); if (br_status) err(breaker,"here (expanding string)"); tmp = GENtostr0(p1, &DFLT_OUTPUT, &gen_output); len = strlen(tmp); avma = av; alloc = 1; } if (ptlimit && bp + len > *ptlimit) bp = realloc_buf(bp, len, ptbuf,ptlimit); memcpy(bp,tmp,len); /* ignore trailing \0 */ if (alloc) free(tmp); return bp + len;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/62a31d7cdb146350310e18b922ba1239df4ca90e/anal.c/buggy/src/language/anal.c |
else | if (alloc) | expand_string(char *bp, char **ptbuf, char **ptlimit){ char *tmp, *s = analyseur; long len, alloc; while (is_keyword_char(*s)) s++; if ((*s == '"' || *s == ',' || *s == ')') && !is_entry(analyseur)) { /* Do not create new user variable. Consider as a literal */ tmp = analyseur; len = s - analyseur; analyseur = s; alloc = 0; } else { gpmem_t av = avma; GEN p1 = expr(); if (br_status) err(breaker,"here (expanding string)"); tmp = GENtostr0(p1, &DFLT_OUTPUT, &gen_output); len = strlen(tmp); avma = av; alloc = 1; } if (ptlimit && bp + len > *ptlimit) bp = realloc_buf(bp, len, ptbuf,ptlimit); memcpy(bp,tmp,len); /* ignore trailing \0 */ if (alloc) free(tmp); return bp + len;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/62a31d7cdb146350310e18b922ba1239df4ca90e/anal.c/buggy/src/language/anal.c |
alloc = 1; | expand_string(char *bp, char **ptbuf, char **ptlimit){ char *tmp, *s = analyseur; long len, alloc; while (is_keyword_char(*s)) s++; if ((*s == '"' || *s == ',' || *s == ')') && !is_entry(analyseur)) { /* Do not create new user variable. Consider as a literal */ tmp = analyseur; len = s - analyseur; analyseur = s; alloc = 0; } else { gpmem_t av = avma; GEN p1 = expr(); if (br_status) err(breaker,"here (expanding string)"); tmp = GENtostr0(p1, &DFLT_OUTPUT, &gen_output); len = strlen(tmp); avma = av; alloc = 1; } if (ptlimit && bp + len > *ptlimit) bp = realloc_buf(bp, len, ptbuf,ptlimit); memcpy(bp,tmp,len); /* ignore trailing \0 */ if (alloc) free(tmp); return bp + len;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/62a31d7cdb146350310e18b922ba1239df4ca90e/anal.c/buggy/src/language/anal.c |
|
p1[2] = lpolx[v0]; LSB = _vec(p1); | p1[2] = lpolx[0]; LSB = _vec(p1); | subfieldsall(GEN nf){ long av=avma,av1,N,ld,i,v0; GEN pol,dpol,dg,LSB,NLSB,p1; nf = checknf(nf); pol = (GEN)nf[1]; v0 = varn(pol); N = deg(pol); dg = divisors(stoi(N)); ld = lg(dg)-1; if (DEBUGLEVEL) fprintferr("\n***** Entering subfields\n\npol = %Z\n",pol); p1 = cgetg(3,t_VEC); p1[1] = (long)pol; p1[2] = lpolx[v0]; LSB = _vec(p1); if (ld > 2) { FACTORDL = factor(absi((GEN)nf[3])); dpol = mulii(sqri((GEN)nf[4]),(GEN)nf[3]); for (i=2; i<ld; i++) { av1 = avma; NLSB = subfields_of_given_degree(nf,dpol, N / itos((GEN)dg[i])); if (lg(NLSB) > 1) LSB = concatsp(LSB,NLSB); else avma = av1; } } p1 = cgetg(3,t_VEC); p1[1] = (long)polx[v0]; p1[2] = (long)pol; LSB = concatsp(LSB, _vec(p1)); if (DEBUGLEVEL) fprintferr("\n***** Leaving subfields\n\n"); return gerepileupto(av, gcopy(LSB));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59af7aa1a95aeb4e670f3d2cf01cd1e105edb8c4/subfield.c/buggy/src/modules/subfield.c |
p1[1] = (long)polx[v0]; | p1[1] = (long)polx[0]; | subfieldsall(GEN nf){ long av=avma,av1,N,ld,i,v0; GEN pol,dpol,dg,LSB,NLSB,p1; nf = checknf(nf); pol = (GEN)nf[1]; v0 = varn(pol); N = deg(pol); dg = divisors(stoi(N)); ld = lg(dg)-1; if (DEBUGLEVEL) fprintferr("\n***** Entering subfields\n\npol = %Z\n",pol); p1 = cgetg(3,t_VEC); p1[1] = (long)pol; p1[2] = lpolx[v0]; LSB = _vec(p1); if (ld > 2) { FACTORDL = factor(absi((GEN)nf[3])); dpol = mulii(sqri((GEN)nf[4]),(GEN)nf[3]); for (i=2; i<ld; i++) { av1 = avma; NLSB = subfields_of_given_degree(nf,dpol, N / itos((GEN)dg[i])); if (lg(NLSB) > 1) LSB = concatsp(LSB,NLSB); else avma = av1; } } p1 = cgetg(3,t_VEC); p1[1] = (long)polx[v0]; p1[2] = (long)pol; LSB = concatsp(LSB, _vec(p1)); if (DEBUGLEVEL) fprintferr("\n***** Leaving subfields\n\n"); return gerepileupto(av, gcopy(LSB));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59af7aa1a95aeb4e670f3d2cf01cd1e105edb8c4/subfield.c/buggy/src/modules/subfield.c |
return gerepileupto(av, gcopy(LSB)); | return gerepileupto(av, gcopy(fix_var(LSB,v0))); | subfieldsall(GEN nf){ long av=avma,av1,N,ld,i,v0; GEN pol,dpol,dg,LSB,NLSB,p1; nf = checknf(nf); pol = (GEN)nf[1]; v0 = varn(pol); N = deg(pol); dg = divisors(stoi(N)); ld = lg(dg)-1; if (DEBUGLEVEL) fprintferr("\n***** Entering subfields\n\npol = %Z\n",pol); p1 = cgetg(3,t_VEC); p1[1] = (long)pol; p1[2] = lpolx[v0]; LSB = _vec(p1); if (ld > 2) { FACTORDL = factor(absi((GEN)nf[3])); dpol = mulii(sqri((GEN)nf[4]),(GEN)nf[3]); for (i=2; i<ld; i++) { av1 = avma; NLSB = subfields_of_given_degree(nf,dpol, N / itos((GEN)dg[i])); if (lg(NLSB) > 1) LSB = concatsp(LSB,NLSB); else avma = av1; } } p1 = cgetg(3,t_VEC); p1[1] = (long)polx[v0]; p1[2] = (long)pol; LSB = concatsp(LSB, _vec(p1)); if (DEBUGLEVEL) fprintferr("\n***** Leaving subfields\n\n"); return gerepileupto(av, gcopy(LSB));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59af7aa1a95aeb4e670f3d2cf01cd1e105edb8c4/subfield.c/buggy/src/modules/subfield.c |
lx=lg(x); y=cgetg(lx,tx); y[1]=x[1]; | lx=lg(x); y=cgetg(lx,t_POL); y[1]=x[1]; | gprec_w(GEN x, long pr){ long tx=typ(x),lx,i; GEN y; switch(tx) { case t_REAL: y=cgetr(pr); affrr(x,y); break; case t_POL: lx=lg(x); y=cgetg(lx,tx); y[1]=x[1]; for (i=2; i<lx; i++) y[i]=(long)gprec_w((GEN)x[i],pr); break; case t_COMPLEX: case t_POLMOD: case t_RFRAC: case t_VEC: case t_COL: case t_MAT: lx=lg(x); y=cgetg(lx,tx); for (i=1; i<lx; i++) y[i]=(long)gprec_w((GEN)x[i],pr); break; default: y=gprec(x,pr); } return y;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/2edc82b0d172402925241429eca01a236af8dd01/bibli2.c/buggy/src/basemath/bibli2.c |
rtems_status_code status; rtems_interval ticks_since_boot; | rtems_status_code status; rtems_interval ticks; | clock_t _times( struct tms *ptms){ rtems_status_code status; rtems_interval ticks_since_boot; if ( !ptms ) { errno = EFAULT; return -1; } /* "POSIX" does not seem to allow for not having a TOD */ status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks_since_boot ); if ( status != RTEMS_SUCCESSFUL ) { assert( 0 ); return -1; } /* * RTEMS has no notion of system versus user time and does * not (as of 3.2.0) keep track of CPU usage on a per task basis. */ ptms->tms_utime = ticks_since_boot; ptms->tms_stime = 0; ptms->tms_cutime = 0; ptms->tms_cstime = 0; return 0;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/__times.c/clean/cpukit/libcsupport/src/__times.c |
status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks_since_boot ); | status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks ); | clock_t _times( struct tms *ptms){ rtems_status_code status; rtems_interval ticks_since_boot; if ( !ptms ) { errno = EFAULT; return -1; } /* "POSIX" does not seem to allow for not having a TOD */ status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks_since_boot ); if ( status != RTEMS_SUCCESSFUL ) { assert( 0 ); return -1; } /* * RTEMS has no notion of system versus user time and does * not (as of 3.2.0) keep track of CPU usage on a per task basis. */ ptms->tms_utime = ticks_since_boot; ptms->tms_stime = 0; ptms->tms_cutime = 0; ptms->tms_cstime = 0; return 0;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/__times.c/clean/cpukit/libcsupport/src/__times.c |
* RTEMS has no notion of system versus user time and does * not (as of 3.2.0) keep track of CPU usage on a per task basis. | * RTEMS has no notion of system versus user time and although * a way to keep track of per task CPU usage was added since * 3.6.0, this routine does not utilize it yet. | clock_t _times( struct tms *ptms){ rtems_status_code status; rtems_interval ticks_since_boot; if ( !ptms ) { errno = EFAULT; return -1; } /* "POSIX" does not seem to allow for not having a TOD */ status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks_since_boot ); if ( status != RTEMS_SUCCESSFUL ) { assert( 0 ); return -1; } /* * RTEMS has no notion of system versus user time and does * not (as of 3.2.0) keep track of CPU usage on a per task basis. */ ptms->tms_utime = ticks_since_boot; ptms->tms_stime = 0; ptms->tms_cutime = 0; ptms->tms_cstime = 0; return 0;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/__times.c/clean/cpukit/libcsupport/src/__times.c |
ptms->tms_utime = ticks_since_boot; | ptms->tms_utime = ticks; | clock_t _times( struct tms *ptms){ rtems_status_code status; rtems_interval ticks_since_boot; if ( !ptms ) { errno = EFAULT; return -1; } /* "POSIX" does not seem to allow for not having a TOD */ status = rtems_clock_get( RTEMS_CLOCK_GET_TICKS_SINCE_BOOT, &ticks_since_boot ); if ( status != RTEMS_SUCCESSFUL ) { assert( 0 ); return -1; } /* * RTEMS has no notion of system versus user time and does * not (as of 3.2.0) keep track of CPU usage on a per task basis. */ ptms->tms_utime = ticks_since_boot; ptms->tms_stime = 0; ptms->tms_cutime = 0; ptms->tms_cstime = 0; return 0;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/07a3253de2c3f9bc2d96a351680ec72548dadd2d/__times.c/clean/cpukit/libcsupport/src/__times.c |
if (typ(x) != t_POL) return gscalcol(x, lg(A[1])-1); l=lgef(x)-1; if (l == 1) return zerocol(lg(A[1])-1); | if (typ(x) != t_POL) return gmul(x,(GEN)A[1]); /* scalar */ l=lgef(x)-1; if (l == 1) return typ(A)==t_VEC? gzero: zerocol(lg(A[1])-1); | mulmat_pol(GEN A, GEN x){ long i,l; GEN z; if (typ(x) != t_POL) return gscalcol(x, lg(A[1])-1); l=lgef(x)-1; if (l == 1) return zerocol(lg(A[1])-1); x++; z = gmul((GEN)x[1], (GEN)A[1]); for (i=2; i<l ; i++) if (!gcmp0((GEN)x[i])) z = gadd(z, gmul((GEN)x[i], (GEN)A[i])); return z;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/396563f37e475af678516ab5fc7a28538411a2d9/base3.c/clean/src/basemath/base3.c |
j=1+bfffo(m); m<<=j; j = BITS_IN_LONG-j; | j=1+bfffo((ulong)m); m<<=j; j = BITS_IN_LONG-j; | element_powid_mod_p(GEN nf, long I, GEN n, GEN p){ ulong av = avma; long s,N,i,j,m; GEN y,p1; if (typ(n)!=t_INT) err(talker,"not an integer exponent in nfpow"); nf=checknf(nf); N=degpol(nf[1]); s=signe(n); if (!s || I == 1) return gscalcol_i(gun,N); p1 = n+2; m = *p1; y = zerocol(N); y[I] = un; j=1+bfffo(m); m<<=j; j = BITS_IN_LONG-j; for (i=lgefint(n)-2;;) { for (; j; m<<=1,j--) { y = element_sqri(nf, y); if (m<0) y=element_mulid(nf, y, I); y = FpV_red(y, p); } if (--i == 0) break; m = *++p1; j = BITS_IN_LONG; } if (s<0) y = FpV_red(element_inv(nf,y), p); return av==avma? gcopy(y): gerepileupto(av,y);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/6f0450eaf26bb1653fbb257487c2cbc116d69406/base3.c/clean/src/basemath/base3.c |
if (!do_units) return gerepileupto(av0, gcopy(z)); | if (!do_units) return gerepilecopy(av0, z); | ideallistzstarall(GEN bnf,long bound,long flag){ byteptr ptdif=diffptr; long lim,av0=avma,av,i,j,k,l,q2,lp1,q; long do_gen = flag & 1, do_units = flag & 2, big_id = !(flag & 4); GEN y,nf,p,z,z2,p1,p2,p3,fa,pr,ideal,lu,lu2,funits,racunit,embunit; nf = checknf(bnf); if (bound <= 0) return cgetg(1,t_VEC); z = cgetg(bound+1,t_VEC); for (i=2; i<=bound; i++) z[i] = lgetg(1,t_VEC); ideal = idmat(degpol(nf[1])); if (big_id) ideal = zidealstarinitall(nf,ideal,do_gen); z[1] = (long)_vec(ideal); if (do_units) { init_units(bnf,&funits,&racunit); lu = cgetg(bound+1,t_VEC); for (i=2; i<=bound; i++) lu[i]=lgetg(1,t_VEC); lu[1] = (long)_vec(logunitmatrix(nf,funits,racunit,ideal)); } p=cgeti(3); p[1]=evalsigne(1) | evallgefint(3); av=avma; lim=stack_lim(av,1); lu2 = embunit = NULL; /* gcc -Wall */ if (bound > (long)maxprime()) err(primer1); for (p[2]=0; p[2]<=bound; ) { p[2] += *ptdif++; if (DEBUGLEVEL>1) { fprintferr("%ld ",p[2]); flusherr(); } fa = primedec(nf,p); for (j=1; j<lg(fa); j++) { pr = (GEN)fa[j]; p1 = powgi(p,(GEN)pr[4]); if (is_bigint(p1) || (q = itos(p1)) > bound) continue; q2=q; ideal=pr; z2=dummycopy(z); if (do_units) lu2=dummycopy(lu); for (l=2; ;l++) { if (big_id) ideal = zidealstarinitall(nf,ideal,do_gen); if (do_units) embunit = logunitmatrix(nf,funits,racunit,ideal); for (i=q; i<=bound; i+=q) { p1 = (GEN)z[i/q]; lp1 = lg(p1); if (lp1 == 1) continue; p2 = cgetg(lp1,t_VEC); for (k=1; k<lp1; k++) if (big_id) p2[k] = (long)zidealstarinitjoin(nf,(GEN)p1[k],ideal,do_gen); else p2[k] = (long)idealmul(nf,(GEN)p1[k],ideal); z2[i] = (long)concatsp((GEN)z2[i],p2); if (do_units) { p1 = (GEN)lu[i/q]; p2 = cgetg(lp1,t_VEC); for (k=1; k<lp1; k++) p2[k] = (long)vconcat((GEN)p1[k],embunit); lu2[i] = (long)concatsp((GEN)lu2[i],p2); } } q *= q2; if ((ulong)q > (ulong)bound) break; ideal = idealpows(nf,pr,l); } z = z2; if (do_units) lu = lu2; } if (low_stack(lim, stack_lim(av,1))) { GEN *gptr[2]; gptr[0]=&z; gptr[1]=&lu; if(DEBUGMEM>1) err(warnmem,"ideallistzstarall"); gerepilemany(av,gptr,do_units?2:1); } } if (!do_units) return gerepileupto(av0, gcopy(z)); y = cgetg(3,t_VEC); y[1] = lcopy(z); lu2 = cgetg(lg(z),t_VEC); for (i=1; i<lg(z); i++) { p1=(GEN)z[i]; p2=(GEN)lu[i]; lp1=lg(p1); p3=cgetg(lp1,t_VEC); lu2[i]=(long)p3; for (j=1; j<lp1; j++) p3[j] = lmul(gmael(p1,j,5),(GEN)p2[j]); } y[2]=(long)lu2; return gerepileupto(av0, y);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/7168973a923818508c45aa17d871c53e9225fad1/base3.c/buggy/src/basemath/base3.c |
long av,tetpil,i,j,lp1; long do_units = flag & 2; | ulong av; long i,j,lp1, do_units = flag & 2; | ideallistarchall(GEN bnf,GEN list,GEN arch,long flag){ long av,tetpil,i,j,lp1; long do_units = flag & 2; GEN nf = checknf(bnf), p1,p2,p3,racunit,funits,lu2,lu,embunit,z,y; if (typ(list) != t_VEC || (do_units && lg(list) != 3)) err(typeer, "ideallistarch"); if (lg(list) == 1) return cgetg(1,t_VEC); if (do_units) { y = cgetg(3,t_VEC); z = (GEN)list[1]; lu= (GEN)list[2]; if (typ(lu) != t_VEC) err(typeer, "ideallistarch"); } else { z = list; y = lu = NULL; /* gcc -Wall */ } if (typ(z) != t_VEC) err(typeer, "ideallistarch"); z = ideallist_arch(nf,z,arch, flag & 1); if (!do_units) return z; y[1]=(long)z; av=avma; init_units(bnf,&funits,&racunit); lu2=cgetg(lg(z),t_VEC); for (i=1; i<lg(z); i++) { p1=(GEN)z[i]; p2=(GEN)lu[i]; lp1=lg(p1); p3=cgetg(lp1,t_VEC); lu2[i]=(long)p3; for (j=1; j<lp1; j++) { embunit = logunitmatrixarch(nf,funits,racunit,(GEN)p1[j]); p3[j] = lmul(gmael(p1,j,5), vconcat((GEN)p2[j],embunit)); } } tetpil=avma; y[2]=lpile(av,tetpil,gcopy(lu2)); return y;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/7168973a923818508c45aa17d871c53e9225fad1/base3.c/buggy/src/basemath/base3.c |
tetpil=avma; y[2]=lpile(av,tetpil,gcopy(lu2)); return y; | y[2]=lpilecopy(av,lu2); return y; | ideallistarchall(GEN bnf,GEN list,GEN arch,long flag){ long av,tetpil,i,j,lp1; long do_units = flag & 2; GEN nf = checknf(bnf), p1,p2,p3,racunit,funits,lu2,lu,embunit,z,y; if (typ(list) != t_VEC || (do_units && lg(list) != 3)) err(typeer, "ideallistarch"); if (lg(list) == 1) return cgetg(1,t_VEC); if (do_units) { y = cgetg(3,t_VEC); z = (GEN)list[1]; lu= (GEN)list[2]; if (typ(lu) != t_VEC) err(typeer, "ideallistarch"); } else { z = list; y = lu = NULL; /* gcc -Wall */ } if (typ(z) != t_VEC) err(typeer, "ideallistarch"); z = ideallist_arch(nf,z,arch, flag & 1); if (!do_units) return z; y[1]=(long)z; av=avma; init_units(bnf,&funits,&racunit); lu2=cgetg(lg(z),t_VEC); for (i=1; i<lg(z); i++) { p1=(GEN)z[i]; p2=(GEN)lu[i]; lp1=lg(p1); p3=cgetg(lp1,t_VEC); lu2[i]=(long)p3; for (j=1; j<lp1; j++) { embunit = logunitmatrixarch(nf,funits,racunit,(GEN)p1[j]); p3[j] = lmul(gmael(p1,j,5), vconcat((GEN)p2[j],embunit)); } } tetpil=avma; y[2]=lpile(av,tetpil,gcopy(lu2)); return y;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/7168973a923818508c45aa17d871c53e9225fad1/base3.c/buggy/src/basemath/base3.c |
rtems_unsigned32 n = rtems_get_index(*next_id); | uint32_t n = rtems_get_index(*next_id); | rtems_monitor_dname_next( void *object_information, rtems_monitor_dname_t *canonical_dname, rtems_id *next_id){ rtems_unsigned32 n = rtems_get_index(*next_id); rtems_driver_name_t *table = _IO_Driver_name_table; rtems_driver_name_t *np = 0;/* XXX should we be using _IO_Number_of_devices */ for (np = table + n ; n<_IO_Number_of_devices; n++, np++) if (np->device_name) goto done; *next_id = RTEMS_OBJECT_ID_FINAL; return 0;done: _Thread_Disable_dispatch(); /* * dummy up a fake id and name for this item */ canonical_dname->id = n; canonical_dname->name = rtems_build_name('-', '-', '-', '-'); *next_id += 1; return np;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/3e08d4ee6242f1a0ea4afe9dc0a20800632184fe/mon-dname.c/clean/cpukit/libmisc/monitor/mon-dname.c |
unsigned32 length = 0; | uint32_t length = 0; | rtems_monitor_driver_dump( rtems_monitor_driver_t *monitor_driver, boolean verbose){ unsigned32 length = 0; length += printf(" %d", monitor_driver->id); length += rtems_monitor_pad(13, length); length += printf("init: "); length += rtems_monitor_symbol_dump(&monitor_driver->initialization, verbose); length += printf("; control: "); length += rtems_monitor_symbol_dump(&monitor_driver->control, verbose); length += printf("\n"); length = 0; length += rtems_monitor_pad(13, length); length += printf("open: "); length += rtems_monitor_symbol_dump(&monitor_driver->open, verbose); length += printf("; close: "); length += rtems_monitor_symbol_dump(&monitor_driver->close, verbose); length += printf("\n"); length = 0; length += rtems_monitor_pad(13, length); length += printf("read: "); length += rtems_monitor_symbol_dump(&monitor_driver->read, verbose); length += printf("; write: "); length += rtems_monitor_symbol_dump(&monitor_driver->write, verbose); length += printf("\n"); length = 0;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/3e08d4ee6242f1a0ea4afe9dc0a20800632184fe/mon-driver.c/clean/cpukit/libmisc/monitor/mon-driver.c |
if (!group) { avma = av; return gzero; } | rnfconductor(GEN bnf, GEN polrel, long flag, long prec){ long av=avma,tetpil,R1,i,v; GEN nf,module,rnf,arch,bnr,group,p1,pol2; bnf = checkbnf(bnf); nf=(GEN)bnf[7]; if (typ(polrel)!=t_POL) err(typeer,"rnfconductor"); module=cgetg(3,t_VEC); R1=itos(gmael(nf,2,1)); v=varn(polrel); p1=unifpol((GEN)bnf[7],polrel,0); p1=denom(gtovec(p1)); pol2=gsubst(polrel,v,gdiv(polx[v],p1)); pol2=gmul(pol2,gpuigs(p1,degree(pol2))); if (flag) { rnf=rnfinitalg(bnf,pol2,DEFAULTPREC); module[1]=mael(rnf,3,1); } else { rnf=NULL; module[1]=rnfdiscf(nf,pol2)[1]; } arch=cgetg(R1+1,t_VEC); module[2]=(long)arch; for (i=1; i<=R1; i++) arch[i]=un; bnr=buchrayall(bnf,module,nf_INIT | nf_GEN,prec); group=rnfnormgroup0(bnr,pol2,rnf); tetpil=avma; return gerepile(av,tetpil,conductor(bnr,group,1,prec));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/275f4667f70a314841e502489753d9e76fa02c47/buch3.c/clean/src/basemath/buch3.c |
|
return gerepileupto(av,s); | return gerepileupto(av, s); | eltreltoabs(GEN rnfeq, GEN x){ long i, k, va; pari_sp av = avma; GEN polabs, teta, alpha, s; rnfeq = checkrnfeq(rnfeq); polabs= (GEN)rnfeq[1]; alpha = (GEN)rnfeq[2]; k = itos((GEN)rnfeq[3]); va = varn(polabs); if (gvar(x) > va) x = scalarpol(x,va); /* Mod(X + k alpha, polabs(X)), alpha root of the polynomial defining base */ teta = gmodulcp(gsub(polx[va], gmulsg(k,lift_intern(alpha))), polabs); s = gzero; for (i=lgef(x)-1; i>1; i--) { GEN c = (GEN)x[i]; long tc = typ(c); switch(tc) { case t_POLMOD: c = (GEN)c[2]; /* fall through */ case t_POL: c = poleval(c, alpha); break; default: if (!is_const_t(tc)) err(talker, "incorrect data in eltreltoabs"); } s = gadd(c, gmul(teta,s)); } return gerepileupto(av,s);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59f511650949bd335c0ea3ba14f6dd6ce94d3308/base5.c/clean/src/basemath/base5.c |
return gerepileupto(av, subfields_of_given_degree(nf,dpol,di)); | p1 = subfields_of_given_degree(nf,dpol,di); return gerepileupto(av, fix_var(p1,v0)); | subfields(GEN nf,GEN d){ long av=avma,di,N,v0; GEN dpol,p1,pol; nf = checknf(nf); pol = (GEN)nf[1]; v0=varn(pol); N=deg(pol); di=itos(d); if (di==N) { p1 = cgetg(3,t_VEC); p1[1] = lcopy(pol); p1[2] = lpolx[v0]; return _vec(p1); } if (di==1) { p1 = cgetg(3,t_VEC); p1[1] = lpolx[v0]; p1[2] = lcopy(pol); return _vec(p1); } if (di<=0 || di>N || N%di) return cgetg(1,t_VEC); FACTORDL = factor(absi((GEN)nf[3])); dpol = mulii((GEN)nf[3],sqri((GEN)nf[4])); return gerepileupto(av, subfields_of_given_degree(nf,dpol,di));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59af7aa1a95aeb4e670f3d2cf01cd1e105edb8c4/subfield.c/buggy/src/modules/subfield.c |
/*mode = (mode_t) va_arg( arg, mode_t * );*/ | sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
|
/*value = (unsigned int) va_arg( arg, unsigned int * );*/ | sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
|
if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ | /* * Unless we are willing to create name -> ID translation failure is * an error. */ if ( status == EINVAL ) { if ( !(oflag & O_CREAT) ) { | sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
/* we are willing to create it */ | sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
|
/* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ | sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
|
} else { /* name -> ID translation succeeded */ | } else { /* * Check for existence with creation. */ | sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
/* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ | sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
|
sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
||
/* XXX verify this comment... * | /* | sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
return (sem_t *) -1; | return SEM_FAILED; | sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
sem_t *sem_open( const char *name, int oflag, ... /* mode_t mode, */ /* unsigned int value */){ va_list arg; mode_t mode; unsigned int value = 0; int status; Objects_Id the_semaphore_id; POSIX_Semaphore_Control *the_semaphore; Objects_Locations location; if ( oflag & O_CREAT ) { va_start(arg, oflag); /*mode = (mode_t) va_arg( arg, mode_t * );*/ mode = va_arg( arg, mode_t ); /*value = (unsigned int) va_arg( arg, unsigned int * );*/ value = va_arg( arg, unsigned int ); va_end(arg); } status = _POSIX_Semaphore_Name_to_id( name, &the_semaphore_id ); /* * If the name to id translation worked, then the semaphore exists * and we can just return a pointer to the id. Otherwise we may * need to check to see if this is a "semaphore does not exist" * or some other miscellaneous error on the name. */ if ( status ) { if ( status == EINVAL ) { /* name -> ID translation failed */ if ( !(oflag & O_CREAT) ) { /* willing to create it? */ set_errno_and_return_minus_one_cast( ENOENT, sem_t * ); } /* we are willing to create it */ } /* some type of error */ /*set_errno_and_return_minus_one_cast( status, sem_t * );*/ } else { /* name -> ID translation succeeded */ if ( (oflag & (O_CREAT | O_EXCL)) == (O_CREAT | O_EXCL) ) { set_errno_and_return_minus_one_cast( EEXIST, sem_t * ); } /* * XXX In this case we need to do an ID->pointer conversion to * check the mode. This is probably a good place for a subroutine. */ the_semaphore = _POSIX_Semaphore_Get( &the_semaphore_id, &location ); the_semaphore->open_count += 1; return (sem_t *)&the_semaphore->Object.id; } /* XXX verify this comment... * * At this point, the semaphore does not exist and everything has been * checked. We should go ahead and create a semaphore. */ status = _POSIX_Semaphore_Create_support( name, FALSE, /* not shared across processes */ value, &the_semaphore ); if ( status == -1 ) return (sem_t *) -1; return (sem_t *) &the_semaphore->Object.id; } | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/17879f4750a2bc0d556c8cd1d0f6715b127d681a/semopen.c/buggy/c/src/exec/posix/src/semopen.c |
||
avma = av; y = cgetr(3); y[1] = evalexpo(itos(x)); y[2] = 0; return y; | avma = av; return realzero_bit(itos(x)); | gpow(GEN x, GEN n, long prec){ long av,tetpil,i,lx,tx; GEN y; if (typ(n)==t_INT) return powgi(x,n); tx = typ(x); if (is_matvec_t(tx)) { lx=lg(x); y=cgetg(lx,tx); for (i=1; i<lx; i++) y[i]=lpui((GEN)x[i],n,prec); return y; } if (tx==t_SER) { if (valp(x)) err(talker,"not an integer exponent for non invertible series in gpow"); if (lg(x) == 2) return gcopy(x); /* O(1) */ return ser_pui(x,n,prec); } av=avma; if (gcmp0(x)) { long tn = typ(n); if (!is_scalar_t(tn) || tn == t_PADIC || tn == t_INTMOD) err(talker,"zero to a forbidden power in gpow"); n = greal(n); if (gsigne(n) <= 0) err(talker,"zero to a non positive exponent in gpow"); if (!precision(x)) return gcopy(x); x = ground(gmulsg(gexpo(x),n)); if (is_bigint(x) || (ulong)x[2] >= (ulong)HIGHEXPOBIT) err(talker,"underflow or overflow in gpow"); avma = av; y = cgetr(3); y[1] = evalexpo(itos(x)); y[2] = 0; return y; } if (tx==t_INTMOD && typ(n)==t_FRAC) { GEN p1; if (!isprime((GEN)x[1])) err(talker,"modulus must be prime in gpow"); y=cgetg(3,tx); copyifstack(x[1],y[1]); av=avma; p1=mpsqrtnmod((GEN)x[2],(GEN)n[2],(GEN)x[1],NULL); if(!p1) err(talker,"n-root does not exists in gpow"); p1=powmodulo(p1,(GEN)n[1],(GEN)x[1]); y[2]=lpileupto(av,p1); return y; } i = (long) precision(n); if (i) prec=i; y=gmul(n,glog(x,prec)); tetpil=avma; return gerepile(av,tetpil,gexp(y,prec));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/1558baf8c3b715dd704e6dddf2c7f1f51dc47e84/trans1.c/buggy/src/basemath/trans1.c |
powpolmod(Cache *C, Red *R, int p, int k, GEN jac) | powpolmod(Cache *C, Red *R, long p, long k, GEN jac) | powpolmod(Cache *C, Red *R, int p, int k, GEN jac){ GEN (*_sqr)(GEN, Red *); if (DEBUGLEVEL>2) C->ctsgt++; if (C->matvite) return _powpolmodsimple(C, R, jac); if (p == 2) /* p = 2 */ { if (k == 2) _sqr = &sqrmod4; else _sqr = &sqrmod; R->n = k; R->red = &_red_cyclo2n; } else if (k == 1) { if (p == 3) _sqr = &sqrmod3; else if (p == 5) _sqr = &sqrmod5; else _sqr = &sqrmod; R->n = p; R->red = &_red_cyclop; } else { R->red = &_red; _sqr = &sqrmod; } return _powpolmod(C, jac, R, _sqr);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/b03001ef86c74799b6280212f7a40aee0823ed89/aprcl.c/clean/src/modules/aprcl.c |
pari_sp av = avma; long l = precision(x); if (!l) l = prec; | pari_sp av = avma, av2; long L, l = precision(x); if (!l) l = prec; | agm1cx(GEN x, long prec){ GEN a1, b1; pari_sp av = avma; long l = precision(x); if (!l) l = prec; a1 = x; b1 = gun; l = 5-bit_accuracy(l); do { GEN a = a1; a1 = gmul2n(gadd(a,b1),-1); b1 = gsqrt(gmul(a,b1), prec); } while (gexpo(gsub(b1,a1)) - gexpo(b1) >= l); return gerepilecopy(av,a1);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/a0d8bd4ca3992fcf4e709bbc857cacac191dae1b/trans1.c/buggy/src/basemath/trans1.c |
a1 = x; b1 = gun; l = 5-bit_accuracy(l); do | L = 5-bit_accuracy(l); a1 = gmul2n(gadd(realun(l), x), -1); av2 = avma; b1 = gsqrt(x, prec); while (gexpo(gsub(b1,a1)) - gexpo(b1) >= L) | agm1cx(GEN x, long prec){ GEN a1, b1; pari_sp av = avma; long l = precision(x); if (!l) l = prec; a1 = x; b1 = gun; l = 5-bit_accuracy(l); do { GEN a = a1; a1 = gmul2n(gadd(a,b1),-1); b1 = gsqrt(gmul(a,b1), prec); } while (gexpo(gsub(b1,a1)) - gexpo(b1) >= l); return gerepilecopy(av,a1);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/a0d8bd4ca3992fcf4e709bbc857cacac191dae1b/trans1.c/buggy/src/basemath/trans1.c |
while (gexpo(gsub(b1,a1)) - gexpo(b1) >= l); return gerepilecopy(av,a1); | avma = av2; return gerepileupto(av,a1); | agm1cx(GEN x, long prec){ GEN a1, b1; pari_sp av = avma; long l = precision(x); if (!l) l = prec; a1 = x; b1 = gun; l = 5-bit_accuracy(l); do { GEN a = a1; a1 = gmul2n(gadd(a,b1),-1); b1 = gsqrt(gmul(a,b1), prec); } while (gexpo(gsub(b1,a1)) - gexpo(b1) >= l); return gerepilecopy(av,a1);} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/a0d8bd4ca3992fcf4e709bbc857cacac191dae1b/trans1.c/buggy/src/basemath/trans1.c |
GEN y, z; | GEN z; | mpch(GEN x){ pari_sp av; GEN y, z; if (gcmp0(x)) { /* 1 + x */ long e = expo(x); if (e > 0) return realzero_bit(e); return realun(3 + ((-e)>>TWOPOTBITS_IN_LONG)); } y = cgetr(lg(x)); av = avma; z = mpexp(x); z = addrr(z, ginv(z)); setexpo(z, expo(z)-1); affrr(z, y); avma = av; return y;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/a0d8bd4ca3992fcf4e709bbc857cacac191dae1b/trans2.c/buggy/src/basemath/trans2.c |
y = cgetr(lg(x)); av = avma; z = mpexp(x); z = addrr(z, ginv(z)); setexpo(z, expo(z)-1); affrr(z, y); avma = av; return y; | av = avma; z = mpexp(x); z = addrr(z, ginv(z)); setexpo(z, expo(z)-1); return gerepileuptoleaf(av, z); | mpch(GEN x){ pari_sp av; GEN y, z; if (gcmp0(x)) { /* 1 + x */ long e = expo(x); if (e > 0) return realzero_bit(e); return realun(3 + ((-e)>>TWOPOTBITS_IN_LONG)); } y = cgetr(lg(x)); av = avma; z = mpexp(x); z = addrr(z, ginv(z)); setexpo(z, expo(z)-1); affrr(z, y); avma = av; return y;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/a0d8bd4ca3992fcf4e709bbc857cacac191dae1b/trans2.c/buggy/src/basemath/trans2.c |
if (Z) *Z = shiftpol(x, v); | if (Z) *Z = shiftpol_i(x, v); | polvaluation_inexact(GEN x, GEN *Z){ long v; if (!signe(x)) { if (Z) *Z = zeropol(varn(x)); return VERYBIGINT; } for (v = 0;; v++) if (!gcmp0((GEN)x[2+v])) break; if (Z) *Z = shiftpol(x, v); return v;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d3de7e02a93356b9ace88132cf2b2d1d2820bfd1/gen2.c/buggy/src/basemath/gen2.c |
GEN AL, E = (GEN)tabE[pk]; | GEN AL, E = (GEN)tabE[pkfalse]; | get_AL(GEN N, int pk){ const int r = smodis(N, pk); GEN AL, E = (GEN)tabE[pk]; int i, LE = lg(E); AL = cgetg(LE,t_VEC); for (i=1; i<LE; i++) { GEN p1 = cgetg(3,t_VECSMALL); AL[i] = (long)p1; p1[1] = E[i]; p1[2] = (r*E[i]) / pk; } return AL;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d824424e0a4051e3b938353b1b01e0b528104092/aprcl.c/clean/src/modules/aprcl.c |
a,b, lg(oldCM_L)-1, CM_L? lg(CM_L)-1: 1, TIMER(&TI)); | a,b, lg(m)-1, CM_L? lg(CM_L)-1: 1, TIMER(&TI)); | LLL_cmbf(GEN P, GEN famod, GEN p, GEN pa, GEN bound, long a, long rec){ const long N0 = 1; /* # of traces added at each step */ double BitPerFactor = 0.5; /* nb bits in p^(a-b) / modular factor */ long i,j,tmax,n0,C, dP = degpol(P); double logp = log((double)itos(p)), LOGp2 = LOG2/logp; double b0 = log((double)dP*2) / logp, logBr; GEN lP, Br, Bnorm, Tra, T2, TT, CM_L, m, list, ZERO; gpmem_t av, av2, lim; long ti_LLL = 0, ti_CF = 0; pari_timer ti, ti2, TI; if (DEBUGLEVEL>2) (void)TIMER(&ti); lP = absi(leading_term(P)); if (is_pm1(lP)) lP = NULL; Br = root_bound(P); if (lP) Br = gmul(lP, Br); logBr = gtodouble(glog(Br, DEFAULTPREC)) / logp; n0 = lg(famod) - 1; C = (long)ceil( sqrt(N0 * n0 / 4.) ); /* > 1 */ Bnorm = dbltor(n0 * (C*C + N0*n0/4.) * 1.00001); ZERO = zeromat(n0, N0); av = avma; lim = stack_lim(av, 1); TT = cgetg(n0+1, t_VEC); Tra = cgetg(n0+1, t_MAT); for (i=1; i<=n0; i++) { TT[i] = 0; Tra[i] = lgetg(N0+1, t_COL); } CM_L = gscalsmat(C, n0); /* tmax = current number of traces used (and computed so far) */ for (tmax = 0;; tmax += N0) { long b, bmin, bgood, delta, tnew = tmax + N0, r = lg(CM_L)-1; GEN M_L, q, CM_Lp, oldCM_L; int first = 1; bmin = (long)ceil(b0 + tnew*logBr); if (DEBUGLEVEL>2) fprintferr("\nLLL_cmbf: %ld potential factors (tmax = %ld, bmin = %ld)\n", r, tmax, bmin); /* compute Newton sums (possibly relifting first) */ if (a <= bmin) { a = (long)ceil(bmin + 3*N0*logBr) + 1; /* enough for 3 more rounds */ a = next2pow(a); pa = gpowgs(p,a); famod = hensel_lift_fact(P,famod,NULL,p,pa,a); for (i=1; i<=n0; i++) TT[i] = 0; } for (i=1; i<=n0; i++) { GEN p1 = (GEN)Tra[i]; GEN p2 = polsym_gen((GEN)famod[i], (GEN)TT[i], tnew, NULL, pa); TT[i] = (long)p2; p2 += 1+tmax; /* ignore traces number 0...tmax */ for (j=1; j<=N0; j++) p1[j] = p2[j]; if (lP) { /* make Newton sums integral */ GEN lPpow = gpowgs(lP, tmax); for (j=1; j<=N0; j++) { lPpow = mulii(lPpow,lP); p1[j] = lmulii((GEN)p1[j], lPpow); } } } /* compute truncation parameter */ if (DEBUGLEVEL>2) { TIMERstart(&ti2); TIMERstart(&TI); } oldCM_L = CM_L; av2 = avma; delta = b = 0; /* -Wall */AGAIN: M_L = gdivexact(CM_L, stoi(C)); T2 = centermod( gmul(Tra, M_L), pa ); if (first) { /* initialize lattice, using few p-adic digits for traces */ double t = gexpo(T2) - max(32, BitPerFactor*r); bgood = (long) (t * LOGp2); b = max(bmin, bgood); delta = a - b; } else { /* add more p-adic digits and continue reduction */ long b0 = gexpo(T2) * LOGp2; if (b0 < b) b = b0; b = max(b-delta, bmin); if (b - delta/2 < bmin) b = bmin; /* near there. Go all the way */ } q = gpowgs(p, b); m = vconcat( CM_L, gdivround(T2, q) ); if (first) { GEN P1 = gscalmat(gpowgs(p, a-b), N0); first = 0; m = concatsp( m, vconcat(ZERO, P1) ); /* [ C M_L 0 ] * m = [ ] square matrix * [ T2' p^(a-b) I_s ] T2' = Tra * M_L truncated */ } CM_L = LLL_check_progress(Bnorm, n0, m, b == bmin, /*dbg:*/ &ti, &ti_LLL); if (DEBUGLEVEL>2) fprintferr("LLL_cmbf: (a,b) =%4ld,%4ld; r =%3ld -->%3ld, time = %ld\n", a,b, lg(oldCM_L)-1, CM_L? lg(CM_L)-1: 1, TIMER(&TI)); if (!CM_L) { list = _col(P); break; } if (b > bmin) { CM_L = gerepilecopy(av2, CM_L); goto AGAIN; } if (DEBUGLEVEL>2) msgTIMER(&ti2, "for this block of traces"); i = lg(CM_L) - 1; if (i == r && gegal(CM_L, oldCM_L)) { CM_L = oldCM_L; avma = av2; continue; } CM_Lp = FpM_image(CM_L, stoi(27449)); /* inexpensive test */ if (lg(CM_Lp) != lg(CM_L)) { if (DEBUGLEVEL>2) fprintferr("LLL_cmbf: rank decrease\n"); CM_L = ZM_HNFimage(CM_L); } if (i <= r && i*rec < n0) { if (DEBUGLEVEL>2) (void)TIMER(&ti); list = check_factors(P, M_L, bound, famod, pa); if (DEBUGLEVEL>2) ti_CF += TIMER(&ti); if (list) break; CM_L = gerepilecopy(av2, CM_L); } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"LLL_cmbf"); gerepileall(av, 5, &CM_L, &TT, &Tra, &famod, &pa); } } if (DEBUGLEVEL>2) fprintferr("* Time LLL: %ld\n* Time Check Factor: %ld\n",ti_LLL,ti_CF); return list;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/babcdb564493374762bd4ced20474cccd01dec85/polarit2.c/clean/src/basemath/polarit2.c |
long ffs,fs,resp,flbou,tdi,nba, k2,karch,kka,nbarch,jjj,jj,square; | long ffs,fs,resp,flbou,nba, k2,karch,kka,nbarch,jjj,jj,square; | discrayabslistarchintern(GEN bnf, GEN arch, long bound, long ramip){ byteptr ptdif=diffptr; long degk,lim,av0,av,av1,tetpil,i,j,k,p2s,lfa,lp1,sqbou,cex, allarch; long ffs,fs,resp,flbou,tdi,nba, k2,karch,kka,nbarch,jjj,jj,square; long ii2,ii,ly,clhray,lfa2,ep,som,clhss,normps,normi,nbdezero,r1,R1,n,c; ulong q; GEN nf,p,z,pol,p1,p2,p3,fa,pr,normp,ideal,bidp,z2,matarchunit; GEN bigres,funits,racunit,embunit,sous,clh,sousray,raylist; GEN clhrayall,discall,faall,Id,idealrel,idealrelinit; GEN sousdisc,module,fa2,ex,fac,no1,no2,fad,fad1,fad2,fadkabs,pz; GEN arch2,dlk,disclist,bidsimp,p4,faussefa,pex,fauxpr,gprime; GEN *gptr[2]; clhray = nbdezero = 0; /* gcc -Wall */ module = Id = dlk = ideal = clhrayall = discall = faall = NULL; /* ce qui suit recopie d'assez pres ideallistzstarall */ if (DEBUGLEVEL>2) timer2(); if (bound <= 0) err(talker,"non-positive bound in discrayabslist"); av0=avma; bnf = checkbnf(bnf); flbou=0; nf=(GEN)bnf[7]; bigres=(GEN)bnf[8]; pol=(GEN)nf[1]; degk=lgef(pol)-3; r1 = nf_get_r1(nf); fadkabs=factor(absi((GEN)nf[3])); clh=gmael(bigres,1,1); funits = check_units(bnf,"discrayabslistarchintern"); racunit=gmael(bigres,4,2); if (ramip >= 0) square = 0; else { square = 1; ramip = -ramip; if (ramip==1) ramip=0; } nba = 0; allarch = (arch==NULL); if (allarch) { arch=cgetg(r1+1,t_VEC); for (i=1; i<=r1; i++) arch[i]=un; nba=r1; } else if (gcmp0(arch)) { arch=cgetg(r1+1,t_VEC); for (i=1; i<=r1; i++) arch[i]=zero; } else { if (lg(arch)!=r1+1) err(talker,"incorrect archimedean argument in discrayabslistlong"); for (i=1; i<=r1; i++) if (signe(arch[i])) nba++; if (nba) module=cgetg(3,t_VEC); } p1=cgetg(3,t_VEC); p1[1]=(long)idmat(degk); p1[2]=(long)arch; bidp=zidealstarinitall(nf,p1,0); matarchunit = allarch? logunitmatrix(nf,funits,racunit,bidp): (GEN)NULL; p=cgeti(3); p[1]=evalsigne(1)|evallgef(3); sqbou=itos(racine(stoi(bound)))+1; av=avma; lim=stack_lim(av,1); z=bigcgetvec(bound); for (i=2; i<=bound; i++) putcompobig(z,i,cgetg(1,t_VEC)); if (allarch) bidp=zidealstarinitall(nf,idmat(degk),0); embunit=logunitmatrix(nf,funits,racunit,bidp); p1=cgetg(2,t_VEC); putcompobig(z,1,p1); p1[1]=(long)zsimp(bidp,embunit); if (DEBUGLEVEL>=2) fprintferr("Starting zidealstarunits computations\n"); for (p[2]=0; p[2]<=bound; ) { if (!*ptdif) err(primer1); p[2] += *ptdif++; if (!flbou && p[2]>sqbou) { flbou=1; if (DEBUGLEVEL>=2) { fprintferr("\nStarting rayclassno computations\n"); flusherr(); } tetpil=avma; z=gerepile(av,tetpil,gcopy(z)); av1=avma; raylist=bigcgetvec(bound); /* maintenant on suit rayclassnolist */ for (i=1; i<=bound; i++) { sous=getcompobig(z,i); sousray=rayclassnointernarch(sous,clh,matarchunit); putcompobig(raylist,i,sousray); } tetpil=avma; raylist=gerepile(av1,tetpil,gcopy(raylist)); z2=bigcgetvec(sqbou); for (i=1; i<=sqbou; i++) { p1=gcopy(getcompobig(z,i)); putcompobig(z2,i,p1); } z = z2; } fa=primedec(nf,p); lfa=lg(fa)-1; for (j=1; j<=lfa; j++) { pr=(GEN)fa[j]; normp=powgi(p,(GEN)pr[4]); cex=0; if (DEBUGLEVEL>=2) { fprintferr("%ld ",p[2]); flusherr(); } if (gcmpgs(normp,bound)<=0) { fauxpr=stoi(p[2]*degk*degk+(itos((GEN)pr[4])-1)*degk+j-1); q=p2s=itos(normp); ideal=pr; while (q <= (ulong)bound) { bidp=zidealstarinitall(nf,ideal,0); faussefa=cgetg(3,t_MAT); p1=cgetg(2,t_COL); faussefa[1]=(long)p1; p1[1]=(long)fauxpr; pex=cgetg(2,t_COL); faussefa[2]=(long)pex; cex++; pex[1]=lstoi(cex); embunit=logunitmatrix(nf,funits,racunit,bidp); for (i=q; i<=bound; i+=q) { p1=getcompobig(z,i/q); lp1=lg(p1); if (lp1>1) { p2=cgetg(lp1,t_VEC); c=0; for (k=1; k<lp1; k++) { p3=(GEN)p1[k]; if (i==q || ((p4=gmael(p3,1,1)) && !isinvector(p4,fauxpr,lg(p4)-1))) { c++; p2[c]=(long)zsimpjoin(p3,bidp,faussefa,embunit); } } setlg(p2,c+1); if (c) { if (p[2]<=sqbou) { pz=getcompobig(z,i); if (lg(pz)>1) putcompobig(z,i,concatsp(pz,p2)); else putcompobig(z,i,p2); } else { sousray=rayclassnointernarch(p2,clh,matarchunit); pz=getcompobig(raylist,i); if (lg(pz)>1) putcompobig(raylist,i,concatsp(pz,sousray)); else putcompobig(raylist,i,sousray); } } } } if (ramip && ramip % p[2]) q=bound+1; else { pz=mulss(q,p2s); q=(gcmpgs(pz,bound)>0)?bound+1:pz[2]; if (q <= (ulong)bound) ideal=idealmul(nf,ideal,pr); } } } } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[1]: discrayabslistarch"); if (!flbou) { if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(z) = %ld ",avma-bot,taille2(z)); tetpil=avma; z=gerepile(av,tetpil,gcopy(z)); } else { if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(r) = %ld ",avma-bot,taille2(raylist)); gptr[0]=&z; gptr[1]=&raylist; gerepilemany(av,gptr,2); } if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); flusherr(); } } } if (!flbou) /* maintenant on suit rayclassnolist */ { if (DEBUGLEVEL>=2) { fprintferr("\nStarting rayclassno computations\n"); flusherr(); } tetpil=avma; z=gerepile(av,tetpil,gcopy(z)); av1=avma; raylist=bigcgetvec(bound); for (i=1; i<=bound; i++) { sous=getcompobig(z,i); sousray=rayclassnointernarch(sous,clh,matarchunit); putcompobig(raylist,i,sousray); } } if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(r) = %ld ",avma-bot,taille2(raylist)); tetpil=avma; raylist=gerepile(av,tetpil,gcopy(raylist)); if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); msgtimer("zidealstarlist"); } /* maintenant on suit discrayabslist */ if (DEBUGLEVEL>=2) { fprintferr("Starting discrayabs computations\n"); flusherr(); } if (allarch) nbarch = 1<<r1; else { nbarch = 1; clhrayall = cgetg(2,t_VEC); discall = cgetg(2,t_VEC); faall = cgetg(2,t_VEC); Id = idmat(degk); } idealrelinit=cgetg(3,t_MAT); idealrelinit[1]=lgetg(1,t_COL); idealrelinit[2]=lgetg(1,t_COL); av1=avma; lim=stack_lim(av1,1); if (square) bound = sqbou-1; disclist=bigcgetvec(bound); for (ii=1; ii<=bound; ii++) putcompobig(disclist,ii,cgetg(1,t_VEC)); for (ii2=1; ii2<=bound; ii2++) { ii = square? ii2*ii2: ii2; if (DEBUGLEVEL>=2 && ii%100==0) { fprintferr("%ld ",ii); flusherr(); } sous=getcompobig(raylist,ii); ly=lg(sous); sousdisc=cgetg(ly,t_VEC); putcompobig(disclist, square? ii2: ii,sousdisc); for (jj=1; jj<ly; jj++) { bidsimp=(GEN)sous[jj]; fa=(GEN)bidsimp[1]; fac=gcopy(fa); fa2=(GEN)fa[1]; ex=(GEN)fa[2]; lfa2=lg(fa2); if (allarch) { clhrayall = (GEN)bidsimp[2]; discall=cgetg(nbarch+1,t_VEC); } else clhray = itos((GEN)bidsimp[2]); for (karch=0; karch<nbarch; karch++) { if (!allarch) ideal = Id; else { kka=karch; nba=0; for (jjj=1; jjj<=r1; jjj++) { if (kka%2) nba++; kka>>=1; } clhray=itos((GEN)clhrayall[karch+1]); for (k2=1,k=1; k<=r1; k++,k2<<=1) { if (karch&k2 && clhray==itos((GEN)clhrayall[karch-k2+1])) { clhray=0; goto LDISCRAY; } } } idealrel = idealrelinit; for (k=1; k<lfa2; k++) { fauxpr=(GEN)fa2[k]; ep=itos((GEN)ex[k]); ffs=itos(fauxpr); /* Hack for NeXTgcc 2.5.8 -- splitting "resp=fs%degk+1" */ fs=ffs/degk; resp=fs%degk; resp++; gprime=stoi((long)(fs/degk)); if (!allarch && nba) { p1=(GEN)primedec(nf,gprime)[ffs%degk+1]; ideal = idealmul(nf,ideal,idealpow(nf,p1,(GEN)ex[k])); } som=0; clhss=0; normp=gpuigs(gprime,resp); normps=itos(normp); normi=ii; normp=cgetg(3,t_MAT); no1=cgetg(2,t_COL); no1[1]=(long)gprime; normp[1]=(long)no1; no2=cgetg(2,t_COL); no2[1]=lstoi(resp); normp[2]=(long)no2; for (j=1; j<=ep; j++) { if (clhss==1) som++; else { if (j<ep) { coeff(fac,k,2)=lstoi(ep-j); fad=fac; } else { fad=cgetg(3,t_MAT); fad1=cgetg(lfa2-1,t_COL); fad[1]=(long)fad1; fad2=cgetg(lfa2-1,t_COL); fad[2]=(long)fad2; for (i=1; i<k; i++) { fad1[i]=coeff(fac,i,1); fad2[i]=coeff(fac,i,2); } for ( ; i<lfa2-1; i++) { fad1[i]=coeff(fac,i+1,1); fad2[i]=coeff(fac,i+1,2); } } normi /= normps; /* Hack for NeXTgcc 2.5.8 -- using dlk as temporary variable */ dlk=rayclassnolistessimp(getcompobig(raylist,normi),fad); if (allarch) dlk = (GEN)dlk[karch+1]; clhss = itos(dlk); if (j==1 && clhss==clhray) { clhray=0; coeff(fac,k,2)=ex[k]; goto LDISCRAY; } som += clhss; } } coeff(fac,k,2)=ex[k]; idealrel=factormul(idealrel,factorpow(normp,som)); } dlk=factordivexact(factorpow(factor(stoi(ii)),clhray),idealrel); if (!allarch && nba) { module[1]=(long)ideal; arch2=gcopy(arch); module[2]=(long)arch2; nbdezero=0; for (k=1; k<=r1; k++) { if (signe(arch[k])) { arch2[k]=zero; clhss=itos(rayclassno(bnf,module)); arch2[k]=un; if (clhss==clhray) { clhray=0; goto LDISCRAY; } } else nbdezero++; } } else nbdezero = r1-nba;LDISCRAY: p1=cgetg(4,t_VEC); discall[karch+1]=(long)p1; if (!clhray) p1[1]=p1[2]=p1[3]=zero; else { p3=factorpow(fadkabs,clhray); n=clhray*degk; R1=nbdezero*clhray; if (((n-R1)&3)==2) { normp=cgetg(3,t_MAT); no1=cgetg(2,t_COL); normp[1]=(long)no1; no1[1]=lstoi(-1); no2=cgetg(2,t_COL); normp[2]=(long)no2; no2[1]=un; dlk=factormul(normp,dlk); } p1[1]=lstoi(n); p1[2]=lstoi(R1); p1[3]=(long)factormul(dlk,p3); } } if (allarch) { p1 = cgetg(3,t_VEC); p1[1]=(long)fa; p1[2]=(long)discall; } else { faall[1]=(long)fa; p1 = concatsp(faall, p1); } sousdisc[jj]=(long)p1; if (low_stack(lim, stack_lim(av1,1))) { if(DEBUGMEM>1) err(warnmem,"[2]: discrayabslistarch"); if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(d) = %ld ",avma-bot,taille2(disclist)); tetpil=avma; disclist=gerepile(av1,tetpil,gcopy(disclist)); if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); flusherr(); } } } } if (DEBUGLEVEL>2) msgtimer("discrayabs"); tdi=taille2(disclist); if (DEBUGLEVEL>2) { fprintferr("avma = %ld, t(d) = %ld ",avma-bot,tdi); flusherr(); } if (tdi<avma-bot) { tetpil=avma; disclist=gerepile(av0,tetpil,gcopy(disclist)); if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); flusherr(); } } return disclist;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/9749d3e46caef3f61b412b608c8ac51b8f010460/buch3.c/buggy/src/basemath/buch3.c |
if (i==q || | if (q == (ulong)i || | discrayabslistarchintern(GEN bnf, GEN arch, long bound, long ramip){ byteptr ptdif=diffptr; long degk,lim,av0,av,av1,tetpil,i,j,k,p2s,lfa,lp1,sqbou,cex, allarch; long ffs,fs,resp,flbou,tdi,nba, k2,karch,kka,nbarch,jjj,jj,square; long ii2,ii,ly,clhray,lfa2,ep,som,clhss,normps,normi,nbdezero,r1,R1,n,c; ulong q; GEN nf,p,z,pol,p1,p2,p3,fa,pr,normp,ideal,bidp,z2,matarchunit; GEN bigres,funits,racunit,embunit,sous,clh,sousray,raylist; GEN clhrayall,discall,faall,Id,idealrel,idealrelinit; GEN sousdisc,module,fa2,ex,fac,no1,no2,fad,fad1,fad2,fadkabs,pz; GEN arch2,dlk,disclist,bidsimp,p4,faussefa,pex,fauxpr,gprime; GEN *gptr[2]; clhray = nbdezero = 0; /* gcc -Wall */ module = Id = dlk = ideal = clhrayall = discall = faall = NULL; /* ce qui suit recopie d'assez pres ideallistzstarall */ if (DEBUGLEVEL>2) timer2(); if (bound <= 0) err(talker,"non-positive bound in discrayabslist"); av0=avma; bnf = checkbnf(bnf); flbou=0; nf=(GEN)bnf[7]; bigres=(GEN)bnf[8]; pol=(GEN)nf[1]; degk=lgef(pol)-3; r1 = nf_get_r1(nf); fadkabs=factor(absi((GEN)nf[3])); clh=gmael(bigres,1,1); funits = check_units(bnf,"discrayabslistarchintern"); racunit=gmael(bigres,4,2); if (ramip >= 0) square = 0; else { square = 1; ramip = -ramip; if (ramip==1) ramip=0; } nba = 0; allarch = (arch==NULL); if (allarch) { arch=cgetg(r1+1,t_VEC); for (i=1; i<=r1; i++) arch[i]=un; nba=r1; } else if (gcmp0(arch)) { arch=cgetg(r1+1,t_VEC); for (i=1; i<=r1; i++) arch[i]=zero; } else { if (lg(arch)!=r1+1) err(talker,"incorrect archimedean argument in discrayabslistlong"); for (i=1; i<=r1; i++) if (signe(arch[i])) nba++; if (nba) module=cgetg(3,t_VEC); } p1=cgetg(3,t_VEC); p1[1]=(long)idmat(degk); p1[2]=(long)arch; bidp=zidealstarinitall(nf,p1,0); matarchunit = allarch? logunitmatrix(nf,funits,racunit,bidp): (GEN)NULL; p=cgeti(3); p[1]=evalsigne(1)|evallgef(3); sqbou=itos(racine(stoi(bound)))+1; av=avma; lim=stack_lim(av,1); z=bigcgetvec(bound); for (i=2; i<=bound; i++) putcompobig(z,i,cgetg(1,t_VEC)); if (allarch) bidp=zidealstarinitall(nf,idmat(degk),0); embunit=logunitmatrix(nf,funits,racunit,bidp); p1=cgetg(2,t_VEC); putcompobig(z,1,p1); p1[1]=(long)zsimp(bidp,embunit); if (DEBUGLEVEL>=2) fprintferr("Starting zidealstarunits computations\n"); for (p[2]=0; p[2]<=bound; ) { if (!*ptdif) err(primer1); p[2] += *ptdif++; if (!flbou && p[2]>sqbou) { flbou=1; if (DEBUGLEVEL>=2) { fprintferr("\nStarting rayclassno computations\n"); flusherr(); } tetpil=avma; z=gerepile(av,tetpil,gcopy(z)); av1=avma; raylist=bigcgetvec(bound); /* maintenant on suit rayclassnolist */ for (i=1; i<=bound; i++) { sous=getcompobig(z,i); sousray=rayclassnointernarch(sous,clh,matarchunit); putcompobig(raylist,i,sousray); } tetpil=avma; raylist=gerepile(av1,tetpil,gcopy(raylist)); z2=bigcgetvec(sqbou); for (i=1; i<=sqbou; i++) { p1=gcopy(getcompobig(z,i)); putcompobig(z2,i,p1); } z = z2; } fa=primedec(nf,p); lfa=lg(fa)-1; for (j=1; j<=lfa; j++) { pr=(GEN)fa[j]; normp=powgi(p,(GEN)pr[4]); cex=0; if (DEBUGLEVEL>=2) { fprintferr("%ld ",p[2]); flusherr(); } if (gcmpgs(normp,bound)<=0) { fauxpr=stoi(p[2]*degk*degk+(itos((GEN)pr[4])-1)*degk+j-1); q=p2s=itos(normp); ideal=pr; while (q <= (ulong)bound) { bidp=zidealstarinitall(nf,ideal,0); faussefa=cgetg(3,t_MAT); p1=cgetg(2,t_COL); faussefa[1]=(long)p1; p1[1]=(long)fauxpr; pex=cgetg(2,t_COL); faussefa[2]=(long)pex; cex++; pex[1]=lstoi(cex); embunit=logunitmatrix(nf,funits,racunit,bidp); for (i=q; i<=bound; i+=q) { p1=getcompobig(z,i/q); lp1=lg(p1); if (lp1>1) { p2=cgetg(lp1,t_VEC); c=0; for (k=1; k<lp1; k++) { p3=(GEN)p1[k]; if (i==q || ((p4=gmael(p3,1,1)) && !isinvector(p4,fauxpr,lg(p4)-1))) { c++; p2[c]=(long)zsimpjoin(p3,bidp,faussefa,embunit); } } setlg(p2,c+1); if (c) { if (p[2]<=sqbou) { pz=getcompobig(z,i); if (lg(pz)>1) putcompobig(z,i,concatsp(pz,p2)); else putcompobig(z,i,p2); } else { sousray=rayclassnointernarch(p2,clh,matarchunit); pz=getcompobig(raylist,i); if (lg(pz)>1) putcompobig(raylist,i,concatsp(pz,sousray)); else putcompobig(raylist,i,sousray); } } } } if (ramip && ramip % p[2]) q=bound+1; else { pz=mulss(q,p2s); q=(gcmpgs(pz,bound)>0)?bound+1:pz[2]; if (q <= (ulong)bound) ideal=idealmul(nf,ideal,pr); } } } } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[1]: discrayabslistarch"); if (!flbou) { if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(z) = %ld ",avma-bot,taille2(z)); tetpil=avma; z=gerepile(av,tetpil,gcopy(z)); } else { if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(r) = %ld ",avma-bot,taille2(raylist)); gptr[0]=&z; gptr[1]=&raylist; gerepilemany(av,gptr,2); } if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); flusherr(); } } } if (!flbou) /* maintenant on suit rayclassnolist */ { if (DEBUGLEVEL>=2) { fprintferr("\nStarting rayclassno computations\n"); flusherr(); } tetpil=avma; z=gerepile(av,tetpil,gcopy(z)); av1=avma; raylist=bigcgetvec(bound); for (i=1; i<=bound; i++) { sous=getcompobig(z,i); sousray=rayclassnointernarch(sous,clh,matarchunit); putcompobig(raylist,i,sousray); } } if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(r) = %ld ",avma-bot,taille2(raylist)); tetpil=avma; raylist=gerepile(av,tetpil,gcopy(raylist)); if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); msgtimer("zidealstarlist"); } /* maintenant on suit discrayabslist */ if (DEBUGLEVEL>=2) { fprintferr("Starting discrayabs computations\n"); flusherr(); } if (allarch) nbarch = 1<<r1; else { nbarch = 1; clhrayall = cgetg(2,t_VEC); discall = cgetg(2,t_VEC); faall = cgetg(2,t_VEC); Id = idmat(degk); } idealrelinit=cgetg(3,t_MAT); idealrelinit[1]=lgetg(1,t_COL); idealrelinit[2]=lgetg(1,t_COL); av1=avma; lim=stack_lim(av1,1); if (square) bound = sqbou-1; disclist=bigcgetvec(bound); for (ii=1; ii<=bound; ii++) putcompobig(disclist,ii,cgetg(1,t_VEC)); for (ii2=1; ii2<=bound; ii2++) { ii = square? ii2*ii2: ii2; if (DEBUGLEVEL>=2 && ii%100==0) { fprintferr("%ld ",ii); flusherr(); } sous=getcompobig(raylist,ii); ly=lg(sous); sousdisc=cgetg(ly,t_VEC); putcompobig(disclist, square? ii2: ii,sousdisc); for (jj=1; jj<ly; jj++) { bidsimp=(GEN)sous[jj]; fa=(GEN)bidsimp[1]; fac=gcopy(fa); fa2=(GEN)fa[1]; ex=(GEN)fa[2]; lfa2=lg(fa2); if (allarch) { clhrayall = (GEN)bidsimp[2]; discall=cgetg(nbarch+1,t_VEC); } else clhray = itos((GEN)bidsimp[2]); for (karch=0; karch<nbarch; karch++) { if (!allarch) ideal = Id; else { kka=karch; nba=0; for (jjj=1; jjj<=r1; jjj++) { if (kka%2) nba++; kka>>=1; } clhray=itos((GEN)clhrayall[karch+1]); for (k2=1,k=1; k<=r1; k++,k2<<=1) { if (karch&k2 && clhray==itos((GEN)clhrayall[karch-k2+1])) { clhray=0; goto LDISCRAY; } } } idealrel = idealrelinit; for (k=1; k<lfa2; k++) { fauxpr=(GEN)fa2[k]; ep=itos((GEN)ex[k]); ffs=itos(fauxpr); /* Hack for NeXTgcc 2.5.8 -- splitting "resp=fs%degk+1" */ fs=ffs/degk; resp=fs%degk; resp++; gprime=stoi((long)(fs/degk)); if (!allarch && nba) { p1=(GEN)primedec(nf,gprime)[ffs%degk+1]; ideal = idealmul(nf,ideal,idealpow(nf,p1,(GEN)ex[k])); } som=0; clhss=0; normp=gpuigs(gprime,resp); normps=itos(normp); normi=ii; normp=cgetg(3,t_MAT); no1=cgetg(2,t_COL); no1[1]=(long)gprime; normp[1]=(long)no1; no2=cgetg(2,t_COL); no2[1]=lstoi(resp); normp[2]=(long)no2; for (j=1; j<=ep; j++) { if (clhss==1) som++; else { if (j<ep) { coeff(fac,k,2)=lstoi(ep-j); fad=fac; } else { fad=cgetg(3,t_MAT); fad1=cgetg(lfa2-1,t_COL); fad[1]=(long)fad1; fad2=cgetg(lfa2-1,t_COL); fad[2]=(long)fad2; for (i=1; i<k; i++) { fad1[i]=coeff(fac,i,1); fad2[i]=coeff(fac,i,2); } for ( ; i<lfa2-1; i++) { fad1[i]=coeff(fac,i+1,1); fad2[i]=coeff(fac,i+1,2); } } normi /= normps; /* Hack for NeXTgcc 2.5.8 -- using dlk as temporary variable */ dlk=rayclassnolistessimp(getcompobig(raylist,normi),fad); if (allarch) dlk = (GEN)dlk[karch+1]; clhss = itos(dlk); if (j==1 && clhss==clhray) { clhray=0; coeff(fac,k,2)=ex[k]; goto LDISCRAY; } som += clhss; } } coeff(fac,k,2)=ex[k]; idealrel=factormul(idealrel,factorpow(normp,som)); } dlk=factordivexact(factorpow(factor(stoi(ii)),clhray),idealrel); if (!allarch && nba) { module[1]=(long)ideal; arch2=gcopy(arch); module[2]=(long)arch2; nbdezero=0; for (k=1; k<=r1; k++) { if (signe(arch[k])) { arch2[k]=zero; clhss=itos(rayclassno(bnf,module)); arch2[k]=un; if (clhss==clhray) { clhray=0; goto LDISCRAY; } } else nbdezero++; } } else nbdezero = r1-nba;LDISCRAY: p1=cgetg(4,t_VEC); discall[karch+1]=(long)p1; if (!clhray) p1[1]=p1[2]=p1[3]=zero; else { p3=factorpow(fadkabs,clhray); n=clhray*degk; R1=nbdezero*clhray; if (((n-R1)&3)==2) { normp=cgetg(3,t_MAT); no1=cgetg(2,t_COL); normp[1]=(long)no1; no1[1]=lstoi(-1); no2=cgetg(2,t_COL); normp[2]=(long)no2; no2[1]=un; dlk=factormul(normp,dlk); } p1[1]=lstoi(n); p1[2]=lstoi(R1); p1[3]=(long)factormul(dlk,p3); } } if (allarch) { p1 = cgetg(3,t_VEC); p1[1]=(long)fa; p1[2]=(long)discall; } else { faall[1]=(long)fa; p1 = concatsp(faall, p1); } sousdisc[jj]=(long)p1; if (low_stack(lim, stack_lim(av1,1))) { if(DEBUGMEM>1) err(warnmem,"[2]: discrayabslistarch"); if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(d) = %ld ",avma-bot,taille2(disclist)); tetpil=avma; disclist=gerepile(av1,tetpil,gcopy(disclist)); if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); flusherr(); } } } } if (DEBUGLEVEL>2) msgtimer("discrayabs"); tdi=taille2(disclist); if (DEBUGLEVEL>2) { fprintferr("avma = %ld, t(d) = %ld ",avma-bot,tdi); flusherr(); } if (tdi<avma-bot) { tetpil=avma; disclist=gerepile(av0,tetpil,gcopy(disclist)); if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); flusherr(); } } return disclist;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/9749d3e46caef3f61b412b608c8ac51b8f010460/buch3.c/buggy/src/basemath/buch3.c |
tdi=taille2(disclist); if (DEBUGLEVEL>2) { fprintferr("avma = %ld, t(d) = %ld ",avma-bot,tdi); flusherr(); } if (tdi<avma-bot) { tetpil=avma; disclist=gerepile(av0,tetpil,gcopy(disclist)); if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); flusherr(); } } return disclist; | tetpil=avma; return gerepile(av0,tetpil,gcopy(disclist)); | discrayabslistarchintern(GEN bnf, GEN arch, long bound, long ramip){ byteptr ptdif=diffptr; long degk,lim,av0,av,av1,tetpil,i,j,k,p2s,lfa,lp1,sqbou,cex, allarch; long ffs,fs,resp,flbou,tdi,nba, k2,karch,kka,nbarch,jjj,jj,square; long ii2,ii,ly,clhray,lfa2,ep,som,clhss,normps,normi,nbdezero,r1,R1,n,c; ulong q; GEN nf,p,z,pol,p1,p2,p3,fa,pr,normp,ideal,bidp,z2,matarchunit; GEN bigres,funits,racunit,embunit,sous,clh,sousray,raylist; GEN clhrayall,discall,faall,Id,idealrel,idealrelinit; GEN sousdisc,module,fa2,ex,fac,no1,no2,fad,fad1,fad2,fadkabs,pz; GEN arch2,dlk,disclist,bidsimp,p4,faussefa,pex,fauxpr,gprime; GEN *gptr[2]; clhray = nbdezero = 0; /* gcc -Wall */ module = Id = dlk = ideal = clhrayall = discall = faall = NULL; /* ce qui suit recopie d'assez pres ideallistzstarall */ if (DEBUGLEVEL>2) timer2(); if (bound <= 0) err(talker,"non-positive bound in discrayabslist"); av0=avma; bnf = checkbnf(bnf); flbou=0; nf=(GEN)bnf[7]; bigres=(GEN)bnf[8]; pol=(GEN)nf[1]; degk=lgef(pol)-3; r1 = nf_get_r1(nf); fadkabs=factor(absi((GEN)nf[3])); clh=gmael(bigres,1,1); funits = check_units(bnf,"discrayabslistarchintern"); racunit=gmael(bigres,4,2); if (ramip >= 0) square = 0; else { square = 1; ramip = -ramip; if (ramip==1) ramip=0; } nba = 0; allarch = (arch==NULL); if (allarch) { arch=cgetg(r1+1,t_VEC); for (i=1; i<=r1; i++) arch[i]=un; nba=r1; } else if (gcmp0(arch)) { arch=cgetg(r1+1,t_VEC); for (i=1; i<=r1; i++) arch[i]=zero; } else { if (lg(arch)!=r1+1) err(talker,"incorrect archimedean argument in discrayabslistlong"); for (i=1; i<=r1; i++) if (signe(arch[i])) nba++; if (nba) module=cgetg(3,t_VEC); } p1=cgetg(3,t_VEC); p1[1]=(long)idmat(degk); p1[2]=(long)arch; bidp=zidealstarinitall(nf,p1,0); matarchunit = allarch? logunitmatrix(nf,funits,racunit,bidp): (GEN)NULL; p=cgeti(3); p[1]=evalsigne(1)|evallgef(3); sqbou=itos(racine(stoi(bound)))+1; av=avma; lim=stack_lim(av,1); z=bigcgetvec(bound); for (i=2; i<=bound; i++) putcompobig(z,i,cgetg(1,t_VEC)); if (allarch) bidp=zidealstarinitall(nf,idmat(degk),0); embunit=logunitmatrix(nf,funits,racunit,bidp); p1=cgetg(2,t_VEC); putcompobig(z,1,p1); p1[1]=(long)zsimp(bidp,embunit); if (DEBUGLEVEL>=2) fprintferr("Starting zidealstarunits computations\n"); for (p[2]=0; p[2]<=bound; ) { if (!*ptdif) err(primer1); p[2] += *ptdif++; if (!flbou && p[2]>sqbou) { flbou=1; if (DEBUGLEVEL>=2) { fprintferr("\nStarting rayclassno computations\n"); flusherr(); } tetpil=avma; z=gerepile(av,tetpil,gcopy(z)); av1=avma; raylist=bigcgetvec(bound); /* maintenant on suit rayclassnolist */ for (i=1; i<=bound; i++) { sous=getcompobig(z,i); sousray=rayclassnointernarch(sous,clh,matarchunit); putcompobig(raylist,i,sousray); } tetpil=avma; raylist=gerepile(av1,tetpil,gcopy(raylist)); z2=bigcgetvec(sqbou); for (i=1; i<=sqbou; i++) { p1=gcopy(getcompobig(z,i)); putcompobig(z2,i,p1); } z = z2; } fa=primedec(nf,p); lfa=lg(fa)-1; for (j=1; j<=lfa; j++) { pr=(GEN)fa[j]; normp=powgi(p,(GEN)pr[4]); cex=0; if (DEBUGLEVEL>=2) { fprintferr("%ld ",p[2]); flusherr(); } if (gcmpgs(normp,bound)<=0) { fauxpr=stoi(p[2]*degk*degk+(itos((GEN)pr[4])-1)*degk+j-1); q=p2s=itos(normp); ideal=pr; while (q <= (ulong)bound) { bidp=zidealstarinitall(nf,ideal,0); faussefa=cgetg(3,t_MAT); p1=cgetg(2,t_COL); faussefa[1]=(long)p1; p1[1]=(long)fauxpr; pex=cgetg(2,t_COL); faussefa[2]=(long)pex; cex++; pex[1]=lstoi(cex); embunit=logunitmatrix(nf,funits,racunit,bidp); for (i=q; i<=bound; i+=q) { p1=getcompobig(z,i/q); lp1=lg(p1); if (lp1>1) { p2=cgetg(lp1,t_VEC); c=0; for (k=1; k<lp1; k++) { p3=(GEN)p1[k]; if (i==q || ((p4=gmael(p3,1,1)) && !isinvector(p4,fauxpr,lg(p4)-1))) { c++; p2[c]=(long)zsimpjoin(p3,bidp,faussefa,embunit); } } setlg(p2,c+1); if (c) { if (p[2]<=sqbou) { pz=getcompobig(z,i); if (lg(pz)>1) putcompobig(z,i,concatsp(pz,p2)); else putcompobig(z,i,p2); } else { sousray=rayclassnointernarch(p2,clh,matarchunit); pz=getcompobig(raylist,i); if (lg(pz)>1) putcompobig(raylist,i,concatsp(pz,sousray)); else putcompobig(raylist,i,sousray); } } } } if (ramip && ramip % p[2]) q=bound+1; else { pz=mulss(q,p2s); q=(gcmpgs(pz,bound)>0)?bound+1:pz[2]; if (q <= (ulong)bound) ideal=idealmul(nf,ideal,pr); } } } } if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[1]: discrayabslistarch"); if (!flbou) { if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(z) = %ld ",avma-bot,taille2(z)); tetpil=avma; z=gerepile(av,tetpil,gcopy(z)); } else { if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(r) = %ld ",avma-bot,taille2(raylist)); gptr[0]=&z; gptr[1]=&raylist; gerepilemany(av,gptr,2); } if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); flusherr(); } } } if (!flbou) /* maintenant on suit rayclassnolist */ { if (DEBUGLEVEL>=2) { fprintferr("\nStarting rayclassno computations\n"); flusherr(); } tetpil=avma; z=gerepile(av,tetpil,gcopy(z)); av1=avma; raylist=bigcgetvec(bound); for (i=1; i<=bound; i++) { sous=getcompobig(z,i); sousray=rayclassnointernarch(sous,clh,matarchunit); putcompobig(raylist,i,sousray); } } if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(r) = %ld ",avma-bot,taille2(raylist)); tetpil=avma; raylist=gerepile(av,tetpil,gcopy(raylist)); if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); msgtimer("zidealstarlist"); } /* maintenant on suit discrayabslist */ if (DEBUGLEVEL>=2) { fprintferr("Starting discrayabs computations\n"); flusherr(); } if (allarch) nbarch = 1<<r1; else { nbarch = 1; clhrayall = cgetg(2,t_VEC); discall = cgetg(2,t_VEC); faall = cgetg(2,t_VEC); Id = idmat(degk); } idealrelinit=cgetg(3,t_MAT); idealrelinit[1]=lgetg(1,t_COL); idealrelinit[2]=lgetg(1,t_COL); av1=avma; lim=stack_lim(av1,1); if (square) bound = sqbou-1; disclist=bigcgetvec(bound); for (ii=1; ii<=bound; ii++) putcompobig(disclist,ii,cgetg(1,t_VEC)); for (ii2=1; ii2<=bound; ii2++) { ii = square? ii2*ii2: ii2; if (DEBUGLEVEL>=2 && ii%100==0) { fprintferr("%ld ",ii); flusherr(); } sous=getcompobig(raylist,ii); ly=lg(sous); sousdisc=cgetg(ly,t_VEC); putcompobig(disclist, square? ii2: ii,sousdisc); for (jj=1; jj<ly; jj++) { bidsimp=(GEN)sous[jj]; fa=(GEN)bidsimp[1]; fac=gcopy(fa); fa2=(GEN)fa[1]; ex=(GEN)fa[2]; lfa2=lg(fa2); if (allarch) { clhrayall = (GEN)bidsimp[2]; discall=cgetg(nbarch+1,t_VEC); } else clhray = itos((GEN)bidsimp[2]); for (karch=0; karch<nbarch; karch++) { if (!allarch) ideal = Id; else { kka=karch; nba=0; for (jjj=1; jjj<=r1; jjj++) { if (kka%2) nba++; kka>>=1; } clhray=itos((GEN)clhrayall[karch+1]); for (k2=1,k=1; k<=r1; k++,k2<<=1) { if (karch&k2 && clhray==itos((GEN)clhrayall[karch-k2+1])) { clhray=0; goto LDISCRAY; } } } idealrel = idealrelinit; for (k=1; k<lfa2; k++) { fauxpr=(GEN)fa2[k]; ep=itos((GEN)ex[k]); ffs=itos(fauxpr); /* Hack for NeXTgcc 2.5.8 -- splitting "resp=fs%degk+1" */ fs=ffs/degk; resp=fs%degk; resp++; gprime=stoi((long)(fs/degk)); if (!allarch && nba) { p1=(GEN)primedec(nf,gprime)[ffs%degk+1]; ideal = idealmul(nf,ideal,idealpow(nf,p1,(GEN)ex[k])); } som=0; clhss=0; normp=gpuigs(gprime,resp); normps=itos(normp); normi=ii; normp=cgetg(3,t_MAT); no1=cgetg(2,t_COL); no1[1]=(long)gprime; normp[1]=(long)no1; no2=cgetg(2,t_COL); no2[1]=lstoi(resp); normp[2]=(long)no2; for (j=1; j<=ep; j++) { if (clhss==1) som++; else { if (j<ep) { coeff(fac,k,2)=lstoi(ep-j); fad=fac; } else { fad=cgetg(3,t_MAT); fad1=cgetg(lfa2-1,t_COL); fad[1]=(long)fad1; fad2=cgetg(lfa2-1,t_COL); fad[2]=(long)fad2; for (i=1; i<k; i++) { fad1[i]=coeff(fac,i,1); fad2[i]=coeff(fac,i,2); } for ( ; i<lfa2-1; i++) { fad1[i]=coeff(fac,i+1,1); fad2[i]=coeff(fac,i+1,2); } } normi /= normps; /* Hack for NeXTgcc 2.5.8 -- using dlk as temporary variable */ dlk=rayclassnolistessimp(getcompobig(raylist,normi),fad); if (allarch) dlk = (GEN)dlk[karch+1]; clhss = itos(dlk); if (j==1 && clhss==clhray) { clhray=0; coeff(fac,k,2)=ex[k]; goto LDISCRAY; } som += clhss; } } coeff(fac,k,2)=ex[k]; idealrel=factormul(idealrel,factorpow(normp,som)); } dlk=factordivexact(factorpow(factor(stoi(ii)),clhray),idealrel); if (!allarch && nba) { module[1]=(long)ideal; arch2=gcopy(arch); module[2]=(long)arch2; nbdezero=0; for (k=1; k<=r1; k++) { if (signe(arch[k])) { arch2[k]=zero; clhss=itos(rayclassno(bnf,module)); arch2[k]=un; if (clhss==clhray) { clhray=0; goto LDISCRAY; } } else nbdezero++; } } else nbdezero = r1-nba;LDISCRAY: p1=cgetg(4,t_VEC); discall[karch+1]=(long)p1; if (!clhray) p1[1]=p1[2]=p1[3]=zero; else { p3=factorpow(fadkabs,clhray); n=clhray*degk; R1=nbdezero*clhray; if (((n-R1)&3)==2) { normp=cgetg(3,t_MAT); no1=cgetg(2,t_COL); normp[1]=(long)no1; no1[1]=lstoi(-1); no2=cgetg(2,t_COL); normp[2]=(long)no2; no2[1]=un; dlk=factormul(normp,dlk); } p1[1]=lstoi(n); p1[2]=lstoi(R1); p1[3]=(long)factormul(dlk,p3); } } if (allarch) { p1 = cgetg(3,t_VEC); p1[1]=(long)fa; p1[2]=(long)discall; } else { faall[1]=(long)fa; p1 = concatsp(faall, p1); } sousdisc[jj]=(long)p1; if (low_stack(lim, stack_lim(av1,1))) { if(DEBUGMEM>1) err(warnmem,"[2]: discrayabslistarch"); if (DEBUGLEVEL>2) fprintferr("avma = %ld, t(d) = %ld ",avma-bot,taille2(disclist)); tetpil=avma; disclist=gerepile(av1,tetpil,gcopy(disclist)); if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); flusherr(); } } } } if (DEBUGLEVEL>2) msgtimer("discrayabs"); tdi=taille2(disclist); if (DEBUGLEVEL>2) { fprintferr("avma = %ld, t(d) = %ld ",avma-bot,tdi); flusherr(); } if (tdi<avma-bot) { tetpil=avma; disclist=gerepile(av0,tetpil,gcopy(disclist)); if (DEBUGLEVEL>2) { fprintferr("avma = %ld ",avma-bot); flusherr(); } } return disclist;} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/9749d3e46caef3f61b412b608c8ac51b8f010460/buch3.c/buggy/src/basemath/buch3.c |
#if 0 printf( "write %d in %d: %*s\n", to_copy, block, to_copy, src ); #endif | MEMFILE_STATIC int IMFS_memfile_write( IMFS_jnode_t *the_jnode, off_t start, const unsigned char *source, unsigned int length){ block_p *block_ptr; unsigned int block; int status; unsigned int my_length; unsigned int to_copy = 0; unsigned int last_byte; unsigned int start_offset; int copied; const unsigned char *src; src = source; /* * Perform internal consistency checks */ assert( the_jnode ); if ( !the_jnode ) set_errno_and_return_minus_one( EIO ); assert( the_jnode->type == IMFS_MEMORY_FILE ); if ( the_jnode->type != IMFS_MEMORY_FILE ) set_errno_and_return_minus_one( EIO ); /* * Error check arguments */ assert( source ); if ( !source ) set_errno_and_return_minus_one( EINVAL ); /* * If there is nothing to write, then quick exit. */ my_length = length; if ( !my_length ) set_errno_and_return_minus_one( EINVAL ); /* * If the last byte we are supposed to write is past the end of this * in memory file, then extend the length. */ last_byte = start + length; if ( last_byte > the_jnode->info.file.size ) { status = IMFS_memfile_extend( the_jnode, last_byte ); if ( status ) set_errno_and_return_minus_one( ENOSPC ); } copied = 0; /* * Three phases to the write: * + possibly the last part of one block * + all of zero of more blocks * + possibly the first part of one block */ /* * Phase 1: possibly the last part of one block */ start_offset = start % IMFS_MEMFILE_BYTES_PER_BLOCK; block = start / IMFS_MEMFILE_BYTES_PER_BLOCK; if ( start_offset ) { to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK - start_offset; if ( to_copy > my_length ) to_copy = my_length; block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 ); assert( block_ptr ); if ( !block_ptr ) return copied; memcpy( &(*block_ptr)[ start_offset ], src, to_copy ); src += to_copy; block++; my_length -= to_copy; copied += to_copy; } /* * Phase 2: all of zero of more blocks */ to_copy = IMFS_MEMFILE_BYTES_PER_BLOCK; while ( my_length >= IMFS_MEMFILE_BYTES_PER_BLOCK ) { block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 ); assert( block_ptr ); if ( !block_ptr ) return copied; memcpy( &(*block_ptr)[ 0 ], src, to_copy ); src += to_copy; block++; my_length -= to_copy; copied += to_copy; } /* * Phase 3: possibly the first part of one block */ assert( my_length < IMFS_MEMFILE_BYTES_PER_BLOCK ); to_copy = my_length; if ( my_length ) { block_ptr = IMFS_memfile_get_block_pointer( the_jnode, block, 0 ); assert( block_ptr ); if ( !block_ptr ) return copied; memcpy( &(*block_ptr)[ 0 ], src, my_length ); my_length = 0; copied += to_copy; } IMFS_atime_mtime_update( the_jnode ); return copied;} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/b10f6e12e00caba93e56976cdef7b6326bc3af3e/memfile.c/clean/c/src/libfs/src/imfs/memfile.c |
|
dhcp_hostname = NULL; | if (dhcp_hostname != NULL) { /* free it */ dhcp_hostname=bootp_strdup_realloc(dhcp_hostname,0); } | bootpc_init(int update_files){ struct bootp_packet call; struct bootp_packet reply; static u_int32_t xid = ~0xFF; struct ifreq ireq; struct ifnet *ifp; struct socket *so; int j; int error; struct sockaddr_in myaddr; struct ifaddr *ifa; struct sockaddr_dl *sdl = NULL; char *delim; struct proc *procp = NULL; /* * If already filled in, don't touch it here */ if (nfs_diskless_valid) return; /* * If we are to update the files create the root * file structure. */ if (update_files) if (rtems_create_root_fs () < 0) { printf("Error creating the root filesystem.\nFile not created.\n"); update_files = 0; } dhcp_hostname = NULL; /* * Find a network interface. */ for (ifp = ifnet; ifp != 0; ifp = ifp->if_next) if ((ifp->if_flags & (IFF_LOOPBACK|IFF_POINTOPOINT)) == 0) break; if (ifp == NULL) panic("bootpc_init: no suitable interface"); bzero(&ireq,sizeof(ireq)); sprintf(ireq.ifr_name, "%s%d", ifp->if_name,ifp->if_unit); printf("bootpc_init: using network interface '%s'\n", ireq.ifr_name); if ((error = socreate(AF_INET, &so, SOCK_DGRAM, 0,procp)) != 0) panic("nfs_boot: socreate, error=%d", error); bootpc_fakeup_interface(&ireq,so,procp); printf("Bootpc testing starting\n"); /* Get HW address */ for (ifa = ifp->if_addrlist;ifa; ifa = ifa->ifa_next) if (ifa->ifa_addr->sa_family == AF_LINK && (sdl = ((struct sockaddr_dl *) ifa->ifa_addr)) && sdl->sdl_type == IFT_ETHER) break; if (!sdl) panic("bootpc: Unable to find HW address"); if (sdl->sdl_alen != EALEN ) panic("bootpc: HW address len is %d, expected value is %d", sdl->sdl_alen,EALEN); printf("bootpc hw address is "); delim=""; for (j=0;j<sdl->sdl_alen;j++) { printf("%s%x",delim,((unsigned char *)LLADDR(sdl))[j]); delim=":"; } printf("\n");#if 0 bootpboot_p_iflist(); bootpboot_p_rtlist();#endif bzero((caddr_t) &call, sizeof(call)); /* bootpc part */ call.op = 1; /* BOOTREQUEST */ call.htype= 1; /* 10mb ethernet */ call.hlen=sdl->sdl_alen; /* Hardware address length */ call.hops=0; xid++; call.xid = txdr_unsigned(xid); bcopy(LLADDR(sdl),&call.chaddr,sdl->sdl_alen); call.vend[0]=99; call.vend[1]=130; call.vend[2]=83; call.vend[3]=99; call.vend[4]=255; call.secs = 0; call.flags = htons(0x8000); /* We need an broadcast answer */ error = bootpc_call(&call,&reply,procp); if (error) panic("BOOTP call failed -- error %d", error); /* * Initialize network address structures */ bzero(&myaddr,sizeof(myaddr)); bzero(&dhcp_netmask,sizeof(dhcp_netmask)); bzero(&dhcp_gw,sizeof(dhcp_gw)); myaddr.sin_len = sizeof(myaddr); myaddr.sin_family = AF_INET; dhcp_netmask.sin_len = sizeof(dhcp_netmask); dhcp_netmask.sin_family = AF_INET; dhcp_gw.sin_len = sizeof(dhcp_gw); dhcp_gw.sin_family= AF_INET; /* * Set our address */ myaddr.sin_addr = reply.yiaddr; printip("My ip address",myaddr.sin_addr); /* * Process BOOTP/DHCP options */ if (reply.vend[0]==99 && reply.vend[1]==130 && reply.vend[2]==83 && reply.vend[3]==99) { processOptions (&reply.vend[4], sizeof(reply.vend) - 4); } if (dhcpOptionOverload & 1) { processOptions (reply.file, sizeof reply.file); } else { if (reply.file[0]) rtems_bsdnet_bootp_boot_file_name = bootp_strdup_realloc(rtems_bsdnet_bootp_boot_file_name,reply.file); } if (dhcpOptionOverload & 2) { processOptions (reply.sname, sizeof reply.sname); } else { if (reply.sname[0]) rtems_bsdnet_bootp_server_name = bootp_strdup_realloc(rtems_bsdnet_bootp_server_name,reply.sname); } if (rtems_bsdnet_bootp_server_name) printf ("Server name is %s\n", rtems_bsdnet_bootp_server_name); if (rtems_bsdnet_bootp_boot_file_name) printf ("Boot file is %s\n", rtems_bsdnet_bootp_boot_file_name); if (rtems_bsdnet_bootp_cmdline) printf ("Command line is %s\n", rtems_bsdnet_bootp_cmdline); /* * Use defaults if values were not supplied by BOOTP/DHCP options */ if (!dhcp_gotnetmask) { if (IN_CLASSA(ntohl(myaddr.sin_addr.s_addr))) dhcp_netmask.sin_addr.s_addr = htonl(IN_CLASSA_NET); else if (IN_CLASSB(ntohl(myaddr.sin_addr.s_addr))) dhcp_netmask.sin_addr.s_addr = htonl(IN_CLASSB_NET); else dhcp_netmask.sin_addr.s_addr = htonl(IN_CLASSC_NET); } printip ("Subnet mask", dhcp_netmask.sin_addr); if (!dhcp_gotserver) rtems_bsdnet_bootp_server_address = reply.siaddr; printip ("Server ip address" ,rtems_bsdnet_bootp_server_address); if (!dhcp_gotgw) dhcp_gw.sin_addr = reply.giaddr; printip ("Gateway ip address", dhcp_gw.sin_addr); if (!dhcp_gotlogserver) rtems_bsdnet_log_host_address = rtems_bsdnet_bootp_server_address; printip ("Log server ip address", rtems_bsdnet_log_host_address); /* * Update the files if we are asked too. */ if (update_files) { char *dn = rtems_bsdnet_domain_name; char *hn = dhcp_hostname; if (!dn) dn = "mydomain"; if (!hn) hn = "me"; rtems_rootfs_append_host_rec(*((unsigned long*) &myaddr.sin_addr), hn, dn); /* * Should the given domainname be used here ? */ if (dhcp_gotserver) { if (rtems_bsdnet_bootp_server_name) hn = rtems_bsdnet_bootp_server_name; else hn = "bootps"; rtems_rootfs_append_host_rec(*((unsigned long *) &rtems_bsdnet_bootp_server_address), hn, dn); } if (dhcp_gotlogserver) { rtems_rootfs_append_host_rec(*((unsigned long *) &rtems_bsdnet_log_host_address), "logs", dn); } /* * Setup the DNS configuration file /etc/resolv.conf. */ if (rtems_bsdnet_nameserver_count) { int i; char buf[64]; const char *bufl[1]; bufl[0] = buf; #define MKFILE_MODE (S_IRUSR | S_IWUSR | S_IWGRP | S_IRGRP | S_IROTH) if (rtems_bsdnet_domain_name && (strlen(rtems_bsdnet_domain_name) < (sizeof(buf) - 1))) { strcpy(buf, "search "); strcat(buf, rtems_bsdnet_domain_name); strcat(buf, "\n"); rtems_rootfs_file_append ("/etc/resolv.conf", MKFILE_MODE, 1, bufl); } for (i = 0; i < rtems_bsdnet_nameserver_count; i++) { strcpy(buf, "nameserver "); strcat(buf, inet_ntoa(rtems_bsdnet_ntpserver[i])); strcat(buf, "\n"); if (rtems_rootfs_file_append ("/etc/resolv.conf", MKFILE_MODE, 1, bufl)) break; } } } /* * Configure the interface with the new settings */ error = bootpc_adjust_interface(&ireq,so, &myaddr,&dhcp_netmask,&dhcp_gw,procp); soclose(so);} | 10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/7ac73e6ee2af1a0bcdcccf76344e60db558efe9a/bootp_subr.c/buggy/cpukit/libnetworking/nfs/bootp_subr.c |
embedding_of_potential_subfields(GEN nf,GEN g,GEN DATA,GEN rootsA,GEN delta) | embedding_of_potential_subfields(GEN g,GEN DATA,GEN rootsA,GEN delta) | embedding_of_potential_subfields(GEN nf,GEN g,GEN DATA,GEN rootsA,GEN delta){ GEN w0_Q,w0,w1,h0,gp,w1_Q,T,p,ind, maxp; ulong av; T = (GEN)nf[1]; ind = (GEN)nf[4]; p = (GEN)DATA[2]; maxp = mulii((GEN)DATA[7],ind); gp = derivpol(g); av = avma; w0 = interpolation_polynomial(rootsA, delta, (GEN)DATA[4],p); w0_Q = retrieve_ratpol(ind,w0,p); /* h0 = 1/g'(w0) mod (T,p) */ h0 = FpXQ_inv(FpX_FpXQ_compo(gp,w0, T,p), T,p); for(;;) { GEN p1; /* Given g in Z[x], g' its derivative, p a prime, [w0,h0] in Z[x] s.t. * h0.g'(w0) = 1 and g(w0) = 0 mod (T,p), return * [w1,h1] satisfying the same condition mod p^2, [w1,h1] = [w0,h0] (mod p) * (cf. Dixon: J. Austral. Math. Soc., Series A, vol.49, 1990, p.445) */ if (DEBUGLEVEL>2) fprintferr("w = %Z\nh = %Z\n",w0,h0); p = sqri(p); /* w1 = w0 - h0 g(w0) mod (T,p) */ p1 = gmul(gneg(h0), FpX_FpXQ_compo(g,w0, T,p)); w1 = gadd(w0, FpX_res(p1, T,p)); w1_Q = retrieve_ratpol(ind,w1,p); if ((gegal(w1_Q, w0_Q) || cmpii(p,maxp)) && gcmp0(poleval(g, gmodulcp(w1_Q,T)))) break; if (DEBUGLEVEL>2) { fprintferr("Old Q-polynomial: %Z\n",w0_Q); fprintferr("New Q-polynomial: %Z\n",w1_Q); } if (cmpii(p, maxp) > 0) { if (DEBUGLEVEL) fprintferr("coeff too big for embedding\n"); return NULL; } p1 = gmul(gneg(h0), FpX_FpXQ_compo(gp,w1, T,p)); p1 = gadd(gdeux, FpX_res(p1, T,p)); h0 = FpX_res(gmul(h0, p1), T,p); w0 = w1; w0_Q = w1_Q; { GEN *gptr[4]; gptr[0]=&w0; gptr[1]=&h0; gptr[2]=&w0_Q; gptr[3]=&p; gerepilemany(av,gptr,4); } } return poleval(w1_Q, gadd(polx[0],stoi(TR)));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59af7aa1a95aeb4e670f3d2cf01cd1e105edb8c4/subfield.c/buggy/src/modules/subfield.c |
GEN w0_Q,w0,w1,h0,gp,w1_Q,T,p,ind, maxp; | GEN w0_Q,w0,w1,h0,gp,w1_Q,T,p,ind,maxp,p1; | embedding_of_potential_subfields(GEN nf,GEN g,GEN DATA,GEN rootsA,GEN delta){ GEN w0_Q,w0,w1,h0,gp,w1_Q,T,p,ind, maxp; ulong av; T = (GEN)nf[1]; ind = (GEN)nf[4]; p = (GEN)DATA[2]; maxp = mulii((GEN)DATA[7],ind); gp = derivpol(g); av = avma; w0 = interpolation_polynomial(rootsA, delta, (GEN)DATA[4],p); w0_Q = retrieve_ratpol(ind,w0,p); /* h0 = 1/g'(w0) mod (T,p) */ h0 = FpXQ_inv(FpX_FpXQ_compo(gp,w0, T,p), T,p); for(;;) { GEN p1; /* Given g in Z[x], g' its derivative, p a prime, [w0,h0] in Z[x] s.t. * h0.g'(w0) = 1 and g(w0) = 0 mod (T,p), return * [w1,h1] satisfying the same condition mod p^2, [w1,h1] = [w0,h0] (mod p) * (cf. Dixon: J. Austral. Math. Soc., Series A, vol.49, 1990, p.445) */ if (DEBUGLEVEL>2) fprintferr("w = %Z\nh = %Z\n",w0,h0); p = sqri(p); /* w1 = w0 - h0 g(w0) mod (T,p) */ p1 = gmul(gneg(h0), FpX_FpXQ_compo(g,w0, T,p)); w1 = gadd(w0, FpX_res(p1, T,p)); w1_Q = retrieve_ratpol(ind,w1,p); if ((gegal(w1_Q, w0_Q) || cmpii(p,maxp)) && gcmp0(poleval(g, gmodulcp(w1_Q,T)))) break; if (DEBUGLEVEL>2) { fprintferr("Old Q-polynomial: %Z\n",w0_Q); fprintferr("New Q-polynomial: %Z\n",w1_Q); } if (cmpii(p, maxp) > 0) { if (DEBUGLEVEL) fprintferr("coeff too big for embedding\n"); return NULL; } p1 = gmul(gneg(h0), FpX_FpXQ_compo(gp,w1, T,p)); p1 = gadd(gdeux, FpX_res(p1, T,p)); h0 = FpX_res(gmul(h0, p1), T,p); w0 = w1; w0_Q = w1_Q; { GEN *gptr[4]; gptr[0]=&w0; gptr[1]=&h0; gptr[2]=&w0_Q; gptr[3]=&p; gerepilemany(av,gptr,4); } } return poleval(w1_Q, gadd(polx[0],stoi(TR)));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59af7aa1a95aeb4e670f3d2cf01cd1e105edb8c4/subfield.c/buggy/src/modules/subfield.c |
T = (GEN)nf[1]; ind = (GEN)nf[4]; p = (GEN)DATA[2]; maxp = mulii((GEN)DATA[7],ind); gp = derivpol(g); av = avma; | T = (GEN)DATA[1]; p = (GEN)DATA[2]; maxp = (GEN)DATA[7]; ind = (GEN)DATA[9]; gp = derivpol(g); av = avma; | embedding_of_potential_subfields(GEN nf,GEN g,GEN DATA,GEN rootsA,GEN delta){ GEN w0_Q,w0,w1,h0,gp,w1_Q,T,p,ind, maxp; ulong av; T = (GEN)nf[1]; ind = (GEN)nf[4]; p = (GEN)DATA[2]; maxp = mulii((GEN)DATA[7],ind); gp = derivpol(g); av = avma; w0 = interpolation_polynomial(rootsA, delta, (GEN)DATA[4],p); w0_Q = retrieve_ratpol(ind,w0,p); /* h0 = 1/g'(w0) mod (T,p) */ h0 = FpXQ_inv(FpX_FpXQ_compo(gp,w0, T,p), T,p); for(;;) { GEN p1; /* Given g in Z[x], g' its derivative, p a prime, [w0,h0] in Z[x] s.t. * h0.g'(w0) = 1 and g(w0) = 0 mod (T,p), return * [w1,h1] satisfying the same condition mod p^2, [w1,h1] = [w0,h0] (mod p) * (cf. Dixon: J. Austral. Math. Soc., Series A, vol.49, 1990, p.445) */ if (DEBUGLEVEL>2) fprintferr("w = %Z\nh = %Z\n",w0,h0); p = sqri(p); /* w1 = w0 - h0 g(w0) mod (T,p) */ p1 = gmul(gneg(h0), FpX_FpXQ_compo(g,w0, T,p)); w1 = gadd(w0, FpX_res(p1, T,p)); w1_Q = retrieve_ratpol(ind,w1,p); if ((gegal(w1_Q, w0_Q) || cmpii(p,maxp)) && gcmp0(poleval(g, gmodulcp(w1_Q,T)))) break; if (DEBUGLEVEL>2) { fprintferr("Old Q-polynomial: %Z\n",w0_Q); fprintferr("New Q-polynomial: %Z\n",w1_Q); } if (cmpii(p, maxp) > 0) { if (DEBUGLEVEL) fprintferr("coeff too big for embedding\n"); return NULL; } p1 = gmul(gneg(h0), FpX_FpXQ_compo(gp,w1, T,p)); p1 = gadd(gdeux, FpX_res(p1, T,p)); h0 = FpX_res(gmul(h0, p1), T,p); w0 = w1; w0_Q = w1_Q; { GEN *gptr[4]; gptr[0]=&w0; gptr[1]=&h0; gptr[2]=&w0_Q; gptr[3]=&p; gerepilemany(av,gptr,4); } } return poleval(w1_Q, gadd(polx[0],stoi(TR)));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59af7aa1a95aeb4e670f3d2cf01cd1e105edb8c4/subfield.c/buggy/src/modules/subfield.c |
/* h0 = 1/g'(w0) mod (T,p) */ h0 = FpXQ_inv(FpX_FpXQ_compo(gp,w0, T,p), T,p); | h0 = FpXQ_inv(FpX_FpXQ_compo(gp,w0, T,p), T,p); /* = 1/g'(w0) mod (T,p) */ | embedding_of_potential_subfields(GEN nf,GEN g,GEN DATA,GEN rootsA,GEN delta){ GEN w0_Q,w0,w1,h0,gp,w1_Q,T,p,ind, maxp; ulong av; T = (GEN)nf[1]; ind = (GEN)nf[4]; p = (GEN)DATA[2]; maxp = mulii((GEN)DATA[7],ind); gp = derivpol(g); av = avma; w0 = interpolation_polynomial(rootsA, delta, (GEN)DATA[4],p); w0_Q = retrieve_ratpol(ind,w0,p); /* h0 = 1/g'(w0) mod (T,p) */ h0 = FpXQ_inv(FpX_FpXQ_compo(gp,w0, T,p), T,p); for(;;) { GEN p1; /* Given g in Z[x], g' its derivative, p a prime, [w0,h0] in Z[x] s.t. * h0.g'(w0) = 1 and g(w0) = 0 mod (T,p), return * [w1,h1] satisfying the same condition mod p^2, [w1,h1] = [w0,h0] (mod p) * (cf. Dixon: J. Austral. Math. Soc., Series A, vol.49, 1990, p.445) */ if (DEBUGLEVEL>2) fprintferr("w = %Z\nh = %Z\n",w0,h0); p = sqri(p); /* w1 = w0 - h0 g(w0) mod (T,p) */ p1 = gmul(gneg(h0), FpX_FpXQ_compo(g,w0, T,p)); w1 = gadd(w0, FpX_res(p1, T,p)); w1_Q = retrieve_ratpol(ind,w1,p); if ((gegal(w1_Q, w0_Q) || cmpii(p,maxp)) && gcmp0(poleval(g, gmodulcp(w1_Q,T)))) break; if (DEBUGLEVEL>2) { fprintferr("Old Q-polynomial: %Z\n",w0_Q); fprintferr("New Q-polynomial: %Z\n",w1_Q); } if (cmpii(p, maxp) > 0) { if (DEBUGLEVEL) fprintferr("coeff too big for embedding\n"); return NULL; } p1 = gmul(gneg(h0), FpX_FpXQ_compo(gp,w1, T,p)); p1 = gadd(gdeux, FpX_res(p1, T,p)); h0 = FpX_res(gmul(h0, p1), T,p); w0 = w1; w0_Q = w1_Q; { GEN *gptr[4]; gptr[0]=&w0; gptr[1]=&h0; gptr[2]=&w0_Q; gptr[3]=&p; gerepilemany(av,gptr,4); } } return poleval(w1_Q, gadd(polx[0],stoi(TR)));} | 2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59af7aa1a95aeb4e670f3d2cf01cd1e105edb8c4/subfield.c/buggy/src/modules/subfield.c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.