void
check_max (void)
{
  mpf_t  f;
  long   want;
  long   got;

  mpf_init2 (f, 200L);

#define CHECK_MAX(name)                                         \
  if (got != want)                                              \
    {                                                           \
      printf ("mpf_get_si wrong on %s\n", name);                \
      printf ("   f    ");                                      \
      mpf_out_str (stdout, 10, 0, f); printf (", hex ");        \
      mpf_out_str (stdout, 16, 0, f); printf ("\n");            \
      printf ("   got  %ld, hex %lX\n", got, got);              \
      printf ("   want %ld, hex %lX\n", want, want);            \
      abort();                                                  \
    }

  want = LONG_MAX;
  mpf_set_si (f, want);
  got = mpf_get_si (f);
  CHECK_MAX ("LONG_MAX");

  want = LONG_MIN;
  mpf_set_si (f, want);
  got = mpf_get_si (f);
  CHECK_MAX ("LONG_MIN");

  mpf_clear (f);
}
void
check_max (void)
{
  mpz_t  n;
  long   want;
  long   got;

  mpz_init (n);

#define CHECK_MAX(name)                                 \
  if (got != want)                                      \
    {                                                   \
      printf ("mpz_get_si wrong on %s\n", name);        \
      printf ("   n    ");                              \
      mpz_out_str (stdout, 10, n); printf (", hex ");   \
      mpz_out_str (stdout, 16, n); printf ("\n");       \
      printf ("   got  %ld, hex %lX\n", got, got);      \
      printf ("   want %ld, hex %lX\n", want, want);    \
      abort();                                          \
    }

  want = LONG_MAX;
  mpz_set_si (n, want);
  got = mpz_get_si (n);
  CHECK_MAX ("LONG_MAX");

  want = LONG_MIN;
  mpz_set_si (n, want);
  got = mpz_get_si (n);
  CHECK_MAX ("LONG_MIN");

  /* The following checks that -0x100000000 gives -0x80000000.  This doesn't
     actually fit in a long and the result from mpz_get_si() is undefined,
     but -0x80000000 is what comes out currently, and it should be that
     value irrespective of the mp_limb_t size (long or long long).  */

  want = LONG_MIN;
  mpz_mul_2exp (n, n, 1);
  CHECK_MAX ("-0x100...00");

  mpz_clear (n);
}
Exemple #3
0
void
of_object_track(of_object_t *obj, const char *file, int line)
{
    if (obj != NULL) {
        LOCI_LOG_TRACE("OF obj track %p, wire buf %p\n%s:%d\\n",
                       obj, obj->wire_object.wbuf, file, line);
        obj->track_info.file = file;
        obj->track_info.line = line;
        TRACK_OBJS = biglist_prepend(TRACK_OBJS, (void *)obj);
        obj->track_info.bl_entry = TRACK_OBJS;
        obj->track_info.magic = OF_OBJECT_TRACKING_MAGIC;

        TRACK->allocs += 1;
        TRACK->count_current += 1;
        CHECK_MAX(TRACK->count_current, TRACK->count_max);
    }
}