28#include "gdbsupport/traits.h"
47 mpz_set (
m_val, from_val);
60 template<
typename T,
typename = gdb::Requires<std::is_
integral<T>>>
70 mpz_swap (
m_val, from.m_val);
82 mpz_swap (
m_val, other.m_val);
86 template<
typename T,
typename = gdb::Requires<std::is_
integral<T>>>
95 mpz_set_ui (
m_val, (
unsigned long) src);
103 return mpz_set_str (
m_val,
str, base) != -1;
110 mpz_ui_pow_ui (result.
m_val, base, exp);
138 void read (gdb::array_view<const gdb_byte> buf,
enum bfd_endian byte_order,
145 void write (gdb::array_view<gdb_byte> buf,
enum bfd_endian byte_order,
146 bool unsigned_p)
const
148 export_bits (buf, byte_order == BFD_ENDIAN_BIG ? 1 : -1 ,
154 void truncate (gdb::array_view<gdb_byte> buf,
enum bfd_endian byte_order,
155 bool unsigned_p)
const
157 export_bits (buf, byte_order == BFD_ENDIAN_BIG ? 1 : -1 ,
184 {
return mpz_sgn (
m_val); }
186 explicit operator bool ()
const
187 {
return sgn () != 0; }
323 return mpz_cmp_si (
m_val, other) < 0;
331 template<
typename T,
typename = gdb::Requires<std::is_
integral<T>>>
334 if (std::is_signed<T>::value)
336 if (
sizeof (
T) <=
sizeof (
long))
337 return mpz_cmp_si (
m_val, other) == 0;
341 if (
sizeof (
T) <=
sizeof (
unsigned long))
342 return mpz_cmp_ui (
m_val, other) == 0;
344 return *
this ==
gdb_mpz (other);
360 template<
typename T>
void set (
T src);
378 void export_bits (gdb::array_view<gdb_byte> buf,
int endian,
bool unsigned_p,
397 mpq_set (
m_val, from_val);
409 mpq_swap (
m_val, from.m_val);
417 mpq_canonicalize (
m_val);
423 mpq_set_si (
m_val, num, denom);
424 mpq_canonicalize (
m_val);
436 mpq_swap (
m_val, from.m_val);
448 mpq_set_d (
m_val, d);
455 {
return mpq_sgn (
m_val); }
523 {
return mpq_get_d (
m_val); }
535 enum bfd_endian byte_order,
bool unsigned_p,
536 const gdb_mpq &scaling_factor);
545 enum bfd_endian byte_order,
bool unsigned_p,
546 const gdb_mpq &scaling_factor)
const;
578 enum bfd_endian byte_order,
bool unsigned_p,
589 std::string
str (
const char *fmt)
const
606 mpz_import (
m_val, 1 , -1 ,
609 if (std::is_signed<T>::value && src < 0)
616 mpz_ui_pow_ui (neg_offset.
m_val, 2, sizeof (
T) * HOST_CHAR_BIT);
629 this->
export_bits ({(gdb_byte *) &result,
sizeof (result)},
631 !std::is_signed<T>::value ,
645 this->
export_bits ({(gdb_byte *) &result,
sizeof (result)},
647 !std::is_signed<T>::value ,
std::string gmp_string_printf(const char *fmt,...)
DISABLE_COPY_AND_ASSIGN(gdb_mpf)
std::string str(const char *fmt) const
void read_fixed_point(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order, bool unsigned_p, const gdb_mpq &scaling_factor)
void write_fixed_point(gdb::array_view< gdb_byte > buf, enum bfd_endian byte_order, bool unsigned_p, const gdb_mpq &scaling_factor) const
gdb_mpq(const mpq_t &from_val)
gdb_mpq & operator*=(const gdb_mpq &other)
gdb_mpq(const gdb_mpz &num, const gdb_mpz &denom)
bool operator==(const gdb_mpq &other) const
gdb_mpq & operator/=(const gdb_mpq &other)
bool operator<(const gdb_mpq &other) const
gdb_mpq(const gdb_mpq &from)
gdb_mpq operator/(const gdb_mpq &other) const
gdb_mpq & operator=(const gdb_mpq &from)
gdb_mpq(long num, long denom)
gdb_mpq operator-(const gdb_mpq &other) const
gdb_mpq operator+(const gdb_mpq &other) const
void read_fixed_point(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order, bool unsigned_p, const gdb_mpq &scaling_factor)
gdb_mpz get_rounded() const
gdb_mpz as_integer() const
gdb_mpq operator*(const gdb_mpq &other) const
gdb_mpz operator&(const gdb_mpz &other) const
T as_integer_truncate() const
gdb_mpz operator%(const gdb_mpz &other) const
gdb_mpz operator+(const gdb_mpz &other) const
gdb_mpz operator*(const gdb_mpz &other) const
gdb_mpz operator^(const gdb_mpz &other) const
void read(gdb::array_view< const gdb_byte > buf, enum bfd_endian byte_order, bool unsigned_p)
void write(gdb::array_view< gdb_byte > buf, enum bfd_endian byte_order, bool unsigned_p) const
gdb_mpz operator-(const gdb_mpz &other) const
gdb_mpz(const mpz_t &from_val)
static gdb_mpz pow(unsigned long base, unsigned long exp)
gdb_mpz operator|(const gdb_mpz &other) const
gdb_mpz pow(unsigned long exp) const
void truncate(gdb::array_view< gdb_byte > buf, enum bfd_endian byte_order, bool unsigned_p) const
gdb_mpz operator/(const gdb_mpz &other) const
gdb_mpz & operator>>=(unsigned long nbits)
bool operator<=(const gdb_mpz &other) const
bool operator==(T other) const
bool operator>(const gdb_mpz &other) const
bool operator<(const gdb_mpz &other) const
gdb_mpz operator>>(unsigned long nbits) const
gdb_mpz & operator+=(unsigned long other)
bool set(const char *str, int base)
gdb_mpz & operator=(const gdb_mpz &from)
gdb_mpz(const gdb_mpz &from)
gdb_mpz operator<<(unsigned long nbits) const
gdb_mpz & operator-=(unsigned long other)
bool operator>=(const gdb_mpz &other) const
bool operator!=(const gdb_mpz &other) const
void export_bits(gdb::array_view< gdb_byte > buf, int endian, bool unsigned_p, bool safe) const
gdb_mpz & operator<<=(unsigned long nbits)
gdb_mpz & operator*=(long other)