target-ppc: gdbstub: Add VSX support
[qemu/ar7.git] / qobject / qint.c
blob7cba9adf40c0b85570ec89f5c07e78e2d65db5f3
1 /*
2 * QInt Module
4 * Copyright (C) 2009 Red Hat Inc.
6 * Authors:
7 * Luiz Capitulino <lcapitulino@redhat.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.
13 #include "qapi/qmp/qint.h"
14 #include "qapi/qmp/qobject.h"
15 #include "qemu-common.h"
17 /**
18 * qint_from_int(): Create a new QInt from an int64_t
20 * Return strong reference.
22 QInt *qint_from_int(int64_t value)
24 QInt *qi;
26 qi = g_malloc(sizeof(*qi));
27 qobject_init(QOBJECT(qi), QTYPE_QINT);
28 qi->value = value;
30 return qi;
33 /**
34 * qint_get_int(): Get the stored integer
36 int64_t qint_get_int(const QInt *qi)
38 return qi->value;
41 /**
42 * qobject_to_qint(): Convert a QObject into a QInt
44 QInt *qobject_to_qint(const QObject *obj)
46 if (!obj || qobject_type(obj) != QTYPE_QINT) {
47 return NULL;
49 return container_of(obj, QInt, base);
52 /**
53 * qint_destroy_obj(): Free all memory allocated by a
54 * QInt object
56 void qint_destroy_obj(QObject *obj)
58 assert(obj != NULL);
59 g_free(qobject_to_qint(obj));