petalogix-ml605: Set the MicroBlaze CPU version to 8.10.a
[qemu/ar7.git] / qobject / qfloat.c
blob87d89a772122eeed4cafb5f6f7899f44a8fffdfd
1 /*
2 * QFloat Module
4 * Copyright IBM, Corp. 2009
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
9 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
10 * See the COPYING.LIB file in the top-level directory.
14 #include "qapi/qmp/qfloat.h"
15 #include "qapi/qmp/qobject.h"
16 #include "qemu-common.h"
18 /**
19 * qfloat_from_int(): Create a new QFloat from a float
21 * Return strong reference.
23 QFloat *qfloat_from_double(double value)
25 QFloat *qf;
27 qf = g_malloc(sizeof(*qf));
28 qobject_init(QOBJECT(qf), QTYPE_QFLOAT);
29 qf->value = value;
31 return qf;
34 /**
35 * qfloat_get_double(): Get the stored float
37 double qfloat_get_double(const QFloat *qf)
39 return qf->value;
42 /**
43 * qobject_to_qfloat(): Convert a QObject into a QFloat
45 QFloat *qobject_to_qfloat(const QObject *obj)
47 if (!obj || qobject_type(obj) != QTYPE_QFLOAT) {
48 return NULL;
50 return container_of(obj, QFloat, base);
53 /**
54 * qfloat_destroy_obj(): Free all memory allocated by a
55 * QFloat object
57 void qfloat_destroy_obj(QObject *obj)
59 assert(obj != NULL);
60 g_free(qobject_to_qfloat(obj));