rem
stringlengths
0
274k
add
stringlengths
0
169k
context
stringlengths
9
471k
q = gpowgs(p, pp+xp);
q = gpowgs(p, pp+2*xp);
gzetap(GEN s){ long pp, j, k, N, f, c, xp, l; pari_sp av = avma; GEN p, q, vz, is, cff, vtz, val, va, cft, bn; if (valp(s) < 0) err(talker, "argument must be a p-adic integer"); p = (GEN)s[2]; xp = 3; /* the extra precision; FIXME: quite arbitrary */ pp = precp(s); is = gtrunc(s); /* make s an integer */ N = itos(mulis(p, pp))+2*xp; /* FIXME: crude estimation */ q = gpowgs(p, pp+xp); /* initialize the roots of unity for the computation of the Teichmuller character (also the values of f and c) */ if (cmpis(p, 2) == 0) { vz = NULL; f = 4; c = 3; } else { GEN x = polx[0]; GEN p1 = gsubgs(powgi(x, subis(p, 1)), 1); vz = cgetg(itos(p), t_VEC); for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gsubgs(x, j); p1 = hensel_lift_fact(p1, vz, NULL, p, q, pp+xp); /* p1 = polhensellift(p1, vz, p, pp+xp); */ for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gadd(gneg(polcoeff0((GEN) p1[j], 0, 0)), zeropadic(p, pp+xp)); f = itos(p); c = 2; } /* compute the first N coefficients of the Malher expansion of phi^(-1)_s skipping the first one (which is zero) */ cff = cgetg(N+1, t_VEC); bn = new_chunk(N+2); /* bn[i] = binom(k, i), i <= k */ l = lg(q); for (k = 0; k <= N; k++) { GEN t = cgeti(l); affsi(1, t); bn[k] = (long)t; } for (k = 1; k <= N; k++) { pari_sp av2 = avma; GEN p1, A = phi_ms(vz, p, -1, is, gaddsg(k, zeropadic(p, pp+xp))); A = gtrunc(A); p1 = gzero; for (j = k - 1; j > 0; j--) { GEN b = addii((GEN)bn[j], (GEN)bn[j-1]); if (cmpii(b, q) >= 0) b = subii(b, q); affii(b, (GEN)bn[j]); /* = binom(k, j+1) */ } for (j = 1; j < k; j++) p1 = addii(p1, mulii((GEN)bn[j], (GEN)cff[j])); cff[k] = (long)gerepileuptoint(av2, modii(subii(A, p1), q)); } /* compute the coefficients of the power series corresponding to the twisted partial zeta function Z_f(a, c, s) for a in va */ /* The line below looks a bit stupid but it is to keep the possibility of later adding p-adic Dirichlet L-functions */ va = perm_identity(f - 1); vtz = twistpartialpowser(p, q, N, f, c, va); /* sum over all a's the coefficients of the twisted partial zeta functions and integrate */ val = gzero; for (k = 1; k <= N; k++) { GEN p1 = gzero; for (j = 1; j < f; j++) p1 = gadd(p1, gcoeff(vtz, k, j)); val = gadd(val, gmul(p1, (GEN)cff[k])); } /* finally we multiply by the corrective factor */ cft = gsubgs(gmulsg(c, phi_ms(vz, p, -1, is, gaddsg(c, zeropadic(p, pp+xp)))), 1); val = gdiv(val, cft); /* adjust the precision and return */ return gerepileupto(av, gadd(val, zeropadic(p, pp)));}
vz[j] = (long)gadd(gneg(polcoeff0((GEN) p1[j], 0, 0)), zeropadic(p, pp+xp));
vz[j] = (long)gmodulcp(gneg(polcoeff0((GEN) p1[j], 0, 0)), q);
gzetap(GEN s){ long pp, j, k, N, f, c, xp, l; pari_sp av = avma; GEN p, q, vz, is, cff, vtz, val, va, cft, bn; if (valp(s) < 0) err(talker, "argument must be a p-adic integer"); p = (GEN)s[2]; xp = 3; /* the extra precision; FIXME: quite arbitrary */ pp = precp(s); is = gtrunc(s); /* make s an integer */ N = itos(mulis(p, pp))+2*xp; /* FIXME: crude estimation */ q = gpowgs(p, pp+xp); /* initialize the roots of unity for the computation of the Teichmuller character (also the values of f and c) */ if (cmpis(p, 2) == 0) { vz = NULL; f = 4; c = 3; } else { GEN x = polx[0]; GEN p1 = gsubgs(powgi(x, subis(p, 1)), 1); vz = cgetg(itos(p), t_VEC); for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gsubgs(x, j); p1 = hensel_lift_fact(p1, vz, NULL, p, q, pp+xp); /* p1 = polhensellift(p1, vz, p, pp+xp); */ for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gadd(gneg(polcoeff0((GEN) p1[j], 0, 0)), zeropadic(p, pp+xp)); f = itos(p); c = 2; } /* compute the first N coefficients of the Malher expansion of phi^(-1)_s skipping the first one (which is zero) */ cff = cgetg(N+1, t_VEC); bn = new_chunk(N+2); /* bn[i] = binom(k, i), i <= k */ l = lg(q); for (k = 0; k <= N; k++) { GEN t = cgeti(l); affsi(1, t); bn[k] = (long)t; } for (k = 1; k <= N; k++) { pari_sp av2 = avma; GEN p1, A = phi_ms(vz, p, -1, is, gaddsg(k, zeropadic(p, pp+xp))); A = gtrunc(A); p1 = gzero; for (j = k - 1; j > 0; j--) { GEN b = addii((GEN)bn[j], (GEN)bn[j-1]); if (cmpii(b, q) >= 0) b = subii(b, q); affii(b, (GEN)bn[j]); /* = binom(k, j+1) */ } for (j = 1; j < k; j++) p1 = addii(p1, mulii((GEN)bn[j], (GEN)cff[j])); cff[k] = (long)gerepileuptoint(av2, modii(subii(A, p1), q)); } /* compute the coefficients of the power series corresponding to the twisted partial zeta function Z_f(a, c, s) for a in va */ /* The line below looks a bit stupid but it is to keep the possibility of later adding p-adic Dirichlet L-functions */ va = perm_identity(f - 1); vtz = twistpartialpowser(p, q, N, f, c, va); /* sum over all a's the coefficients of the twisted partial zeta functions and integrate */ val = gzero; for (k = 1; k <= N; k++) { GEN p1 = gzero; for (j = 1; j < f; j++) p1 = gadd(p1, gcoeff(vtz, k, j)); val = gadd(val, gmul(p1, (GEN)cff[k])); } /* finally we multiply by the corrective factor */ cft = gsubgs(gmulsg(c, phi_ms(vz, p, -1, is, gaddsg(c, zeropadic(p, pp+xp)))), 1); val = gdiv(val, cft); /* adjust the precision and return */ return gerepileupto(av, gadd(val, zeropadic(p, pp)));}
GEN p1, A = phi_ms(vz, p, -1, is, gaddsg(k, zeropadic(p, pp+xp))); A = gtrunc(A); p1 = gzero;
GEN p1 = gzero, A = phi_ms(vz, p, -1, is, gmodulsg(k, q));
gzetap(GEN s){ long pp, j, k, N, f, c, xp, l; pari_sp av = avma; GEN p, q, vz, is, cff, vtz, val, va, cft, bn; if (valp(s) < 0) err(talker, "argument must be a p-adic integer"); p = (GEN)s[2]; xp = 3; /* the extra precision; FIXME: quite arbitrary */ pp = precp(s); is = gtrunc(s); /* make s an integer */ N = itos(mulis(p, pp))+2*xp; /* FIXME: crude estimation */ q = gpowgs(p, pp+xp); /* initialize the roots of unity for the computation of the Teichmuller character (also the values of f and c) */ if (cmpis(p, 2) == 0) { vz = NULL; f = 4; c = 3; } else { GEN x = polx[0]; GEN p1 = gsubgs(powgi(x, subis(p, 1)), 1); vz = cgetg(itos(p), t_VEC); for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gsubgs(x, j); p1 = hensel_lift_fact(p1, vz, NULL, p, q, pp+xp); /* p1 = polhensellift(p1, vz, p, pp+xp); */ for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gadd(gneg(polcoeff0((GEN) p1[j], 0, 0)), zeropadic(p, pp+xp)); f = itos(p); c = 2; } /* compute the first N coefficients of the Malher expansion of phi^(-1)_s skipping the first one (which is zero) */ cff = cgetg(N+1, t_VEC); bn = new_chunk(N+2); /* bn[i] = binom(k, i), i <= k */ l = lg(q); for (k = 0; k <= N; k++) { GEN t = cgeti(l); affsi(1, t); bn[k] = (long)t; } for (k = 1; k <= N; k++) { pari_sp av2 = avma; GEN p1, A = phi_ms(vz, p, -1, is, gaddsg(k, zeropadic(p, pp+xp))); A = gtrunc(A); p1 = gzero; for (j = k - 1; j > 0; j--) { GEN b = addii((GEN)bn[j], (GEN)bn[j-1]); if (cmpii(b, q) >= 0) b = subii(b, q); affii(b, (GEN)bn[j]); /* = binom(k, j+1) */ } for (j = 1; j < k; j++) p1 = addii(p1, mulii((GEN)bn[j], (GEN)cff[j])); cff[k] = (long)gerepileuptoint(av2, modii(subii(A, p1), q)); } /* compute the coefficients of the power series corresponding to the twisted partial zeta function Z_f(a, c, s) for a in va */ /* The line below looks a bit stupid but it is to keep the possibility of later adding p-adic Dirichlet L-functions */ va = perm_identity(f - 1); vtz = twistpartialpowser(p, q, N, f, c, va); /* sum over all a's the coefficients of the twisted partial zeta functions and integrate */ val = gzero; for (k = 1; k <= N; k++) { GEN p1 = gzero; for (j = 1; j < f; j++) p1 = gadd(p1, gcoeff(vtz, k, j)); val = gadd(val, gmul(p1, (GEN)cff[k])); } /* finally we multiply by the corrective factor */ cft = gsubgs(gmulsg(c, phi_ms(vz, p, -1, is, gaddsg(c, zeropadic(p, pp+xp)))), 1); val = gdiv(val, cft); /* adjust the precision and return */ return gerepileupto(av, gadd(val, zeropadic(p, pp)));}
vtz = twistpartialpowser(p, q, N, f, c, va);
if (DEBUGLEVEL > 1) fprintferr("gzetap: computing twisted partial zeta functions\n"); vtz = twistpartialzeta(p, q, N, f, c, va, cff);
gzetap(GEN s){ long pp, j, k, N, f, c, xp, l; pari_sp av = avma; GEN p, q, vz, is, cff, vtz, val, va, cft, bn; if (valp(s) < 0) err(talker, "argument must be a p-adic integer"); p = (GEN)s[2]; xp = 3; /* the extra precision; FIXME: quite arbitrary */ pp = precp(s); is = gtrunc(s); /* make s an integer */ N = itos(mulis(p, pp))+2*xp; /* FIXME: crude estimation */ q = gpowgs(p, pp+xp); /* initialize the roots of unity for the computation of the Teichmuller character (also the values of f and c) */ if (cmpis(p, 2) == 0) { vz = NULL; f = 4; c = 3; } else { GEN x = polx[0]; GEN p1 = gsubgs(powgi(x, subis(p, 1)), 1); vz = cgetg(itos(p), t_VEC); for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gsubgs(x, j); p1 = hensel_lift_fact(p1, vz, NULL, p, q, pp+xp); /* p1 = polhensellift(p1, vz, p, pp+xp); */ for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gadd(gneg(polcoeff0((GEN) p1[j], 0, 0)), zeropadic(p, pp+xp)); f = itos(p); c = 2; } /* compute the first N coefficients of the Malher expansion of phi^(-1)_s skipping the first one (which is zero) */ cff = cgetg(N+1, t_VEC); bn = new_chunk(N+2); /* bn[i] = binom(k, i), i <= k */ l = lg(q); for (k = 0; k <= N; k++) { GEN t = cgeti(l); affsi(1, t); bn[k] = (long)t; } for (k = 1; k <= N; k++) { pari_sp av2 = avma; GEN p1, A = phi_ms(vz, p, -1, is, gaddsg(k, zeropadic(p, pp+xp))); A = gtrunc(A); p1 = gzero; for (j = k - 1; j > 0; j--) { GEN b = addii((GEN)bn[j], (GEN)bn[j-1]); if (cmpii(b, q) >= 0) b = subii(b, q); affii(b, (GEN)bn[j]); /* = binom(k, j+1) */ } for (j = 1; j < k; j++) p1 = addii(p1, mulii((GEN)bn[j], (GEN)cff[j])); cff[k] = (long)gerepileuptoint(av2, modii(subii(A, p1), q)); } /* compute the coefficients of the power series corresponding to the twisted partial zeta function Z_f(a, c, s) for a in va */ /* The line below looks a bit stupid but it is to keep the possibility of later adding p-adic Dirichlet L-functions */ va = perm_identity(f - 1); vtz = twistpartialpowser(p, q, N, f, c, va); /* sum over all a's the coefficients of the twisted partial zeta functions and integrate */ val = gzero; for (k = 1; k <= N; k++) { GEN p1 = gzero; for (j = 1; j < f; j++) p1 = gadd(p1, gcoeff(vtz, k, j)); val = gadd(val, gmul(p1, (GEN)cff[k])); } /* finally we multiply by the corrective factor */ cft = gsubgs(gmulsg(c, phi_ms(vz, p, -1, is, gaddsg(c, zeropadic(p, pp+xp)))), 1); val = gdiv(val, cft); /* adjust the precision and return */ return gerepileupto(av, gadd(val, zeropadic(p, pp)));}
for (k = 1; k <= N; k++) { GEN p1 = gzero; for (j = 1; j < f; j++) p1 = gadd(p1, gcoeff(vtz, k, j)); val = gadd(val, gmul(p1, (GEN)cff[k])); }
for (j = 1; j < f; j++) val = gadd(val, (GEN)vtz[j]); val = lift(val);
gzetap(GEN s){ long pp, j, k, N, f, c, xp, l; pari_sp av = avma; GEN p, q, vz, is, cff, vtz, val, va, cft, bn; if (valp(s) < 0) err(talker, "argument must be a p-adic integer"); p = (GEN)s[2]; xp = 3; /* the extra precision; FIXME: quite arbitrary */ pp = precp(s); is = gtrunc(s); /* make s an integer */ N = itos(mulis(p, pp))+2*xp; /* FIXME: crude estimation */ q = gpowgs(p, pp+xp); /* initialize the roots of unity for the computation of the Teichmuller character (also the values of f and c) */ if (cmpis(p, 2) == 0) { vz = NULL; f = 4; c = 3; } else { GEN x = polx[0]; GEN p1 = gsubgs(powgi(x, subis(p, 1)), 1); vz = cgetg(itos(p), t_VEC); for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gsubgs(x, j); p1 = hensel_lift_fact(p1, vz, NULL, p, q, pp+xp); /* p1 = polhensellift(p1, vz, p, pp+xp); */ for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gadd(gneg(polcoeff0((GEN) p1[j], 0, 0)), zeropadic(p, pp+xp)); f = itos(p); c = 2; } /* compute the first N coefficients of the Malher expansion of phi^(-1)_s skipping the first one (which is zero) */ cff = cgetg(N+1, t_VEC); bn = new_chunk(N+2); /* bn[i] = binom(k, i), i <= k */ l = lg(q); for (k = 0; k <= N; k++) { GEN t = cgeti(l); affsi(1, t); bn[k] = (long)t; } for (k = 1; k <= N; k++) { pari_sp av2 = avma; GEN p1, A = phi_ms(vz, p, -1, is, gaddsg(k, zeropadic(p, pp+xp))); A = gtrunc(A); p1 = gzero; for (j = k - 1; j > 0; j--) { GEN b = addii((GEN)bn[j], (GEN)bn[j-1]); if (cmpii(b, q) >= 0) b = subii(b, q); affii(b, (GEN)bn[j]); /* = binom(k, j+1) */ } for (j = 1; j < k; j++) p1 = addii(p1, mulii((GEN)bn[j], (GEN)cff[j])); cff[k] = (long)gerepileuptoint(av2, modii(subii(A, p1), q)); } /* compute the coefficients of the power series corresponding to the twisted partial zeta function Z_f(a, c, s) for a in va */ /* The line below looks a bit stupid but it is to keep the possibility of later adding p-adic Dirichlet L-functions */ va = perm_identity(f - 1); vtz = twistpartialpowser(p, q, N, f, c, va); /* sum over all a's the coefficients of the twisted partial zeta functions and integrate */ val = gzero; for (k = 1; k <= N; k++) { GEN p1 = gzero; for (j = 1; j < f; j++) p1 = gadd(p1, gcoeff(vtz, k, j)); val = gadd(val, gmul(p1, (GEN)cff[k])); } /* finally we multiply by the corrective factor */ cft = gsubgs(gmulsg(c, phi_ms(vz, p, -1, is, gaddsg(c, zeropadic(p, pp+xp)))), 1); val = gdiv(val, cft); /* adjust the precision and return */ return gerepileupto(av, gadd(val, zeropadic(p, pp)));}
cft = gsubgs(gmulsg(c, phi_ms(vz, p, -1, is, gaddsg(c, zeropadic(p, pp+xp)))), 1);
cft = gsubgs(gmulsg(c, phi_ms(vz, p, -1, is, gmodulsg(c, q))), 1);
gzetap(GEN s){ long pp, j, k, N, f, c, xp, l; pari_sp av = avma; GEN p, q, vz, is, cff, vtz, val, va, cft, bn; if (valp(s) < 0) err(talker, "argument must be a p-adic integer"); p = (GEN)s[2]; xp = 3; /* the extra precision; FIXME: quite arbitrary */ pp = precp(s); is = gtrunc(s); /* make s an integer */ N = itos(mulis(p, pp))+2*xp; /* FIXME: crude estimation */ q = gpowgs(p, pp+xp); /* initialize the roots of unity for the computation of the Teichmuller character (also the values of f and c) */ if (cmpis(p, 2) == 0) { vz = NULL; f = 4; c = 3; } else { GEN x = polx[0]; GEN p1 = gsubgs(powgi(x, subis(p, 1)), 1); vz = cgetg(itos(p), t_VEC); for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gsubgs(x, j); p1 = hensel_lift_fact(p1, vz, NULL, p, q, pp+xp); /* p1 = polhensellift(p1, vz, p, pp+xp); */ for (j = 1; cmpsi(j, p) < 0; j++) vz[j] = (long)gadd(gneg(polcoeff0((GEN) p1[j], 0, 0)), zeropadic(p, pp+xp)); f = itos(p); c = 2; } /* compute the first N coefficients of the Malher expansion of phi^(-1)_s skipping the first one (which is zero) */ cff = cgetg(N+1, t_VEC); bn = new_chunk(N+2); /* bn[i] = binom(k, i), i <= k */ l = lg(q); for (k = 0; k <= N; k++) { GEN t = cgeti(l); affsi(1, t); bn[k] = (long)t; } for (k = 1; k <= N; k++) { pari_sp av2 = avma; GEN p1, A = phi_ms(vz, p, -1, is, gaddsg(k, zeropadic(p, pp+xp))); A = gtrunc(A); p1 = gzero; for (j = k - 1; j > 0; j--) { GEN b = addii((GEN)bn[j], (GEN)bn[j-1]); if (cmpii(b, q) >= 0) b = subii(b, q); affii(b, (GEN)bn[j]); /* = binom(k, j+1) */ } for (j = 1; j < k; j++) p1 = addii(p1, mulii((GEN)bn[j], (GEN)cff[j])); cff[k] = (long)gerepileuptoint(av2, modii(subii(A, p1), q)); } /* compute the coefficients of the power series corresponding to the twisted partial zeta function Z_f(a, c, s) for a in va */ /* The line below looks a bit stupid but it is to keep the possibility of later adding p-adic Dirichlet L-functions */ va = perm_identity(f - 1); vtz = twistpartialpowser(p, q, N, f, c, va); /* sum over all a's the coefficients of the twisted partial zeta functions and integrate */ val = gzero; for (k = 1; k <= N; k++) { GEN p1 = gzero; for (j = 1; j < f; j++) p1 = gadd(p1, gcoeff(vtz, k, j)); val = gadd(val, gmul(p1, (GEN)cff[k])); } /* finally we multiply by the corrective factor */ cft = gsubgs(gmulsg(c, phi_ms(vz, p, -1, is, gaddsg(c, zeropadic(p, pp+xp)))), 1); val = gdiv(val, cft); /* adjust the precision and return */ return gerepileupto(av, gadd(val, zeropadic(p, pp)));}
if (lx>=ly) for (i=2; i<ly; i++) y[i]=x[i]; else
if (lx <= ly)
affrr(GEN x, GEN y){ long lx,ly,i; y[1] = x[1]; if (!signe(x)) return; lx=lg(x); ly=lg(y); if (lx>=ly) for (i=2; i<ly; i++) y[i]=x[i]; else { for (i=2; i<lx; i++) y[i]=x[i]; for ( ; i<ly; i++) y[i]=0; }}
for (i=2; i<ly; i++) y[i]=x[i]; if (x[ly] & HIGHBIT) roundr_up_ip(y, ly);
affrr(GEN x, GEN y){ long lx,ly,i; y[1] = x[1]; if (!signe(x)) return; lx=lg(x); ly=lg(y); if (lx>=ly) for (i=2; i<ly; i++) y[i]=x[i]; else { for (i=2; i<lx; i++) y[i]=x[i]; for ( ; i<ly; i++) y[i]=0; }}
GEN z = cgetg(l, t_VEC); z[1] = x[1]; for (i = 2; i < l; i++) gel(z,i) = Rg_to_Fp(gel(x,i), p);
GEN z = cgetg(l, t_VEC); for (i = 1; i < l; i++) gel(z,i) = Rg_to_Fp(gel(x,i), p);
RgV_to_FpV(GEN x, GEN p){ long i, l = lg(x); GEN z = cgetg(l, t_VEC); z[1] = x[1]; for (i = 2; i < l; i++) gel(z,i) = Rg_to_Fp(gel(x,i), p); return z;}
if (!under_emacs && !ioctl(0, TIOCGWINSZ, &s)) return s.ws_col;
if (!under_emacs && !under_texmacs && !ioctl(0, TIOCGWINSZ, &s)) return s.ws_col;
term_width_intern(){#ifdef HAS_TIOCGWINSZ { struct winsize s; if (!under_emacs && !ioctl(0, TIOCGWINSZ, &s)) return s.ws_col; }#endif#ifdef UNIX { char *str; if ((str = getenv("COLUMNS"))) return atoi(str); }#endif#ifdef __EMX__ { int scrsize[2]; _scrsize(scrsize); return scrsize[0]; }#endif return 0;}
return sarg((GEN)x[1],(GEN)x[2],prec);
return cxarg((GEN)x[1],(GEN)x[2],prec);
garg(GEN x, long prec){ long tx = typ(x); pari_sp av; if (gcmp0(x)) err(talker,"zero argument in garg"); switch(tx) { case t_REAL: prec = lg(x); /* fall through */ case t_INT: case t_FRAC: return (gsigne(x)>0)? realzero(prec): mppi(prec); case t_QUAD: av = avma; return gerepileuptoleaf(av, garg(quadtoc(x, prec), prec)); case t_COMPLEX: return sarg((GEN)x[1],(GEN)x[2],prec); case t_VEC: case t_COL: case t_MAT: return transc(garg,x,prec); } err(typeer,"garg"); return NULL; /* not reached */}
F->pow = (powFB_t*) gpmalloc(sizeof(powFB_t));
F->pow = new = (powFB_t*) gpmalloc(sizeof(powFB_t));
powFBgen(FB_t *F, RELCACHE_t *cache, GEN nf){ const int a = 1<<RANDOM_BITS; pari_sp av = avma; long i, j, c = 1, n = lg(F->subFB); GEN Id2, Alg, Ord; if (DEBUGLEVEL) fprintferr("Computing powers for subFB: %Z\n",F->subFB); F->pow = (powFB_t*) gpmalloc(sizeof(powFB_t)); Id2 = cgetg(n, t_VEC); Alg = cgetg(n, t_VEC); Ord = cgetg(n, t_VECSMALL); F->pow->arc = NULL; if (cache) pre_allocate(cache, n); for (i=1; i<n; i++) { GEN M, m, alg, id2, vp = (GEN)F->LP[ F->subFB[i] ]; GEN z = cgetg(3,t_VEC); z[1] = vp[1]; z[2] = vp[2]; id2 = cgetg(a+1,t_VEC); Id2[i] = (long)id2; id2[1] = (long)z; alg = cgetg(a+1,t_VEC); Alg[i] = (long)alg; alg[1] = un; vp = prime_to_ideal(nf,vp); for (j=2; j<=a; j++) { GEN J = red(nf, idealmulh(nf,vp,(GEN)id2[j-1]), &m); if (DEBUGLEVEL>1) fprintferr(" %ld",j); if (!J) { if (j == 2 && !red(nf, vp, &M)) { j = 1; m = M; } break; } if (gegal(J, (GEN)id2[j-1])) { j = 1; break; } id2[j] = (long)J; alg[j] = (long)m; } if (cache && j <= a) { /* vp^j principal */ long k; REL_t *rel = cache->last + 1; rel->R = col_0(F->KC); rel->nz = F->subFB[i]; rel->R[ rel->nz ] = j; for (k = 2; k < j; k++) m = element_mul(nf, m, (GEN)alg[k]); rel->m = gclone(m); rel->ex= NULL; cache->last = rel; } /* trouble with subFB: include ideal even though it's principal */ if (j == 1 && F->sfb_chg == sfb_UNSUITABLE) j = 2; setlg(id2, j); setlg(alg, j); Ord[i] = j; if (c < 64) c *= j; if (DEBUGLEVEL>1) fprintferr("\n"); } F->pow->id2 = gclone(Id2); F->pow->ord = gclone(Ord); F->pow->alg = gclone(Alg); avma = av; if (DEBUGLEVEL) msgtimer("powFBgen"); /* if c too small we'd better change the subFB soon */ F->sfb_chg = (c < 6)? sfb_UNSUITABLE: 0;}
F->pow->arc = NULL;
new->arc = NULL;
powFBgen(FB_t *F, RELCACHE_t *cache, GEN nf){ const int a = 1<<RANDOM_BITS; pari_sp av = avma; long i, j, c = 1, n = lg(F->subFB); GEN Id2, Alg, Ord; if (DEBUGLEVEL) fprintferr("Computing powers for subFB: %Z\n",F->subFB); F->pow = (powFB_t*) gpmalloc(sizeof(powFB_t)); Id2 = cgetg(n, t_VEC); Alg = cgetg(n, t_VEC); Ord = cgetg(n, t_VECSMALL); F->pow->arc = NULL; if (cache) pre_allocate(cache, n); for (i=1; i<n; i++) { GEN M, m, alg, id2, vp = (GEN)F->LP[ F->subFB[i] ]; GEN z = cgetg(3,t_VEC); z[1] = vp[1]; z[2] = vp[2]; id2 = cgetg(a+1,t_VEC); Id2[i] = (long)id2; id2[1] = (long)z; alg = cgetg(a+1,t_VEC); Alg[i] = (long)alg; alg[1] = un; vp = prime_to_ideal(nf,vp); for (j=2; j<=a; j++) { GEN J = red(nf, idealmulh(nf,vp,(GEN)id2[j-1]), &m); if (DEBUGLEVEL>1) fprintferr(" %ld",j); if (!J) { if (j == 2 && !red(nf, vp, &M)) { j = 1; m = M; } break; } if (gegal(J, (GEN)id2[j-1])) { j = 1; break; } id2[j] = (long)J; alg[j] = (long)m; } if (cache && j <= a) { /* vp^j principal */ long k; REL_t *rel = cache->last + 1; rel->R = col_0(F->KC); rel->nz = F->subFB[i]; rel->R[ rel->nz ] = j; for (k = 2; k < j; k++) m = element_mul(nf, m, (GEN)alg[k]); rel->m = gclone(m); rel->ex= NULL; cache->last = rel; } /* trouble with subFB: include ideal even though it's principal */ if (j == 1 && F->sfb_chg == sfb_UNSUITABLE) j = 2; setlg(id2, j); setlg(alg, j); Ord[i] = j; if (c < 64) c *= j; if (DEBUGLEVEL>1) fprintferr("\n"); } F->pow->id2 = gclone(Id2); F->pow->ord = gclone(Ord); F->pow->alg = gclone(Alg); avma = av; if (DEBUGLEVEL) msgtimer("powFBgen"); /* if c too small we'd better change the subFB soon */ F->sfb_chg = (c < 6)? sfb_UNSUITABLE: 0;}
F->pow->id2 = gclone(Id2); F->pow->ord = gclone(Ord); F->pow->alg = gclone(Alg); avma = av;
new->prev = old; new->id2 = gclone(Id2); new->ord = gclone(Ord); new->alg = gclone(Alg); avma = av;
powFBgen(FB_t *F, RELCACHE_t *cache, GEN nf){ const int a = 1<<RANDOM_BITS; pari_sp av = avma; long i, j, c = 1, n = lg(F->subFB); GEN Id2, Alg, Ord; if (DEBUGLEVEL) fprintferr("Computing powers for subFB: %Z\n",F->subFB); F->pow = (powFB_t*) gpmalloc(sizeof(powFB_t)); Id2 = cgetg(n, t_VEC); Alg = cgetg(n, t_VEC); Ord = cgetg(n, t_VECSMALL); F->pow->arc = NULL; if (cache) pre_allocate(cache, n); for (i=1; i<n; i++) { GEN M, m, alg, id2, vp = (GEN)F->LP[ F->subFB[i] ]; GEN z = cgetg(3,t_VEC); z[1] = vp[1]; z[2] = vp[2]; id2 = cgetg(a+1,t_VEC); Id2[i] = (long)id2; id2[1] = (long)z; alg = cgetg(a+1,t_VEC); Alg[i] = (long)alg; alg[1] = un; vp = prime_to_ideal(nf,vp); for (j=2; j<=a; j++) { GEN J = red(nf, idealmulh(nf,vp,(GEN)id2[j-1]), &m); if (DEBUGLEVEL>1) fprintferr(" %ld",j); if (!J) { if (j == 2 && !red(nf, vp, &M)) { j = 1; m = M; } break; } if (gegal(J, (GEN)id2[j-1])) { j = 1; break; } id2[j] = (long)J; alg[j] = (long)m; } if (cache && j <= a) { /* vp^j principal */ long k; REL_t *rel = cache->last + 1; rel->R = col_0(F->KC); rel->nz = F->subFB[i]; rel->R[ rel->nz ] = j; for (k = 2; k < j; k++) m = element_mul(nf, m, (GEN)alg[k]); rel->m = gclone(m); rel->ex= NULL; cache->last = rel; } /* trouble with subFB: include ideal even though it's principal */ if (j == 1 && F->sfb_chg == sfb_UNSUITABLE) j = 2; setlg(id2, j); setlg(alg, j); Ord[i] = j; if (c < 64) c *= j; if (DEBUGLEVEL>1) fprintferr("\n"); } F->pow->id2 = gclone(Id2); F->pow->ord = gclone(Ord); F->pow->alg = gclone(Alg); avma = av; if (DEBUGLEVEL) msgtimer("powFBgen"); /* if c too small we'd better change the subFB soon */ F->sfb_chg = (c < 6)? sfb_UNSUITABLE: 0;}
F->newpow = 0;
powFBgen(FB_t *F, RELCACHE_t *cache, GEN nf){ const int a = 1<<RANDOM_BITS; pari_sp av = avma; long i, j, c = 1, n = lg(F->subFB); GEN Id2, Alg, Ord; if (DEBUGLEVEL) fprintferr("Computing powers for subFB: %Z\n",F->subFB); F->pow = (powFB_t*) gpmalloc(sizeof(powFB_t)); Id2 = cgetg(n, t_VEC); Alg = cgetg(n, t_VEC); Ord = cgetg(n, t_VECSMALL); F->pow->arc = NULL; if (cache) pre_allocate(cache, n); for (i=1; i<n; i++) { GEN M, m, alg, id2, vp = (GEN)F->LP[ F->subFB[i] ]; GEN z = cgetg(3,t_VEC); z[1] = vp[1]; z[2] = vp[2]; id2 = cgetg(a+1,t_VEC); Id2[i] = (long)id2; id2[1] = (long)z; alg = cgetg(a+1,t_VEC); Alg[i] = (long)alg; alg[1] = un; vp = prime_to_ideal(nf,vp); for (j=2; j<=a; j++) { GEN J = red(nf, idealmulh(nf,vp,(GEN)id2[j-1]), &m); if (DEBUGLEVEL>1) fprintferr(" %ld",j); if (!J) { if (j == 2 && !red(nf, vp, &M)) { j = 1; m = M; } break; } if (gegal(J, (GEN)id2[j-1])) { j = 1; break; } id2[j] = (long)J; alg[j] = (long)m; } if (cache && j <= a) { /* vp^j principal */ long k; REL_t *rel = cache->last + 1; rel->R = col_0(F->KC); rel->nz = F->subFB[i]; rel->R[ rel->nz ] = j; for (k = 2; k < j; k++) m = element_mul(nf, m, (GEN)alg[k]); rel->m = gclone(m); rel->ex= NULL; cache->last = rel; } /* trouble with subFB: include ideal even though it's principal */ if (j == 1 && F->sfb_chg == sfb_UNSUITABLE) j = 2; setlg(id2, j); setlg(alg, j); Ord[i] = j; if (c < 64) c *= j; if (DEBUGLEVEL>1) fprintferr("\n"); } F->pow->id2 = gclone(Id2); F->pow->ord = gclone(Ord); F->pow->alg = gclone(Alg); avma = av; if (DEBUGLEVEL) msgtimer("powFBgen"); /* if c too small we'd better change the subFB soon */ F->sfb_chg = (c < 6)? sfb_UNSUITABLE: 0;}
GEN p1 = n+2, y = x;
GEN p1 = n+2, y;
Fp_pow_mod_pol(GEN x, GEN n, GEN pol, GEN p){ long m,i,j,av=avma, lim=stack_lim(av,1), vx = varn(x); GEN p1 = n+2, y = x; if (!signe(n)) return polun[vx]; if (signe(n)<0) { x=Fp_inv_mod_pol(x,pol,p); if (is_pm1(n)) return x;/*n=-1*/ } else if (is_pm1(n)) return gcopy(x);/*n=1*/ m = *p1; j=1+bfffo(m); m<<=j; j = BITS_IN_LONG-j; for (i=lgefint(n)-2;;) { for (; j; m<<=1,j--) { y = Fp_sqr_mod_pol(y,pol,p); if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[1]: Fp_pow_mod_pol"); y = gerepileupto(av, y); } if (m<0) y = Fp_mul_mod_pol(y,x,pol,p); if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[2]: Fp_pow_mod_pol"); y = gerepileupto(av, y); } } if (--i == 0) break; m = *++p1, j = BITS_IN_LONG; } return gerepileupto(av,y);}
m = *p1;
m = *p1; y = x;
Fp_pow_mod_pol(GEN x, GEN n, GEN pol, GEN p){ long m,i,j,av=avma, lim=stack_lim(av,1), vx = varn(x); GEN p1 = n+2, y = x; if (!signe(n)) return polun[vx]; if (signe(n)<0) { x=Fp_inv_mod_pol(x,pol,p); if (is_pm1(n)) return x;/*n=-1*/ } else if (is_pm1(n)) return gcopy(x);/*n=1*/ m = *p1; j=1+bfffo(m); m<<=j; j = BITS_IN_LONG-j; for (i=lgefint(n)-2;;) { for (; j; m<<=1,j--) { y = Fp_sqr_mod_pol(y,pol,p); if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[1]: Fp_pow_mod_pol"); y = gerepileupto(av, y); } if (m<0) y = Fp_mul_mod_pol(y,x,pol,p); if (low_stack(lim, stack_lim(av,1))) { if(DEBUGMEM>1) err(warnmem,"[2]: Fp_pow_mod_pol"); y = gerepileupto(av, y); } } if (--i == 0) break; m = *++p1, j = BITS_IN_LONG; } return gerepileupto(av,y);}
long av=avma,tetpil,tx,tk=typ(k),lx,i,e;
ulong av = avma, tetpil; long tx,tk=typ(k),lx,i,e;
bestappr(GEN x, GEN k){ long av=avma,tetpil,tx,tk=typ(k),lx,i,e; GEN p0,p1,p,q0,q1,q,a,y; if (tk != t_INT) { if (tk != t_REAL && !is_frac_t(tk)) err(talker,"incorrect bound type in bestappr"); k = gcvtoi(k,&e); } if (signe(k) <= 0) k=gun; tx=typ(x); if (tx == t_FRACN) x = gred(x); switch(tx) { case t_INT: if (av==avma) return icopy(x); tetpil=avma; return gerepile(av,tetpil,icopy(x)); case t_FRAC: if (cmpii((GEN)x[2],k) <= 0) { if (av==avma) return gcopy(x); tetpil=avma; return gerepile(av,tetpil,gcopy(x)); } case t_REAL: p1=gun; p0=gfloor(x); q1=gzero; q0=gun; a=p0; while (gcmp(q0,k)<=0) { x = gsub(x,a); if (gcmp0(x)) { p1=p0; q1=q0; break; } x = ginv(x); a = (gcmp(x,k)<0)? gfloor(x): k; p = addii(mulii(a,p0),p1); p1=p0; p0=p; q = addii(mulii(a,q0),q1); q1=q0; q0=q; } tetpil=avma; return gerepile(av,tetpil,gdiv(p1,q1)); case t_COMPLEX: case t_POL: case t_SER: case t_RFRAC: case t_RFRACN: case t_VEC: case t_COL: case t_MAT: lx = (tx==t_POL)? lgef(x): lg(x); y=cgetg(lx,tx); for (i=1; i<lontyp[tx]; i++) y[i]=x[i]; for ( ; i<lx; i++) y[i]=(long)bestappr((GEN)x[i],k); return y; } err(typeer,"bestappr"); return NULL; /* not reached */}
new_line->level = -1;
Line_Control *AllocateLine( void ){ Line_Control *new_line; new_line = (Line_Control *) _Chain_Get( &Line_Pool ); if ( !new_line ) { FillLinePool(); new_line = (Line_Control *) _Chain_Get( &Line_Pool ); assert( new_line ); } /* * This is commented out because although it is helpful during debug, * it consumes a significant percentage of the program's execution time. memset( new_line->Contents, '\0', sizeof( new_line->Contents ) );*/ new_line->number = -1; new_line->keyword = UNUSED; new_line->format = NO_EXTRA_FORMATTING_INFO; new_line->Node.next = NULL; new_line->Node.previous = NULL; return new_line;}
unsigned32 cln
uint32_t cln
fat_cluster_num_to_sector512_num( rtems_filesystem_mount_table_entry_t *mt_entry, unsigned32 cln ){ fat_fs_info_t *fs_info = mt_entry->fs_info; if (cln == 1) return 1; return (fat_cluster_num_to_sector_num(mt_entry, cln) << fs_info->vol.sec_mul);}
int fd, void *buf, int len
int dd_fd, char *dd_buf, int dd_len
int getdents( int fd, void *buf, int len){ return -1;}
return -1;
rtems_libio_t *iop; rtems_filesystem_location_info_t loc; iop = rtems_libio_iop( dd_fd ); loc = iop->pathinfo; if ( !loc.ops->node_type ) set_errno_and_return_minus_one( ENOTSUP ); if ( (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) set_errno_and_return_minus_one( ENOTDIR ); if ( !iop->handlers->read ) set_errno_and_return_minus_one( ENOTSUP ); return (*iop->handlers->read)( iop, dd_buf, dd_len );
int getdents( int fd, void *buf, int len){ return -1;}
d = mppgcd(a,b);
d = gcdii(a,b);
bestappr_mod(GEN x, GEN A, GEN B){ long i,lx,tx; GEN y; tx = typ(x); switch(tx) { case t_INTMOD: { pari_sp av = avma; GEN a,b,d, t = cgetg(3, t_FRAC); if (! ratlift((GEN)x[2], (GEN)x[1], &a,&b,A,B)) return NULL; if (is_pm1(b)) return icopy_av(a, (GEN)av); d = mppgcd(a,b); if (!is_pm1(d)) { avma = av; return NULL; } cgiv(d); t[1] = (long)a; t[2] = (long)b; return t; } case t_COMPLEX: case t_POL: case t_SER: case t_RFRAC: case t_VEC: case t_COL: case t_MAT: y = init_gen_op(x, tx, &lx, &i); for (; i<lx; i++) { GEN t = bestappr_mod((GEN)x[i],A,B); if (!t) return NULL; y[i] = (long)t; } return y; } err(typeer,"bestappr0"); return NULL; /* not reached */}
if (!M0) avma = av; else M0 = gerepileupto(av, gcopy(M0));
if (!M0) avma = av; else M0 = gerepilecopy(av, M0);
compute_M0(GEN M_star,long N){ long m1,m2,n1,n2,n3,k,kk,lr,lr1,lr2,i,j,l,vx,vy,vz,vM,prec; GEN pol,p1,p2,p3,p4,p5,p6,p7,p8,p9,u,v,w,r,r1,r2,M0,M0_pro,S,P,M; GEN f1,f2,f3,g1,g2,g3,pg1,pg2,pg3,pf1,pf2,pf3,X,Y,Z; long bitprec = 24, PREC = gprecision(M_star); if (N==2) return gmul2n(gsqr(gach(gmul2n(M_star,-1),PREC)), -1); vM = fetch_var(); M = polx[vM]; vz = fetch_var(); Z = polx[vz]; vy = fetch_var(); Y = polx[vy]; vx = fetch_var(); X = polx[vx]; PREC = PREC>>1; if (!PREC) PREC = DEFAULTPREC; M0 = NULL; m1 = N/3; for (n1=1; n1<=m1; n1++) { m2 = (N-n1)>>1; for (n2=n1; n2<=m2; n2++) { long av = avma; n3=N-n1-n2; prec=PREC; if (n1==n2 && n1==n3) /* n1 = n2 = n3 = m1 = N/3 */ { p1=gdivgs(M_star,m1); p2=gaddsg(1,p1); p3=gsubgs(p1,3); p4=gsqrt(gmul(p2,p3),prec); p5=gsubgs(p1,1); u=gun; v=gmul2n(gadd(p5,p4),-1); w=gmul2n(gsub(p5,p4),-1); M0_pro=gmul2n(gmulsg(m1,gadd(gsqr(glog(v,prec)),gsqr(glog(w,prec)))),-2); if (DEBUGLEVEL>2) { fprintferr("[ %ld, %ld, %ld ]: %Z\n",n1,n2,n3,gprec_w(M0_pro,3)); flusherr(); } if (!M0 || gcmp(M0_pro,M0)<0) M0 = M0_pro; } else if (n1==n2 || n2==n3) { /* n3 > N/3 >= n1 */ k = n2; kk = N-2*k; p2=gsub(M_star,gmulgs(X,k)); p3=gmul(gpuigs(stoi(kk),kk),gpuigs(gsubgs(gmul(M_star,p2),kk*kk),k)); pol=gsub(p3,gmul(gmul(gpuigs(stoi(k),k),gpuigs(X,k)),gpuigs(p2,N-k))); prec=gprecision(pol); if (!prec) prec = MEDDEFAULTPREC; r=roots(pol,prec); lr = lg(r); for (i=1; i<lr; i++) { if (is_complex((GEN)r[i], bitprec) || signe(S = greal((GEN)r[i])) <= 0) continue; p4=gsub(M_star,gmulsg(k,S)); P=gdiv(gmul(gmulsg(k,S),p4),gsubgs(gmul(M_star,p4),kk*kk)); p5=gsub(gsqr(S),gmul2n(P,2)); if (gsigne(p5) < 0) continue; p6=gsqrt(p5,prec); v=gmul2n(gsub(S,p6),-1); if (gsigne(v) <= 0) continue; u=gmul2n(gadd(S,p6),-1); w=gpui(P,gdivgs(stoi(-k),kk),prec); p6=gmulsg(k,gadd(gsqr(glog(u,prec)),gsqr(glog(v,prec)))); M0_pro=gmul2n(gadd(p6,gmulsg(kk,gsqr(glog(w,prec)))),-2); if (DEBUGLEVEL>2) { fprintferr("[ %ld, %ld, %ld ]: %Z\n",n1,n2,n3,gprec_w(M0_pro,3)); flusherr(); } if (!M0 || gcmp(M0_pro,M0)<0) M0 = M0_pro; } } else { f1 = gsub(gadd(gmulsg(n1,X),gadd(gmulsg(n2,Y),gmulsg(n3,Z))), M); f2 = gmulsg(n1,gmul(Y,Z)); f2 = gadd(f2,gmulsg(n2,gmul(X,Z))); f2 = gadd(f2,gmulsg(n3,gmul(X,Y))); f2 = gsub(f2,gmul(M,gmul(X,gmul(Y,Z)))); f3 = gsub(gmul(gpuigs(X,n1),gmul(gpuigs(Y,n2),gpuigs(Z,n3))), gun); /* f1 = n1 X + n2 Y + n3 Z - M */ /* f2 = n1 YZ + n2 XZ + n3 XY */ /* f3 = X^n1 Y^n2 Z^n3 - 1*/ g1=subres(f1,f2); g1=gdiv(g1,content(g1)); g2=subres(f1,f3); g2=gdiv(g2,content(g2)); g3=subres(g1,g2); g3=gdiv(g3,content(g3)); pf1=gsubst(f1,vM,M_star); pg1=gsubst(g1,vM,M_star); pf2=gsubst(f2,vM,M_star); pg2=gsubst(g2,vM,M_star); pf3=gsubst(f3,vM,M_star); pg3=gsubst(g3,vM,M_star); prec=gprecision(pg3); if (!prec) prec = MEDDEFAULTPREC; r=roots(pg3,prec); lr = lg(r); for (i=1; i<lr; i++) { if (is_complex((GEN)r[i], bitprec) || signe(w = greal((GEN)r[i])) <= 0) continue; p1=gsubst(pg1,vz,w); p2=gsubst(pg2,vz,w); p3=gsubst(pf1,vz,w); p4=gsubst(pf2,vz,w); p5=gsubst(pf3,vz,w); prec=gprecision(p1); if (!prec) prec = MEDDEFAULTPREC; r1 = roots(p1,prec); lr1 = lg(r1); for (j=1; j<lr1; j++) { if (is_complex((GEN)r1[j], bitprec) || signe(v = greal((GEN)r1[j])) <= 0 || !is_zero(gsubst(p2,vy,v), bitprec)) continue; p7=gsubst(p3,vy,v); p8=gsubst(p4,vy,v); p9=gsubst(p5,vy,v); prec=gprecision(p7); if (!prec) prec = MEDDEFAULTPREC; r2 = roots(p7,prec); lr2 = lg(r2); for (l=1; l<lr2; l++) { if (is_complex((GEN)r2[l], bitprec) || signe(u = greal((GEN)r2[l])) <= 0 || !is_zero(gsubst(p8,vx,u), bitprec) || !is_zero(gsubst(p9,vx,u), bitprec)) continue; M0_pro = gmulsg(n1,gsqr(mplog(u))); M0_pro = gadd(M0_pro, gmulsg(n2,gsqr(mplog(v)))); M0_pro = gadd(M0_pro, gmulsg(n3,gsqr(mplog(w)))); M0_pro = gmul2n(M0_pro,-2); if (DEBUGLEVEL>2) { fprintferr("[ %ld, %ld, %ld ]: %Z\n",n1,n2,n3,gprec_w(M0_pro,3)); flusherr(); } if (!M0 || gcmp(M0_pro,M0) < 0) M0 = M0_pro; } } } } if (!M0) avma = av; else M0 = gerepileupto(av, gcopy(M0)); } } for (i=1;i<=4;i++) delete_var(); return M0? M0: gzero;}
powsubFBgen(nf,subFB,CBUCHG+1,PRECREG,PRECREGINT);
powsubFBgen(nf,subFB,CBUCHG+1,PRECREG);
buchall(GEN P,GEN gcbach,GEN gcbach2,GEN gRELSUP,GEN gborne,long nbrelpid, long minsFB,long flun,long prec){ long av = avma,av0,av1,limpile,i,j,k,ss,cglob,lgsub; long N,R1,R2,RU,PRECREG,PRECREGINT,KCCO,KCCOPRO,RELSUP; long extrarel,nlze,sreg,nrelsup,nreldep,phase,slim,matcopymax; long first = 1, sfb_increase = 0, sfb_trials = 0, precdouble = 0; long **mat,**matcopy,*ex; double cbach,cbach2,drc,LOGD2,lim,LIMC,LIMC2; GEN p1,p2,vecT2,fu,zu,nf,LLLnf,D,xarch,W,reg,lfun,z,clh,vperm,subFB; GEN B,C,c1,sublambda,pdep,parch,liste,invp,clg1,clg2; GEN CHANGE=NULL, extramat=NULL, extraC=NULL, list_jideal = NULL; char *precpb = NULL; if (DEBUGLEVEL) timer2(); if (typ(P)==t_POL) nf = NULL; else { nf=checknf(P); P=(GEN)nf[1]; } if (typ(gRELSUP)!=t_INT) gRELSUP=gtrunc(gRELSUP); RELSUP = itos(gRELSUP); if (RELSUP<=0) err(talker,"not enough relations in bnfxxx"); /* Initializations */ fu = NULL; KCCOPRO = extrarel = 0; /* gcc -Wall */ N=lgef(P)-3; PRECREG = max(BIGDEFAULTPREC,prec); if (!nf) { nf=initalgall0(P, nf_REGULAR, PRECREG); if (lg(nf)==3) /* P was a non-monic polynomial, nfinit changed it */ { CHANGE=(GEN)nf[2]; nf=(GEN)nf[1]; } if (DEBUGLEVEL) msgtimer("initalg"); } if (N<=1) return buchall_for_degree_one_pol(nf,CHANGE,flun); zu=rootsof1(nf); zu[2] = lmul((GEN)nf[7],(GEN)zu[2]); if (DEBUGLEVEL) msgtimer("rootsof1"); R1=itos(gmael(nf,2,1)); R2=(N-R1)>>1; RU=R1+R2; D=(GEN)nf[3]; drc=fabs(gtodouble(D)); LOGD2=log(drc); LOGD2 = LOGD2*LOGD2; lim = exp(-(double)N) * sqrt(2*PI*N*drc) * pow(4/PI,(double)R2); if (lim < 3.) lim = 3.; cbach = min(12., gtodouble(gcbach)); cbach /= 2; cbach2 = gtodouble(gcbach2); if (DEBUGLEVEL) { fprintferr("N = %ld, R1 = %ld, R2 = %ld, RU = %ld\n",N,R1,R2,RU); fprintferr("D = %Z\n",D); } av0 = avma; matcopy = NULL; FB = powsubFB = NULL;INCREASEGEN: if (precpb) { precdouble++; PRECREG=(PRECREG<<1)-2; if (DEBUGLEVEL) { char str[64]; sprintf(str,"buchall (%s)",precpb); err(warnprec,str,PRECREG); } precpb = NULL; avma = av0; nf = nfnewprec(nf,PRECREG); av0 = avma; } else cbach = check_bach(cbach,12.); if (first) first = 0; else { desallocate(matcopy); avma = av0; } /* T2-LLL-reduce nf.zk */ LLLnf = get_LLLnf(nf, PRECREG); if (!LLLnf) { precpb = "LLLnf"; goto INCREASEGEN; } sfb_trials = sfb_increase = 0; nreldep = nrelsup = 0; LIMC = cbach*LOGD2; if (LIMC < 20.) LIMC = 20.; LIMC2=max(3. * N, max(cbach,cbach2)*LOGD2); if (LIMC2 < LIMC) LIMC2=LIMC; if (DEBUGLEVEL) { fprintferr("LIMC = %.1f, LIMC2 = %.1f\n",LIMC,LIMC2); } /* initialize FB, [sub]vperm */ lfun = FBgen(nf,(long)LIMC2,(long)LIMC); if (!lfun) goto INCREASEGEN; vperm = cgetg(lg(vectbase), t_VECSMALL); subFB = subFBgen(N,(long)min(lim,LIMC2), minsFB, vperm, &ss); if (!subFB) goto INCREASEGEN; lgsub = lg(subFB); ex = cgetg(lgsub,t_VECSMALL); PRECREGINT = DEFAULTPREC + ((expi(D)*(lgsub-2)+((N*N)>>2))>>TWOPOTBITS_IN_LONG); if (!precdouble) PRECREG = max(prec+1, PRECREGINT); else if (PRECREG < PRECREGINT) PRECREG = PRECREGINT; KCCO = KC+RU-1 + max(ss,RELSUP); if (DEBUGLEVEL) { fprintferr("nbrelsup = %ld, ss = %ld, ",RELSUP,ss); fprintferr("KCZ = %ld, KC = %ld, KCCO = %ld \n",KCZ,KC,KCCO); flusherr(); } mat=(long**)gpmalloc(sizeof(long*)*(KCCO+1)); setlg(mat, KCCO+1); C = cgetg(KCCO+1,t_MAT); cglob=0; /* trivial relations */ p2 = zerocol(RU); for (i=1; i<=KCZ; i++) { GEN P = idealbase[i]; if (isclone(P)) { /* all prime divisors in FB */ unsetisclone(P); cglob++; C[cglob] = (long)p2; mat[cglob] = p1 = col_0(KC); k = numideal[FB[i]]; p1[0] = k+1; /* for already_found_relation */ p1 += k; for (j=lg(P)-1; j; j--) p1[j] = itos(gmael(P,j,3)); } } /* initialize for other relations */ for (i=cglob+1; i<=KCCO; i++) { mat[i] = col_0(KC); C[i] = (long) (p1 = cgetg(RU+1,t_COL)); for (j=1; j<=RU; j++) { p2=cgetg(3,t_COMPLEX); p2[1]=lgetr(PRECREG); p2[2]=lgetr(PRECREG); p1[j]=(long)p2; } } if (DEBUGLEVEL) fprintferr("After trivial relations, cglob = %ld\n",cglob); av1 = avma; liste = cgetg(KC+1,t_VECSMALL); for (i=1; i<=KC; i++) liste[i]=0; invp = relationrank(mat,cglob,liste); /* relations through elements of small norm */ cglob = small_norm_for_buchall(cglob,mat,C,KCCO,(long)LIMC, PRECREG,nf, gborne,nbrelpid,invp,liste,LLLnf); if (cglob < 0) { for (j=1; j<=KCCO; j++) free(mat[j]); free(mat); precpb = "small_norm"; goto INCREASEGEN; } avma = av1; limpile=stack_lim(av1,1); slim = KCCO; phase = 0; nlze = matcopymax = 0; /* for lint */ vecT2 = NULL; /* random relations */ if (cglob == KCCO) /* enough relations, initialize nevertheless */ ((void(*)(long))random_relation)(-1); else { GEN maarch; long **ma; if (DEBUGLEVEL) { fprintferr("\n#### Looking for random relations\n"); flusherr(); } LABELINT: if (sfb_increase) { /* increase subFB */ sfb_increase = 0; if (++sfb_trials >= SFB_MAX) goto INCREASEGEN; subFB = subFBgen(N, (long)min(lim,LIMC2), lgsub-1+SFB_STEP, NULL, &ss); if (!subFB) goto INCREASEGEN; if (DEBUGLEVEL) fprintferr("*** Increasing sub factor base\n"); powsubFB = NULL; nreldep = nrelsup = 0; lgsub = lg(subFB); } if (phase == 0) { ma = mat; maarch = C; } else /* reduced the relation matrix at least once */ { extrarel = nlze; if (extrarel < MIN_EXTRA) extrarel = MIN_EXTRA; slim = cglob+extrarel; setlg(extraC,extrarel+1); setlg(extramat,extrarel+1); if (slim > matcopymax) { matcopy = (long**)gprealloc(matcopy, (2*slim+1) * sizeof(long*), (matcopymax+1) * sizeof(long*)); matcopymax = 2 * slim; } setlg(matcopy,slim+1); if (DEBUGLEVEL) fprintferr("\n(need %ld more relation%s)\n", extrarel, (extrarel==1)?"":"s"); for (j=cglob+1; j<=slim; j++) matcopy[j] = col_0(KC); maarch = extraC - cglob; /* start at 0, the others at cglob */ ma = matcopy; } if (!vecT2) { vecT2 = compute_vecT2(RU,nf); av1 = avma; } if (!powsubFB) { powsubFBgen(nf,subFB,CBUCHG+1,PRECREG,PRECREGINT); av1 = avma; } ss = random_relation(phase,cglob,slim,(long)LIMC,PRECREG,PRECREGINT, nf,subFB,vecT2,ma,maarch,ex,list_jideal); if (ss < 0) /* could not find relations */ { if (phase == 0) { for (j=1; j<=KCCO; j++) free(mat[j]); free(mat); } if (ss != -1) precpb = "random_relation"; /* precision pb */ goto INCREASEGEN; } if (DEBUGLEVEL > 2) dbg_outrel(phase,cglob,vperm,ma,maarch); if (phase) for (j=1; j<=extrarel; j++) { long *c = matcopy[cglob+j]; GEN *g = (GEN*) extramat[j]; for (k=1; k<=KC; k++) g[k] = stoi(c[vperm[k]]); } cglob = ss; } /* reduce relation matrices */ if (phase == 0) /* never reduced before */ { matcopymax = 10*KCCO + MAXRELSUP; matcopy = (long**)gpmalloc(sizeof(long*)*(matcopymax + 1)); setlg(matcopy, KCCO+1); for (j=1; j<=KCCO; j++) matcopy[j] = col_dup(KC,mat[j]); W = hnfspec(mat,vperm,&pdep,&B,&C,lgsub-1); for (j=1; j<=KCCO; j++) free(mat[j]); free(mat); KCCOPRO = KCCO; phase = 1; /* keep some room for the extra relation. We will update matrix size when * extrarel goes down */ nlze = lg(pdep)>1? lg(pdep[1])-1: lg(B[1])-1; if (nlze) { list_jideal = cgetg(nlze+1, t_VECSMALL); for (i=1; i<=nlze; i++) list_jideal[i] = vperm[i]; } extrarel = nlze; /* in case the regulator is 0 */ if (extrarel < MIN_EXTRA) extrarel = MIN_EXTRA; extramat =cgetg(extrarel+1,t_MAT); extraC=cgetg(extrarel+1,t_MAT); for (j=1; j<=extrarel; j++) { extramat[j]=lgetg(KC+1,t_COL); extraC[j]=lgetg(RU+1,t_COL); for (i=1; i<=RU; i++) { p1 = cgetg(3,t_COMPLEX); mael(extraC,j,i)=(long)p1; p1[1]=lgetr(PRECREG); p1[2]=lgetr(PRECREG); } } } else { list_jideal = NULL; if (low_stack(limpile, stack_lim(av1,1))) { GEN *gptr[6]; if(DEBUGMEM>1) err(warnmem,"buchall"); gptr[0]=&W; gptr[1]=&C; gptr[2]=&B; gptr[3]=&pdep; gptr[4]=&extramat; gptr[5]=&extraC; gerepilemany(av1,gptr,6); } W = hnfadd(W,vperm,&pdep,&B,&C, extramat,extraC); nlze = lg(pdep)>1? lg(pdep[1])-1: lg(B[1])-1;#if 0 /* useless now: rank nearly maximal. Random relations are preferable */ if (nlze) { list_jideal = cgetg(nlze+1, t_VECSMALL); for (i=1; i<=nlze; i++) list_jideal[i] = vperm[i]; }#endif KCCOPRO += extrarel; if (nlze && ++nreldep > MAXRELSUP) { sfb_increase=1; goto LABELINT; } } if (nlze) goto LABELINT; /* dependent rows */ /* first attempt at regulator for the check */ sreg = KCCOPRO - (lg(B)-1) - (lg(W)-1); /* = zc (cf hnffinal) */ xarch = cgetg(sreg+1,t_MAT); /* cols corresponding to units */ for (j=1; j<=sreg; j++) xarch[j] = C[j]; reg = compute_multiple_of_R(xarch,RU,N,&sublambda); if (!reg) { /* not full rank for units */ if (DEBUGLEVEL) fprintferr("regulator is zero.\n"); if (++nrelsup > MAXRELSUP) goto INCREASEGEN; nlze=MIN_EXTRA; goto LABELINT; } /* anticipate precision problems */ if (!sublambda) { precpb = "bestappr"; goto INCREASEGEN; } /* class number */ clh = dethnf_i(W); if (DEBUGLEVEL) fprintferr("\n#### Tentative class number: %Z\n", clh); /* check */ z = mulrr(lfun,gmul(gmul2n(gpuigs(shiftr(mppi(DEFAULTPREC),1),-R2),-R1), gsqrt(absi(D),DEFAULTPREC))); z = mulri(z,(GEN)zu[1]); /* z = Res (zeta_K, s = 1) * w D^(1/2) / [ 2^r1 (2pi)^r2 ] = h R */ p1 = gmul2n(divir(clh,z), 1); /* c1 should be close to 2, and not much smaller */ c1 = compute_check(sublambda,p1,&parch,&reg); /* precision problems? */ if (!c1 || gcmpgs(gmul2n(c1,1),3) < 0) { /* has to be a precision problem unless we cheat on Bach constant */ if (!precdouble) precpb = "compute_check"; goto INCREASEGEN; } if (gcmpgs(c1,3) > 0) { if (++nrelsup <= MAXRELSUP) { if (DEBUGLEVEL) { fprintferr("\n ***** check = %f\n",gtodouble(c1)/2); flusherr(); } nlze=MIN_EXTRA; goto LABELINT; } if (cbach<11.99) { sfb_increase=1; goto LABELINT; } err(warner,"suspicious check. Try to increase extra relations"); } if (KCZ2 > KCZ) { /* "be honest" */ if (!powsubFB) powsubFBgen(nf,subFB,CBUCHG+1,PRECREG,PRECREGINT); if (!be_honest(nf,subFB,RU,PRECREGINT)) goto INCREASEGEN; } /* fundamental units */ if (flun < 0 || flun > 1) { xarch = cleancol(gmul(xarch,parch),N,PRECREG); if (DEBUGLEVEL) msgtimer("cleancol"); } if (labs(flun) > 1) { fu = getfu(nf,&xarch,reg,flun,&k,PRECREG); if (!k && labs(flun) > 2) { precpb = "getfu"; goto INCREASEGEN; } } /* class group generators */ i = lg(C)-sreg; C += sreg; C[0] = evaltyp(t_MAT)|evallg(i); C = cleancol(C,N,PRECREG); class_group_gen(nf,W,C,vperm, &clg1, &clg2, PRECREGINT); c1 = gdiv(gmul(reg,clh), z); desallocate(matcopy); return gerepileupto(av, buchall_end(nf,CHANGE,flun,k,fu,clg1,clg2,reg,c1,zu,W,B,xarch,C,vectbase,vperm));}
u = lllint_marked(1, make_Tr(T->x, T->bas), 100, 1, &u,NULL,NULL);
u = lllfp_marked(1, make_Tr(T->x, T->bas), 100, 0, DEFAULTPREC, 1);
get_LLL_basis(nfbasic_t *T, GEN *pro){ GEN u; if (T->r1 != degpol(T->x)) u = get_red_G(T, pro); else { u = lllint_marked(1, make_Tr(T->x, T->bas), 100, 1, &u,NULL,NULL); if (!u) u = idmat(1); } return u;}
v1 = mulii(v1, mppgcd(d1,mppgcd((GEN)x[3],mppgcd((GEN)y[3],n))));
v1 = mulii(v1, gcdii(d1,gcdii((GEN)x[3],gcdii((GEN)y[3],n))));
comp_gen(GEN z,GEN x,GEN y){ GEN s, n, d, d1, x1, x2, y1, y2, v1, v2, c3, m, p1, r; if (x == y) { sq_gen(z,x); return; } s = shifti(addii((GEN)x[2],(GEN)y[2]),-1); n = subii((GEN)y[2],s); d = bezout((GEN)y[1],(GEN)x[1],&y1,&x1); d1 = bezout(s,d,&x2,&y2); if (gcmp1(d1)) { v1 = (GEN)x[1]; v2 = (GEN)y[1]; } else { v1 = diviiexact((GEN)x[1],d1); v2 = diviiexact((GEN)y[1],d1); v1 = mulii(v1, mppgcd(d1,mppgcd((GEN)x[3],mppgcd((GEN)y[3],n)))); } m = addii(mulii(mulii(y1,y2),n), mulii((GEN)y[3],x2)); setsigne(m,-signe(m)); r = modii(m,v1); p1 = mulii(v2,r); c3 = addii(mulii((GEN)y[3],d1), mulii(r,addii((GEN)y[2],p1))); z[1] = lmulii(v1,v2); z[2] = laddii((GEN)y[2], shifti(p1,1)); z[3] = ldivii(c3,v1);}
long bitprec2,n=lgef(p)-3,j,e,av;
long bitprec0, bitprec2,n=lgef(p)-3,i,e,av;
all_roots(GEN p, long bitprec){ GEN q,roots_pol,m; long bitprec2,n=lgef(p)-3,j,e,av; roots_pol=cgetg(n+1,t_VEC); av=avma; for (j=1; j<=10; j++) { setlg(roots_pol,1); e = 2*gexpo(cauchy_bound(p)); if (e<0) e=0; bitprec2=bitprec+(1<<j)*n+gexpo(p)-gexpo((GEN)p[2+n]) + (long)log2(n)+1+e; q=gmul(myrealun(bitprec2), mygprec(p,bitprec2)); m=split_complete(q,bitprec2,roots_pol); e = gexpo(gsub(mygprec_special(p,bitprec2),m)) - gexpo((GEN)q[2+n])+(long) log2((double)n)+1; if (e<-2*bitprec2) e=-2*bitprec2; /* to avoid e=-pariINFINITY */ if (e < 0 && a_posteriori_errors(q,roots_pol,e) < -bitprec) break; avma = av; } if (j > 10) err(bugparier,"all_roots"); return roots_pol;}
for (j=1; j<=10; j++)
e = 2*gexpo(cauchy_bound(p)); if (e<0) e=0; bitprec0=bitprec + gexpo(p) - gexpo((GEN)p[2+n]) + (long)log2(n) + 1 + e; for (i=1;; i++)
all_roots(GEN p, long bitprec){ GEN q,roots_pol,m; long bitprec2,n=lgef(p)-3,j,e,av; roots_pol=cgetg(n+1,t_VEC); av=avma; for (j=1; j<=10; j++) { setlg(roots_pol,1); e = 2*gexpo(cauchy_bound(p)); if (e<0) e=0; bitprec2=bitprec+(1<<j)*n+gexpo(p)-gexpo((GEN)p[2+n]) + (long)log2(n)+1+e; q=gmul(myrealun(bitprec2), mygprec(p,bitprec2)); m=split_complete(q,bitprec2,roots_pol); e = gexpo(gsub(mygprec_special(p,bitprec2),m)) - gexpo((GEN)q[2+n])+(long) log2((double)n)+1; if (e<-2*bitprec2) e=-2*bitprec2; /* to avoid e=-pariINFINITY */ if (e < 0 && a_posteriori_errors(q,roots_pol,e) < -bitprec) break; avma = av; } if (j > 10) err(bugparier,"all_roots"); return roots_pol;}
e = 2*gexpo(cauchy_bound(p)); if (e<0) e=0; bitprec2=bitprec+(1<<j)*n+gexpo(p)-gexpo((GEN)p[2+n]) + (long)log2(n)+1+e; q=gmul(myrealun(bitprec2), mygprec(p,bitprec2)); m=split_complete(q,bitprec2,roots_pol);
bitprec2 = bitprec0 + (1<<i)*n; q = gmul(myrealun(bitprec2), mygprec(p,bitprec2)); m = split_complete(q,bitprec2,roots_pol);
all_roots(GEN p, long bitprec){ GEN q,roots_pol,m; long bitprec2,n=lgef(p)-3,j,e,av; roots_pol=cgetg(n+1,t_VEC); av=avma; for (j=1; j<=10; j++) { setlg(roots_pol,1); e = 2*gexpo(cauchy_bound(p)); if (e<0) e=0; bitprec2=bitprec+(1<<j)*n+gexpo(p)-gexpo((GEN)p[2+n]) + (long)log2(n)+1+e; q=gmul(myrealun(bitprec2), mygprec(p,bitprec2)); m=split_complete(q,bitprec2,roots_pol); e = gexpo(gsub(mygprec_special(p,bitprec2),m)) - gexpo((GEN)q[2+n])+(long) log2((double)n)+1; if (e<-2*bitprec2) e=-2*bitprec2; /* to avoid e=-pariINFINITY */ if (e < 0 && a_posteriori_errors(q,roots_pol,e) < -bitprec) break; avma = av; } if (j > 10) err(bugparier,"all_roots"); return roots_pol;}
if (e < 0 && a_posteriori_errors(q,roots_pol,e) < -bitprec) break;
if (e < 0) { e = a_posteriori_errors(q,roots_pol,e); if (e < -bitprec) return roots_pol; } if (DEBUGLEVEL > 7) fprintferr("all_roots: restarting, i = %ld, e = %ld\n", i,e);
all_roots(GEN p, long bitprec){ GEN q,roots_pol,m; long bitprec2,n=lgef(p)-3,j,e,av; roots_pol=cgetg(n+1,t_VEC); av=avma; for (j=1; j<=10; j++) { setlg(roots_pol,1); e = 2*gexpo(cauchy_bound(p)); if (e<0) e=0; bitprec2=bitprec+(1<<j)*n+gexpo(p)-gexpo((GEN)p[2+n]) + (long)log2(n)+1+e; q=gmul(myrealun(bitprec2), mygprec(p,bitprec2)); m=split_complete(q,bitprec2,roots_pol); e = gexpo(gsub(mygprec_special(p,bitprec2),m)) - gexpo((GEN)q[2+n])+(long) log2((double)n)+1; if (e<-2*bitprec2) e=-2*bitprec2; /* to avoid e=-pariINFINITY */ if (e < 0 && a_posteriori_errors(q,roots_pol,e) < -bitprec) break; avma = av; } if (j > 10) err(bugparier,"all_roots"); return roots_pol;}
if (j > 10) err(bugparier,"all_roots"); return roots_pol;
all_roots(GEN p, long bitprec){ GEN q,roots_pol,m; long bitprec2,n=lgef(p)-3,j,e,av; roots_pol=cgetg(n+1,t_VEC); av=avma; for (j=1; j<=10; j++) { setlg(roots_pol,1); e = 2*gexpo(cauchy_bound(p)); if (e<0) e=0; bitprec2=bitprec+(1<<j)*n+gexpo(p)-gexpo((GEN)p[2+n]) + (long)log2(n)+1+e; q=gmul(myrealun(bitprec2), mygprec(p,bitprec2)); m=split_complete(q,bitprec2,roots_pol); e = gexpo(gsub(mygprec_special(p,bitprec2),m)) - gexpo((GEN)q[2+n])+(long) log2((double)n)+1; if (e<-2*bitprec2) e=-2*bitprec2; /* to avoid e=-pariINFINITY */ if (e < 0 && a_posteriori_errors(q,roots_pol,e) < -bitprec) break; avma = av; } if (j > 10) err(bugparier,"all_roots"); return roots_pol;}
unsigned32 Irql;
uint32_t Irql;
void DEBUG_puts( char *string){ char *s; unsigned32 Irql; rtems_interrupt_disable(Irql); for ( s = string ; *s ; s++ ) { Console_Port_Tbl[Console_Port_Minor].pDeviceFns-> deviceWritePolled(Console_Port_Minor, *s); } rtems_interrupt_enable(Irql);}
sunitrelnf=concatsp(gtrans(aux),sunitrelnf);
sunitrelnf=concatsp(aux,sunitrelnf);
rnfisnorm(GEN bnf,GEN ext,GEN x,long flag,long PREC){ long lgsunitrelnf,i,lbot, ltop = avma; GEN relnf,aux,vec,tors,xnf,H,Y,M,A,suni,sunitrelnf,sunitnormnf,prod; GEN res = cgetg(3,t_VEC), S1,S2; if (typ(ext)!=t_VEC || lg(ext)!=4) err (typeer,"bnfisnorm"); bnf = checkbnf(bnf); relnf = (GEN)ext[3]; if (gcmp0(x) || gcmp1(x) || (gcmp_1(x) && (degree((GEN)ext[1])&1))) { res[1]=lcopy(x); res[2]=un; return res; }/* construction de l'ensemble S des ideaux qui interviennent dans les solutions */ prod=gun; S1=S2=cgetg(1,t_VEC); if (!gcmp1(gmael3(relnf,8,1,1))) { GEN genclass=gmael3(relnf,8,1,3); vec=cgetg(1,t_VEC); for(i=1;i<lg(genclass);i++) if (!gcmp1(ggcd(gmael4(relnf,8,1,2,i), stoi(degree((GEN)ext[1]))))) vec=concatsp(vec,(GEN)factor(gmael3(genclass,i,1,1))[1]); vecconcat(bnf,relnf,vec,&prod,&S1,&S2); } if (flag>1) { for (i=2; i<=flag; i++) if (isprime(stoi(i)) && signe(resis(prod,i))) { prod=mulis(prod,i); S1=concatsp(S1,primedec(bnf,stoi(i))); S2=concatsp(S2,primedec(relnf,stoi(i))); } } else if (flag<0) vecconcat(bnf,relnf,(GEN)factor(stoi(-flag))[1],&prod,&S1,&S2); if (flag) { GEN normdiscrel=divii(gmael(relnf,7,3), gpuigs(gmael(bnf,7,3),lg(ext[1])-3)); vecconcat(bnf,relnf,(GEN) factor(absi(normdiscrel))[1], &prod,&S1,&S2); } vec=(GEN) idealfactor(bnf,x)[1]; aux=cgetg(2,t_VEC); for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S1=concatsp(S1,aux); } xnf=lift(x); xnf=gsubst(xnf,varn(xnf),(GEN)ext[2]); vec=(GEN) idealfactor(relnf,xnf)[1]; for (i=1; i<lg(vec); i++) if (signe(resii(prod,gmael(vec,i,1)))) { aux[1]=vec[i]; S2=concatsp(S2,aux); } res[1]=un; res[2]=(long)x; tors=cgetg(2,t_VEC); tors[1]=mael3(relnf,8,4,2); /* calcul sur les S-unites */ suni=bnfsunit(bnf,S1,PREC); A=lift(bnfissunit(bnf,suni,x)); sunitrelnf=(GEN) bnfsunit(relnf,S2,PREC)[1]; if (lg(sunitrelnf)>1) { sunitrelnf=lift(basistoalg(relnf,sunitrelnf)); sunitrelnf=concatsp(tors,sunitrelnf); } else sunitrelnf=tors; aux=(GEN)relnf[8]; if (lg(aux)>=6) aux=(GEN)aux[5]; else { aux=buchfu(relnf); if(gcmp0((GEN)aux[2])) err(talker,"please increase precision to have units in bnfisnorm"); aux=(GEN)aux[1]; } if (lg(aux)>1) sunitrelnf=concatsp(gtrans(aux),sunitrelnf); lgsunitrelnf=lg(sunitrelnf); M=cgetg(lgsunitrelnf+1,t_MAT); sunitnormnf=cgetg(lgsunitrelnf,t_VEC); for (i=1; i<lgsunitrelnf; i++) { sunitnormnf[i]=lnorm(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1])); M[i]=llift(bnfissunit(bnf,suni,(GEN) sunitnormnf[i])); } M[lgsunitrelnf]=lgetg(lg(A),t_COL); for (i=1; i<lg(A); i++) mael(M,lgsunitrelnf,i)=zero; mael(M,lgsunitrelnf,lg(mael(bnf,7,6))-1)=mael3(bnf,8,4,1); H=hnfall(M); Y=inverseimage(gmul(M,(GEN) H[2]),A); Y=gmul((GEN) H[2],Y); for (aux=(GEN)res[1],i=1; i<lgsunitrelnf; i++) aux=gmul(aux,gpuigs(gmodulcp((GEN) sunitrelnf[i],(GEN)ext[1]), itos(gfloor((GEN)Y[i])))); res[1]=(long)aux; res[2]=ldiv(x,gnorm(gmodulcp(lift(aux),(GEN)ext[1]))); lbot=avma; return gerepile(ltop,lbot,gcopy(res));}
if (!rnf && !k) return gerepileupto(av, gcopy(group));
if (!rnf && !k) return gerepilecopy(av, group);
rnfnormgroup0(GEN bnr, GEN polrel, GEN rnf){ long av=avma,i,j,reldeg,sizemat,p,pmax,nfac,k; GEN bnf,polreldisc,discnf,nf,raycl,group,detgroup,fa,greldeg; GEN contreld,primreld,reldisc,famo,ep,fac,col,p1,bd,upnf; byteptr d = diffptr + 1; /* start at p = 2 */ checkbnr(bnr); bnf=(GEN)bnr[1]; raycl=(GEN)bnr[5]; nf=(GEN)bnf[7]; polrel = fix_relative_pol(nf,polrel,1); if (typ(polrel)!=t_POL) err(typeer,"rnfnormgroup"); reldeg=degpol(polrel); /* reldeg-th powers are in norm group */ greldeg = stoi(reldeg); group = diagonal(gmod((GEN)raycl[2], greldeg)); for (i=1; i<lg(group); i++) if (!signe(gcoeff(group,i,i))) coeff(group,i,i) = (long)greldeg; detgroup = dethnf_i(group); k = cmpis(detgroup,reldeg); if (k<0) { if (rnf) return NULL; err(talker,"not an Abelian extension in rnfnormgroup?"); } if (!rnf && !k) return gerepileupto(av, gcopy(group)); polreldisc=discsr(polrel); if (rnf) { reldisc=gmael(rnf,3,1); upnf=nfinit0(gmael(rnf,11,1),1,DEFAULTPREC); } else { reldisc = idealhermite(nf,polreldisc); upnf = NULL; } reldisc = idealmul(nf, reldisc, gmael3(bnr,2,1,1)); contreld= content(reldisc); primreld= gcmp1(contreld)? reldisc: gdiv(reldisc, contreld); discnf = (GEN)nf[3]; k = degpol(nf[1]); bd = gmulsg(k, glog(absi(discnf), DEFAULTPREC)); bd = gadd(bd,glog(mpabs(det(reldisc)),DEFAULTPREC)); p1 = dbltor(reldeg * k * 2.5 + 5); bd = gfloor(gsqr(gadd(gmulsg(4,bd),p1))); pmax = is_bigint(bd)? 0: itos(bd); if (rnf) { if (DEBUGLEVEL) fprintferr("rnfnormgroup: bound for primes = %Z\n", bd); if (!pmax) err(warner,"rnfnormgroup: prime bound too large, can't certify"); } sizemat=lg(group)-1; for (p=2; !pmax || p < pmax; p += *d++) { long oldf = -1, lfa; /* If all pr are unramified and have the same residue degree, p =prod pr * and including last pr^f or p^f is the same, but the last isprincipal * is much easier! oldf is used to track this */ if (!*d) err(primer1); if (!smodis(contreld,p)) continue; /* all pr|p ramified */ fa = primedec(nf,stoi(p)); lfa = lg(fa)-1; for (i=1; i<=lfa; i++) { GEN pr = (GEN)fa[i]; long f; /* check decomposition of pr has Galois type */ if (element_val(nf,polreldisc,pr) != 0) { /* if pr ramified, we will have to use all (non-ram) P | pr */ if (idealval(nf,primreld,pr)!=0) { oldf = 0; continue; } famo=idealfactor(upnf,rnfidealup(rnf,pr)); ep=(GEN)famo[2]; fac=(GEN)famo[1]; nfac=lg(ep)-1; f = itos(gmael(fac,1,4)); for (j=1; j<=nfac; j++) { if (!gcmp1((GEN)ep[j])) err(bugparier,"rnfnormgroup"); if (itos(gmael(fac,j,4)) != f) { if (rnf) return NULL; err(talker,"non Galois extension in rnfnormgroup"); } } } else { famo=nffactormod(nf,polrel,pr); ep=(GEN)famo[2]; fac=(GEN)famo[1]; nfac=lg(ep)-1; f = degpol((GEN)fac[1]); for (j=1; j<=nfac; j++) { if (!gcmp1((GEN)ep[j])) err(bugparier,"rnfnormgroup"); if (degpol(fac[j]) != f) { if (rnf) return NULL; err(talker,"non Galois extension in rnfnormgroup"); } } } if (oldf < 0) oldf = f; else if (oldf != f) oldf = 0; if (f == reldeg) continue; /* reldeg-th powers already included */ if (oldf && i == lfa && !smodis(discnf, p)) pr = stoi(p); /* pr^f = N P, P | pr, hence is in norm group */ col = gmulsg(f, isprincipalrayall(bnr,pr,nf_REGULAR)); group = hnf(concatsp(group, col)); detgroup = dethnf_i(group); k = cmpis(detgroup,reldeg); if (k < 0) { if (rnf) return NULL; err(talker,"not an Abelian extension in rnfnormgroup"); } if (!rnf && !k) { cgiv(detgroup); return gerepileupto(av,group); } } } if (k>0) err(bugparier,"rnfnormgroup"); cgiv(detgroup); return gerepileupto(av,group);}
C = sort_vecpol(C);
C = sort_vecpol(C, &cmpii);
polcompositum0(GEN A, GEN B, long flall){ pari_sp av = avma; int same = (A == B || gegal(A,B)); long v, k; GEN C, D, LPRS; if (typ(A)!=t_POL || typ(B)!=t_POL) err(typeer,"polcompositum0"); if (degpol(A)<=0 || degpol(B)<=0) err(constpoler,"compositum"); v = varn(A); if (varn(B) != v) err(talker,"not the same variable in compositum"); A = Q_primpart(A); check_pol_int(A,"compositum"); if (!ZX_is_squarefree(A)) err(talker,"compositum: %Z inseparable", A); if (!same) { B = Q_primpart(B); check_pol_int(B,"compositum"); if (!ZX_is_squarefree(B)) err(talker,"compositum: %Z inseparable", B); } D = NULL; /* -Wall */ k = same? -1: 1; C = ZY_ZXY_resultant_all(A, B, &k, flall? &LPRS: NULL); if (same) { D = rescale_pol(A, stoi(1 - k)); C = gdivexact(C, D); } C = DDF2(C, 0); /* C = Res_Y (A, B(X + kY)) guaranteed squarefree */ if (same) C = concatsp(C, D); C = sort_vecpol(C); if (flall) { long i,l = lg(C); GEN w,a,b; /* a,b,c root of A,B,C = compositum, c = b - k a */ for (i=1; i<l; i++) { /* invmod possibly very costly */ a = gmul((GEN)LPRS[1], QX_invmod((GEN)LPRS[2], (GEN)C[i])); a = gneg_i(gmod(a, (GEN)C[i])); b = gadd(polx[v], gmulsg(k,a)); w = cgetg(5,t_VEC); /* [C, a, b, n ] */ w[1] = C[i]; w[2] = (long)to_polmod(a, (GEN)w[1]); w[3] = (long)to_polmod(b, (GEN)w[1]); w[4] = lstoi(-k); C[i] = (long)w; } } settyp(C, t_VEC); return gerepilecopy(av, C);}
int i,pass; unsigned long pi; PTE pte; long vsid; if (pt->active) return -1;
int i, pass; unsigned long pi; APte pte; long vsid; #ifdef DEBUG long saved_vsid = ovsid; #endif
triv121PgTblMap( Triv121PgTbl pt, long ovsid, unsigned long start, unsigned long numPages, unsigned attributes, unsigned protection ){int i,pass;unsigned long pi;PTE pte;long vsid; /* already activated - no change allowed */ if (pt->active) return -1; if (ovsid < 0) { /* use 1:1 mapping */ ovsid = VSID121(start); }#ifdef DEBUG PRINTF("Mapping %i (0x%x) pages at 0x%08x for VSID 0x%08x\n", (unsigned)numPages, (unsigned)numPages, (unsigned)start, (unsigned)vsid);#endif /* map in two passes. During the first pass, we try * to claim entries as needed. The 'slotFor()' routine * will 'mark' the claimed entries without 'valid'ating * them. * If the mapping fails, all claimed entries are unmarked * and we return the PI for which allocation failed. * * Once we know that the allocation would succeed, we * do a second pass; during the second pass, the PTE * is actually written. * */ for (pass=0; pass<2; pass++) { /* check if we would succeed during the first pass */ for (i=0, pi=PI121(start), vsid = ovsid; i<numPages; i++,pi++) { if ( pi >= 1<<LD_PI_SIZE ) { vsid++; pi = 0; } /* leave alone existing mappings for this EA */ if (!alreadyMapped(pt, vsid, pi)) { if (!(pte=slotFor(pt, vsid, pi))) { /* no free slot found for page index 'pi' */ unmarkAll(pt); return pi; } else { /* have a free slot; marked by slotFor() */ if (pass) { /* second pass; do the real work */ pte->vsid=vsid; /* H was set by slotFor() */ pte->api =API(pi); /* set up 1:1 mapping */ pte->rpn =((((unsigned long)vsid)&((1<<(LD_PHYS_SIZE-LD_SEG_SIZE))-1))<<LD_PI_SIZE) | pi; pte->wimg=attributes & 0xf; pte->pp=protection&0x3; /* mark it valid */ pte->v=1; pte->marked=0;#ifdef DEBUG /* add paranoia */ assert(alreadyMapped(pt, vsid, pi) == pte);#endif } } } } unmarkAll(pt); }#ifdef DEBUG { unsigned long failedat; CONSCHECK(-1); /* double check that the requested range is mapped */ failedat=triv121IsRangeMapped(start, start + (1<<LD_PG_SIZE)*numPages); if (0x0C0C != failedat) { PRINTF("triv121 mapping failed at 0x%08x\n",(unsigned)failedat); return PI121(failedat); } }#endif return TRIV121_MAP_SUCCESS; /* -1 !! */}
if (ovsid < 0) { ovsid = VSID121(start); }
if (TRIV121_121_VSID == ovsid) { ovsid = VSID121 (start); } else if (TRIV121_SEG_VSID == ovsid) { ovsid = seg2vsid (start); }
triv121PgTblMap( Triv121PgTbl pt, long ovsid, unsigned long start, unsigned long numPages, unsigned attributes, unsigned protection ){int i,pass;unsigned long pi;PTE pte;long vsid; /* already activated - no change allowed */ if (pt->active) return -1; if (ovsid < 0) { /* use 1:1 mapping */ ovsid = VSID121(start); }#ifdef DEBUG PRINTF("Mapping %i (0x%x) pages at 0x%08x for VSID 0x%08x\n", (unsigned)numPages, (unsigned)numPages, (unsigned)start, (unsigned)vsid);#endif /* map in two passes. During the first pass, we try * to claim entries as needed. The 'slotFor()' routine * will 'mark' the claimed entries without 'valid'ating * them. * If the mapping fails, all claimed entries are unmarked * and we return the PI for which allocation failed. * * Once we know that the allocation would succeed, we * do a second pass; during the second pass, the PTE * is actually written. * */ for (pass=0; pass<2; pass++) { /* check if we would succeed during the first pass */ for (i=0, pi=PI121(start), vsid = ovsid; i<numPages; i++,pi++) { if ( pi >= 1<<LD_PI_SIZE ) { vsid++; pi = 0; } /* leave alone existing mappings for this EA */ if (!alreadyMapped(pt, vsid, pi)) { if (!(pte=slotFor(pt, vsid, pi))) { /* no free slot found for page index 'pi' */ unmarkAll(pt); return pi; } else { /* have a free slot; marked by slotFor() */ if (pass) { /* second pass; do the real work */ pte->vsid=vsid; /* H was set by slotFor() */ pte->api =API(pi); /* set up 1:1 mapping */ pte->rpn =((((unsigned long)vsid)&((1<<(LD_PHYS_SIZE-LD_SEG_SIZE))-1))<<LD_PI_SIZE) | pi; pte->wimg=attributes & 0xf; pte->pp=protection&0x3; /* mark it valid */ pte->v=1; pte->marked=0;#ifdef DEBUG /* add paranoia */ assert(alreadyMapped(pt, vsid, pi) == pte);#endif } } } } unmarkAll(pt); }#ifdef DEBUG { unsigned long failedat; CONSCHECK(-1); /* double check that the requested range is mapped */ failedat=triv121IsRangeMapped(start, start + (1<<LD_PG_SIZE)*numPages); if (0x0C0C != failedat) { PRINTF("triv121 mapping failed at 0x%08x\n",(unsigned)failedat); return PI121(failedat); } }#endif return TRIV121_MAP_SUCCESS; /* -1 !! */}
PRINTF("Mapping %i (0x%x) pages at 0x%08x for VSID 0x%08x\n", (unsigned)numPages, (unsigned)numPages, (unsigned)start, (unsigned)vsid);
PRINTF ("Mapping %i (0x%x) pages at 0x%08x for VSID 0x%08x\n", (unsigned) numPages, (unsigned) numPages, (unsigned) start, (unsigned) ovsid);
triv121PgTblMap( Triv121PgTbl pt, long ovsid, unsigned long start, unsigned long numPages, unsigned attributes, unsigned protection ){int i,pass;unsigned long pi;PTE pte;long vsid; /* already activated - no change allowed */ if (pt->active) return -1; if (ovsid < 0) { /* use 1:1 mapping */ ovsid = VSID121(start); }#ifdef DEBUG PRINTF("Mapping %i (0x%x) pages at 0x%08x for VSID 0x%08x\n", (unsigned)numPages, (unsigned)numPages, (unsigned)start, (unsigned)vsid);#endif /* map in two passes. During the first pass, we try * to claim entries as needed. The 'slotFor()' routine * will 'mark' the claimed entries without 'valid'ating * them. * If the mapping fails, all claimed entries are unmarked * and we return the PI for which allocation failed. * * Once we know that the allocation would succeed, we * do a second pass; during the second pass, the PTE * is actually written. * */ for (pass=0; pass<2; pass++) { /* check if we would succeed during the first pass */ for (i=0, pi=PI121(start), vsid = ovsid; i<numPages; i++,pi++) { if ( pi >= 1<<LD_PI_SIZE ) { vsid++; pi = 0; } /* leave alone existing mappings for this EA */ if (!alreadyMapped(pt, vsid, pi)) { if (!(pte=slotFor(pt, vsid, pi))) { /* no free slot found for page index 'pi' */ unmarkAll(pt); return pi; } else { /* have a free slot; marked by slotFor() */ if (pass) { /* second pass; do the real work */ pte->vsid=vsid; /* H was set by slotFor() */ pte->api =API(pi); /* set up 1:1 mapping */ pte->rpn =((((unsigned long)vsid)&((1<<(LD_PHYS_SIZE-LD_SEG_SIZE))-1))<<LD_PI_SIZE) | pi; pte->wimg=attributes & 0xf; pte->pp=protection&0x3; /* mark it valid */ pte->v=1; pte->marked=0;#ifdef DEBUG /* add paranoia */ assert(alreadyMapped(pt, vsid, pi) == pte);#endif } } } } unmarkAll(pt); }#ifdef DEBUG { unsigned long failedat; CONSCHECK(-1); /* double check that the requested range is mapped */ failedat=triv121IsRangeMapped(start, start + (1<<LD_PG_SIZE)*numPages); if (0x0C0C != failedat) { PRINTF("triv121 mapping failed at 0x%08x\n",(unsigned)failedat); return PI121(failedat); } }#endif return TRIV121_MAP_SUCCESS; /* -1 !! */}
for (pass=0; pass<2; pass++) { for (i=0, pi=PI121(start), vsid = ovsid; i<numPages; i++,pi++) { if ( pi >= 1<<LD_PI_SIZE ) { vsid++; pi = 0; } if (!alreadyMapped(pt, vsid, pi)) { if (!(pte=slotFor(pt, vsid, pi))) { unmarkAll(pt); return pi; } else { if (pass) { pte->vsid=vsid; pte->api =API(pi); pte->rpn =((((unsigned long)vsid)&((1<<(LD_PHYS_SIZE-LD_SEG_SIZE))-1))<<LD_PI_SIZE) | pi; pte->wimg=attributes & 0xf; pte->pp=protection&0x3; pte->v=1; pte->marked=0;
for (pass = 0; pass < 2; pass++) { for (i = 0, pi = PI121 (start), vsid = ovsid; i < numPages; i++, pi++) { if (pi >= 1 << LD_PI_SIZE) { vsid++; pi = 0; } if (!alreadyMapped (pt, vsid, pi)) { if (!(pte = slotFor (pt, vsid, pi))) { unmarkAll (pt); return pi; } else { if (pass) { pte->vsid = vsid; pte->api = API (pi); pte->rpn = ((((unsigned long) vsid) & ((1 << (LD_PHYS_SIZE - LD_SEG_SIZE)) - 1)) << LD_PI_SIZE) | pi; pte->wimg = attributes & 0xf; pte->pp = protection & 0x3; pte->marked = 0; if (pt->active) { unsigned32 flags; rtems_interrupt_disable (flags); asm volatile ("eieio"); pte->v = 1; asm volatile ("sync"); rtems_interrupt_enable (flags); } else { pte->v = 1; }
triv121PgTblMap( Triv121PgTbl pt, long ovsid, unsigned long start, unsigned long numPages, unsigned attributes, unsigned protection ){int i,pass;unsigned long pi;PTE pte;long vsid; /* already activated - no change allowed */ if (pt->active) return -1; if (ovsid < 0) { /* use 1:1 mapping */ ovsid = VSID121(start); }#ifdef DEBUG PRINTF("Mapping %i (0x%x) pages at 0x%08x for VSID 0x%08x\n", (unsigned)numPages, (unsigned)numPages, (unsigned)start, (unsigned)vsid);#endif /* map in two passes. During the first pass, we try * to claim entries as needed. The 'slotFor()' routine * will 'mark' the claimed entries without 'valid'ating * them. * If the mapping fails, all claimed entries are unmarked * and we return the PI for which allocation failed. * * Once we know that the allocation would succeed, we * do a second pass; during the second pass, the PTE * is actually written. * */ for (pass=0; pass<2; pass++) { /* check if we would succeed during the first pass */ for (i=0, pi=PI121(start), vsid = ovsid; i<numPages; i++,pi++) { if ( pi >= 1<<LD_PI_SIZE ) { vsid++; pi = 0; } /* leave alone existing mappings for this EA */ if (!alreadyMapped(pt, vsid, pi)) { if (!(pte=slotFor(pt, vsid, pi))) { /* no free slot found for page index 'pi' */ unmarkAll(pt); return pi; } else { /* have a free slot; marked by slotFor() */ if (pass) { /* second pass; do the real work */ pte->vsid=vsid; /* H was set by slotFor() */ pte->api =API(pi); /* set up 1:1 mapping */ pte->rpn =((((unsigned long)vsid)&((1<<(LD_PHYS_SIZE-LD_SEG_SIZE))-1))<<LD_PI_SIZE) | pi; pte->wimg=attributes & 0xf; pte->pp=protection&0x3; /* mark it valid */ pte->v=1; pte->marked=0;#ifdef DEBUG /* add paranoia */ assert(alreadyMapped(pt, vsid, pi) == pte);#endif } } } } unmarkAll(pt); }#ifdef DEBUG { unsigned long failedat; CONSCHECK(-1); /* double check that the requested range is mapped */ failedat=triv121IsRangeMapped(start, start + (1<<LD_PG_SIZE)*numPages); if (0x0C0C != failedat) { PRINTF("triv121 mapping failed at 0x%08x\n",(unsigned)failedat); return PI121(failedat); } }#endif return TRIV121_MAP_SUCCESS; /* -1 !! */}
{ unsigned long failedat; CONSCHECK(-1); failedat=triv121IsRangeMapped(start, start + (1<<LD_PG_SIZE)*numPages); if (0x0C0C != failedat) { PRINTF("triv121 mapping failed at 0x%08x\n",(unsigned)failedat); return PI121(failedat); } }
{ unsigned long failedat; CONSCHECK (-1); failedat = triv121IsRangeMapped (saved_vsid, start, start + (1 << LD_PG_SIZE) * numPages); if (0x0C0C != failedat) { PRINTF ("triv121 mapping failed at 0x%08x\n", (unsigned) failedat); return PI121 (failedat); } }
triv121PgTblMap( Triv121PgTbl pt, long ovsid, unsigned long start, unsigned long numPages, unsigned attributes, unsigned protection ){int i,pass;unsigned long pi;PTE pte;long vsid; /* already activated - no change allowed */ if (pt->active) return -1; if (ovsid < 0) { /* use 1:1 mapping */ ovsid = VSID121(start); }#ifdef DEBUG PRINTF("Mapping %i (0x%x) pages at 0x%08x for VSID 0x%08x\n", (unsigned)numPages, (unsigned)numPages, (unsigned)start, (unsigned)vsid);#endif /* map in two passes. During the first pass, we try * to claim entries as needed. The 'slotFor()' routine * will 'mark' the claimed entries without 'valid'ating * them. * If the mapping fails, all claimed entries are unmarked * and we return the PI for which allocation failed. * * Once we know that the allocation would succeed, we * do a second pass; during the second pass, the PTE * is actually written. * */ for (pass=0; pass<2; pass++) { /* check if we would succeed during the first pass */ for (i=0, pi=PI121(start), vsid = ovsid; i<numPages; i++,pi++) { if ( pi >= 1<<LD_PI_SIZE ) { vsid++; pi = 0; } /* leave alone existing mappings for this EA */ if (!alreadyMapped(pt, vsid, pi)) { if (!(pte=slotFor(pt, vsid, pi))) { /* no free slot found for page index 'pi' */ unmarkAll(pt); return pi; } else { /* have a free slot; marked by slotFor() */ if (pass) { /* second pass; do the real work */ pte->vsid=vsid; /* H was set by slotFor() */ pte->api =API(pi); /* set up 1:1 mapping */ pte->rpn =((((unsigned long)vsid)&((1<<(LD_PHYS_SIZE-LD_SEG_SIZE))-1))<<LD_PI_SIZE) | pi; pte->wimg=attributes & 0xf; pte->pp=protection&0x3; /* mark it valid */ pte->v=1; pte->marked=0;#ifdef DEBUG /* add paranoia */ assert(alreadyMapped(pt, vsid, pi) == pte);#endif } } } } unmarkAll(pt); }#ifdef DEBUG { unsigned long failedat; CONSCHECK(-1); /* double check that the requested range is mapped */ failedat=triv121IsRangeMapped(start, start + (1<<LD_PG_SIZE)*numPages); if (0x0C0C != failedat) { PRINTF("triv121 mapping failed at 0x%08x\n",(unsigned)failedat); return PI121(failedat); } }#endif return TRIV121_MAP_SUCCESS; /* -1 !! */}
status = BSP_install_rtems_irq_handler (&ethernetFECIrqData); if (status != RTEMS_SUCCESSFUL) rtems_panic ("Can't attach M860 FEC interrupt handler: %s\n", rtems_status_text (status));
if (!BSP_install_rtems_irq_handler (&ethernetFECIrqData)) rtems_panic ("Can't attach M860 FEC interrupt handler\n");
m860_fec_initialize_hardware (struct m860_enet_struct *sc){ int i; unsigned char *hwaddr; rtems_status_code status; rtems_isr_entry old_handler; /* * Issue reset to FEC */ m8xx.fec.ecntrl=0x1; /* * Put ethernet transciever in reset */ m8xx.pgcra |= 0x80; /* * Configure I/O ports */ m8xx.pdpar = 0x1fff; m8xx.pddir = 0x1c58; /* * Take ethernet transciever out of reset */ m8xx.pgcra &= ~0x80; /* * Set SIU interrupt level to LVL2 * */ m8xx.fec.ivec = ((((unsigned) BSP_FAST_ETHERNET_CTRL)/2) << 29); /* * Set the TX and RX fifo sizes. For now, we'll split it evenly */ /* If you uncomment these, the FEC will not work right. m8xx.fec.r_fstart = ((m8xx.fec.r_bound & 0x3ff) >> 2) & 0x3ff; m8xx.fec.x_fstart = 0; */ /* * Set our physical address */ hwaddr = sc->arpcom.ac_enaddr; m8xx.fec.addr_low = (hwaddr[0] << 24) | (hwaddr[1] << 16) | (hwaddr[2] << 8) | (hwaddr[3] << 0); m8xx.fec.addr_high = (hwaddr[4] << 24) | (hwaddr[5] << 16); /* * Clear the hash table */ m8xx.fec.hash_table_high = 0; m8xx.fec.hash_table_low = 0; /* * Set up receive buffer size */ m8xx.fec.r_buf_size = 0x5f0; /* set to 1520 */ /* * Allocate mbuf pointers */ sc->rxMbuf = malloc (sc->rxBdCount * sizeof *sc->rxMbuf, M_MBUF, M_NOWAIT); sc->txMbuf = malloc (sc->txBdCount * sizeof *sc->txMbuf, M_MBUF, M_NOWAIT); if (!sc->rxMbuf || !sc->txMbuf) rtems_panic ("No memory for mbuf pointers"); /* * Set receiver and transmitter buffer descriptor bases */ sc->rxBdBase = m8xx_bd_allocate(sc->rxBdCount); sc->txBdBase = m8xx_bd_allocate(sc->txBdCount); m8xx.fec.r_des_start = (int)sc->rxBdBase; m8xx.fec.x_des_start = (int)sc->txBdBase; /* * Set up Receive Control Register: * Not promiscuous mode * MII mode * Half duplex * No loopback */ m8xx.fec.r_cntrl = 0x00000006; /* * Set up Transmit Control Register: * Half duplex * No heartbeat */ m8xx.fec.x_cntrl = 0x00000000; /* * Set up DMA function code: * Big-endian * DMA functino code = 0 */ m8xx.fec.fun_code = 0x78000000; /* * Initialize SDMA configuration register * SDMA ignores FRZ * FEC not aggressive * FEC arbitration ID = 0 => U-bus arbitration = 6 * RISC arbitration ID = 1 => U-bus arbitration = 5 */ m8xx.sdcr = 1; /* * Set MII speed to 2.5 MHz for 25 Mhz system clock */ m8xx.fec.mii_speed = 0x0a; m8xx.fec.mii_data = 0x58021000; /* * Set up receive buffer descriptors */ for (i = 0 ; i < sc->rxBdCount ; i++) (sc->rxBdBase + i)->status = 0; /* * Set up transmit buffer descriptors */ for (i = 0 ; i < sc->txBdCount ; i++) { (sc->txBdBase + i)->status = 0; sc->txMbuf[i] = NULL; } sc->txBdHead = sc->txBdTail = 0; sc->txBdActiveCount = 0; /* * Mask all FEC interrupts and clear events */ m8xx.fec.imask = M8xx_FEC_IEVENT_TFINT | M8xx_FEC_IEVENT_RFINT; m8xx.fec.ievent = ~0; /* * Set up interrupts */ status = BSP_install_rtems_irq_handler (&ethernetFECIrqData); if (status != RTEMS_SUCCESSFUL) rtems_panic ("Can't attach M860 FEC interrupt handler: %s\n", rtems_status_text (status));}
int scandir( const char *dirname, struct dirent ***namelist, int (*select)(struct dirent *), int (*dcomp)(const void *, const void *) )
scandir(dirname, namelist, select, dcomp) const char *dirname; struct dirent ***namelist; int (*select) __P((struct dirent *)); int (*dcomp) __P((const void *, const void *));
int scandir( const char *dirname, struct dirent ***namelist, int (*select)(struct dirent *), int (*dcomp)(const void *, const void *)){ errno = ENOSYS; return -1;}
errno = ENOSYS; return -1;
register struct dirent *d, *p, **names; register size_t nitems; struct stat stb; long arraysz; DIR *dirp; if ((dirp = opendir(dirname)) == NULL) return(-1); if (fstat(dirp->dd_fd, &stb) < 0) return(-1); arraysz = (stb.st_size / 24); names = (struct dirent **)malloc(arraysz * sizeof(struct dirent *)); if (names == NULL) return(-1); nitems = 0; while ((d = readdir(dirp)) != NULL) { if (select != NULL && !(*select)(d)) continue; p = (struct dirent *)malloc(DIRSIZ(d)); if (p == NULL) return(-1); p->d_ino = d->d_ino; p->d_reclen = d->d_reclen; p->d_namlen = d->d_namlen; bcopy(d->d_name, p->d_name, p->d_namlen + 1); if (++nitems >= arraysz) { if (fstat(dirp->dd_fd, &stb) < 0) return(-1); arraysz = stb.st_size / 12; names = (struct dirent **)realloc((char *)names, arraysz * sizeof(struct dirent *)); if (names == NULL) return(-1); } names[nitems-1] = p; } closedir(dirp); if (nitems && dcomp != NULL){ qsort(names, nitems, sizeof(struct dirent *), dcomp); } *namelist = names; return(nitems);
int scandir( const char *dirname, struct dirent ***namelist, int (*select)(struct dirent *), int (*dcomp)(const void *, const void *)){ errno = ENOSYS; return -1;}
char ch
unsigned char ch
void console_outbyte_polled( int port, char ch){ if ( port == 0 ) { while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) == 0 ); LEON_REG.UART_Channel_1 = (int) ch; return; } while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) == 0 ); LEON_REG.UART_Channel_2 = (int) ch;}
LEON_REG.UART_Channel_1 = (int) ch;
LEON_REG.UART_Channel_1 = (unsigned int) ch;
void console_outbyte_polled( int port, char ch){ if ( port == 0 ) { while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) == 0 ); LEON_REG.UART_Channel_1 = (int) ch; return; } while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) == 0 ); LEON_REG.UART_Channel_2 = (int) ch;}
LEON_REG.UART_Channel_2 = (int) ch;
LEON_REG.UART_Channel_2 = (unsigned int) ch;
void console_outbyte_polled( int port, char ch){ if ( port == 0 ) { while ( (LEON_REG.UART_Status_1 & LEON_REG_UART_STATUS_THE) == 0 ); LEON_REG.UART_Channel_1 = (int) ch; return; } while ( (LEON_REG.UART_Status_2 & LEON_REG_UART_STATUS_THE) == 0 ); LEON_REG.UART_Channel_2 = (int) ch;}
if( *once == 0 )
if( *(volatile __gthread_once_t *)once == 0 )
int rtems_gxx_once(__gthread_once_t *once, void (*func) ()){#ifdef DEBUG_GXX_WRAPPERS printk( "gxx_wrappers: once=%x, func=%x\n", *once, func );#endif if( *once == 0 ) { /* * NOTE: could not use the call to disable "preemption", it causes * one exception. Somebody might want to investiage it further * sometime later. */ _Thread_Disable_dispatch(); *once = 1; (*func)(); _Thread_Enable_dispatch(); } return 0;}
_Thread_Disable_dispatch(); *once = 1; (*func)(); _Thread_Enable_dispatch();
rtems_mode saveMode; rtems_task_mode(RTEMS_NO_PREEMPT, RTEMS_PREEMPT_MASK, &saveMode); if( *(volatile __gthread_once_t *)once == 0 ) { *(volatile __gthread_once_t *)once = 1; (*func)(); } rtems_task_mode(saveMode, RTEMS_PREEMPT_MASK, &saveMode);
int rtems_gxx_once(__gthread_once_t *once, void (*func) ()){#ifdef DEBUG_GXX_WRAPPERS printk( "gxx_wrappers: once=%x, func=%x\n", *once, func );#endif if( *once == 0 ) { /* * NOTE: could not use the call to disable "preemption", it causes * one exception. Somebody might want to investiage it further * sometime later. */ _Thread_Disable_dispatch(); *once = 1; (*func)(); _Thread_Enable_dispatch(); } return 0;}
if (typ(y) == t_SER) { setvalp(y, valp(y) - vd); return gerepileupto(av, gadd(y, x)); } y = add_ser_scal(x, y, vx, valp(x) + vd);
if (typ(y) != t_SER) y = greffe(y,l,1);
gadd(GEN x, GEN y){ long tx = typ(x), ty = typ(y), vx, vy, lx, ly, i, j, l; pari_sp av, tetpil; GEN z, p1; if (tx == ty) switch(tx) /* shortcut to generic case */ { case t_INT: return addii(x,y); case t_REAL: return addrr(x,y); case t_INTMOD: { GEN X = (GEN)x[1], Y = (GEN)y[1]; z = cgetg(3,t_INTMOD); if (X==Y || equalii(X,Y)) return add_intmod_same(z, X, (GEN)x[2], (GEN)y[2]); z[1] = (long)gcdii(X,Y); av = avma; p1 = addii((GEN)x[2],(GEN)y[2]); z[2] = (long)gerepileuptoint(av, remii(p1, (GEN)z[1])); return z; } case t_FRAC: return addfrac(x,y); case t_COMPLEX: z = cgetg(3,t_COMPLEX); z[2] = ladd((GEN)x[2],(GEN)y[2]); if (isexactzero((GEN)z[2])) { avma = (pari_sp)(z+3); return gadd((GEN)x[1],(GEN)y[1]); } z[1] = ladd((GEN)x[1],(GEN)y[1]); return z; case t_PADIC: if (!equalii((GEN)x[2],(GEN)y[2])) err(operi,"+",x,y); return addpp(x,y); case t_QUAD: z = cgetg(4,t_QUAD); if (!gequal((GEN)x[1],(GEN)y[1])) err(operi,"+",x,y); copyifstack(x[1], z[1]); z[2] = ladd((GEN)x[2],(GEN)y[2]); z[3] = ladd((GEN)x[3],(GEN)y[3]); return z; case t_POLMOD: if (gequal((GEN)x[1], (GEN)y[1])) return add_polmod_same((GEN)x[1], (GEN)x[2], (GEN)y[2]); return add_polmod((GEN)x[1], (GEN)y[1], (GEN)x[2], (GEN)y[2]); case t_POL: vx = varn(x); vy = varn(y); if (vx != vy) { if (varncmp(vx, vy) < 0) return add_pol_scal(x, y, vx); else return add_pol_scal(y, x, vy); } /* same variable */ lx = lg(x); ly = lg(y); if (lx == ly) { z = cgetg(lx, t_POL); z[1] = x[1]; for (i=2; i < lx; i++) z[i] = ladd((GEN)x[i],(GEN)y[i]); return normalizepol_i(z, lx); } if (ly < lx) { z = cgetg(lx,t_POL); z[1] = x[1]; for (i=2; i < ly; i++) z[i] = ladd((GEN)x[i],(GEN)y[i]); for ( ; i < lx; i++) z[i] = lcopy((GEN)x[i]); if (!signe(x)) z = normalizepol_i(z, lx); } else { z = cgetg(ly,t_POL); z[1] = y[1]; for (i=2; i < lx; i++) z[i] = ladd((GEN)x[i],(GEN)y[i]); for ( ; i < ly; i++) z[i] = lcopy((GEN)y[i]); if (!signe(y)) z = normalizepol_i(z, ly); } return z; case t_SER: vx = varn(x); vy = varn(y); if (vx != vy) { if (varncmp(vx, vy) < 0) return add_ser_scal(x, y, vx, valp(x)); else return add_ser_scal(y, x, vy, valp(y)); } l = valp(y) - valp(x); if (l < 0) { l = -l; swap(x,y); } /* valp(x) <= valp(y) */ if (!signe(x)) return gcopy(x); lx = lg(x); ly = signe(y)? lg(y): 2; ly += l; if (lx < ly) ly = lx; av = avma; z = cgetg(ly,t_SER); if (l) { if (l > lx-2) { avma = av; return gcopy(x); } for (i=2; i<=l+1; i++) z[i] = lcopy((GEN)x[i]); for ( ; i < ly; i++) z[i] = ladd((GEN)x[i],(GEN)y[i-l]); z[1] = x[1]; return z; } for (i = 2; i < ly; i++) { p1 = gadd((GEN)x[i],(GEN)y[i]); if (!isexactzero(p1)) { l = i-2; stackdummy(z,l); z += l; z[0] = evaltyp(t_SER) | evallg(ly-l); z[1] = evalvalp(valp(x)+i-2) | evalsigne(1) | evalvarn(vx); for (j=i+1; j<ly; j++) z[j-l] = ladd((GEN)x[j],(GEN)y[j]); z[2] = (long)p1; return z; } avma = (pari_sp)z; } avma = av; return zeroser(vx, ly-2 + valp(y)); case t_RFRAC: vx = gvar(x); vy = gvar(y); if (vx != vy) { if (varncmp(vx, vy) < 0) return add_rfrac_scal(x, y); else return add_rfrac_scal(y, x); } return add_rfrac(x,y); case t_VEC: case t_COL: case t_MAT: ly = lg(y); if (ly != lg(x)) err(operi,"+",x,y); z = cgetg(ly, ty); for (i = 1; i < ly; i++) z[i] = ladd((GEN)x[i],(GEN)y[i]); return z; default: err(operf,"+",x,y); } /* tx != ty */ if (tx > ty) { swap(x,y); lswap(tx,ty); } if (is_const_t(ty)) switch(tx) /* tx < ty, is_const_t(tx) && is_const_t(ty) */ { case t_INT: switch(ty) { case t_REAL: return addir(x,y); case t_INTMOD: z = cgetg(3, t_INTMOD); return add_intmod_same(z, (GEN)y[1], (GEN)y[2], modii(x, (GEN)y[1])); case t_FRAC: z = cgetg(3,t_FRAC); z[1] = lpileuptoint((pari_sp)z, addii((GEN)y[1], mulii((GEN)y[2],x))); z[2] = licopy((GEN)y[2]); return z; case t_COMPLEX: return addRc(x, y); case t_PADIC: return addQp(x,y); case t_QUAD: return addRq(x, y); } case t_REAL: switch(ty) { case t_FRAC: if (!signe(y[1])) return rcopy(x); if (!signe(x)) { lx = expi((GEN)y[1]) - expi((GEN)y[2]) - expo(x); return lx <= 0? rcopy(x): fractor(y, nbits2prec(lx)); } av=avma; z=addir((GEN)y[1],mulir((GEN)y[2],x)); tetpil=avma; return gerepile(av,tetpil,divri(z,(GEN)y[2])); case t_COMPLEX: return addRc(x, y); case t_QUAD: return gcmp0(y)? rcopy(x): addqf(y, x, lg(x)); default: err(operf,"+",x,y); } case t_INTMOD: switch(ty) { case t_FRAC: { GEN X = (GEN)x[1]; z = cgetg(3, t_INTMOD); p1 = modii(mulii((GEN)y[1], Fp_inv((GEN)y[2],X)), X); return add_intmod_same(z, X, p1, (GEN)x[2]); } case t_COMPLEX: return addRc(x, y); case t_PADIC: { GEN X = (GEN)x[1]; z = cgetg(3, t_INTMOD); return add_intmod_same(z, X, (GEN)x[2], padic_to_Fp(y, X)); } case t_QUAD: return addRq(x, y); } case t_FRAC: switch (ty) { case t_COMPLEX: return addRc(x, y); case t_PADIC: return addQp(x,y); case t_QUAD: return addRq(x, y); } case t_COMPLEX: switch(ty) { case t_PADIC: return Zp_nosquare_m1((GEN)y[2])? addRc(y, x): addTp(x, y); case t_QUAD: lx = precision(x); if (!lx) err(operi,"+",x,y); return gcmp0(y)? rcopy(x): addqf(y, x, lx); } case t_PADIC: /* ty == t_QUAD */ return (kro_quad((GEN)y[1],(GEN)x[2]) == -1)? addRq(x, y): addTp(y, x); } /* tx < ty, !is_const_t(y) */ if (ty == t_MAT) { if (is_matvec_t(tx)) err(operf,"+",x,y); if (isexactzero(x)) return gcopy(y); return gaddmat(x,y); } if (ty == t_POLMOD) /* is_const_t(tx) in this case */ return add_polmod_scal((GEN)y[1], (GEN)y[2], x); vy = gvar(y); if (is_scalar_t(tx)) { if (tx == t_POLMOD) { vx = varn(x[1]); if (vx == vy) y = gmod(y, (GEN)x[1]); /* error if ty == t_SER */ else if (varncmp(vx,vy) > 0) return add_scal(y, x, ty, vy); return add_polmod_scal((GEN)x[1], (GEN)x[2], y); } return add_scal(y, x, ty, vy); } /* x and y are not scalars, ty != t_MAT */ vx = gvar(x); if (vx != vy) { /* x or y is treated as a scalar */ if (is_vec_t(tx) || is_vec_t(ty)) err(operf,"+",x,y); return (varncmp(vx, vy) < 0)? add_scal(x, y, tx, vx) : add_scal(y, x, ty, vy); } /* vx = vy */ switch(tx) { case t_POL: switch (ty) { case t_SER: if (isexactzero(x)) return gcopy(y); ly = signe(y)? lg(y): 3; i = ly + valp(y) - polvaluation(x, NULL); if (i < 3) return gcopy(y); p1 = greffe(x,i,0); y = gadd(p1,y); free(p1); return y; case t_RFRAC: return add_rfrac_scal(y, x); } break; case t_SER: if (ty == t_RFRAC) { GEN n, d; long vn, vd; if (isexactzero(y)) return gcopy(x); n = gel(y,1); vn = gval(n, vy); d = gel(y,2); vd = polvaluation(d, &d); l = valp(x) - (vn - vd); l += gcmp0(x)? 3: lg(x); if (l < 3) return gcopy(x); av = avma; /* take advantage of y = t^n ! */ d = degpol(d)? greffe(d,l,1) : gel(d,2); y = gdiv(n, d); if (typ(y) == t_SER) { setvalp(y, valp(y) - vd); return gerepileupto(av, gadd(y, x)); } y = add_ser_scal(x, y, vx, valp(x) + vd); setvalp(y, valp(y) - vd); return gerepileupto(av, y); } break; } err(operf,"+",x,y); return NULL; /* not reached */}
return gerepileupto(av, y);
return gerepileupto(av, gadd(y, x));
gadd(GEN x, GEN y){ long tx = typ(x), ty = typ(y), vx, vy, lx, ly, i, j, l; pari_sp av, tetpil; GEN z, p1; if (tx == ty) switch(tx) /* shortcut to generic case */ { case t_INT: return addii(x,y); case t_REAL: return addrr(x,y); case t_INTMOD: { GEN X = (GEN)x[1], Y = (GEN)y[1]; z = cgetg(3,t_INTMOD); if (X==Y || equalii(X,Y)) return add_intmod_same(z, X, (GEN)x[2], (GEN)y[2]); z[1] = (long)gcdii(X,Y); av = avma; p1 = addii((GEN)x[2],(GEN)y[2]); z[2] = (long)gerepileuptoint(av, remii(p1, (GEN)z[1])); return z; } case t_FRAC: return addfrac(x,y); case t_COMPLEX: z = cgetg(3,t_COMPLEX); z[2] = ladd((GEN)x[2],(GEN)y[2]); if (isexactzero((GEN)z[2])) { avma = (pari_sp)(z+3); return gadd((GEN)x[1],(GEN)y[1]); } z[1] = ladd((GEN)x[1],(GEN)y[1]); return z; case t_PADIC: if (!equalii((GEN)x[2],(GEN)y[2])) err(operi,"+",x,y); return addpp(x,y); case t_QUAD: z = cgetg(4,t_QUAD); if (!gequal((GEN)x[1],(GEN)y[1])) err(operi,"+",x,y); copyifstack(x[1], z[1]); z[2] = ladd((GEN)x[2],(GEN)y[2]); z[3] = ladd((GEN)x[3],(GEN)y[3]); return z; case t_POLMOD: if (gequal((GEN)x[1], (GEN)y[1])) return add_polmod_same((GEN)x[1], (GEN)x[2], (GEN)y[2]); return add_polmod((GEN)x[1], (GEN)y[1], (GEN)x[2], (GEN)y[2]); case t_POL: vx = varn(x); vy = varn(y); if (vx != vy) { if (varncmp(vx, vy) < 0) return add_pol_scal(x, y, vx); else return add_pol_scal(y, x, vy); } /* same variable */ lx = lg(x); ly = lg(y); if (lx == ly) { z = cgetg(lx, t_POL); z[1] = x[1]; for (i=2; i < lx; i++) z[i] = ladd((GEN)x[i],(GEN)y[i]); return normalizepol_i(z, lx); } if (ly < lx) { z = cgetg(lx,t_POL); z[1] = x[1]; for (i=2; i < ly; i++) z[i] = ladd((GEN)x[i],(GEN)y[i]); for ( ; i < lx; i++) z[i] = lcopy((GEN)x[i]); if (!signe(x)) z = normalizepol_i(z, lx); } else { z = cgetg(ly,t_POL); z[1] = y[1]; for (i=2; i < lx; i++) z[i] = ladd((GEN)x[i],(GEN)y[i]); for ( ; i < ly; i++) z[i] = lcopy((GEN)y[i]); if (!signe(y)) z = normalizepol_i(z, ly); } return z; case t_SER: vx = varn(x); vy = varn(y); if (vx != vy) { if (varncmp(vx, vy) < 0) return add_ser_scal(x, y, vx, valp(x)); else return add_ser_scal(y, x, vy, valp(y)); } l = valp(y) - valp(x); if (l < 0) { l = -l; swap(x,y); } /* valp(x) <= valp(y) */ if (!signe(x)) return gcopy(x); lx = lg(x); ly = signe(y)? lg(y): 2; ly += l; if (lx < ly) ly = lx; av = avma; z = cgetg(ly,t_SER); if (l) { if (l > lx-2) { avma = av; return gcopy(x); } for (i=2; i<=l+1; i++) z[i] = lcopy((GEN)x[i]); for ( ; i < ly; i++) z[i] = ladd((GEN)x[i],(GEN)y[i-l]); z[1] = x[1]; return z; } for (i = 2; i < ly; i++) { p1 = gadd((GEN)x[i],(GEN)y[i]); if (!isexactzero(p1)) { l = i-2; stackdummy(z,l); z += l; z[0] = evaltyp(t_SER) | evallg(ly-l); z[1] = evalvalp(valp(x)+i-2) | evalsigne(1) | evalvarn(vx); for (j=i+1; j<ly; j++) z[j-l] = ladd((GEN)x[j],(GEN)y[j]); z[2] = (long)p1; return z; } avma = (pari_sp)z; } avma = av; return zeroser(vx, ly-2 + valp(y)); case t_RFRAC: vx = gvar(x); vy = gvar(y); if (vx != vy) { if (varncmp(vx, vy) < 0) return add_rfrac_scal(x, y); else return add_rfrac_scal(y, x); } return add_rfrac(x,y); case t_VEC: case t_COL: case t_MAT: ly = lg(y); if (ly != lg(x)) err(operi,"+",x,y); z = cgetg(ly, ty); for (i = 1; i < ly; i++) z[i] = ladd((GEN)x[i],(GEN)y[i]); return z; default: err(operf,"+",x,y); } /* tx != ty */ if (tx > ty) { swap(x,y); lswap(tx,ty); } if (is_const_t(ty)) switch(tx) /* tx < ty, is_const_t(tx) && is_const_t(ty) */ { case t_INT: switch(ty) { case t_REAL: return addir(x,y); case t_INTMOD: z = cgetg(3, t_INTMOD); return add_intmod_same(z, (GEN)y[1], (GEN)y[2], modii(x, (GEN)y[1])); case t_FRAC: z = cgetg(3,t_FRAC); z[1] = lpileuptoint((pari_sp)z, addii((GEN)y[1], mulii((GEN)y[2],x))); z[2] = licopy((GEN)y[2]); return z; case t_COMPLEX: return addRc(x, y); case t_PADIC: return addQp(x,y); case t_QUAD: return addRq(x, y); } case t_REAL: switch(ty) { case t_FRAC: if (!signe(y[1])) return rcopy(x); if (!signe(x)) { lx = expi((GEN)y[1]) - expi((GEN)y[2]) - expo(x); return lx <= 0? rcopy(x): fractor(y, nbits2prec(lx)); } av=avma; z=addir((GEN)y[1],mulir((GEN)y[2],x)); tetpil=avma; return gerepile(av,tetpil,divri(z,(GEN)y[2])); case t_COMPLEX: return addRc(x, y); case t_QUAD: return gcmp0(y)? rcopy(x): addqf(y, x, lg(x)); default: err(operf,"+",x,y); } case t_INTMOD: switch(ty) { case t_FRAC: { GEN X = (GEN)x[1]; z = cgetg(3, t_INTMOD); p1 = modii(mulii((GEN)y[1], Fp_inv((GEN)y[2],X)), X); return add_intmod_same(z, X, p1, (GEN)x[2]); } case t_COMPLEX: return addRc(x, y); case t_PADIC: { GEN X = (GEN)x[1]; z = cgetg(3, t_INTMOD); return add_intmod_same(z, X, (GEN)x[2], padic_to_Fp(y, X)); } case t_QUAD: return addRq(x, y); } case t_FRAC: switch (ty) { case t_COMPLEX: return addRc(x, y); case t_PADIC: return addQp(x,y); case t_QUAD: return addRq(x, y); } case t_COMPLEX: switch(ty) { case t_PADIC: return Zp_nosquare_m1((GEN)y[2])? addRc(y, x): addTp(x, y); case t_QUAD: lx = precision(x); if (!lx) err(operi,"+",x,y); return gcmp0(y)? rcopy(x): addqf(y, x, lx); } case t_PADIC: /* ty == t_QUAD */ return (kro_quad((GEN)y[1],(GEN)x[2]) == -1)? addRq(x, y): addTp(y, x); } /* tx < ty, !is_const_t(y) */ if (ty == t_MAT) { if (is_matvec_t(tx)) err(operf,"+",x,y); if (isexactzero(x)) return gcopy(y); return gaddmat(x,y); } if (ty == t_POLMOD) /* is_const_t(tx) in this case */ return add_polmod_scal((GEN)y[1], (GEN)y[2], x); vy = gvar(y); if (is_scalar_t(tx)) { if (tx == t_POLMOD) { vx = varn(x[1]); if (vx == vy) y = gmod(y, (GEN)x[1]); /* error if ty == t_SER */ else if (varncmp(vx,vy) > 0) return add_scal(y, x, ty, vy); return add_polmod_scal((GEN)x[1], (GEN)x[2], y); } return add_scal(y, x, ty, vy); } /* x and y are not scalars, ty != t_MAT */ vx = gvar(x); if (vx != vy) { /* x or y is treated as a scalar */ if (is_vec_t(tx) || is_vec_t(ty)) err(operf,"+",x,y); return (varncmp(vx, vy) < 0)? add_scal(x, y, tx, vx) : add_scal(y, x, ty, vy); } /* vx = vy */ switch(tx) { case t_POL: switch (ty) { case t_SER: if (isexactzero(x)) return gcopy(y); ly = signe(y)? lg(y): 3; i = ly + valp(y) - polvaluation(x, NULL); if (i < 3) return gcopy(y); p1 = greffe(x,i,0); y = gadd(p1,y); free(p1); return y; case t_RFRAC: return add_rfrac_scal(y, x); } break; case t_SER: if (ty == t_RFRAC) { GEN n, d; long vn, vd; if (isexactzero(y)) return gcopy(x); n = gel(y,1); vn = gval(n, vy); d = gel(y,2); vd = polvaluation(d, &d); l = valp(x) - (vn - vd); l += gcmp0(x)? 3: lg(x); if (l < 3) return gcopy(x); av = avma; /* take advantage of y = t^n ! */ d = degpol(d)? greffe(d,l,1) : gel(d,2); y = gdiv(n, d); if (typ(y) == t_SER) { setvalp(y, valp(y) - vd); return gerepileupto(av, gadd(y, x)); } y = add_ser_scal(x, y, vx, valp(x) + vd); setvalp(y, valp(y) - vd); return gerepileupto(av, y); } break; } err(operf,"+",x,y); return NULL; /* not reached */}
u_Fp_gauss_get_col(GEN a, GEN b, ulong piv, long li, ulong p)
u_Fp_gauss_get_col(GEN a, GEN b, ulong invpiv, long li, ulong p)
u_Fp_gauss_get_col(GEN a, GEN b, ulong piv, long li, ulong p){ GEN u = cgetg(li+1,t_VECSMALL); ulong m; long i,j; m = b[li] % p; if (u_OK_ULONG(p)) { u[li] = (m * u_Fp_inv(piv,p)) % p; for (i=li-1; i>0; i--) { m = p - b[i]%p; for (j=i+1; j<=li; j++) { if (m & HIGHBIT) m %= p; m += coeff(a,i,j) * u[j]; } m %= p; if (m) m = ((p-m) * u_invmod((ulong)coeff(a,i,i), p)) % p; u[i] = m; } } else { u[li] = mulssmod(m, u_Fp_inv(piv,p), p); for (i=li-1; i>0; i--) { m = p - b[i]%p; for (j=i+1; j<=li; j++) m += mulssmod(coeff(a,i,j), u[j], p); m %= p; if (m) m = mulssmod(p-m, u_invmod((ulong)coeff(a,i,i), p), p); u[i] = m; } } return u;}
GEN u = cgetg(li+1,t_VECSMALL); ulong m;
ulong *u = (ulong*)cgetg(li+1,t_VECSMALL); ulong m = b[li] % p;
u_Fp_gauss_get_col(GEN a, GEN b, ulong piv, long li, ulong p){ GEN u = cgetg(li+1,t_VECSMALL); ulong m; long i,j; m = b[li] % p; if (u_OK_ULONG(p)) { u[li] = (m * u_Fp_inv(piv,p)) % p; for (i=li-1; i>0; i--) { m = p - b[i]%p; for (j=i+1; j<=li; j++) { if (m & HIGHBIT) m %= p; m += coeff(a,i,j) * u[j]; } m %= p; if (m) m = ((p-m) * u_invmod((ulong)coeff(a,i,i), p)) % p; u[i] = m; } } else { u[li] = mulssmod(m, u_Fp_inv(piv,p), p); for (i=li-1; i>0; i--) { m = p - b[i]%p; for (j=i+1; j<=li; j++) m += mulssmod(coeff(a,i,j), u[j], p); m %= p; if (m) m = mulssmod(p-m, u_invmod((ulong)coeff(a,i,i), p), p); u[i] = m; } } return u;}
m = b[li] % p; if (u_OK_ULONG(p))
u[li] = mulssmod(m, invpiv, p); for (i=li-1; i>0; i--)
u_Fp_gauss_get_col(GEN a, GEN b, ulong piv, long li, ulong p){ GEN u = cgetg(li+1,t_VECSMALL); ulong m; long i,j; m = b[li] % p; if (u_OK_ULONG(p)) { u[li] = (m * u_Fp_inv(piv,p)) % p; for (i=li-1; i>0; i--) { m = p - b[i]%p; for (j=i+1; j<=li; j++) { if (m & HIGHBIT) m %= p; m += coeff(a,i,j) * u[j]; } m %= p; if (m) m = ((p-m) * u_invmod((ulong)coeff(a,i,i), p)) % p; u[i] = m; } } else { u[li] = mulssmod(m, u_Fp_inv(piv,p), p); for (i=li-1; i>0; i--) { m = p - b[i]%p; for (j=i+1; j<=li; j++) m += mulssmod(coeff(a,i,j), u[j], p); m %= p; if (m) m = mulssmod(p-m, u_invmod((ulong)coeff(a,i,i), p), p); u[i] = m; } } return u;}
u[li] = (m * u_Fp_inv(piv,p)) % p; for (i=li-1; i>0; i--) { m = p - b[i]%p; for (j=i+1; j<=li; j++) { if (m & HIGHBIT) m %= p; m += coeff(a,i,j) * u[j]; } m %= p; if (m) m = ((p-m) * u_invmod((ulong)coeff(a,i,i), p)) % p; u[i] = m; } } else { u[li] = mulssmod(m, u_Fp_inv(piv,p), p); for (i=li-1; i>0; i--) { m = p - b[i]%p; for (j=i+1; j<=li; j++) m += mulssmod(coeff(a,i,j), u[j], p); m %= p; if (m) m = mulssmod(p-m, u_invmod((ulong)coeff(a,i,i), p), p); u[i] = m; }
m = p - b[i]%p; for (j = i+1; j <= li; j++) m += mulssmod(coeff(a,i,j), u[j], p); m %= p; if (m) m = mulssmod(p-m, u_invmod((ulong)coeff(a,i,i), p), p); u[i] = m;
u_Fp_gauss_get_col(GEN a, GEN b, ulong piv, long li, ulong p){ GEN u = cgetg(li+1,t_VECSMALL); ulong m; long i,j; m = b[li] % p; if (u_OK_ULONG(p)) { u[li] = (m * u_Fp_inv(piv,p)) % p; for (i=li-1; i>0; i--) { m = p - b[i]%p; for (j=i+1; j<=li; j++) { if (m & HIGHBIT) m %= p; m += coeff(a,i,j) * u[j]; } m %= p; if (m) m = ((p-m) * u_invmod((ulong)coeff(a,i,i), p)) % p; u[i] = m; } } else { u[li] = mulssmod(m, u_Fp_inv(piv,p), p); for (i=li-1; i>0; i--) { m = p - b[i]%p; for (j=i+1; j<=li; j++) m += mulssmod(coeff(a,i,j), u[j], p); m %= p; if (m) m = mulssmod(p-m, u_invmod((ulong)coeff(a,i,i), p), p); u[i] = m; } } return u;}
gel(u,j) = u_Fp_gauss_get_col_OK(a,(uGEN)b[j], invpiv, aco, p);
ugel(u,j) = u_Fp_gauss_get_col_OK(a,(uGEN)b[j], invpiv, aco, p);
Flm_gauss_sp(GEN a, GEN b, ulong p){ long iscol, i, j, k, li, bco, aco = lg(a)-1; ulong piv, invpiv, m; const int OK_ulong = u_OK_ULONG(p); GEN u; if (!aco) return cgetg(1,t_MAT); li = lg(a[1])-1; bco = lg(b)-1; iscol = (typ(b)!=t_MAT); if (iscol) b = mkmat(b); piv = invpiv = 0; /* -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ if (OK_ulong) /* u_Fp_gauss_get_col wants 0 <= a[i,j] < p for all i,j */ for (k = 1; k < i; k++) ucoeff(a,k,i) %= p; for (k = i; k <= li; k++) { piv = ( ucoeff(a,k,i) %= p ); if (piv) break; } if (!piv) return NULL; invpiv = Fl_inv(piv, p); /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(gcoeff(a,i,j), gcoeff(a,k,j)); for (j=1; j<=bco; j++) swap(gcoeff(b,i,j), gcoeff(b,k,j)); } if (i == aco) break; for (k=i+1; k<=li; k++) { m = ( ucoeff(a,k,i) %= p ); if (!m) continue; m = p - Fl_mul(m, invpiv, p); /* - 1/piv mod p */ if (m == 1) { for (j=i+1; j<=aco; j++) _u_Fp_add((uGEN)a[j],k,i, p); for (j=1; j<=bco; j++) _u_Fp_add((uGEN)b[j],k,i, p); } else if (OK_ulong) { for (j=i+1; j<=aco; j++) _u_Fp_addmul_OK((uGEN)a[j],k,i,m, p); for (j=1; j<=bco; j++) _u_Fp_addmul_OK((uGEN)b[j],k,i,m, p); } else { for (j=i+1; j<=aco; j++) _u_Fp_addmul((uGEN)a[j],k,i,m, p); for (j=1; j<=bco; j++) _u_Fp_addmul((uGEN)b[j],k,i,m, p); } } } u = cgetg(bco+1,t_MAT); if (OK_ulong) for (j=1; j<=bco; j++) gel(u,j) = u_Fp_gauss_get_col_OK(a,(uGEN)b[j], invpiv, aco, p); else for (j=1; j<=bco; j++) gel(u,j) = u_Fp_gauss_get_col(a,(uGEN)b[j], invpiv, aco, p); return iscol? gel(u,1): u;}
gel(u,j) = u_Fp_gauss_get_col(a,(uGEN)b[j], invpiv, aco, p);
ugel(u,j) = u_Fp_gauss_get_col(a,(uGEN)b[j], invpiv, aco, p);
Flm_gauss_sp(GEN a, GEN b, ulong p){ long iscol, i, j, k, li, bco, aco = lg(a)-1; ulong piv, invpiv, m; const int OK_ulong = u_OK_ULONG(p); GEN u; if (!aco) return cgetg(1,t_MAT); li = lg(a[1])-1; bco = lg(b)-1; iscol = (typ(b)!=t_MAT); if (iscol) b = mkmat(b); piv = invpiv = 0; /* -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ if (OK_ulong) /* u_Fp_gauss_get_col wants 0 <= a[i,j] < p for all i,j */ for (k = 1; k < i; k++) ucoeff(a,k,i) %= p; for (k = i; k <= li; k++) { piv = ( ucoeff(a,k,i) %= p ); if (piv) break; } if (!piv) return NULL; invpiv = Fl_inv(piv, p); /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(gcoeff(a,i,j), gcoeff(a,k,j)); for (j=1; j<=bco; j++) swap(gcoeff(b,i,j), gcoeff(b,k,j)); } if (i == aco) break; for (k=i+1; k<=li; k++) { m = ( ucoeff(a,k,i) %= p ); if (!m) continue; m = p - Fl_mul(m, invpiv, p); /* - 1/piv mod p */ if (m == 1) { for (j=i+1; j<=aco; j++) _u_Fp_add((uGEN)a[j],k,i, p); for (j=1; j<=bco; j++) _u_Fp_add((uGEN)b[j],k,i, p); } else if (OK_ulong) { for (j=i+1; j<=aco; j++) _u_Fp_addmul_OK((uGEN)a[j],k,i,m, p); for (j=1; j<=bco; j++) _u_Fp_addmul_OK((uGEN)b[j],k,i,m, p); } else { for (j=i+1; j<=aco; j++) _u_Fp_addmul((uGEN)a[j],k,i,m, p); for (j=1; j<=bco; j++) _u_Fp_addmul((uGEN)b[j],k,i,m, p); } } } u = cgetg(bco+1,t_MAT); if (OK_ulong) for (j=1; j<=bco; j++) gel(u,j) = u_Fp_gauss_get_col_OK(a,(uGEN)b[j], invpiv, aco, p); else for (j=1; j<=bco; j++) gel(u,j) = u_Fp_gauss_get_col(a,(uGEN)b[j], invpiv, aco, p); return iscol? gel(u,1): u;}
w = v = FpXQYQ_pow(polx[varn(u)], q, u, T, p);
w = v = FqXQ_pow(polx[varn(u)], q, u, T, p);
FqM_Berlekamp_ker(GEN u, GEN T, GEN q, GEN p){ long j,N = degpol(u); GEN vker,v,w,Q,p1; if (DEBUGLEVEL > 7) (void)timer2(); Q = cgetg(N+1,t_MAT); Q[1] = (long)zerocol(N); w = v = FpXQYQ_pow(polx[varn(u)], q, u, T, p); for (j=2; j<=N; j++) { p1 = pol_to_vec(w, N); p1[j] = laddgs((GEN)p1[j], -1); Q[j] = (long)p1; if (j < N) { gpmem_t av = avma; w = gerepileupto(av, FpXQX_divres(FpXQX_mul(w,v, T,p), u,T,p,ONLY_REM)); } } if (DEBUGLEVEL > 7) msgtimer("frobenius"); vker = FqM_ker(Q,T,p); if (DEBUGLEVEL > 7) msgtimer("kernel"); return vker;}
GEN piv,m,u;
GEN piv, invpiv, m, u;
FpM_gauss(GEN a, GEN b, GEN p){ pari_sp av,lim; long i,j,k,li,bco, aco = lg(a)-1; int iscol; GEN piv,m,u; if (typ(a)!=t_MAT) err(mattype1,"gauss"); if (b && typ(b)!=t_COL && typ(b)!=t_MAT) err(typeer,"gauss"); if (!aco) { if (b && lg(b)!=1) err(consister,"gauss"); if (DEBUGLEVEL) err(warner,"in Gauss lg(a)=1 lg(b)=%ld", b?1:-1); return cgetg(1,t_MAT); } li = lg(a[1])-1; if (li != aco && (li < aco || b)) err(mattype1,"gauss"); b = check_b(b,li, &iscol); av = avma; if (OK_ULONG(p)) { ulong pp=p[2]; a = u_Fp_FpM(a, pp); b = u_Fp_FpM(b, pp); u = u_FpM_gauss_sp(a,b, pp); u = iscol? small_to_col((GEN)u[1]): small_to_mat(u); return gerepileupto(av, u); } lim = stack_lim(av,1); a = dummycopy(a); bco = lg(b)-1; piv = NULL; /* gcc -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ coeff(a,i,i) = lresii(gcoeff(a,i,i), p); piv = gcoeff(a,i,i); k = i; if (!signe(piv)) { for (k++; k <= li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); if (signe(coeff(a,k,i))) break; } if (k>li) return NULL; } /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(coeff(a,i,j), coeff(a,k,j)); for (j=1; j<=bco; j++) swap(coeff(b,i,j), coeff(b,k,j)); piv = gcoeff(a,i,i); } if (i == aco) break; for (k=i+1; k<=li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); m = gcoeff(a,k,i); coeff(a,k,i) = zero; if (signe(m)) { m = mulii(m, mpinvmod(piv,p)); m = resii(negi(m), p); for (j=i+1; j<=aco; j++) _Fp_addmul((GEN)a[j],k,i,m, p); for (j=1 ; j<=bco; j++) _Fp_addmul((GEN)b[j],k,i,m, p); } } if (low_stack(lim, stack_lim(av,1))) { GEN *gptr[2]; gptr[0]=&a; gptr[1]=&b; if(DEBUGMEM>1) err(warnmem,"FpM_gauss. i=%ld",i); gerepilemany(av,gptr,2); } } if(DEBUGLEVEL>4) fprintferr("Solving the triangular system\n"); u = cgetg(bco+1,t_MAT); for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a,(GEN)b[j],piv,aco,p); return gerepilecopy(av, iscol? (GEN)u[1]: u);}
piv = NULL;
piv = invpiv = NULL;
FpM_gauss(GEN a, GEN b, GEN p){ pari_sp av,lim; long i,j,k,li,bco, aco = lg(a)-1; int iscol; GEN piv,m,u; if (typ(a)!=t_MAT) err(mattype1,"gauss"); if (b && typ(b)!=t_COL && typ(b)!=t_MAT) err(typeer,"gauss"); if (!aco) { if (b && lg(b)!=1) err(consister,"gauss"); if (DEBUGLEVEL) err(warner,"in Gauss lg(a)=1 lg(b)=%ld", b?1:-1); return cgetg(1,t_MAT); } li = lg(a[1])-1; if (li != aco && (li < aco || b)) err(mattype1,"gauss"); b = check_b(b,li, &iscol); av = avma; if (OK_ULONG(p)) { ulong pp=p[2]; a = u_Fp_FpM(a, pp); b = u_Fp_FpM(b, pp); u = u_FpM_gauss_sp(a,b, pp); u = iscol? small_to_col((GEN)u[1]): small_to_mat(u); return gerepileupto(av, u); } lim = stack_lim(av,1); a = dummycopy(a); bco = lg(b)-1; piv = NULL; /* gcc -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ coeff(a,i,i) = lresii(gcoeff(a,i,i), p); piv = gcoeff(a,i,i); k = i; if (!signe(piv)) { for (k++; k <= li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); if (signe(coeff(a,k,i))) break; } if (k>li) return NULL; } /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(coeff(a,i,j), coeff(a,k,j)); for (j=1; j<=bco; j++) swap(coeff(b,i,j), coeff(b,k,j)); piv = gcoeff(a,i,i); } if (i == aco) break; for (k=i+1; k<=li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); m = gcoeff(a,k,i); coeff(a,k,i) = zero; if (signe(m)) { m = mulii(m, mpinvmod(piv,p)); m = resii(negi(m), p); for (j=i+1; j<=aco; j++) _Fp_addmul((GEN)a[j],k,i,m, p); for (j=1 ; j<=bco; j++) _Fp_addmul((GEN)b[j],k,i,m, p); } } if (low_stack(lim, stack_lim(av,1))) { GEN *gptr[2]; gptr[0]=&a; gptr[1]=&b; if(DEBUGMEM>1) err(warnmem,"FpM_gauss. i=%ld",i); gerepilemany(av,gptr,2); } } if(DEBUGLEVEL>4) fprintferr("Solving the triangular system\n"); u = cgetg(bco+1,t_MAT); for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a,(GEN)b[j],piv,aco,p); return gerepilecopy(av, iscol? (GEN)u[1]: u);}
coeff(a,i,i) = lresii(gcoeff(a,i,i), p); piv = gcoeff(a,i,i); k = i; if (!signe(piv))
for (k = i; k <= li; k++)
FpM_gauss(GEN a, GEN b, GEN p){ pari_sp av,lim; long i,j,k,li,bco, aco = lg(a)-1; int iscol; GEN piv,m,u; if (typ(a)!=t_MAT) err(mattype1,"gauss"); if (b && typ(b)!=t_COL && typ(b)!=t_MAT) err(typeer,"gauss"); if (!aco) { if (b && lg(b)!=1) err(consister,"gauss"); if (DEBUGLEVEL) err(warner,"in Gauss lg(a)=1 lg(b)=%ld", b?1:-1); return cgetg(1,t_MAT); } li = lg(a[1])-1; if (li != aco && (li < aco || b)) err(mattype1,"gauss"); b = check_b(b,li, &iscol); av = avma; if (OK_ULONG(p)) { ulong pp=p[2]; a = u_Fp_FpM(a, pp); b = u_Fp_FpM(b, pp); u = u_FpM_gauss_sp(a,b, pp); u = iscol? small_to_col((GEN)u[1]): small_to_mat(u); return gerepileupto(av, u); } lim = stack_lim(av,1); a = dummycopy(a); bco = lg(b)-1; piv = NULL; /* gcc -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ coeff(a,i,i) = lresii(gcoeff(a,i,i), p); piv = gcoeff(a,i,i); k = i; if (!signe(piv)) { for (k++; k <= li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); if (signe(coeff(a,k,i))) break; } if (k>li) return NULL; } /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(coeff(a,i,j), coeff(a,k,j)); for (j=1; j<=bco; j++) swap(coeff(b,i,j), coeff(b,k,j)); piv = gcoeff(a,i,i); } if (i == aco) break; for (k=i+1; k<=li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); m = gcoeff(a,k,i); coeff(a,k,i) = zero; if (signe(m)) { m = mulii(m, mpinvmod(piv,p)); m = resii(negi(m), p); for (j=i+1; j<=aco; j++) _Fp_addmul((GEN)a[j],k,i,m, p); for (j=1 ; j<=bco; j++) _Fp_addmul((GEN)b[j],k,i,m, p); } } if (low_stack(lim, stack_lim(av,1))) { GEN *gptr[2]; gptr[0]=&a; gptr[1]=&b; if(DEBUGMEM>1) err(warnmem,"FpM_gauss. i=%ld",i); gerepilemany(av,gptr,2); } } if(DEBUGLEVEL>4) fprintferr("Solving the triangular system\n"); u = cgetg(bco+1,t_MAT); for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a,(GEN)b[j],piv,aco,p); return gerepilecopy(av, iscol? (GEN)u[1]: u);}
for (k++; k <= li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); if (signe(coeff(a,k,i))) break; } if (k>li) return NULL;
piv = resii(gcoeff(a,k,i), p); coeff(a,k,i) = (long)piv; if (signe(piv)) break;
FpM_gauss(GEN a, GEN b, GEN p){ pari_sp av,lim; long i,j,k,li,bco, aco = lg(a)-1; int iscol; GEN piv,m,u; if (typ(a)!=t_MAT) err(mattype1,"gauss"); if (b && typ(b)!=t_COL && typ(b)!=t_MAT) err(typeer,"gauss"); if (!aco) { if (b && lg(b)!=1) err(consister,"gauss"); if (DEBUGLEVEL) err(warner,"in Gauss lg(a)=1 lg(b)=%ld", b?1:-1); return cgetg(1,t_MAT); } li = lg(a[1])-1; if (li != aco && (li < aco || b)) err(mattype1,"gauss"); b = check_b(b,li, &iscol); av = avma; if (OK_ULONG(p)) { ulong pp=p[2]; a = u_Fp_FpM(a, pp); b = u_Fp_FpM(b, pp); u = u_FpM_gauss_sp(a,b, pp); u = iscol? small_to_col((GEN)u[1]): small_to_mat(u); return gerepileupto(av, u); } lim = stack_lim(av,1); a = dummycopy(a); bco = lg(b)-1; piv = NULL; /* gcc -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ coeff(a,i,i) = lresii(gcoeff(a,i,i), p); piv = gcoeff(a,i,i); k = i; if (!signe(piv)) { for (k++; k <= li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); if (signe(coeff(a,k,i))) break; } if (k>li) return NULL; } /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(coeff(a,i,j), coeff(a,k,j)); for (j=1; j<=bco; j++) swap(coeff(b,i,j), coeff(b,k,j)); piv = gcoeff(a,i,i); } if (i == aco) break; for (k=i+1; k<=li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); m = gcoeff(a,k,i); coeff(a,k,i) = zero; if (signe(m)) { m = mulii(m, mpinvmod(piv,p)); m = resii(negi(m), p); for (j=i+1; j<=aco; j++) _Fp_addmul((GEN)a[j],k,i,m, p); for (j=1 ; j<=bco; j++) _Fp_addmul((GEN)b[j],k,i,m, p); } } if (low_stack(lim, stack_lim(av,1))) { GEN *gptr[2]; gptr[0]=&a; gptr[1]=&b; if(DEBUGMEM>1) err(warnmem,"FpM_gauss. i=%ld",i); gerepilemany(av,gptr,2); } } if(DEBUGLEVEL>4) fprintferr("Solving the triangular system\n"); u = cgetg(bco+1,t_MAT); for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a,(GEN)b[j],piv,aco,p); return gerepilecopy(av, iscol? (GEN)u[1]: u);}
piv = gcoeff(a,i,i);
FpM_gauss(GEN a, GEN b, GEN p){ pari_sp av,lim; long i,j,k,li,bco, aco = lg(a)-1; int iscol; GEN piv,m,u; if (typ(a)!=t_MAT) err(mattype1,"gauss"); if (b && typ(b)!=t_COL && typ(b)!=t_MAT) err(typeer,"gauss"); if (!aco) { if (b && lg(b)!=1) err(consister,"gauss"); if (DEBUGLEVEL) err(warner,"in Gauss lg(a)=1 lg(b)=%ld", b?1:-1); return cgetg(1,t_MAT); } li = lg(a[1])-1; if (li != aco && (li < aco || b)) err(mattype1,"gauss"); b = check_b(b,li, &iscol); av = avma; if (OK_ULONG(p)) { ulong pp=p[2]; a = u_Fp_FpM(a, pp); b = u_Fp_FpM(b, pp); u = u_FpM_gauss_sp(a,b, pp); u = iscol? small_to_col((GEN)u[1]): small_to_mat(u); return gerepileupto(av, u); } lim = stack_lim(av,1); a = dummycopy(a); bco = lg(b)-1; piv = NULL; /* gcc -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ coeff(a,i,i) = lresii(gcoeff(a,i,i), p); piv = gcoeff(a,i,i); k = i; if (!signe(piv)) { for (k++; k <= li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); if (signe(coeff(a,k,i))) break; } if (k>li) return NULL; } /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(coeff(a,i,j), coeff(a,k,j)); for (j=1; j<=bco; j++) swap(coeff(b,i,j), coeff(b,k,j)); piv = gcoeff(a,i,i); } if (i == aco) break; for (k=i+1; k<=li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); m = gcoeff(a,k,i); coeff(a,k,i) = zero; if (signe(m)) { m = mulii(m, mpinvmod(piv,p)); m = resii(negi(m), p); for (j=i+1; j<=aco; j++) _Fp_addmul((GEN)a[j],k,i,m, p); for (j=1 ; j<=bco; j++) _Fp_addmul((GEN)b[j],k,i,m, p); } } if (low_stack(lim, stack_lim(av,1))) { GEN *gptr[2]; gptr[0]=&a; gptr[1]=&b; if(DEBUGMEM>1) err(warnmem,"FpM_gauss. i=%ld",i); gerepilemany(av,gptr,2); } } if(DEBUGLEVEL>4) fprintferr("Solving the triangular system\n"); u = cgetg(bco+1,t_MAT); for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a,(GEN)b[j],piv,aco,p); return gerepilecopy(av, iscol? (GEN)u[1]: u);}
m = mulii(m, mpinvmod(piv,p)); m = resii(negi(m), p);
m = resii(mulii(m, minvpiv), p);
FpM_gauss(GEN a, GEN b, GEN p){ pari_sp av,lim; long i,j,k,li,bco, aco = lg(a)-1; int iscol; GEN piv,m,u; if (typ(a)!=t_MAT) err(mattype1,"gauss"); if (b && typ(b)!=t_COL && typ(b)!=t_MAT) err(typeer,"gauss"); if (!aco) { if (b && lg(b)!=1) err(consister,"gauss"); if (DEBUGLEVEL) err(warner,"in Gauss lg(a)=1 lg(b)=%ld", b?1:-1); return cgetg(1,t_MAT); } li = lg(a[1])-1; if (li != aco && (li < aco || b)) err(mattype1,"gauss"); b = check_b(b,li, &iscol); av = avma; if (OK_ULONG(p)) { ulong pp=p[2]; a = u_Fp_FpM(a, pp); b = u_Fp_FpM(b, pp); u = u_FpM_gauss_sp(a,b, pp); u = iscol? small_to_col((GEN)u[1]): small_to_mat(u); return gerepileupto(av, u); } lim = stack_lim(av,1); a = dummycopy(a); bco = lg(b)-1; piv = NULL; /* gcc -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ coeff(a,i,i) = lresii(gcoeff(a,i,i), p); piv = gcoeff(a,i,i); k = i; if (!signe(piv)) { for (k++; k <= li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); if (signe(coeff(a,k,i))) break; } if (k>li) return NULL; } /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(coeff(a,i,j), coeff(a,k,j)); for (j=1; j<=bco; j++) swap(coeff(b,i,j), coeff(b,k,j)); piv = gcoeff(a,i,i); } if (i == aco) break; for (k=i+1; k<=li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); m = gcoeff(a,k,i); coeff(a,k,i) = zero; if (signe(m)) { m = mulii(m, mpinvmod(piv,p)); m = resii(negi(m), p); for (j=i+1; j<=aco; j++) _Fp_addmul((GEN)a[j],k,i,m, p); for (j=1 ; j<=bco; j++) _Fp_addmul((GEN)b[j],k,i,m, p); } } if (low_stack(lim, stack_lim(av,1))) { GEN *gptr[2]; gptr[0]=&a; gptr[1]=&b; if(DEBUGMEM>1) err(warnmem,"FpM_gauss. i=%ld",i); gerepilemany(av,gptr,2); } } if(DEBUGLEVEL>4) fprintferr("Solving the triangular system\n"); u = cgetg(bco+1,t_MAT); for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a,(GEN)b[j],piv,aco,p); return gerepilecopy(av, iscol? (GEN)u[1]: u);}
GEN *gptr[2]; gptr[0]=&a; gptr[1]=&b;
FpM_gauss(GEN a, GEN b, GEN p){ pari_sp av,lim; long i,j,k,li,bco, aco = lg(a)-1; int iscol; GEN piv,m,u; if (typ(a)!=t_MAT) err(mattype1,"gauss"); if (b && typ(b)!=t_COL && typ(b)!=t_MAT) err(typeer,"gauss"); if (!aco) { if (b && lg(b)!=1) err(consister,"gauss"); if (DEBUGLEVEL) err(warner,"in Gauss lg(a)=1 lg(b)=%ld", b?1:-1); return cgetg(1,t_MAT); } li = lg(a[1])-1; if (li != aco && (li < aco || b)) err(mattype1,"gauss"); b = check_b(b,li, &iscol); av = avma; if (OK_ULONG(p)) { ulong pp=p[2]; a = u_Fp_FpM(a, pp); b = u_Fp_FpM(b, pp); u = u_FpM_gauss_sp(a,b, pp); u = iscol? small_to_col((GEN)u[1]): small_to_mat(u); return gerepileupto(av, u); } lim = stack_lim(av,1); a = dummycopy(a); bco = lg(b)-1; piv = NULL; /* gcc -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ coeff(a,i,i) = lresii(gcoeff(a,i,i), p); piv = gcoeff(a,i,i); k = i; if (!signe(piv)) { for (k++; k <= li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); if (signe(coeff(a,k,i))) break; } if (k>li) return NULL; } /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(coeff(a,i,j), coeff(a,k,j)); for (j=1; j<=bco; j++) swap(coeff(b,i,j), coeff(b,k,j)); piv = gcoeff(a,i,i); } if (i == aco) break; for (k=i+1; k<=li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); m = gcoeff(a,k,i); coeff(a,k,i) = zero; if (signe(m)) { m = mulii(m, mpinvmod(piv,p)); m = resii(negi(m), p); for (j=i+1; j<=aco; j++) _Fp_addmul((GEN)a[j],k,i,m, p); for (j=1 ; j<=bco; j++) _Fp_addmul((GEN)b[j],k,i,m, p); } } if (low_stack(lim, stack_lim(av,1))) { GEN *gptr[2]; gptr[0]=&a; gptr[1]=&b; if(DEBUGMEM>1) err(warnmem,"FpM_gauss. i=%ld",i); gerepilemany(av,gptr,2); } } if(DEBUGLEVEL>4) fprintferr("Solving the triangular system\n"); u = cgetg(bco+1,t_MAT); for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a,(GEN)b[j],piv,aco,p); return gerepilecopy(av, iscol? (GEN)u[1]: u);}
gerepilemany(av,gptr,2);
gerepileall(av,2, &a,&b);
FpM_gauss(GEN a, GEN b, GEN p){ pari_sp av,lim; long i,j,k,li,bco, aco = lg(a)-1; int iscol; GEN piv,m,u; if (typ(a)!=t_MAT) err(mattype1,"gauss"); if (b && typ(b)!=t_COL && typ(b)!=t_MAT) err(typeer,"gauss"); if (!aco) { if (b && lg(b)!=1) err(consister,"gauss"); if (DEBUGLEVEL) err(warner,"in Gauss lg(a)=1 lg(b)=%ld", b?1:-1); return cgetg(1,t_MAT); } li = lg(a[1])-1; if (li != aco && (li < aco || b)) err(mattype1,"gauss"); b = check_b(b,li, &iscol); av = avma; if (OK_ULONG(p)) { ulong pp=p[2]; a = u_Fp_FpM(a, pp); b = u_Fp_FpM(b, pp); u = u_FpM_gauss_sp(a,b, pp); u = iscol? small_to_col((GEN)u[1]): small_to_mat(u); return gerepileupto(av, u); } lim = stack_lim(av,1); a = dummycopy(a); bco = lg(b)-1; piv = NULL; /* gcc -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ coeff(a,i,i) = lresii(gcoeff(a,i,i), p); piv = gcoeff(a,i,i); k = i; if (!signe(piv)) { for (k++; k <= li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); if (signe(coeff(a,k,i))) break; } if (k>li) return NULL; } /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(coeff(a,i,j), coeff(a,k,j)); for (j=1; j<=bco; j++) swap(coeff(b,i,j), coeff(b,k,j)); piv = gcoeff(a,i,i); } if (i == aco) break; for (k=i+1; k<=li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); m = gcoeff(a,k,i); coeff(a,k,i) = zero; if (signe(m)) { m = mulii(m, mpinvmod(piv,p)); m = resii(negi(m), p); for (j=i+1; j<=aco; j++) _Fp_addmul((GEN)a[j],k,i,m, p); for (j=1 ; j<=bco; j++) _Fp_addmul((GEN)b[j],k,i,m, p); } } if (low_stack(lim, stack_lim(av,1))) { GEN *gptr[2]; gptr[0]=&a; gptr[1]=&b; if(DEBUGMEM>1) err(warnmem,"FpM_gauss. i=%ld",i); gerepilemany(av,gptr,2); } } if(DEBUGLEVEL>4) fprintferr("Solving the triangular system\n"); u = cgetg(bco+1,t_MAT); for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a,(GEN)b[j],piv,aco,p); return gerepilecopy(av, iscol? (GEN)u[1]: u);}
for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a,(GEN)b[j],piv,aco,p);
for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a, (GEN)b[j], invpiv, aco, p);
FpM_gauss(GEN a, GEN b, GEN p){ pari_sp av,lim; long i,j,k,li,bco, aco = lg(a)-1; int iscol; GEN piv,m,u; if (typ(a)!=t_MAT) err(mattype1,"gauss"); if (b && typ(b)!=t_COL && typ(b)!=t_MAT) err(typeer,"gauss"); if (!aco) { if (b && lg(b)!=1) err(consister,"gauss"); if (DEBUGLEVEL) err(warner,"in Gauss lg(a)=1 lg(b)=%ld", b?1:-1); return cgetg(1,t_MAT); } li = lg(a[1])-1; if (li != aco && (li < aco || b)) err(mattype1,"gauss"); b = check_b(b,li, &iscol); av = avma; if (OK_ULONG(p)) { ulong pp=p[2]; a = u_Fp_FpM(a, pp); b = u_Fp_FpM(b, pp); u = u_FpM_gauss_sp(a,b, pp); u = iscol? small_to_col((GEN)u[1]): small_to_mat(u); return gerepileupto(av, u); } lim = stack_lim(av,1); a = dummycopy(a); bco = lg(b)-1; piv = NULL; /* gcc -Wall */ for (i=1; i<=aco; i++) { /* k is the line where we find the pivot */ coeff(a,i,i) = lresii(gcoeff(a,i,i), p); piv = gcoeff(a,i,i); k = i; if (!signe(piv)) { for (k++; k <= li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); if (signe(coeff(a,k,i))) break; } if (k>li) return NULL; } /* if (k!=i), exchange the lines s.t. k = i */ if (k != i) { for (j=i; j<=aco; j++) swap(coeff(a,i,j), coeff(a,k,j)); for (j=1; j<=bco; j++) swap(coeff(b,i,j), coeff(b,k,j)); piv = gcoeff(a,i,i); } if (i == aco) break; for (k=i+1; k<=li; k++) { coeff(a,k,i) = lresii(gcoeff(a,k,i), p); m = gcoeff(a,k,i); coeff(a,k,i) = zero; if (signe(m)) { m = mulii(m, mpinvmod(piv,p)); m = resii(negi(m), p); for (j=i+1; j<=aco; j++) _Fp_addmul((GEN)a[j],k,i,m, p); for (j=1 ; j<=bco; j++) _Fp_addmul((GEN)b[j],k,i,m, p); } } if (low_stack(lim, stack_lim(av,1))) { GEN *gptr[2]; gptr[0]=&a; gptr[1]=&b; if(DEBUGMEM>1) err(warnmem,"FpM_gauss. i=%ld",i); gerepilemany(av,gptr,2); } } if(DEBUGLEVEL>4) fprintferr("Solving the triangular system\n"); u = cgetg(bco+1,t_MAT); for (j=1; j<=bco; j++) u[j] = (long)Fp_gauss_get_col(a,(GEN)b[j],piv,aco,p); return gerepilecopy(av, iscol? (GEN)u[1]: u);}
if (lgefint(p) == 3 && p[2] < (MAXHALFULONG>>1))
if (lgefint(p) == 3 && (ulong)p[2] < (MAXHALFULONG>>1))
FpM_ker_i(GEN x, GEN p, long nontriv){ GEN y,c,d,piv,mun; long i,j,k,r,t,n,m,av0,av,lim,tetpil; if (typ(x)!=t_MAT) err(typeer,"FpM_ker"); n=lg(x)-1; if (!n) return cgetg(1,t_MAT); if (lgefint(p) == 3 && p[2] < (MAXHALFULONG>>1)) return u_FpM_ker(x, p, nontriv); m=lg(x[1])-1; r=0; av0 = avma; x=dummycopy(x); mun=negi(gun); c=new_chunk(m+1); for (k=1; k<=m; k++) c[k]=0; d=new_chunk(n+1); av=avma; lim=stack_lim(av,1); for (k=1; k<=n; k++) { for (j=1; j<=m; j++) if (!c[j]) { coeff(x,j,k) = lmodii(gcoeff(x,j,k), p); if (signe(coeff(x,j,k))) break; } if (j>m) { if (nontriv) { avma = av0; return NULL; } r++; d[k]=0; for(j=1; j<k; j++) if (d[j]) coeff(x,d[j],k) = lclone(gcoeff(x,d[j],k)); } else { c[j]=k; d[k]=j; piv = negi(mpinvmod(gcoeff(x,j,k), p)); coeff(x,j,k) = (long)mun; for (i=k+1; i<=n; i++) coeff(x,j,i) = lmodii(mulii(piv,gcoeff(x,j,i)), p); for (t=1; t<=m; t++) if (t!=j) { piv = modii(gcoeff(x,t,k), p); if (signe(piv)) { coeff(x,t,k)=zero; for (i=k+1; i<=n; i++) coeff(x,t,i) = laddii(gcoeff(x,t,i),mulii(piv,gcoeff(x,j,i))); if (low_stack(lim, stack_lim(av,1))) gerepile_gauss_FpM_ker(x,p,m,n,k,t,av); } } } } tetpil=avma; y=cgetg(r+1,t_MAT); for (j=k=1; j<=r; j++,k++) { GEN c = cgetg(n+1,t_COL); y[j]=(long)c; while (d[k]) k++; for (i=1; i<k; i++) if (d[i]) { GEN p1=gcoeff(x,d[i],k); c[i] = lmodii(p1, p); gunclone(p1); } else c[i] = zero; c[k]=un; for (i=k+1; i<=n; i++) c[i]=zero; } return gerepile(av0,tetpil,y);}
for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { switch (line->keyword) { case UNUSED: case KEYWORD_OTHER: case KEYWORD_END: line->level = -1; break; case KEYWORD_CHAPTER: case KEYWORD_CHAPHEADING: currentlevel = 0; line->level = baselevel + currentlevel; break; case KEYWORD_SECTION: currentlevel = 1; line->level = baselevel + currentlevel; break; case KEYWORD_SUBSECTION: currentlevel = 2; line->level = baselevel + currentlevel; break; case KEYWORD_SUBSUBSECTION: currentlevel = 3; line->level = baselevel + currentlevel; break; case KEYWORD_RAISE: assert( baselevel ); baselevel--; line->level = -1; break; case KEYWORD_LOWER: baselevel++; line->level = -1; break; } }
void FormatToTexinfo( void ){ if ( Verbose ) fprintf( stderr, "-------->INSERTING TEXINFO MENUS\n" ); BuildTexinfoNodes();}
puts( "pthread_equal first id bad" ); status = pthread_equal( -1, Task_id ); assert( status == 0); puts( "pthread_equal second id bad" ); status = pthread_equal( Init_id, -1 ); assert( status == 0);
void *Task_1_through_3( void *argument){ int status; /* XXX temporary */ /* get id of this thread */ Task_id = pthread_self(); printf( "Task's ID is 0x%08x\n", Task_id ); status = pthread_equal( Task_id, Task_id ); if ( status ) puts( "pthread_equal match case passed" ); assert( status ); status = pthread_equal( Init_id, Task_id ); if ( !status ) puts( "pthread_equal different case passed" ); assert( !status ); puts( "*** END OF POSIX TEST 1 ***" ); exit( 0 ); return NULL; /* just so the compiler thinks we returned something */}
unsigned long n=pt->size / sizeof(PTERec); unsigned long i; PTE pte; for (i=0,pte=pt->base; i<n; i++,pte++) pte->marked=0;
unsigned long n = pt->size / sizeof (PTERec); unsigned long i; APte pte; for (i = 0, pte = pt->base; i < n; i++, pte++) pte->marked = 0;
unmarkAll(Triv121PgTbl pt){unsigned long n=pt->size / sizeof(PTERec);unsigned long i;PTE pte; for (i=0,pte=pt->base; i<n; i++,pte++) pte->marked=0;}
chprint_data[index].version = 1;
int check_chprint_file (int index){ char *chprint_cmdset_v01[6] = {"LOGIN", "CHROOM", "LOGOUT", "SENDMSG", "RECVERR", "KEEPALIVE"}; int i; char chprint_cmd[15]; /* check INFO-Section */ if (iniparser_find_entry(chprint_data[index].data, "INFO") == 0) { return 210; } else { if (iniparser_getstring(chprint_data[index].data, "INFO:Name", "NULL") == "NULL") { return 211; } if (iniparser_getstring(chprint_data[index].data, "INFO:LongName", "NULL") == "NULL") { return 211; } }/* check CMD-Section for **CHPRINT Version 0.1 commands */ if (iniparser_find_entry(chprint_data[index].data, "CMD") == 0) { return 212; } else { for(i = 0; i < 6; i++) { sprintf(chprint_cmd, "CMD:"); strcat(chprint_cmd, chprint_cmdset_v01[i]); if (iniparser_getstring(chprint_data[index].data, chprint_cmd, "NULL") == "NULL") { return 213; }/* check CMD-Section for Subsections */ if (strcmp(iniparser_getstring(chprint_data[index].data, chprint_cmd, "NULL"), "SUB") == 0) { sprintf(chprint_cmd, "CMD/"); strcat(chprint_cmd, chprint_cmdset_v01[i]); if (iniparser_find_entry(chprint_data[index].data, chprint_cmd) == 0) { return 214; } } } } return 0;}
tes = gadd(bernreal(i,prec), gdivgs(gmul(s5,tes), (i+1)*(i+2)));
tes = gadd(bernreal(i,prec), divgsns(gmul(s5,tes), i+1));
czeta(GEN s0, long prec){ GEN s, u, a, y, res, tes, sig, invn2, unr; GEN sim, *tab, tabn; long p, i, sqn, nn, lim, lim2, ct; pari_sp av, av2 = avma, avlim; int funeq = 0; byteptr d; if (DEBUGLEVEL>2) (void)timer2(); s = trans_fix_arg(&prec,&s0,&sig,&av,&res); if (gcmp0(s)) { y = gneg(ghalf); goto END; } if (gexpo(gsub(s, gun)) < -5 || (gexpo(s) > -5 && (signe(sig) <= 0 || expo(sig) < -1))) { /* s <--> 1-s */ if (typ(s0) == t_INT) { p = itos(s0); avma = av2; return szeta(p,prec); } funeq = 1; s = gsub(gun, s); sig = real_i(s); } if (gcmp(sig, stoi(bit_accuracy(prec) + 1)) > 0) { y = gun; goto END; } optim_zeta(s, prec, &lim, &nn); maxprime_check((ulong)nn); prec++; unr = realun(prec); /* one extra word of precision */ tab = (GEN*)cgetg(nn, t_VEC); /* table of q^(-s), q = p^e */ d = diffptr + 1; if (typ(s0) == t_INT) { /* no explog for 1/p^s */ for (p=2; p < nn;) { tab[p] = divrr(unr, rpowsi(p, s0, prec)); NEXT_PRIME_VIADIFF(p,d); } a = divrr(unr, rpowsi(nn, s0, prec)); } else { /* general case */ GEN ms = gneg(s), rp = cgetr(prec); for (p=2; p < nn;) { affsr(p, rp); tab[p] = gexp(gmul(ms, mplog(rp)), prec); NEXT_PRIME_VIADIFF(p,d); } affsr(nn, rp); a = gexp(gmul(ms, mplog(rp)), prec); } sqn = (long)sqrt(nn-1.); maxprime_check(sqn); d = diffptr + 2; /* fill in odd prime powers */ for (p=3; p <= sqn; ) { ulong oldq = p, q = p*p; while (q<(ulong)nn) { tab[q] = gmul(tab[p], tab[oldq]); oldq = q; q *= p; } NEXT_PRIME_VIADIFF(p,d); } if (DEBUGLEVEL>2) msgtimer("tab[q^-s] from 1 to N-1"); tabn = cgetg(nn, t_VECSMALL); ct = 0; for (i = nn-1; i; i>>=1) tabn[++ct] = (i-1)>>1; sim = y = unr; for (i=ct; i > 1; i--) { long j; pari_sp av2 = avma; for (j=tabn[i]+1; j<=tabn[i-1]; j++) sim = gadd(sim, n_s(2*j+1, tab)); sim = gerepileupto(av2, sim); y = gadd(sim, gmul(tab[2],y)); } y = gadd(y, gmul2n(a,-1)); if (DEBUGLEVEL>2) msgtimer("sum from 1 to N-1"); invn2 = divri(unr, mulss(nn,nn)); lim2 = lim<<1; tes = bernreal(lim2, prec); if (typ(s0) == t_INT) { av2 = avma; avlim = stack_lim(av2,3); for (i=lim2-2; i>=2; i-=2) { /* using single prec (when (s0 + i) < 2^31) not faster (even at \p28) */ u = mulri(mulrr(tes,invn2), mulii(addsi(i,s0), addsi(i-1,s0))); tes = addrr(bernreal(i,prec), divrsns(u, i+1)); /* u / (i+1)(i+2) */ if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"czeta"); tes = gerepileuptoleaf(av2, tes); } } u = gmul(gmul(tes,invn2), gmul2n(mulii(s0, addsi(-1,s0)), -1)); tes = gmulsg(nn, gaddsg(1, u)); } else /* typ(s0) != t_INT */ { GEN s1, s2, s3, s4, s5; s1 = gsub(gmul2n(s,1), unr); s2 = gmul(s, gsub(s,unr)); s3 = gmul2n(invn2,3); av2 = avma; avlim = stack_lim(av2,3); s4 = gmul(invn2, gmul2n(gaddsg(4*lim-2,s1),1)); s5 = gmul(invn2, gadd(s2, gmulsg(lim2, gaddgs(s1, lim2)))); for (i = lim2-2; i>=2; i -= 2) { s5 = gsub(s5, s4); s4 = gsub(s4, s3); tes = gadd(bernreal(i,prec), gdivgs(gmul(s5,tes), (i+1)*(i+2))); if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"czeta"); gerepileall(av2,3, &tes,&s5,&s4); } } u = gmul(gmul(tes,invn2), gmul2n(s2, -1)); tes = gmulsg(nn, gaddsg(1, u)); } if (DEBUGLEVEL>2) msgtimer("Bernoulli sum"); /* y += tes n^(-s) / (s-1) */ y = gadd(y, gmul(tes, gdiv(a, gsub(s, unr))));END: if (funeq) { y = gmul(gmul(y, ggamma(gprec_w(s,prec),prec)), gpow(Pi2n(1,prec), gneg(s), prec)); y = gmul2n(gmul(y, gcos(gmul(Pi2n(-1,prec),s), prec)), 1); } gaffect(y,res); avma = av; return res;}
if (DEBUGLEVEL>=6) fprintferr("GaloisConj: Fixed field %Z\n",P);
galoisgenfixedfield(GEN Tp, GEN Pmod, GEN V, GEN ip, struct galois_borne *gb, GEN Pg){ gpmem_t ltop=avma; GEN P, PL, Pden, PM, Pp, Pladicabs; GEN tau, PG; long g,gp; long x=varn(Tp); P=(GEN)V[2]; PL=(GEN)V[1]; gp=lg(Pmod)-1; Pp = FpX_red(P,ip); if (degpol(P)==2) { PG=cgetg(3,t_VEC); PG[1]=lgetg(2,t_VEC); PG[2]=lgetg(2,t_VECSMALL); mael(PG,1,1)=lgetg(3,t_VECSMALL); mael(PG,2,1)=2; mael3(PG,1,1,1)=2; mael3(PG,1,1,2)=1; tau=deg1pol(stoi(-1),negi((GEN)P[3]),x); tau = lift(gmul(tau,gmodulcp(gun,ip))); tau = FpX_FpXQ_compo((GEN) Pmod[gp], tau,Pp,ip); tau = FpX_gcd(Pp, tau,ip); tau = FpX_Fp_mul(tau,mpinvmod((GEN) tau[lgef(tau) - 1],ip),ip); for (g = 1; g <= gp; g++) if (gegal(tau, (GEN) Pmod[g])) break; if (g == lg(Pmod)) return NULL; Pg[1]=g; } else { struct galois_analysis Pga; struct galois_borne Pgb; long j; galoisanalysis(P, &Pga, 0, 0); if (Pga.deg == 0) return NULL; /* Avoid computing the discriminant */ Pgb.l = gb->l; Pden = galoisborne(P, NULL, &Pgb, Pga.ppp); Pladicabs=Pgb.ladicabs; if (Pgb.valabs > gb->valabs) { if (DEBUGLEVEL>=4) fprintferr("GaloisConj:increase prec of p-adic roots of %ld.\n" ,Pgb.valabs-gb->valabs); PL = rootpadicliftroots(P,PL,gb->l,Pgb.valabs); } PM = vandermondeinversemod(PL, P, Pden, Pgb.ladicabs); PG = galoisgen(P, PL, PM, Pden, &Pgb, &Pga); if (PG == gzero) return NULL; for (j = 1; j < lg(PG[1]); j++) { gpmem_t btop=avma; tau = permtopol(gmael(PG,1,j), PL, PM, Pden, Pladicabs, x); tau = lift(gmul(tau,gmodulcp(gun,ip))); tau = FpX_FpXQ_compo((GEN) Pmod[gp], tau,Pp,ip); tau = FpX_gcd(Pp, tau,ip); tau = FpX_Fp_mul(tau,mpinvmod((GEN) tau[lgef(tau) - 1],ip),ip); for (g = 1; g < lg(Pmod); g++) if (gegal(tau, (GEN) Pmod[g])) break; if (g == lg(Pmod)) return NULL; avma=btop; Pg[j]=g; } } return gerepilecopy(ltop,PG);}
k = serf_bucket_mem_alloc(bkt->allocator, end_key - ctx->line + 1); v = serf_bucket_mem_alloc(bkt->allocator, (ctx->line + ctx->line_used) - c); memcpy(k, ctx->line, end_key - ctx->line); k[end_key - ctx->line] = '\0'; memcpy(v, c, (ctx->line + ctx->line_used) - c); v[(ctx->line + ctx->line_used) - c] = '\0';
k = serf_bstrmemdup(bkt->allocator, ctx->line, end_key - ctx->line); v = serf_bstrmemdup(bkt->allocator, c, ctx->line + ctx->line_used - c);
static apr_status_t run_machine(serf_bucket_t *bkt, response_context_t *ctx){ apr_status_t status; switch (ctx->state) { case STATE_STATUS_LINE: status = fetch_line(ctx, ctx->stream); if (!status) { ctx->state = STATE_HEADERS; } break; case STATE_HEADERS: do { status = fetch_line(ctx, ctx->stream); if (status) { return status; } if (ctx->lstate == LINE_READY && ctx->line_used) { const char *end_key, *c; char *k, *v; end_key = c = memchr(ctx->line, ':', ctx->line_used); if (!c) { /* Bad headers? */ return APR_EGENERAL; } /* Skip over initial : and spaces. */ while (apr_isspace(*++c)); k = serf_bucket_mem_alloc(bkt->allocator, end_key - ctx->line + 1); v = serf_bucket_mem_alloc(bkt->allocator, (ctx->line + ctx->line_used) - c); memcpy(k, ctx->line, end_key - ctx->line); k[end_key - ctx->line] = '\0'; memcpy(v, c, (ctx->line + ctx->line_used) - c); v[(ctx->line + ctx->line_used) - c] = '\0'; serf_bucket_set_metadata(bkt, SERF_RESPONSE_HEADERS, k, v); } } while (!status && ctx->line_used); if (!status) { const void *v; /* Are we C-L, chunked, or conn close? */ serf_bucket_get_metadata(bkt, SERF_RESPONSE_HEADERS, "Content-Length", &v); if (v) { const char *cl = v; ctx->chunked = 0; ctx->body_left = apr_strtoi64(v, NULL, 10); if (errno == ERANGE) { return errno; } } ctx->state = STATE_BODY; } break; case STATE_BODY: /* Don't do anything. */ break; default: abort(); } return status;}
if (typ(perm) != t_VECSMALL) err(typeer, "galoispermtopol"); return permtopol(perm, (GEN) gal[3], (GEN) gal[4], (GEN) gal[5], varn((GEN) gal[1]));
switch (t) { case t_VECSMALL: return permtopol(perm, (GEN) gal[3], (GEN) gal[4], (GEN) gal[5], varn((GEN) gal[1])); case t_VEC: case t_COL: case t_MAT: v = cgetg(lg(perm), t); for (i = 1; i < lg(v); i++) v[i] = (long) galoispermtopol(gal, (GEN) perm[i]); return v; } err(typeer, "galoispermtopol"); return NULL;
galoispermtopol(GEN gal, GEN perm){ gal = checkgal(gal); if (typ(perm) != t_VECSMALL) err(typeer, "galoispermtopol"); return permtopol(perm, (GEN) gal[3], (GEN) gal[4], (GEN) gal[5], varn((GEN) gal[1]));}
GEN B, norm, u;
GEN B, norm, u, up;
LLL_check_progress(GEN Bnorm, GEN m, long r, long C, GEN *ML, long id, long *ti_LLL){ GEN B, norm, u; long i, s, R; if (DEBUGLEVEL>2) (void)gentimer(id); m = lllint_ip(m, 4); u = lllint_i(m, 1000, 0, NULL, NULL, &B); if (DEBUGLEVEL>2) *ti_LLL += gentimer(id); norm = GS_norms(B, DEFAULTPREC); for (R=lg(m)-1; R > 0; R--) if (cmprr((GEN)norm[R], Bnorm) < 0) break; if (R > r) return R; /* no progress */ if (R <= 1) { if (R == 0) err(bugparier,"LLL_cmbf [no factor]"); return R; } setlg(u, R+1); for (i=1; i<=R; i++) setlg(u[i], r+1); if (C != 1) u = gdivexact(u, stoi(C)); s = R; u = image(u); R = lg(u)-1; if (DEBUGLEVEL>2 && R < s) fprintferr("LLL_cmbf: free rank decrease = %ld\n", R - s); *ML = gmul(*ML, u); return R;}
s = R; u = image(u); R = lg(u)-1; if (DEBUGLEVEL>2 && R < s) fprintferr("LLL_cmbf: free rank decrease = %ld\n", R - s);
up = FpM_image(u, stoi(27449)); if (lg(up) != lg(u)) { s = R; u = image(u); R = lg(u)-1; if (DEBUGLEVEL>2 && R < s) fprintferr("LLL_cmbf: free rank decrease = %ld\n", R - s); }
LLL_check_progress(GEN Bnorm, GEN m, long r, long C, GEN *ML, long id, long *ti_LLL){ GEN B, norm, u; long i, s, R; if (DEBUGLEVEL>2) (void)gentimer(id); m = lllint_ip(m, 4); u = lllint_i(m, 1000, 0, NULL, NULL, &B); if (DEBUGLEVEL>2) *ti_LLL += gentimer(id); norm = GS_norms(B, DEFAULTPREC); for (R=lg(m)-1; R > 0; R--) if (cmprr((GEN)norm[R], Bnorm) < 0) break; if (R > r) return R; /* no progress */ if (R <= 1) { if (R == 0) err(bugparier,"LLL_cmbf [no factor]"); return R; } setlg(u, R+1); for (i=1; i<=R; i++) setlg(u[i], r+1); if (C != 1) u = gdivexact(u, stoi(C)); s = R; u = image(u); R = lg(u)-1; if (DEBUGLEVEL>2 && R < s) fprintferr("LLL_cmbf: free rank decrease = %ld\n", R - s); *ML = gmul(*ML, u); return R;}
if (lx==1) { pariputs("[;]\n"); return; } pariputc('\n'); l=lg(g[1]);
if (lx==1 || lg(g[1]) == 1) { pariputs("[;]\n"); return; } l = lg(g[1]); pariputc('\n');
sori(GEN g, pariout_t *T){ long tg=typ(g), i,j,r,l,close_paren; GEN a,b; const char *v; char buf[32]; if (tg == t_INT) { wr_int(T,g,1); return; } if (tg != t_MAT && tg != t_COL) T->fieldw = 0; switch (tg) { case t_REAL: wr_real(T,g,1); return; case t_STR: quote_string(GSTR(g)); return; case t_LIST: pariputs("List("); l = lgeflist(g); for (i=2; i<l; i++) { sori((GEN)g[i], T); if (i < l-1) pariputs(", "); } pariputs(")\n"); return; } close_paren = 0; if (!is_graphicvec_t(tg)) { if (tg == t_FRAC && gsigne(g) < 0) pariputc('-'); pariputc('('); close_paren = 1; } switch(tg) { case t_INTMOD: case t_POLMOD: a = (GEN)g[2]; b = (GEN)g[1]; if (tg == t_INTMOD && signe(a) < 0) a = addii(a,b); sori(a,T); pariputs(" mod "); sori(b,T); break; case t_FRAC: a=(GEN)g[1]; wr_int(T,a,0); pariputs(" /"); b=(GEN)g[2]; wr_int(T,b,0); break; case t_COMPLEX: case t_QUAD: r = (tg==t_QUAD); a = (GEN)g[r+1]; b = (GEN)g[r+2]; v = r? "w": "I"; if (isnull(a)) { sor_lead_monome(T,b,v,1); break; } sori(a,T); if (!isnull(b)) sor_monome(T,b,v,1); break; case t_PADIC: { GEN p = (GEN)g[2]; char *ev; i = valp(g); l = precp(g)+i; g = (GEN)g[4]; ev = GENtostr(p); for (; i<l; i++) { g = dvmdii(g,p,&a); if (signe(a)) { if (!i || !is_pm1(a)) { wr_int(T,a,1); pariputc(i? '*': ' '); } if (i) { padic_nome(ev,i); pariputc(' '); } pariputs("+ "); } } pariputs("O("); if (!i) pariputs(" 1)"); else padic_nome(ev,i); pariputc(')'); free(ev); break; } case t_POL: if (!signe(g)) { pariputc('0'); break; } v = get_var(ordvar[varn(g)],buf); i = degpol(g); g += 2; while (isnull((GEN)g[i])) i--; sor_lead_monome(T,(GEN)g[i],v,i); while (i--) { a = (GEN)g[i]; if (!isnull_for_pol(a)) sor_monome(T,a,v,i); } break; case t_SER: v = get_var(ordvar[varn(g)],buf); i = valp(g); if (signe(g)) { /* hack: we want g[i] = coeff of degree i. */ l = i + lg(g)-2; g += (2-i); sor_lead_monome(T,(GEN)g[i],v,i); while (++i < l) { a = (GEN)g[i]; if (!isnull_for_pol(a)) sor_monome(T,a,v,i); } pariputs(" + "); } pariputs("O("); if (!i) pariputs(" 1)"); else monome(v,i); pariputc(')'); break; case t_RFRAC: sori((GEN)g[1],T); pariputs(" / "); sori((GEN)g[2],T); break; case t_QFR: case t_QFI: pariputc('{'); sori((GEN)g[1],T); pariputs(", "); sori((GEN)g[2],T); pariputs(", "); sori((GEN)g[3],T); if (tg == t_QFR) { pariputs(", "); sori((GEN)g[4],T); } pariputs("}\n"); break; case t_VEC: pariputc('['); for (i=1; i<lg(g); i++) { sori((GEN)g[i],T); if (i<lg(g)-1) pariputs(", "); } pariputc(']'); break; case t_VECSMALL: wr_vecsmall(T,g); break; case t_COL: if (lg(g)==1) { pariputs("[]\n"); return; } pariputc('\n'); for (i=1; i<lg(g); i++) { pariputc('['); sori((GEN)g[i],T); pariputs("]\n"); } break; case t_MAT: { void (*print)(GEN, pariout_t *); long lx = lg(g); if (lx==1) { pariputs("[;]\n"); return; } pariputc('\n'); l=lg(g[1]); print = (typ(g[1]) == t_VECSMALL)? sors: sori; for (i=1; i<l; i++) { pariputc('['); for (j=1; j<lx; j++) { print(gcoeff(g,i,j),T); if (j<lx-1) pariputc(' '); } pariputs("]\n"); if (i<l-1) pariputc('\n'); } break; } default: sorstring(VOIR_STRING2,*g); } if (close_paren) pariputc(')');}
if (phase == PHASE_DEAD)
if (pppd_phase == PHASE_DEAD)
link_terminated(unit) int unit;{ if (phase == PHASE_DEAD) return; if (pap_logout_hook) { pap_logout_hook(); } new_phase(PHASE_DEAD); notice("Connection terminated.");}
printf (" Discarded:%-8lu\n", (unsigned long)m860.scc1p.un.ethernet.disfc);
printf (" Discarded:%-8lu\n", (unsigned long)m8xx.scc1p.un.ethernet.disfc);
enet_stats (struct m860_enet_struct *sc){ printf (" Rx Interrupts:%-8lu", sc->rxInterrupts); printf (" Not First:%-8lu", sc->rxNotFirst); printf (" Not Last:%-8lu\n", sc->rxNotLast); printf (" Giant:%-8lu", sc->rxGiant); printf (" Runt:%-8lu", sc->rxRunt); printf (" Non-octet:%-8lu\n", sc->rxNonOctet); printf (" Bad CRC:%-8lu", sc->rxBadCRC); printf (" Overrun:%-8lu", sc->rxOverrun); printf (" Collision:%-8lu\n", sc->rxCollision); printf (" Discarded:%-8lu\n", (unsigned long)m860.scc1p.un.ethernet.disfc); printf (" Tx Interrupts:%-8lu", sc->txInterrupts); printf (" Deferred:%-8lu", sc->txDeferred); printf (" Missed Hearbeat:%-8lu\n", sc->txHeartbeat); printf (" No Carrier:%-8lu", sc->txLostCarrier); printf ("Retransmit Limit:%-8lu", sc->txRetryLimit); printf (" Late Collision:%-8lu\n", sc->txLateCollision); printf (" Underrun:%-8lu", sc->txUnderrun); printf (" Raw output wait:%-8lu\n", sc->txRawWait);}
Objects_Name name,
rtems_name name,
rtems_status_code rtems_partition_create( Objects_Name name, void *starting_address, unsigned32 length, unsigned32 buffer_size, rtems_attribute attribute_set, Objects_Id *id){ register Partition_Control *the_partition; if ( !_Objects_Is_name_valid( name ) ) return ( RTEMS_INVALID_NAME ); if ( length == 0 || buffer_size == 0 || length < buffer_size || !_Partition_Is_buffer_size_aligned( buffer_size ) ) return ( RTEMS_INVALID_SIZE ); if ( !_Addresses_Is_aligned( starting_address ) ) return( RTEMS_INVALID_ADDRESS ); if ( _Attributes_Is_global( attribute_set ) && !_Configuration_Is_multiprocessing() ) return( RTEMS_MP_NOT_CONFIGURED ); _Thread_Disable_dispatch(); /* prevents deletion */ the_partition = _Partition_Allocate(); if ( !the_partition ) { _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } if ( _Attributes_Is_global( attribute_set ) && !( _Objects_MP_Open( &_Partition_Information, name, the_partition->Object.id, FALSE ) ) ) { _Partition_Free( the_partition ); _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } the_partition->starting_address = starting_address; the_partition->length = length; the_partition->buffer_size = buffer_size; the_partition->attribute_set = attribute_set; the_partition->number_of_used_blocks = 0; _Chain_Initialize( &the_partition->Memory, starting_address, length / buffer_size, buffer_size ); _Objects_Open( &_Partition_Information, &the_partition->Object, name ); *id = the_partition->Object.id; if ( _Attributes_Is_global( attribute_set ) ) _Partition_MP_Send_process_packet( PARTITION_MP_ANNOUNCE_CREATE, the_partition->Object.id, name, 0 /* Not used */ ); _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL );}
if ( !_Objects_Is_name_valid( name ) )
if ( !rtems_is_name_valid( name ) )
rtems_status_code rtems_partition_create( Objects_Name name, void *starting_address, unsigned32 length, unsigned32 buffer_size, rtems_attribute attribute_set, Objects_Id *id){ register Partition_Control *the_partition; if ( !_Objects_Is_name_valid( name ) ) return ( RTEMS_INVALID_NAME ); if ( length == 0 || buffer_size == 0 || length < buffer_size || !_Partition_Is_buffer_size_aligned( buffer_size ) ) return ( RTEMS_INVALID_SIZE ); if ( !_Addresses_Is_aligned( starting_address ) ) return( RTEMS_INVALID_ADDRESS ); if ( _Attributes_Is_global( attribute_set ) && !_Configuration_Is_multiprocessing() ) return( RTEMS_MP_NOT_CONFIGURED ); _Thread_Disable_dispatch(); /* prevents deletion */ the_partition = _Partition_Allocate(); if ( !the_partition ) { _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } if ( _Attributes_Is_global( attribute_set ) && !( _Objects_MP_Open( &_Partition_Information, name, the_partition->Object.id, FALSE ) ) ) { _Partition_Free( the_partition ); _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } the_partition->starting_address = starting_address; the_partition->length = length; the_partition->buffer_size = buffer_size; the_partition->attribute_set = attribute_set; the_partition->number_of_used_blocks = 0; _Chain_Initialize( &the_partition->Memory, starting_address, length / buffer_size, buffer_size ); _Objects_Open( &_Partition_Information, &the_partition->Object, name ); *id = the_partition->Object.id; if ( _Attributes_Is_global( attribute_set ) ) _Partition_MP_Send_process_packet( PARTITION_MP_ANNOUNCE_CREATE, the_partition->Object.id, name, 0 /* Not used */ ); _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL );}
_Objects_Open( &_Partition_Information, &the_partition->Object, name );
_Objects_Open( &_Partition_Information, &the_partition->Object, &name );
rtems_status_code rtems_partition_create( Objects_Name name, void *starting_address, unsigned32 length, unsigned32 buffer_size, rtems_attribute attribute_set, Objects_Id *id){ register Partition_Control *the_partition; if ( !_Objects_Is_name_valid( name ) ) return ( RTEMS_INVALID_NAME ); if ( length == 0 || buffer_size == 0 || length < buffer_size || !_Partition_Is_buffer_size_aligned( buffer_size ) ) return ( RTEMS_INVALID_SIZE ); if ( !_Addresses_Is_aligned( starting_address ) ) return( RTEMS_INVALID_ADDRESS ); if ( _Attributes_Is_global( attribute_set ) && !_Configuration_Is_multiprocessing() ) return( RTEMS_MP_NOT_CONFIGURED ); _Thread_Disable_dispatch(); /* prevents deletion */ the_partition = _Partition_Allocate(); if ( !the_partition ) { _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } if ( _Attributes_Is_global( attribute_set ) && !( _Objects_MP_Open( &_Partition_Information, name, the_partition->Object.id, FALSE ) ) ) { _Partition_Free( the_partition ); _Thread_Enable_dispatch(); return( RTEMS_TOO_MANY ); } the_partition->starting_address = starting_address; the_partition->length = length; the_partition->buffer_size = buffer_size; the_partition->attribute_set = attribute_set; the_partition->number_of_used_blocks = 0; _Chain_Initialize( &the_partition->Memory, starting_address, length / buffer_size, buffer_size ); _Objects_Open( &_Partition_Information, &the_partition->Object, name ); *id = the_partition->Object.id; if ( _Attributes_Is_global( attribute_set ) ) _Partition_MP_Send_process_packet( PARTITION_MP_ANNOUNCE_CREATE, the_partition->Object.id, name, 0 /* Not used */ ); _Thread_Enable_dispatch(); return( RTEMS_SUCCESSFUL );}
Objects_Name name,
rtems_name name,
rtems_status_code rtems_partition_ident( Objects_Name name, unsigned32 node, Objects_Id *id){ return( _Objects_Name_to_id( &_Partition_Information, name, node, id ) );}
return( _Objects_Name_to_id( &_Partition_Information, name, node, id ) );
return _Objects_Name_to_id( &_Partition_Information, &name, node, id );
rtems_status_code rtems_partition_ident( Objects_Name name, unsigned32 node, Objects_Id *id){ return( _Objects_Name_to_id( &_Partition_Information, name, node, id ) );}
_MESSAGE_QUEUE_CORE_MESSAGE_QUEUE_MP_SUPPORT
rtems_status_code _Message_queue_Submit( Objects_Id id, void *buffer, unsigned32 size, Message_queue_Submit_types submit_type){ register Message_queue_Control *the_message_queue; Objects_Locations location; CORE_message_queue_Status core_status; the_message_queue = _Message_queue_Get( id, &location ); switch ( location ) { case OBJECTS_REMOTE:#if defined(RTEMS_MULTIPROCESSING) switch ( submit_type ) { case MESSAGE_QUEUE_SEND_REQUEST: return _Message_queue_MP_Send_request_packet( MESSAGE_QUEUE_MP_SEND_REQUEST, id, buffer, &size, 0, /* option_set */ MPCI_DEFAULT_TIMEOUT ); case MESSAGE_QUEUE_URGENT_REQUEST: return _Message_queue_MP_Send_request_packet( MESSAGE_QUEUE_MP_URGENT_REQUEST, id, buffer, &size, 0, /* option_set */ MPCI_DEFAULT_TIMEOUT ); } break;#endif case OBJECTS_ERROR: return RTEMS_INVALID_ID; case OBJECTS_LOCAL: switch ( submit_type ) { case MESSAGE_QUEUE_SEND_REQUEST: core_status = _CORE_message_queue_Send( &the_message_queue->message_queue, buffer, size, id,#if defined(RTEMS_MULTIPROCESSING) _Message_queue_Core_message_queue_mp_support#else NULL#endif ); break; case MESSAGE_QUEUE_URGENT_REQUEST: core_status = _CORE_message_queue_Urgent( &the_message_queue->message_queue, buffer, size, id,#if defined(RTEMS_MULTIPROCESSING) _Message_queue_Core_message_queue_mp_support#else NULL#endif ); break; default: core_status = CORE_MESSAGE_QUEUE_STATUS_SUCCESSFUL; return RTEMS_INTERNAL_ERROR; /* should never get here */ } _Thread_Enable_dispatch(); return _Message_queue_Translate_core_message_queue_return_code( core_status ); } return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */}
if ( the_thread_queue->sync ) {
if ( the_thread_queue->sync && the_thread_queue->sync_state != THREAD_QUEUE_SATISFIED ) {
Thread_Control *_Thread_queue_Dequeue_priority( Thread_queue_Control *the_thread_queue){ unsigned32 index; ISR_Level level; Thread_Control *the_thread; Thread_Control *new_first_thread; Chain_Node *new_first_node; Chain_Node *new_second_node; Chain_Node *last_node; Chain_Node *next_node; Chain_Node *previous_node; _ISR_Disable( level ); for( index=0 ; index < TASK_QUEUE_DATA_NUMBER_OF_PRIORITY_HEADERS ; index++ ) { if ( !_Chain_Is_empty( &the_thread_queue->Queues.Priority[ index ] ) ) { the_thread = (Thread_Control *) the_thread_queue->Queues.Priority[ index ].first; goto dequeue; } } if ( the_thread_queue->sync ) { the_thread_queue->sync_state = THREAD_QUEUE_SATISFIED; _ISR_Enable( level ); return _Thread_Executing; } _ISR_Enable( level ); return NULL;dequeue: new_first_node = the_thread->Wait.Block2n.first; new_first_thread = (Thread_Control *) new_first_node; next_node = the_thread->Object.Node.next; previous_node = the_thread->Object.Node.previous; if ( !_Chain_Is_empty( &the_thread->Wait.Block2n ) ) { last_node = the_thread->Wait.Block2n.last; new_second_node = new_first_node->next; previous_node->next = new_first_node; next_node->previous = new_first_node; new_first_node->next = next_node; new_first_node->previous = previous_node; if ( !_Chain_Has_only_one_node( &the_thread->Wait.Block2n ) ) { /* > two threads on 2-n */ new_second_node->previous = _Chain_Head( &new_first_thread->Wait.Block2n ); new_first_thread->Wait.Block2n.first = new_second_node; new_first_thread->Wait.Block2n.last = last_node; last_node->next = _Chain_Tail( &new_first_thread->Wait.Block2n ); } } else { previous_node->next = next_node; next_node->previous = previous_node; } if ( !_Watchdog_Is_active( &the_thread->Timer ) ) { _ISR_Enable( level ); _Thread_Unblock( the_thread ); } else { _Watchdog_Deactivate( &the_thread->Timer ); _ISR_Enable( level ); (void) _Watchdog_Remove( &the_thread->Timer ); _Thread_Unblock( the_thread ); } if ( !_Objects_Is_local_id( the_thread->Object.id ) ) _Thread_MP_Free_proxy( the_thread ); return( the_thread );}
the_thread_queue->sync = FALSE;
void _Thread_queue_Enqueue_priority( Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, Watchdog_Interval timeout){ Priority_Control search_priority; Thread_Control *search_thread; ISR_Level level; Chain_Control *header; unsigned32 header_index; Chain_Node *the_node; Chain_Node *next_node; Chain_Node *previous_node; Chain_Node *search_node; Priority_Control priority; States_Control block_state; _Chain_Initialize_empty( &the_thread->Wait.Block2n ); priority = the_thread->current_priority; header_index = _Thread_queue_Header_number( priority ); header = &the_thread_queue->Queues.Priority[ header_index ]; block_state = the_thread_queue->state; if ( _Thread_queue_Is_reverse_search( priority ) ) goto restart_reverse_search;restart_forward_search: search_priority = PRIORITY_MINIMUM - 1; _ISR_Disable( level ); search_thread = (Thread_Control *) header->first; while ( !_Chain_Is_tail( header, (Chain_Node *)search_thread ) ) { search_priority = search_thread->current_priority; if ( priority <= search_priority ) break;#if ( CPU_UNROLL_ENQUEUE_PRIORITY == TRUE ) search_thread = (Thread_Control *) search_thread->Object.Node.next; if ( _Chain_Is_tail( header, (Chain_Node *)search_thread ) ) break; search_priority = search_thread->current_priority; if ( priority <= search_priority ) break;#endif _ISR_Flash( level ); if ( !_States_Are_set( search_thread->current_state, block_state) ) { _ISR_Enable( level ); goto restart_forward_search; } search_thread = (Thread_Control *)search_thread->Object.Node.next; } if ( the_thread_queue->sync_state != THREAD_QUEUE_NOTHING_HAPPENED ) goto syncronize; the_thread_queue->sync = FALSE; if ( priority == search_priority ) goto equal_priority; search_node = (Chain_Node *) search_thread; previous_node = search_node->previous; the_node = (Chain_Node *) the_thread; the_node->next = search_node; the_node->previous = previous_node; previous_node->next = the_node; search_node->previous = the_node; _ISR_Enable( level ); return;restart_reverse_search: search_priority = PRIORITY_MAXIMUM + 1; _ISR_Disable( level ); search_thread = (Thread_Control *) header->last; while ( !_Chain_Is_head( header, (Chain_Node *)search_thread ) ) { search_priority = search_thread->current_priority; if ( priority >= search_priority ) break;#if ( CPU_UNROLL_ENQUEUE_PRIORITY == TRUE ) search_thread = (Thread_Control *) search_thread->Object.Node.previous; if ( _Chain_Is_head( header, (Chain_Node *)search_thread ) ) break; search_priority = search_thread->current_priority; if ( priority >= search_priority ) break;#endif _ISR_Flash( level ); if ( !_States_Are_set( search_thread->current_state, block_state) ) { _ISR_Enable( level ); goto restart_reverse_search; } search_thread = (Thread_Control *) search_thread->Object.Node.previous; } if ( the_thread_queue->sync_state != THREAD_QUEUE_NOTHING_HAPPENED ) goto syncronize; the_thread_queue->sync = FALSE; if ( priority == search_priority ) goto equal_priority; search_node = (Chain_Node *) search_thread; next_node = search_node->next; the_node = (Chain_Node *) the_thread; the_node->next = next_node; the_node->previous = search_node; search_node->next = the_node; next_node->previous = the_node; _ISR_Enable( level ); return;equal_priority: /* add at end of priority group */ search_node = _Chain_Tail( &search_thread->Wait.Block2n ); previous_node = search_node->previous; the_node = (Chain_Node *) the_thread; the_node->next = search_node; the_node->previous = previous_node; previous_node->next = the_node; search_node->previous = the_node; _ISR_Enable( level ); return;syncronize: switch ( the_thread_queue->sync_state ) { case THREAD_QUEUE_NOTHING_HAPPENED: /* * All of this was dealt with above. This should never happen. */ break; case THREAD_QUEUE_TIMEOUT: the_thread->Wait.return_code = the_thread->Wait.queue->timeout_status; _ISR_Enable( level ); break; case THREAD_QUEUE_SATISFIED: if ( _Watchdog_Is_active( &the_thread->Timer ) ) { _Watchdog_Deactivate( &the_thread->Timer ); _ISR_Enable( level ); (void) _Watchdog_Remove( &the_thread->Timer ); } else _ISR_Enable( level ); break; } /* * Global objects with thread queue's should not be operated on from an * ISR. But the sync code still must allow short timeouts to be processed * correctly. */ _Thread_Unblock( the_thread ); if ( !_Objects_Is_local_id( the_thread->Object.id ) ) _Thread_MP_Free_proxy( the_thread );}
the_thread_queue->sync = FALSE;
void _Thread_queue_Enqueue_fifo ( Thread_queue_Control *the_thread_queue, Thread_Control *the_thread, Watchdog_Interval timeout){ ISR_Level level; _ISR_Disable( level ); switch ( the_thread_queue->sync_state ) { case THREAD_QUEUE_NOTHING_HAPPENED: the_thread_queue->sync = FALSE; _Chain_Append_unprotected( &the_thread_queue->Queues.Fifo, &the_thread->Object.Node ); _ISR_Enable( level ); return; case THREAD_QUEUE_TIMEOUT: the_thread->Wait.return_code = the_thread->Wait.queue->timeout_status; _ISR_Enable( level ); break; case THREAD_QUEUE_SATISFIED: if ( _Watchdog_Is_active( &the_thread->Timer ) ) { _Watchdog_Deactivate( &the_thread->Timer ); _ISR_Enable( level ); (void) _Watchdog_Remove( &the_thread->Timer ); } else _ISR_Enable( level ); break; } /* * Global objects with thread queue's should not be operated on from an * ISR. But the sync code still must allow short timeouts to be processed * correctly. */ _Thread_Unblock( the_thread ); if ( !_Objects_Is_local_id( the_thread->Object.id ) ) _Thread_MP_Free_proxy( the_thread );}
} else if ( the_thread_queue->sync ) {
} else if ( the_thread_queue->sync && the_thread_queue->sync_state != THREAD_QUEUE_SATISFIED ) {
Thread_Control *_Thread_queue_Dequeue_fifo( Thread_queue_Control *the_thread_queue){ ISR_Level level; Thread_Control *the_thread; _ISR_Disable( level ); if ( !_Chain_Is_empty( &the_thread_queue->Queues.Fifo ) ) { the_thread = (Thread_Control *) _Chain_Get_first_unprotected( &the_thread_queue->Queues.Fifo ); if ( !_Watchdog_Is_active( &the_thread->Timer ) ) { _ISR_Enable( level ); _Thread_Unblock( the_thread ); } else { _Watchdog_Deactivate( &the_thread->Timer ); _ISR_Enable( level ); (void) _Watchdog_Remove( &the_thread->Timer ); _Thread_Unblock( the_thread ); } if ( !_Objects_Is_local_id( the_thread->Object.id ) ) _Thread_MP_Free_proxy( the_thread ); return the_thread; } else if ( the_thread_queue->sync ) { the_thread_queue->sync_state = THREAD_QUEUE_SATISFIED; _ISR_Enable( level ); return _Thread_Executing; } else { _ISR_Enable( level ); return NULL; }}
status = EXIT_CONNECT_TIME;
pppd_status = EXIT_CONNECT_TIME;
connect_time_expired(arg) void *arg;{ info("Connect time expired"); lcp_close(0, "Connect time expired"); /* Close connection */ status = EXIT_CONNECT_TIME;}
status = EXIT_AUTH_TOPEER_FAILED;
pppd_status = EXIT_AUTH_TOPEER_FAILED;
auth_withpeer_fail(unit, protocol) int unit, protocol;{ if (passwd_from_file) BZERO(passwd, MAXSECRETLEN); /* * We've failed to authenticate ourselves to our peer. * Some servers keep sending CHAP challenges, but there * is no point in persisting without any way to get updated * authentication secrets. */ lcp_close(unit, "Failed to authenticate ourselves to peer"); status = EXIT_AUTH_TOPEER_FAILED;}
ctx->body = serf_bucket_limit_create(ctx->stream, length,
ctx->body = serf_bucket_limit_create(ctx->body, length,
static apr_status_t run_machine(serf_bucket_t *bkt, response_context_t *ctx){ apr_status_t status = APR_SUCCESS; /* initialize to avoid gcc warnings */ switch (ctx->state) { case STATE_STATUS_LINE: /* RFC 2616 says that CRLF is the only line ending, but we can easily * accept any kind of line ending. */ status = fetch_line(ctx, SERF_NEWLINE_ANY); if (SERF_BUCKET_READ_ERROR(status)) return status; if (ctx->linebuf.state == SERF_LINEBUF_READY) { /* The Status-Line is in the line buffer. Process it. */ status = parse_status_line(ctx, bkt->allocator); if (status) return status; /* Okay... move on to reading the headers. */ ctx->state = STATE_HEADERS; } break; case STATE_HEADERS: status = fetch_headers(bkt, ctx); if (SERF_BUCKET_READ_ERROR(status)) return status; /* If an empty line was read, then we hit the end of the headers. * Move on to the body. */ if (ctx->linebuf.state == SERF_LINEBUF_READY && !ctx->linebuf.used) { const void *v; /* Are we C-L, chunked, or conn close? */ v = serf_bucket_headers_get(ctx->headers, "Content-Length"); if (v) { apr_size_t length; length = apr_strtoi64(v, NULL, 10); if (errno == ERANGE) { return APR_FROM_OS_ERROR(ERANGE); } ctx->body = serf_bucket_limit_create(ctx->stream, length, bkt->allocator); } else { v = serf_bucket_headers_get(ctx->headers, "Transfer-Encoding"); /* Need to handle multiple transfer-encoding. */ if (v && strcasecmp("chunked", v) == 0) { ctx->chunked = 1; ctx->body = serf_bucket_dechunk_create(ctx->stream, bkt->allocator); } /* Connection: Close response. */ /* FIXME There is a problem that arises here due to bucket * ownership. If we were to get a Conn: Close with gzip * encoding, we'll get a double free and abort(). * * The reason is that the deflate bucket assumes that its * streams are of the same lifetime. However, the dechunk * and limit buckets assume that its streams are of * different lifetimes. This isn't quite right and needs * to be rethought. */ if (!ctx->body) { ctx->body = ctx->stream; } } v = serf_bucket_headers_get(ctx->headers, "Content-Encoding"); if (v) { /* Need to handle multiple content-encoding. */ if (v && strcasecmp("gzip", v) == 0) { ctx->body = serf_bucket_deflate_create(ctx->body, bkt->allocator); } } ctx->state = STATE_BODY; } break; case STATE_BODY: /* Don't do anything. */ break; case STATE_TRAILERS: status = fetch_headers(bkt, ctx); if (SERF_BUCKET_READ_ERROR(status)) return status; /* If an empty line was read, then we're done. */ if (ctx->linebuf.state == SERF_LINEBUF_READY && !ctx->linebuf.used) { ctx->state = STATE_DONE; return APR_EOF; } break; case STATE_DONE: return APR_EOF; default: abort(); } return status;}
ctx->body = serf_bucket_dechunk_create(ctx->stream,
ctx->body = serf_bucket_dechunk_create(ctx->body,
static apr_status_t run_machine(serf_bucket_t *bkt, response_context_t *ctx){ apr_status_t status = APR_SUCCESS; /* initialize to avoid gcc warnings */ switch (ctx->state) { case STATE_STATUS_LINE: /* RFC 2616 says that CRLF is the only line ending, but we can easily * accept any kind of line ending. */ status = fetch_line(ctx, SERF_NEWLINE_ANY); if (SERF_BUCKET_READ_ERROR(status)) return status; if (ctx->linebuf.state == SERF_LINEBUF_READY) { /* The Status-Line is in the line buffer. Process it. */ status = parse_status_line(ctx, bkt->allocator); if (status) return status; /* Okay... move on to reading the headers. */ ctx->state = STATE_HEADERS; } break; case STATE_HEADERS: status = fetch_headers(bkt, ctx); if (SERF_BUCKET_READ_ERROR(status)) return status; /* If an empty line was read, then we hit the end of the headers. * Move on to the body. */ if (ctx->linebuf.state == SERF_LINEBUF_READY && !ctx->linebuf.used) { const void *v; /* Are we C-L, chunked, or conn close? */ v = serf_bucket_headers_get(ctx->headers, "Content-Length"); if (v) { apr_size_t length; length = apr_strtoi64(v, NULL, 10); if (errno == ERANGE) { return APR_FROM_OS_ERROR(ERANGE); } ctx->body = serf_bucket_limit_create(ctx->stream, length, bkt->allocator); } else { v = serf_bucket_headers_get(ctx->headers, "Transfer-Encoding"); /* Need to handle multiple transfer-encoding. */ if (v && strcasecmp("chunked", v) == 0) { ctx->chunked = 1; ctx->body = serf_bucket_dechunk_create(ctx->stream, bkt->allocator); } /* Connection: Close response. */ /* FIXME There is a problem that arises here due to bucket * ownership. If we were to get a Conn: Close with gzip * encoding, we'll get a double free and abort(). * * The reason is that the deflate bucket assumes that its * streams are of the same lifetime. However, the dechunk * and limit buckets assume that its streams are of * different lifetimes. This isn't quite right and needs * to be rethought. */ if (!ctx->body) { ctx->body = ctx->stream; } } v = serf_bucket_headers_get(ctx->headers, "Content-Encoding"); if (v) { /* Need to handle multiple content-encoding. */ if (v && strcasecmp("gzip", v) == 0) { ctx->body = serf_bucket_deflate_create(ctx->body, bkt->allocator); } } ctx->state = STATE_BODY; } break; case STATE_BODY: /* Don't do anything. */ break; case STATE_TRAILERS: status = fetch_headers(bkt, ctx); if (SERF_BUCKET_READ_ERROR(status)) return status; /* If an empty line was read, then we're done. */ if (ctx->linebuf.state == SERF_LINEBUF_READY && !ctx->linebuf.used) { ctx->state = STATE_DONE; return APR_EOF; } break; case STATE_DONE: return APR_EOF; default: abort(); } return status;}
if (!ctx->body) { ctx->body = ctx->stream;
if (!ctx->chunked) {
static apr_status_t run_machine(serf_bucket_t *bkt, response_context_t *ctx){ apr_status_t status = APR_SUCCESS; /* initialize to avoid gcc warnings */ switch (ctx->state) { case STATE_STATUS_LINE: /* RFC 2616 says that CRLF is the only line ending, but we can easily * accept any kind of line ending. */ status = fetch_line(ctx, SERF_NEWLINE_ANY); if (SERF_BUCKET_READ_ERROR(status)) return status; if (ctx->linebuf.state == SERF_LINEBUF_READY) { /* The Status-Line is in the line buffer. Process it. */ status = parse_status_line(ctx, bkt->allocator); if (status) return status; /* Okay... move on to reading the headers. */ ctx->state = STATE_HEADERS; } break; case STATE_HEADERS: status = fetch_headers(bkt, ctx); if (SERF_BUCKET_READ_ERROR(status)) return status; /* If an empty line was read, then we hit the end of the headers. * Move on to the body. */ if (ctx->linebuf.state == SERF_LINEBUF_READY && !ctx->linebuf.used) { const void *v; /* Are we C-L, chunked, or conn close? */ v = serf_bucket_headers_get(ctx->headers, "Content-Length"); if (v) { apr_size_t length; length = apr_strtoi64(v, NULL, 10); if (errno == ERANGE) { return APR_FROM_OS_ERROR(ERANGE); } ctx->body = serf_bucket_limit_create(ctx->stream, length, bkt->allocator); } else { v = serf_bucket_headers_get(ctx->headers, "Transfer-Encoding"); /* Need to handle multiple transfer-encoding. */ if (v && strcasecmp("chunked", v) == 0) { ctx->chunked = 1; ctx->body = serf_bucket_dechunk_create(ctx->stream, bkt->allocator); } /* Connection: Close response. */ /* FIXME There is a problem that arises here due to bucket * ownership. If we were to get a Conn: Close with gzip * encoding, we'll get a double free and abort(). * * The reason is that the deflate bucket assumes that its * streams are of the same lifetime. However, the dechunk * and limit buckets assume that its streams are of * different lifetimes. This isn't quite right and needs * to be rethought. */ if (!ctx->body) { ctx->body = ctx->stream; } } v = serf_bucket_headers_get(ctx->headers, "Content-Encoding"); if (v) { /* Need to handle multiple content-encoding. */ if (v && strcasecmp("gzip", v) == 0) { ctx->body = serf_bucket_deflate_create(ctx->body, bkt->allocator); } } ctx->state = STATE_BODY; } break; case STATE_BODY: /* Don't do anything. */ break; case STATE_TRAILERS: status = fetch_headers(bkt, ctx); if (SERF_BUCKET_READ_ERROR(status)) return status; /* If an empty line was read, then we're done. */ if (ctx->linebuf.state == SERF_LINEBUF_READY && !ctx->linebuf.used) { ctx->state = STATE_DONE; return APR_EOF; } break; case STATE_DONE: return APR_EOF; default: abort(); } return status;}
rtems_driver_name_t *driver = NULL;
rtems_driver_name_t driver;
rtems_device_driver sh_sci_initialize( rtems_device_major_number major, rtems_device_minor_number minor, void *arg ){ rtems_device_driver status ; rtems_device_minor_number i; rtems_driver_name_t *driver = NULL; /* * register all possible devices. * the initialization of the hardware is done by sci_open * * One of devices could be previously registered by console * initialization therefore we check it everytime */ for ( i = 0 ; i < SCI_MINOR_DEVICES ; i++ ) { status = rtems_io_lookup_name( sci_device[i].name, &driver); if( status != RTEMS_SUCCESSFUL ) { /* OK. We assume it is not registered yet. */ status = rtems_io_register_name( sci_device[i].name, major, sci_device[i].minor ); if (status != RTEMS_SUCCESSFUL) rtems_fatal_error_occurred(status); } } /* non-default hardware setup occurs in sh_sci_open() */ return RTEMS_SUCCESSFUL;}
if (!under_emacs && !ioctl(0, TIOCGWINSZ, &s)) return s.ws_row;
if (!under_emacs && !under_texmacs && !ioctl(0, TIOCGWINSZ, &s)) return s.ws_row;
term_height_intern(){#ifdef HAS_TIOCGWINSZ { struct winsize s; if (!under_emacs && !ioctl(0, TIOCGWINSZ, &s)) return s.ws_row; }#endif#ifdef UNIX { char *str; if ((str = getenv("LINES"))) return atoi(str); }#endif#ifdef __EMX__ { int scrsize[2]; _scrsize(scrsize); return scrsize[1]; }#endif return 0;}
unsigned32 tmr_freq;
uint32_t tmr_freq;
void Timer_initialize( void ){ unsigned32 tmr_freq; /* since we are using timer_clock2, divide mck by 8 */ tmr_freq = at91rm9200_get_mck() / 8; TC_TC0_REG(TC_CMR) = TC_CMR_TCCLKS(1); /* timer_clock2 */ TC_TC0_REG(TC_CCR) = (TC_CCR_CLKEN /* enable the counter */ | TC_CCR_SWTRG); /* start it up */ /* tick time in nanoseconds */ tick_time = 1000000000/tmr_freq;}
long j, k, lva = lg(va)-1, a, N = lg(cff)-1, N0 = N;
long j, k, lva = lg(va)-1, a, N = lg(cff)-1;
twistpartialzeta(GEN p, GEN q, long f, long c, GEN va, GEN cff){ long j, k, lva = lg(va)-1, a, N = lg(cff)-1, N0 = N; pari_sp av, lim; GEN x = polx[0], y = polx[fetch_user_var("y")], eta, one, mon, den; GEN cyc, psm, invden, rep, ser; cyc = gdiv(gsubgs(gpowgs(y, c), 1), gsubgs(y, 1)); psm = polsym(cyc, degpol(cyc) - 1); eta = gmodulcp(y, cyc); one = gmodulsg(1, q); /* Mod(1, q); */ mon = gaddsg(1, x); den = gsubsg(1, gmul(gpowgs(gmul(one,eta), f), gpowgs(gmul(one,mon), f))); /* FIXME: get rid of unnecessary coeffs; should be done in coeff_of_phi_ms? */ while (gcmp0((GEN)cff[N0])) N0--; den = gadd(den, zeroser(0, N0+5)); av = avma; lim = stack_lim(av, 1); invden = ginv(den); rep = zerovec(lva); /* a = 1 is always the first element of va */ ser = gmul(gmul(eta, mon), invden); ser = lift_intern(lift_intern(ser)); /* t_SER of ZY */ /* ser is a unit, convert to POL */ ser[0] = evaltyp(t_POL)| evallg(lg(ser)); ser[1] = evalsigne(1)| evalvarn(0); a = 1; for (j = 1; j <= lva; j++) { GEN p1 = gzero; if (DEBUGLEVEL > 2 && !(j%50)) fprintferr(" twistpartialpowser: %ld\%\n", 100*j/lva); for (k = 1; k <= N; k++) { pari_sp av2 = avma; GEN p2 = quicktrace(polcoeff_i(ser,k,0), psm); p1 = gerepileupto(av2, addii(p1, mulii((GEN)cff[k], p2))); } rep[j] = lmodii(p1, q); if (j < lva) { long e = va[j+1] - a, i; GEN z = eta; for (i = 1; i <= e; i++) /* assume e small */ { ser = addmulXn(ser, ser, 1); /* ser *= 1+x */ setlg(ser, lg(ser)-1); /* truncate highest degree term */ } if (e > 1) z = gpowgs(z, e); z = lift_intern(z); if (!degpol(z)) { z = (GEN)z[2]; /* +/- 1 */ if (signe(z) < 0) ser = gneg(ser); ser = FpXX_red(ser, q); } else { ser = gmul(z, ser); for (i=2; i<lg(ser); i++) ser[i] = (long)FpX_rem((GEN)ser[i], cyc, q); } a = va[j+1]; } if (low_stack(lim, stack_lim(av, 1))) { if(DEBUGMEM>1) err(warnmem, "twistpartialpowser, j = %ld/%ld", j,lva); gerepileall(av, 2, &rep, &ser); } } return rep;}