target-sparc: Remove MMU_MODE*_SUFFIX
[qemu/ar7.git] / qobject / qint.c
blobd7d1b3021fa39778130412e51dd52c07bf9a8614
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 "qemu/osdep.h"
14 #include "qapi/qmp/qint.h"
15 #include "qapi/qmp/qobject.h"
16 #include "qemu-common.h"
18 /**
19 * qint_from_int(): Create a new QInt from an int64_t
21 * Return strong reference.
23 QInt *qint_from_int(int64_t value)
25 QInt *qi;
27 qi = g_malloc(sizeof(*qi));
28 qobject_init(QOBJECT(qi), QTYPE_QINT);
29 qi->value = value;
31 return qi;
34 /**
35 * qint_get_int(): Get the stored integer
37 int64_t qint_get_int(const QInt *qi)
39 return qi->value;
42 /**
43 * qobject_to_qint(): Convert a QObject into a QInt
45 QInt *qobject_to_qint(const QObject *obj)
47 if (!obj || qobject_type(obj) != QTYPE_QINT) {
48 return NULL;
50 return container_of(obj, QInt, base);
53 /**
54 * qint_destroy_obj(): Free all memory allocated by a
55 * QInt object
57 void qint_destroy_obj(QObject *obj)
59 assert(obj != NULL);
60 g_free(qobject_to_qint(obj));