From add6962d7af2fd3943c2f2d739bd13b3ce4b91d8 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla <sreek@google.com> Date: Tue, 21 Mar 2017 16:12:39 -0700 Subject: [PATCH] Add version macro --- include/grpc/grpc.h | 4 +++- src/core/lib/surface/completion_queue_factory.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index bcf64a6081..fa4fd6d49d 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -128,10 +128,12 @@ typedef enum { GRPC_CQ_NON_POLLING } grpc_cq_polling_type; + +#define GRPC_CQ_CURRENT_VERSION 1 typedef struct grpc_completion_queue_attributes { /* The version number of this structure. More fields might be added to this structure in future. */ - int version; /* Current version is 1 */ + int version; /* Set to GRPC_CQ_CURRENT_VERSION */ grpc_cq_completion_type cq_type; diff --git a/src/core/lib/surface/completion_queue_factory.c b/src/core/lib/surface/completion_queue_factory.c index 879b456ed5..138dfeff48 100644 --- a/src/core/lib/surface/completion_queue_factory.c +++ b/src/core/lib/surface/completion_queue_factory.c @@ -52,7 +52,9 @@ static const grpc_completion_queue_factory g_default_cq_factory = { const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup( const grpc_completion_queue_attributes* attributes) { /* As we add more fields to grpc_completion_queue_attributes, we may have to - change this assert */ + change this assert to: + GPR_ASSERT (attributes->version >= 1 && + attributes->version <= GRPC_CQ_CURRENT_VERSION) */ GPR_ASSERT(attributes->version == 1); /* The default factory can handle version 1 of the attributes structure. We -- GitLab