From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:53981) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StHAL-0005Rz-4h for qemu-devel@nongnu.org; Mon, 23 Jul 2012 07:51:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StHAA-0000U0-9h for qemu-devel@nongnu.org; Mon, 23 Jul 2012 07:51:09 -0400 Received: from e06smtp16.uk.ibm.com ([195.75.94.112]:35067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StHAA-0000TL-1W for qemu-devel@nongnu.org; Mon, 23 Jul 2012 07:50:58 -0400 Received: from /spool/local by e06smtp16.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Jul 2012 12:50:56 +0100 Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6NBosEr2777320 for ; Mon, 23 Jul 2012 12:50:54 +0100 Received: from d06av06.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6NBosqL007933 for ; Mon, 23 Jul 2012 05:50:54 -0600 From: Stefan Hajnoczi Date: Mon, 23 Jul 2012 12:50:30 +0100 Message-Id: <1343044244-28728-6-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1343044244-28728-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1343044244-28728-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 05/19] qapi: introduce "size" type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Laszlo Ersek , qemu-devel@nongnu.org, Stefan Hajnoczi From: Laszlo Ersek v1->v2: - fall back to uint64 rather than int Signed-off-by: Laszlo Ersek Signed-off-by: Stefan Hajnoczi --- qapi/qapi-visit-core.c | 7 +++++++ qapi/qapi-visit-core.h | 3 +++ scripts/qapi.py | 2 ++ 3 files changed, 12 insertions(+) diff --git a/qapi/qapi-visit-core.c b/qapi/qapi-visit-core.c index d41595e..7a82b637 100644 --- a/qapi/qapi-visit-core.c +++ b/qapi/qapi-visit-core.c @@ -234,6 +234,13 @@ void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp) } } +void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp) +{ + if (!error_is_set(errp)) { + (v->type_size ? v->type_size : v->type_uint64)(v, obj, name, errp); + } +} + void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp) { if (!error_is_set(errp)) { diff --git a/qapi/qapi-visit-core.h b/qapi/qapi-visit-core.h index a19d70c..60aceda 100644 --- a/qapi/qapi-visit-core.h +++ b/qapi/qapi-visit-core.h @@ -60,6 +60,8 @@ struct Visitor void (*type_int16)(Visitor *v, int16_t *obj, const char *name, Error **errp); void (*type_int32)(Visitor *v, int32_t *obj, const char *name, Error **errp); void (*type_int64)(Visitor *v, int64_t *obj, const char *name, Error **errp); + /* visit_type_size() falls back to (*type_uint64)() if type_size is unset */ + void (*type_size)(Visitor *v, uint64_t *obj, const char *name, Error **errp); }; void visit_start_handle(Visitor *v, void **obj, const char *kind, @@ -85,6 +87,7 @@ void visit_type_int8(Visitor *v, int8_t *obj, const char *name, Error **errp); void visit_type_int16(Visitor *v, int16_t *obj, const char *name, Error **errp); void visit_type_int32(Visitor *v, int32_t *obj, const char *name, Error **errp); void visit_type_int64(Visitor *v, int64_t *obj, const char *name, Error **errp); +void visit_type_size(Visitor *v, uint64_t *obj, const char *name, Error **errp); void visit_type_bool(Visitor *v, bool *obj, const char *name, Error **errp); void visit_type_str(Visitor *v, char **obj, const char *name, Error **errp); void visit_type_number(Visitor *v, double *obj, const char *name, Error **errp); diff --git a/scripts/qapi.py b/scripts/qapi.py index 1292476..8082af3 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -163,6 +163,8 @@ def c_type(name): name == 'int64' or name == 'uint8' or name == 'uint16' or name == 'uint32' or name == 'uint64'): return name + '_t' + elif name == 'size': + return 'uint64_t' elif name == 'bool': return 'bool' elif name == 'number': -- 1.7.10.4