bridge/class-master/depend/pari/src/basemath/mftrace.c
/* handle a cache miss: store stats, possibly reset table; return value
 * if (now) cached; return NULL on failure. HACK: some caches contain an
 * ulong where the 0 value is impossible, and return it (typecase to GEN) */
handle a cache miss: store stats, possibly reset table; return value
if (now) cached; return NULL on failure. HACK: some caches contain an
ulong where the 0 value is impossible, and return it (typecase to GEN)
handle a cache miss : store stats possibly reset table ; return value if ( now ) cached ; return NULL on failure . HACK : some caches contain an ulong where the 0 value is impossible and return it ( typecase to GEN )
static GEN
cache_get(long id, ulong D)
{
  cache *S = &caches[id];
  const ulong d = (id == cache_H)? D>>1: D;
  ulong max, l;
  if (!S->cache)
  {
    max = maxuu(minuu(D, S->maxself), S->minself);
    S->init(max);
    l = lg(S->cache);
  }
  else
  {
    l = lg(S->cache);
    if (l <= d)
    {
      if (D > S->maxmiss) S->maxmiss = D;
      if (DEBUGLEVEL >= 3)
        err_printf("miss in cache %s: %lu, max = %lu\n",
                   S->name, D, S->maxmiss);
      if (S->miss++ >= 5 && D < S->maxself)
      {
        max = minuu(S->maxself, (long)(S->maxmiss * 1.2));
        if (max <= S->maxself)
        {
          if (DEBUGLEVEL >= 3)
            err_printf("resetting cache %s to %lu\n", S->name, max);
          S->init(max); l = lg(S->cache);
        }
      }
    }
  }
  return (l <= d)? NULL: gel(S->cache, d);
}
static GEN cache_get ( long id , ulong D ) { cache * S = & caches [ id ] ; const ulong d = ( id == cache_H ) ? D >> 1 : D ; ulong max , l ; if ( ! S -> cache ) { max = maxuu ( minuu ( D , S -> maxself ) , S -> minself ) ; S -> init ( max ) ; l = lg ( S -> cache ) ; } else { l = lg ( S -> cache ) ; if ( l <= d ) { if ( D > S -> maxmiss ) S -> maxmiss = D ; if ( DEBUGLEVEL >= 3 ) err_printf ( " \n " , S -> name , D , S -> maxmiss ) ; if ( S -> miss ++ >= 5 && D < S -> maxself ) { max = minuu ( S -> maxself , ( long ) ( S -> maxmiss * 1.2 ) ) ; if ( max <= S -> maxself ) { if ( DEBUGLEVEL >= 3 ) err_printf ( " \n " , S -> name , max ) ; S -> init ( max ) ; l = lg ( S -> cache ) ; } } } } return ( l <= d ) ? NULL : gel ( S -> cache , d ) ; }
handle a cache miss: store stats, possibly reset table; return value
 if (now) cached; return NULL on failure.
handle a cache miss : store stats possibly reset table ; return value if ( now ) cached ; return NULL on failure .
/* cache_H is compressed: D=0,1 mod 4 */