mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 15:23:53 -06:00
qnum: add uint type
In order to store integer values between INT64_MAX and UINT64_MAX, add a uint64_t internal representation. Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20170607163635.17635-10-marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
parent
36aeb6094f
commit
61a8f418b2
3 changed files with 119 additions and 0 deletions
|
@ -19,6 +19,7 @@
|
|||
|
||||
typedef enum {
|
||||
QNUM_I64,
|
||||
QNUM_U64,
|
||||
QNUM_DOUBLE
|
||||
} QNumKind;
|
||||
|
||||
|
@ -27,15 +28,21 @@ typedef struct QNum {
|
|||
QNumKind kind;
|
||||
union {
|
||||
int64_t i64;
|
||||
uint64_t u64;
|
||||
double dbl;
|
||||
} u;
|
||||
} QNum;
|
||||
|
||||
QNum *qnum_from_int(int64_t value);
|
||||
QNum *qnum_from_uint(uint64_t value);
|
||||
QNum *qnum_from_double(double value);
|
||||
|
||||
bool qnum_get_try_int(const QNum *qn, int64_t *val);
|
||||
int64_t qnum_get_int(const QNum *qn);
|
||||
|
||||
bool qnum_get_try_uint(const QNum *qn, uint64_t *val);
|
||||
uint64_t qnum_get_uint(const QNum *qn);
|
||||
|
||||
double qnum_get_double(QNum *qn);
|
||||
|
||||
char *qnum_to_string(QNum *qn);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue