diff options
author | Craig Tiller <craig.tiller@gmail.com> | 2016-02-09 16:32:51 -0800 |
---|---|---|
committer | Craig Tiller <craig.tiller@gmail.com> | 2016-02-09 16:32:51 -0800 |
commit | f73429901acf8f7c19c9c33539fbdbc7b703d7a4 (patch) | |
tree | a23fabb6ef6337610c3e8382e628b0b24aad46ba /include | |
parent | 7e5a9cf32addfaf8e6b73fda27fa1a36d5a3821e (diff) | |
parent | bfe240ea07d09786e26c0e7f75a7dbabcb977c7f (diff) |
Merge github.com:grpc/grpc into sceq
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/impl/codegen/async_unary_call.h | 46 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/call.h | 18 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/server_context.h | 13 | ||||
-rw-r--r-- | include/grpc++/security/credentials.h | 2 | ||||
-rw-r--r-- | include/grpc/census.h | 314 | ||||
-rw-r--r-- | include/grpc/grpc_zookeeper.h | 2 | ||||
-rw-r--r-- | include/grpc/impl/codegen/compression_types.h | 2 | ||||
-rw-r--r-- | include/grpc/impl/codegen/port_platform.h | 17 | ||||
-rw-r--r-- | include/grpc/impl/codegen/propagation_bits.h | 2 | ||||
-rw-r--r-- | include/grpc/impl/codegen/sync.h | 3 | ||||
-rw-r--r-- | include/grpc/impl/codegen/time.h | 18 |
11 files changed, 238 insertions, 199 deletions
diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h index 481b20b535..f3c75dc3b1 100644 --- a/include/grpc++/impl/codegen/async_unary_call.h +++ b/include/grpc++/impl/codegen/async_unary_call.h @@ -62,40 +62,50 @@ class ClientAsyncResponseReader GRPC_FINAL ClientAsyncResponseReader(ChannelInterface* channel, CompletionQueue* cq, const RpcMethod& method, ClientContext* context, const W& request) - : context_(context), call_(channel->CreateCall(method, context, cq)) { - init_buf_.SendInitialMetadata(context->send_initial_metadata_); + : context_(context), + call_(channel->CreateCall(method, context, cq)), + collection_(new CallOpSetCollection) { + collection_->init_buf_.SetCollection(collection_); + collection_->init_buf_.SendInitialMetadata(context->send_initial_metadata_); // TODO(ctiller): don't assert - GPR_ASSERT(init_buf_.SendMessage(request).ok()); - init_buf_.ClientSendClose(); - call_.PerformOps(&init_buf_); + GPR_ASSERT(collection_->init_buf_.SendMessage(request).ok()); + collection_->init_buf_.ClientSendClose(); + call_.PerformOps(&collection_->init_buf_); } void ReadInitialMetadata(void* tag) { GPR_ASSERT(!context_->initial_metadata_received_); - meta_buf_.set_output_tag(tag); - meta_buf_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_buf_); + collection_->meta_buf_.SetCollection(collection_); + collection_->meta_buf_.set_output_tag(tag); + collection_->meta_buf_.RecvInitialMetadata(context_); + call_.PerformOps(&collection_->meta_buf_); } void Finish(R* msg, Status* status, void* tag) { - finish_buf_.set_output_tag(tag); + collection_->finish_buf_.SetCollection(collection_); + collection_->finish_buf_.set_output_tag(tag); if (!context_->initial_metadata_received_) { - finish_buf_.RecvInitialMetadata(context_); + collection_->finish_buf_.RecvInitialMetadata(context_); } - finish_buf_.RecvMessage(msg); - finish_buf_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_buf_); + collection_->finish_buf_.RecvMessage(msg); + collection_->finish_buf_.ClientRecvStatus(context_, status); + call_.PerformOps(&collection_->finish_buf_); } private: ClientContext* context_; Call call_; - SneakyCallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, - CallOpClientSendClose> init_buf_; - CallOpSet<CallOpRecvInitialMetadata> meta_buf_; - CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>, - CallOpClientRecvStatus> finish_buf_; + + class CallOpSetCollection : public CallOpSetCollectionInterface { + public: + SneakyCallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, + CallOpClientSendClose> init_buf_; + CallOpSet<CallOpRecvInitialMetadata> meta_buf_; + CallOpSet<CallOpRecvInitialMetadata, CallOpRecvMessage<R>, + CallOpClientRecvStatus> finish_buf_; + }; + std::shared_ptr<CallOpSetCollection> collection_; }; template <class W> diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index 1e06768ac4..e65349ddd3 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -472,6 +472,17 @@ class CallOpClientRecvStatus { size_t status_details_capacity_; }; +/// An abstract collection of CallOpSet's, to be used whenever +/// CallOpSet objects must be thought of as a group. Each member +/// of the group should have a shared_ptr back to the collection, +/// as will the object that instantiates the collection, allowing +/// for automatic ref-counting. In practice, any actual use should +/// derive from this base class. This is specifically necessary if +/// some of the CallOpSet's in the collection are "Sneaky" and don't +/// report back to the C++ layer CQ operations +class CallOpSetCollectionInterface + : public std::enable_shared_from_this<CallOpSetCollectionInterface> {}; + /// An abstract collection of call ops, used to generate the /// grpc_call_op structure to pass down to the lower layers, /// and as it is-a CompletionQueueTag, also massages the final @@ -488,8 +499,14 @@ class CallOpSetInterface : public CompletionQueueTag { max_message_size_ = max_message_size; } + /// Mark this as belonging to a collection if needed + void SetCollection(std::shared_ptr<CallOpSetCollectionInterface> collection) { + collection_ = collection; + } + protected: int max_message_size_; + std::shared_ptr<CallOpSetCollectionInterface> collection_; }; /// Primary implementaiton of CallOpSetInterface. @@ -527,6 +544,7 @@ class CallOpSet : public CallOpSetInterface, this->Op5::FinishOp(status, max_message_size_); this->Op6::FinishOp(status, max_message_size_); *tag = return_tag_; + collection_.reset(); // drop the ref at this point return true; } diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h index 2af9fdaa34..ad08b8210d 100644 --- a/include/grpc++/impl/codegen/server_context.h +++ b/include/grpc++/impl/codegen/server_context.h @@ -105,6 +105,19 @@ class ServerContext { bool IsCancelled() const; + // Cancel the Call from the server. This is a best-effort API and depending on + // when it is called, the RPC may still appear successful to the client. + // For example, if TryCancel() is called on a separate thread, it might race + // with the server handler which might return success to the client before + // TryCancel() was even started by the thread. + // + // It is the caller's responsibility to prevent such races and ensure that if + // TryCancel() is called, the serverhandler must return Status::CANCELLED. The + // only exception is that if the serverhandler is already returning an error + // status code, it is ok to not return Status::CANCELLED even if TryCancel() + // was called. + void TryCancel() const; + const std::multimap<grpc::string_ref, grpc::string_ref>& client_metadata() { return client_metadata_; } diff --git a/include/grpc++/security/credentials.h b/include/grpc++/security/credentials.h index 4d64b5e227..e0806c0b7b 100644 --- a/include/grpc++/security/credentials.h +++ b/include/grpc++/security/credentials.h @@ -83,7 +83,7 @@ class ChannelCredentials : private GrpcLibrary { /// authenticate with a server for a given call on a channel. /// /// \see http://www.grpc.io/docs/guides/auth.html -class CallCredentials { +class CallCredentials : private GrpcLibrary { public: CallCredentials(); ~CallCredentials(); diff --git a/include/grpc/census.h b/include/grpc/census.h index 70d4f80efb..6313b196f2 100644 --- a/include/grpc/census.h +++ b/include/grpc/census.h @@ -70,28 +70,148 @@ CENSUS_API int census_supported(void); CENSUS_API int census_enabled(void); /** - Context is a handle used by census to represent the current tracing and - tagging information. Contexts should be propagated across RPC's. Contexts - are created by any of the census_start_*_op() functions. A context is - typically used as argument to most census functions. Conceptually, contexts - should be thought of as specific to single RPC/thread. The context can be - serialized for passing across the wire, via census_context_serialize(). -*/ + A Census Context is a handle used by Census to represent the current tracing + and stats collection information. Contexts should be propagated across RPC's + (this is the responsibility of the local RPC system). A context is typically + used as the first argument to most census functions. Conceptually, they + should be thought of as specific to a single RPC/thread. The user visible + context representation is that of a collection of key:value string pairs, + each of which is termed a 'tag'; these form the basis against which Census + metrics will be recorded. Keys are unique within a context. */ typedef struct census_context census_context; -/* This function is called by the RPC subsystem whenever it needs to get a - * serialized form of the current census context (presumably to pass across - * the wire). Arguments: - * 'buffer': pointer to memory into which serialized context will be placed - * 'buf_size': size of 'buffer' - * - * Returns: the number of bytes used in buffer if successful, or 0 if the - * buffer is of insufficient size. - * - * TODO(aveitch): determine how best to communicate required/max buffer size - * so caller doesn't have to guess. */ -CENSUS_API size_t census_context_serialize(const census_context *context, - char *buffer, size_t buf_size); +/* A tag is a key:value pair. The key is a non-empty, printable (UTF-8 + encoded), nil-terminated string. The value is a binary string, that may be + printable. There are limits on the sizes of both keys and values (see + CENSUS_MAX_TAG_KB_LEN definition below), and the number of tags that can be + propagated (CENSUS_MAX_PROPAGATED_TAGS). Users should also remember that + some systems may have limits on, e.g., the number of bytes that can be + transmitted as metadata, and that larger tags means more memory consumed + and time in processing. */ +typedef struct { + const char *key; + const char *value; + size_t value_len; + uint8_t flags; +} census_tag; + +/* Maximum length of a tag's key or value. */ +#define CENSUS_MAX_TAG_KV_LEN 255 +/* Maximum number of propagatable tags. */ +#define CENSUS_MAX_PROPAGATED_TAGS 255 + +/* Tag flags. */ +#define CENSUS_TAG_PROPAGATE 1 /* Tag should be propagated over RPC */ +#define CENSUS_TAG_STATS 2 /* Tag will be used for statistics aggregation */ +#define CENSUS_TAG_BINARY 4 /* Tag value is not printable */ +#define CENSUS_TAG_RESERVED 8 /* Reserved for internal use. */ +/* Flag values 8,16,32,64,128 are reserved for future/internal use. Clients + should not use or rely on their values. */ + +#define CENSUS_TAG_IS_PROPAGATED(flags) (flags & CENSUS_TAG_PROPAGATE) +#define CENSUS_TAG_IS_STATS(flags) (flags & CENSUS_TAG_STATS) +#define CENSUS_TAG_IS_BINARY(flags) (flags & CENSUS_TAG_BINARY) + +/* An instance of this structure is kept by every context, and records the + basic information associated with the creation of that context. */ +typedef struct { + int n_propagated_tags; /* number of propagated printable tags */ + int n_propagated_binary_tags; /* number of propagated binary tags */ + int n_local_tags; /* number of non-propagated (local) tags */ + int n_deleted_tags; /* number of tags that were deleted */ + int n_added_tags; /* number of tags that were added */ + int n_modified_tags; /* number of tags that were modified */ + int n_invalid_tags; /* number of tags with bad keys or values (e.g. + longer than CENSUS_MAX_TAG_KV_LEN) */ + int n_ignored_tags; /* number of tags ignored because of + CENSUS_MAX_PROPAGATED_TAGS limit. */ +} census_context_status; + +/* Create a new context, adding and removing tags from an existing context. + This will copy all tags from the 'tags' input, so it is recommended + to add as many tags in a single operation as is practical for the client. + @param base Base context to build upon. Can be NULL. + @param tags A set of tags to be added/changed/deleted. Tags with keys that + are in 'tags', but not 'base', are added to the tag set. Keys that are in + both 'tags' and 'base' will have their value/flags modified. Tags with keys + in both, but with NULL or zero-length values, will be deleted from the tag + set. Tags with invalid (too long or short) keys or values will be ignored. + If adding a tag will result in more than CENSUS_MAX_PROPAGATED_TAGS in either + binary or non-binary tags, they will be ignored, as will deletions of + tags that don't exist. + @param ntags number of tags in 'tags' + @param status If not NULL, will return a pointer to a census_context_status + structure containing information about the new context and status of the + tags used in its creation. + @return A new, valid census_context. +*/ +CENSUS_API census_context *census_context_create( + const census_context *base, const census_tag *tags, int ntags, + census_context_status const **status); + +/* Destroy a context. Once this function has been called, the context cannot + be reused. */ +CENSUS_API void census_context_destroy(census_context *context); + +/* Get a pointer to the original status from the context creation. */ +CENSUS_API const census_context_status *census_context_get_status( + const census_context *context); + +/* Structure used for iterating over the tegs in a context. API clients should + not use or reference internal fields - neither their contents or + presence/absence are guaranteed. */ +typedef struct { + const census_context *context; + int base; + int index; + char *kvm; +} census_context_iterator; + +/* Initialize a census_tag_iterator. Must be called before first use. */ +CENSUS_API void census_context_initialize_iterator( + const census_context *context, census_context_iterator *iterator); + +/* Get the contents of the "next" tag in the context. If there are no more + tags, returns 0 (and 'tag' contents will be unchanged), otherwise returns 1. + */ +CENSUS_API int census_context_next_tag(census_context_iterator *iterator, + census_tag *tag); + +/* Get a context tag by key. Returns 0 if the key is not present. */ +CENSUS_API int census_context_get_tag(const census_context *context, + const char *key, census_tag *tag); + +/* Tag set encode/decode functionality. These functionas are intended + for use by RPC systems only, for purposes of transmitting/receiving contexts. + */ + +/* Encode a context into a buffer. The propagated tags are encoded into the + buffer in two regions: one for printable tags, and one for binary tags. + @param context context to be encoded + @param buffer pointer to buffer. This address will be used to encode the + printable tags. + @param buf_size number of available bytes in buffer. + @param print_buf_size Will be set to the number of bytes consumed by + printable tags. + @param bin_buf_size Will be set to the number of bytes used to encode the + binary tags. + @return A pointer to the binary tag's encoded, or NULL if the buffer was + insufficiently large to hold the encoded tags. Thus, if successful, + printable tags are encoded into + [buffer, buffer + *print_buf_size) and binary tags into + [returned-ptr, returned-ptr + *bin_buf_size) (and the returned + pointer should be buffer + *print_buf_size) */ +CENSUS_API char *census_context_encode(const census_context *context, + char *buffer, size_t buf_size, + size_t *print_buf_size, + size_t *bin_buf_size); + +/* Decode context buffers encoded with census_context_encode(). Returns NULL + if there is an error in parsing either buffer. */ +CENSUS_API census_context *census_context_decode(const char *buffer, + size_t size, + const char *bin_buffer, + size_t bin_size); /* Distributed traces can have a number of options. */ enum census_trace_mask_values { @@ -326,146 +446,6 @@ CENSUS_API int census_get_trace_record(census_trace_record *trace_record); /** End a scan previously started by census_trace_scan_start() */ CENSUS_API void census_trace_scan_end(); -/* A Census tag set is a collection of key:value string pairs; these form the - basis against which Census metrics will be recorded. Keys are unique within - a tag set. All contexts have an associated tag set. */ -typedef struct census_tag_set census_tag_set; - -/* A tag is a key:value pair. The key is a non-empty, printable (UTF-8 - encoded), nil-terminated string. The value is a binary string, that may be - printable. There are limits on the sizes of both keys and values (see - CENSUS_MAX_TAG_KB_LEN definition below), and the number of tags that can be - propagated (CENSUS_MAX_PROPAGATED_TAGS). Users should also remember that - some systems may have limits on, e.g., the number of bytes that can be - transmitted as metadata, and that larger tags means more memory consumed - and time in processing. */ -typedef struct { - const char *key; - const char *value; - size_t value_len; - uint8_t flags; -} census_tag; - -/* Maximum length of a tag's key or value. */ -#define CENSUS_MAX_TAG_KV_LEN 255 -/* Maximum number of propagatable tags. */ -#define CENSUS_MAX_PROPAGATED_TAGS 255 - -/* Tag flags. */ -#define CENSUS_TAG_PROPAGATE 1 /* Tag should be propagated over RPC */ -#define CENSUS_TAG_STATS 2 /* Tag will be used for statistics aggregation */ -#define CENSUS_TAG_BINARY 4 /* Tag value is not printable */ -#define CENSUS_TAG_RESERVED 8 /* Reserved for internal use. */ -/* Flag values 8,16,32,64,128 are reserved for future/internal use. Clients - should not use or rely on their values. */ - -#define CENSUS_TAG_IS_PROPAGATED(flags) (flags & CENSUS_TAG_PROPAGATE) -#define CENSUS_TAG_IS_STATS(flags) (flags & CENSUS_TAG_STATS) -#define CENSUS_TAG_IS_BINARY(flags) (flags & CENSUS_TAG_BINARY) - -typedef struct { - int n_propagated_tags; /* number of propagated printable tags */ - int n_propagated_binary_tags; /* number of propagated binary tags */ - int n_local_tags; /* number of non-propagated (local) tags */ - int n_deleted_tags; /* number of tags that were deleted */ - int n_added_tags; /* number of tags that were added */ - int n_modified_tags; /* number of tags that were modified */ - int n_invalid_tags; /* number of tags with bad keys or values (e.g. - longer than CENSUS_MAX_TAG_KV_LEN) */ - int n_ignored_tags; /* number of tags ignored because of - CENSUS_MAX_PROPAGATED_TAGS limit. */ -} census_tag_set_create_status; - -/* Create a new tag set, adding and removing tags from an existing tag set. - This will copy all tags from it's input parameters, so it is recommended - to add as many tags in a single operation as is practical for the client. - @param base Base tag set to build upon. Can be NULL. - @param tags A set of tags to be added/changed/deleted. Tags with keys that - are in 'tags', but not 'base', are added to the tag set. Keys that are in - both 'tags' and 'base' will have their value/flags modified. Tags with keys - in both, but with NULL or zero-length values, will be deleted from the tag - set. Tags with invalid (too long or short) keys or values will be ignored. - If adding a tag will result in more than CENSUS_MAX_PROPAGATED_TAGS in either - binary or non-binary tags, they will be ignored, as will deletions of - tags that don't exist. - @param ntags number of tags in 'tags' - @param status If not NULL, will return a pointer to a - census_tag_set_create_status structure containing information about the new - tag set and status of the tags used in its creation. - @return A new, valid census_tag_set. -*/ -CENSUS_API census_tag_set *census_tag_set_create( - const census_tag_set *base, const census_tag *tags, int ntags, - census_tag_set_create_status const **status); - -/* Destroy a tag set created by census_tag_set_create(). Once this function - has been called, the tag set cannot be reused. */ -CENSUS_API void census_tag_set_destroy(census_tag_set *tags); - -/* Get a pointer to the original status from the creation of this tag set. */ -CENSUS_API const census_tag_set_create_status *census_tag_set_get_create_status( - const census_tag_set *tags); - -/* Structure used for tag set iteration. API clients should not use or - reference internal fields - neither their contents or presence/absence are - guaranteed. */ -typedef struct { - const census_tag_set *tags; - int base; - int index; - char *kvm; -} census_tag_set_iterator; - -/* Initialize a tag set iterator. Must be called before first use of the - iterator. */ -CENSUS_API void census_tag_set_initialize_iterator( - const census_tag_set *tags, census_tag_set_iterator *iterator); - -/* Get the contents of the "next" tag in the tag set. If there are no more - tags in the tag set, returns 0 (and 'tag' contents will be unchanged), - otherwise returns 1. */ -CENSUS_API int census_tag_set_next_tag(census_tag_set_iterator *iterator, - census_tag *tag); - -/* Get a tag by its key. Returns 0 if the key is not present in the tag - set. */ -CENSUS_API int census_tag_set_get_tag_by_key(const census_tag_set *tags, - const char *key, census_tag *tag); - -/* Tag set encode/decode functionality. These functionas are intended - for use by RPC systems only, for purposes of transmitting/receiving tag - sets. */ - -/* Encode a tag set into a buffer. The propagated tags are encoded into the - buffer in two regions: one for printable tags, and one for binary tags. - @param tags tag set to be encoded - @param buffer pointer to buffer. This address will be used to encode the - printable tags. - @param buf_size number of available bytes in buffer. - @param print_buf_size Will be set to the number of bytes consumed by - printable tags. - @param bin_buf_size Will be set to the number of bytes used to encode the - binary tags. - @return A pointer to the binary tag's encoded, or NULL if the buffer was - insufficiently large to hold the encoded tags. Thus, if successful, - printable tags are encoded into - [buffer, buffer + *print_buf_size) and binary tags into - [returned-ptr, returned-ptr + *bin_buf_size) (and the return value - should be buffer + *print_buf_size) */ -CENSUS_API char *census_tag_set_encode(const census_tag_set *tags, char *buffer, - size_t buf_size, size_t *print_buf_size, - size_t *bin_buf_size); - -/* Decode tag set buffers encoded with census_tag_set_encode_*(). Returns NULL - if there is an error in parsing either buffer. */ -CENSUS_API census_tag_set *census_tag_set_decode(const char *buffer, - size_t size, - const char *bin_buffer, - size_t bin_size); - -/* Get a contexts tag set. */ -CENSUS_API census_tag_set *census_context_tag_set(census_context *context); - /* Core stats collection API's. The following concepts are used: * Aggregation: A collection of values. Census supports the following aggregation types: @@ -511,8 +491,7 @@ extern census_aggregation_ops census_agg_window; construction via census_define_view(). */ typedef struct { const census_aggregation_ops *ops; - const void * - create_arg; /* Argument to be used for aggregation initialization. */ + const void *create_arg; /* Aaggregation initialization argument. */ } census_aggregation; /** A census view type. Opaque. */ @@ -520,14 +499,17 @@ typedef struct census_view census_view; /** Create a new view. @param metric_id Metric with which this view is associated. - @param tags tags that define the view + @param tags tags that define the view. @param aggregations aggregations to associate with the view @param naggregations number of aggregations @return A new census view */ + +/* TODO(aveitch): consider if context is the right argument type to pass in + tags. */ CENSUS_API census_view *census_view_create( - uint32_t metric_id, const census_tag_set *tags, + uint32_t metric_id, const census_context *tags, const census_aggregation *aggregations, size_t naggregations); /** Destroy a previously created view. */ @@ -540,7 +522,7 @@ CENSUS_API size_t census_view_metric(const census_view *view); CENSUS_API size_t census_view_naggregations(const census_view *view); /** Get tags associated with view. */ -CENSUS_API const census_tag_set *census_view_tags(const census_view *view); +CENSUS_API const census_context *census_view_tags(const census_view *view); /** Get aggregation descriptors associated with a view. */ CENSUS_API const census_aggregation *census_view_aggregrations( @@ -549,7 +531,7 @@ CENSUS_API const census_aggregation *census_view_aggregrations( /** Holds all the aggregation data for a particular view instantiation. Forms part of the data returned by census_view_data(). */ typedef struct { - const census_tag_set *tags; /* Tags for this set of aggregations. */ + const census_context *tags; /* Tags for this set of aggregations. */ const void **data; /* One data set for every aggregation in the view. */ } census_view_aggregation_data; diff --git a/include/grpc/grpc_zookeeper.h b/include/grpc/grpc_zookeeper.h index f6a5246d3a..b23bd88b43 100644 --- a/include/grpc/grpc_zookeeper.h +++ b/include/grpc/grpc_zookeeper.h @@ -50,7 +50,7 @@ extern "C" { #endif /** Register zookeeper name resolver in grpc */ -GRPC_API void grpc_zookeeper_register(); +void grpc_zookeeper_register(); #ifdef __cplusplus } diff --git a/include/grpc/impl/codegen/compression_types.h b/include/grpc/impl/codegen/compression_types.h index f552d3c8a2..0daccd92f2 100644 --- a/include/grpc/impl/codegen/compression_types.h +++ b/include/grpc/impl/codegen/compression_types.h @@ -34,7 +34,7 @@ #ifndef GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H #define GRPC_IMPL_CODEGEN_COMPRESSION_TYPES_H -#include <stdint.h> +#include <grpc/impl/codegen/port_platform.h> #ifdef __cplusplus extern "C" { diff --git a/include/grpc/impl/codegen/port_platform.h b/include/grpc/impl/codegen/port_platform.h index d5294b2efa..d265e9b392 100644 --- a/include/grpc/impl/codegen/port_platform.h +++ b/include/grpc/impl/codegen/port_platform.h @@ -254,9 +254,22 @@ #define GPR_FORBID_UNREACHABLE_CODE 1 #endif -/* For a common case, assume that the platform has a C99-like stdint.h */ - +#ifdef _MSC_VER +#if _MSC_VER < 1700 +typedef __int8 int8_t; +typedef __int16 int16_t; +typedef __int32 int32_t; +typedef __int64 int64_t; +typedef unsigned __int8 uint8_t; +typedef unsigned __int16 uint16_t; +typedef unsigned __int32 uint32_t; +typedef unsigned __int64 uint64_t; +#else +#include <stdint.h> +#endif /* _MSC_VER < 1700 */ +#else #include <stdint.h> +#endif /* _MSC_VER */ /* Cache line alignment */ #ifndef GPR_CACHELINE_SIZE_LOG diff --git a/include/grpc/impl/codegen/propagation_bits.h b/include/grpc/impl/codegen/propagation_bits.h index 989b86f2aa..cdd699710c 100644 --- a/include/grpc/impl/codegen/propagation_bits.h +++ b/include/grpc/impl/codegen/propagation_bits.h @@ -34,7 +34,7 @@ #ifndef GRPC_IMPL_CODEGEN_H #define GRPC_IMPL_CODEGEN_H -#include <stdint.h> +#include <grpc/impl/codegen/port_platform.h> #ifdef __cplusplus extern "C" { diff --git a/include/grpc/impl/codegen/sync.h b/include/grpc/impl/codegen/sync.h index 7086b5d371..04ff0dc5bf 100644 --- a/include/grpc/impl/codegen/sync.h +++ b/include/grpc/impl/codegen/sync.h @@ -115,7 +115,8 @@ GPR_API void gpr_cv_destroy(gpr_cv *cv); /* Atomically release *mu and wait on *cv. When the calling thread is woken from *cv or the deadline abs_deadline is exceeded, execute gpr_mu_lock(mu) and return whether the deadline was exceeded. Use - abs_deadline==gpr_inf_future for no deadline. May return even when not + abs_deadline==gpr_inf_future for no deadline. abs_deadline can be either + an absolute deadline, or a GPR_TIMESPAN. May return even when not woken explicitly. Requires: *mu and *cv initialized; the calling thread holds an exclusive lock on *mu. */ GPR_API int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline); diff --git a/include/grpc/impl/codegen/time.h b/include/grpc/impl/codegen/time.h index b40c2b260c..4ed1c3cbd8 100644 --- a/include/grpc/impl/codegen/time.h +++ b/include/grpc/impl/codegen/time.h @@ -102,14 +102,16 @@ GPR_API gpr_timespec gpr_time_min(gpr_timespec a, gpr_timespec b); GPR_API gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b); GPR_API gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b); -/* Return a timespec representing a given number of time units. LONG_MIN is - interpreted as gpr_inf_past, and LONG_MAX as gpr_inf_future. */ -GPR_API gpr_timespec gpr_time_from_micros(long x, gpr_clock_type clock_type); -GPR_API gpr_timespec gpr_time_from_nanos(long x, gpr_clock_type clock_type); -GPR_API gpr_timespec gpr_time_from_millis(long x, gpr_clock_type clock_type); -GPR_API gpr_timespec gpr_time_from_seconds(long x, gpr_clock_type clock_type); -GPR_API gpr_timespec gpr_time_from_minutes(long x, gpr_clock_type clock_type); -GPR_API gpr_timespec gpr_time_from_hours(long x, gpr_clock_type clock_type); +/* Return a timespec representing a given number of time units. INT64_MIN is + interpreted as gpr_inf_past, and INT64_MAX as gpr_inf_future. */ +GPR_API gpr_timespec gpr_time_from_micros(int64_t x, gpr_clock_type clock_type); +GPR_API gpr_timespec gpr_time_from_nanos(int64_t x, gpr_clock_type clock_type); +GPR_API gpr_timespec gpr_time_from_millis(int64_t x, gpr_clock_type clock_type); +GPR_API gpr_timespec +gpr_time_from_seconds(int64_t x, gpr_clock_type clock_type); +GPR_API gpr_timespec +gpr_time_from_minutes(int64_t x, gpr_clock_type clock_type); +GPR_API gpr_timespec gpr_time_from_hours(int64_t x, gpr_clock_type clock_type); GPR_API int32_t gpr_time_to_millis(gpr_timespec timespec); |