static void
TestPrintUnsignedFast64()
{
  PoisonOutput();
  sprintf(output, "%" PRIoFAST64, uint_fast64_t(UINT64_C(0424242424242)));
  MOZ_RELEASE_ASSERT(!strcmp(output, "424242424242"));

  PoisonOutput();
  sprintf(output, "%" PRIuFAST64, uint_fast64_t(UINT64_C(17171717171717171717)));
  MOZ_RELEASE_ASSERT(!strcmp(output, "17171717171717171717"));

  PoisonOutput();
  sprintf(output, "%" PRIxFAST64, uint_fast64_t(UINT64_C(0x2a2a2a2a2a2a2a)));
  MOZ_RELEASE_ASSERT(!strcmp(output, "2a2a2a2a2a2a2a"));

  PoisonOutput();
  sprintf(output, "%" PRIXFAST64, uint_fast64_t(UINT64_C(0xCDCDCDCDCDCD)));
  MOZ_RELEASE_ASSERT(!strcmp(output, "CDCDCDCDCDCD"));
}
Esempio n. 2
0
inline int_fast64_t from_ref(ref_type v) noexcept
{
    // Check that v is divisible by 8 (64-bit aligned).
    REALM_ASSERT_DEBUG(v % 8 == 0);

    static_assert(std::is_same<ref_type, size_t>::value,
                  "If ref_type changes, from_ref and to_ref should probably be updated");

    // Make sure that we preserve the bit pattern of the ref_type (without sign extension).
    return util::from_twos_compl<int_fast64_t>(uint_fast64_t(v));
}
Esempio n. 3
0
static uint_fast64_t nowNs() {
  struct timespec time;
  clock_gettime(CLOCK_REALTIME, &time);
  return uint_fast64_t(1000000000) * time.tv_sec + time.tv_nsec;
}
Esempio n. 4
0
uint_fast64_t tpt_rng::randUint64()
{
	return (uint_fast64_t(gen())<<32) | gen();
}