diff options
Diffstat (limited to 'src')
83 files changed, 4706 insertions, 981 deletions
diff --git a/src/core/census/context.c b/src/core/census/context.c index cab58b653c..e60330de64 100644 --- a/src/core/census/context.c +++ b/src/core/census/context.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,16 +31,500 @@ * */ -#include "src/core/census/context.h" - -#include <string.h> #include <grpc/census.h> #include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/port_platform.h> +#include <grpc/support/useful.h> +#include <stdbool.h> +#include <string.h> +#include "src/core/support/string.h" + +// Functions in this file support the public context API, including +// encoding/decoding as part of context propagation across RPC's. The overall +// requirements (in approximate priority order) for the +// context representation: +// 1. Efficient conversion to/from wire format +// 2. Minimal bytes used on-wire +// 3. Efficient context creation +// 4. Efficient lookup of tag value for a key +// 5. Efficient iteration over tags +// 6. Minimal memory footprint +// +// Notes on tradeoffs/decisions: +// * tag includes 1 byte length of key, as well as nil-terminating byte. These +// are to aid in efficient parsing and the ability to directly return key +// strings. This is more important than saving a single byte/tag on the wire. +// * The wire encoding uses only single byte values. This eliminates the need +// to handle endian-ness conversions. It also means there is a hard upper +// limit of 255 for both CENSUS_MAX_TAG_KV_LEN and CENSUS_MAX_PROPAGATED_TAGS. +// * Keep all tag information (keys/values/flags) in a single memory buffer, +// that can be directly copied to the wire. +// * Binary tags share the same structure as, but are encoded separately from, +// non-binary tags. This is primarily because non-binary tags are far more +// likely to be repeated across multiple RPC calls, so are more efficiently +// cached and compressed in any metadata schemes. + +// Structure representing a set of tags. Essentially a count of number of tags +// present, and pointer to a chunk of memory that contains the per-tag details. +struct tag_set { + int ntags; // number of tags. + int ntags_alloc; // ntags + number of deleted tags (total number of tags + // in all of kvm). This will always be == ntags, except during the process + // of building a new tag set. + size_t kvm_size; // number of bytes allocated for key/value storage. + size_t kvm_used; // number of bytes of used key/value memory + char *kvm; // key/value memory. Consists of repeated entries of: + // Offset Size Description + // 0 1 Key length, including trailing 0. (K) + // 1 1 Value length. (V) + // 2 1 Flags + // 3 K Key bytes + // 3 + K V Value bytes + // + // We refer to the first 3 entries as the 'tag header'. If extra values are + // introduced in the header, you will need to modify the TAG_HEADER_SIZE + // constant, the raw_tag structure (and everything that uses it) and the + // encode/decode functions appropriately. +}; + +// Number of bytes in tag header. +#define TAG_HEADER_SIZE 3 // key length (1) + value length (1) + flags (1) +// Offsets to tag header entries. +#define KEY_LEN_OFFSET 0 +#define VALUE_LEN_OFFSET 1 +#define FLAG_OFFSET 2 + +// raw_tag represents the raw-storage form of a tag in the kvm of a tag_set. +struct raw_tag { + uint8_t key_len; + uint8_t value_len; + uint8_t flags; + char *key; + char *value; +}; + +// Use a reserved flag bit for indication of deleted tag. +#define CENSUS_TAG_DELETED CENSUS_TAG_RESERVED +#define CENSUS_TAG_IS_DELETED(flags) (flags & CENSUS_TAG_DELETED) + +// Primary (external) representation of a context. Composed of 3 underlying +// tag_set structs, one for each of the binary/printable propagated tags, and +// one for everything else. This is to efficiently support tag +// encoding/decoding. +struct census_context { + struct tag_set tags[3]; + census_context_status status; +}; + +// Indices into the tags member of census_context +#define PROPAGATED_TAGS 0 +#define PROPAGATED_BINARY_TAGS 1 +#define LOCAL_TAGS 2 + +// Extract a raw tag given a pointer (raw) to the tag header. Allow for some +// extra bytes in the tag header (see encode/decode functions for usage: this +// allows for future expansion of the tag header). +static char *decode_tag(struct raw_tag *tag, char *header, int offset) { + tag->key_len = (uint8_t)(*header++); + tag->value_len = (uint8_t)(*header++); + tag->flags = (uint8_t)(*header++); + header += offset; + tag->key = header; + header += tag->key_len; + tag->value = header; + return header + tag->value_len; +} -/* Placeholder implementation only. */ +// Make a copy (in 'to') of an existing tag_set. +static void tag_set_copy(struct tag_set *to, const struct tag_set *from) { + memcpy(to, from, sizeof(struct tag_set)); + to->kvm = gpr_malloc(to->kvm_size); + memcpy(to->kvm, from->kvm, from->kvm_used); +} + +// Delete a tag from a tag_set, if it exists (returns true if it did). +static bool tag_set_delete_tag(struct tag_set *tags, const char *key, + size_t key_len) { + char *kvp = tags->kvm; + for (int i = 0; i < tags->ntags_alloc; i++) { + uint8_t *flags = (uint8_t *)(kvp + FLAG_OFFSET); + struct raw_tag tag; + kvp = decode_tag(&tag, kvp, 0); + if (CENSUS_TAG_IS_DELETED(tag.flags)) continue; + if ((key_len == tag.key_len) && (memcmp(key, tag.key, key_len) == 0)) { + *flags |= CENSUS_TAG_DELETED; + tags->ntags--; + return true; + } + } + return false; +} + +// Delete a tag from a context, return true if it existed. +static bool context_delete_tag(census_context *context, const census_tag *tag, + size_t key_len) { + return ( + tag_set_delete_tag(&context->tags[LOCAL_TAGS], tag->key, key_len) || + tag_set_delete_tag(&context->tags[PROPAGATED_TAGS], tag->key, key_len) || + tag_set_delete_tag(&context->tags[PROPAGATED_BINARY_TAGS], tag->key, + key_len)); +} + +// Add a tag to a tag_set. Return true on success, false if the tag could +// not be added because of constraints on tag set size. This function should +// not be called if the tag may already exist (in a non-deleted state) in +// the tag_set, as that would result in two tags with the same key. +static bool tag_set_add_tag(struct tag_set *tags, const census_tag *tag, + size_t key_len) { + if (tags->ntags == CENSUS_MAX_PROPAGATED_TAGS) { + return false; + } + const size_t tag_size = key_len + tag->value_len + TAG_HEADER_SIZE; + if (tags->kvm_used + tag_size > tags->kvm_size) { + // allocate new memory if needed + tags->kvm_size += 2 * CENSUS_MAX_TAG_KV_LEN + TAG_HEADER_SIZE; + char *new_kvm = gpr_malloc(tags->kvm_size); + memcpy(new_kvm, tags->kvm, tags->kvm_used); + gpr_free(tags->kvm); + tags->kvm = new_kvm; + } + char *kvp = tags->kvm + tags->kvm_used; + *kvp++ = (char)key_len; + *kvp++ = (char)tag->value_len; + // ensure reserved flags are not used. + *kvp++ = (char)(tag->flags & (CENSUS_TAG_PROPAGATE | CENSUS_TAG_STATS | + CENSUS_TAG_BINARY)); + memcpy(kvp, tag->key, key_len); + kvp += key_len; + memcpy(kvp, tag->value, tag->value_len); + tags->kvm_used += tag_size; + tags->ntags++; + tags->ntags_alloc++; + return true; +} + +// Add/modify/delete a tag to/in a context. Caller must validate that tag key +// etc. are valid. +static void context_modify_tag(census_context *context, const census_tag *tag, + size_t key_len) { + // First delete the tag if it is already present. + bool deleted = context_delete_tag(context, tag, key_len); + // Determine if we need to add it back. + bool call_add = tag->value != NULL && tag->value_len != 0; + bool added = false; + if (call_add) { + if (CENSUS_TAG_IS_PROPAGATED(tag->flags)) { + if (CENSUS_TAG_IS_BINARY(tag->flags)) { + added = tag_set_add_tag(&context->tags[PROPAGATED_BINARY_TAGS], tag, + key_len); + } else { + added = tag_set_add_tag(&context->tags[PROPAGATED_TAGS], tag, key_len); + } + } else { + added = tag_set_add_tag(&context->tags[LOCAL_TAGS], tag, key_len); + } + } + if (deleted) { + if (call_add) { + context->status.n_modified_tags++; + } else { + context->status.n_deleted_tags++; + } + } else { + if (added) { + context->status.n_added_tags++; + } else { + context->status.n_ignored_tags++; + } + } +} + +// Remove memory used for deleted tags from a tag set. Basic algorithm: +// 1) Walk through tag set to find first deleted tag. Record where it is. +// 2) Find the next not-deleted tag. Copy all of kvm from there to the end +// "over" the deleted tags +// 3) repeat #1 and #2 until we have seen all tags +// 4) if we are still looking for a not-deleted tag, then all the end portion +// of the kvm is deleted. Just reduce the used amount of memory by the +// appropriate amount. +static void tag_set_flatten(struct tag_set *tags) { + if (tags->ntags == tags->ntags_alloc) return; + bool found_deleted = false; // found a deleted tag. + char *kvp = tags->kvm; + char *dbase = NULL; // record location of deleted tag + for (int i = 0; i < tags->ntags_alloc; i++) { + struct raw_tag tag; + char *next_kvp = decode_tag(&tag, kvp, 0); + if (found_deleted) { + if (!CENSUS_TAG_IS_DELETED(tag.flags)) { + ptrdiff_t reduce = kvp - dbase; // #bytes in deleted tags + GPR_ASSERT(reduce > 0); + ptrdiff_t copy_size = tags->kvm + tags->kvm_used - kvp; + GPR_ASSERT(copy_size > 0); + memmove(dbase, kvp, (size_t)copy_size); + tags->kvm_used -= (size_t)reduce; + next_kvp -= reduce; + found_deleted = false; + } + } else { + if (CENSUS_TAG_IS_DELETED(tag.flags)) { + dbase = kvp; + found_deleted = true; + } + } + kvp = next_kvp; + } + if (found_deleted) { + GPR_ASSERT(dbase > tags->kvm); + tags->kvm_used = (size_t)(dbase - tags->kvm); + } + tags->ntags_alloc = tags->ntags; +} -size_t census_context_serialize(const census_context *context, char *buffer, - size_t buf_size) { - /* TODO(aveitch): implement serialization */ +census_context *census_context_create(const census_context *base, + const census_tag *tags, int ntags, + census_context_status const **status) { + census_context *context = gpr_malloc(sizeof(census_context)); + // If we are given a base, copy it into our new tag set. Otherwise set it + // to zero/NULL everything. + if (base == NULL) { + memset(context, 0, sizeof(census_context)); + } else { + tag_set_copy(&context->tags[PROPAGATED_TAGS], &base->tags[PROPAGATED_TAGS]); + tag_set_copy(&context->tags[PROPAGATED_BINARY_TAGS], + &base->tags[PROPAGATED_BINARY_TAGS]); + tag_set_copy(&context->tags[LOCAL_TAGS], &base->tags[LOCAL_TAGS]); + memset(&context->status, 0, sizeof(context->status)); + } + // Walk over the additional tags and, for those that aren't invalid, modify + // the context to add/replace/delete as required. + for (int i = 0; i < ntags; i++) { + const census_tag *tag = &tags[i]; + size_t key_len = strlen(tag->key) + 1; + // ignore the tag if it is too long/short. + if (key_len != 1 && key_len <= CENSUS_MAX_TAG_KV_LEN && + tag->value_len <= CENSUS_MAX_TAG_KV_LEN) { + context_modify_tag(context, tag, key_len); + } else { + context->status.n_invalid_tags++; + } + } + // Remove any deleted tags, update status if needed, and return. + tag_set_flatten(&context->tags[PROPAGATED_TAGS]); + tag_set_flatten(&context->tags[PROPAGATED_BINARY_TAGS]); + tag_set_flatten(&context->tags[LOCAL_TAGS]); + context->status.n_propagated_tags = context->tags[PROPAGATED_TAGS].ntags; + context->status.n_propagated_binary_tags = + context->tags[PROPAGATED_BINARY_TAGS].ntags; + context->status.n_local_tags = context->tags[LOCAL_TAGS].ntags; + if (status) { + *status = &context->status; + } + return context; +} + +const census_context_status *census_context_get_status( + const census_context *context) { + return &context->status; +} + +void census_context_destroy(census_context *context) { + gpr_free(context->tags[PROPAGATED_TAGS].kvm); + gpr_free(context->tags[PROPAGATED_BINARY_TAGS].kvm); + gpr_free(context->tags[LOCAL_TAGS].kvm); + gpr_free(context); +} + +void census_context_initialize_iterator(const census_context *context, + census_context_iterator *iterator) { + iterator->context = context; + iterator->index = 0; + if (context->tags[PROPAGATED_TAGS].ntags != 0) { + iterator->base = PROPAGATED_TAGS; + iterator->kvm = context->tags[PROPAGATED_TAGS].kvm; + } else if (context->tags[PROPAGATED_BINARY_TAGS].ntags != 0) { + iterator->base = PROPAGATED_BINARY_TAGS; + iterator->kvm = context->tags[PROPAGATED_BINARY_TAGS].kvm; + } else if (context->tags[LOCAL_TAGS].ntags != 0) { + iterator->base = LOCAL_TAGS; + iterator->kvm = context->tags[LOCAL_TAGS].kvm; + } else { + iterator->base = -1; + } +} + +int census_context_next_tag(census_context_iterator *iterator, + census_tag *tag) { + if (iterator->base < 0) { + return 0; + } + struct raw_tag raw; + iterator->kvm = decode_tag(&raw, iterator->kvm, 0); + tag->key = raw.key; + tag->value = raw.value; + tag->value_len = raw.value_len; + tag->flags = raw.flags; + if (++iterator->index == iterator->context->tags[iterator->base].ntags) { + do { + if (iterator->base == LOCAL_TAGS) { + iterator->base = -1; + return 1; + } + } while (iterator->context->tags[++iterator->base].ntags == 0); + iterator->index = 0; + iterator->kvm = iterator->context->tags[iterator->base].kvm; + } + return 1; +} + +// Find a tag in a tag_set by key. Return true if found, false otherwise. +static bool tag_set_get_tag(const struct tag_set *tags, const char *key, + size_t key_len, census_tag *tag) { + char *kvp = tags->kvm; + for (int i = 0; i < tags->ntags; i++) { + struct raw_tag raw; + kvp = decode_tag(&raw, kvp, 0); + if (key_len == raw.key_len && memcmp(raw.key, key, key_len) == 0) { + tag->key = raw.key; + tag->value = raw.value; + tag->value_len = raw.value_len; + tag->flags = raw.flags; + return true; + } + } + return false; +} + +int census_context_get_tag(const census_context *context, const char *key, + census_tag *tag) { + size_t key_len = strlen(key) + 1; + if (key_len == 1) { + return 0; + } + if (tag_set_get_tag(&context->tags[PROPAGATED_TAGS], key, key_len, tag) || + tag_set_get_tag(&context->tags[PROPAGATED_BINARY_TAGS], key, key_len, + tag) || + tag_set_get_tag(&context->tags[LOCAL_TAGS], key, key_len, tag)) { + return 1; + } return 0; } + +// Context encoding and decoding functions. +// +// Wire format for tag_set's on the wire: +// +// First, a tag set header: +// +// offset bytes description +// 0 1 version number +// 1 1 number of bytes in this header. This allows for future +// expansion. +// 2 1 number of bytes in each tag header. +// 3 1 ntags value from tag set. +// +// This is followed by the key/value memory from struct tag_set. + +#define ENCODED_VERSION 0 // Version number +#define ENCODED_HEADER_SIZE 4 // size of tag set header + +// Encode a tag set. Returns 0 if buffer is too small. +static size_t tag_set_encode(const struct tag_set *tags, char *buffer, + size_t buf_size) { + if (buf_size < ENCODED_HEADER_SIZE + tags->kvm_used) { + return 0; + } + buf_size -= ENCODED_HEADER_SIZE; + *buffer++ = (char)ENCODED_VERSION; + *buffer++ = (char)ENCODED_HEADER_SIZE; + *buffer++ = (char)TAG_HEADER_SIZE; + *buffer++ = (char)tags->ntags; + if (tags->ntags == 0) { + return ENCODED_HEADER_SIZE; + } + memcpy(buffer, tags->kvm, tags->kvm_used); + return ENCODED_HEADER_SIZE + tags->kvm_used; +} + +char *census_context_encode(const census_context *context, char *buffer, + size_t buf_size, size_t *print_buf_size, + size_t *bin_buf_size) { + *print_buf_size = + tag_set_encode(&context->tags[PROPAGATED_TAGS], buffer, buf_size); + if (*print_buf_size == 0) { + return NULL; + } + char *b_buffer = buffer + *print_buf_size; + *bin_buf_size = tag_set_encode(&context->tags[PROPAGATED_BINARY_TAGS], + b_buffer, buf_size - *print_buf_size); + if (*bin_buf_size == 0) { + return NULL; + } + return b_buffer; +} + +// Decode a tag set. +static void tag_set_decode(struct tag_set *tags, const char *buffer, + size_t size) { + uint8_t version = (uint8_t)(*buffer++); + uint8_t header_size = (uint8_t)(*buffer++); + uint8_t tag_header_size = (uint8_t)(*buffer++); + tags->ntags = tags->ntags_alloc = (int)(*buffer++); + if (tags->ntags == 0) { + tags->ntags_alloc = 0; + tags->kvm_size = 0; + tags->kvm_used = 0; + tags->kvm = NULL; + return; + } + if (header_size != ENCODED_HEADER_SIZE) { + GPR_ASSERT(version != ENCODED_VERSION); + GPR_ASSERT(ENCODED_HEADER_SIZE < header_size); + buffer += (header_size - ENCODED_HEADER_SIZE); + } + tags->kvm_used = size - header_size; + tags->kvm_size = tags->kvm_used + CENSUS_MAX_TAG_KV_LEN; + tags->kvm = gpr_malloc(tags->kvm_size); + if (tag_header_size != TAG_HEADER_SIZE) { + // something new in the tag information. I don't understand it, so + // don't copy it over. + GPR_ASSERT(version != ENCODED_VERSION); + GPR_ASSERT(tag_header_size > TAG_HEADER_SIZE); + char *kvp = tags->kvm; + for (int i = 0; i < tags->ntags; i++) { + memcpy(kvp, buffer, TAG_HEADER_SIZE); + kvp += header_size; + struct raw_tag raw; + buffer = + decode_tag(&raw, (char *)buffer, tag_header_size - TAG_HEADER_SIZE); + memcpy(kvp, raw.key, (size_t)raw.key_len + raw.value_len); + kvp += raw.key_len + raw.value_len; + } + } else { + memcpy(tags->kvm, buffer, tags->kvm_used); + } +} + +census_context *census_context_decode(const char *buffer, size_t size, + const char *bin_buffer, size_t bin_size) { + census_context *context = gpr_malloc(sizeof(census_context)); + memset(&context->tags[LOCAL_TAGS], 0, sizeof(struct tag_set)); + if (buffer == NULL) { + memset(&context->tags[PROPAGATED_TAGS], 0, sizeof(struct tag_set)); + } else { + tag_set_decode(&context->tags[PROPAGATED_TAGS], buffer, size); + } + if (bin_buffer == NULL) { + memset(&context->tags[PROPAGATED_BINARY_TAGS], 0, sizeof(struct tag_set)); + } else { + tag_set_decode(&context->tags[PROPAGATED_BINARY_TAGS], bin_buffer, + bin_size); + } + memset(&context->status, 0, sizeof(context->status)); + context->status.n_propagated_tags = context->tags[PROPAGATED_TAGS].ntags; + context->status.n_propagated_binary_tags = + context->tags[PROPAGATED_BINARY_TAGS].ntags; + // TODO(aveitch): check that BINARY flag is correct for each type. + return context; +} diff --git a/src/core/census/placeholders.c b/src/core/census/placeholders.c new file mode 100644 index 0000000000..fe23d13971 --- /dev/null +++ b/src/core/census/placeholders.c @@ -0,0 +1,109 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <grpc/census.h> + +#include <grpc/support/log.h> + +/* Placeholders for the pending APIs */ + +int census_get_trace_record(census_trace_record *trace_record) { + (void)trace_record; + abort(); +} + +void census_record_values(census_context *context, census_value *values, + size_t nvalues) { + (void)context; + (void)values; + (void)nvalues; + abort(); +} + +void census_set_rpc_client_peer(census_context *context, const char *peer) { + (void)context; + (void)peer; + abort(); +} + +void census_trace_scan_end() { abort(); } + +int census_trace_scan_start(int consume) { + (void)consume; + abort(); +} + +const census_aggregation *census_view_aggregrations(const census_view *view) { + (void)view; + abort(); +} + +census_view *census_view_create(uint32_t metric_id, const census_context *tags, + const census_aggregation *aggregations, + size_t naggregations) { + (void)metric_id; + (void)tags; + (void)aggregations; + (void)naggregations; + abort(); +} + +const census_context *census_view_tags(const census_view *view) { + (void)view; + abort(); +} + +void census_view_delete(census_view *view) { + (void)view; + abort(); +} + +const census_view_data *census_view_get_data(const census_view *view) { + (void)view; + abort(); +} + +size_t census_view_metric(const census_view *view) { + (void)view; + abort(); +} + +size_t census_view_naggregations(const census_view *view) { + (void)view; + abort(); +} + +void census_view_reset(census_view *view) { + (void)view; + abort(); +} diff --git a/src/core/census/tag_set.c b/src/core/census/tag_set.c deleted file mode 100644 index 9b65a1dfa1..0000000000 --- a/src/core/census/tag_set.c +++ /dev/null @@ -1,535 +0,0 @@ -/* - * - * Copyright 2015-2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include <grpc/census.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> -#include <grpc/support/port_platform.h> -#include <grpc/support/useful.h> -#include <stdbool.h> -#include <string.h> -#include "src/core/support/string.h" - -// Functions in this file support the public tag_set API, as well as -// encoding/decoding tag_sets as part of context propagation across -// RPC's. The overall requirements (in approximate priority order) for the -// tag_set representations: -// 1. Efficient conversion to/from wire format -// 2. Minimal bytes used on-wire -// 3. Efficient tag set creation -// 4. Efficient lookup of value for a key -// 5. Efficient lookup of value for an index (to support iteration) -// 6. Minimal memory footprint -// -// Notes on tradeoffs/decisions: -// * tag includes 1 byte length of key, as well as nil-terminating byte. These -// are to aid in efficient parsing and the ability to directly return key -// strings. This is more important than saving a single byte/tag on the wire. -// * The wire encoding uses only single byte values. This eliminates the need -// to handle endian-ness conversions. It also means there is a hard upper -// limit of 255 for both CENSUS_MAX_TAG_KV_LEN and CENSUS_MAX_PROPAGATED_TAGS. -// * Keep all tag information (keys/values/flags) in a single memory buffer, -// that can be directly copied to the wire.14 -// * Binary tags share the same structure as, but are encoded separately from, -// non-binary tags. This is primarily because non-binary tags are far more -// likely to be repeated across multiple RPC calls, so are more efficiently -// cached and compressed in any metadata schemes. -// * all lengths etc. are restricted to one byte. This eliminates endian -// issues. - -// Structure representing a set of tags. Essentially a count of number of tags -// present, and pointer to a chunk of memory that contains the per-tag details. -struct tag_set { - int ntags; // number of tags. - int ntags_alloc; // ntags + number of deleted tags (total number of tags - // in all of kvm). This will always be == ntags, except during the process - // of building a new tag set. - size_t kvm_size; // number of bytes allocated for key/value storage. - size_t kvm_used; // number of bytes of used key/value memory - char *kvm; // key/value memory. Consists of repeated entries of: - // Offset Size Description - // 0 1 Key length, including trailing 0. (K) - // 1 1 Value length. (V) - // 2 1 Flags - // 3 K Key bytes - // 3 + K V Value bytes - // - // We refer to the first 3 entries as the 'tag header'. If extra values are - // introduced in the header, you will need to modify the TAG_HEADER_SIZE - // constant, the raw_tag structure (and everything that uses it) and the - // encode/decode functions appropriately. -}; - -// Number of bytes in tag header. -#define TAG_HEADER_SIZE 3 // key length (1) + value length (1) + flags (1) -// Offsets to tag header entries. -#define KEY_LEN_OFFSET 0 -#define VALUE_LEN_OFFSET 1 -#define FLAG_OFFSET 2 - -// raw_tag represents the raw-storage form of a tag in the kvm of a tag_set. -struct raw_tag { - uint8_t key_len; - uint8_t value_len; - uint8_t flags; - char *key; - char *value; -}; - -// Use a reserved flag bit for indication of deleted tag. -#define CENSUS_TAG_DELETED CENSUS_TAG_RESERVED -#define CENSUS_TAG_IS_DELETED(flags) (flags & CENSUS_TAG_DELETED) - -// Primary (external) representation of a tag set. Composed of 3 underlying -// tag_set structs, one for each of the binary/printable propagated tags, and -// one for everything else. This is to efficiently support tag -// encoding/decoding. -struct census_tag_set { - struct tag_set tags[3]; - census_tag_set_create_status status; -}; - -// Indices into the tags member of census_tag_set -#define PROPAGATED_TAGS 0 -#define PROPAGATED_BINARY_TAGS 1 -#define LOCAL_TAGS 2 - -// Extract a raw tag given a pointer (raw) to the tag header. Allow for some -// extra bytes in the tag header (see encode/decode functions for usage: this -// allows for future expansion of the tag header). -static char *decode_tag(struct raw_tag *tag, char *header, int offset) { - tag->key_len = (uint8_t)(*header++); - tag->value_len = (uint8_t)(*header++); - tag->flags = (uint8_t)(*header++); - header += offset; - tag->key = header; - header += tag->key_len; - tag->value = header; - return header + tag->value_len; -} - -// Make a copy (in 'to') of an existing tag_set. -static void tag_set_copy(struct tag_set *to, const struct tag_set *from) { - memcpy(to, from, sizeof(struct tag_set)); - to->kvm = gpr_malloc(to->kvm_size); - memcpy(to->kvm, from->kvm, from->kvm_used); -} - -// Delete a tag from a tag_set, if it exists (returns true if it did). -static bool tag_set_delete_tag(struct tag_set *tags, const char *key, - size_t key_len) { - char *kvp = tags->kvm; - for (int i = 0; i < tags->ntags_alloc; i++) { - uint8_t *flags = (uint8_t *)(kvp + FLAG_OFFSET); - struct raw_tag tag; - kvp = decode_tag(&tag, kvp, 0); - if (CENSUS_TAG_IS_DELETED(tag.flags)) continue; - if ((key_len == tag.key_len) && (memcmp(key, tag.key, key_len) == 0)) { - *flags |= CENSUS_TAG_DELETED; - tags->ntags--; - return true; - } - } - return false; -} - -// Delete a tag from a census_tag_set, return true if it existed. -static bool cts_delete_tag(census_tag_set *tags, const census_tag *tag, - size_t key_len) { - return (tag_set_delete_tag(&tags->tags[LOCAL_TAGS], tag->key, key_len) || - tag_set_delete_tag(&tags->tags[PROPAGATED_TAGS], tag->key, key_len) || - tag_set_delete_tag(&tags->tags[PROPAGATED_BINARY_TAGS], tag->key, - key_len)); -} - -// Add a tag to a tag_set. Return true on sucess, false if the tag could -// not be added because of constraints on tag set size. This function should -// not be called if the tag may already exist (in a non-deleted state) in -// the tag_set, as that would result in two tags with the same key. -static bool tag_set_add_tag(struct tag_set *tags, const census_tag *tag, - size_t key_len) { - if (tags->ntags == CENSUS_MAX_PROPAGATED_TAGS) { - return false; - } - const size_t tag_size = key_len + tag->value_len + TAG_HEADER_SIZE; - if (tags->kvm_used + tag_size > tags->kvm_size) { - // allocate new memory if needed - tags->kvm_size += 2 * CENSUS_MAX_TAG_KV_LEN + TAG_HEADER_SIZE; - char *new_kvm = gpr_malloc(tags->kvm_size); - memcpy(new_kvm, tags->kvm, tags->kvm_used); - gpr_free(tags->kvm); - tags->kvm = new_kvm; - } - char *kvp = tags->kvm + tags->kvm_used; - *kvp++ = (char)key_len; - *kvp++ = (char)tag->value_len; - // ensure reserved flags are not used. - *kvp++ = (char)(tag->flags & (CENSUS_TAG_PROPAGATE | CENSUS_TAG_STATS | - CENSUS_TAG_BINARY)); - memcpy(kvp, tag->key, key_len); - kvp += key_len; - memcpy(kvp, tag->value, tag->value_len); - tags->kvm_used += tag_size; - tags->ntags++; - tags->ntags_alloc++; - return true; -} - -// Add/modify/delete a tag to/in a census_tag_set. Caller must validate that -// tag key etc. are valid. -static void cts_modify_tag(census_tag_set *tags, const census_tag *tag, - size_t key_len) { - // First delete the tag if it is already present. - bool deleted = cts_delete_tag(tags, tag, key_len); - // Determine if we need to add it back. - bool call_add = tag->value != NULL && tag->value_len != 0; - bool added = false; - if (call_add) { - if (CENSUS_TAG_IS_PROPAGATED(tag->flags)) { - if (CENSUS_TAG_IS_BINARY(tag->flags)) { - added = - tag_set_add_tag(&tags->tags[PROPAGATED_BINARY_TAGS], tag, key_len); - } else { - added = tag_set_add_tag(&tags->tags[PROPAGATED_TAGS], tag, key_len); - } - } else { - added = tag_set_add_tag(&tags->tags[LOCAL_TAGS], tag, key_len); - } - } - if (deleted) { - if (call_add) { - tags->status.n_modified_tags++; - } else { - tags->status.n_deleted_tags++; - } - } else { - if (added) { - tags->status.n_added_tags++; - } else { - tags->status.n_ignored_tags++; - } - } -} - -// Remove memory used for deleted tags from the tag set. Basic algorithm: -// 1) Walk through tag set to find first deleted tag. Record where it is. -// 2) Find the next not-deleted tag. Copy all of kvm from there to the end -// "over" the deleted tags -// 3) repeat #1 and #2 until we have seen all tags -// 4) if we are still looking for a not-deleted tag, then all the end portion -// of the kvm is deleted. Just reduce the used amount of memory by the -// appropriate amount. -static void tag_set_flatten(struct tag_set *tags) { - if (tags->ntags == tags->ntags_alloc) return; - bool found_deleted = false; // found a deleted tag. - char *kvp = tags->kvm; - char *dbase = NULL; // record location of deleted tag - for (int i = 0; i < tags->ntags_alloc; i++) { - struct raw_tag tag; - char *next_kvp = decode_tag(&tag, kvp, 0); - if (found_deleted) { - if (!CENSUS_TAG_IS_DELETED(tag.flags)) { - ptrdiff_t reduce = kvp - dbase; // #bytes in deleted tags - GPR_ASSERT(reduce > 0); - ptrdiff_t copy_size = tags->kvm + tags->kvm_used - kvp; - GPR_ASSERT(copy_size > 0); - memmove(dbase, kvp, (size_t)copy_size); - tags->kvm_used -= (size_t)reduce; - next_kvp -= reduce; - found_deleted = false; - } - } else { - if (CENSUS_TAG_IS_DELETED(tag.flags)) { - dbase = kvp; - found_deleted = true; - } - } - kvp = next_kvp; - } - if (found_deleted) { - GPR_ASSERT(dbase > tags->kvm); - tags->kvm_used = (size_t)(dbase - tags->kvm); - } - tags->ntags_alloc = tags->ntags; -} - -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) { - census_tag_set *new_ts = gpr_malloc(sizeof(census_tag_set)); - // If we are given a base, copy it into our new tag set. Otherwise set it - // to zero/NULL everything. - if (base == NULL) { - memset(new_ts, 0, sizeof(census_tag_set)); - } else { - tag_set_copy(&new_ts->tags[PROPAGATED_TAGS], &base->tags[PROPAGATED_TAGS]); - tag_set_copy(&new_ts->tags[PROPAGATED_BINARY_TAGS], - &base->tags[PROPAGATED_BINARY_TAGS]); - tag_set_copy(&new_ts->tags[LOCAL_TAGS], &base->tags[LOCAL_TAGS]); - memset(&new_ts->status, 0, sizeof(new_ts->status)); - } - // Walk over the additional tags and, for those that aren't invalid, modify - // the tag set to add/replace/delete as required. - for (int i = 0; i < ntags; i++) { - const census_tag *tag = &tags[i]; - size_t key_len = strlen(tag->key) + 1; - // ignore the tag if it is too long/short. - if (key_len != 1 && key_len <= CENSUS_MAX_TAG_KV_LEN && - tag->value_len <= CENSUS_MAX_TAG_KV_LEN) { - cts_modify_tag(new_ts, tag, key_len); - } else { - new_ts->status.n_invalid_tags++; - } - } - // Remove any deleted tags, update status if needed, and return. - tag_set_flatten(&new_ts->tags[PROPAGATED_TAGS]); - tag_set_flatten(&new_ts->tags[PROPAGATED_BINARY_TAGS]); - tag_set_flatten(&new_ts->tags[LOCAL_TAGS]); - new_ts->status.n_propagated_tags = new_ts->tags[PROPAGATED_TAGS].ntags; - new_ts->status.n_propagated_binary_tags = - new_ts->tags[PROPAGATED_BINARY_TAGS].ntags; - new_ts->status.n_local_tags = new_ts->tags[LOCAL_TAGS].ntags; - if (status) { - *status = &new_ts->status; - } - return new_ts; -} - -const census_tag_set_create_status *census_tag_set_get_create_status( - const census_tag_set *tags) { - return &tags->status; -} - -void census_tag_set_destroy(census_tag_set *tags) { - gpr_free(tags->tags[PROPAGATED_TAGS].kvm); - gpr_free(tags->tags[PROPAGATED_BINARY_TAGS].kvm); - gpr_free(tags->tags[LOCAL_TAGS].kvm); - gpr_free(tags); -} - -// Initialize a tag set iterator. Must be called before first use of the -// iterator. -void census_tag_set_initialize_iterator(const census_tag_set *tags, - census_tag_set_iterator *iterator) { - iterator->tags = tags; - iterator->index = 0; - if (tags->tags[PROPAGATED_TAGS].ntags != 0) { - iterator->base = PROPAGATED_TAGS; - iterator->kvm = tags->tags[PROPAGATED_TAGS].kvm; - } else if (tags->tags[PROPAGATED_BINARY_TAGS].ntags != 0) { - iterator->base = PROPAGATED_BINARY_TAGS; - iterator->kvm = tags->tags[PROPAGATED_BINARY_TAGS].kvm; - } else if (tags->tags[LOCAL_TAGS].ntags != 0) { - iterator->base = LOCAL_TAGS; - iterator->kvm = tags->tags[LOCAL_TAGS].kvm; - } else { - iterator->base = -1; - } -} - -// 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. */ -int census_tag_set_next_tag(census_tag_set_iterator *iterator, - census_tag *tag) { - if (iterator->base < 0) { - return 0; - } - struct raw_tag raw; - iterator->kvm = decode_tag(&raw, iterator->kvm, 0); - tag->key = raw.key; - tag->value = raw.value; - tag->value_len = raw.value_len; - tag->flags = raw.flags; - if (++iterator->index == iterator->tags->tags[iterator->base].ntags) { - do { - if (iterator->base == LOCAL_TAGS) { - iterator->base = -1; - return 1; - } - } while (iterator->tags->tags[++iterator->base].ntags == 0); - iterator->index = 0; - iterator->kvm = iterator->tags->tags[iterator->base].kvm; - } - return 1; -} - -// Find a tag in a tag_set by key. Return true if found, false otherwise. -static bool tag_set_get_tag_by_key(const struct tag_set *tags, const char *key, - size_t key_len, census_tag *tag) { - char *kvp = tags->kvm; - for (int i = 0; i < tags->ntags; i++) { - struct raw_tag raw; - kvp = decode_tag(&raw, kvp, 0); - if (key_len == raw.key_len && memcmp(raw.key, key, key_len) == 0) { - tag->key = raw.key; - tag->value = raw.value; - tag->value_len = raw.value_len; - tag->flags = raw.flags; - return true; - } - } - return false; -} - -int census_tag_set_get_tag_by_key(const census_tag_set *tags, const char *key, - census_tag *tag) { - size_t key_len = strlen(key) + 1; - if (key_len == 1) { - return 0; - } - if (tag_set_get_tag_by_key(&tags->tags[PROPAGATED_TAGS], key, key_len, tag) || - tag_set_get_tag_by_key(&tags->tags[PROPAGATED_BINARY_TAGS], key, key_len, - tag) || - tag_set_get_tag_by_key(&tags->tags[LOCAL_TAGS], key, key_len, tag)) { - return 1; - } - return 0; -} - -// tag_set encoding and decoding functions. -// -// Wire format for tag sets on the wire: -// -// First, a tag set header: -// -// offset bytes description -// 0 1 version number -// 1 1 number of bytes in this header. This allows for future -// expansion. -// 2 1 number of bytes in each tag header. -// 3 1 ntags value from tag set. -// -// This is followed by the key/value memory from struct tag_set. - -#define ENCODED_VERSION 0 // Version number -#define ENCODED_HEADER_SIZE 4 // size of tag set header - -// Encode a tag set. Returns 0 if buffer is too small. -static size_t tag_set_encode(const struct tag_set *tags, char *buffer, - size_t buf_size) { - if (buf_size < ENCODED_HEADER_SIZE + tags->kvm_used) { - return 0; - } - buf_size -= ENCODED_HEADER_SIZE; - *buffer++ = (char)ENCODED_VERSION; - *buffer++ = (char)ENCODED_HEADER_SIZE; - *buffer++ = (char)TAG_HEADER_SIZE; - *buffer++ = (char)tags->ntags; - if (tags->ntags == 0) { - return ENCODED_HEADER_SIZE; - } - memcpy(buffer, tags->kvm, tags->kvm_used); - return ENCODED_HEADER_SIZE + tags->kvm_used; -} - -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) { - *print_buf_size = - tag_set_encode(&tags->tags[PROPAGATED_TAGS], buffer, buf_size); - if (*print_buf_size == 0) { - return NULL; - } - char *b_buffer = buffer + *print_buf_size; - *bin_buf_size = tag_set_encode(&tags->tags[PROPAGATED_BINARY_TAGS], b_buffer, - buf_size - *print_buf_size); - if (*bin_buf_size == 0) { - return NULL; - } - return b_buffer; -} - -// Decode a tag set. -static void tag_set_decode(struct tag_set *tags, const char *buffer, - size_t size) { - uint8_t version = (uint8_t)(*buffer++); - uint8_t header_size = (uint8_t)(*buffer++); - uint8_t tag_header_size = (uint8_t)(*buffer++); - tags->ntags = tags->ntags_alloc = (int)(*buffer++); - if (tags->ntags == 0) { - tags->ntags_alloc = 0; - tags->kvm_size = 0; - tags->kvm_used = 0; - tags->kvm = NULL; - return; - } - if (header_size != ENCODED_HEADER_SIZE) { - GPR_ASSERT(version != ENCODED_VERSION); - GPR_ASSERT(ENCODED_HEADER_SIZE < header_size); - buffer += (header_size - ENCODED_HEADER_SIZE); - } - tags->kvm_used = size - header_size; - tags->kvm_size = tags->kvm_used + CENSUS_MAX_TAG_KV_LEN; - tags->kvm = gpr_malloc(tags->kvm_size); - if (tag_header_size != TAG_HEADER_SIZE) { - // something new in the tag information. I don't understand it, so - // don't copy it over. - GPR_ASSERT(version != ENCODED_VERSION); - GPR_ASSERT(tag_header_size > TAG_HEADER_SIZE); - char *kvp = tags->kvm; - for (int i = 0; i < tags->ntags; i++) { - memcpy(kvp, buffer, TAG_HEADER_SIZE); - kvp += header_size; - struct raw_tag raw; - buffer = - decode_tag(&raw, (char *)buffer, tag_header_size - TAG_HEADER_SIZE); - memcpy(kvp, raw.key, (size_t)raw.key_len + raw.value_len); - kvp += raw.key_len + raw.value_len; - } - } else { - memcpy(tags->kvm, buffer, tags->kvm_used); - } -} - -census_tag_set *census_tag_set_decode(const char *buffer, size_t size, - const char *bin_buffer, size_t bin_size) { - census_tag_set *new_ts = gpr_malloc(sizeof(census_tag_set)); - memset(&new_ts->tags[LOCAL_TAGS], 0, sizeof(struct tag_set)); - if (buffer == NULL) { - memset(&new_ts->tags[PROPAGATED_TAGS], 0, sizeof(struct tag_set)); - } else { - tag_set_decode(&new_ts->tags[PROPAGATED_TAGS], buffer, size); - } - if (bin_buffer == NULL) { - memset(&new_ts->tags[PROPAGATED_BINARY_TAGS], 0, sizeof(struct tag_set)); - } else { - tag_set_decode(&new_ts->tags[PROPAGATED_BINARY_TAGS], bin_buffer, bin_size); - } - memset(&new_ts->status, 0, sizeof(new_ts->status)); - new_ts->status.n_propagated_tags = new_ts->tags[PROPAGATED_TAGS].ntags; - new_ts->status.n_propagated_binary_tags = - new_ts->tags[PROPAGATED_BINARY_TAGS].ntags; - // TODO(aveitch): check that BINARY flag is correct for each type. - return new_ts; -} diff --git a/src/core/iomgr/iocp_windows.c b/src/core/iomgr/iocp_windows.c index 96b6f81024..759340e00e 100644 --- a/src/core/iomgr/iocp_windows.c +++ b/src/core/iomgr/iocp_windows.c @@ -57,7 +57,7 @@ static HANDLE g_iocp; static DWORD deadline_to_millis_timeout(gpr_timespec deadline, gpr_timespec now) { gpr_timespec timeout; - static const int max_spin_polling_us = 10; + static const int64_t max_spin_polling_us = 10; if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) { return INFINITE; } diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index a8e2e22977..19ee6650f0 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -393,7 +393,7 @@ void grpc_pollset_shutdown(grpc_exec_ctx *exec_ctx, grpc_pollset *pollset, int grpc_poll_deadline_to_millis_timeout(gpr_timespec deadline, gpr_timespec now) { gpr_timespec timeout; - static const int max_spin_polling_us = 10; + static const int64_t max_spin_polling_us = 10; if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) == 0) { return -1; } diff --git a/src/core/iomgr/tcp_server.h b/src/core/iomgr/tcp_server.h index 8f3184ff1e..a39dd3bafc 100644 --- a/src/core/iomgr/tcp_server.h +++ b/src/core/iomgr/tcp_server.h @@ -40,15 +40,14 @@ /* Forward decl of grpc_tcp_server */ typedef struct grpc_tcp_server grpc_tcp_server; -typedef struct grpc_tcp_server_acceptor grpc_tcp_server_acceptor; -struct grpc_tcp_server_acceptor { +typedef struct grpc_tcp_server_acceptor { /* grpc_tcp_server_cb functions share a ref on from_server that is valid until the function returns. */ grpc_tcp_server *from_server; /* Indices that may be passed to grpc_tcp_server_port_fd(). */ unsigned port_index; unsigned fd_index; -}; +} grpc_tcp_server_acceptor; /* Called for newly connected TCP connections. */ typedef void (*grpc_tcp_server_cb)(grpc_exec_ctx *exec_ctx, void *arg, @@ -57,7 +56,7 @@ typedef void (*grpc_tcp_server_cb)(grpc_exec_ctx *exec_ctx, void *arg, /* Create a server, initially not bound to any ports. The caller owns one ref. If shutdown_complete is not NULL, it will be used by - grpc_tcp_server_unref(). */ + grpc_tcp_server_unref() when the ref count reaches zero. */ grpc_tcp_server *grpc_tcp_server_create(grpc_closure *shutdown_complete); /* Start listening to bound ports */ @@ -84,7 +83,7 @@ unsigned grpc_tcp_server_port_fd_count(grpc_tcp_server *s, unsigned port_index); /* Returns the file descriptor of the Mth (fd_index) listening socket of the Nth (port_index) call to add_port() on this server, or -1 if the indices are out of bounds. The file descriptor remains owned by the server, and will be - cleaned up when grpc_tcp_server_destroy is called. */ + cleaned up when the ref count reaches zero. */ int grpc_tcp_server_port_fd(grpc_tcp_server *s, unsigned port_index, unsigned fd_index); @@ -97,7 +96,7 @@ grpc_tcp_server *grpc_tcp_server_ref(grpc_tcp_server *s); void grpc_tcp_server_shutdown_starting_add(grpc_tcp_server *s, grpc_closure *shutdown_starting); -/* If the recount drops to zero, delete s, and call (exec_ctx==NULL) or enqueue +/* If the refcount drops to zero, delete s, and call (exec_ctx==NULL) or enqueue a call (exec_ctx!=NULL) to shutdown_complete. */ void grpc_tcp_server_unref(grpc_exec_ctx *exec_ctx, grpc_tcp_server *s); diff --git a/src/core/security/google_default_credentials.c b/src/core/security/google_default_credentials.c index ae71107bef..f3ac14568a 100644 --- a/src/core/security/google_default_credentials.c +++ b/src/core/security/google_default_credentials.c @@ -157,7 +157,7 @@ static grpc_call_credentials *create_default_creds_from_path(char *creds_path) { if (grpc_auth_json_key_is_valid(&key)) { result = grpc_service_account_jwt_access_credentials_create_from_auth_json_key( - key, grpc_max_auth_token_lifetime); + key, grpc_max_auth_token_lifetime()); goto end; } diff --git a/src/core/security/json_token.c b/src/core/security/json_token.c index 4d4bc4baad..762f02989a 100644 --- a/src/core/security/json_token.c +++ b/src/core/security/json_token.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -49,7 +49,13 @@ /* --- Constants. --- */ /* 1 hour max. */ -const gpr_timespec grpc_max_auth_token_lifetime = {3600, 0, GPR_TIMESPAN}; +gpr_timespec grpc_max_auth_token_lifetime() { + gpr_timespec out; + out.tv_sec = 3600; + out.tv_nsec = 0; + out.clock_type = GPR_TIMESPAN; + return out; +} #define GRPC_JWT_RSA_SHA256_ALGORITHM "RS256" #define GRPC_JWT_TYPE "JWT" @@ -211,9 +217,9 @@ static char *encoded_jwt_claim(const grpc_auth_json_key *json_key, gpr_timespec expiration = gpr_time_add(now, token_lifetime); char now_str[GPR_LTOA_MIN_BUFSIZE]; char expiration_str[GPR_LTOA_MIN_BUFSIZE]; - if (gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime) > 0) { + if (gpr_time_cmp(token_lifetime, grpc_max_auth_token_lifetime()) > 0) { gpr_log(GPR_INFO, "Cropping token lifetime to maximum allowed value."); - expiration = gpr_time_add(now, grpc_max_auth_token_lifetime); + expiration = gpr_time_add(now, grpc_max_auth_token_lifetime()); } int64_ttoa(now.tv_sec, now_str); int64_ttoa(expiration.tv_sec, expiration_str); diff --git a/src/core/security/security_connector.c b/src/core/security/security_connector.c index 61336a1057..bdccbabfea 100644 --- a/src/core/security/security_connector.c +++ b/src/core/security/security_connector.c @@ -61,6 +61,14 @@ static const char *installed_roots_path = INSTALL_PREFIX "/share/grpc/roots.pem"; #endif +/* -- Overridden default roots. -- */ + +static grpc_ssl_roots_override_callback ssl_roots_override_cb = NULL; + +void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb) { + ssl_roots_override_cb = cb; +} + /* -- Cipher suites. -- */ /* Defines the cipher suites that we accept by default. All these cipher suites @@ -595,23 +603,44 @@ static grpc_security_connector_vtable ssl_channel_vtable = { static grpc_security_connector_vtable ssl_server_vtable = { ssl_server_destroy, ssl_server_do_handshake, ssl_server_check_peer}; -static gpr_slice default_pem_root_certs; +static gpr_slice compute_default_pem_root_certs_once(void) { + gpr_slice result = gpr_empty_slice(); -static void init_default_pem_root_certs(void) { /* First try to load the roots from the environment. */ char *default_root_certs_path = gpr_getenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR); - if (default_root_certs_path == NULL) { - default_pem_root_certs = gpr_empty_slice(); - } else { - default_pem_root_certs = gpr_load_file(default_root_certs_path, 0, NULL); + if (default_root_certs_path != NULL) { + result = gpr_load_file(default_root_certs_path, 0, NULL); gpr_free(default_root_certs_path); } + /* Try overridden roots if needed. */ + grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL; + if (GPR_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != NULL) { + char *pem_root_certs = NULL; + ovrd_res = ssl_roots_override_cb(&pem_root_certs); + if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) { + GPR_ASSERT(pem_root_certs != NULL); + result = gpr_slice_new(pem_root_certs, strlen(pem_root_certs), gpr_free); + } + } + /* Fall back to installed certs if needed. */ - if (GPR_SLICE_IS_EMPTY(default_pem_root_certs)) { - default_pem_root_certs = gpr_load_file(installed_roots_path, 0, NULL); + if (GPR_SLICE_IS_EMPTY(result) && + ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) { + result = gpr_load_file(installed_roots_path, 0, NULL); } + return result; +} + +static gpr_slice default_pem_root_certs; + +static void init_default_pem_root_certs(void) { + default_pem_root_certs = compute_default_pem_root_certs_once(); +} + +gpr_slice grpc_get_default_ssl_roots_for_testing(void) { + return compute_default_pem_root_certs_once(); } size_t grpc_get_default_ssl_roots(const unsigned char **pem_root_certs) { diff --git a/src/core/security/security_connector.h b/src/core/security/security_connector.h index 2b734109b3..39df7821f0 100644 --- a/src/core/security/security_connector.h +++ b/src/core/security/security_connector.h @@ -209,6 +209,9 @@ grpc_security_status grpc_ssl_channel_security_connector_create( /* Gets the default ssl roots. */ size_t grpc_get_default_ssl_roots(const unsigned char **pem_root_certs); +/* Exposed for TESTING ONLY!. */ +gpr_slice grpc_get_default_ssl_roots_for_testing(void); + /* Config for ssl servers. */ typedef struct { unsigned char **pem_private_keys; diff --git a/src/core/security/server_secure_chttp2.c b/src/core/security/server_secure_chttp2.c index ee3443c828..84a883390c 100644 --- a/src/core/security/server_secure_chttp2.c +++ b/src/core/security/server_secure_chttp2.c @@ -208,6 +208,14 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr, goto error; } + state->server = server; + state->tcp = tcp; + state->sc = sc; + state->creds = grpc_server_credentials_ref(creds); + state->is_shutdown = 0; + gpr_mu_init(&state->mu); + gpr_ref_init(&state->refcount, 1); + for (i = 0; i < resolved->naddrs; i++) { port_temp = grpc_tcp_server_add_port( tcp, (struct sockaddr *)&resolved->addrs[i].addr, @@ -233,15 +241,6 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr, } grpc_resolved_addresses_destroy(resolved); - state->server = server; - state->tcp = tcp; - state->sc = sc; - state->creds = grpc_server_credentials_ref(creds); - - state->is_shutdown = 0; - gpr_mu_init(&state->mu); - gpr_ref_init(&state->refcount, 1); - /* Register with the server only upon success */ grpc_server_add_listener(&exec_ctx, server, state, start, destroy); @@ -250,17 +249,18 @@ int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr, /* Error path: cleanup and return */ error: - if (sc) { - GRPC_SECURITY_CONNECTOR_UNREF(sc, "server"); - } if (resolved) { grpc_resolved_addresses_destroy(resolved); } if (tcp) { grpc_tcp_server_unref(&exec_ctx, tcp); - } - if (state) { - gpr_free(state); + } else { + if (sc) { + GRPC_SECURITY_CONNECTOR_UNREF(sc, "server"); + } + if (state) { + gpr_free(state); + } } grpc_exec_ctx_finish(&exec_ctx); return 0; diff --git a/src/core/statistics/census_init.c b/src/core/statistics/census_init.c index e6306f5e6f..b6a962f228 100644 --- a/src/core/statistics/census_init.c +++ b/src/core/statistics/census_init.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without diff --git a/src/core/support/env_linux.c b/src/core/support/env_linux.c index 2e03365e33..442cd8298e 100644 --- a/src/core/support/env_linux.c +++ b/src/core/support/env_linux.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -42,15 +42,25 @@ #include "src/core/support/env.h" +#include <dlfcn.h> #include <stdlib.h> #include <grpc/support/log.h> #include <grpc/support/string_util.h> +#include <grpc/support/useful.h> #include "src/core/support/string.h" char *gpr_getenv(const char *name) { - char *result = secure_getenv(name); + typedef char *(*getenv_type)(const char *); + static getenv_type getenv_func = NULL; + /* Check to see which getenv variant is supported (go from most + * to least secure) */ + const char *names[] = {"secure_getenv", "__secure_getenv", "getenv"}; + for (size_t i = 0; getenv_func == NULL && i < GPR_ARRAY_SIZE(names); i++) { + getenv_func = (getenv_type)dlsym(RTLD_DEFAULT, names[i]); + } + char *result = getenv_func(name); return result == NULL ? result : gpr_strdup(result); } diff --git a/src/core/support/stack_lockfree.c b/src/core/support/stack_lockfree.c index cd0afddf9d..9daecd2e18 100644 --- a/src/core/support/stack_lockfree.c +++ b/src/core/support/stack_lockfree.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -99,6 +99,11 @@ gpr_stack_lockfree *gpr_stack_lockfree_create(size_t entries) { /* Point the head at reserved dummy entry */ stack->head.contents.index = INVALID_ENTRY_INDEX; +/* Fill in the pad and aba_ctr to avoid confusing memcheck tools */ +#ifdef GPR_ARCH_64 + stack->head.contents.pad = 0; +#endif + stack->head.contents.aba_ctr = 0; return stack; } @@ -115,6 +120,11 @@ int gpr_stack_lockfree_push(gpr_stack_lockfree *stack, int entry) { /* First fill in the entry's index and aba ctr for new head */ newhead.contents.index = (uint16_t)entry; +#ifdef GPR_ARCH_64 + /* Fill in the pad to avoid confusing memcheck tools */ + newhead.contents.pad = 0; +#endif + /* Also post-increment the aba_ctr */ curent.atm = gpr_atm_no_barrier_load(&stack->entries[entry].atm); newhead.contents.aba_ctr = ++curent.contents.aba_ctr; diff --git a/src/core/support/subprocess_windows.c b/src/core/support/subprocess_windows.c new file mode 100644 index 0000000000..2b25ef063a --- /dev/null +++ b/src/core/support/subprocess_windows.c @@ -0,0 +1,141 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <grpc/support/port_platform.h> + +#ifdef GPR_WINDOWS_SUBPROCESS + +#include <windows.h> +#include <string.h> +#include <tchar.h> + +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/subprocess.h> +#include "src/core/support/string.h" +#include "src/core/support/string_win32.h" + +struct gpr_subprocess { + PROCESS_INFORMATION pi; + int joined; + int interrupted; +}; + +const char *gpr_subprocess_binary_extension() { return ".exe"; } + +gpr_subprocess *gpr_subprocess_create(int argc, const char **argv) { + gpr_subprocess *r; + + STARTUPINFO si; + PROCESS_INFORMATION pi; + + char *args = gpr_strjoin_sep(argv, (size_t)argc, " ", NULL); + TCHAR *args_tchar; + + args_tchar = gpr_char_to_tchar(args); + gpr_free(args); + + memset(&si, 0, sizeof(si)); + si.cb = sizeof(si); + memset(&pi, 0, sizeof(pi)); + + if (!CreateProcess(NULL, args_tchar, NULL, NULL, FALSE, + CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)) { + gpr_free(args_tchar); + return NULL; + } + gpr_free(args_tchar); + + r = gpr_malloc(sizeof(gpr_subprocess)); + memset(r, 0, sizeof(*r)); + r->pi = pi; + return r; +} + +void gpr_subprocess_destroy(gpr_subprocess *p) { + if (p) { + if (!p->joined) { + gpr_subprocess_interrupt(p); + gpr_subprocess_join(p); + } + if (p->pi.hProcess) { + CloseHandle(p->pi.hProcess); + } + if (p->pi.hThread) { + CloseHandle(p->pi.hThread); + } + gpr_free(p); + } +} + +int gpr_subprocess_join(gpr_subprocess *p) { + DWORD dwExitCode; + if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { + if (dwExitCode == STILL_ACTIVE) { + if (WaitForSingleObject(p->pi.hProcess, INFINITE) == WAIT_OBJECT_0) { + p->joined = 1; + goto getExitCode; + } + return -1; // failed to join + } else { + goto getExitCode; + } + } else { + return -1; // failed to get exit code + } + +getExitCode: + if (p->interrupted) { + return 0; + } + if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { + return (int)dwExitCode; + } else { + return -1; // failed to get exit code + } +} + +void gpr_subprocess_interrupt(gpr_subprocess *p) { + DWORD dwExitCode; + if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { + if (dwExitCode == STILL_ACTIVE) { + gpr_log(GPR_INFO, "sending ctrl-break"); + GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT, p->pi.dwProcessId); + p->joined = 1; + p->interrupted = 1; + } + } + return; +} + +#endif /* GPR_WINDOWS_SUBPROCESS */ diff --git a/src/core/support/sync_win32.c b/src/core/support/sync_win32.c index 84d412a75f..41998ebcb6 100644 --- a/src/core/support/sync_win32.c +++ b/src/core/support/sync_win32.c @@ -87,6 +87,7 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) { 0) { SleepConditionVariableCS(cv, &mu->cs, INFINITE); } else { + abs_deadline = gpr_convert_clock_type(abs_deadline, GPR_CLOCK_REALTIME); gpr_timespec now = gpr_now(abs_deadline.clock_type); int64_t now_ms = (int64_t)now.tv_sec * 1000 + now.tv_nsec / 1000000; int64_t deadline_ms = diff --git a/src/core/support/time.c b/src/core/support/time.c index ac8c3bcde5..423d12ffc0 100644 --- a/src/core/support/time.c +++ b/src/core/support/time.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -83,12 +83,12 @@ gpr_timespec gpr_inf_past(gpr_clock_type type) { /* TODO(ctiller): consider merging _nanos, _micros, _millis into a single function for maintainability. Similarly for _seconds, _minutes, and _hours */ -gpr_timespec gpr_time_from_nanos(long ns, gpr_clock_type type) { +gpr_timespec gpr_time_from_nanos(int64_t ns, gpr_clock_type type) { gpr_timespec result; result.clock_type = type; - if (ns == LONG_MAX) { + if (ns == INT64_MAX) { result = gpr_inf_future(type); - } else if (ns == LONG_MIN) { + } else if (ns == INT64_MIN) { result = gpr_inf_past(type); } else if (ns >= 0) { result.tv_sec = ns / GPR_NS_PER_SEC; @@ -101,12 +101,12 @@ gpr_timespec gpr_time_from_nanos(long ns, gpr_clock_type type) { return result; } -gpr_timespec gpr_time_from_micros(long us, gpr_clock_type type) { +gpr_timespec gpr_time_from_micros(int64_t us, gpr_clock_type type) { gpr_timespec result; result.clock_type = type; - if (us == LONG_MAX) { + if (us == INT64_MAX) { result = gpr_inf_future(type); - } else if (us == LONG_MIN) { + } else if (us == INT64_MIN) { result = gpr_inf_past(type); } else if (us >= 0) { result.tv_sec = us / 1000000; @@ -119,12 +119,12 @@ gpr_timespec gpr_time_from_micros(long us, gpr_clock_type type) { return result; } -gpr_timespec gpr_time_from_millis(long ms, gpr_clock_type type) { +gpr_timespec gpr_time_from_millis(int64_t ms, gpr_clock_type type) { gpr_timespec result; result.clock_type = type; - if (ms == LONG_MAX) { + if (ms == INT64_MAX) { result = gpr_inf_future(type); - } else if (ms == LONG_MIN) { + } else if (ms == INT64_MIN) { result = gpr_inf_past(type); } else if (ms >= 0) { result.tv_sec = ms / 1000; @@ -137,12 +137,12 @@ gpr_timespec gpr_time_from_millis(long ms, gpr_clock_type type) { return result; } -gpr_timespec gpr_time_from_seconds(long s, gpr_clock_type type) { +gpr_timespec gpr_time_from_seconds(int64_t s, gpr_clock_type type) { gpr_timespec result; result.clock_type = type; - if (s == LONG_MAX) { + if (s == INT64_MAX) { result = gpr_inf_future(type); - } else if (s == LONG_MIN) { + } else if (s == INT64_MIN) { result = gpr_inf_past(type); } else { result.tv_sec = s; @@ -151,12 +151,12 @@ gpr_timespec gpr_time_from_seconds(long s, gpr_clock_type type) { return result; } -gpr_timespec gpr_time_from_minutes(long m, gpr_clock_type type) { +gpr_timespec gpr_time_from_minutes(int64_t m, gpr_clock_type type) { gpr_timespec result; result.clock_type = type; - if (m >= LONG_MAX / 60) { + if (m >= INT64_MAX / 60) { result = gpr_inf_future(type); - } else if (m <= LONG_MIN / 60) { + } else if (m <= INT64_MIN / 60) { result = gpr_inf_past(type); } else { result.tv_sec = m * 60; @@ -165,12 +165,12 @@ gpr_timespec gpr_time_from_minutes(long m, gpr_clock_type type) { return result; } -gpr_timespec gpr_time_from_hours(long h, gpr_clock_type type) { +gpr_timespec gpr_time_from_hours(int64_t h, gpr_clock_type type) { gpr_timespec result; result.clock_type = type; - if (h >= LONG_MAX / 3600) { + if (h >= INT64_MAX / 3600) { result = gpr_inf_future(type); - } else if (h <= LONG_MIN / 3600) { + } else if (h <= INT64_MIN / 3600) { result = gpr_inf_past(type); } else { result.tv_sec = h * 3600; diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c index 06bb78c913..1f92d7f090 100644 --- a/src/core/support/time_posix.c +++ b/src/core/support/time_posix.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,9 @@ #include <stdlib.h> #include <time.h> #include <unistd.h> +#ifdef __linux__ +#include <sys/syscall.h> +#endif #include <grpc/support/log.h> #include <grpc/support/time.h> #include "src/core/support/block_annotate.h" @@ -70,7 +73,8 @@ static gpr_timespec gpr_from_timespec(struct timespec ts, } /** maps gpr_clock_type --> clockid_t for clock_gettime */ -static clockid_t clockid_for_gpr_clock[] = {CLOCK_MONOTONIC, CLOCK_REALTIME}; +static const clockid_t clockid_for_gpr_clock[] = {CLOCK_MONOTONIC, + CLOCK_REALTIME}; void gpr_time_init(void) { gpr_precise_clock_init(); } @@ -82,7 +86,12 @@ gpr_timespec gpr_now(gpr_clock_type clock_type) { gpr_precise_clock_now(&ret); return ret; } else { +#if defined(__linux__) && !defined(GPR_NO_DIRECT_SYSCALLS) + /* avoid ABI problems by invoking syscalls directly */ + syscall(SYS_clock_gettime, clockid_for_gpr_clock[clock_type], &now); +#else clock_gettime(clockid_for_gpr_clock[clock_type], &now); +#endif return gpr_from_timespec(now, clock_type); } } diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannel.h b/src/core/support/wrap_memcpy.c index b82b9fe35a..15c289f7b8 100644 --- a/src/objective-c/GRPCClient/private/GRPCSecureChannel.h +++ b/src/core/support/wrap_memcpy.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,25 +31,23 @@ * */ -#include <grpc/grpc.h> +#include <string.h> -#import "GRPCChannel.h" - -struct grpc_channel_credentials; - -@interface GRPCSecureChannel : GRPCChannel -- (instancetype)initWithHost:(NSString *)host; - -/** - * Only in tests shouldn't pathToCertificates or hostNameOverride be nil. Passing nil for - * pathToCertificates results in using the default root certificates distributed with the library. +/* Provide a wrapped memcpy for targets that need to be backwards + * compatible with older libc's. + * + * Enable by setting LDFLAGS=-Wl,-wrap,memcpy when linking. */ -- (instancetype)initWithHost:(NSString *)host - pathToCertificates:(NSString *)path - hostNameOverride:(NSString *)hostNameOverride; -/** The passed arguments aren't required to be valid beyond the invocation of this initializer. */ -- (instancetype)initWithHost:(NSString *)host - credentials:(struct grpc_channel_credentials *)credentials - args:(grpc_channel_args *)args NS_DESIGNATED_INITIALIZER; -@end +#ifdef __linux__ +#ifdef __x86_64__ +__asm__(".symver memcpy,memcpy@GLIBC_2.2.5"); +void *__wrap_memcpy(void *destination, const void *source, size_t num) { + return memcpy(destination, source, num); +} +#else /* !__x86_64__ */ +void *__wrap_memcpy(void *destination, const void *source, size_t num) { + return memmove(destination, source, num); +} +#endif +#endif diff --git a/src/core/surface/alarm.c b/src/core/surface/alarm.c index 7c47dd56f8..d753023ca9 100644 --- a/src/core/surface/alarm.c +++ b/src/core/surface/alarm.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -48,7 +48,7 @@ struct grpc_alarm { static void do_nothing_end_completion(grpc_exec_ctx *exec_ctx, void *arg, grpc_cq_completion *c) {} -static void alarm_cb(grpc_exec_ctx *exec_ctx, void *arg, int success) { +static void alarm_cb(grpc_exec_ctx *exec_ctx, void *arg, bool success) { grpc_alarm *alarm = arg; grpc_cq_end_op(exec_ctx, alarm->cq, alarm->tag, success, do_nothing_end_completion, NULL, &alarm->completion); @@ -65,7 +65,7 @@ grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq, gpr_timespec deadline, grpc_timer_init(&exec_ctx, &alarm->alarm, deadline, alarm_cb, alarm, gpr_now(GPR_CLOCK_MONOTONIC)); - grpc_cq_begin_op(cq); + grpc_cq_begin_op(cq, tag); grpc_exec_ctx_finish(&exec_ctx); return alarm; } diff --git a/src/core/surface/version.c b/src/core/surface/version.c index 262a13f184..7723f39401 100644 --- a/src/core/surface/version.c +++ b/src/core/surface/version.c @@ -36,4 +36,4 @@ #include <grpc/grpc.h> -const char *grpc_version_string(void) { return "0.13.0.0"; } +const char *grpc_version_string(void) { return "0.14.0-dev"; } diff --git a/src/core/transport/chttp2/hpack_encoder.c b/src/core/transport/chttp2/hpack_encoder.c index 89a80d896c..f30f574d06 100644 --- a/src/core/transport/chttp2/hpack_encoder.c +++ b/src/core/transport/chttp2/hpack_encoder.c @@ -283,7 +283,7 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c, len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1); GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40, add_tiny_header_data(st, len_pfx), len_pfx); - GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, 0x00, + GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, huffman_prefix, add_tiny_header_data(st, len_val_len), len_val_len); add_header_data(st, gpr_slice_ref(value_slice)); } @@ -300,7 +300,7 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c, len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1); GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00, add_tiny_header_data(st, len_pfx), len_pfx); - GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, 0x00, + GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, huffman_prefix, add_tiny_header_data(st, len_val_len), len_val_len); add_header_data(st, gpr_slice_ref(value_slice)); } diff --git a/src/core/transport/chttp2/internal.h b/src/core/transport/chttp2/internal.h index 6823f8f551..c611496e7e 100644 --- a/src/core/transport/chttp2/internal.h +++ b/src/core/transport/chttp2/internal.h @@ -35,6 +35,7 @@ #define GRPC_INTERNAL_CORE_CHTTP2_INTERNAL_H #include <assert.h> +#include <stdbool.h> #include "src/core/iomgr/endpoint.h" #include "src/core/transport/chttp2/frame.h" @@ -67,6 +68,9 @@ typedef enum { GRPC_CHTTP2_LIST_CLOSED_WAITING_FOR_PARSING, GRPC_CHTTP2_LIST_CLOSED_WAITING_FOR_WRITING, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT, + /* streams waiting for the outgoing window in the writing path, they will be + * merged to the stalled list or writable list under transport lock. */ + GRPC_CHTTP2_LIST_WRITING_STALLED_BY_TRANSPORT, /** streams that are waiting to start because there are too many concurrent streams on the connection */ GRPC_CHTTP2_LIST_WAITING_FOR_CONCURRENCY, @@ -504,11 +508,11 @@ void grpc_chttp2_publish_reads(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport_global *global, grpc_chttp2_transport_parsing *parsing); -/** Get a writable stream - returns non-zero if there was a stream available */ void grpc_chttp2_list_add_writable_stream( grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global *stream_global); +/** Get a writable stream + returns non-zero if there was a stream available */ int grpc_chttp2_list_pop_writable_stream( grpc_chttp2_transport_global *transport_global, grpc_chttp2_transport_writing *transport_writing, @@ -560,9 +564,12 @@ int grpc_chttp2_list_pop_check_read_ops( grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global **stream_global); -void grpc_chttp2_list_add_stalled_by_transport( +void grpc_chttp2_list_add_writing_stalled_by_transport( grpc_chttp2_transport_writing *transport_writing, grpc_chttp2_stream_writing *stream_writing); +void grpc_chttp2_list_flush_writing_stalled_by_transport( + grpc_chttp2_transport_writing *transport_writing, bool is_window_available); + int grpc_chttp2_list_pop_stalled_by_transport( grpc_chttp2_transport_global *transport_global, grpc_chttp2_stream_global **stream_global); diff --git a/src/core/transport/chttp2/stream_lists.c b/src/core/transport/chttp2/stream_lists.c index 273a513e2f..2f31a47cb3 100644 --- a/src/core/transport/chttp2/stream_lists.c +++ b/src/core/transport/chttp2/stream_lists.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -313,12 +313,27 @@ int grpc_chttp2_list_pop_check_read_ops( return r; } -void grpc_chttp2_list_add_stalled_by_transport( +void grpc_chttp2_list_add_writing_stalled_by_transport( grpc_chttp2_transport_writing *transport_writing, grpc_chttp2_stream_writing *stream_writing) { stream_list_add(TRANSPORT_FROM_WRITING(transport_writing), STREAM_FROM_WRITING(stream_writing), - GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT); + GRPC_CHTTP2_LIST_WRITING_STALLED_BY_TRANSPORT); +} + +void grpc_chttp2_list_flush_writing_stalled_by_transport( + grpc_chttp2_transport_writing *transport_writing, + bool is_window_available) { + grpc_chttp2_stream *stream; + grpc_chttp2_transport *transport = TRANSPORT_FROM_WRITING(transport_writing); + while (stream_list_pop(transport, &stream, + GRPC_CHTTP2_LIST_WRITING_STALLED_BY_TRANSPORT)) { + if (is_window_available) { + grpc_chttp2_list_add_writable_stream(&transport->global, &stream->global); + } else { + stream_list_add(transport, stream, GRPC_CHTTP2_LIST_STALLED_BY_TRANSPORT); + } + } } int grpc_chttp2_list_pop_stalled_by_transport( diff --git a/src/core/transport/chttp2/writing.c b/src/core/transport/chttp2/writing.c index f78adb9e26..cafecf1046 100644 --- a/src/core/transport/chttp2/writing.c +++ b/src/core/transport/chttp2/writing.c @@ -75,6 +75,9 @@ int grpc_chttp2_unlocking_check_writes( GRPC_CHTTP2_FLOW_MOVE_TRANSPORT("write", transport_writing, outgoing_window, transport_global, outgoing_window); + bool is_window_available = transport_writing->outgoing_window > 0; + grpc_chttp2_list_flush_writing_stalled_by_transport(transport_writing, + is_window_available); /* for each grpc_chttp2_stream that's become writable, frame it's data (according to available window sizes) and add to the output buffer */ @@ -130,8 +133,8 @@ int grpc_chttp2_unlocking_check_writes( GRPC_CHTTP2_STREAM_REF(stream_global, "chttp2_writing"); } } else { - grpc_chttp2_list_add_stalled_by_transport(transport_writing, - stream_writing); + grpc_chttp2_list_add_writing_stalled_by_transport(transport_writing, + stream_writing); } } if (stream_global->send_trailing_metadata) { @@ -273,8 +276,8 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx, stream_writing->sent_message = 1; } } else if (transport_writing->outgoing_window == 0) { - grpc_chttp2_list_add_stalled_by_transport(transport_writing, - stream_writing); + grpc_chttp2_list_add_writing_stalled_by_transport(transport_writing, + stream_writing); grpc_chttp2_list_add_written_stream(transport_writing, stream_writing); } } @@ -312,8 +315,8 @@ static void finalize_outbuf(grpc_exec_ctx *exec_ctx, /* do nothing - already reffed */ } } else { - grpc_chttp2_list_add_stalled_by_transport(transport_writing, - stream_writing); + grpc_chttp2_list_add_writing_stalled_by_transport(transport_writing, + stream_writing); grpc_chttp2_list_add_written_stream(transport_writing, stream_writing); } } else { diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc index 3732c1f090..e205a1969b 100644 --- a/src/cpp/server/server_context.cc +++ b/src/cpp/server/server_context.cc @@ -33,14 +33,14 @@ #include <grpc++/server_context.h> -#include <grpc/compression.h> -#include <grpc/grpc.h> -#include <grpc/support/alloc.h> -#include <grpc/support/log.h> #include <grpc++/completion_queue.h> #include <grpc++/impl/call.h> #include <grpc++/impl/sync.h> #include <grpc++/support/time.h> +#include <grpc/compression.h> +#include <grpc/grpc.h> +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> #include "src/core/channel/compress_filter.h" #include "src/cpp/common/create_auth_context.h" @@ -173,6 +173,14 @@ void ServerContext::AddTrailingMetadata(const grpc::string& key, trailing_metadata_.insert(std::make_pair(key, value)); } +void ServerContext::TryCancel() const { + grpc_call_error err = grpc_call_cancel_with_status( + call_, GRPC_STATUS_CANCELLED, "Cancelled on the server side", NULL); + if (err != GRPC_CALL_OK) { + gpr_log(GPR_ERROR, "TryCancel failed with: %d", err); + } +} + bool ServerContext::IsCancelled() const { return completion_op_ && completion_op_->CheckCancelled(cq_); } diff --git a/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs b/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs index 78295cf6d4..ab12c120cb 100644 --- a/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs +++ b/src/csharp/Grpc.Core.Tests/GrpcEnvironmentTest.cs @@ -84,7 +84,7 @@ namespace Grpc.Core.Tests { var coreVersion = GrpcEnvironment.GetCoreVersionString(); var parts = coreVersion.Split('.'); - Assert.AreEqual(4, parts.Length); + Assert.AreEqual(3, parts.Length); } } } diff --git a/src/csharp/Grpc.Core/Grpc.Core.csproj b/src/csharp/Grpc.Core/Grpc.Core.csproj index 307c0e8783..9587503e4b 100644 --- a/src/csharp/Grpc.Core/Grpc.Core.csproj +++ b/src/csharp/Grpc.Core/Grpc.Core.csproj @@ -128,6 +128,7 @@ <Compile Include="Profiling\ProfilerScope.cs" /> <Compile Include="Profiling\IProfiler.cs" /> <Compile Include="Profiling\Profilers.cs" /> + <Compile Include="Internal\DefaultSslRootsOverride.cs" /> </ItemGroup> <ItemGroup> <None Include="Grpc.Core.nuspec" /> @@ -135,4 +136,12 @@ </ItemGroup> <Import Project="NativeDeps.targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <ItemGroup> + <Folder Include="Resources\" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="..\..\..\etc\roots.pem"> + <Link>Resources\roots.pem</Link> + </EmbeddedResource> + </ItemGroup> </Project>
\ No newline at end of file diff --git a/src/csharp/Grpc.Core/Grpc.Core.nuspec b/src/csharp/Grpc.Core/Grpc.Core.nuspec index 9a4c1a3c85..49bccb050e 100644 --- a/src/csharp/Grpc.Core/Grpc.Core.nuspec +++ b/src/csharp/Grpc.Core/Grpc.Core.nuspec @@ -20,7 +20,6 @@ </dependencies> </metadata> <files> - <file src="..\..\..\etc\roots.pem" target="tools" /> <file src="bin/ReleaseSigned/Grpc.Core.dll" target="lib/net45" /> <file src="bin/ReleaseSigned/Grpc.Core.pdb" target="lib/net45" /> <file src="bin/ReleaseSigned/Grpc.Core.xml" target="lib/net45" /> diff --git a/src/csharp/Grpc.Core/Internal/DefaultSslRootsOverride.cs b/src/csharp/Grpc.Core/Internal/DefaultSslRootsOverride.cs new file mode 100644 index 0000000000..eeaa7add81 --- /dev/null +++ b/src/csharp/Grpc.Core/Internal/DefaultSslRootsOverride.cs @@ -0,0 +1,72 @@ +#region Copyright notice and license + +// Copyright 2015-2016, Google Inc. +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +#endregion + +using System; +using System.Collections.Concurrent; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using System.Runtime.InteropServices; +using System.Threading; + +namespace Grpc.Core.Internal +{ + /// <summary> + /// Overrides the content of default SSL roots. + /// </summary> + internal static class DefaultSslRootsOverride + { + const string RootsPemResourceName = "Grpc.Core.Resources.roots.pem"; + static object staticLock = new object(); + + /// <summary> + /// Overrides C core's default roots with roots.pem loaded as embedded resource. + /// </summary> + public static void Override(NativeMethods native) + { + lock (staticLock) + { + var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(RootsPemResourceName); + if (stream == null) + { + throw new IOException(string.Format("Error loading the embedded resource \"{0}\"", RootsPemResourceName)); + } + using (var streamReader = new StreamReader(stream)) + { + var pemRootCerts = streamReader.ReadToEnd(); + native.grpcsharp_override_default_ssl_roots(pemRootCerts); + } + } + } + } +} diff --git a/src/csharp/Grpc.Core/Internal/NativeExtension.cs b/src/csharp/Grpc.Core/Internal/NativeExtension.cs index 137533b3ef..4c742ab6c3 100644 --- a/src/csharp/Grpc.Core/Internal/NativeExtension.cs +++ b/src/csharp/Grpc.Core/Internal/NativeExtension.cs @@ -60,6 +60,8 @@ namespace Grpc.Core.Internal // to make sure we don't lose any logs. NativeLogRedirector.Redirect(this.nativeMethods); + DefaultSslRootsOverride.Override(this.nativeMethods); + Logger.Debug("gRPC native library loaded successfully."); } @@ -104,7 +106,7 @@ namespace Grpc.Core.Internal private static string GetExecutingAssemblyDirectory() { - return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + return Path.GetDirectoryName(typeof(NativeExtension).GetTypeInfo().Assembly.Location); } private static string GetPlatformString() diff --git a/src/csharp/Grpc.Core/Internal/NativeMethods.cs b/src/csharp/Grpc.Core/Internal/NativeMethods.cs index af37d61c73..19a573581e 100644 --- a/src/csharp/Grpc.Core/Internal/NativeMethods.cs +++ b/src/csharp/Grpc.Core/Internal/NativeMethods.cs @@ -97,6 +97,7 @@ namespace Grpc.Core.Internal public readonly Delegates.grpcsharp_channel_args_set_integer_delegate grpcsharp_channel_args_set_integer; public readonly Delegates.grpcsharp_channel_args_destroy_delegate grpcsharp_channel_args_destroy; + public readonly Delegates.grpcsharp_override_default_ssl_roots grpcsharp_override_default_ssl_roots; public readonly Delegates.grpcsharp_ssl_credentials_create_delegate grpcsharp_ssl_credentials_create; public readonly Delegates.grpcsharp_composite_channel_credentials_create_delegate grpcsharp_composite_channel_credentials_create; public readonly Delegates.grpcsharp_channel_credentials_release_delegate grpcsharp_channel_credentials_release; @@ -203,6 +204,7 @@ namespace Grpc.Core.Internal this.grpcsharp_channel_args_set_integer = GetMethodDelegate<Delegates.grpcsharp_channel_args_set_integer_delegate>(library); this.grpcsharp_channel_args_destroy = GetMethodDelegate<Delegates.grpcsharp_channel_args_destroy_delegate>(library); + this.grpcsharp_override_default_ssl_roots = GetMethodDelegate<Delegates.grpcsharp_override_default_ssl_roots>(library); this.grpcsharp_ssl_credentials_create = GetMethodDelegate<Delegates.grpcsharp_ssl_credentials_create_delegate>(library); this.grpcsharp_composite_channel_credentials_create = GetMethodDelegate<Delegates.grpcsharp_composite_channel_credentials_create_delegate>(library); this.grpcsharp_channel_credentials_release = GetMethodDelegate<Delegates.grpcsharp_channel_credentials_release_delegate>(library); @@ -306,6 +308,7 @@ namespace Grpc.Core.Internal this.grpcsharp_channel_args_set_integer = PInvokeMethods.grpcsharp_channel_args_set_integer; this.grpcsharp_channel_args_destroy = PInvokeMethods.grpcsharp_channel_args_destroy; + this.grpcsharp_override_default_ssl_roots = PInvokeMethods.grpcsharp_override_default_ssl_roots; this.grpcsharp_ssl_credentials_create = PInvokeMethods.grpcsharp_ssl_credentials_create; this.grpcsharp_composite_channel_credentials_create = PInvokeMethods.grpcsharp_composite_channel_credentials_create; this.grpcsharp_channel_credentials_release = PInvokeMethods.grpcsharp_channel_credentials_release; @@ -449,6 +452,7 @@ namespace Grpc.Core.Internal public delegate void grpcsharp_channel_args_set_integer_delegate(ChannelArgsSafeHandle args, UIntPtr index, string key, int value); public delegate void grpcsharp_channel_args_destroy_delegate(IntPtr args); + public delegate void grpcsharp_override_default_ssl_roots(string pemRootCerts); public delegate ChannelCredentialsSafeHandle grpcsharp_ssl_credentials_create_delegate(string pemRootCerts, string keyCertPairCertChain, string keyCertPairPrivateKey); public delegate ChannelCredentialsSafeHandle grpcsharp_composite_channel_credentials_create_delegate(ChannelCredentialsSafeHandle channelCreds, CallCredentialsSafeHandle callCreds); public delegate void grpcsharp_channel_credentials_release_delegate(IntPtr credentials); @@ -658,6 +662,9 @@ namespace Grpc.Core.Internal // ChannelCredentialsSafeHandle [DllImport("grpc_csharp_ext.dll", CharSet = CharSet.Ansi)] + public static extern void grpcsharp_override_default_ssl_roots(string pemRootCerts); + + [DllImport("grpc_csharp_ext.dll", CharSet = CharSet.Ansi)] public static extern ChannelCredentialsSafeHandle grpcsharp_ssl_credentials_create(string pemRootCerts, string keyCertPairCertChain, string keyCertPairPrivateKey); [DllImport("grpc_csharp_ext.dll")] diff --git a/src/csharp/Grpc.Core/Internal/PlatformApis.cs b/src/csharp/Grpc.Core/Internal/PlatformApis.cs index d71e7eccdd..f0c5b0f63f 100644 --- a/src/csharp/Grpc.Core/Internal/PlatformApis.cs +++ b/src/csharp/Grpc.Core/Internal/PlatformApis.cs @@ -49,6 +49,7 @@ namespace Grpc.Core.Internal static readonly bool isLinux; static readonly bool isMacOSX; static readonly bool isWindows; + static readonly bool isMono; static PlatformApis() { @@ -58,6 +59,7 @@ namespace Grpc.Core.Internal isMacOSX = (platform == PlatformID.Unix && GetUname() == "Darwin"); isLinux = (platform == PlatformID.Unix && !isMacOSX); isWindows = (platform == PlatformID.Win32NT || platform == PlatformID.Win32S || platform == PlatformID.Win32Windows); + isMono = Type.GetType("Mono.Runtime") != null; } public static bool IsLinux @@ -75,6 +77,11 @@ namespace Grpc.Core.Internal get { return isWindows; } } + public static bool IsMono + { + get { return isMono; } + } + public static bool Is64Bit { get { return IntPtr.Size == 8; } diff --git a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs index e614cab6ab..95a8797e3e 100644 --- a/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs +++ b/src/csharp/Grpc.Core/Internal/UnmanagedLibrary.cs @@ -91,6 +91,10 @@ namespace Grpc.Core.Internal { if (PlatformApis.IsLinux) { + if (PlatformApis.IsMono) + { + return Mono.dlsym(this.handle, symbolName); + } return Linux.dlsym(this.handle, symbolName); } if (PlatformApis.IsMacOSX) @@ -122,6 +126,10 @@ namespace Grpc.Core.Internal } if (PlatformApis.IsLinux) { + if (PlatformApis.IsMono) + { + return Mono.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY); + } return Linux.dlopen(libraryPath, RTLD_GLOBAL + RTLD_LAZY); } if (PlatformApis.IsMacOSX) @@ -154,5 +162,21 @@ namespace Grpc.Core.Internal [DllImport("libSystem.dylib")] internal static extern IntPtr dlsym(IntPtr handle, string symbol); } + + /// <summary> + /// On Linux systems, using using dlopen and dlsym results in + /// DllNotFoundException("libdl.so not found") if libc6-dev + /// is not installed. As a workaround, we load symbols for + /// dlopen and dlsym from the current process as on Linux + /// Mono sure is linked against these symbols. + /// </summary> + private static class Mono + { + [DllImport("__Internal")] + internal static extern IntPtr dlopen(string filename, int flags); + + [DllImport("__Internal")] + internal static extern IntPtr dlsym(IntPtr handle, string symbol); + } } } diff --git a/src/csharp/Grpc.Core/Version.cs b/src/csharp/Grpc.Core/Version.cs index d02b301cac..8a26bd8362 100644 --- a/src/csharp/Grpc.Core/Version.cs +++ b/src/csharp/Grpc.Core/Version.cs @@ -34,4 +34,4 @@ using System.Reflection; // The current version of gRPC C#. -[assembly: AssemblyVersion(Grpc.Core.VersionInfo.CurrentVersion + ".0")] +[assembly: AssemblyVersion(Grpc.Core.VersionInfo.CurrentAssemblyVersion)] diff --git a/src/csharp/Grpc.Core/VersionInfo.cs b/src/csharp/Grpc.Core/VersionInfo.cs index 65813909de..4bd4f204dd 100644 --- a/src/csharp/Grpc.Core/VersionInfo.cs +++ b/src/csharp/Grpc.Core/VersionInfo.cs @@ -39,8 +39,13 @@ namespace Grpc.Core public static class VersionInfo { /// <summary> + /// Current version of gRPC C# assemblies + /// </summary> + public const string CurrentAssemblyVersion = "0.14.0.0"; + + /// <summary> /// Current version of gRPC C# /// </summary> - public const string CurrentVersion = "0.13.0"; + public const string CurrentVersion = "0.14.0-dev"; } } diff --git a/src/csharp/build_packages.bat b/src/csharp/build_packages.bat index 7a34bf3fd6..b7768f7821 100644 --- a/src/csharp/build_packages.bat +++ b/src/csharp/build_packages.bat @@ -1,7 +1,7 @@ @rem Builds gRPC NuGet packages @rem Current package versions -set VERSION=0.13.0 +set VERSION=0.14.0-dev set PROTOBUF_VERSION=3.0.0-beta2 @rem Packages that depend on prerelease packages (like Google.Protobuf) need to have prerelease suffix as well. @@ -49,6 +49,10 @@ endlocal @rem copy resulting nuget packages to artifacts directory xcopy /Y /I *.nupkg ..\..\artifacts\ +@rem create a zipfile with the artifacts as well +powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('..\..\artifacts', 'csharp_nugets.zip');" +xcopy /Y /I csharp_nugets.zip ..\..\artifacts\ + goto :EOF :error diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 26f1537398..1df74a0993 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -835,6 +835,30 @@ grpcsharp_server_request_call(grpc_server *server, grpc_completion_queue *cq, /* Security */ +static char *default_pem_root_certs = NULL; + +static grpc_ssl_roots_override_result override_ssl_roots_handler( + char **pem_root_certs) { + if (!default_pem_root_certs) { + *pem_root_certs = NULL; + return GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY; + } + *pem_root_certs = gpr_strdup(default_pem_root_certs); + return GRPC_SSL_ROOTS_OVERRIDE_OK; +} + +GPR_EXPORT void GPR_CALLTYPE grpcsharp_override_default_ssl_roots( + const char *pem_root_certs) { + /* + * This currently wastes ~300kB of memory by keeping a copy of roots + * in a static variable, but for desktop/server use, the overhead + * is negligible. In the future, we might want to change the behavior + * for mobile (e.g. Xamarin). + */ + default_pem_root_certs = gpr_strdup(pem_root_certs); + grpc_set_ssl_roots_override_callback(override_ssl_roots_handler); +} + GPR_EXPORT grpc_channel_credentials *GPR_CALLTYPE grpcsharp_ssl_credentials_create(const char *pem_root_certs, const char *key_cert_pair_cert_chain, @@ -917,6 +941,7 @@ GPR_EXPORT grpc_call_credentials *GPR_CALLTYPE grpcsharp_composite_call_credenti return grpc_composite_call_credentials_create(creds1, creds2, NULL); } + /* Metadata credentials plugin */ GPR_EXPORT void GPR_CALLTYPE grpcsharp_metadata_credentials_notify_from_plugin( diff --git a/src/node/ext/timeval.cc b/src/node/ext/timeval.cc index 64015e8412..c8f8534cfa 100644 --- a/src/node/ext/timeval.cc +++ b/src/node/ext/timeval.cc @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -32,6 +32,7 @@ */ #include <limits> +#include <cstdint> #include "grpc/grpc.h" #include "grpc/support/time.h" @@ -46,7 +47,7 @@ gpr_timespec MillisecondsToTimespec(double millis) { } else if (millis == -std::numeric_limits<double>::infinity()) { return gpr_inf_past(GPR_CLOCK_REALTIME); } else { - return gpr_time_from_micros(static_cast<long>(millis * 1000), + return gpr_time_from_micros(static_cast<int64_t>(millis * 1000), GPR_CLOCK_REALTIME); } } diff --git a/src/node/performance/worker_service_impl.js b/src/node/performance/worker_service_impl.js index 99ae32127e..1439249878 100644 --- a/src/node/performance/worker_service_impl.js +++ b/src/node/performance/worker_service_impl.js @@ -33,9 +33,15 @@ 'use strict'; +var os = require('os'); var BenchmarkClient = require('./benchmark_client'); var BenchmarkServer = require('./benchmark_server'); +exports.quitWorker = function quitWorker(call, callback) { + callback(null, {}); + process.exit(0); +} + exports.runClient = function runClient(call) { var client; call.on('data', function(request) { @@ -130,3 +136,7 @@ exports.runServer = function runServer(call) { }); }); }; + +exports.coreCount = function coreCount(call, callback) { + callback(null, {cores: os.cpus().length}); +}; diff --git a/src/objective-c/GRPCClient/private/GRPCUnsecuredChannel.m b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h index 15b6ffc75c..bd6b064f16 100644 --- a/src/objective-c/GRPCClient/private/GRPCUnsecuredChannel.m +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -30,21 +30,17 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +#import "GRPCCall.h" -#import "GRPCUnsecuredChannel.h" - -#include <grpc/grpc.h> - -@implementation GRPCUnsecuredChannel +/** + * Methods to configure GRPC channel options. + */ +@interface GRPCCall (ChannelArg) -- (instancetype)initWithHost:(NSString *)host { - return (self = [super initWithChannel:grpc_insecure_channel_create(host.UTF8String, NULL, NULL)]); -} +/** + * Use the provided @c userAgentPrefix at the beginning of the HTTP User Agent string for all calls + * to the specified @c host. + */ ++ (void)setUserAgentPrefix:(NSString *)userAgentPrefix forHost:(NSString *)host; -// TODO(jcanizales): GRPCSecureChannel and GRPCUnsecuredChannel are just convenience initializers -// for GRPCChannel. Move them into GRPCChannel, which will make the following unnecessary. -- (instancetype)initWithChannel:(grpc_channel *)unmanagedChannel { - [NSException raise:NSInternalInconsistencyException format:@"use the other initializer"]; - return [self initWithHost:nil]; // silence warnings -} @end diff --git a/src/core/census/context.h b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m index 700bcf86cf..5f9932d86d 100644 --- a/src/core/census/context.h +++ b/src/objective-c/GRPCClient/GRPCCall+ChannelArg.m @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,17 +31,19 @@ * */ -#ifndef GRPC_INTERNAL_CORE_CENSUS_CONTEXT_H -#define GRPC_INTERNAL_CORE_CENSUS_CONTEXT_H +#import "GRPCCall+ChannelArg.h" -#include <grpc/census.h> +#import "private/GRPCHost.h" -#define GRPC_CENSUS_MAX_ON_THE_WIRE_TAG_BYTES 2048 +@implementation GRPCCall (ChannelArg) -/* census_context is the in-memory representation of information needed to - * maintain tracing, RPC statistics and resource usage information. */ -struct census_context { - census_tag_set *tags; /* Opaque data structure for census tags. */ -}; ++ (void)setUserAgentPrefix:(NSString *)userAgentPrefix forHost:(NSString *)host { + if (!host) { + [NSException raise:NSInvalidArgumentException + format:@"host and userAgentPrefix must be provided."]; + } + GRPCHost *hostConfig = [GRPCHost hostWithAddress:host]; + hostConfig.userAgentPrefix = userAgentPrefix; +} -#endif /* GRPC_INTERNAL_CORE_CENSUS_CONTEXT_H */ +@end diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.h b/src/objective-c/GRPCClient/private/GRPCChannel.h index e2d19d506a..8661ae6f97 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.h +++ b/src/objective-c/GRPCClient/private/GRPCChannel.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,18 +33,51 @@ #import <Foundation/Foundation.h> -struct grpc_channel; +#include <grpc/grpc.h> + +struct grpc_channel_credentials; + /** * Each separate instance of this class represents at least one TCP connection to the provided host. - * Create them using one of the subclasses |GRPCSecureChannel| and |GRPCUnsecuredChannel|. */ @interface GRPCChannel : NSObject -@property(nonatomic, readonly) struct grpc_channel *unmanagedChannel; + +@property(nonatomic, readonly, nonnull) struct grpc_channel *unmanagedChannel; + +- (nullable instancetype)init NS_UNAVAILABLE; /** - * This initializer takes ownership of the passed channel, and will destroy it when this object is - * deallocated. It's illegal to pass the same grpc_channel to two different GRPCChannel objects. + * Creates a secure channel to the specified @c host using default credentials and channel + * arguments. If certificates could not be found to create a secure channel, then @c nil is + * returned. */ -- (instancetype)initWithChannel:(struct grpc_channel *)unmanagedChannel NS_DESIGNATED_INITIALIZER; ++ (nullable GRPCChannel *)secureChannelWithHost:(nonnull NSString *)host; + +/** + * Creates a secure channel to the specified @c host using the specified @c pathToCertificates and + * @c channelArgs. Only in tests should @c pathToCertificates be nil or + * @c GRPC_SSL_TARGET_NAME_OVERRIDE_ARG channel arg be set. Passing nil for @c pathToCertificates + * results in using the default root certificates distributed with the library. If certificates + * could not be found in any case, then @c nil is returned. + */ ++ (nullable GRPCChannel *)secureChannelWithHost:(nonnull NSString *)host + pathToCertificates:(nullable NSString *)pathToCertificates + channelArgs:(nullable NSDictionary *)channelArgs; + + +/** + * Creates a secure channel to the specified @c host using the specified @c credentials and + * @c channelArgs. Only in tests should @c GRPC_SSL_TARGET_NAME_OVERRIDE_ARG channel arg be set. + */ ++ (nonnull GRPCChannel *)secureChannelWithHost:(nonnull NSString *)host + credentials:(nonnull struct grpc_channel_credentials *)credentials + channelArgs:(nullable NSDictionary *)channelArgs; + +/** + * Creates an insecure channel to the specified @c host using the specified @c channelArgs. + */ ++ (nonnull GRPCChannel *)insecureChannelWithHost:(nonnull NSString *)host + channelArgs:(nullable NSDictionary *)channelArgs; + @end diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m index 4366e63320..7e55a473d7 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -33,22 +33,114 @@ #import "GRPCChannel.h" -#include <grpc/grpc.h> +#include <grpc/grpc_security.h> +#include <grpc/support/alloc.h> +#include <grpc/support/log.h> +#include <grpc/support/string_util.h> -@implementation GRPCChannel +/** + * Returns @c grpc_channel_credentials from the specified @c path. If the file at the path could not + * be read then NULL is returned. If NULL is returned, @c errorPtr may not be NULL if there are + * details available describing what went wrong. + */ +static grpc_channel_credentials *CertificatesAtPath(NSString *path, NSError **errorPtr) { + // Files in PEM format can have non-ASCII characters in their comments (e.g. for the name of the + // issuer). Load them as UTF8 and produce an ASCII equivalent. + NSString *contentInUTF8 = [NSString stringWithContentsOfFile:path + encoding:NSUTF8StringEncoding + error:errorPtr]; + NSData *contentInASCII = [contentInUTF8 dataUsingEncoding:NSASCIIStringEncoding + allowLossyConversion:YES]; + if (!contentInASCII.bytes) { + // Passing NULL to grpc_ssl_credentials_create produces behavior we don't want, so return. + return NULL; + } + return grpc_ssl_credentials_create(contentInASCII.bytes, NULL, NULL); +} + +void freeChannelArgs(grpc_channel_args *channel_args) { + for (size_t i = 0; i < channel_args->num_args; ++i) { + grpc_arg *arg = &channel_args->args[i]; + gpr_free(arg->key); + if (arg->type == GRPC_ARG_STRING) { + gpr_free(arg->value.string); + } + } + gpr_free(channel_args); +} + +/** + * Allocates a @c grpc_channel_args and populates it with the options specified in the + * @c dictionary. Keys must be @c NSString. If the value responds to @c @selector(UTF8String) then + * it will be mapped to @c GRPC_ARG_STRING. If not, it will be mapped to @c GRPC_ARG_INTEGER if the + * value responds to @c @selector(intValue). Otherwise, an exception will be raised. The caller of + * this function is responsible for calling @c freeChannelArgs on a non-NULL returned value. + */ +grpc_channel_args * buildChannelArgs(NSDictionary *dictionary) { + if (!dictionary) { + return NULL; + } -- (instancetype)init { - return [self initWithChannel:NULL]; + NSArray *keys = [dictionary allKeys]; + NSUInteger argCount = [keys count]; + + grpc_channel_args *channelArgs = gpr_malloc(sizeof(grpc_channel_args)); + channelArgs->num_args = argCount; + channelArgs->args = gpr_malloc(argCount * sizeof(grpc_arg)); + + // TODO(kriswuollett) Check that keys adhere to GRPC core library requirements + + for (NSUInteger i = 0; i < argCount; ++i) { + grpc_arg *arg = &channelArgs->args[i]; + arg->key = gpr_strdup([keys[i] UTF8String]); + + id value = dictionary[keys[i]]; + if ([value respondsToSelector:@selector(UTF8String)]) { + arg->type = GRPC_ARG_STRING; + arg->value.string = gpr_strdup([value UTF8String]); + } else if ([value respondsToSelector:@selector(intValue)]) { + arg->type = GRPC_ARG_INTEGER; + arg->value.integer = [value intValue]; + } else { + [NSException raise:NSInvalidArgumentException + format:@"Invalid value type: %@", [value class]]; + } + } + + return channelArgs; +} + +@implementation GRPCChannel { + // Retain arguments to channel_create because they may not be used on the thread that invoked + // the channel_create function. + NSString *_host; + grpc_channel_args *_channelArgs; } -// Designated initializer -- (instancetype)initWithChannel:(grpc_channel *)unmanagedChannel { - if (!unmanagedChannel) { + +- (instancetype)initWithHost:(NSString *)host + secure:(BOOL)secure + credentials:(struct grpc_channel_credentials *)credentials + channelArgs:(NSDictionary *)channelArgs { + if (!host) { + [NSException raise:NSInvalidArgumentException format:@"host argument missing"]; + } + + if (secure && !credentials) { return nil; } - if ((self = [super init])) { - _unmanagedChannel = unmanagedChannel; + + if (self = [super init]) { + _channelArgs = buildChannelArgs(channelArgs); + _host = [host copy]; + if (secure) { + _unmanagedChannel = grpc_secure_channel_create(credentials, _host.UTF8String, _channelArgs, + NULL); + } else { + _unmanagedChannel = grpc_insecure_channel_create(_host.UTF8String, _channelArgs, NULL); + } } + return self; } @@ -56,5 +148,61 @@ // TODO(jcanizales): Be sure to add a test with a server that closes the connection prematurely, // as in the past that made this call to crash. grpc_channel_destroy(_unmanagedChannel); + freeChannelArgs(_channelArgs); } + ++ (GRPCChannel *)secureChannelWithHost:(NSString *)host { + return [[GRPCChannel alloc] initWithHost:host secure:YES credentials:NULL channelArgs:NULL]; +} + ++ (GRPCChannel *)secureChannelWithHost:(NSString *)host + pathToCertificates:(NSString *)path + channelArgs:(NSDictionary *)channelArgs { + // Load default SSL certificates once. + static grpc_channel_credentials *kDefaultCertificates; + static dispatch_once_t loading; + dispatch_once(&loading, ^{ + NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem + // Do not use NSBundle.mainBundle, as it's nil for tests of library projects. + NSBundle *bundle = [NSBundle bundleForClass:self.class]; + NSString *path = [bundle pathForResource:defaultPath ofType:@"pem"]; + NSError *error; + kDefaultCertificates = CertificatesAtPath(path, &error); + NSAssert(kDefaultCertificates, @"Could not read %@/%@.pem. This file, with the root " + "certificates, is needed to establish secure (TLS) connections. Because the file is " + "distributed with the gRPC library, this error is usually a sign that the library " + "wasn't configured correctly for your project. Error: %@", + bundle.bundlePath, defaultPath, error); + }); + + //TODO(jcanizales): Add NSError** parameter to the initializer. + grpc_channel_credentials *certificates = path + ? CertificatesAtPath(path, NULL) + : kDefaultCertificates; + + return [[GRPCChannel alloc] initWithHost:host + secure:YES + credentials:certificates + channelArgs:channelArgs]; +} + + ++ (GRPCChannel *)secureChannelWithHost:(NSString *)host + credentials:(struct grpc_channel_credentials *)credentials + channelArgs:(NSDictionary *)channelArgs { + return [[GRPCChannel alloc] initWithHost:host + secure:YES + credentials:credentials + channelArgs:channelArgs]; + +} + ++ (GRPCChannel *)insecureChannelWithHost:(NSString *)host + channelArgs:(NSDictionary *)channelArgs { + return [[GRPCChannel alloc] initWithHost:host + secure:NO + credentials:NULL + channelArgs:channelArgs]; +} + @end diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCHost.h index 6b4f98746d..82c0ad6cf6 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.h +++ b/src/objective-c/GRPCClient/private/GRPCHost.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,7 @@ struct grpc_call; @interface GRPCHost : NSObject @property(nonatomic, readonly) NSString *address; +@property(nonatomic, copy) NSString *userAgentPrefix; /** The following properties should only be modified for testing: */ diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index a8cd3a0e74..eb1db899b7 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -34,11 +34,15 @@ #import "GRPCHost.h" #include <grpc/grpc.h> +#import <GRPCClient/GRPCCall+ChannelArg.h> #import "GRPCChannel.h" #import "GRPCCompletionQueue.h" -#import "GRPCSecureChannel.h" -#import "GRPCUnsecuredChannel.h" +#import "NSDictionary+GRPC.h" + +// TODO(jcanizales): Generate the version in a standalone header, from templates. Like +// templates/src/core/surface/version.c.template . +#define GRPC_OBJC_VERSION_STRING @"0.13.0" @interface GRPCHost () // TODO(mlumish): Investigate whether caching channels with strong links is a good idea. @@ -106,13 +110,28 @@ - (GRPCChannel *)channel { // Create it lazily, because we don't want to open a connection just because someone is // configuring a host. + if (!_channel) { + NSMutableDictionary *args = [NSMutableDictionary dictionary]; + + // TODO(jcanizales): Add OS and device information (see + // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md#user-agents ). + NSString *userAgent = @"grpc-objc/" GRPC_OBJC_VERSION_STRING; + if (_userAgentPrefix) { + userAgent = [@[_userAgentPrefix, userAgent] componentsJoinedByString:@" "]; + } + args[@GRPC_ARG_PRIMARY_USER_AGENT_STRING] = userAgent; + if (_secure) { - _channel = [[GRPCSecureChannel alloc] initWithHost:_address - pathToCertificates:_pathToCertificates - hostNameOverride:_hostNameOverride]; + if (_hostNameOverride) { + args[@GRPC_SSL_TARGET_NAME_OVERRIDE_ARG] = _hostNameOverride; + } + + _channel = [GRPCChannel secureChannelWithHost:_address + pathToCertificates:_pathToCertificates + channelArgs:args]; } else { - _channel = [[GRPCUnsecuredChannel alloc] initWithHost:_address]; + _channel = [GRPCChannel insecureChannelWithHost:_address channelArgs:args]; } } return _channel; diff --git a/src/objective-c/GRPCClient/private/GRPCSecureChannel.m b/src/objective-c/GRPCClient/private/GRPCSecureChannel.m deleted file mode 100644 index a573c171e9..0000000000 --- a/src/objective-c/GRPCClient/private/GRPCSecureChannel.m +++ /dev/null @@ -1,118 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import "GRPCSecureChannel.h" - -#include <grpc/grpc_security.h> - -// Returns NULL if the file at path couldn't be read. In that case, if errorPtr isn't NULL, -// *errorPtr will be an object describing what went wrong. -static grpc_channel_credentials *CertificatesAtPath(NSString *path, NSError **errorPtr) { - // Files in PEM format can have non-ASCII characters in their comments (e.g. for the name of the - // issuer). Load them as UTF8 and produce an ASCII equivalent. - NSString *contentInUTF8 = [NSString stringWithContentsOfFile:path - encoding:NSUTF8StringEncoding - error:errorPtr]; - NSData *contentInASCII = [contentInUTF8 dataUsingEncoding:NSASCIIStringEncoding - allowLossyConversion:YES]; - if (!contentInASCII.bytes) { - // Passing NULL to grpc_ssl_credentials_create produces behavior we don't want, so return. - return NULL; - } - return grpc_ssl_credentials_create(contentInASCII.bytes, NULL, NULL); -} - -@implementation GRPCSecureChannel - -- (instancetype)initWithHost:(NSString *)host { - return [self initWithHost:host pathToCertificates:nil hostNameOverride:nil]; -} - -- (instancetype)initWithHost:(NSString *)host - pathToCertificates:(NSString *)path - hostNameOverride:(NSString *)hostNameOverride { - // Load default SSL certificates once. - static grpc_channel_credentials *kDefaultCertificates; - static dispatch_once_t loading; - dispatch_once(&loading, ^{ - NSString *defaultPath = @"gRPCCertificates.bundle/roots"; // .pem - // Do not use NSBundle.mainBundle, as it's nil for tests of library projects. - NSBundle *bundle = [NSBundle bundleForClass:self.class]; - NSString *path = [bundle pathForResource:defaultPath ofType:@"pem"]; - NSError *error; - kDefaultCertificates = CertificatesAtPath(path, &error); - NSAssert(kDefaultCertificates, @"Could not read %@/%@.pem. This file, with the root " - "certificates, is needed to establish secure (TLS) connections. Because the file is " - "distributed with the gRPC library, this error is usually a sign that the library " - "wasn't configured correctly for your project. Error: %@", - bundle.bundlePath, defaultPath, error); - }); - - //TODO(jcanizales): Add NSError** parameter to the initializer. - grpc_channel_credentials *certificates = path - ? CertificatesAtPath(path, NULL) - : kDefaultCertificates; - if (!certificates) { - return nil; - } - - // Ritual to pass the SSL host name override to the C library. - grpc_channel_args channelArgs; - grpc_arg nameOverrideArg; - channelArgs.num_args = 1; - channelArgs.args = &nameOverrideArg; - nameOverrideArg.type = GRPC_ARG_STRING; - nameOverrideArg.key = GRPC_SSL_TARGET_NAME_OVERRIDE_ARG; - // Cast const away. Hope C gRPC doesn't modify it! - nameOverrideArg.value.string = (char *) hostNameOverride.UTF8String; - grpc_channel_args *args = hostNameOverride ? &channelArgs : NULL; - - return [self initWithHost:host credentials:certificates args:args]; -} - -- (instancetype)initWithHost:(NSString *)host - credentials:(grpc_channel_credentials *)credentials - args:(grpc_channel_args *)args { - return (self = [super - initWithChannel:grpc_secure_channel_create( - credentials, host.UTF8String, args, NULL)]); -} - -// TODO(jcanizales): GRPCSecureChannel and GRPCUnsecuredChannel are just convenience initializers -// for GRPCChannel. Move them into GRPCChannel, which will make the following unnecessary. -- (instancetype)initWithChannel:(grpc_channel *)unmanagedChannel { - [NSException raise:NSInternalInconsistencyException format:@"use another initializer"]; - return [self initWithHost:nil]; // silence warnings -} - -@end diff --git a/src/php/ext/grpc/config.m4 b/src/php/ext/grpc/config.m4 index 0fb843d51f..b825a84215 100755 --- a/src/php/ext/grpc/config.m4 +++ b/src/php/ext/grpc/config.m4 @@ -50,17 +50,6 @@ if test "$PHP_GRPC" != "no"; then PHP_ADD_LIBPATH($GRPC_LIBDIR) - PHP_CHECK_LIBRARY(gpr,gpr_now, - [ - PHP_ADD_LIBRARY(gpr,,GRPC_SHARED_LIBADD) - PHP_ADD_LIBRARY(gpr) - AC_DEFINE(HAVE_GPRLIB,1,[ ]) - ],[ - AC_MSG_ERROR([wrong gpr lib version or lib not found]) - ],[ - -L$GRPC_LIBDIR - ]) - PHP_CHECK_LIBRARY(grpc,grpc_channel_destroy, [ PHP_ADD_LIBRARY(grpc,,GRPC_SHARED_LIBADD) diff --git a/src/proto/grpc/testing/control.proto b/src/proto/grpc/testing/control.proto index 2f352e652f..cc365cafe1 100644 --- a/src/proto/grpc/testing/control.proto +++ b/src/proto/grpc/testing/control.proto @@ -107,6 +107,10 @@ message ClientConfig { LoadParams load_params = 10; PayloadConfig payload_config = 11; HistogramParams histogram_params = 12; + + // Specify the cores we should run the client on, if desired + repeated int32 core_list = 13; + int32 core_limit = 14; } message ClientStatus { ClientStats stats = 1; } @@ -131,9 +135,13 @@ message ServerConfig { int32 port = 4; // Only for async server. Number of threads used to serve the requests. int32 async_server_threads = 7; - // restrict core usage, currently unused + // Specify the number of cores to limit server to, if desired int32 core_limit = 8; + // payload config, used in generic server PayloadConfig payload_config = 9; + + // Specify the cores we should run the server on, if desired + repeated int32 core_list = 10; } message ServerArgs { @@ -147,6 +155,17 @@ message ServerStatus { ServerStats stats = 1; // the port bound by the server int32 port = 2; - // Number of cores on the server. See gpr_cpu_num_cores. + // Number of cores available to the server int32 cores = 3; } + +message CoreRequest { +} + +message CoreResponse { + // Number of cores available on the server + int32 cores = 1; +} + +message Void { +} diff --git a/src/proto/grpc/testing/services.proto b/src/proto/grpc/testing/services.proto index af285ceab8..a2c5fda47e 100644 --- a/src/proto/grpc/testing/services.proto +++ b/src/proto/grpc/testing/services.proto @@ -1,4 +1,4 @@ -// Copyright 2015, Google Inc. +// Copyright 2015-2016, Google Inc. // All rights reserved. // // Redistribution and use in source and binary forms, with or without @@ -62,4 +62,10 @@ service WorkerService { // and once the shutdown has finished, the OK status is sent to terminate // this RPC. rpc RunClient(stream ClientArgs) returns (stream ClientStatus); + + // Just return the core count - unary call + rpc CoreCount(CoreRequest) returns (CoreResponse); + + // Quit this worker + rpc QuitWorker(Void) returns (Void); } diff --git a/src/python/grpcio/commands.py b/src/python/grpcio/commands.py index a6b8ad3fc0..774e7ad6a1 100644 --- a/src/python/grpcio/commands.py +++ b/src/python/grpcio/commands.py @@ -52,6 +52,13 @@ import support PYTHON_STEM = os.path.dirname(os.path.abspath(__file__)) +BINARIES_REPOSITORY = os.environ.get( + 'GRPC_PYTHON_BINARIES_REPOSITORY', + 'https://storage.googleapis.com/grpc-precompiled-binaries/python') + +USE_GRPC_CUSTOM_BDIST = bool(int(os.environ.get( + 'GRPC_PYTHON_USE_CUSTOM_BDIST', '1'))) + CONF_PY_ADDENDUM = """ extensions.append('sphinx.ext.napoleon') napoleon_google_docstring = True @@ -67,7 +74,7 @@ class CommandError(Exception): # TODO(atash): Remove this once PyPI has better Linux bdist support. See # https://bitbucket.org/pypa/pypi/issues/120/binary-wheels-for-linux-are-not-supported -def _get_linux_bdist_egg(decorated_basename, target_egg_basename): +def _get_grpc_custom_bdist_egg(decorated_basename, target_egg_basename): """Returns a string path to a .egg file for Linux to install. If we can retrieve a pre-compiled egg from online, uses it. Else, emits a @@ -78,10 +85,7 @@ def _get_linux_bdist_egg(decorated_basename, target_egg_basename): from six.moves.urllib import request decorated_path = decorated_basename + '.egg' try: - url = ( - 'https://storage.googleapis.com/grpc-precompiled-binaries/' - 'python/{target}' - .format(target=decorated_path)) + url = BINARIES_REPOSITORY + '/{target}'.format(target=decorated_path) egg_data = request.urlopen(url).read() except IOError as error: raise CommandError( @@ -100,6 +104,7 @@ def _get_linux_bdist_egg(decorated_basename, target_egg_basename): class EggNameMixin(object): + """Mixin for setuptools.Command classes to enable acquiring the egg name.""" def egg_name(self, with_custom): """ @@ -124,39 +129,42 @@ class Install(install.install, EggNameMixin): """ user_options = install.install.user_options + [ - # TODO(atash): remove this once manylinux gets on PyPI. See + # TODO(atash): remove this once PyPI has better Linux bdist support. See # https://bitbucket.org/pypa/pypi/issues/120/binary-wheels-for-linux-are-not-supported - ('use-linux-bdist', None, - 'Whether to retrieve a binary for Linux instead of building from ' - 'source.'), + ('use-grpc-custom-bdist', None, + 'Whether to retrieve a binary from the gRPC binary repository instead ' + 'of building from source.'), ] def initialize_options(self): install.install.initialize_options(self) - self.use_linux_bdist = False + self.use_grpc_custom_bdist = USE_GRPC_CUSTOM_BDIST def finalize_options(self): install.install.finalize_options(self) def run(self): - if self.use_linux_bdist: - try: - egg_path = _get_linux_bdist_egg(self.egg_name(True), - self.egg_name(False)) - except CommandError as error: - sys.stderr.write( - '\nWARNING: Failed to acquire grpcio prebuilt binary:\n' - '{}.\n\n'.format(error.message)) - raise + if self.use_grpc_custom_bdist: try: - self._run_bdist_retrieval_install(egg_path) - except Exception as error: - # if anything else happens (and given how there's no way to really know - # what's happening in setuptools here, I mean *anything*), warn the user - # and fall back to building from source. - sys.stderr.write( - '{}\nWARNING: Failed to install grpcio prebuilt binary.\n\n' - .format(traceback.format_exc())) + try: + egg_path = _get_grpc_custom_bdist_egg(self.egg_name(True), + self.egg_name(False)) + except CommandError as error: + sys.stderr.write( + '\nWARNING: Failed to acquire grpcio prebuilt binary:\n' + '{}.\n\n'.format(error.message)) + raise + try: + self._run_bdist_retrieval_install(egg_path) + except Exception as error: + # if anything else happens (and given how there's no way to really know + # what's happening in setuptools here, I mean *anything*), warn the user + # and fall back to building from source. + sys.stderr.write( + '{}\nWARNING: Failed to install grpcio prebuilt binary.\n\n' + .format(traceback.format_exc())) + raise + except Exception: install.install.run(self) else: install.install.run(self) @@ -320,11 +328,11 @@ class BuildExt(build_ext.build_ext): extension.extra_link_args += list(BuildExt.LINK_OPTIONS[compiler]) try: build_ext.build_ext.build_extensions(self) - except KeyboardInterrupt: - raise except Exception as error: - support.diagnose_build_ext_error(self, error) - raise CommandError("Failed `build_ext` step.") + formatted_exception = traceback.format_exc() + support.diagnose_build_ext_error(self, error, formatted_exception) + raise CommandError( + "Failed `build_ext` step:\n{}".format(formatted_exception)) class Gather(setuptools.Command): diff --git a/src/python/grpcio/grpc/_cython/.gitignore b/src/python/grpcio/grpc/_cython/.gitignore index c315029288..306e3ad277 100644 --- a/src/python/grpcio/grpc/_cython/.gitignore +++ b/src/python/grpcio/grpc/_cython/.gitignore @@ -1,5 +1,4 @@ -*.h -*.c +cygrpc.c *.a *.so *.dll diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 9b10d2ae75..9c85e0ee1b 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -28,15 +28,20 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. cimport libc.time -from libc.stdint cimport int64_t, uint32_t, int32_t -cdef extern from "grpc/support/alloc.h": +cdef extern from "grpc/_cython/loader.h": + + ctypedef int int32_t + ctypedef unsigned uint32_t + ctypedef long int64_t + + int pygrpc_load_core(const char*) + void *gpr_malloc(size_t size) void gpr_free(void *ptr) void *gpr_realloc(void *p, size_t size) -cdef extern from "grpc/support/slice.h": ctypedef struct gpr_slice: # don't worry about writing out the members of gpr_slice; we never access # them directly. @@ -55,9 +60,6 @@ cdef extern from "grpc/support/slice.h": void *gpr_slice_start_ptr "GPR_SLICE_START_PTR" (gpr_slice s) size_t gpr_slice_length "GPR_SLICE_LENGTH" (gpr_slice s) - -cdef extern from "grpc/support/time.h": - ctypedef enum gpr_clock_type: GPR_CLOCK_MONOTONIC GPR_CLOCK_REALTIME @@ -78,8 +80,6 @@ cdef extern from "grpc/support/time.h": gpr_timespec gpr_convert_clock_type(gpr_timespec t, gpr_clock_type target_clock) - -cdef extern from "grpc/status.h": ctypedef enum grpc_status_code: GRPC_STATUS_OK GRPC_STATUS_CANCELLED @@ -100,14 +100,10 @@ cdef extern from "grpc/status.h": GRPC_STATUS_DATA_LOSS GRPC_STATUS__DO_NOT_USE - -cdef extern from "grpc/byte_buffer_reader.h": struct grpc_byte_buffer_reader: # We don't care about the internals pass - -cdef extern from "grpc/byte_buffer.h": ctypedef struct grpc_byte_buffer: # We don't care about the internals. pass @@ -123,9 +119,6 @@ cdef extern from "grpc/byte_buffer.h": gpr_slice *slice) void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader) - -cdef extern from "grpc/grpc.h": - const char *GRPC_ARG_PRIMARY_USER_AGENT_STRING const char *GRPC_ARG_ENABLE_CENSUS const char *GRPC_ARG_MAX_CONCURRENT_STREAMS @@ -333,9 +326,6 @@ cdef extern from "grpc/grpc.h": void grpc_server_cancel_all_calls(grpc_server *server) void grpc_server_destroy(grpc_server *server) - -cdef extern from "grpc/grpc_security.h": - ctypedef struct grpc_ssl_pem_key_cert_pair: const char *private_key const char *certificate_chain "cert_chain" diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index d7ad9e5215..fa4ea99ea9 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -146,8 +146,13 @@ cdef class Timespec: gpr_convert_clock_type(self.c_time, GPR_CLOCK_REALTIME)) return <double>real_time.seconds + <double>real_time.nanoseconds / 1e9 - infinite_future = Timespec(float("+inf")) - infinite_past = Timespec(float("-inf")) + @staticmethod + def infinite_future(): + return Timespec(float("+inf")) + + @staticmethod + def infinite_past(): + return Timespec(float("-inf")) cdef class CallDetails: diff --git a/src/python/grpcio/grpc/_cython/cygrpc.pyx b/src/python/grpcio/grpc/_cython/cygrpc.pyx index 297c8001c5..b1836bf5be 100644 --- a/src/python/grpcio/grpc/_cython/cygrpc.pyx +++ b/src/python/grpcio/grpc/_cython/cygrpc.pyx @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -29,6 +29,10 @@ cimport cpython +import pkg_resources +import os.path +import sys + # TODO(atash): figure out why the coverage tool gets confused about the Cython # coverage plugin when the following files don't have a '.pxi' suffix. include "grpc/_cython/_cygrpc/call.pyx.pxi" @@ -44,11 +48,20 @@ include "grpc/_cython/_cygrpc/server.pyx.pxi" cdef class _ModuleState: + cdef bint is_loaded + def __cinit__(self): + if 'win32' in sys.platform: + filename = pkg_resources.resource_filename( + 'grpc._cython', '_windows/grpc_c.64.python') + if not pygrpc_load_core(filename): + raise ImportError('failed to load core gRPC library') grpc_init() + self.is_loaded = True def __dealloc__(self): - grpc_shutdown() + if self.is_loaded: + grpc_shutdown() _module_state = _ModuleState() diff --git a/src/python/grpcio/grpc/_cython/imports.generated.c b/src/python/grpcio/grpc/_cython/imports.generated.c new file mode 100644 index 0000000000..817303c8a4 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/imports.generated.c @@ -0,0 +1,560 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <grpc/support/port_platform.h> + +#include "imports.generated.h" + +#ifdef GPR_WIN32 + +census_initialize_type census_initialize_import; +census_shutdown_type census_shutdown_import; +census_supported_type census_supported_import; +census_enabled_type census_enabled_import; +census_context_create_type census_context_create_import; +census_context_destroy_type census_context_destroy_import; +census_context_get_status_type census_context_get_status_import; +census_context_initialize_iterator_type census_context_initialize_iterator_import; +census_context_next_tag_type census_context_next_tag_import; +census_context_get_tag_type census_context_get_tag_import; +census_context_encode_type census_context_encode_import; +census_context_decode_type census_context_decode_import; +census_trace_mask_type census_trace_mask_import; +census_set_trace_mask_type census_set_trace_mask_import; +census_start_rpc_op_timestamp_type census_start_rpc_op_timestamp_import; +census_start_client_rpc_op_type census_start_client_rpc_op_import; +census_set_rpc_client_peer_type census_set_rpc_client_peer_import; +census_start_server_rpc_op_type census_start_server_rpc_op_import; +census_start_op_type census_start_op_import; +census_end_op_type census_end_op_import; +census_trace_print_type census_trace_print_import; +census_trace_scan_start_type census_trace_scan_start_import; +census_get_trace_record_type census_get_trace_record_import; +census_trace_scan_end_type census_trace_scan_end_import; +census_record_values_type census_record_values_import; +census_view_create_type census_view_create_import; +census_view_delete_type census_view_delete_import; +census_view_metric_type census_view_metric_import; +census_view_naggregations_type census_view_naggregations_import; +census_view_tags_type census_view_tags_import; +census_view_aggregrations_type census_view_aggregrations_import; +census_view_get_data_type census_view_get_data_import; +census_view_reset_type census_view_reset_import; +grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import; +grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import; +grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import; +grpc_compression_options_init_type grpc_compression_options_init_import; +grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import; +grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import; +grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import; +grpc_metadata_array_init_type grpc_metadata_array_init_import; +grpc_metadata_array_destroy_type grpc_metadata_array_destroy_import; +grpc_call_details_init_type grpc_call_details_init_import; +grpc_call_details_destroy_type grpc_call_details_destroy_import; +grpc_register_plugin_type grpc_register_plugin_import; +grpc_init_type grpc_init_import; +grpc_shutdown_type grpc_shutdown_import; +grpc_version_string_type grpc_version_string_import; +grpc_completion_queue_create_type grpc_completion_queue_create_import; +grpc_completion_queue_next_type grpc_completion_queue_next_import; +grpc_completion_queue_pluck_type grpc_completion_queue_pluck_import; +grpc_completion_queue_shutdown_type grpc_completion_queue_shutdown_import; +grpc_completion_queue_destroy_type grpc_completion_queue_destroy_import; +grpc_alarm_create_type grpc_alarm_create_import; +grpc_alarm_cancel_type grpc_alarm_cancel_import; +grpc_alarm_destroy_type grpc_alarm_destroy_import; +grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import; +grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import; +grpc_channel_create_call_type grpc_channel_create_call_import; +grpc_channel_ping_type grpc_channel_ping_import; +grpc_channel_register_call_type grpc_channel_register_call_import; +grpc_channel_create_registered_call_type grpc_channel_create_registered_call_import; +grpc_call_start_batch_type grpc_call_start_batch_import; +grpc_call_get_peer_type grpc_call_get_peer_import; +grpc_census_call_set_context_type grpc_census_call_set_context_import; +grpc_census_call_get_context_type grpc_census_call_get_context_import; +grpc_channel_get_target_type grpc_channel_get_target_import; +grpc_insecure_channel_create_type grpc_insecure_channel_create_import; +grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import; +grpc_channel_destroy_type grpc_channel_destroy_import; +grpc_call_cancel_type grpc_call_cancel_import; +grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import; +grpc_call_destroy_type grpc_call_destroy_import; +grpc_server_request_call_type grpc_server_request_call_import; +grpc_server_register_method_type grpc_server_register_method_import; +grpc_server_request_registered_call_type grpc_server_request_registered_call_import; +grpc_server_create_type grpc_server_create_import; +grpc_server_register_completion_queue_type grpc_server_register_completion_queue_import; +grpc_server_add_insecure_http2_port_type grpc_server_add_insecure_http2_port_import; +grpc_server_start_type grpc_server_start_import; +grpc_server_shutdown_and_notify_type grpc_server_shutdown_and_notify_import; +grpc_server_cancel_all_calls_type grpc_server_cancel_all_calls_import; +grpc_server_destroy_type grpc_server_destroy_import; +grpc_tracer_set_enabled_type grpc_tracer_set_enabled_import; +grpc_header_key_is_legal_type grpc_header_key_is_legal_import; +grpc_header_nonbin_value_is_legal_type grpc_header_nonbin_value_is_legal_import; +grpc_is_binary_header_type grpc_is_binary_header_import; +grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import; +grpc_auth_context_property_iterator_type grpc_auth_context_property_iterator_import; +grpc_auth_context_peer_identity_type grpc_auth_context_peer_identity_import; +grpc_auth_context_find_properties_by_name_type grpc_auth_context_find_properties_by_name_import; +grpc_auth_context_peer_identity_property_name_type grpc_auth_context_peer_identity_property_name_import; +grpc_auth_context_peer_is_authenticated_type grpc_auth_context_peer_is_authenticated_import; +grpc_call_auth_context_type grpc_call_auth_context_import; +grpc_auth_context_release_type grpc_auth_context_release_import; +grpc_auth_context_add_property_type grpc_auth_context_add_property_import; +grpc_auth_context_add_cstring_property_type grpc_auth_context_add_cstring_property_import; +grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import; +grpc_channel_credentials_release_type grpc_channel_credentials_release_import; +grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import; +grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; +grpc_call_credentials_release_type grpc_call_credentials_release_import; +grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import; +grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import; +grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import; +grpc_max_auth_token_lifetime_type grpc_max_auth_token_lifetime_import; +grpc_service_account_jwt_access_credentials_create_type grpc_service_account_jwt_access_credentials_create_import; +grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_credentials_create_import; +grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import; +grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import; +grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import; +grpc_secure_channel_create_type grpc_secure_channel_create_import; +grpc_server_credentials_release_type grpc_server_credentials_release_import; +grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; +grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import; +grpc_call_set_credentials_type grpc_call_set_credentials_import; +grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; +gpr_malloc_type gpr_malloc_import; +gpr_free_type gpr_free_import; +gpr_realloc_type gpr_realloc_import; +gpr_malloc_aligned_type gpr_malloc_aligned_import; +gpr_free_aligned_type gpr_free_aligned_import; +gpr_set_allocation_functions_type gpr_set_allocation_functions_import; +gpr_get_allocation_functions_type gpr_get_allocation_functions_import; +grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import; +grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import; +grpc_byte_buffer_copy_type grpc_byte_buffer_copy_import; +grpc_byte_buffer_length_type grpc_byte_buffer_length_import; +grpc_byte_buffer_destroy_type grpc_byte_buffer_destroy_import; +grpc_byte_buffer_reader_init_type grpc_byte_buffer_reader_init_import; +grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import; +grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import; +grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import; +grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import; +gpr_log_type gpr_log_import; +gpr_log_message_type gpr_log_message_import; +gpr_set_log_function_type gpr_set_log_function_import; +gpr_slice_ref_type gpr_slice_ref_import; +gpr_slice_unref_type gpr_slice_unref_import; +gpr_slice_new_type gpr_slice_new_import; +gpr_slice_new_with_len_type gpr_slice_new_with_len_import; +gpr_slice_malloc_type gpr_slice_malloc_import; +gpr_slice_from_copied_string_type gpr_slice_from_copied_string_import; +gpr_slice_from_copied_buffer_type gpr_slice_from_copied_buffer_import; +gpr_slice_from_static_string_type gpr_slice_from_static_string_import; +gpr_slice_sub_type gpr_slice_sub_import; +gpr_slice_sub_no_ref_type gpr_slice_sub_no_ref_import; +gpr_slice_split_tail_type gpr_slice_split_tail_import; +gpr_slice_split_head_type gpr_slice_split_head_import; +gpr_empty_slice_type gpr_empty_slice_import; +gpr_slice_cmp_type gpr_slice_cmp_import; +gpr_slice_str_cmp_type gpr_slice_str_cmp_import; +gpr_slice_buffer_init_type gpr_slice_buffer_init_import; +gpr_slice_buffer_destroy_type gpr_slice_buffer_destroy_import; +gpr_slice_buffer_add_type gpr_slice_buffer_add_import; +gpr_slice_buffer_add_indexed_type gpr_slice_buffer_add_indexed_import; +gpr_slice_buffer_addn_type gpr_slice_buffer_addn_import; +gpr_slice_buffer_tiny_add_type gpr_slice_buffer_tiny_add_import; +gpr_slice_buffer_pop_type gpr_slice_buffer_pop_import; +gpr_slice_buffer_reset_and_unref_type gpr_slice_buffer_reset_and_unref_import; +gpr_slice_buffer_swap_type gpr_slice_buffer_swap_import; +gpr_slice_buffer_move_into_type gpr_slice_buffer_move_into_import; +gpr_slice_buffer_trim_end_type gpr_slice_buffer_trim_end_import; +gpr_slice_buffer_move_first_type gpr_slice_buffer_move_first_import; +gpr_slice_buffer_take_first_type gpr_slice_buffer_take_first_import; +gpr_mu_init_type gpr_mu_init_import; +gpr_mu_destroy_type gpr_mu_destroy_import; +gpr_mu_lock_type gpr_mu_lock_import; +gpr_mu_unlock_type gpr_mu_unlock_import; +gpr_mu_trylock_type gpr_mu_trylock_import; +gpr_cv_init_type gpr_cv_init_import; +gpr_cv_destroy_type gpr_cv_destroy_import; +gpr_cv_wait_type gpr_cv_wait_import; +gpr_cv_signal_type gpr_cv_signal_import; +gpr_cv_broadcast_type gpr_cv_broadcast_import; +gpr_once_init_type gpr_once_init_import; +gpr_event_init_type gpr_event_init_import; +gpr_event_set_type gpr_event_set_import; +gpr_event_get_type gpr_event_get_import; +gpr_event_wait_type gpr_event_wait_import; +gpr_ref_init_type gpr_ref_init_import; +gpr_ref_type gpr_ref_import; +gpr_refn_type gpr_refn_import; +gpr_unref_type gpr_unref_import; +gpr_stats_init_type gpr_stats_init_import; +gpr_stats_inc_type gpr_stats_inc_import; +gpr_stats_read_type gpr_stats_read_import; +gpr_time_0_type gpr_time_0_import; +gpr_inf_future_type gpr_inf_future_import; +gpr_inf_past_type gpr_inf_past_import; +gpr_time_init_type gpr_time_init_import; +gpr_now_type gpr_now_import; +gpr_convert_clock_type_type gpr_convert_clock_type_import; +gpr_time_cmp_type gpr_time_cmp_import; +gpr_time_max_type gpr_time_max_import; +gpr_time_min_type gpr_time_min_import; +gpr_time_add_type gpr_time_add_import; +gpr_time_sub_type gpr_time_sub_import; +gpr_time_from_micros_type gpr_time_from_micros_import; +gpr_time_from_nanos_type gpr_time_from_nanos_import; +gpr_time_from_millis_type gpr_time_from_millis_import; +gpr_time_from_seconds_type gpr_time_from_seconds_import; +gpr_time_from_minutes_type gpr_time_from_minutes_import; +gpr_time_from_hours_type gpr_time_from_hours_import; +gpr_time_to_millis_type gpr_time_to_millis_import; +gpr_time_similar_type gpr_time_similar_import; +gpr_sleep_until_type gpr_sleep_until_import; +gpr_timespec_to_micros_type gpr_timespec_to_micros_import; +gpr_avl_create_type gpr_avl_create_import; +gpr_avl_ref_type gpr_avl_ref_import; +gpr_avl_unref_type gpr_avl_unref_import; +gpr_avl_add_type gpr_avl_add_import; +gpr_avl_remove_type gpr_avl_remove_import; +gpr_avl_get_type gpr_avl_get_import; +gpr_cmdline_create_type gpr_cmdline_create_import; +gpr_cmdline_add_int_type gpr_cmdline_add_int_import; +gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import; +gpr_cmdline_add_string_type gpr_cmdline_add_string_import; +gpr_cmdline_on_extra_arg_type gpr_cmdline_on_extra_arg_import; +gpr_cmdline_set_survive_failure_type gpr_cmdline_set_survive_failure_import; +gpr_cmdline_parse_type gpr_cmdline_parse_import; +gpr_cmdline_destroy_type gpr_cmdline_destroy_import; +gpr_cmdline_usage_string_type gpr_cmdline_usage_string_import; +gpr_cpu_num_cores_type gpr_cpu_num_cores_import; +gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; +gpr_histogram_create_type gpr_histogram_create_import; +gpr_histogram_destroy_type gpr_histogram_destroy_import; +gpr_histogram_add_type gpr_histogram_add_import; +gpr_histogram_merge_type gpr_histogram_merge_import; +gpr_histogram_percentile_type gpr_histogram_percentile_import; +gpr_histogram_mean_type gpr_histogram_mean_import; +gpr_histogram_stddev_type gpr_histogram_stddev_import; +gpr_histogram_variance_type gpr_histogram_variance_import; +gpr_histogram_maximum_type gpr_histogram_maximum_import; +gpr_histogram_minimum_type gpr_histogram_minimum_import; +gpr_histogram_count_type gpr_histogram_count_import; +gpr_histogram_sum_type gpr_histogram_sum_import; +gpr_histogram_sum_of_squares_type gpr_histogram_sum_of_squares_import; +gpr_histogram_get_contents_type gpr_histogram_get_contents_import; +gpr_histogram_merge_contents_type gpr_histogram_merge_contents_import; +gpr_join_host_port_type gpr_join_host_port_import; +gpr_split_host_port_type gpr_split_host_port_import; +gpr_format_message_type gpr_format_message_import; +gpr_strdup_type gpr_strdup_import; +gpr_asprintf_type gpr_asprintf_import; +gpr_subprocess_binary_extension_type gpr_subprocess_binary_extension_import; +gpr_subprocess_create_type gpr_subprocess_create_import; +gpr_subprocess_destroy_type gpr_subprocess_destroy_import; +gpr_subprocess_join_type gpr_subprocess_join_import; +gpr_subprocess_interrupt_type gpr_subprocess_interrupt_import; +gpr_thd_new_type gpr_thd_new_import; +gpr_thd_options_default_type gpr_thd_options_default_import; +gpr_thd_options_set_detached_type gpr_thd_options_set_detached_import; +gpr_thd_options_set_joinable_type gpr_thd_options_set_joinable_import; +gpr_thd_options_is_detached_type gpr_thd_options_is_detached_import; +gpr_thd_options_is_joinable_type gpr_thd_options_is_joinable_import; +gpr_thd_currentid_type gpr_thd_currentid_import; +gpr_thd_join_type gpr_thd_join_import; + +void pygrpc_load_imports(HMODULE library) { + census_initialize_import = (census_initialize_type) GetProcAddress(library, "census_initialize"); + census_shutdown_import = (census_shutdown_type) GetProcAddress(library, "census_shutdown"); + census_supported_import = (census_supported_type) GetProcAddress(library, "census_supported"); + census_enabled_import = (census_enabled_type) GetProcAddress(library, "census_enabled"); + census_context_create_import = (census_context_create_type) GetProcAddress(library, "census_context_create"); + census_context_destroy_import = (census_context_destroy_type) GetProcAddress(library, "census_context_destroy"); + census_context_get_status_import = (census_context_get_status_type) GetProcAddress(library, "census_context_get_status"); + census_context_initialize_iterator_import = (census_context_initialize_iterator_type) GetProcAddress(library, "census_context_initialize_iterator"); + census_context_next_tag_import = (census_context_next_tag_type) GetProcAddress(library, "census_context_next_tag"); + census_context_get_tag_import = (census_context_get_tag_type) GetProcAddress(library, "census_context_get_tag"); + census_context_encode_import = (census_context_encode_type) GetProcAddress(library, "census_context_encode"); + census_context_decode_import = (census_context_decode_type) GetProcAddress(library, "census_context_decode"); + census_trace_mask_import = (census_trace_mask_type) GetProcAddress(library, "census_trace_mask"); + census_set_trace_mask_import = (census_set_trace_mask_type) GetProcAddress(library, "census_set_trace_mask"); + census_start_rpc_op_timestamp_import = (census_start_rpc_op_timestamp_type) GetProcAddress(library, "census_start_rpc_op_timestamp"); + census_start_client_rpc_op_import = (census_start_client_rpc_op_type) GetProcAddress(library, "census_start_client_rpc_op"); + census_set_rpc_client_peer_import = (census_set_rpc_client_peer_type) GetProcAddress(library, "census_set_rpc_client_peer"); + census_start_server_rpc_op_import = (census_start_server_rpc_op_type) GetProcAddress(library, "census_start_server_rpc_op"); + census_start_op_import = (census_start_op_type) GetProcAddress(library, "census_start_op"); + census_end_op_import = (census_end_op_type) GetProcAddress(library, "census_end_op"); + census_trace_print_import = (census_trace_print_type) GetProcAddress(library, "census_trace_print"); + census_trace_scan_start_import = (census_trace_scan_start_type) GetProcAddress(library, "census_trace_scan_start"); + census_get_trace_record_import = (census_get_trace_record_type) GetProcAddress(library, "census_get_trace_record"); + census_trace_scan_end_import = (census_trace_scan_end_type) GetProcAddress(library, "census_trace_scan_end"); + census_record_values_import = (census_record_values_type) GetProcAddress(library, "census_record_values"); + census_view_create_import = (census_view_create_type) GetProcAddress(library, "census_view_create"); + census_view_delete_import = (census_view_delete_type) GetProcAddress(library, "census_view_delete"); + census_view_metric_import = (census_view_metric_type) GetProcAddress(library, "census_view_metric"); + census_view_naggregations_import = (census_view_naggregations_type) GetProcAddress(library, "census_view_naggregations"); + census_view_tags_import = (census_view_tags_type) GetProcAddress(library, "census_view_tags"); + census_view_aggregrations_import = (census_view_aggregrations_type) GetProcAddress(library, "census_view_aggregrations"); + census_view_get_data_import = (census_view_get_data_type) GetProcAddress(library, "census_view_get_data"); + census_view_reset_import = (census_view_reset_type) GetProcAddress(library, "census_view_reset"); + grpc_compression_algorithm_parse_import = (grpc_compression_algorithm_parse_type) GetProcAddress(library, "grpc_compression_algorithm_parse"); + grpc_compression_algorithm_name_import = (grpc_compression_algorithm_name_type) GetProcAddress(library, "grpc_compression_algorithm_name"); + grpc_compression_algorithm_for_level_import = (grpc_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_compression_algorithm_for_level"); + grpc_compression_options_init_import = (grpc_compression_options_init_type) GetProcAddress(library, "grpc_compression_options_init"); + grpc_compression_options_enable_algorithm_import = (grpc_compression_options_enable_algorithm_type) GetProcAddress(library, "grpc_compression_options_enable_algorithm"); + grpc_compression_options_disable_algorithm_import = (grpc_compression_options_disable_algorithm_type) GetProcAddress(library, "grpc_compression_options_disable_algorithm"); + grpc_compression_options_is_algorithm_enabled_import = (grpc_compression_options_is_algorithm_enabled_type) GetProcAddress(library, "grpc_compression_options_is_algorithm_enabled"); + grpc_metadata_array_init_import = (grpc_metadata_array_init_type) GetProcAddress(library, "grpc_metadata_array_init"); + grpc_metadata_array_destroy_import = (grpc_metadata_array_destroy_type) GetProcAddress(library, "grpc_metadata_array_destroy"); + grpc_call_details_init_import = (grpc_call_details_init_type) GetProcAddress(library, "grpc_call_details_init"); + grpc_call_details_destroy_import = (grpc_call_details_destroy_type) GetProcAddress(library, "grpc_call_details_destroy"); + grpc_register_plugin_import = (grpc_register_plugin_type) GetProcAddress(library, "grpc_register_plugin"); + grpc_init_import = (grpc_init_type) GetProcAddress(library, "grpc_init"); + grpc_shutdown_import = (grpc_shutdown_type) GetProcAddress(library, "grpc_shutdown"); + grpc_version_string_import = (grpc_version_string_type) GetProcAddress(library, "grpc_version_string"); + grpc_completion_queue_create_import = (grpc_completion_queue_create_type) GetProcAddress(library, "grpc_completion_queue_create"); + grpc_completion_queue_next_import = (grpc_completion_queue_next_type) GetProcAddress(library, "grpc_completion_queue_next"); + grpc_completion_queue_pluck_import = (grpc_completion_queue_pluck_type) GetProcAddress(library, "grpc_completion_queue_pluck"); + grpc_completion_queue_shutdown_import = (grpc_completion_queue_shutdown_type) GetProcAddress(library, "grpc_completion_queue_shutdown"); + grpc_completion_queue_destroy_import = (grpc_completion_queue_destroy_type) GetProcAddress(library, "grpc_completion_queue_destroy"); + grpc_alarm_create_import = (grpc_alarm_create_type) GetProcAddress(library, "grpc_alarm_create"); + grpc_alarm_cancel_import = (grpc_alarm_cancel_type) GetProcAddress(library, "grpc_alarm_cancel"); + grpc_alarm_destroy_import = (grpc_alarm_destroy_type) GetProcAddress(library, "grpc_alarm_destroy"); + grpc_channel_check_connectivity_state_import = (grpc_channel_check_connectivity_state_type) GetProcAddress(library, "grpc_channel_check_connectivity_state"); + grpc_channel_watch_connectivity_state_import = (grpc_channel_watch_connectivity_state_type) GetProcAddress(library, "grpc_channel_watch_connectivity_state"); + grpc_channel_create_call_import = (grpc_channel_create_call_type) GetProcAddress(library, "grpc_channel_create_call"); + grpc_channel_ping_import = (grpc_channel_ping_type) GetProcAddress(library, "grpc_channel_ping"); + grpc_channel_register_call_import = (grpc_channel_register_call_type) GetProcAddress(library, "grpc_channel_register_call"); + grpc_channel_create_registered_call_import = (grpc_channel_create_registered_call_type) GetProcAddress(library, "grpc_channel_create_registered_call"); + grpc_call_start_batch_import = (grpc_call_start_batch_type) GetProcAddress(library, "grpc_call_start_batch"); + grpc_call_get_peer_import = (grpc_call_get_peer_type) GetProcAddress(library, "grpc_call_get_peer"); + grpc_census_call_set_context_import = (grpc_census_call_set_context_type) GetProcAddress(library, "grpc_census_call_set_context"); + grpc_census_call_get_context_import = (grpc_census_call_get_context_type) GetProcAddress(library, "grpc_census_call_get_context"); + grpc_channel_get_target_import = (grpc_channel_get_target_type) GetProcAddress(library, "grpc_channel_get_target"); + grpc_insecure_channel_create_import = (grpc_insecure_channel_create_type) GetProcAddress(library, "grpc_insecure_channel_create"); + grpc_lame_client_channel_create_import = (grpc_lame_client_channel_create_type) GetProcAddress(library, "grpc_lame_client_channel_create"); + grpc_channel_destroy_import = (grpc_channel_destroy_type) GetProcAddress(library, "grpc_channel_destroy"); + grpc_call_cancel_import = (grpc_call_cancel_type) GetProcAddress(library, "grpc_call_cancel"); + grpc_call_cancel_with_status_import = (grpc_call_cancel_with_status_type) GetProcAddress(library, "grpc_call_cancel_with_status"); + grpc_call_destroy_import = (grpc_call_destroy_type) GetProcAddress(library, "grpc_call_destroy"); + grpc_server_request_call_import = (grpc_server_request_call_type) GetProcAddress(library, "grpc_server_request_call"); + grpc_server_register_method_import = (grpc_server_register_method_type) GetProcAddress(library, "grpc_server_register_method"); + grpc_server_request_registered_call_import = (grpc_server_request_registered_call_type) GetProcAddress(library, "grpc_server_request_registered_call"); + grpc_server_create_import = (grpc_server_create_type) GetProcAddress(library, "grpc_server_create"); + grpc_server_register_completion_queue_import = (grpc_server_register_completion_queue_type) GetProcAddress(library, "grpc_server_register_completion_queue"); + grpc_server_add_insecure_http2_port_import = (grpc_server_add_insecure_http2_port_type) GetProcAddress(library, "grpc_server_add_insecure_http2_port"); + grpc_server_start_import = (grpc_server_start_type) GetProcAddress(library, "grpc_server_start"); + grpc_server_shutdown_and_notify_import = (grpc_server_shutdown_and_notify_type) GetProcAddress(library, "grpc_server_shutdown_and_notify"); + grpc_server_cancel_all_calls_import = (grpc_server_cancel_all_calls_type) GetProcAddress(library, "grpc_server_cancel_all_calls"); + grpc_server_destroy_import = (grpc_server_destroy_type) GetProcAddress(library, "grpc_server_destroy"); + grpc_tracer_set_enabled_import = (grpc_tracer_set_enabled_type) GetProcAddress(library, "grpc_tracer_set_enabled"); + grpc_header_key_is_legal_import = (grpc_header_key_is_legal_type) GetProcAddress(library, "grpc_header_key_is_legal"); + grpc_header_nonbin_value_is_legal_import = (grpc_header_nonbin_value_is_legal_type) GetProcAddress(library, "grpc_header_nonbin_value_is_legal"); + grpc_is_binary_header_import = (grpc_is_binary_header_type) GetProcAddress(library, "grpc_is_binary_header"); + grpc_auth_property_iterator_next_import = (grpc_auth_property_iterator_next_type) GetProcAddress(library, "grpc_auth_property_iterator_next"); + grpc_auth_context_property_iterator_import = (grpc_auth_context_property_iterator_type) GetProcAddress(library, "grpc_auth_context_property_iterator"); + grpc_auth_context_peer_identity_import = (grpc_auth_context_peer_identity_type) GetProcAddress(library, "grpc_auth_context_peer_identity"); + grpc_auth_context_find_properties_by_name_import = (grpc_auth_context_find_properties_by_name_type) GetProcAddress(library, "grpc_auth_context_find_properties_by_name"); + grpc_auth_context_peer_identity_property_name_import = (grpc_auth_context_peer_identity_property_name_type) GetProcAddress(library, "grpc_auth_context_peer_identity_property_name"); + grpc_auth_context_peer_is_authenticated_import = (grpc_auth_context_peer_is_authenticated_type) GetProcAddress(library, "grpc_auth_context_peer_is_authenticated"); + grpc_call_auth_context_import = (grpc_call_auth_context_type) GetProcAddress(library, "grpc_call_auth_context"); + grpc_auth_context_release_import = (grpc_auth_context_release_type) GetProcAddress(library, "grpc_auth_context_release"); + grpc_auth_context_add_property_import = (grpc_auth_context_add_property_type) GetProcAddress(library, "grpc_auth_context_add_property"); + grpc_auth_context_add_cstring_property_import = (grpc_auth_context_add_cstring_property_type) GetProcAddress(library, "grpc_auth_context_add_cstring_property"); + grpc_auth_context_set_peer_identity_property_name_import = (grpc_auth_context_set_peer_identity_property_name_type) GetProcAddress(library, "grpc_auth_context_set_peer_identity_property_name"); + grpc_channel_credentials_release_import = (grpc_channel_credentials_release_type) GetProcAddress(library, "grpc_channel_credentials_release"); + grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create"); + grpc_ssl_credentials_create_import = (grpc_ssl_credentials_create_type) GetProcAddress(library, "grpc_ssl_credentials_create"); + grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release"); + grpc_composite_channel_credentials_create_import = (grpc_composite_channel_credentials_create_type) GetProcAddress(library, "grpc_composite_channel_credentials_create"); + grpc_composite_call_credentials_create_import = (grpc_composite_call_credentials_create_type) GetProcAddress(library, "grpc_composite_call_credentials_create"); + grpc_google_compute_engine_credentials_create_import = (grpc_google_compute_engine_credentials_create_type) GetProcAddress(library, "grpc_google_compute_engine_credentials_create"); + grpc_max_auth_token_lifetime_import = (grpc_max_auth_token_lifetime_type) GetProcAddress(library, "grpc_max_auth_token_lifetime"); + grpc_service_account_jwt_access_credentials_create_import = (grpc_service_account_jwt_access_credentials_create_type) GetProcAddress(library, "grpc_service_account_jwt_access_credentials_create"); + grpc_google_refresh_token_credentials_create_import = (grpc_google_refresh_token_credentials_create_type) GetProcAddress(library, "grpc_google_refresh_token_credentials_create"); + grpc_access_token_credentials_create_import = (grpc_access_token_credentials_create_type) GetProcAddress(library, "grpc_access_token_credentials_create"); + grpc_google_iam_credentials_create_import = (grpc_google_iam_credentials_create_type) GetProcAddress(library, "grpc_google_iam_credentials_create"); + grpc_metadata_credentials_create_from_plugin_import = (grpc_metadata_credentials_create_from_plugin_type) GetProcAddress(library, "grpc_metadata_credentials_create_from_plugin"); + grpc_secure_channel_create_import = (grpc_secure_channel_create_type) GetProcAddress(library, "grpc_secure_channel_create"); + grpc_server_credentials_release_import = (grpc_server_credentials_release_type) GetProcAddress(library, "grpc_server_credentials_release"); + grpc_ssl_server_credentials_create_import = (grpc_ssl_server_credentials_create_type) GetProcAddress(library, "grpc_ssl_server_credentials_create"); + grpc_server_add_secure_http2_port_import = (grpc_server_add_secure_http2_port_type) GetProcAddress(library, "grpc_server_add_secure_http2_port"); + grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials"); + grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor"); + gpr_malloc_import = (gpr_malloc_type) GetProcAddress(library, "gpr_malloc"); + gpr_free_import = (gpr_free_type) GetProcAddress(library, "gpr_free"); + gpr_realloc_import = (gpr_realloc_type) GetProcAddress(library, "gpr_realloc"); + gpr_malloc_aligned_import = (gpr_malloc_aligned_type) GetProcAddress(library, "gpr_malloc_aligned"); + gpr_free_aligned_import = (gpr_free_aligned_type) GetProcAddress(library, "gpr_free_aligned"); + gpr_set_allocation_functions_import = (gpr_set_allocation_functions_type) GetProcAddress(library, "gpr_set_allocation_functions"); + gpr_get_allocation_functions_import = (gpr_get_allocation_functions_type) GetProcAddress(library, "gpr_get_allocation_functions"); + grpc_raw_byte_buffer_create_import = (grpc_raw_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_byte_buffer_create"); + grpc_raw_compressed_byte_buffer_create_import = (grpc_raw_compressed_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_compressed_byte_buffer_create"); + grpc_byte_buffer_copy_import = (grpc_byte_buffer_copy_type) GetProcAddress(library, "grpc_byte_buffer_copy"); + grpc_byte_buffer_length_import = (grpc_byte_buffer_length_type) GetProcAddress(library, "grpc_byte_buffer_length"); + grpc_byte_buffer_destroy_import = (grpc_byte_buffer_destroy_type) GetProcAddress(library, "grpc_byte_buffer_destroy"); + grpc_byte_buffer_reader_init_import = (grpc_byte_buffer_reader_init_type) GetProcAddress(library, "grpc_byte_buffer_reader_init"); + grpc_byte_buffer_reader_destroy_import = (grpc_byte_buffer_reader_destroy_type) GetProcAddress(library, "grpc_byte_buffer_reader_destroy"); + grpc_byte_buffer_reader_next_import = (grpc_byte_buffer_reader_next_type) GetProcAddress(library, "grpc_byte_buffer_reader_next"); + grpc_byte_buffer_reader_readall_import = (grpc_byte_buffer_reader_readall_type) GetProcAddress(library, "grpc_byte_buffer_reader_readall"); + grpc_raw_byte_buffer_from_reader_import = (grpc_raw_byte_buffer_from_reader_type) GetProcAddress(library, "grpc_raw_byte_buffer_from_reader"); + gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log"); + gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message"); + gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function"); + gpr_slice_ref_import = (gpr_slice_ref_type) GetProcAddress(library, "gpr_slice_ref"); + gpr_slice_unref_import = (gpr_slice_unref_type) GetProcAddress(library, "gpr_slice_unref"); + gpr_slice_new_import = (gpr_slice_new_type) GetProcAddress(library, "gpr_slice_new"); + gpr_slice_new_with_len_import = (gpr_slice_new_with_len_type) GetProcAddress(library, "gpr_slice_new_with_len"); + gpr_slice_malloc_import = (gpr_slice_malloc_type) GetProcAddress(library, "gpr_slice_malloc"); + gpr_slice_from_copied_string_import = (gpr_slice_from_copied_string_type) GetProcAddress(library, "gpr_slice_from_copied_string"); + gpr_slice_from_copied_buffer_import = (gpr_slice_from_copied_buffer_type) GetProcAddress(library, "gpr_slice_from_copied_buffer"); + gpr_slice_from_static_string_import = (gpr_slice_from_static_string_type) GetProcAddress(library, "gpr_slice_from_static_string"); + gpr_slice_sub_import = (gpr_slice_sub_type) GetProcAddress(library, "gpr_slice_sub"); + gpr_slice_sub_no_ref_import = (gpr_slice_sub_no_ref_type) GetProcAddress(library, "gpr_slice_sub_no_ref"); + gpr_slice_split_tail_import = (gpr_slice_split_tail_type) GetProcAddress(library, "gpr_slice_split_tail"); + gpr_slice_split_head_import = (gpr_slice_split_head_type) GetProcAddress(library, "gpr_slice_split_head"); + gpr_empty_slice_import = (gpr_empty_slice_type) GetProcAddress(library, "gpr_empty_slice"); + gpr_slice_cmp_import = (gpr_slice_cmp_type) GetProcAddress(library, "gpr_slice_cmp"); + gpr_slice_str_cmp_import = (gpr_slice_str_cmp_type) GetProcAddress(library, "gpr_slice_str_cmp"); + gpr_slice_buffer_init_import = (gpr_slice_buffer_init_type) GetProcAddress(library, "gpr_slice_buffer_init"); + gpr_slice_buffer_destroy_import = (gpr_slice_buffer_destroy_type) GetProcAddress(library, "gpr_slice_buffer_destroy"); + gpr_slice_buffer_add_import = (gpr_slice_buffer_add_type) GetProcAddress(library, "gpr_slice_buffer_add"); + gpr_slice_buffer_add_indexed_import = (gpr_slice_buffer_add_indexed_type) GetProcAddress(library, "gpr_slice_buffer_add_indexed"); + gpr_slice_buffer_addn_import = (gpr_slice_buffer_addn_type) GetProcAddress(library, "gpr_slice_buffer_addn"); + gpr_slice_buffer_tiny_add_import = (gpr_slice_buffer_tiny_add_type) GetProcAddress(library, "gpr_slice_buffer_tiny_add"); + gpr_slice_buffer_pop_import = (gpr_slice_buffer_pop_type) GetProcAddress(library, "gpr_slice_buffer_pop"); + gpr_slice_buffer_reset_and_unref_import = (gpr_slice_buffer_reset_and_unref_type) GetProcAddress(library, "gpr_slice_buffer_reset_and_unref"); + gpr_slice_buffer_swap_import = (gpr_slice_buffer_swap_type) GetProcAddress(library, "gpr_slice_buffer_swap"); + gpr_slice_buffer_move_into_import = (gpr_slice_buffer_move_into_type) GetProcAddress(library, "gpr_slice_buffer_move_into"); + gpr_slice_buffer_trim_end_import = (gpr_slice_buffer_trim_end_type) GetProcAddress(library, "gpr_slice_buffer_trim_end"); + gpr_slice_buffer_move_first_import = (gpr_slice_buffer_move_first_type) GetProcAddress(library, "gpr_slice_buffer_move_first"); + gpr_slice_buffer_take_first_import = (gpr_slice_buffer_take_first_type) GetProcAddress(library, "gpr_slice_buffer_take_first"); + gpr_mu_init_import = (gpr_mu_init_type) GetProcAddress(library, "gpr_mu_init"); + gpr_mu_destroy_import = (gpr_mu_destroy_type) GetProcAddress(library, "gpr_mu_destroy"); + gpr_mu_lock_import = (gpr_mu_lock_type) GetProcAddress(library, "gpr_mu_lock"); + gpr_mu_unlock_import = (gpr_mu_unlock_type) GetProcAddress(library, "gpr_mu_unlock"); + gpr_mu_trylock_import = (gpr_mu_trylock_type) GetProcAddress(library, "gpr_mu_trylock"); + gpr_cv_init_import = (gpr_cv_init_type) GetProcAddress(library, "gpr_cv_init"); + gpr_cv_destroy_import = (gpr_cv_destroy_type) GetProcAddress(library, "gpr_cv_destroy"); + gpr_cv_wait_import = (gpr_cv_wait_type) GetProcAddress(library, "gpr_cv_wait"); + gpr_cv_signal_import = (gpr_cv_signal_type) GetProcAddress(library, "gpr_cv_signal"); + gpr_cv_broadcast_import = (gpr_cv_broadcast_type) GetProcAddress(library, "gpr_cv_broadcast"); + gpr_once_init_import = (gpr_once_init_type) GetProcAddress(library, "gpr_once_init"); + gpr_event_init_import = (gpr_event_init_type) GetProcAddress(library, "gpr_event_init"); + gpr_event_set_import = (gpr_event_set_type) GetProcAddress(library, "gpr_event_set"); + gpr_event_get_import = (gpr_event_get_type) GetProcAddress(library, "gpr_event_get"); + gpr_event_wait_import = (gpr_event_wait_type) GetProcAddress(library, "gpr_event_wait"); + gpr_ref_init_import = (gpr_ref_init_type) GetProcAddress(library, "gpr_ref_init"); + gpr_ref_import = (gpr_ref_type) GetProcAddress(library, "gpr_ref"); + gpr_refn_import = (gpr_refn_type) GetProcAddress(library, "gpr_refn"); + gpr_unref_import = (gpr_unref_type) GetProcAddress(library, "gpr_unref"); + gpr_stats_init_import = (gpr_stats_init_type) GetProcAddress(library, "gpr_stats_init"); + gpr_stats_inc_import = (gpr_stats_inc_type) GetProcAddress(library, "gpr_stats_inc"); + gpr_stats_read_import = (gpr_stats_read_type) GetProcAddress(library, "gpr_stats_read"); + gpr_time_0_import = (gpr_time_0_type) GetProcAddress(library, "gpr_time_0"); + gpr_inf_future_import = (gpr_inf_future_type) GetProcAddress(library, "gpr_inf_future"); + gpr_inf_past_import = (gpr_inf_past_type) GetProcAddress(library, "gpr_inf_past"); + gpr_time_init_import = (gpr_time_init_type) GetProcAddress(library, "gpr_time_init"); + gpr_now_import = (gpr_now_type) GetProcAddress(library, "gpr_now"); + gpr_convert_clock_type_import = (gpr_convert_clock_type_type) GetProcAddress(library, "gpr_convert_clock_type"); + gpr_time_cmp_import = (gpr_time_cmp_type) GetProcAddress(library, "gpr_time_cmp"); + gpr_time_max_import = (gpr_time_max_type) GetProcAddress(library, "gpr_time_max"); + gpr_time_min_import = (gpr_time_min_type) GetProcAddress(library, "gpr_time_min"); + gpr_time_add_import = (gpr_time_add_type) GetProcAddress(library, "gpr_time_add"); + gpr_time_sub_import = (gpr_time_sub_type) GetProcAddress(library, "gpr_time_sub"); + gpr_time_from_micros_import = (gpr_time_from_micros_type) GetProcAddress(library, "gpr_time_from_micros"); + gpr_time_from_nanos_import = (gpr_time_from_nanos_type) GetProcAddress(library, "gpr_time_from_nanos"); + gpr_time_from_millis_import = (gpr_time_from_millis_type) GetProcAddress(library, "gpr_time_from_millis"); + gpr_time_from_seconds_import = (gpr_time_from_seconds_type) GetProcAddress(library, "gpr_time_from_seconds"); + gpr_time_from_minutes_import = (gpr_time_from_minutes_type) GetProcAddress(library, "gpr_time_from_minutes"); + gpr_time_from_hours_import = (gpr_time_from_hours_type) GetProcAddress(library, "gpr_time_from_hours"); + gpr_time_to_millis_import = (gpr_time_to_millis_type) GetProcAddress(library, "gpr_time_to_millis"); + gpr_time_similar_import = (gpr_time_similar_type) GetProcAddress(library, "gpr_time_similar"); + gpr_sleep_until_import = (gpr_sleep_until_type) GetProcAddress(library, "gpr_sleep_until"); + gpr_timespec_to_micros_import = (gpr_timespec_to_micros_type) GetProcAddress(library, "gpr_timespec_to_micros"); + gpr_avl_create_import = (gpr_avl_create_type) GetProcAddress(library, "gpr_avl_create"); + gpr_avl_ref_import = (gpr_avl_ref_type) GetProcAddress(library, "gpr_avl_ref"); + gpr_avl_unref_import = (gpr_avl_unref_type) GetProcAddress(library, "gpr_avl_unref"); + gpr_avl_add_import = (gpr_avl_add_type) GetProcAddress(library, "gpr_avl_add"); + gpr_avl_remove_import = (gpr_avl_remove_type) GetProcAddress(library, "gpr_avl_remove"); + gpr_avl_get_import = (gpr_avl_get_type) GetProcAddress(library, "gpr_avl_get"); + gpr_cmdline_create_import = (gpr_cmdline_create_type) GetProcAddress(library, "gpr_cmdline_create"); + gpr_cmdline_add_int_import = (gpr_cmdline_add_int_type) GetProcAddress(library, "gpr_cmdline_add_int"); + gpr_cmdline_add_flag_import = (gpr_cmdline_add_flag_type) GetProcAddress(library, "gpr_cmdline_add_flag"); + gpr_cmdline_add_string_import = (gpr_cmdline_add_string_type) GetProcAddress(library, "gpr_cmdline_add_string"); + gpr_cmdline_on_extra_arg_import = (gpr_cmdline_on_extra_arg_type) GetProcAddress(library, "gpr_cmdline_on_extra_arg"); + gpr_cmdline_set_survive_failure_import = (gpr_cmdline_set_survive_failure_type) GetProcAddress(library, "gpr_cmdline_set_survive_failure"); + gpr_cmdline_parse_import = (gpr_cmdline_parse_type) GetProcAddress(library, "gpr_cmdline_parse"); + gpr_cmdline_destroy_import = (gpr_cmdline_destroy_type) GetProcAddress(library, "gpr_cmdline_destroy"); + gpr_cmdline_usage_string_import = (gpr_cmdline_usage_string_type) GetProcAddress(library, "gpr_cmdline_usage_string"); + gpr_cpu_num_cores_import = (gpr_cpu_num_cores_type) GetProcAddress(library, "gpr_cpu_num_cores"); + gpr_cpu_current_cpu_import = (gpr_cpu_current_cpu_type) GetProcAddress(library, "gpr_cpu_current_cpu"); + gpr_histogram_create_import = (gpr_histogram_create_type) GetProcAddress(library, "gpr_histogram_create"); + gpr_histogram_destroy_import = (gpr_histogram_destroy_type) GetProcAddress(library, "gpr_histogram_destroy"); + gpr_histogram_add_import = (gpr_histogram_add_type) GetProcAddress(library, "gpr_histogram_add"); + gpr_histogram_merge_import = (gpr_histogram_merge_type) GetProcAddress(library, "gpr_histogram_merge"); + gpr_histogram_percentile_import = (gpr_histogram_percentile_type) GetProcAddress(library, "gpr_histogram_percentile"); + gpr_histogram_mean_import = (gpr_histogram_mean_type) GetProcAddress(library, "gpr_histogram_mean"); + gpr_histogram_stddev_import = (gpr_histogram_stddev_type) GetProcAddress(library, "gpr_histogram_stddev"); + gpr_histogram_variance_import = (gpr_histogram_variance_type) GetProcAddress(library, "gpr_histogram_variance"); + gpr_histogram_maximum_import = (gpr_histogram_maximum_type) GetProcAddress(library, "gpr_histogram_maximum"); + gpr_histogram_minimum_import = (gpr_histogram_minimum_type) GetProcAddress(library, "gpr_histogram_minimum"); + gpr_histogram_count_import = (gpr_histogram_count_type) GetProcAddress(library, "gpr_histogram_count"); + gpr_histogram_sum_import = (gpr_histogram_sum_type) GetProcAddress(library, "gpr_histogram_sum"); + gpr_histogram_sum_of_squares_import = (gpr_histogram_sum_of_squares_type) GetProcAddress(library, "gpr_histogram_sum_of_squares"); + gpr_histogram_get_contents_import = (gpr_histogram_get_contents_type) GetProcAddress(library, "gpr_histogram_get_contents"); + gpr_histogram_merge_contents_import = (gpr_histogram_merge_contents_type) GetProcAddress(library, "gpr_histogram_merge_contents"); + gpr_join_host_port_import = (gpr_join_host_port_type) GetProcAddress(library, "gpr_join_host_port"); + gpr_split_host_port_import = (gpr_split_host_port_type) GetProcAddress(library, "gpr_split_host_port"); + gpr_format_message_import = (gpr_format_message_type) GetProcAddress(library, "gpr_format_message"); + gpr_strdup_import = (gpr_strdup_type) GetProcAddress(library, "gpr_strdup"); + gpr_asprintf_import = (gpr_asprintf_type) GetProcAddress(library, "gpr_asprintf"); + gpr_subprocess_binary_extension_import = (gpr_subprocess_binary_extension_type) GetProcAddress(library, "gpr_subprocess_binary_extension"); + gpr_subprocess_create_import = (gpr_subprocess_create_type) GetProcAddress(library, "gpr_subprocess_create"); + gpr_subprocess_destroy_import = (gpr_subprocess_destroy_type) GetProcAddress(library, "gpr_subprocess_destroy"); + gpr_subprocess_join_import = (gpr_subprocess_join_type) GetProcAddress(library, "gpr_subprocess_join"); + gpr_subprocess_interrupt_import = (gpr_subprocess_interrupt_type) GetProcAddress(library, "gpr_subprocess_interrupt"); + gpr_thd_new_import = (gpr_thd_new_type) GetProcAddress(library, "gpr_thd_new"); + gpr_thd_options_default_import = (gpr_thd_options_default_type) GetProcAddress(library, "gpr_thd_options_default"); + gpr_thd_options_set_detached_import = (gpr_thd_options_set_detached_type) GetProcAddress(library, "gpr_thd_options_set_detached"); + gpr_thd_options_set_joinable_import = (gpr_thd_options_set_joinable_type) GetProcAddress(library, "gpr_thd_options_set_joinable"); + gpr_thd_options_is_detached_import = (gpr_thd_options_is_detached_type) GetProcAddress(library, "gpr_thd_options_is_detached"); + gpr_thd_options_is_joinable_import = (gpr_thd_options_is_joinable_type) GetProcAddress(library, "gpr_thd_options_is_joinable"); + gpr_thd_currentid_import = (gpr_thd_currentid_type) GetProcAddress(library, "gpr_thd_currentid"); + gpr_thd_join_import = (gpr_thd_join_type) GetProcAddress(library, "gpr_thd_join"); +} + +#endif /* !GPR_WIN32 */ diff --git a/src/python/grpcio/grpc/_cython/imports.generated.h b/src/python/grpcio/grpc/_cython/imports.generated.h new file mode 100644 index 0000000000..6d0a6e06c0 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/imports.generated.h @@ -0,0 +1,854 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef PYGRPC_CYTHON_WINDOWS_IMPORTS_H_ +#define PYGRPC_CYTHON_WINDOWS_IMPORTS_H_ + +#include <grpc/support/port_platform.h> + +#ifdef GPR_WIN32 + +#include <windows.h> + +#include <grpc/census.h> +#include <grpc/compression.h> +#include <grpc/grpc.h> +#include <grpc/grpc_security.h> +#include <grpc/impl/codegen/alloc.h> +#include <grpc/impl/codegen/byte_buffer.h> +#include <grpc/impl/codegen/log.h> +#include <grpc/impl/codegen/slice.h> +#include <grpc/impl/codegen/slice_buffer.h> +#include <grpc/impl/codegen/sync.h> +#include <grpc/impl/codegen/time.h> +#include <grpc/support/avl.h> +#include <grpc/support/cmdline.h> +#include <grpc/support/cpu.h> +#include <grpc/support/histogram.h> +#include <grpc/support/host_port.h> +#include <grpc/support/log_win32.h> +#include <grpc/support/string_util.h> +#include <grpc/support/subprocess.h> +#include <grpc/support/thd.h> + +typedef int(*census_initialize_type)(int features); +extern census_initialize_type census_initialize_import; +#define census_initialize census_initialize_import +typedef void(*census_shutdown_type)(void); +extern census_shutdown_type census_shutdown_import; +#define census_shutdown census_shutdown_import +typedef int(*census_supported_type)(void); +extern census_supported_type census_supported_import; +#define census_supported census_supported_import +typedef int(*census_enabled_type)(void); +extern census_enabled_type census_enabled_import; +#define census_enabled census_enabled_import +typedef census_context *(*census_context_create_type)(const census_context *base, const census_tag *tags, int ntags, census_context_status const **status); +extern census_context_create_type census_context_create_import; +#define census_context_create census_context_create_import +typedef void(*census_context_destroy_type)(census_context *context); +extern census_context_destroy_type census_context_destroy_import; +#define census_context_destroy census_context_destroy_import +typedef const census_context_status *(*census_context_get_status_type)(const census_context *context); +extern census_context_get_status_type census_context_get_status_import; +#define census_context_get_status census_context_get_status_import +typedef void(*census_context_initialize_iterator_type)(const census_context *context, census_context_iterator *iterator); +extern census_context_initialize_iterator_type census_context_initialize_iterator_import; +#define census_context_initialize_iterator census_context_initialize_iterator_import +typedef int(*census_context_next_tag_type)(census_context_iterator *iterator, census_tag *tag); +extern census_context_next_tag_type census_context_next_tag_import; +#define census_context_next_tag census_context_next_tag_import +typedef int(*census_context_get_tag_type)(const census_context *context, const char *key, census_tag *tag); +extern census_context_get_tag_type census_context_get_tag_import; +#define census_context_get_tag census_context_get_tag_import +typedef char *(*census_context_encode_type)(const census_context *context, char *buffer, size_t buf_size, size_t *print_buf_size, size_t *bin_buf_size); +extern census_context_encode_type census_context_encode_import; +#define census_context_encode census_context_encode_import +typedef census_context *(*census_context_decode_type)(const char *buffer, size_t size, const char *bin_buffer, size_t bin_size); +extern census_context_decode_type census_context_decode_import; +#define census_context_decode census_context_decode_import +typedef int(*census_trace_mask_type)(const census_context *context); +extern census_trace_mask_type census_trace_mask_import; +#define census_trace_mask census_trace_mask_import +typedef void(*census_set_trace_mask_type)(int trace_mask); +extern census_set_trace_mask_type census_set_trace_mask_import; +#define census_set_trace_mask census_set_trace_mask_import +typedef census_timestamp(*census_start_rpc_op_timestamp_type)(void); +extern census_start_rpc_op_timestamp_type census_start_rpc_op_timestamp_import; +#define census_start_rpc_op_timestamp census_start_rpc_op_timestamp_import +typedef census_context *(*census_start_client_rpc_op_type)(const census_context *context, int64_t rpc_name_id, const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask, const census_timestamp *start_time); +extern census_start_client_rpc_op_type census_start_client_rpc_op_import; +#define census_start_client_rpc_op census_start_client_rpc_op_import +typedef void(*census_set_rpc_client_peer_type)(census_context *context, const char *peer); +extern census_set_rpc_client_peer_type census_set_rpc_client_peer_import; +#define census_set_rpc_client_peer census_set_rpc_client_peer_import +typedef census_context *(*census_start_server_rpc_op_type)(const char *buffer, int64_t rpc_name_id, const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask, census_timestamp *start_time); +extern census_start_server_rpc_op_type census_start_server_rpc_op_import; +#define census_start_server_rpc_op census_start_server_rpc_op_import +typedef census_context *(*census_start_op_type)(census_context *context, const char *family, const char *name, int trace_mask); +extern census_start_op_type census_start_op_import; +#define census_start_op census_start_op_import +typedef void(*census_end_op_type)(census_context *context, int status); +extern census_end_op_type census_end_op_import; +#define census_end_op census_end_op_import +typedef void(*census_trace_print_type)(census_context *context, uint32_t type, const char *buffer, size_t n); +extern census_trace_print_type census_trace_print_import; +#define census_trace_print census_trace_print_import +typedef int(*census_trace_scan_start_type)(int consume); +extern census_trace_scan_start_type census_trace_scan_start_import; +#define census_trace_scan_start census_trace_scan_start_import +typedef int(*census_get_trace_record_type)(census_trace_record *trace_record); +extern census_get_trace_record_type census_get_trace_record_import; +#define census_get_trace_record census_get_trace_record_import +typedef void(*census_trace_scan_end_type)(); +extern census_trace_scan_end_type census_trace_scan_end_import; +#define census_trace_scan_end census_trace_scan_end_import +typedef void(*census_record_values_type)(census_context *context, census_value *values, size_t nvalues); +extern census_record_values_type census_record_values_import; +#define census_record_values census_record_values_import +typedef census_view *(*census_view_create_type)(uint32_t metric_id, const census_context *tags, const census_aggregation *aggregations, size_t naggregations); +extern census_view_create_type census_view_create_import; +#define census_view_create census_view_create_import +typedef void(*census_view_delete_type)(census_view *view); +extern census_view_delete_type census_view_delete_import; +#define census_view_delete census_view_delete_import +typedef size_t(*census_view_metric_type)(const census_view *view); +extern census_view_metric_type census_view_metric_import; +#define census_view_metric census_view_metric_import +typedef size_t(*census_view_naggregations_type)(const census_view *view); +extern census_view_naggregations_type census_view_naggregations_import; +#define census_view_naggregations census_view_naggregations_import +typedef const census_context *(*census_view_tags_type)(const census_view *view); +extern census_view_tags_type census_view_tags_import; +#define census_view_tags census_view_tags_import +typedef const census_aggregation *(*census_view_aggregrations_type)(const census_view *view); +extern census_view_aggregrations_type census_view_aggregrations_import; +#define census_view_aggregrations census_view_aggregrations_import +typedef const census_view_data *(*census_view_get_data_type)(const census_view *view); +extern census_view_get_data_type census_view_get_data_import; +#define census_view_get_data census_view_get_data_import +typedef void(*census_view_reset_type)(census_view *view); +extern census_view_reset_type census_view_reset_import; +#define census_view_reset census_view_reset_import +typedef int(*grpc_compression_algorithm_parse_type)(const char *name, size_t name_length, grpc_compression_algorithm *algorithm); +extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import; +#define grpc_compression_algorithm_parse grpc_compression_algorithm_parse_import +typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, char **name); +extern grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import; +#define grpc_compression_algorithm_name grpc_compression_algorithm_name_import +typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level); +extern grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import; +#define grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level_import +typedef void(*grpc_compression_options_init_type)(grpc_compression_options *opts); +extern grpc_compression_options_init_type grpc_compression_options_init_import; +#define grpc_compression_options_init grpc_compression_options_init_import +typedef void(*grpc_compression_options_enable_algorithm_type)(grpc_compression_options *opts, grpc_compression_algorithm algorithm); +extern grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import; +#define grpc_compression_options_enable_algorithm grpc_compression_options_enable_algorithm_import +typedef void(*grpc_compression_options_disable_algorithm_type)(grpc_compression_options *opts, grpc_compression_algorithm algorithm); +extern grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import; +#define grpc_compression_options_disable_algorithm grpc_compression_options_disable_algorithm_import +typedef int(*grpc_compression_options_is_algorithm_enabled_type)(const grpc_compression_options *opts, grpc_compression_algorithm algorithm); +extern grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import; +#define grpc_compression_options_is_algorithm_enabled grpc_compression_options_is_algorithm_enabled_import +typedef void(*grpc_metadata_array_init_type)(grpc_metadata_array *array); +extern grpc_metadata_array_init_type grpc_metadata_array_init_import; +#define grpc_metadata_array_init grpc_metadata_array_init_import +typedef void(*grpc_metadata_array_destroy_type)(grpc_metadata_array *array); +extern grpc_metadata_array_destroy_type grpc_metadata_array_destroy_import; +#define grpc_metadata_array_destroy grpc_metadata_array_destroy_import +typedef void(*grpc_call_details_init_type)(grpc_call_details *details); +extern grpc_call_details_init_type grpc_call_details_init_import; +#define grpc_call_details_init grpc_call_details_init_import +typedef void(*grpc_call_details_destroy_type)(grpc_call_details *details); +extern grpc_call_details_destroy_type grpc_call_details_destroy_import; +#define grpc_call_details_destroy grpc_call_details_destroy_import +typedef void(*grpc_register_plugin_type)(void (*init)(void), void (*destroy)(void)); +extern grpc_register_plugin_type grpc_register_plugin_import; +#define grpc_register_plugin grpc_register_plugin_import +typedef void(*grpc_init_type)(void); +extern grpc_init_type grpc_init_import; +#define grpc_init grpc_init_import +typedef void(*grpc_shutdown_type)(void); +extern grpc_shutdown_type grpc_shutdown_import; +#define grpc_shutdown grpc_shutdown_import +typedef const char *(*grpc_version_string_type)(void); +extern grpc_version_string_type grpc_version_string_import; +#define grpc_version_string grpc_version_string_import +typedef grpc_completion_queue *(*grpc_completion_queue_create_type)(void *reserved); +extern grpc_completion_queue_create_type grpc_completion_queue_create_import; +#define grpc_completion_queue_create grpc_completion_queue_create_import +typedef grpc_event(*grpc_completion_queue_next_type)(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved); +extern grpc_completion_queue_next_type grpc_completion_queue_next_import; +#define grpc_completion_queue_next grpc_completion_queue_next_import +typedef grpc_event(*grpc_completion_queue_pluck_type)(grpc_completion_queue *cq, void *tag, gpr_timespec deadline, void *reserved); +extern grpc_completion_queue_pluck_type grpc_completion_queue_pluck_import; +#define grpc_completion_queue_pluck grpc_completion_queue_pluck_import +typedef void(*grpc_completion_queue_shutdown_type)(grpc_completion_queue *cq); +extern grpc_completion_queue_shutdown_type grpc_completion_queue_shutdown_import; +#define grpc_completion_queue_shutdown grpc_completion_queue_shutdown_import +typedef void(*grpc_completion_queue_destroy_type)(grpc_completion_queue *cq); +extern grpc_completion_queue_destroy_type grpc_completion_queue_destroy_import; +#define grpc_completion_queue_destroy grpc_completion_queue_destroy_import +typedef grpc_alarm *(*grpc_alarm_create_type)(grpc_completion_queue *cq, gpr_timespec deadline, void *tag); +extern grpc_alarm_create_type grpc_alarm_create_import; +#define grpc_alarm_create grpc_alarm_create_import +typedef void(*grpc_alarm_cancel_type)(grpc_alarm *alarm); +extern grpc_alarm_cancel_type grpc_alarm_cancel_import; +#define grpc_alarm_cancel grpc_alarm_cancel_import +typedef void(*grpc_alarm_destroy_type)(grpc_alarm *alarm); +extern grpc_alarm_destroy_type grpc_alarm_destroy_import; +#define grpc_alarm_destroy grpc_alarm_destroy_import +typedef grpc_connectivity_state(*grpc_channel_check_connectivity_state_type)(grpc_channel *channel, int try_to_connect); +extern grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import; +#define grpc_channel_check_connectivity_state grpc_channel_check_connectivity_state_import +typedef void(*grpc_channel_watch_connectivity_state_type)(grpc_channel *channel, grpc_connectivity_state last_observed_state, gpr_timespec deadline, grpc_completion_queue *cq, void *tag); +extern grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import; +#define grpc_channel_watch_connectivity_state grpc_channel_watch_connectivity_state_import +typedef grpc_call *(*grpc_channel_create_call_type)(grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *completion_queue, const char *method, const char *host, gpr_timespec deadline, void *reserved); +extern grpc_channel_create_call_type grpc_channel_create_call_import; +#define grpc_channel_create_call grpc_channel_create_call_import +typedef void(*grpc_channel_ping_type)(grpc_channel *channel, grpc_completion_queue *cq, void *tag, void *reserved); +extern grpc_channel_ping_type grpc_channel_ping_import; +#define grpc_channel_ping grpc_channel_ping_import +typedef void *(*grpc_channel_register_call_type)(grpc_channel *channel, const char *method, const char *host, void *reserved); +extern grpc_channel_register_call_type grpc_channel_register_call_import; +#define grpc_channel_register_call grpc_channel_register_call_import +typedef grpc_call *(*grpc_channel_create_registered_call_type)(grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *completion_queue, void *registered_call_handle, gpr_timespec deadline, void *reserved); +extern grpc_channel_create_registered_call_type grpc_channel_create_registered_call_import; +#define grpc_channel_create_registered_call grpc_channel_create_registered_call_import +typedef grpc_call_error(*grpc_call_start_batch_type)(grpc_call *call, const grpc_op *ops, size_t nops, void *tag, void *reserved); +extern grpc_call_start_batch_type grpc_call_start_batch_import; +#define grpc_call_start_batch grpc_call_start_batch_import +typedef char *(*grpc_call_get_peer_type)(grpc_call *call); +extern grpc_call_get_peer_type grpc_call_get_peer_import; +#define grpc_call_get_peer grpc_call_get_peer_import +typedef void(*grpc_census_call_set_context_type)(grpc_call *call, struct census_context *context); +extern grpc_census_call_set_context_type grpc_census_call_set_context_import; +#define grpc_census_call_set_context grpc_census_call_set_context_import +typedef struct census_context *(*grpc_census_call_get_context_type)(grpc_call *call); +extern grpc_census_call_get_context_type grpc_census_call_get_context_import; +#define grpc_census_call_get_context grpc_census_call_get_context_import +typedef char *(*grpc_channel_get_target_type)(grpc_channel *channel); +extern grpc_channel_get_target_type grpc_channel_get_target_import; +#define grpc_channel_get_target grpc_channel_get_target_import +typedef grpc_channel *(*grpc_insecure_channel_create_type)(const char *target, const grpc_channel_args *args, void *reserved); +extern grpc_insecure_channel_create_type grpc_insecure_channel_create_import; +#define grpc_insecure_channel_create grpc_insecure_channel_create_import +typedef grpc_channel *(*grpc_lame_client_channel_create_type)(const char *target, grpc_status_code error_code, const char *error_message); +extern grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import; +#define grpc_lame_client_channel_create grpc_lame_client_channel_create_import +typedef void(*grpc_channel_destroy_type)(grpc_channel *channel); +extern grpc_channel_destroy_type grpc_channel_destroy_import; +#define grpc_channel_destroy grpc_channel_destroy_import +typedef grpc_call_error(*grpc_call_cancel_type)(grpc_call *call, void *reserved); +extern grpc_call_cancel_type grpc_call_cancel_import; +#define grpc_call_cancel grpc_call_cancel_import +typedef grpc_call_error(*grpc_call_cancel_with_status_type)(grpc_call *call, grpc_status_code status, const char *description, void *reserved); +extern grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import; +#define grpc_call_cancel_with_status grpc_call_cancel_with_status_import +typedef void(*grpc_call_destroy_type)(grpc_call *call); +extern grpc_call_destroy_type grpc_call_destroy_import; +#define grpc_call_destroy grpc_call_destroy_import +typedef grpc_call_error(*grpc_server_request_call_type)(grpc_server *server, grpc_call **call, grpc_call_details *details, grpc_metadata_array *request_metadata, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new); +extern grpc_server_request_call_type grpc_server_request_call_import; +#define grpc_server_request_call grpc_server_request_call_import +typedef void *(*grpc_server_register_method_type)(grpc_server *server, const char *method, const char *host); +extern grpc_server_register_method_type grpc_server_register_method_import; +#define grpc_server_register_method grpc_server_register_method_import +typedef grpc_call_error(*grpc_server_request_registered_call_type)(grpc_server *server, void *registered_method, grpc_call **call, gpr_timespec *deadline, grpc_metadata_array *request_metadata, grpc_byte_buffer **optional_payload, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new); +extern grpc_server_request_registered_call_type grpc_server_request_registered_call_import; +#define grpc_server_request_registered_call grpc_server_request_registered_call_import +typedef grpc_server *(*grpc_server_create_type)(const grpc_channel_args *args, void *reserved); +extern grpc_server_create_type grpc_server_create_import; +#define grpc_server_create grpc_server_create_import +typedef void(*grpc_server_register_completion_queue_type)(grpc_server *server, grpc_completion_queue *cq, void *reserved); +extern grpc_server_register_completion_queue_type grpc_server_register_completion_queue_import; +#define grpc_server_register_completion_queue grpc_server_register_completion_queue_import +typedef int(*grpc_server_add_insecure_http2_port_type)(grpc_server *server, const char *addr); +extern grpc_server_add_insecure_http2_port_type grpc_server_add_insecure_http2_port_import; +#define grpc_server_add_insecure_http2_port grpc_server_add_insecure_http2_port_import +typedef void(*grpc_server_start_type)(grpc_server *server); +extern grpc_server_start_type grpc_server_start_import; +#define grpc_server_start grpc_server_start_import +typedef void(*grpc_server_shutdown_and_notify_type)(grpc_server *server, grpc_completion_queue *cq, void *tag); +extern grpc_server_shutdown_and_notify_type grpc_server_shutdown_and_notify_import; +#define grpc_server_shutdown_and_notify grpc_server_shutdown_and_notify_import +typedef void(*grpc_server_cancel_all_calls_type)(grpc_server *server); +extern grpc_server_cancel_all_calls_type grpc_server_cancel_all_calls_import; +#define grpc_server_cancel_all_calls grpc_server_cancel_all_calls_import +typedef void(*grpc_server_destroy_type)(grpc_server *server); +extern grpc_server_destroy_type grpc_server_destroy_import; +#define grpc_server_destroy grpc_server_destroy_import +typedef int(*grpc_tracer_set_enabled_type)(const char *name, int enabled); +extern grpc_tracer_set_enabled_type grpc_tracer_set_enabled_import; +#define grpc_tracer_set_enabled grpc_tracer_set_enabled_import +typedef int(*grpc_header_key_is_legal_type)(const char *key, size_t length); +extern grpc_header_key_is_legal_type grpc_header_key_is_legal_import; +#define grpc_header_key_is_legal grpc_header_key_is_legal_import +typedef int(*grpc_header_nonbin_value_is_legal_type)(const char *value, size_t length); +extern grpc_header_nonbin_value_is_legal_type grpc_header_nonbin_value_is_legal_import; +#define grpc_header_nonbin_value_is_legal grpc_header_nonbin_value_is_legal_import +typedef int(*grpc_is_binary_header_type)(const char *key, size_t length); +extern grpc_is_binary_header_type grpc_is_binary_header_import; +#define grpc_is_binary_header grpc_is_binary_header_import +typedef const grpc_auth_property *(*grpc_auth_property_iterator_next_type)(grpc_auth_property_iterator *it); +extern grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import; +#define grpc_auth_property_iterator_next grpc_auth_property_iterator_next_import +typedef grpc_auth_property_iterator(*grpc_auth_context_property_iterator_type)(const grpc_auth_context *ctx); +extern grpc_auth_context_property_iterator_type grpc_auth_context_property_iterator_import; +#define grpc_auth_context_property_iterator grpc_auth_context_property_iterator_import +typedef grpc_auth_property_iterator(*grpc_auth_context_peer_identity_type)(const grpc_auth_context *ctx); +extern grpc_auth_context_peer_identity_type grpc_auth_context_peer_identity_import; +#define grpc_auth_context_peer_identity grpc_auth_context_peer_identity_import +typedef grpc_auth_property_iterator(*grpc_auth_context_find_properties_by_name_type)(const grpc_auth_context *ctx, const char *name); +extern grpc_auth_context_find_properties_by_name_type grpc_auth_context_find_properties_by_name_import; +#define grpc_auth_context_find_properties_by_name grpc_auth_context_find_properties_by_name_import +typedef const char *(*grpc_auth_context_peer_identity_property_name_type)(const grpc_auth_context *ctx); +extern grpc_auth_context_peer_identity_property_name_type grpc_auth_context_peer_identity_property_name_import; +#define grpc_auth_context_peer_identity_property_name grpc_auth_context_peer_identity_property_name_import +typedef int(*grpc_auth_context_peer_is_authenticated_type)(const grpc_auth_context *ctx); +extern grpc_auth_context_peer_is_authenticated_type grpc_auth_context_peer_is_authenticated_import; +#define grpc_auth_context_peer_is_authenticated grpc_auth_context_peer_is_authenticated_import +typedef grpc_auth_context *(*grpc_call_auth_context_type)(grpc_call *call); +extern grpc_call_auth_context_type grpc_call_auth_context_import; +#define grpc_call_auth_context grpc_call_auth_context_import +typedef void(*grpc_auth_context_release_type)(grpc_auth_context *context); +extern grpc_auth_context_release_type grpc_auth_context_release_import; +#define grpc_auth_context_release grpc_auth_context_release_import +typedef void(*grpc_auth_context_add_property_type)(grpc_auth_context *ctx, const char *name, const char *value, size_t value_length); +extern grpc_auth_context_add_property_type grpc_auth_context_add_property_import; +#define grpc_auth_context_add_property grpc_auth_context_add_property_import +typedef void(*grpc_auth_context_add_cstring_property_type)(grpc_auth_context *ctx, const char *name, const char *value); +extern grpc_auth_context_add_cstring_property_type grpc_auth_context_add_cstring_property_import; +#define grpc_auth_context_add_cstring_property grpc_auth_context_add_cstring_property_import +typedef int(*grpc_auth_context_set_peer_identity_property_name_type)(grpc_auth_context *ctx, const char *name); +extern grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import; +#define grpc_auth_context_set_peer_identity_property_name grpc_auth_context_set_peer_identity_property_name_import +typedef void(*grpc_channel_credentials_release_type)(grpc_channel_credentials *creds); +extern grpc_channel_credentials_release_type grpc_channel_credentials_release_import; +#define grpc_channel_credentials_release grpc_channel_credentials_release_import +typedef grpc_channel_credentials *(*grpc_google_default_credentials_create_type)(void); +extern grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import; +#define grpc_google_default_credentials_create grpc_google_default_credentials_create_import +typedef grpc_channel_credentials *(*grpc_ssl_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, void *reserved); +extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; +#define grpc_ssl_credentials_create grpc_ssl_credentials_create_import +typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials *creds); +extern grpc_call_credentials_release_type grpc_call_credentials_release_import; +#define grpc_call_credentials_release grpc_call_credentials_release_import +typedef grpc_channel_credentials *(*grpc_composite_channel_credentials_create_type)(grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds, void *reserved); +extern grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import; +#define grpc_composite_channel_credentials_create grpc_composite_channel_credentials_create_import +typedef grpc_call_credentials *(*grpc_composite_call_credentials_create_type)(grpc_call_credentials *creds1, grpc_call_credentials *creds2, void *reserved); +extern grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import; +#define grpc_composite_call_credentials_create grpc_composite_call_credentials_create_import +typedef grpc_call_credentials *(*grpc_google_compute_engine_credentials_create_type)(void *reserved); +extern grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import; +#define grpc_google_compute_engine_credentials_create grpc_google_compute_engine_credentials_create_import +typedef gpr_timespec(*grpc_max_auth_token_lifetime_type)(); +extern grpc_max_auth_token_lifetime_type grpc_max_auth_token_lifetime_import; +#define grpc_max_auth_token_lifetime grpc_max_auth_token_lifetime_import +typedef grpc_call_credentials *(*grpc_service_account_jwt_access_credentials_create_type)(const char *json_key, gpr_timespec token_lifetime, void *reserved); +extern grpc_service_account_jwt_access_credentials_create_type grpc_service_account_jwt_access_credentials_create_import; +#define grpc_service_account_jwt_access_credentials_create grpc_service_account_jwt_access_credentials_create_import +typedef grpc_call_credentials *(*grpc_google_refresh_token_credentials_create_type)(const char *json_refresh_token, void *reserved); +extern grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_credentials_create_import; +#define grpc_google_refresh_token_credentials_create grpc_google_refresh_token_credentials_create_import +typedef grpc_call_credentials *(*grpc_access_token_credentials_create_type)(const char *access_token, void *reserved); +extern grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import; +#define grpc_access_token_credentials_create grpc_access_token_credentials_create_import +typedef grpc_call_credentials *(*grpc_google_iam_credentials_create_type)(const char *authorization_token, const char *authority_selector, void *reserved); +extern grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import; +#define grpc_google_iam_credentials_create grpc_google_iam_credentials_create_import +typedef grpc_call_credentials *(*grpc_metadata_credentials_create_from_plugin_type)(grpc_metadata_credentials_plugin plugin, void *reserved); +extern grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import; +#define grpc_metadata_credentials_create_from_plugin grpc_metadata_credentials_create_from_plugin_import +typedef grpc_channel *(*grpc_secure_channel_create_type)(grpc_channel_credentials *creds, const char *target, const grpc_channel_args *args, void *reserved); +extern grpc_secure_channel_create_type grpc_secure_channel_create_import; +#define grpc_secure_channel_create grpc_secure_channel_create_import +typedef void(*grpc_server_credentials_release_type)(grpc_server_credentials *creds); +extern grpc_server_credentials_release_type grpc_server_credentials_release_import; +#define grpc_server_credentials_release grpc_server_credentials_release_import +typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void *reserved); +extern grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; +#define grpc_ssl_server_credentials_create grpc_ssl_server_credentials_create_import +typedef int(*grpc_server_add_secure_http2_port_type)(grpc_server *server, const char *addr, grpc_server_credentials *creds); +extern grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import; +#define grpc_server_add_secure_http2_port grpc_server_add_secure_http2_port_import +typedef grpc_call_error(*grpc_call_set_credentials_type)(grpc_call *call, grpc_call_credentials *creds); +extern grpc_call_set_credentials_type grpc_call_set_credentials_import; +#define grpc_call_set_credentials grpc_call_set_credentials_import +typedef void(*grpc_server_credentials_set_auth_metadata_processor_type)(grpc_server_credentials *creds, grpc_auth_metadata_processor processor); +extern grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; +#define grpc_server_credentials_set_auth_metadata_processor grpc_server_credentials_set_auth_metadata_processor_import +typedef void *(*gpr_malloc_type)(size_t size); +extern gpr_malloc_type gpr_malloc_import; +#define gpr_malloc gpr_malloc_import +typedef void(*gpr_free_type)(void *ptr); +extern gpr_free_type gpr_free_import; +#define gpr_free gpr_free_import +typedef void *(*gpr_realloc_type)(void *p, size_t size); +extern gpr_realloc_type gpr_realloc_import; +#define gpr_realloc gpr_realloc_import +typedef void *(*gpr_malloc_aligned_type)(size_t size, size_t alignment_log); +extern gpr_malloc_aligned_type gpr_malloc_aligned_import; +#define gpr_malloc_aligned gpr_malloc_aligned_import +typedef void(*gpr_free_aligned_type)(void *ptr); +extern gpr_free_aligned_type gpr_free_aligned_import; +#define gpr_free_aligned gpr_free_aligned_import +typedef void(*gpr_set_allocation_functions_type)(gpr_allocation_functions functions); +extern gpr_set_allocation_functions_type gpr_set_allocation_functions_import; +#define gpr_set_allocation_functions gpr_set_allocation_functions_import +typedef gpr_allocation_functions(*gpr_get_allocation_functions_type)(); +extern gpr_get_allocation_functions_type gpr_get_allocation_functions_import; +#define gpr_get_allocation_functions gpr_get_allocation_functions_import +typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_create_type)(gpr_slice *slices, size_t nslices); +extern grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import; +#define grpc_raw_byte_buffer_create grpc_raw_byte_buffer_create_import +typedef grpc_byte_buffer *(*grpc_raw_compressed_byte_buffer_create_type)(gpr_slice *slices, size_t nslices, grpc_compression_algorithm compression); +extern grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import; +#define grpc_raw_compressed_byte_buffer_create grpc_raw_compressed_byte_buffer_create_import +typedef grpc_byte_buffer *(*grpc_byte_buffer_copy_type)(grpc_byte_buffer *bb); +extern grpc_byte_buffer_copy_type grpc_byte_buffer_copy_import; +#define grpc_byte_buffer_copy grpc_byte_buffer_copy_import +typedef size_t(*grpc_byte_buffer_length_type)(grpc_byte_buffer *bb); +extern grpc_byte_buffer_length_type grpc_byte_buffer_length_import; +#define grpc_byte_buffer_length grpc_byte_buffer_length_import +typedef void(*grpc_byte_buffer_destroy_type)(grpc_byte_buffer *byte_buffer); +extern grpc_byte_buffer_destroy_type grpc_byte_buffer_destroy_import; +#define grpc_byte_buffer_destroy grpc_byte_buffer_destroy_import +typedef void(*grpc_byte_buffer_reader_init_type)(grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer); +extern grpc_byte_buffer_reader_init_type grpc_byte_buffer_reader_init_import; +#define grpc_byte_buffer_reader_init grpc_byte_buffer_reader_init_import +typedef void(*grpc_byte_buffer_reader_destroy_type)(grpc_byte_buffer_reader *reader); +extern grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import; +#define grpc_byte_buffer_reader_destroy grpc_byte_buffer_reader_destroy_import +typedef int(*grpc_byte_buffer_reader_next_type)(grpc_byte_buffer_reader *reader, gpr_slice *slice); +extern grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import; +#define grpc_byte_buffer_reader_next grpc_byte_buffer_reader_next_import +typedef gpr_slice(*grpc_byte_buffer_reader_readall_type)(grpc_byte_buffer_reader *reader); +extern grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import; +#define grpc_byte_buffer_reader_readall grpc_byte_buffer_reader_readall_import +typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader *reader); +extern grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import; +#define grpc_raw_byte_buffer_from_reader grpc_raw_byte_buffer_from_reader_import +typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...); +extern gpr_log_type gpr_log_import; +#define gpr_log gpr_log_import +typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message); +extern gpr_log_message_type gpr_log_message_import; +#define gpr_log_message gpr_log_message_import +typedef void(*gpr_set_log_function_type)(gpr_log_func func); +extern gpr_set_log_function_type gpr_set_log_function_import; +#define gpr_set_log_function gpr_set_log_function_import +typedef gpr_slice(*gpr_slice_ref_type)(gpr_slice s); +extern gpr_slice_ref_type gpr_slice_ref_import; +#define gpr_slice_ref gpr_slice_ref_import +typedef void(*gpr_slice_unref_type)(gpr_slice s); +extern gpr_slice_unref_type gpr_slice_unref_import; +#define gpr_slice_unref gpr_slice_unref_import +typedef gpr_slice(*gpr_slice_new_type)(void *p, size_t len, void (*destroy)(void *)); +extern gpr_slice_new_type gpr_slice_new_import; +#define gpr_slice_new gpr_slice_new_import +typedef gpr_slice(*gpr_slice_new_with_len_type)(void *p, size_t len, void (*destroy)(void *, size_t)); +extern gpr_slice_new_with_len_type gpr_slice_new_with_len_import; +#define gpr_slice_new_with_len gpr_slice_new_with_len_import +typedef gpr_slice(*gpr_slice_malloc_type)(size_t length); +extern gpr_slice_malloc_type gpr_slice_malloc_import; +#define gpr_slice_malloc gpr_slice_malloc_import +typedef gpr_slice(*gpr_slice_from_copied_string_type)(const char *source); +extern gpr_slice_from_copied_string_type gpr_slice_from_copied_string_import; +#define gpr_slice_from_copied_string gpr_slice_from_copied_string_import +typedef gpr_slice(*gpr_slice_from_copied_buffer_type)(const char *source, size_t len); +extern gpr_slice_from_copied_buffer_type gpr_slice_from_copied_buffer_import; +#define gpr_slice_from_copied_buffer gpr_slice_from_copied_buffer_import +typedef gpr_slice(*gpr_slice_from_static_string_type)(const char *source); +extern gpr_slice_from_static_string_type gpr_slice_from_static_string_import; +#define gpr_slice_from_static_string gpr_slice_from_static_string_import +typedef gpr_slice(*gpr_slice_sub_type)(gpr_slice s, size_t begin, size_t end); +extern gpr_slice_sub_type gpr_slice_sub_import; +#define gpr_slice_sub gpr_slice_sub_import +typedef gpr_slice(*gpr_slice_sub_no_ref_type)(gpr_slice s, size_t begin, size_t end); +extern gpr_slice_sub_no_ref_type gpr_slice_sub_no_ref_import; +#define gpr_slice_sub_no_ref gpr_slice_sub_no_ref_import +typedef gpr_slice(*gpr_slice_split_tail_type)(gpr_slice *s, size_t split); +extern gpr_slice_split_tail_type gpr_slice_split_tail_import; +#define gpr_slice_split_tail gpr_slice_split_tail_import +typedef gpr_slice(*gpr_slice_split_head_type)(gpr_slice *s, size_t split); +extern gpr_slice_split_head_type gpr_slice_split_head_import; +#define gpr_slice_split_head gpr_slice_split_head_import +typedef gpr_slice(*gpr_empty_slice_type)(void); +extern gpr_empty_slice_type gpr_empty_slice_import; +#define gpr_empty_slice gpr_empty_slice_import +typedef int(*gpr_slice_cmp_type)(gpr_slice a, gpr_slice b); +extern gpr_slice_cmp_type gpr_slice_cmp_import; +#define gpr_slice_cmp gpr_slice_cmp_import +typedef int(*gpr_slice_str_cmp_type)(gpr_slice a, const char *b); +extern gpr_slice_str_cmp_type gpr_slice_str_cmp_import; +#define gpr_slice_str_cmp gpr_slice_str_cmp_import +typedef void(*gpr_slice_buffer_init_type)(gpr_slice_buffer *sb); +extern gpr_slice_buffer_init_type gpr_slice_buffer_init_import; +#define gpr_slice_buffer_init gpr_slice_buffer_init_import +typedef void(*gpr_slice_buffer_destroy_type)(gpr_slice_buffer *sb); +extern gpr_slice_buffer_destroy_type gpr_slice_buffer_destroy_import; +#define gpr_slice_buffer_destroy gpr_slice_buffer_destroy_import +typedef void(*gpr_slice_buffer_add_type)(gpr_slice_buffer *sb, gpr_slice slice); +extern gpr_slice_buffer_add_type gpr_slice_buffer_add_import; +#define gpr_slice_buffer_add gpr_slice_buffer_add_import +typedef size_t(*gpr_slice_buffer_add_indexed_type)(gpr_slice_buffer *sb, gpr_slice slice); +extern gpr_slice_buffer_add_indexed_type gpr_slice_buffer_add_indexed_import; +#define gpr_slice_buffer_add_indexed gpr_slice_buffer_add_indexed_import +typedef void(*gpr_slice_buffer_addn_type)(gpr_slice_buffer *sb, gpr_slice *slices, size_t n); +extern gpr_slice_buffer_addn_type gpr_slice_buffer_addn_import; +#define gpr_slice_buffer_addn gpr_slice_buffer_addn_import +typedef uint8_t *(*gpr_slice_buffer_tiny_add_type)(gpr_slice_buffer *sb, size_t len); +extern gpr_slice_buffer_tiny_add_type gpr_slice_buffer_tiny_add_import; +#define gpr_slice_buffer_tiny_add gpr_slice_buffer_tiny_add_import +typedef void(*gpr_slice_buffer_pop_type)(gpr_slice_buffer *sb); +extern gpr_slice_buffer_pop_type gpr_slice_buffer_pop_import; +#define gpr_slice_buffer_pop gpr_slice_buffer_pop_import +typedef void(*gpr_slice_buffer_reset_and_unref_type)(gpr_slice_buffer *sb); +extern gpr_slice_buffer_reset_and_unref_type gpr_slice_buffer_reset_and_unref_import; +#define gpr_slice_buffer_reset_and_unref gpr_slice_buffer_reset_and_unref_import +typedef void(*gpr_slice_buffer_swap_type)(gpr_slice_buffer *a, gpr_slice_buffer *b); +extern gpr_slice_buffer_swap_type gpr_slice_buffer_swap_import; +#define gpr_slice_buffer_swap gpr_slice_buffer_swap_import +typedef void(*gpr_slice_buffer_move_into_type)(gpr_slice_buffer *src, gpr_slice_buffer *dst); +extern gpr_slice_buffer_move_into_type gpr_slice_buffer_move_into_import; +#define gpr_slice_buffer_move_into gpr_slice_buffer_move_into_import +typedef void(*gpr_slice_buffer_trim_end_type)(gpr_slice_buffer *src, size_t n, gpr_slice_buffer *garbage); +extern gpr_slice_buffer_trim_end_type gpr_slice_buffer_trim_end_import; +#define gpr_slice_buffer_trim_end gpr_slice_buffer_trim_end_import +typedef void(*gpr_slice_buffer_move_first_type)(gpr_slice_buffer *src, size_t n, gpr_slice_buffer *dst); +extern gpr_slice_buffer_move_first_type gpr_slice_buffer_move_first_import; +#define gpr_slice_buffer_move_first gpr_slice_buffer_move_first_import +typedef gpr_slice(*gpr_slice_buffer_take_first_type)(gpr_slice_buffer *src); +extern gpr_slice_buffer_take_first_type gpr_slice_buffer_take_first_import; +#define gpr_slice_buffer_take_first gpr_slice_buffer_take_first_import +typedef void(*gpr_mu_init_type)(gpr_mu *mu); +extern gpr_mu_init_type gpr_mu_init_import; +#define gpr_mu_init gpr_mu_init_import +typedef void(*gpr_mu_destroy_type)(gpr_mu *mu); +extern gpr_mu_destroy_type gpr_mu_destroy_import; +#define gpr_mu_destroy gpr_mu_destroy_import +typedef void(*gpr_mu_lock_type)(gpr_mu *mu); +extern gpr_mu_lock_type gpr_mu_lock_import; +#define gpr_mu_lock gpr_mu_lock_import +typedef void(*gpr_mu_unlock_type)(gpr_mu *mu); +extern gpr_mu_unlock_type gpr_mu_unlock_import; +#define gpr_mu_unlock gpr_mu_unlock_import +typedef int(*gpr_mu_trylock_type)(gpr_mu *mu); +extern gpr_mu_trylock_type gpr_mu_trylock_import; +#define gpr_mu_trylock gpr_mu_trylock_import +typedef void(*gpr_cv_init_type)(gpr_cv *cv); +extern gpr_cv_init_type gpr_cv_init_import; +#define gpr_cv_init gpr_cv_init_import +typedef void(*gpr_cv_destroy_type)(gpr_cv *cv); +extern gpr_cv_destroy_type gpr_cv_destroy_import; +#define gpr_cv_destroy gpr_cv_destroy_import +typedef int(*gpr_cv_wait_type)(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline); +extern gpr_cv_wait_type gpr_cv_wait_import; +#define gpr_cv_wait gpr_cv_wait_import +typedef void(*gpr_cv_signal_type)(gpr_cv *cv); +extern gpr_cv_signal_type gpr_cv_signal_import; +#define gpr_cv_signal gpr_cv_signal_import +typedef void(*gpr_cv_broadcast_type)(gpr_cv *cv); +extern gpr_cv_broadcast_type gpr_cv_broadcast_import; +#define gpr_cv_broadcast gpr_cv_broadcast_import +typedef void(*gpr_once_init_type)(gpr_once *once, void (*init_routine)(void)); +extern gpr_once_init_type gpr_once_init_import; +#define gpr_once_init gpr_once_init_import +typedef void(*gpr_event_init_type)(gpr_event *ev); +extern gpr_event_init_type gpr_event_init_import; +#define gpr_event_init gpr_event_init_import +typedef void(*gpr_event_set_type)(gpr_event *ev, void *value); +extern gpr_event_set_type gpr_event_set_import; +#define gpr_event_set gpr_event_set_import +typedef void *(*gpr_event_get_type)(gpr_event *ev); +extern gpr_event_get_type gpr_event_get_import; +#define gpr_event_get gpr_event_get_import +typedef void *(*gpr_event_wait_type)(gpr_event *ev, gpr_timespec abs_deadline); +extern gpr_event_wait_type gpr_event_wait_import; +#define gpr_event_wait gpr_event_wait_import +typedef void(*gpr_ref_init_type)(gpr_refcount *r, int n); +extern gpr_ref_init_type gpr_ref_init_import; +#define gpr_ref_init gpr_ref_init_import +typedef void(*gpr_ref_type)(gpr_refcount *r); +extern gpr_ref_type gpr_ref_import; +#define gpr_ref gpr_ref_import +typedef void(*gpr_refn_type)(gpr_refcount *r, int n); +extern gpr_refn_type gpr_refn_import; +#define gpr_refn gpr_refn_import +typedef int(*gpr_unref_type)(gpr_refcount *r); +extern gpr_unref_type gpr_unref_import; +#define gpr_unref gpr_unref_import +typedef void(*gpr_stats_init_type)(gpr_stats_counter *c, intptr_t n); +extern gpr_stats_init_type gpr_stats_init_import; +#define gpr_stats_init gpr_stats_init_import +typedef void(*gpr_stats_inc_type)(gpr_stats_counter *c, intptr_t inc); +extern gpr_stats_inc_type gpr_stats_inc_import; +#define gpr_stats_inc gpr_stats_inc_import +typedef intptr_t(*gpr_stats_read_type)(const gpr_stats_counter *c); +extern gpr_stats_read_type gpr_stats_read_import; +#define gpr_stats_read gpr_stats_read_import +typedef gpr_timespec(*gpr_time_0_type)(gpr_clock_type type); +extern gpr_time_0_type gpr_time_0_import; +#define gpr_time_0 gpr_time_0_import +typedef gpr_timespec(*gpr_inf_future_type)(gpr_clock_type type); +extern gpr_inf_future_type gpr_inf_future_import; +#define gpr_inf_future gpr_inf_future_import +typedef gpr_timespec(*gpr_inf_past_type)(gpr_clock_type type); +extern gpr_inf_past_type gpr_inf_past_import; +#define gpr_inf_past gpr_inf_past_import +typedef void(*gpr_time_init_type)(void); +extern gpr_time_init_type gpr_time_init_import; +#define gpr_time_init gpr_time_init_import +typedef gpr_timespec(*gpr_now_type)(gpr_clock_type clock); +extern gpr_now_type gpr_now_import; +#define gpr_now gpr_now_import +typedef gpr_timespec(*gpr_convert_clock_type_type)(gpr_timespec t, gpr_clock_type target_clock); +extern gpr_convert_clock_type_type gpr_convert_clock_type_import; +#define gpr_convert_clock_type gpr_convert_clock_type_import +typedef int(*gpr_time_cmp_type)(gpr_timespec a, gpr_timespec b); +extern gpr_time_cmp_type gpr_time_cmp_import; +#define gpr_time_cmp gpr_time_cmp_import +typedef gpr_timespec(*gpr_time_max_type)(gpr_timespec a, gpr_timespec b); +extern gpr_time_max_type gpr_time_max_import; +#define gpr_time_max gpr_time_max_import +typedef gpr_timespec(*gpr_time_min_type)(gpr_timespec a, gpr_timespec b); +extern gpr_time_min_type gpr_time_min_import; +#define gpr_time_min gpr_time_min_import +typedef gpr_timespec(*gpr_time_add_type)(gpr_timespec a, gpr_timespec b); +extern gpr_time_add_type gpr_time_add_import; +#define gpr_time_add gpr_time_add_import +typedef gpr_timespec(*gpr_time_sub_type)(gpr_timespec a, gpr_timespec b); +extern gpr_time_sub_type gpr_time_sub_import; +#define gpr_time_sub gpr_time_sub_import +typedef gpr_timespec(*gpr_time_from_micros_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_micros_type gpr_time_from_micros_import; +#define gpr_time_from_micros gpr_time_from_micros_import +typedef gpr_timespec(*gpr_time_from_nanos_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_nanos_type gpr_time_from_nanos_import; +#define gpr_time_from_nanos gpr_time_from_nanos_import +typedef gpr_timespec(*gpr_time_from_millis_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_millis_type gpr_time_from_millis_import; +#define gpr_time_from_millis gpr_time_from_millis_import +typedef gpr_timespec(*gpr_time_from_seconds_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_seconds_type gpr_time_from_seconds_import; +#define gpr_time_from_seconds gpr_time_from_seconds_import +typedef gpr_timespec(*gpr_time_from_minutes_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_minutes_type gpr_time_from_minutes_import; +#define gpr_time_from_minutes gpr_time_from_minutes_import +typedef gpr_timespec(*gpr_time_from_hours_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_hours_type gpr_time_from_hours_import; +#define gpr_time_from_hours gpr_time_from_hours_import +typedef int32_t(*gpr_time_to_millis_type)(gpr_timespec timespec); +extern gpr_time_to_millis_type gpr_time_to_millis_import; +#define gpr_time_to_millis gpr_time_to_millis_import +typedef int(*gpr_time_similar_type)(gpr_timespec a, gpr_timespec b, gpr_timespec threshold); +extern gpr_time_similar_type gpr_time_similar_import; +#define gpr_time_similar gpr_time_similar_import +typedef void(*gpr_sleep_until_type)(gpr_timespec until); +extern gpr_sleep_until_type gpr_sleep_until_import; +#define gpr_sleep_until gpr_sleep_until_import +typedef double(*gpr_timespec_to_micros_type)(gpr_timespec t); +extern gpr_timespec_to_micros_type gpr_timespec_to_micros_import; +#define gpr_timespec_to_micros gpr_timespec_to_micros_import +typedef gpr_avl(*gpr_avl_create_type)(const gpr_avl_vtable *vtable); +extern gpr_avl_create_type gpr_avl_create_import; +#define gpr_avl_create gpr_avl_create_import +typedef gpr_avl(*gpr_avl_ref_type)(gpr_avl avl); +extern gpr_avl_ref_type gpr_avl_ref_import; +#define gpr_avl_ref gpr_avl_ref_import +typedef void(*gpr_avl_unref_type)(gpr_avl avl); +extern gpr_avl_unref_type gpr_avl_unref_import; +#define gpr_avl_unref gpr_avl_unref_import +typedef gpr_avl(*gpr_avl_add_type)(gpr_avl avl, void *key, void *value); +extern gpr_avl_add_type gpr_avl_add_import; +#define gpr_avl_add gpr_avl_add_import +typedef gpr_avl(*gpr_avl_remove_type)(gpr_avl avl, void *key); +extern gpr_avl_remove_type gpr_avl_remove_import; +#define gpr_avl_remove gpr_avl_remove_import +typedef void *(*gpr_avl_get_type)(gpr_avl avl, void *key); +extern gpr_avl_get_type gpr_avl_get_import; +#define gpr_avl_get gpr_avl_get_import +typedef gpr_cmdline *(*gpr_cmdline_create_type)(const char *description); +extern gpr_cmdline_create_type gpr_cmdline_create_import; +#define gpr_cmdline_create gpr_cmdline_create_import +typedef void(*gpr_cmdline_add_int_type)(gpr_cmdline *cl, const char *name, const char *help, int *value); +extern gpr_cmdline_add_int_type gpr_cmdline_add_int_import; +#define gpr_cmdline_add_int gpr_cmdline_add_int_import +typedef void(*gpr_cmdline_add_flag_type)(gpr_cmdline *cl, const char *name, const char *help, int *value); +extern gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import; +#define gpr_cmdline_add_flag gpr_cmdline_add_flag_import +typedef void(*gpr_cmdline_add_string_type)(gpr_cmdline *cl, const char *name, const char *help, char **value); +extern gpr_cmdline_add_string_type gpr_cmdline_add_string_import; +#define gpr_cmdline_add_string gpr_cmdline_add_string_import +typedef void(*gpr_cmdline_on_extra_arg_type)(gpr_cmdline *cl, const char *name, const char *help, void (*on_extra_arg)(void *user_data, const char *arg), void *user_data); +extern gpr_cmdline_on_extra_arg_type gpr_cmdline_on_extra_arg_import; +#define gpr_cmdline_on_extra_arg gpr_cmdline_on_extra_arg_import +typedef void(*gpr_cmdline_set_survive_failure_type)(gpr_cmdline *cl); +extern gpr_cmdline_set_survive_failure_type gpr_cmdline_set_survive_failure_import; +#define gpr_cmdline_set_survive_failure gpr_cmdline_set_survive_failure_import +typedef int(*gpr_cmdline_parse_type)(gpr_cmdline *cl, int argc, char **argv); +extern gpr_cmdline_parse_type gpr_cmdline_parse_import; +#define gpr_cmdline_parse gpr_cmdline_parse_import +typedef void(*gpr_cmdline_destroy_type)(gpr_cmdline *cl); +extern gpr_cmdline_destroy_type gpr_cmdline_destroy_import; +#define gpr_cmdline_destroy gpr_cmdline_destroy_import +typedef char *(*gpr_cmdline_usage_string_type)(gpr_cmdline *cl, const char *argv0); +extern gpr_cmdline_usage_string_type gpr_cmdline_usage_string_import; +#define gpr_cmdline_usage_string gpr_cmdline_usage_string_import +typedef unsigned(*gpr_cpu_num_cores_type)(void); +extern gpr_cpu_num_cores_type gpr_cpu_num_cores_import; +#define gpr_cpu_num_cores gpr_cpu_num_cores_import +typedef unsigned(*gpr_cpu_current_cpu_type)(void); +extern gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; +#define gpr_cpu_current_cpu gpr_cpu_current_cpu_import +typedef gpr_histogram *(*gpr_histogram_create_type)(double resolution, double max_bucket_start); +extern gpr_histogram_create_type gpr_histogram_create_import; +#define gpr_histogram_create gpr_histogram_create_import +typedef void(*gpr_histogram_destroy_type)(gpr_histogram *h); +extern gpr_histogram_destroy_type gpr_histogram_destroy_import; +#define gpr_histogram_destroy gpr_histogram_destroy_import +typedef void(*gpr_histogram_add_type)(gpr_histogram *h, double x); +extern gpr_histogram_add_type gpr_histogram_add_import; +#define gpr_histogram_add gpr_histogram_add_import +typedef int(*gpr_histogram_merge_type)(gpr_histogram *dst, const gpr_histogram *src); +extern gpr_histogram_merge_type gpr_histogram_merge_import; +#define gpr_histogram_merge gpr_histogram_merge_import +typedef double(*gpr_histogram_percentile_type)(gpr_histogram *histogram, double percentile); +extern gpr_histogram_percentile_type gpr_histogram_percentile_import; +#define gpr_histogram_percentile gpr_histogram_percentile_import +typedef double(*gpr_histogram_mean_type)(gpr_histogram *histogram); +extern gpr_histogram_mean_type gpr_histogram_mean_import; +#define gpr_histogram_mean gpr_histogram_mean_import +typedef double(*gpr_histogram_stddev_type)(gpr_histogram *histogram); +extern gpr_histogram_stddev_type gpr_histogram_stddev_import; +#define gpr_histogram_stddev gpr_histogram_stddev_import +typedef double(*gpr_histogram_variance_type)(gpr_histogram *histogram); +extern gpr_histogram_variance_type gpr_histogram_variance_import; +#define gpr_histogram_variance gpr_histogram_variance_import +typedef double(*gpr_histogram_maximum_type)(gpr_histogram *histogram); +extern gpr_histogram_maximum_type gpr_histogram_maximum_import; +#define gpr_histogram_maximum gpr_histogram_maximum_import +typedef double(*gpr_histogram_minimum_type)(gpr_histogram *histogram); +extern gpr_histogram_minimum_type gpr_histogram_minimum_import; +#define gpr_histogram_minimum gpr_histogram_minimum_import +typedef double(*gpr_histogram_count_type)(gpr_histogram *histogram); +extern gpr_histogram_count_type gpr_histogram_count_import; +#define gpr_histogram_count gpr_histogram_count_import +typedef double(*gpr_histogram_sum_type)(gpr_histogram *histogram); +extern gpr_histogram_sum_type gpr_histogram_sum_import; +#define gpr_histogram_sum gpr_histogram_sum_import +typedef double(*gpr_histogram_sum_of_squares_type)(gpr_histogram *histogram); +extern gpr_histogram_sum_of_squares_type gpr_histogram_sum_of_squares_import; +#define gpr_histogram_sum_of_squares gpr_histogram_sum_of_squares_import +typedef const uint32_t *(*gpr_histogram_get_contents_type)(gpr_histogram *histogram, size_t *count); +extern gpr_histogram_get_contents_type gpr_histogram_get_contents_import; +#define gpr_histogram_get_contents gpr_histogram_get_contents_import +typedef void(*gpr_histogram_merge_contents_type)(gpr_histogram *histogram, const uint32_t *data, size_t data_count, double min_seen, double max_seen, double sum, double sum_of_squares, double count); +extern gpr_histogram_merge_contents_type gpr_histogram_merge_contents_import; +#define gpr_histogram_merge_contents gpr_histogram_merge_contents_import +typedef int(*gpr_join_host_port_type)(char **out, const char *host, int port); +extern gpr_join_host_port_type gpr_join_host_port_import; +#define gpr_join_host_port gpr_join_host_port_import +typedef int(*gpr_split_host_port_type)(const char *name, char **host, char **port); +extern gpr_split_host_port_type gpr_split_host_port_import; +#define gpr_split_host_port gpr_split_host_port_import +typedef char *(*gpr_format_message_type)(int messageid); +extern gpr_format_message_type gpr_format_message_import; +#define gpr_format_message gpr_format_message_import +typedef char *(*gpr_strdup_type)(const char *src); +extern gpr_strdup_type gpr_strdup_import; +#define gpr_strdup gpr_strdup_import +typedef int(*gpr_asprintf_type)(char **strp, const char *format, ...); +extern gpr_asprintf_type gpr_asprintf_import; +#define gpr_asprintf gpr_asprintf_import +typedef const char *(*gpr_subprocess_binary_extension_type)(); +extern gpr_subprocess_binary_extension_type gpr_subprocess_binary_extension_import; +#define gpr_subprocess_binary_extension gpr_subprocess_binary_extension_import +typedef gpr_subprocess *(*gpr_subprocess_create_type)(int argc, const char **argv); +extern gpr_subprocess_create_type gpr_subprocess_create_import; +#define gpr_subprocess_create gpr_subprocess_create_import +typedef void(*gpr_subprocess_destroy_type)(gpr_subprocess *p); +extern gpr_subprocess_destroy_type gpr_subprocess_destroy_import; +#define gpr_subprocess_destroy gpr_subprocess_destroy_import +typedef int(*gpr_subprocess_join_type)(gpr_subprocess *p); +extern gpr_subprocess_join_type gpr_subprocess_join_import; +#define gpr_subprocess_join gpr_subprocess_join_import +typedef void(*gpr_subprocess_interrupt_type)(gpr_subprocess *p); +extern gpr_subprocess_interrupt_type gpr_subprocess_interrupt_import; +#define gpr_subprocess_interrupt gpr_subprocess_interrupt_import +typedef int(*gpr_thd_new_type)(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg, const gpr_thd_options *options); +extern gpr_thd_new_type gpr_thd_new_import; +#define gpr_thd_new gpr_thd_new_import +typedef gpr_thd_options(*gpr_thd_options_default_type)(void); +extern gpr_thd_options_default_type gpr_thd_options_default_import; +#define gpr_thd_options_default gpr_thd_options_default_import +typedef void(*gpr_thd_options_set_detached_type)(gpr_thd_options *options); +extern gpr_thd_options_set_detached_type gpr_thd_options_set_detached_import; +#define gpr_thd_options_set_detached gpr_thd_options_set_detached_import +typedef void(*gpr_thd_options_set_joinable_type)(gpr_thd_options *options); +extern gpr_thd_options_set_joinable_type gpr_thd_options_set_joinable_import; +#define gpr_thd_options_set_joinable gpr_thd_options_set_joinable_import +typedef int(*gpr_thd_options_is_detached_type)(const gpr_thd_options *options); +extern gpr_thd_options_is_detached_type gpr_thd_options_is_detached_import; +#define gpr_thd_options_is_detached gpr_thd_options_is_detached_import +typedef int(*gpr_thd_options_is_joinable_type)(const gpr_thd_options *options); +extern gpr_thd_options_is_joinable_type gpr_thd_options_is_joinable_import; +#define gpr_thd_options_is_joinable gpr_thd_options_is_joinable_import +typedef gpr_thd_id(*gpr_thd_currentid_type)(void); +extern gpr_thd_currentid_type gpr_thd_currentid_import; +#define gpr_thd_currentid gpr_thd_currentid_import +typedef void(*gpr_thd_join_type)(gpr_thd_id t); +extern gpr_thd_join_type gpr_thd_join_import; +#define gpr_thd_join gpr_thd_join_import + +void pygrpc_load_imports(HMODULE library); + +#else /* !GPR_WIN32 */ + +#include <grpc/support/alloc.h> +#include <grpc/support/slice.h> +#include <grpc/support/time.h> +#include <grpc/status.h> +#include <grpc/byte_buffer.h> +#include <grpc/byte_buffer_reader.h> +#include <grpc/grpc.h> +#include <grpc/grpc_security.h> + +#endif /* !GPR_WIN32 */ + +#endif diff --git a/src/python/grpcio/grpc/_cython/loader.c b/src/python/grpcio/grpc/_cython/loader.c new file mode 100644 index 0000000000..cdd47deed3 --- /dev/null +++ b/src/python/grpcio/grpc/_cython/loader.c @@ -0,0 +1,59 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "loader.h" + +#if GPR_WIN32 + +int pygrpc_load_core(char *path) { + HMODULE grpc_c; +#ifdef GPR_ARCH_32 + /* Close your eyes for a moment, it'll all be over soon. */ + char *six = strrchr(path, '6'); + *six++ = '3'; + *six = '2'; +#endif + grpc_c = LoadLibraryA(path); + if (grpc_c) { + pygrpc_load_imports(grpc_c); + return 1; + } + + return 0; +} + +#else + +int pygrpc_load_core(char *path) { return 1; } + +#endif diff --git a/src/python/grpcio/grpc/_cython/loader.h b/src/python/grpcio/grpc/_cython/loader.h new file mode 100644 index 0000000000..dd31e1561b --- /dev/null +++ b/src/python/grpcio/grpc/_cython/loader.h @@ -0,0 +1,45 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef PYGRPC_LOADER_H_ +#define PYGRPC_LOADER_H_ + +#include "imports.generated.h" + +/* Additional inclusions not covered by "imports.generated.h" */ +#include <grpc/byte_buffer_reader.h> + +/* Attempts to load the core if necessary, and return non-zero upon succes. */ +int pygrpc_load_core(char *path); + +#endif /* GRPC_RB_BYTE_BUFFER_H_ */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 075c3cf177..cc2636b29b 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -30,47 +30,6 @@ # AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_core_dependencies.py.template`!!! CORE_SOURCE_FILES = [ - 'src/core/profiling/basic_timers.c', - 'src/core/profiling/stap_timers.c', - 'src/core/support/alloc.c', - 'src/core/support/avl.c', - 'src/core/support/cmdline.c', - 'src/core/support/cpu_iphone.c', - 'src/core/support/cpu_linux.c', - 'src/core/support/cpu_posix.c', - 'src/core/support/cpu_windows.c', - 'src/core/support/env_linux.c', - 'src/core/support/env_posix.c', - 'src/core/support/env_win32.c', - 'src/core/support/file.c', - 'src/core/support/file_posix.c', - 'src/core/support/file_win32.c', - 'src/core/support/histogram.c', - 'src/core/support/host_port.c', - 'src/core/support/log.c', - 'src/core/support/log_android.c', - 'src/core/support/log_linux.c', - 'src/core/support/log_posix.c', - 'src/core/support/log_win32.c', - 'src/core/support/murmur_hash.c', - 'src/core/support/slice.c', - 'src/core/support/slice_buffer.c', - 'src/core/support/stack_lockfree.c', - 'src/core/support/string.c', - 'src/core/support/string_posix.c', - 'src/core/support/string_win32.c', - 'src/core/support/subprocess_posix.c', - 'src/core/support/sync.c', - 'src/core/support/sync_posix.c', - 'src/core/support/sync_win32.c', - 'src/core/support/thd.c', - 'src/core/support/thd_posix.c', - 'src/core/support/thd_win32.c', - 'src/core/support/time.c', - 'src/core/support/time_posix.c', - 'src/core/support/time_precise.c', - 'src/core/support/time_win32.c', - 'src/core/support/tls_pthread.c', 'src/core/httpcli/httpcli_security_connector.c', 'src/core/security/base64.c', 'src/core/security/client_auth_filter.c', @@ -172,6 +131,7 @@ CORE_SOURCE_FILES = [ 'src/core/json/json_string.c', 'src/core/json/json_writer.c', 'src/core/proto/grpc/lb/v0/load_balancer.pb.c', + 'src/core/surface/alarm.c', 'src/core/surface/api_trace.c', 'src/core/surface/byte_buffer.c', 'src/core/surface/byte_buffer_reader.c', @@ -220,10 +180,53 @@ CORE_SOURCE_FILES = [ 'src/core/transport/static_metadata.c', 'src/core/transport/transport.c', 'src/core/transport/transport_op_string.c', + 'src/core/profiling/basic_timers.c', + 'src/core/profiling/stap_timers.c', + 'src/core/support/alloc.c', + 'src/core/support/avl.c', + 'src/core/support/cmdline.c', + 'src/core/support/cpu_iphone.c', + 'src/core/support/cpu_linux.c', + 'src/core/support/cpu_posix.c', + 'src/core/support/cpu_windows.c', + 'src/core/support/env_linux.c', + 'src/core/support/env_posix.c', + 'src/core/support/env_win32.c', + 'src/core/support/file.c', + 'src/core/support/file_posix.c', + 'src/core/support/file_win32.c', + 'src/core/support/histogram.c', + 'src/core/support/host_port.c', + 'src/core/support/log.c', + 'src/core/support/log_android.c', + 'src/core/support/log_linux.c', + 'src/core/support/log_posix.c', + 'src/core/support/log_win32.c', + 'src/core/support/murmur_hash.c', + 'src/core/support/slice.c', + 'src/core/support/slice_buffer.c', + 'src/core/support/stack_lockfree.c', + 'src/core/support/string.c', + 'src/core/support/string_posix.c', + 'src/core/support/string_win32.c', + 'src/core/support/subprocess_posix.c', + 'src/core/support/subprocess_windows.c', + 'src/core/support/sync.c', + 'src/core/support/sync_posix.c', + 'src/core/support/sync_win32.c', + 'src/core/support/thd.c', + 'src/core/support/thd_posix.c', + 'src/core/support/thd_win32.c', + 'src/core/support/time.c', + 'src/core/support/time_posix.c', + 'src/core/support/time_precise.c', + 'src/core/support/time_win32.c', + 'src/core/support/tls_pthread.c', + 'src/core/support/wrap_memcpy.c', 'src/core/census/context.c', 'src/core/census/initialize.c', 'src/core/census/operation.c', - 'src/core/census/tag_set.c', + 'src/core/census/placeholders.c', 'src/core/census/tracing.c', 'third_party/nanopb/pb_common.c', 'third_party/nanopb/pb_decode.c', diff --git a/src/python/grpcio/grpc_version.py b/src/python/grpcio/grpc_version.py new file mode 100644 index 0000000000..75b88cfd61 --- /dev/null +++ b/src/python/grpcio/grpc_version.py @@ -0,0 +1,32 @@ +# Copyright 2015-2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# AUTO-GENERATED FROM `$REPO_ROOT/templates/src/python/grpcio/grpc_version.py.template`!!! + +VERSION='0.14.0.dev0' diff --git a/src/python/grpcio/support.py b/src/python/grpcio/support.py index bbc509653d..33244eb388 100644 --- a/src/python/grpcio/support.py +++ b/src/python/grpcio/support.py @@ -76,16 +76,40 @@ def _expect_compile(compiler, source_string, error_message): "Diagnostics found a compilation environment issue:\n{}" .format(error_message)) -def diagnose_build_ext_error(build_ext, error): - { - errors.CompileError: diagnose_compile_error - }[type(error)](build_ext, error) - def diagnose_compile_error(build_ext, error): - """Attempt to run a few test files through the compiler to see if we can - diagnose the reason for the compile failure.""" + """Attempt to diagnose an error during compilation.""" for c_check, message in C_CHECKS.items(): _expect_compile(build_ext.compiler, c_check, message) - raise commands.CommandError( - "\n\nWe could not diagnose your build failure. Please file an issue at " - "http://www.github.com/grpc/grpc with `[Python install]` in the title.") + python_sources = [ + source for source in build_ext.get_source_files() + if source.startswith('./src/python') and source.endswith('c') + ] + for source in python_sources: + if not os.path.isfile(source): + raise commands.CommandError( + ("Diagnostics found a missing Python extension source file:\n{}\n\n" + "This is usually because the Cython sources haven't been transpiled " + "into C yet and you're building from source.\n" + "Try setting the environment variable " + "`GRPC_PYTHON_BUILD_WITH_CYTHON=1` when invoking `setup.py` or " + "when using `pip`, e.g.:\n\n" + "pip install -rrequirements.txt\n" + "GRPC_PYTHON_BUILD_WITH_CYTHON=1 pip install .") + .format(source) + ) + + +_ERROR_DIAGNOSES = { + errors.CompileError: diagnose_compile_error +} + +def diagnose_build_ext_error(build_ext, error, formatted): + diagnostic = _ERROR_DIAGNOSES.get(type(error)) + if diagnostic is None: + raise commands.CommandError( + "\n\nWe could not diagnose your build failure. Please file an issue at " + "http://www.github.com/grpc/grpc with `[Python install]` in the title." + "\n\n{}".format(formatted)) + else: + diagnostic(build_ext, error) + diff --git a/src/ruby/ext/grpc/extconf.rb b/src/ruby/ext/grpc/extconf.rb index 018353ce5d..b7c6cb3d7e 100644 --- a/src/ruby/ext/grpc/extconf.rb +++ b/src/ruby/ext/grpc/extconf.rb @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -54,8 +54,7 @@ LIB_DIRS = [ LIBDIR ] -fail 'libdl not found' unless have_library('dl', 'dlopen') -fail 'zlib not found' unless have_library('z', 'inflate') +windows = RUBY_PLATFORM =~ /mingw|mswin/ grpc_root = File.expand_path(File.join(File.dirname(__FILE__), '../../../..')) @@ -64,29 +63,67 @@ grpc_config = ENV['GRPC_CONFIG'] || 'opt' if ENV.key?('GRPC_LIB_DIR') grpc_lib_dir = File.join(grpc_root, ENV['GRPC_LIB_DIR']) else - grpc_lib_dir = File.join(File.join(grpc_root, 'libs'), grpc_config) + grpc_lib_dir = File.join(grpc_root, 'libs', grpc_config) end -unless File.exist?(File.join(grpc_lib_dir, 'libgrpc.a')) - print "Building internal gRPC\n" - system("make -C #{grpc_root} static_c CONFIG=#{grpc_config}") +ENV['MACOSX_DEPLOYMENT_TARGET'] = '10.7' + +unless File.exist?(File.join(grpc_lib_dir, 'libgrpc.a')) or windows + ENV['AR'] = RbConfig::CONFIG['AR'] + ' rcs' + ENV['CC'] = RbConfig::CONFIG['CC'] + ENV['LD'] = ENV['CC'] + + ENV['AR'] = 'libtool -o' if RUBY_PLATFORM =~ /darwin/ + + ENV['EMBED_OPENSSL'] = 'true' + ENV['EMBED_ZLIB'] = 'true' + ENV['ARCH_FLAGS'] = RbConfig::CONFIG['ARCH_FLAG'] + ENV['ARCH_FLAGS'] = '-arch i386 -arch x86_64' if RUBY_PLATFORM =~ /darwin/ + + output_dir = File.expand_path(RbConfig::CONFIG['topdir']) + grpc_lib_dir = File.join(output_dir, 'libs', grpc_config) + ENV['BUILDDIR'] = output_dir + + puts 'Building internal gRPC into ' + grpc_lib_dir + system("make -j -C #{grpc_root} #{grpc_lib_dir}/libgrpc.a CONFIG=#{grpc_config}") + exit 1 unless $? == 0 end $CFLAGS << ' -I' + File.join(grpc_root, 'include') -$LDFLAGS << ' ' + File.join(grpc_lib_dir, 'libgrpc.a') -$LDFLAGS << ' ' + File.join(grpc_lib_dir, 'libgpr.a') +$LDFLAGS << ' ' + File.join(grpc_lib_dir, 'libgrpc.a') unless windows if grpc_config == 'gcov' $CFLAGS << ' -O0 -fprofile-arcs -ftest-coverage' $LDFLAGS << ' -fprofile-arcs -ftest-coverage -rdynamic' end +$LDFLAGS << ' -Wl,-wrap,memcpy' if RUBY_PLATFORM =~ /linux/ +$LDFLAGS << ' -static' if windows + $CFLAGS << ' -std=c99 ' $CFLAGS << ' -Wall ' $CFLAGS << ' -Wextra ' $CFLAGS << ' -pedantic ' $CFLAGS << ' -Werror ' - -$LDFLAGS << ' -lssl ' -$LDFLAGS << ' -lcrypto ' - -create_makefile('grpc/grpc') +$CFLAGS << ' -Wno-format ' + +output = File.join('grpc', 'grpc_c') +puts 'Generating Makefile for ' + output +create_makefile(output) + +strip_tool = RbConfig::CONFIG['STRIP'] +strip_tool = 'strip -x' if RUBY_PLATFORM =~ /darwin/ + +if grpc_config == 'opt' + File.open('Makefile.new', 'w') do |o| + o.puts 'hijack: all strip' + o.puts + File.foreach('Makefile') do |i| + o.puts i + end + o.puts + o.puts 'strip:' + o.puts "\t$(ECHO) Stripping $(DLLIB)" + o.puts "\t$(Q) #{strip_tool} $(DLLIB)" + end + File.rename('Makefile.new', 'Makefile') +end diff --git a/src/ruby/ext/grpc/rb_byte_buffer.c b/src/ruby/ext/grpc/rb_byte_buffer.c index 0aa34c844e..db7cac363a 100644 --- a/src/ruby/ext/grpc/rb_byte_buffer.c +++ b/src/ruby/ext/grpc/rb_byte_buffer.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_byte_buffer.h" #include <ruby/ruby.h> diff --git a/src/ruby/ext/grpc/rb_call.c b/src/ruby/ext/grpc/rb_call.c index 07864ebf59..af05ddf6e7 100644 --- a/src/ruby/ext/grpc/rb_call.c +++ b/src/ruby/ext/grpc/rb_call.c @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_call.h" #include <ruby/ruby.h> diff --git a/src/ruby/ext/grpc/rb_call_credentials.c b/src/ruby/ext/grpc/rb_call_credentials.c index ebcc6592c2..2426f106a9 100644 --- a/src/ruby/ext/grpc/rb_call_credentials.c +++ b/src/ruby/ext/grpc/rb_call_credentials.c @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_call_credentials.h" #include <ruby/ruby.h> diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c index 2fb8a5cdf0..0e6badbdaf 100644 --- a/src/ruby/ext/grpc/rb_channel.c +++ b/src/ruby/ext/grpc/rb_channel.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_channel.h" #include <ruby/ruby.h> @@ -227,7 +229,7 @@ static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self, } grpc_channel_watch_connectivity_state( ch, - NUM2LONG(last_state), + (grpc_connectivity_state)NUM2LONG(last_state), grpc_rb_time_timeval(deadline, /* absolute time */ 0), cq, ROBJECT(tag)); diff --git a/src/ruby/ext/grpc/rb_channel_args.c b/src/ruby/ext/grpc/rb_channel_args.c index 37dd981925..69827cea1c 100644 --- a/src/ruby/ext/grpc/rb_channel_args.c +++ b/src/ruby/ext/grpc/rb_channel_args.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_channel_args.h" #include <ruby/ruby.h> diff --git a/src/ruby/ext/grpc/rb_channel_credentials.c b/src/ruby/ext/grpc/rb_channel_credentials.c index 3530081c6b..8c6fc3b7eb 100644 --- a/src/ruby/ext/grpc/rb_channel_credentials.c +++ b/src/ruby/ext/grpc/rb_channel_credentials.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_channel_credentials.h" #include <ruby/ruby.h> diff --git a/src/ruby/ext/grpc/rb_completion_queue.c b/src/ruby/ext/grpc/rb_completion_queue.c index a7de96d718..1eb5a28750 100644 --- a/src/ruby/ext/grpc/rb_completion_queue.c +++ b/src/ruby/ext/grpc/rb_completion_queue.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_completion_queue.h" #include <ruby/ruby.h> diff --git a/src/ruby/ext/grpc/rb_event_thread.c b/src/ruby/ext/grpc/rb_event_thread.c index 516f0bdad2..2649a1087f 100644 --- a/src/ruby/ext/grpc/rb_event_thread.c +++ b/src/ruby/ext/grpc/rb_event_thread.c @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_event_thread.h" #include <stdbool.h> diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c index 265ab58ecb..eefdb93d67 100644 --- a/src/ruby/ext/grpc/rb_grpc.c +++ b/src/ruby/ext/grpc/rb_grpc.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_grpc.h" #include <math.h> @@ -45,6 +47,7 @@ #include "rb_channel.h" #include "rb_channel_credentials.h" #include "rb_completion_queue.h" +#include "rb_loader.h" #include "rb_server.h" #include "rb_server_credentials.h" @@ -297,7 +300,12 @@ VALUE sym_code = Qundef; VALUE sym_details = Qundef; VALUE sym_metadata = Qundef; -void Init_grpc() { +void Init_grpc_c() { + if (!grpc_rb_load_core()) { + rb_raise(rb_eLoadError, "Couldn't find or load gRPC's dynamic C core"); + return; + } + grpc_init(); /* TODO: find alternative to ruby_vm_at_exit that is ok in Ruby 2.0 */ diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c new file mode 100644 index 0000000000..d4ddb734c0 --- /dev/null +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -0,0 +1,560 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include <grpc/support/port_platform.h> + +#ifdef GPR_WIN32 + +#include "rb_grpc_imports.generated.h" + +census_initialize_type census_initialize_import; +census_shutdown_type census_shutdown_import; +census_supported_type census_supported_import; +census_enabled_type census_enabled_import; +census_context_create_type census_context_create_import; +census_context_destroy_type census_context_destroy_import; +census_context_get_status_type census_context_get_status_import; +census_context_initialize_iterator_type census_context_initialize_iterator_import; +census_context_next_tag_type census_context_next_tag_import; +census_context_get_tag_type census_context_get_tag_import; +census_context_encode_type census_context_encode_import; +census_context_decode_type census_context_decode_import; +census_trace_mask_type census_trace_mask_import; +census_set_trace_mask_type census_set_trace_mask_import; +census_start_rpc_op_timestamp_type census_start_rpc_op_timestamp_import; +census_start_client_rpc_op_type census_start_client_rpc_op_import; +census_set_rpc_client_peer_type census_set_rpc_client_peer_import; +census_start_server_rpc_op_type census_start_server_rpc_op_import; +census_start_op_type census_start_op_import; +census_end_op_type census_end_op_import; +census_trace_print_type census_trace_print_import; +census_trace_scan_start_type census_trace_scan_start_import; +census_get_trace_record_type census_get_trace_record_import; +census_trace_scan_end_type census_trace_scan_end_import; +census_record_values_type census_record_values_import; +census_view_create_type census_view_create_import; +census_view_delete_type census_view_delete_import; +census_view_metric_type census_view_metric_import; +census_view_naggregations_type census_view_naggregations_import; +census_view_tags_type census_view_tags_import; +census_view_aggregrations_type census_view_aggregrations_import; +census_view_get_data_type census_view_get_data_import; +census_view_reset_type census_view_reset_import; +grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import; +grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import; +grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import; +grpc_compression_options_init_type grpc_compression_options_init_import; +grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import; +grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import; +grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import; +grpc_metadata_array_init_type grpc_metadata_array_init_import; +grpc_metadata_array_destroy_type grpc_metadata_array_destroy_import; +grpc_call_details_init_type grpc_call_details_init_import; +grpc_call_details_destroy_type grpc_call_details_destroy_import; +grpc_register_plugin_type grpc_register_plugin_import; +grpc_init_type grpc_init_import; +grpc_shutdown_type grpc_shutdown_import; +grpc_version_string_type grpc_version_string_import; +grpc_completion_queue_create_type grpc_completion_queue_create_import; +grpc_completion_queue_next_type grpc_completion_queue_next_import; +grpc_completion_queue_pluck_type grpc_completion_queue_pluck_import; +grpc_completion_queue_shutdown_type grpc_completion_queue_shutdown_import; +grpc_completion_queue_destroy_type grpc_completion_queue_destroy_import; +grpc_alarm_create_type grpc_alarm_create_import; +grpc_alarm_cancel_type grpc_alarm_cancel_import; +grpc_alarm_destroy_type grpc_alarm_destroy_import; +grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import; +grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import; +grpc_channel_create_call_type grpc_channel_create_call_import; +grpc_channel_ping_type grpc_channel_ping_import; +grpc_channel_register_call_type grpc_channel_register_call_import; +grpc_channel_create_registered_call_type grpc_channel_create_registered_call_import; +grpc_call_start_batch_type grpc_call_start_batch_import; +grpc_call_get_peer_type grpc_call_get_peer_import; +grpc_census_call_set_context_type grpc_census_call_set_context_import; +grpc_census_call_get_context_type grpc_census_call_get_context_import; +grpc_channel_get_target_type grpc_channel_get_target_import; +grpc_insecure_channel_create_type grpc_insecure_channel_create_import; +grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import; +grpc_channel_destroy_type grpc_channel_destroy_import; +grpc_call_cancel_type grpc_call_cancel_import; +grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import; +grpc_call_destroy_type grpc_call_destroy_import; +grpc_server_request_call_type grpc_server_request_call_import; +grpc_server_register_method_type grpc_server_register_method_import; +grpc_server_request_registered_call_type grpc_server_request_registered_call_import; +grpc_server_create_type grpc_server_create_import; +grpc_server_register_completion_queue_type grpc_server_register_completion_queue_import; +grpc_server_add_insecure_http2_port_type grpc_server_add_insecure_http2_port_import; +grpc_server_start_type grpc_server_start_import; +grpc_server_shutdown_and_notify_type grpc_server_shutdown_and_notify_import; +grpc_server_cancel_all_calls_type grpc_server_cancel_all_calls_import; +grpc_server_destroy_type grpc_server_destroy_import; +grpc_tracer_set_enabled_type grpc_tracer_set_enabled_import; +grpc_header_key_is_legal_type grpc_header_key_is_legal_import; +grpc_header_nonbin_value_is_legal_type grpc_header_nonbin_value_is_legal_import; +grpc_is_binary_header_type grpc_is_binary_header_import; +grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import; +grpc_auth_context_property_iterator_type grpc_auth_context_property_iterator_import; +grpc_auth_context_peer_identity_type grpc_auth_context_peer_identity_import; +grpc_auth_context_find_properties_by_name_type grpc_auth_context_find_properties_by_name_import; +grpc_auth_context_peer_identity_property_name_type grpc_auth_context_peer_identity_property_name_import; +grpc_auth_context_peer_is_authenticated_type grpc_auth_context_peer_is_authenticated_import; +grpc_call_auth_context_type grpc_call_auth_context_import; +grpc_auth_context_release_type grpc_auth_context_release_import; +grpc_auth_context_add_property_type grpc_auth_context_add_property_import; +grpc_auth_context_add_cstring_property_type grpc_auth_context_add_cstring_property_import; +grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import; +grpc_channel_credentials_release_type grpc_channel_credentials_release_import; +grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import; +grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; +grpc_call_credentials_release_type grpc_call_credentials_release_import; +grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import; +grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import; +grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import; +grpc_max_auth_token_lifetime_type grpc_max_auth_token_lifetime_import; +grpc_service_account_jwt_access_credentials_create_type grpc_service_account_jwt_access_credentials_create_import; +grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_credentials_create_import; +grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import; +grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import; +grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import; +grpc_secure_channel_create_type grpc_secure_channel_create_import; +grpc_server_credentials_release_type grpc_server_credentials_release_import; +grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; +grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import; +grpc_call_set_credentials_type grpc_call_set_credentials_import; +grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; +gpr_malloc_type gpr_malloc_import; +gpr_free_type gpr_free_import; +gpr_realloc_type gpr_realloc_import; +gpr_malloc_aligned_type gpr_malloc_aligned_import; +gpr_free_aligned_type gpr_free_aligned_import; +gpr_set_allocation_functions_type gpr_set_allocation_functions_import; +gpr_get_allocation_functions_type gpr_get_allocation_functions_import; +grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import; +grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import; +grpc_byte_buffer_copy_type grpc_byte_buffer_copy_import; +grpc_byte_buffer_length_type grpc_byte_buffer_length_import; +grpc_byte_buffer_destroy_type grpc_byte_buffer_destroy_import; +grpc_byte_buffer_reader_init_type grpc_byte_buffer_reader_init_import; +grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import; +grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import; +grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import; +grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import; +gpr_log_type gpr_log_import; +gpr_log_message_type gpr_log_message_import; +gpr_set_log_function_type gpr_set_log_function_import; +gpr_slice_ref_type gpr_slice_ref_import; +gpr_slice_unref_type gpr_slice_unref_import; +gpr_slice_new_type gpr_slice_new_import; +gpr_slice_new_with_len_type gpr_slice_new_with_len_import; +gpr_slice_malloc_type gpr_slice_malloc_import; +gpr_slice_from_copied_string_type gpr_slice_from_copied_string_import; +gpr_slice_from_copied_buffer_type gpr_slice_from_copied_buffer_import; +gpr_slice_from_static_string_type gpr_slice_from_static_string_import; +gpr_slice_sub_type gpr_slice_sub_import; +gpr_slice_sub_no_ref_type gpr_slice_sub_no_ref_import; +gpr_slice_split_tail_type gpr_slice_split_tail_import; +gpr_slice_split_head_type gpr_slice_split_head_import; +gpr_empty_slice_type gpr_empty_slice_import; +gpr_slice_cmp_type gpr_slice_cmp_import; +gpr_slice_str_cmp_type gpr_slice_str_cmp_import; +gpr_slice_buffer_init_type gpr_slice_buffer_init_import; +gpr_slice_buffer_destroy_type gpr_slice_buffer_destroy_import; +gpr_slice_buffer_add_type gpr_slice_buffer_add_import; +gpr_slice_buffer_add_indexed_type gpr_slice_buffer_add_indexed_import; +gpr_slice_buffer_addn_type gpr_slice_buffer_addn_import; +gpr_slice_buffer_tiny_add_type gpr_slice_buffer_tiny_add_import; +gpr_slice_buffer_pop_type gpr_slice_buffer_pop_import; +gpr_slice_buffer_reset_and_unref_type gpr_slice_buffer_reset_and_unref_import; +gpr_slice_buffer_swap_type gpr_slice_buffer_swap_import; +gpr_slice_buffer_move_into_type gpr_slice_buffer_move_into_import; +gpr_slice_buffer_trim_end_type gpr_slice_buffer_trim_end_import; +gpr_slice_buffer_move_first_type gpr_slice_buffer_move_first_import; +gpr_slice_buffer_take_first_type gpr_slice_buffer_take_first_import; +gpr_mu_init_type gpr_mu_init_import; +gpr_mu_destroy_type gpr_mu_destroy_import; +gpr_mu_lock_type gpr_mu_lock_import; +gpr_mu_unlock_type gpr_mu_unlock_import; +gpr_mu_trylock_type gpr_mu_trylock_import; +gpr_cv_init_type gpr_cv_init_import; +gpr_cv_destroy_type gpr_cv_destroy_import; +gpr_cv_wait_type gpr_cv_wait_import; +gpr_cv_signal_type gpr_cv_signal_import; +gpr_cv_broadcast_type gpr_cv_broadcast_import; +gpr_once_init_type gpr_once_init_import; +gpr_event_init_type gpr_event_init_import; +gpr_event_set_type gpr_event_set_import; +gpr_event_get_type gpr_event_get_import; +gpr_event_wait_type gpr_event_wait_import; +gpr_ref_init_type gpr_ref_init_import; +gpr_ref_type gpr_ref_import; +gpr_refn_type gpr_refn_import; +gpr_unref_type gpr_unref_import; +gpr_stats_init_type gpr_stats_init_import; +gpr_stats_inc_type gpr_stats_inc_import; +gpr_stats_read_type gpr_stats_read_import; +gpr_time_0_type gpr_time_0_import; +gpr_inf_future_type gpr_inf_future_import; +gpr_inf_past_type gpr_inf_past_import; +gpr_time_init_type gpr_time_init_import; +gpr_now_type gpr_now_import; +gpr_convert_clock_type_type gpr_convert_clock_type_import; +gpr_time_cmp_type gpr_time_cmp_import; +gpr_time_max_type gpr_time_max_import; +gpr_time_min_type gpr_time_min_import; +gpr_time_add_type gpr_time_add_import; +gpr_time_sub_type gpr_time_sub_import; +gpr_time_from_micros_type gpr_time_from_micros_import; +gpr_time_from_nanos_type gpr_time_from_nanos_import; +gpr_time_from_millis_type gpr_time_from_millis_import; +gpr_time_from_seconds_type gpr_time_from_seconds_import; +gpr_time_from_minutes_type gpr_time_from_minutes_import; +gpr_time_from_hours_type gpr_time_from_hours_import; +gpr_time_to_millis_type gpr_time_to_millis_import; +gpr_time_similar_type gpr_time_similar_import; +gpr_sleep_until_type gpr_sleep_until_import; +gpr_timespec_to_micros_type gpr_timespec_to_micros_import; +gpr_avl_create_type gpr_avl_create_import; +gpr_avl_ref_type gpr_avl_ref_import; +gpr_avl_unref_type gpr_avl_unref_import; +gpr_avl_add_type gpr_avl_add_import; +gpr_avl_remove_type gpr_avl_remove_import; +gpr_avl_get_type gpr_avl_get_import; +gpr_cmdline_create_type gpr_cmdline_create_import; +gpr_cmdline_add_int_type gpr_cmdline_add_int_import; +gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import; +gpr_cmdline_add_string_type gpr_cmdline_add_string_import; +gpr_cmdline_on_extra_arg_type gpr_cmdline_on_extra_arg_import; +gpr_cmdline_set_survive_failure_type gpr_cmdline_set_survive_failure_import; +gpr_cmdline_parse_type gpr_cmdline_parse_import; +gpr_cmdline_destroy_type gpr_cmdline_destroy_import; +gpr_cmdline_usage_string_type gpr_cmdline_usage_string_import; +gpr_cpu_num_cores_type gpr_cpu_num_cores_import; +gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; +gpr_histogram_create_type gpr_histogram_create_import; +gpr_histogram_destroy_type gpr_histogram_destroy_import; +gpr_histogram_add_type gpr_histogram_add_import; +gpr_histogram_merge_type gpr_histogram_merge_import; +gpr_histogram_percentile_type gpr_histogram_percentile_import; +gpr_histogram_mean_type gpr_histogram_mean_import; +gpr_histogram_stddev_type gpr_histogram_stddev_import; +gpr_histogram_variance_type gpr_histogram_variance_import; +gpr_histogram_maximum_type gpr_histogram_maximum_import; +gpr_histogram_minimum_type gpr_histogram_minimum_import; +gpr_histogram_count_type gpr_histogram_count_import; +gpr_histogram_sum_type gpr_histogram_sum_import; +gpr_histogram_sum_of_squares_type gpr_histogram_sum_of_squares_import; +gpr_histogram_get_contents_type gpr_histogram_get_contents_import; +gpr_histogram_merge_contents_type gpr_histogram_merge_contents_import; +gpr_join_host_port_type gpr_join_host_port_import; +gpr_split_host_port_type gpr_split_host_port_import; +gpr_format_message_type gpr_format_message_import; +gpr_strdup_type gpr_strdup_import; +gpr_asprintf_type gpr_asprintf_import; +gpr_subprocess_binary_extension_type gpr_subprocess_binary_extension_import; +gpr_subprocess_create_type gpr_subprocess_create_import; +gpr_subprocess_destroy_type gpr_subprocess_destroy_import; +gpr_subprocess_join_type gpr_subprocess_join_import; +gpr_subprocess_interrupt_type gpr_subprocess_interrupt_import; +gpr_thd_new_type gpr_thd_new_import; +gpr_thd_options_default_type gpr_thd_options_default_import; +gpr_thd_options_set_detached_type gpr_thd_options_set_detached_import; +gpr_thd_options_set_joinable_type gpr_thd_options_set_joinable_import; +gpr_thd_options_is_detached_type gpr_thd_options_is_detached_import; +gpr_thd_options_is_joinable_type gpr_thd_options_is_joinable_import; +gpr_thd_currentid_type gpr_thd_currentid_import; +gpr_thd_join_type gpr_thd_join_import; + +void grpc_rb_load_imports(HMODULE library) { + census_initialize_import = (census_initialize_type) GetProcAddress(library, "census_initialize"); + census_shutdown_import = (census_shutdown_type) GetProcAddress(library, "census_shutdown"); + census_supported_import = (census_supported_type) GetProcAddress(library, "census_supported"); + census_enabled_import = (census_enabled_type) GetProcAddress(library, "census_enabled"); + census_context_create_import = (census_context_create_type) GetProcAddress(library, "census_context_create"); + census_context_destroy_import = (census_context_destroy_type) GetProcAddress(library, "census_context_destroy"); + census_context_get_status_import = (census_context_get_status_type) GetProcAddress(library, "census_context_get_status"); + census_context_initialize_iterator_import = (census_context_initialize_iterator_type) GetProcAddress(library, "census_context_initialize_iterator"); + census_context_next_tag_import = (census_context_next_tag_type) GetProcAddress(library, "census_context_next_tag"); + census_context_get_tag_import = (census_context_get_tag_type) GetProcAddress(library, "census_context_get_tag"); + census_context_encode_import = (census_context_encode_type) GetProcAddress(library, "census_context_encode"); + census_context_decode_import = (census_context_decode_type) GetProcAddress(library, "census_context_decode"); + census_trace_mask_import = (census_trace_mask_type) GetProcAddress(library, "census_trace_mask"); + census_set_trace_mask_import = (census_set_trace_mask_type) GetProcAddress(library, "census_set_trace_mask"); + census_start_rpc_op_timestamp_import = (census_start_rpc_op_timestamp_type) GetProcAddress(library, "census_start_rpc_op_timestamp"); + census_start_client_rpc_op_import = (census_start_client_rpc_op_type) GetProcAddress(library, "census_start_client_rpc_op"); + census_set_rpc_client_peer_import = (census_set_rpc_client_peer_type) GetProcAddress(library, "census_set_rpc_client_peer"); + census_start_server_rpc_op_import = (census_start_server_rpc_op_type) GetProcAddress(library, "census_start_server_rpc_op"); + census_start_op_import = (census_start_op_type) GetProcAddress(library, "census_start_op"); + census_end_op_import = (census_end_op_type) GetProcAddress(library, "census_end_op"); + census_trace_print_import = (census_trace_print_type) GetProcAddress(library, "census_trace_print"); + census_trace_scan_start_import = (census_trace_scan_start_type) GetProcAddress(library, "census_trace_scan_start"); + census_get_trace_record_import = (census_get_trace_record_type) GetProcAddress(library, "census_get_trace_record"); + census_trace_scan_end_import = (census_trace_scan_end_type) GetProcAddress(library, "census_trace_scan_end"); + census_record_values_import = (census_record_values_type) GetProcAddress(library, "census_record_values"); + census_view_create_import = (census_view_create_type) GetProcAddress(library, "census_view_create"); + census_view_delete_import = (census_view_delete_type) GetProcAddress(library, "census_view_delete"); + census_view_metric_import = (census_view_metric_type) GetProcAddress(library, "census_view_metric"); + census_view_naggregations_import = (census_view_naggregations_type) GetProcAddress(library, "census_view_naggregations"); + census_view_tags_import = (census_view_tags_type) GetProcAddress(library, "census_view_tags"); + census_view_aggregrations_import = (census_view_aggregrations_type) GetProcAddress(library, "census_view_aggregrations"); + census_view_get_data_import = (census_view_get_data_type) GetProcAddress(library, "census_view_get_data"); + census_view_reset_import = (census_view_reset_type) GetProcAddress(library, "census_view_reset"); + grpc_compression_algorithm_parse_import = (grpc_compression_algorithm_parse_type) GetProcAddress(library, "grpc_compression_algorithm_parse"); + grpc_compression_algorithm_name_import = (grpc_compression_algorithm_name_type) GetProcAddress(library, "grpc_compression_algorithm_name"); + grpc_compression_algorithm_for_level_import = (grpc_compression_algorithm_for_level_type) GetProcAddress(library, "grpc_compression_algorithm_for_level"); + grpc_compression_options_init_import = (grpc_compression_options_init_type) GetProcAddress(library, "grpc_compression_options_init"); + grpc_compression_options_enable_algorithm_import = (grpc_compression_options_enable_algorithm_type) GetProcAddress(library, "grpc_compression_options_enable_algorithm"); + grpc_compression_options_disable_algorithm_import = (grpc_compression_options_disable_algorithm_type) GetProcAddress(library, "grpc_compression_options_disable_algorithm"); + grpc_compression_options_is_algorithm_enabled_import = (grpc_compression_options_is_algorithm_enabled_type) GetProcAddress(library, "grpc_compression_options_is_algorithm_enabled"); + grpc_metadata_array_init_import = (grpc_metadata_array_init_type) GetProcAddress(library, "grpc_metadata_array_init"); + grpc_metadata_array_destroy_import = (grpc_metadata_array_destroy_type) GetProcAddress(library, "grpc_metadata_array_destroy"); + grpc_call_details_init_import = (grpc_call_details_init_type) GetProcAddress(library, "grpc_call_details_init"); + grpc_call_details_destroy_import = (grpc_call_details_destroy_type) GetProcAddress(library, "grpc_call_details_destroy"); + grpc_register_plugin_import = (grpc_register_plugin_type) GetProcAddress(library, "grpc_register_plugin"); + grpc_init_import = (grpc_init_type) GetProcAddress(library, "grpc_init"); + grpc_shutdown_import = (grpc_shutdown_type) GetProcAddress(library, "grpc_shutdown"); + grpc_version_string_import = (grpc_version_string_type) GetProcAddress(library, "grpc_version_string"); + grpc_completion_queue_create_import = (grpc_completion_queue_create_type) GetProcAddress(library, "grpc_completion_queue_create"); + grpc_completion_queue_next_import = (grpc_completion_queue_next_type) GetProcAddress(library, "grpc_completion_queue_next"); + grpc_completion_queue_pluck_import = (grpc_completion_queue_pluck_type) GetProcAddress(library, "grpc_completion_queue_pluck"); + grpc_completion_queue_shutdown_import = (grpc_completion_queue_shutdown_type) GetProcAddress(library, "grpc_completion_queue_shutdown"); + grpc_completion_queue_destroy_import = (grpc_completion_queue_destroy_type) GetProcAddress(library, "grpc_completion_queue_destroy"); + grpc_alarm_create_import = (grpc_alarm_create_type) GetProcAddress(library, "grpc_alarm_create"); + grpc_alarm_cancel_import = (grpc_alarm_cancel_type) GetProcAddress(library, "grpc_alarm_cancel"); + grpc_alarm_destroy_import = (grpc_alarm_destroy_type) GetProcAddress(library, "grpc_alarm_destroy"); + grpc_channel_check_connectivity_state_import = (grpc_channel_check_connectivity_state_type) GetProcAddress(library, "grpc_channel_check_connectivity_state"); + grpc_channel_watch_connectivity_state_import = (grpc_channel_watch_connectivity_state_type) GetProcAddress(library, "grpc_channel_watch_connectivity_state"); + grpc_channel_create_call_import = (grpc_channel_create_call_type) GetProcAddress(library, "grpc_channel_create_call"); + grpc_channel_ping_import = (grpc_channel_ping_type) GetProcAddress(library, "grpc_channel_ping"); + grpc_channel_register_call_import = (grpc_channel_register_call_type) GetProcAddress(library, "grpc_channel_register_call"); + grpc_channel_create_registered_call_import = (grpc_channel_create_registered_call_type) GetProcAddress(library, "grpc_channel_create_registered_call"); + grpc_call_start_batch_import = (grpc_call_start_batch_type) GetProcAddress(library, "grpc_call_start_batch"); + grpc_call_get_peer_import = (grpc_call_get_peer_type) GetProcAddress(library, "grpc_call_get_peer"); + grpc_census_call_set_context_import = (grpc_census_call_set_context_type) GetProcAddress(library, "grpc_census_call_set_context"); + grpc_census_call_get_context_import = (grpc_census_call_get_context_type) GetProcAddress(library, "grpc_census_call_get_context"); + grpc_channel_get_target_import = (grpc_channel_get_target_type) GetProcAddress(library, "grpc_channel_get_target"); + grpc_insecure_channel_create_import = (grpc_insecure_channel_create_type) GetProcAddress(library, "grpc_insecure_channel_create"); + grpc_lame_client_channel_create_import = (grpc_lame_client_channel_create_type) GetProcAddress(library, "grpc_lame_client_channel_create"); + grpc_channel_destroy_import = (grpc_channel_destroy_type) GetProcAddress(library, "grpc_channel_destroy"); + grpc_call_cancel_import = (grpc_call_cancel_type) GetProcAddress(library, "grpc_call_cancel"); + grpc_call_cancel_with_status_import = (grpc_call_cancel_with_status_type) GetProcAddress(library, "grpc_call_cancel_with_status"); + grpc_call_destroy_import = (grpc_call_destroy_type) GetProcAddress(library, "grpc_call_destroy"); + grpc_server_request_call_import = (grpc_server_request_call_type) GetProcAddress(library, "grpc_server_request_call"); + grpc_server_register_method_import = (grpc_server_register_method_type) GetProcAddress(library, "grpc_server_register_method"); + grpc_server_request_registered_call_import = (grpc_server_request_registered_call_type) GetProcAddress(library, "grpc_server_request_registered_call"); + grpc_server_create_import = (grpc_server_create_type) GetProcAddress(library, "grpc_server_create"); + grpc_server_register_completion_queue_import = (grpc_server_register_completion_queue_type) GetProcAddress(library, "grpc_server_register_completion_queue"); + grpc_server_add_insecure_http2_port_import = (grpc_server_add_insecure_http2_port_type) GetProcAddress(library, "grpc_server_add_insecure_http2_port"); + grpc_server_start_import = (grpc_server_start_type) GetProcAddress(library, "grpc_server_start"); + grpc_server_shutdown_and_notify_import = (grpc_server_shutdown_and_notify_type) GetProcAddress(library, "grpc_server_shutdown_and_notify"); + grpc_server_cancel_all_calls_import = (grpc_server_cancel_all_calls_type) GetProcAddress(library, "grpc_server_cancel_all_calls"); + grpc_server_destroy_import = (grpc_server_destroy_type) GetProcAddress(library, "grpc_server_destroy"); + grpc_tracer_set_enabled_import = (grpc_tracer_set_enabled_type) GetProcAddress(library, "grpc_tracer_set_enabled"); + grpc_header_key_is_legal_import = (grpc_header_key_is_legal_type) GetProcAddress(library, "grpc_header_key_is_legal"); + grpc_header_nonbin_value_is_legal_import = (grpc_header_nonbin_value_is_legal_type) GetProcAddress(library, "grpc_header_nonbin_value_is_legal"); + grpc_is_binary_header_import = (grpc_is_binary_header_type) GetProcAddress(library, "grpc_is_binary_header"); + grpc_auth_property_iterator_next_import = (grpc_auth_property_iterator_next_type) GetProcAddress(library, "grpc_auth_property_iterator_next"); + grpc_auth_context_property_iterator_import = (grpc_auth_context_property_iterator_type) GetProcAddress(library, "grpc_auth_context_property_iterator"); + grpc_auth_context_peer_identity_import = (grpc_auth_context_peer_identity_type) GetProcAddress(library, "grpc_auth_context_peer_identity"); + grpc_auth_context_find_properties_by_name_import = (grpc_auth_context_find_properties_by_name_type) GetProcAddress(library, "grpc_auth_context_find_properties_by_name"); + grpc_auth_context_peer_identity_property_name_import = (grpc_auth_context_peer_identity_property_name_type) GetProcAddress(library, "grpc_auth_context_peer_identity_property_name"); + grpc_auth_context_peer_is_authenticated_import = (grpc_auth_context_peer_is_authenticated_type) GetProcAddress(library, "grpc_auth_context_peer_is_authenticated"); + grpc_call_auth_context_import = (grpc_call_auth_context_type) GetProcAddress(library, "grpc_call_auth_context"); + grpc_auth_context_release_import = (grpc_auth_context_release_type) GetProcAddress(library, "grpc_auth_context_release"); + grpc_auth_context_add_property_import = (grpc_auth_context_add_property_type) GetProcAddress(library, "grpc_auth_context_add_property"); + grpc_auth_context_add_cstring_property_import = (grpc_auth_context_add_cstring_property_type) GetProcAddress(library, "grpc_auth_context_add_cstring_property"); + grpc_auth_context_set_peer_identity_property_name_import = (grpc_auth_context_set_peer_identity_property_name_type) GetProcAddress(library, "grpc_auth_context_set_peer_identity_property_name"); + grpc_channel_credentials_release_import = (grpc_channel_credentials_release_type) GetProcAddress(library, "grpc_channel_credentials_release"); + grpc_google_default_credentials_create_import = (grpc_google_default_credentials_create_type) GetProcAddress(library, "grpc_google_default_credentials_create"); + grpc_ssl_credentials_create_import = (grpc_ssl_credentials_create_type) GetProcAddress(library, "grpc_ssl_credentials_create"); + grpc_call_credentials_release_import = (grpc_call_credentials_release_type) GetProcAddress(library, "grpc_call_credentials_release"); + grpc_composite_channel_credentials_create_import = (grpc_composite_channel_credentials_create_type) GetProcAddress(library, "grpc_composite_channel_credentials_create"); + grpc_composite_call_credentials_create_import = (grpc_composite_call_credentials_create_type) GetProcAddress(library, "grpc_composite_call_credentials_create"); + grpc_google_compute_engine_credentials_create_import = (grpc_google_compute_engine_credentials_create_type) GetProcAddress(library, "grpc_google_compute_engine_credentials_create"); + grpc_max_auth_token_lifetime_import = (grpc_max_auth_token_lifetime_type) GetProcAddress(library, "grpc_max_auth_token_lifetime"); + grpc_service_account_jwt_access_credentials_create_import = (grpc_service_account_jwt_access_credentials_create_type) GetProcAddress(library, "grpc_service_account_jwt_access_credentials_create"); + grpc_google_refresh_token_credentials_create_import = (grpc_google_refresh_token_credentials_create_type) GetProcAddress(library, "grpc_google_refresh_token_credentials_create"); + grpc_access_token_credentials_create_import = (grpc_access_token_credentials_create_type) GetProcAddress(library, "grpc_access_token_credentials_create"); + grpc_google_iam_credentials_create_import = (grpc_google_iam_credentials_create_type) GetProcAddress(library, "grpc_google_iam_credentials_create"); + grpc_metadata_credentials_create_from_plugin_import = (grpc_metadata_credentials_create_from_plugin_type) GetProcAddress(library, "grpc_metadata_credentials_create_from_plugin"); + grpc_secure_channel_create_import = (grpc_secure_channel_create_type) GetProcAddress(library, "grpc_secure_channel_create"); + grpc_server_credentials_release_import = (grpc_server_credentials_release_type) GetProcAddress(library, "grpc_server_credentials_release"); + grpc_ssl_server_credentials_create_import = (grpc_ssl_server_credentials_create_type) GetProcAddress(library, "grpc_ssl_server_credentials_create"); + grpc_server_add_secure_http2_port_import = (grpc_server_add_secure_http2_port_type) GetProcAddress(library, "grpc_server_add_secure_http2_port"); + grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials"); + grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor"); + gpr_malloc_import = (gpr_malloc_type) GetProcAddress(library, "gpr_malloc"); + gpr_free_import = (gpr_free_type) GetProcAddress(library, "gpr_free"); + gpr_realloc_import = (gpr_realloc_type) GetProcAddress(library, "gpr_realloc"); + gpr_malloc_aligned_import = (gpr_malloc_aligned_type) GetProcAddress(library, "gpr_malloc_aligned"); + gpr_free_aligned_import = (gpr_free_aligned_type) GetProcAddress(library, "gpr_free_aligned"); + gpr_set_allocation_functions_import = (gpr_set_allocation_functions_type) GetProcAddress(library, "gpr_set_allocation_functions"); + gpr_get_allocation_functions_import = (gpr_get_allocation_functions_type) GetProcAddress(library, "gpr_get_allocation_functions"); + grpc_raw_byte_buffer_create_import = (grpc_raw_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_byte_buffer_create"); + grpc_raw_compressed_byte_buffer_create_import = (grpc_raw_compressed_byte_buffer_create_type) GetProcAddress(library, "grpc_raw_compressed_byte_buffer_create"); + grpc_byte_buffer_copy_import = (grpc_byte_buffer_copy_type) GetProcAddress(library, "grpc_byte_buffer_copy"); + grpc_byte_buffer_length_import = (grpc_byte_buffer_length_type) GetProcAddress(library, "grpc_byte_buffer_length"); + grpc_byte_buffer_destroy_import = (grpc_byte_buffer_destroy_type) GetProcAddress(library, "grpc_byte_buffer_destroy"); + grpc_byte_buffer_reader_init_import = (grpc_byte_buffer_reader_init_type) GetProcAddress(library, "grpc_byte_buffer_reader_init"); + grpc_byte_buffer_reader_destroy_import = (grpc_byte_buffer_reader_destroy_type) GetProcAddress(library, "grpc_byte_buffer_reader_destroy"); + grpc_byte_buffer_reader_next_import = (grpc_byte_buffer_reader_next_type) GetProcAddress(library, "grpc_byte_buffer_reader_next"); + grpc_byte_buffer_reader_readall_import = (grpc_byte_buffer_reader_readall_type) GetProcAddress(library, "grpc_byte_buffer_reader_readall"); + grpc_raw_byte_buffer_from_reader_import = (grpc_raw_byte_buffer_from_reader_type) GetProcAddress(library, "grpc_raw_byte_buffer_from_reader"); + gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log"); + gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message"); + gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function"); + gpr_slice_ref_import = (gpr_slice_ref_type) GetProcAddress(library, "gpr_slice_ref"); + gpr_slice_unref_import = (gpr_slice_unref_type) GetProcAddress(library, "gpr_slice_unref"); + gpr_slice_new_import = (gpr_slice_new_type) GetProcAddress(library, "gpr_slice_new"); + gpr_slice_new_with_len_import = (gpr_slice_new_with_len_type) GetProcAddress(library, "gpr_slice_new_with_len"); + gpr_slice_malloc_import = (gpr_slice_malloc_type) GetProcAddress(library, "gpr_slice_malloc"); + gpr_slice_from_copied_string_import = (gpr_slice_from_copied_string_type) GetProcAddress(library, "gpr_slice_from_copied_string"); + gpr_slice_from_copied_buffer_import = (gpr_slice_from_copied_buffer_type) GetProcAddress(library, "gpr_slice_from_copied_buffer"); + gpr_slice_from_static_string_import = (gpr_slice_from_static_string_type) GetProcAddress(library, "gpr_slice_from_static_string"); + gpr_slice_sub_import = (gpr_slice_sub_type) GetProcAddress(library, "gpr_slice_sub"); + gpr_slice_sub_no_ref_import = (gpr_slice_sub_no_ref_type) GetProcAddress(library, "gpr_slice_sub_no_ref"); + gpr_slice_split_tail_import = (gpr_slice_split_tail_type) GetProcAddress(library, "gpr_slice_split_tail"); + gpr_slice_split_head_import = (gpr_slice_split_head_type) GetProcAddress(library, "gpr_slice_split_head"); + gpr_empty_slice_import = (gpr_empty_slice_type) GetProcAddress(library, "gpr_empty_slice"); + gpr_slice_cmp_import = (gpr_slice_cmp_type) GetProcAddress(library, "gpr_slice_cmp"); + gpr_slice_str_cmp_import = (gpr_slice_str_cmp_type) GetProcAddress(library, "gpr_slice_str_cmp"); + gpr_slice_buffer_init_import = (gpr_slice_buffer_init_type) GetProcAddress(library, "gpr_slice_buffer_init"); + gpr_slice_buffer_destroy_import = (gpr_slice_buffer_destroy_type) GetProcAddress(library, "gpr_slice_buffer_destroy"); + gpr_slice_buffer_add_import = (gpr_slice_buffer_add_type) GetProcAddress(library, "gpr_slice_buffer_add"); + gpr_slice_buffer_add_indexed_import = (gpr_slice_buffer_add_indexed_type) GetProcAddress(library, "gpr_slice_buffer_add_indexed"); + gpr_slice_buffer_addn_import = (gpr_slice_buffer_addn_type) GetProcAddress(library, "gpr_slice_buffer_addn"); + gpr_slice_buffer_tiny_add_import = (gpr_slice_buffer_tiny_add_type) GetProcAddress(library, "gpr_slice_buffer_tiny_add"); + gpr_slice_buffer_pop_import = (gpr_slice_buffer_pop_type) GetProcAddress(library, "gpr_slice_buffer_pop"); + gpr_slice_buffer_reset_and_unref_import = (gpr_slice_buffer_reset_and_unref_type) GetProcAddress(library, "gpr_slice_buffer_reset_and_unref"); + gpr_slice_buffer_swap_import = (gpr_slice_buffer_swap_type) GetProcAddress(library, "gpr_slice_buffer_swap"); + gpr_slice_buffer_move_into_import = (gpr_slice_buffer_move_into_type) GetProcAddress(library, "gpr_slice_buffer_move_into"); + gpr_slice_buffer_trim_end_import = (gpr_slice_buffer_trim_end_type) GetProcAddress(library, "gpr_slice_buffer_trim_end"); + gpr_slice_buffer_move_first_import = (gpr_slice_buffer_move_first_type) GetProcAddress(library, "gpr_slice_buffer_move_first"); + gpr_slice_buffer_take_first_import = (gpr_slice_buffer_take_first_type) GetProcAddress(library, "gpr_slice_buffer_take_first"); + gpr_mu_init_import = (gpr_mu_init_type) GetProcAddress(library, "gpr_mu_init"); + gpr_mu_destroy_import = (gpr_mu_destroy_type) GetProcAddress(library, "gpr_mu_destroy"); + gpr_mu_lock_import = (gpr_mu_lock_type) GetProcAddress(library, "gpr_mu_lock"); + gpr_mu_unlock_import = (gpr_mu_unlock_type) GetProcAddress(library, "gpr_mu_unlock"); + gpr_mu_trylock_import = (gpr_mu_trylock_type) GetProcAddress(library, "gpr_mu_trylock"); + gpr_cv_init_import = (gpr_cv_init_type) GetProcAddress(library, "gpr_cv_init"); + gpr_cv_destroy_import = (gpr_cv_destroy_type) GetProcAddress(library, "gpr_cv_destroy"); + gpr_cv_wait_import = (gpr_cv_wait_type) GetProcAddress(library, "gpr_cv_wait"); + gpr_cv_signal_import = (gpr_cv_signal_type) GetProcAddress(library, "gpr_cv_signal"); + gpr_cv_broadcast_import = (gpr_cv_broadcast_type) GetProcAddress(library, "gpr_cv_broadcast"); + gpr_once_init_import = (gpr_once_init_type) GetProcAddress(library, "gpr_once_init"); + gpr_event_init_import = (gpr_event_init_type) GetProcAddress(library, "gpr_event_init"); + gpr_event_set_import = (gpr_event_set_type) GetProcAddress(library, "gpr_event_set"); + gpr_event_get_import = (gpr_event_get_type) GetProcAddress(library, "gpr_event_get"); + gpr_event_wait_import = (gpr_event_wait_type) GetProcAddress(library, "gpr_event_wait"); + gpr_ref_init_import = (gpr_ref_init_type) GetProcAddress(library, "gpr_ref_init"); + gpr_ref_import = (gpr_ref_type) GetProcAddress(library, "gpr_ref"); + gpr_refn_import = (gpr_refn_type) GetProcAddress(library, "gpr_refn"); + gpr_unref_import = (gpr_unref_type) GetProcAddress(library, "gpr_unref"); + gpr_stats_init_import = (gpr_stats_init_type) GetProcAddress(library, "gpr_stats_init"); + gpr_stats_inc_import = (gpr_stats_inc_type) GetProcAddress(library, "gpr_stats_inc"); + gpr_stats_read_import = (gpr_stats_read_type) GetProcAddress(library, "gpr_stats_read"); + gpr_time_0_import = (gpr_time_0_type) GetProcAddress(library, "gpr_time_0"); + gpr_inf_future_import = (gpr_inf_future_type) GetProcAddress(library, "gpr_inf_future"); + gpr_inf_past_import = (gpr_inf_past_type) GetProcAddress(library, "gpr_inf_past"); + gpr_time_init_import = (gpr_time_init_type) GetProcAddress(library, "gpr_time_init"); + gpr_now_import = (gpr_now_type) GetProcAddress(library, "gpr_now"); + gpr_convert_clock_type_import = (gpr_convert_clock_type_type) GetProcAddress(library, "gpr_convert_clock_type"); + gpr_time_cmp_import = (gpr_time_cmp_type) GetProcAddress(library, "gpr_time_cmp"); + gpr_time_max_import = (gpr_time_max_type) GetProcAddress(library, "gpr_time_max"); + gpr_time_min_import = (gpr_time_min_type) GetProcAddress(library, "gpr_time_min"); + gpr_time_add_import = (gpr_time_add_type) GetProcAddress(library, "gpr_time_add"); + gpr_time_sub_import = (gpr_time_sub_type) GetProcAddress(library, "gpr_time_sub"); + gpr_time_from_micros_import = (gpr_time_from_micros_type) GetProcAddress(library, "gpr_time_from_micros"); + gpr_time_from_nanos_import = (gpr_time_from_nanos_type) GetProcAddress(library, "gpr_time_from_nanos"); + gpr_time_from_millis_import = (gpr_time_from_millis_type) GetProcAddress(library, "gpr_time_from_millis"); + gpr_time_from_seconds_import = (gpr_time_from_seconds_type) GetProcAddress(library, "gpr_time_from_seconds"); + gpr_time_from_minutes_import = (gpr_time_from_minutes_type) GetProcAddress(library, "gpr_time_from_minutes"); + gpr_time_from_hours_import = (gpr_time_from_hours_type) GetProcAddress(library, "gpr_time_from_hours"); + gpr_time_to_millis_import = (gpr_time_to_millis_type) GetProcAddress(library, "gpr_time_to_millis"); + gpr_time_similar_import = (gpr_time_similar_type) GetProcAddress(library, "gpr_time_similar"); + gpr_sleep_until_import = (gpr_sleep_until_type) GetProcAddress(library, "gpr_sleep_until"); + gpr_timespec_to_micros_import = (gpr_timespec_to_micros_type) GetProcAddress(library, "gpr_timespec_to_micros"); + gpr_avl_create_import = (gpr_avl_create_type) GetProcAddress(library, "gpr_avl_create"); + gpr_avl_ref_import = (gpr_avl_ref_type) GetProcAddress(library, "gpr_avl_ref"); + gpr_avl_unref_import = (gpr_avl_unref_type) GetProcAddress(library, "gpr_avl_unref"); + gpr_avl_add_import = (gpr_avl_add_type) GetProcAddress(library, "gpr_avl_add"); + gpr_avl_remove_import = (gpr_avl_remove_type) GetProcAddress(library, "gpr_avl_remove"); + gpr_avl_get_import = (gpr_avl_get_type) GetProcAddress(library, "gpr_avl_get"); + gpr_cmdline_create_import = (gpr_cmdline_create_type) GetProcAddress(library, "gpr_cmdline_create"); + gpr_cmdline_add_int_import = (gpr_cmdline_add_int_type) GetProcAddress(library, "gpr_cmdline_add_int"); + gpr_cmdline_add_flag_import = (gpr_cmdline_add_flag_type) GetProcAddress(library, "gpr_cmdline_add_flag"); + gpr_cmdline_add_string_import = (gpr_cmdline_add_string_type) GetProcAddress(library, "gpr_cmdline_add_string"); + gpr_cmdline_on_extra_arg_import = (gpr_cmdline_on_extra_arg_type) GetProcAddress(library, "gpr_cmdline_on_extra_arg"); + gpr_cmdline_set_survive_failure_import = (gpr_cmdline_set_survive_failure_type) GetProcAddress(library, "gpr_cmdline_set_survive_failure"); + gpr_cmdline_parse_import = (gpr_cmdline_parse_type) GetProcAddress(library, "gpr_cmdline_parse"); + gpr_cmdline_destroy_import = (gpr_cmdline_destroy_type) GetProcAddress(library, "gpr_cmdline_destroy"); + gpr_cmdline_usage_string_import = (gpr_cmdline_usage_string_type) GetProcAddress(library, "gpr_cmdline_usage_string"); + gpr_cpu_num_cores_import = (gpr_cpu_num_cores_type) GetProcAddress(library, "gpr_cpu_num_cores"); + gpr_cpu_current_cpu_import = (gpr_cpu_current_cpu_type) GetProcAddress(library, "gpr_cpu_current_cpu"); + gpr_histogram_create_import = (gpr_histogram_create_type) GetProcAddress(library, "gpr_histogram_create"); + gpr_histogram_destroy_import = (gpr_histogram_destroy_type) GetProcAddress(library, "gpr_histogram_destroy"); + gpr_histogram_add_import = (gpr_histogram_add_type) GetProcAddress(library, "gpr_histogram_add"); + gpr_histogram_merge_import = (gpr_histogram_merge_type) GetProcAddress(library, "gpr_histogram_merge"); + gpr_histogram_percentile_import = (gpr_histogram_percentile_type) GetProcAddress(library, "gpr_histogram_percentile"); + gpr_histogram_mean_import = (gpr_histogram_mean_type) GetProcAddress(library, "gpr_histogram_mean"); + gpr_histogram_stddev_import = (gpr_histogram_stddev_type) GetProcAddress(library, "gpr_histogram_stddev"); + gpr_histogram_variance_import = (gpr_histogram_variance_type) GetProcAddress(library, "gpr_histogram_variance"); + gpr_histogram_maximum_import = (gpr_histogram_maximum_type) GetProcAddress(library, "gpr_histogram_maximum"); + gpr_histogram_minimum_import = (gpr_histogram_minimum_type) GetProcAddress(library, "gpr_histogram_minimum"); + gpr_histogram_count_import = (gpr_histogram_count_type) GetProcAddress(library, "gpr_histogram_count"); + gpr_histogram_sum_import = (gpr_histogram_sum_type) GetProcAddress(library, "gpr_histogram_sum"); + gpr_histogram_sum_of_squares_import = (gpr_histogram_sum_of_squares_type) GetProcAddress(library, "gpr_histogram_sum_of_squares"); + gpr_histogram_get_contents_import = (gpr_histogram_get_contents_type) GetProcAddress(library, "gpr_histogram_get_contents"); + gpr_histogram_merge_contents_import = (gpr_histogram_merge_contents_type) GetProcAddress(library, "gpr_histogram_merge_contents"); + gpr_join_host_port_import = (gpr_join_host_port_type) GetProcAddress(library, "gpr_join_host_port"); + gpr_split_host_port_import = (gpr_split_host_port_type) GetProcAddress(library, "gpr_split_host_port"); + gpr_format_message_import = (gpr_format_message_type) GetProcAddress(library, "gpr_format_message"); + gpr_strdup_import = (gpr_strdup_type) GetProcAddress(library, "gpr_strdup"); + gpr_asprintf_import = (gpr_asprintf_type) GetProcAddress(library, "gpr_asprintf"); + gpr_subprocess_binary_extension_import = (gpr_subprocess_binary_extension_type) GetProcAddress(library, "gpr_subprocess_binary_extension"); + gpr_subprocess_create_import = (gpr_subprocess_create_type) GetProcAddress(library, "gpr_subprocess_create"); + gpr_subprocess_destroy_import = (gpr_subprocess_destroy_type) GetProcAddress(library, "gpr_subprocess_destroy"); + gpr_subprocess_join_import = (gpr_subprocess_join_type) GetProcAddress(library, "gpr_subprocess_join"); + gpr_subprocess_interrupt_import = (gpr_subprocess_interrupt_type) GetProcAddress(library, "gpr_subprocess_interrupt"); + gpr_thd_new_import = (gpr_thd_new_type) GetProcAddress(library, "gpr_thd_new"); + gpr_thd_options_default_import = (gpr_thd_options_default_type) GetProcAddress(library, "gpr_thd_options_default"); + gpr_thd_options_set_detached_import = (gpr_thd_options_set_detached_type) GetProcAddress(library, "gpr_thd_options_set_detached"); + gpr_thd_options_set_joinable_import = (gpr_thd_options_set_joinable_type) GetProcAddress(library, "gpr_thd_options_set_joinable"); + gpr_thd_options_is_detached_import = (gpr_thd_options_is_detached_type) GetProcAddress(library, "gpr_thd_options_is_detached"); + gpr_thd_options_is_joinable_import = (gpr_thd_options_is_joinable_type) GetProcAddress(library, "gpr_thd_options_is_joinable"); + gpr_thd_currentid_import = (gpr_thd_currentid_type) GetProcAddress(library, "gpr_thd_currentid"); + gpr_thd_join_import = (gpr_thd_join_type) GetProcAddress(library, "gpr_thd_join"); +} + +#endif /* GPR_WIN32 */ diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h new file mode 100644 index 0000000000..618ae5e7fc --- /dev/null +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -0,0 +1,843 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_RB_GRPC_IMPORTS_H_ +#define GRPC_RB_GRPC_IMPORTS_H_ + +#include <grpc/support/port_platform.h> + +#ifdef GPR_WIN32 + +#include <windows.h> + +#include <grpc/census.h> +#include <grpc/compression.h> +#include <grpc/grpc.h> +#include <grpc/grpc_security.h> +#include <grpc/impl/codegen/alloc.h> +#include <grpc/impl/codegen/byte_buffer.h> +#include <grpc/impl/codegen/log.h> +#include <grpc/impl/codegen/slice.h> +#include <grpc/impl/codegen/slice_buffer.h> +#include <grpc/impl/codegen/sync.h> +#include <grpc/impl/codegen/time.h> +#include <grpc/support/avl.h> +#include <grpc/support/cmdline.h> +#include <grpc/support/cpu.h> +#include <grpc/support/histogram.h> +#include <grpc/support/host_port.h> +#include <grpc/support/log_win32.h> +#include <grpc/support/string_util.h> +#include <grpc/support/subprocess.h> +#include <grpc/support/thd.h> + +typedef int(*census_initialize_type)(int features); +extern census_initialize_type census_initialize_import; +#define census_initialize census_initialize_import +typedef void(*census_shutdown_type)(void); +extern census_shutdown_type census_shutdown_import; +#define census_shutdown census_shutdown_import +typedef int(*census_supported_type)(void); +extern census_supported_type census_supported_import; +#define census_supported census_supported_import +typedef int(*census_enabled_type)(void); +extern census_enabled_type census_enabled_import; +#define census_enabled census_enabled_import +typedef census_context *(*census_context_create_type)(const census_context *base, const census_tag *tags, int ntags, census_context_status const **status); +extern census_context_create_type census_context_create_import; +#define census_context_create census_context_create_import +typedef void(*census_context_destroy_type)(census_context *context); +extern census_context_destroy_type census_context_destroy_import; +#define census_context_destroy census_context_destroy_import +typedef const census_context_status *(*census_context_get_status_type)(const census_context *context); +extern census_context_get_status_type census_context_get_status_import; +#define census_context_get_status census_context_get_status_import +typedef void(*census_context_initialize_iterator_type)(const census_context *context, census_context_iterator *iterator); +extern census_context_initialize_iterator_type census_context_initialize_iterator_import; +#define census_context_initialize_iterator census_context_initialize_iterator_import +typedef int(*census_context_next_tag_type)(census_context_iterator *iterator, census_tag *tag); +extern census_context_next_tag_type census_context_next_tag_import; +#define census_context_next_tag census_context_next_tag_import +typedef int(*census_context_get_tag_type)(const census_context *context, const char *key, census_tag *tag); +extern census_context_get_tag_type census_context_get_tag_import; +#define census_context_get_tag census_context_get_tag_import +typedef char *(*census_context_encode_type)(const census_context *context, char *buffer, size_t buf_size, size_t *print_buf_size, size_t *bin_buf_size); +extern census_context_encode_type census_context_encode_import; +#define census_context_encode census_context_encode_import +typedef census_context *(*census_context_decode_type)(const char *buffer, size_t size, const char *bin_buffer, size_t bin_size); +extern census_context_decode_type census_context_decode_import; +#define census_context_decode census_context_decode_import +typedef int(*census_trace_mask_type)(const census_context *context); +extern census_trace_mask_type census_trace_mask_import; +#define census_trace_mask census_trace_mask_import +typedef void(*census_set_trace_mask_type)(int trace_mask); +extern census_set_trace_mask_type census_set_trace_mask_import; +#define census_set_trace_mask census_set_trace_mask_import +typedef census_timestamp(*census_start_rpc_op_timestamp_type)(void); +extern census_start_rpc_op_timestamp_type census_start_rpc_op_timestamp_import; +#define census_start_rpc_op_timestamp census_start_rpc_op_timestamp_import +typedef census_context *(*census_start_client_rpc_op_type)(const census_context *context, int64_t rpc_name_id, const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask, const census_timestamp *start_time); +extern census_start_client_rpc_op_type census_start_client_rpc_op_import; +#define census_start_client_rpc_op census_start_client_rpc_op_import +typedef void(*census_set_rpc_client_peer_type)(census_context *context, const char *peer); +extern census_set_rpc_client_peer_type census_set_rpc_client_peer_import; +#define census_set_rpc_client_peer census_set_rpc_client_peer_import +typedef census_context *(*census_start_server_rpc_op_type)(const char *buffer, int64_t rpc_name_id, const census_rpc_name_info *rpc_name_info, const char *peer, int trace_mask, census_timestamp *start_time); +extern census_start_server_rpc_op_type census_start_server_rpc_op_import; +#define census_start_server_rpc_op census_start_server_rpc_op_import +typedef census_context *(*census_start_op_type)(census_context *context, const char *family, const char *name, int trace_mask); +extern census_start_op_type census_start_op_import; +#define census_start_op census_start_op_import +typedef void(*census_end_op_type)(census_context *context, int status); +extern census_end_op_type census_end_op_import; +#define census_end_op census_end_op_import +typedef void(*census_trace_print_type)(census_context *context, uint32_t type, const char *buffer, size_t n); +extern census_trace_print_type census_trace_print_import; +#define census_trace_print census_trace_print_import +typedef int(*census_trace_scan_start_type)(int consume); +extern census_trace_scan_start_type census_trace_scan_start_import; +#define census_trace_scan_start census_trace_scan_start_import +typedef int(*census_get_trace_record_type)(census_trace_record *trace_record); +extern census_get_trace_record_type census_get_trace_record_import; +#define census_get_trace_record census_get_trace_record_import +typedef void(*census_trace_scan_end_type)(); +extern census_trace_scan_end_type census_trace_scan_end_import; +#define census_trace_scan_end census_trace_scan_end_import +typedef void(*census_record_values_type)(census_context *context, census_value *values, size_t nvalues); +extern census_record_values_type census_record_values_import; +#define census_record_values census_record_values_import +typedef census_view *(*census_view_create_type)(uint32_t metric_id, const census_context *tags, const census_aggregation *aggregations, size_t naggregations); +extern census_view_create_type census_view_create_import; +#define census_view_create census_view_create_import +typedef void(*census_view_delete_type)(census_view *view); +extern census_view_delete_type census_view_delete_import; +#define census_view_delete census_view_delete_import +typedef size_t(*census_view_metric_type)(const census_view *view); +extern census_view_metric_type census_view_metric_import; +#define census_view_metric census_view_metric_import +typedef size_t(*census_view_naggregations_type)(const census_view *view); +extern census_view_naggregations_type census_view_naggregations_import; +#define census_view_naggregations census_view_naggregations_import +typedef const census_context *(*census_view_tags_type)(const census_view *view); +extern census_view_tags_type census_view_tags_import; +#define census_view_tags census_view_tags_import +typedef const census_aggregation *(*census_view_aggregrations_type)(const census_view *view); +extern census_view_aggregrations_type census_view_aggregrations_import; +#define census_view_aggregrations census_view_aggregrations_import +typedef const census_view_data *(*census_view_get_data_type)(const census_view *view); +extern census_view_get_data_type census_view_get_data_import; +#define census_view_get_data census_view_get_data_import +typedef void(*census_view_reset_type)(census_view *view); +extern census_view_reset_type census_view_reset_import; +#define census_view_reset census_view_reset_import +typedef int(*grpc_compression_algorithm_parse_type)(const char *name, size_t name_length, grpc_compression_algorithm *algorithm); +extern grpc_compression_algorithm_parse_type grpc_compression_algorithm_parse_import; +#define grpc_compression_algorithm_parse grpc_compression_algorithm_parse_import +typedef int(*grpc_compression_algorithm_name_type)(grpc_compression_algorithm algorithm, char **name); +extern grpc_compression_algorithm_name_type grpc_compression_algorithm_name_import; +#define grpc_compression_algorithm_name grpc_compression_algorithm_name_import +typedef grpc_compression_algorithm(*grpc_compression_algorithm_for_level_type)(grpc_compression_level level); +extern grpc_compression_algorithm_for_level_type grpc_compression_algorithm_for_level_import; +#define grpc_compression_algorithm_for_level grpc_compression_algorithm_for_level_import +typedef void(*grpc_compression_options_init_type)(grpc_compression_options *opts); +extern grpc_compression_options_init_type grpc_compression_options_init_import; +#define grpc_compression_options_init grpc_compression_options_init_import +typedef void(*grpc_compression_options_enable_algorithm_type)(grpc_compression_options *opts, grpc_compression_algorithm algorithm); +extern grpc_compression_options_enable_algorithm_type grpc_compression_options_enable_algorithm_import; +#define grpc_compression_options_enable_algorithm grpc_compression_options_enable_algorithm_import +typedef void(*grpc_compression_options_disable_algorithm_type)(grpc_compression_options *opts, grpc_compression_algorithm algorithm); +extern grpc_compression_options_disable_algorithm_type grpc_compression_options_disable_algorithm_import; +#define grpc_compression_options_disable_algorithm grpc_compression_options_disable_algorithm_import +typedef int(*grpc_compression_options_is_algorithm_enabled_type)(const grpc_compression_options *opts, grpc_compression_algorithm algorithm); +extern grpc_compression_options_is_algorithm_enabled_type grpc_compression_options_is_algorithm_enabled_import; +#define grpc_compression_options_is_algorithm_enabled grpc_compression_options_is_algorithm_enabled_import +typedef void(*grpc_metadata_array_init_type)(grpc_metadata_array *array); +extern grpc_metadata_array_init_type grpc_metadata_array_init_import; +#define grpc_metadata_array_init grpc_metadata_array_init_import +typedef void(*grpc_metadata_array_destroy_type)(grpc_metadata_array *array); +extern grpc_metadata_array_destroy_type grpc_metadata_array_destroy_import; +#define grpc_metadata_array_destroy grpc_metadata_array_destroy_import +typedef void(*grpc_call_details_init_type)(grpc_call_details *details); +extern grpc_call_details_init_type grpc_call_details_init_import; +#define grpc_call_details_init grpc_call_details_init_import +typedef void(*grpc_call_details_destroy_type)(grpc_call_details *details); +extern grpc_call_details_destroy_type grpc_call_details_destroy_import; +#define grpc_call_details_destroy grpc_call_details_destroy_import +typedef void(*grpc_register_plugin_type)(void (*init)(void), void (*destroy)(void)); +extern grpc_register_plugin_type grpc_register_plugin_import; +#define grpc_register_plugin grpc_register_plugin_import +typedef void(*grpc_init_type)(void); +extern grpc_init_type grpc_init_import; +#define grpc_init grpc_init_import +typedef void(*grpc_shutdown_type)(void); +extern grpc_shutdown_type grpc_shutdown_import; +#define grpc_shutdown grpc_shutdown_import +typedef const char *(*grpc_version_string_type)(void); +extern grpc_version_string_type grpc_version_string_import; +#define grpc_version_string grpc_version_string_import +typedef grpc_completion_queue *(*grpc_completion_queue_create_type)(void *reserved); +extern grpc_completion_queue_create_type grpc_completion_queue_create_import; +#define grpc_completion_queue_create grpc_completion_queue_create_import +typedef grpc_event(*grpc_completion_queue_next_type)(grpc_completion_queue *cq, gpr_timespec deadline, void *reserved); +extern grpc_completion_queue_next_type grpc_completion_queue_next_import; +#define grpc_completion_queue_next grpc_completion_queue_next_import +typedef grpc_event(*grpc_completion_queue_pluck_type)(grpc_completion_queue *cq, void *tag, gpr_timespec deadline, void *reserved); +extern grpc_completion_queue_pluck_type grpc_completion_queue_pluck_import; +#define grpc_completion_queue_pluck grpc_completion_queue_pluck_import +typedef void(*grpc_completion_queue_shutdown_type)(grpc_completion_queue *cq); +extern grpc_completion_queue_shutdown_type grpc_completion_queue_shutdown_import; +#define grpc_completion_queue_shutdown grpc_completion_queue_shutdown_import +typedef void(*grpc_completion_queue_destroy_type)(grpc_completion_queue *cq); +extern grpc_completion_queue_destroy_type grpc_completion_queue_destroy_import; +#define grpc_completion_queue_destroy grpc_completion_queue_destroy_import +typedef grpc_alarm *(*grpc_alarm_create_type)(grpc_completion_queue *cq, gpr_timespec deadline, void *tag); +extern grpc_alarm_create_type grpc_alarm_create_import; +#define grpc_alarm_create grpc_alarm_create_import +typedef void(*grpc_alarm_cancel_type)(grpc_alarm *alarm); +extern grpc_alarm_cancel_type grpc_alarm_cancel_import; +#define grpc_alarm_cancel grpc_alarm_cancel_import +typedef void(*grpc_alarm_destroy_type)(grpc_alarm *alarm); +extern grpc_alarm_destroy_type grpc_alarm_destroy_import; +#define grpc_alarm_destroy grpc_alarm_destroy_import +typedef grpc_connectivity_state(*grpc_channel_check_connectivity_state_type)(grpc_channel *channel, int try_to_connect); +extern grpc_channel_check_connectivity_state_type grpc_channel_check_connectivity_state_import; +#define grpc_channel_check_connectivity_state grpc_channel_check_connectivity_state_import +typedef void(*grpc_channel_watch_connectivity_state_type)(grpc_channel *channel, grpc_connectivity_state last_observed_state, gpr_timespec deadline, grpc_completion_queue *cq, void *tag); +extern grpc_channel_watch_connectivity_state_type grpc_channel_watch_connectivity_state_import; +#define grpc_channel_watch_connectivity_state grpc_channel_watch_connectivity_state_import +typedef grpc_call *(*grpc_channel_create_call_type)(grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *completion_queue, const char *method, const char *host, gpr_timespec deadline, void *reserved); +extern grpc_channel_create_call_type grpc_channel_create_call_import; +#define grpc_channel_create_call grpc_channel_create_call_import +typedef void(*grpc_channel_ping_type)(grpc_channel *channel, grpc_completion_queue *cq, void *tag, void *reserved); +extern grpc_channel_ping_type grpc_channel_ping_import; +#define grpc_channel_ping grpc_channel_ping_import +typedef void *(*grpc_channel_register_call_type)(grpc_channel *channel, const char *method, const char *host, void *reserved); +extern grpc_channel_register_call_type grpc_channel_register_call_import; +#define grpc_channel_register_call grpc_channel_register_call_import +typedef grpc_call *(*grpc_channel_create_registered_call_type)(grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *completion_queue, void *registered_call_handle, gpr_timespec deadline, void *reserved); +extern grpc_channel_create_registered_call_type grpc_channel_create_registered_call_import; +#define grpc_channel_create_registered_call grpc_channel_create_registered_call_import +typedef grpc_call_error(*grpc_call_start_batch_type)(grpc_call *call, const grpc_op *ops, size_t nops, void *tag, void *reserved); +extern grpc_call_start_batch_type grpc_call_start_batch_import; +#define grpc_call_start_batch grpc_call_start_batch_import +typedef char *(*grpc_call_get_peer_type)(grpc_call *call); +extern grpc_call_get_peer_type grpc_call_get_peer_import; +#define grpc_call_get_peer grpc_call_get_peer_import +typedef void(*grpc_census_call_set_context_type)(grpc_call *call, struct census_context *context); +extern grpc_census_call_set_context_type grpc_census_call_set_context_import; +#define grpc_census_call_set_context grpc_census_call_set_context_import +typedef struct census_context *(*grpc_census_call_get_context_type)(grpc_call *call); +extern grpc_census_call_get_context_type grpc_census_call_get_context_import; +#define grpc_census_call_get_context grpc_census_call_get_context_import +typedef char *(*grpc_channel_get_target_type)(grpc_channel *channel); +extern grpc_channel_get_target_type grpc_channel_get_target_import; +#define grpc_channel_get_target grpc_channel_get_target_import +typedef grpc_channel *(*grpc_insecure_channel_create_type)(const char *target, const grpc_channel_args *args, void *reserved); +extern grpc_insecure_channel_create_type grpc_insecure_channel_create_import; +#define grpc_insecure_channel_create grpc_insecure_channel_create_import +typedef grpc_channel *(*grpc_lame_client_channel_create_type)(const char *target, grpc_status_code error_code, const char *error_message); +extern grpc_lame_client_channel_create_type grpc_lame_client_channel_create_import; +#define grpc_lame_client_channel_create grpc_lame_client_channel_create_import +typedef void(*grpc_channel_destroy_type)(grpc_channel *channel); +extern grpc_channel_destroy_type grpc_channel_destroy_import; +#define grpc_channel_destroy grpc_channel_destroy_import +typedef grpc_call_error(*grpc_call_cancel_type)(grpc_call *call, void *reserved); +extern grpc_call_cancel_type grpc_call_cancel_import; +#define grpc_call_cancel grpc_call_cancel_import +typedef grpc_call_error(*grpc_call_cancel_with_status_type)(grpc_call *call, grpc_status_code status, const char *description, void *reserved); +extern grpc_call_cancel_with_status_type grpc_call_cancel_with_status_import; +#define grpc_call_cancel_with_status grpc_call_cancel_with_status_import +typedef void(*grpc_call_destroy_type)(grpc_call *call); +extern grpc_call_destroy_type grpc_call_destroy_import; +#define grpc_call_destroy grpc_call_destroy_import +typedef grpc_call_error(*grpc_server_request_call_type)(grpc_server *server, grpc_call **call, grpc_call_details *details, grpc_metadata_array *request_metadata, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new); +extern grpc_server_request_call_type grpc_server_request_call_import; +#define grpc_server_request_call grpc_server_request_call_import +typedef void *(*grpc_server_register_method_type)(grpc_server *server, const char *method, const char *host); +extern grpc_server_register_method_type grpc_server_register_method_import; +#define grpc_server_register_method grpc_server_register_method_import +typedef grpc_call_error(*grpc_server_request_registered_call_type)(grpc_server *server, void *registered_method, grpc_call **call, gpr_timespec *deadline, grpc_metadata_array *request_metadata, grpc_byte_buffer **optional_payload, grpc_completion_queue *cq_bound_to_call, grpc_completion_queue *cq_for_notification, void *tag_new); +extern grpc_server_request_registered_call_type grpc_server_request_registered_call_import; +#define grpc_server_request_registered_call grpc_server_request_registered_call_import +typedef grpc_server *(*grpc_server_create_type)(const grpc_channel_args *args, void *reserved); +extern grpc_server_create_type grpc_server_create_import; +#define grpc_server_create grpc_server_create_import +typedef void(*grpc_server_register_completion_queue_type)(grpc_server *server, grpc_completion_queue *cq, void *reserved); +extern grpc_server_register_completion_queue_type grpc_server_register_completion_queue_import; +#define grpc_server_register_completion_queue grpc_server_register_completion_queue_import +typedef int(*grpc_server_add_insecure_http2_port_type)(grpc_server *server, const char *addr); +extern grpc_server_add_insecure_http2_port_type grpc_server_add_insecure_http2_port_import; +#define grpc_server_add_insecure_http2_port grpc_server_add_insecure_http2_port_import +typedef void(*grpc_server_start_type)(grpc_server *server); +extern grpc_server_start_type grpc_server_start_import; +#define grpc_server_start grpc_server_start_import +typedef void(*grpc_server_shutdown_and_notify_type)(grpc_server *server, grpc_completion_queue *cq, void *tag); +extern grpc_server_shutdown_and_notify_type grpc_server_shutdown_and_notify_import; +#define grpc_server_shutdown_and_notify grpc_server_shutdown_and_notify_import +typedef void(*grpc_server_cancel_all_calls_type)(grpc_server *server); +extern grpc_server_cancel_all_calls_type grpc_server_cancel_all_calls_import; +#define grpc_server_cancel_all_calls grpc_server_cancel_all_calls_import +typedef void(*grpc_server_destroy_type)(grpc_server *server); +extern grpc_server_destroy_type grpc_server_destroy_import; +#define grpc_server_destroy grpc_server_destroy_import +typedef int(*grpc_tracer_set_enabled_type)(const char *name, int enabled); +extern grpc_tracer_set_enabled_type grpc_tracer_set_enabled_import; +#define grpc_tracer_set_enabled grpc_tracer_set_enabled_import +typedef int(*grpc_header_key_is_legal_type)(const char *key, size_t length); +extern grpc_header_key_is_legal_type grpc_header_key_is_legal_import; +#define grpc_header_key_is_legal grpc_header_key_is_legal_import +typedef int(*grpc_header_nonbin_value_is_legal_type)(const char *value, size_t length); +extern grpc_header_nonbin_value_is_legal_type grpc_header_nonbin_value_is_legal_import; +#define grpc_header_nonbin_value_is_legal grpc_header_nonbin_value_is_legal_import +typedef int(*grpc_is_binary_header_type)(const char *key, size_t length); +extern grpc_is_binary_header_type grpc_is_binary_header_import; +#define grpc_is_binary_header grpc_is_binary_header_import +typedef const grpc_auth_property *(*grpc_auth_property_iterator_next_type)(grpc_auth_property_iterator *it); +extern grpc_auth_property_iterator_next_type grpc_auth_property_iterator_next_import; +#define grpc_auth_property_iterator_next grpc_auth_property_iterator_next_import +typedef grpc_auth_property_iterator(*grpc_auth_context_property_iterator_type)(const grpc_auth_context *ctx); +extern grpc_auth_context_property_iterator_type grpc_auth_context_property_iterator_import; +#define grpc_auth_context_property_iterator grpc_auth_context_property_iterator_import +typedef grpc_auth_property_iterator(*grpc_auth_context_peer_identity_type)(const grpc_auth_context *ctx); +extern grpc_auth_context_peer_identity_type grpc_auth_context_peer_identity_import; +#define grpc_auth_context_peer_identity grpc_auth_context_peer_identity_import +typedef grpc_auth_property_iterator(*grpc_auth_context_find_properties_by_name_type)(const grpc_auth_context *ctx, const char *name); +extern grpc_auth_context_find_properties_by_name_type grpc_auth_context_find_properties_by_name_import; +#define grpc_auth_context_find_properties_by_name grpc_auth_context_find_properties_by_name_import +typedef const char *(*grpc_auth_context_peer_identity_property_name_type)(const grpc_auth_context *ctx); +extern grpc_auth_context_peer_identity_property_name_type grpc_auth_context_peer_identity_property_name_import; +#define grpc_auth_context_peer_identity_property_name grpc_auth_context_peer_identity_property_name_import +typedef int(*grpc_auth_context_peer_is_authenticated_type)(const grpc_auth_context *ctx); +extern grpc_auth_context_peer_is_authenticated_type grpc_auth_context_peer_is_authenticated_import; +#define grpc_auth_context_peer_is_authenticated grpc_auth_context_peer_is_authenticated_import +typedef grpc_auth_context *(*grpc_call_auth_context_type)(grpc_call *call); +extern grpc_call_auth_context_type grpc_call_auth_context_import; +#define grpc_call_auth_context grpc_call_auth_context_import +typedef void(*grpc_auth_context_release_type)(grpc_auth_context *context); +extern grpc_auth_context_release_type grpc_auth_context_release_import; +#define grpc_auth_context_release grpc_auth_context_release_import +typedef void(*grpc_auth_context_add_property_type)(grpc_auth_context *ctx, const char *name, const char *value, size_t value_length); +extern grpc_auth_context_add_property_type grpc_auth_context_add_property_import; +#define grpc_auth_context_add_property grpc_auth_context_add_property_import +typedef void(*grpc_auth_context_add_cstring_property_type)(grpc_auth_context *ctx, const char *name, const char *value); +extern grpc_auth_context_add_cstring_property_type grpc_auth_context_add_cstring_property_import; +#define grpc_auth_context_add_cstring_property grpc_auth_context_add_cstring_property_import +typedef int(*grpc_auth_context_set_peer_identity_property_name_type)(grpc_auth_context *ctx, const char *name); +extern grpc_auth_context_set_peer_identity_property_name_type grpc_auth_context_set_peer_identity_property_name_import; +#define grpc_auth_context_set_peer_identity_property_name grpc_auth_context_set_peer_identity_property_name_import +typedef void(*grpc_channel_credentials_release_type)(grpc_channel_credentials *creds); +extern grpc_channel_credentials_release_type grpc_channel_credentials_release_import; +#define grpc_channel_credentials_release grpc_channel_credentials_release_import +typedef grpc_channel_credentials *(*grpc_google_default_credentials_create_type)(void); +extern grpc_google_default_credentials_create_type grpc_google_default_credentials_create_import; +#define grpc_google_default_credentials_create grpc_google_default_credentials_create_import +typedef grpc_channel_credentials *(*grpc_ssl_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, void *reserved); +extern grpc_ssl_credentials_create_type grpc_ssl_credentials_create_import; +#define grpc_ssl_credentials_create grpc_ssl_credentials_create_import +typedef void(*grpc_call_credentials_release_type)(grpc_call_credentials *creds); +extern grpc_call_credentials_release_type grpc_call_credentials_release_import; +#define grpc_call_credentials_release grpc_call_credentials_release_import +typedef grpc_channel_credentials *(*grpc_composite_channel_credentials_create_type)(grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds, void *reserved); +extern grpc_composite_channel_credentials_create_type grpc_composite_channel_credentials_create_import; +#define grpc_composite_channel_credentials_create grpc_composite_channel_credentials_create_import +typedef grpc_call_credentials *(*grpc_composite_call_credentials_create_type)(grpc_call_credentials *creds1, grpc_call_credentials *creds2, void *reserved); +extern grpc_composite_call_credentials_create_type grpc_composite_call_credentials_create_import; +#define grpc_composite_call_credentials_create grpc_composite_call_credentials_create_import +typedef grpc_call_credentials *(*grpc_google_compute_engine_credentials_create_type)(void *reserved); +extern grpc_google_compute_engine_credentials_create_type grpc_google_compute_engine_credentials_create_import; +#define grpc_google_compute_engine_credentials_create grpc_google_compute_engine_credentials_create_import +typedef gpr_timespec(*grpc_max_auth_token_lifetime_type)(); +extern grpc_max_auth_token_lifetime_type grpc_max_auth_token_lifetime_import; +#define grpc_max_auth_token_lifetime grpc_max_auth_token_lifetime_import +typedef grpc_call_credentials *(*grpc_service_account_jwt_access_credentials_create_type)(const char *json_key, gpr_timespec token_lifetime, void *reserved); +extern grpc_service_account_jwt_access_credentials_create_type grpc_service_account_jwt_access_credentials_create_import; +#define grpc_service_account_jwt_access_credentials_create grpc_service_account_jwt_access_credentials_create_import +typedef grpc_call_credentials *(*grpc_google_refresh_token_credentials_create_type)(const char *json_refresh_token, void *reserved); +extern grpc_google_refresh_token_credentials_create_type grpc_google_refresh_token_credentials_create_import; +#define grpc_google_refresh_token_credentials_create grpc_google_refresh_token_credentials_create_import +typedef grpc_call_credentials *(*grpc_access_token_credentials_create_type)(const char *access_token, void *reserved); +extern grpc_access_token_credentials_create_type grpc_access_token_credentials_create_import; +#define grpc_access_token_credentials_create grpc_access_token_credentials_create_import +typedef grpc_call_credentials *(*grpc_google_iam_credentials_create_type)(const char *authorization_token, const char *authority_selector, void *reserved); +extern grpc_google_iam_credentials_create_type grpc_google_iam_credentials_create_import; +#define grpc_google_iam_credentials_create grpc_google_iam_credentials_create_import +typedef grpc_call_credentials *(*grpc_metadata_credentials_create_from_plugin_type)(grpc_metadata_credentials_plugin plugin, void *reserved); +extern grpc_metadata_credentials_create_from_plugin_type grpc_metadata_credentials_create_from_plugin_import; +#define grpc_metadata_credentials_create_from_plugin grpc_metadata_credentials_create_from_plugin_import +typedef grpc_channel *(*grpc_secure_channel_create_type)(grpc_channel_credentials *creds, const char *target, const grpc_channel_args *args, void *reserved); +extern grpc_secure_channel_create_type grpc_secure_channel_create_import; +#define grpc_secure_channel_create grpc_secure_channel_create_import +typedef void(*grpc_server_credentials_release_type)(grpc_server_credentials *creds); +extern grpc_server_credentials_release_type grpc_server_credentials_release_import; +#define grpc_server_credentials_release grpc_server_credentials_release_import +typedef grpc_server_credentials *(*grpc_ssl_server_credentials_create_type)(const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, size_t num_key_cert_pairs, int force_client_auth, void *reserved); +extern grpc_ssl_server_credentials_create_type grpc_ssl_server_credentials_create_import; +#define grpc_ssl_server_credentials_create grpc_ssl_server_credentials_create_import +typedef int(*grpc_server_add_secure_http2_port_type)(grpc_server *server, const char *addr, grpc_server_credentials *creds); +extern grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import; +#define grpc_server_add_secure_http2_port grpc_server_add_secure_http2_port_import +typedef grpc_call_error(*grpc_call_set_credentials_type)(grpc_call *call, grpc_call_credentials *creds); +extern grpc_call_set_credentials_type grpc_call_set_credentials_import; +#define grpc_call_set_credentials grpc_call_set_credentials_import +typedef void(*grpc_server_credentials_set_auth_metadata_processor_type)(grpc_server_credentials *creds, grpc_auth_metadata_processor processor); +extern grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; +#define grpc_server_credentials_set_auth_metadata_processor grpc_server_credentials_set_auth_metadata_processor_import +typedef void *(*gpr_malloc_type)(size_t size); +extern gpr_malloc_type gpr_malloc_import; +#define gpr_malloc gpr_malloc_import +typedef void(*gpr_free_type)(void *ptr); +extern gpr_free_type gpr_free_import; +#define gpr_free gpr_free_import +typedef void *(*gpr_realloc_type)(void *p, size_t size); +extern gpr_realloc_type gpr_realloc_import; +#define gpr_realloc gpr_realloc_import +typedef void *(*gpr_malloc_aligned_type)(size_t size, size_t alignment_log); +extern gpr_malloc_aligned_type gpr_malloc_aligned_import; +#define gpr_malloc_aligned gpr_malloc_aligned_import +typedef void(*gpr_free_aligned_type)(void *ptr); +extern gpr_free_aligned_type gpr_free_aligned_import; +#define gpr_free_aligned gpr_free_aligned_import +typedef void(*gpr_set_allocation_functions_type)(gpr_allocation_functions functions); +extern gpr_set_allocation_functions_type gpr_set_allocation_functions_import; +#define gpr_set_allocation_functions gpr_set_allocation_functions_import +typedef gpr_allocation_functions(*gpr_get_allocation_functions_type)(); +extern gpr_get_allocation_functions_type gpr_get_allocation_functions_import; +#define gpr_get_allocation_functions gpr_get_allocation_functions_import +typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_create_type)(gpr_slice *slices, size_t nslices); +extern grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import; +#define grpc_raw_byte_buffer_create grpc_raw_byte_buffer_create_import +typedef grpc_byte_buffer *(*grpc_raw_compressed_byte_buffer_create_type)(gpr_slice *slices, size_t nslices, grpc_compression_algorithm compression); +extern grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import; +#define grpc_raw_compressed_byte_buffer_create grpc_raw_compressed_byte_buffer_create_import +typedef grpc_byte_buffer *(*grpc_byte_buffer_copy_type)(grpc_byte_buffer *bb); +extern grpc_byte_buffer_copy_type grpc_byte_buffer_copy_import; +#define grpc_byte_buffer_copy grpc_byte_buffer_copy_import +typedef size_t(*grpc_byte_buffer_length_type)(grpc_byte_buffer *bb); +extern grpc_byte_buffer_length_type grpc_byte_buffer_length_import; +#define grpc_byte_buffer_length grpc_byte_buffer_length_import +typedef void(*grpc_byte_buffer_destroy_type)(grpc_byte_buffer *byte_buffer); +extern grpc_byte_buffer_destroy_type grpc_byte_buffer_destroy_import; +#define grpc_byte_buffer_destroy grpc_byte_buffer_destroy_import +typedef void(*grpc_byte_buffer_reader_init_type)(grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer); +extern grpc_byte_buffer_reader_init_type grpc_byte_buffer_reader_init_import; +#define grpc_byte_buffer_reader_init grpc_byte_buffer_reader_init_import +typedef void(*grpc_byte_buffer_reader_destroy_type)(grpc_byte_buffer_reader *reader); +extern grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import; +#define grpc_byte_buffer_reader_destroy grpc_byte_buffer_reader_destroy_import +typedef int(*grpc_byte_buffer_reader_next_type)(grpc_byte_buffer_reader *reader, gpr_slice *slice); +extern grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import; +#define grpc_byte_buffer_reader_next grpc_byte_buffer_reader_next_import +typedef gpr_slice(*grpc_byte_buffer_reader_readall_type)(grpc_byte_buffer_reader *reader); +extern grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import; +#define grpc_byte_buffer_reader_readall grpc_byte_buffer_reader_readall_import +typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader *reader); +extern grpc_raw_byte_buffer_from_reader_type grpc_raw_byte_buffer_from_reader_import; +#define grpc_raw_byte_buffer_from_reader grpc_raw_byte_buffer_from_reader_import +typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...); +extern gpr_log_type gpr_log_import; +#define gpr_log gpr_log_import +typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message); +extern gpr_log_message_type gpr_log_message_import; +#define gpr_log_message gpr_log_message_import +typedef void(*gpr_set_log_function_type)(gpr_log_func func); +extern gpr_set_log_function_type gpr_set_log_function_import; +#define gpr_set_log_function gpr_set_log_function_import +typedef gpr_slice(*gpr_slice_ref_type)(gpr_slice s); +extern gpr_slice_ref_type gpr_slice_ref_import; +#define gpr_slice_ref gpr_slice_ref_import +typedef void(*gpr_slice_unref_type)(gpr_slice s); +extern gpr_slice_unref_type gpr_slice_unref_import; +#define gpr_slice_unref gpr_slice_unref_import +typedef gpr_slice(*gpr_slice_new_type)(void *p, size_t len, void (*destroy)(void *)); +extern gpr_slice_new_type gpr_slice_new_import; +#define gpr_slice_new gpr_slice_new_import +typedef gpr_slice(*gpr_slice_new_with_len_type)(void *p, size_t len, void (*destroy)(void *, size_t)); +extern gpr_slice_new_with_len_type gpr_slice_new_with_len_import; +#define gpr_slice_new_with_len gpr_slice_new_with_len_import +typedef gpr_slice(*gpr_slice_malloc_type)(size_t length); +extern gpr_slice_malloc_type gpr_slice_malloc_import; +#define gpr_slice_malloc gpr_slice_malloc_import +typedef gpr_slice(*gpr_slice_from_copied_string_type)(const char *source); +extern gpr_slice_from_copied_string_type gpr_slice_from_copied_string_import; +#define gpr_slice_from_copied_string gpr_slice_from_copied_string_import +typedef gpr_slice(*gpr_slice_from_copied_buffer_type)(const char *source, size_t len); +extern gpr_slice_from_copied_buffer_type gpr_slice_from_copied_buffer_import; +#define gpr_slice_from_copied_buffer gpr_slice_from_copied_buffer_import +typedef gpr_slice(*gpr_slice_from_static_string_type)(const char *source); +extern gpr_slice_from_static_string_type gpr_slice_from_static_string_import; +#define gpr_slice_from_static_string gpr_slice_from_static_string_import +typedef gpr_slice(*gpr_slice_sub_type)(gpr_slice s, size_t begin, size_t end); +extern gpr_slice_sub_type gpr_slice_sub_import; +#define gpr_slice_sub gpr_slice_sub_import +typedef gpr_slice(*gpr_slice_sub_no_ref_type)(gpr_slice s, size_t begin, size_t end); +extern gpr_slice_sub_no_ref_type gpr_slice_sub_no_ref_import; +#define gpr_slice_sub_no_ref gpr_slice_sub_no_ref_import +typedef gpr_slice(*gpr_slice_split_tail_type)(gpr_slice *s, size_t split); +extern gpr_slice_split_tail_type gpr_slice_split_tail_import; +#define gpr_slice_split_tail gpr_slice_split_tail_import +typedef gpr_slice(*gpr_slice_split_head_type)(gpr_slice *s, size_t split); +extern gpr_slice_split_head_type gpr_slice_split_head_import; +#define gpr_slice_split_head gpr_slice_split_head_import +typedef gpr_slice(*gpr_empty_slice_type)(void); +extern gpr_empty_slice_type gpr_empty_slice_import; +#define gpr_empty_slice gpr_empty_slice_import +typedef int(*gpr_slice_cmp_type)(gpr_slice a, gpr_slice b); +extern gpr_slice_cmp_type gpr_slice_cmp_import; +#define gpr_slice_cmp gpr_slice_cmp_import +typedef int(*gpr_slice_str_cmp_type)(gpr_slice a, const char *b); +extern gpr_slice_str_cmp_type gpr_slice_str_cmp_import; +#define gpr_slice_str_cmp gpr_slice_str_cmp_import +typedef void(*gpr_slice_buffer_init_type)(gpr_slice_buffer *sb); +extern gpr_slice_buffer_init_type gpr_slice_buffer_init_import; +#define gpr_slice_buffer_init gpr_slice_buffer_init_import +typedef void(*gpr_slice_buffer_destroy_type)(gpr_slice_buffer *sb); +extern gpr_slice_buffer_destroy_type gpr_slice_buffer_destroy_import; +#define gpr_slice_buffer_destroy gpr_slice_buffer_destroy_import +typedef void(*gpr_slice_buffer_add_type)(gpr_slice_buffer *sb, gpr_slice slice); +extern gpr_slice_buffer_add_type gpr_slice_buffer_add_import; +#define gpr_slice_buffer_add gpr_slice_buffer_add_import +typedef size_t(*gpr_slice_buffer_add_indexed_type)(gpr_slice_buffer *sb, gpr_slice slice); +extern gpr_slice_buffer_add_indexed_type gpr_slice_buffer_add_indexed_import; +#define gpr_slice_buffer_add_indexed gpr_slice_buffer_add_indexed_import +typedef void(*gpr_slice_buffer_addn_type)(gpr_slice_buffer *sb, gpr_slice *slices, size_t n); +extern gpr_slice_buffer_addn_type gpr_slice_buffer_addn_import; +#define gpr_slice_buffer_addn gpr_slice_buffer_addn_import +typedef uint8_t *(*gpr_slice_buffer_tiny_add_type)(gpr_slice_buffer *sb, size_t len); +extern gpr_slice_buffer_tiny_add_type gpr_slice_buffer_tiny_add_import; +#define gpr_slice_buffer_tiny_add gpr_slice_buffer_tiny_add_import +typedef void(*gpr_slice_buffer_pop_type)(gpr_slice_buffer *sb); +extern gpr_slice_buffer_pop_type gpr_slice_buffer_pop_import; +#define gpr_slice_buffer_pop gpr_slice_buffer_pop_import +typedef void(*gpr_slice_buffer_reset_and_unref_type)(gpr_slice_buffer *sb); +extern gpr_slice_buffer_reset_and_unref_type gpr_slice_buffer_reset_and_unref_import; +#define gpr_slice_buffer_reset_and_unref gpr_slice_buffer_reset_and_unref_import +typedef void(*gpr_slice_buffer_swap_type)(gpr_slice_buffer *a, gpr_slice_buffer *b); +extern gpr_slice_buffer_swap_type gpr_slice_buffer_swap_import; +#define gpr_slice_buffer_swap gpr_slice_buffer_swap_import +typedef void(*gpr_slice_buffer_move_into_type)(gpr_slice_buffer *src, gpr_slice_buffer *dst); +extern gpr_slice_buffer_move_into_type gpr_slice_buffer_move_into_import; +#define gpr_slice_buffer_move_into gpr_slice_buffer_move_into_import +typedef void(*gpr_slice_buffer_trim_end_type)(gpr_slice_buffer *src, size_t n, gpr_slice_buffer *garbage); +extern gpr_slice_buffer_trim_end_type gpr_slice_buffer_trim_end_import; +#define gpr_slice_buffer_trim_end gpr_slice_buffer_trim_end_import +typedef void(*gpr_slice_buffer_move_first_type)(gpr_slice_buffer *src, size_t n, gpr_slice_buffer *dst); +extern gpr_slice_buffer_move_first_type gpr_slice_buffer_move_first_import; +#define gpr_slice_buffer_move_first gpr_slice_buffer_move_first_import +typedef gpr_slice(*gpr_slice_buffer_take_first_type)(gpr_slice_buffer *src); +extern gpr_slice_buffer_take_first_type gpr_slice_buffer_take_first_import; +#define gpr_slice_buffer_take_first gpr_slice_buffer_take_first_import +typedef void(*gpr_mu_init_type)(gpr_mu *mu); +extern gpr_mu_init_type gpr_mu_init_import; +#define gpr_mu_init gpr_mu_init_import +typedef void(*gpr_mu_destroy_type)(gpr_mu *mu); +extern gpr_mu_destroy_type gpr_mu_destroy_import; +#define gpr_mu_destroy gpr_mu_destroy_import +typedef void(*gpr_mu_lock_type)(gpr_mu *mu); +extern gpr_mu_lock_type gpr_mu_lock_import; +#define gpr_mu_lock gpr_mu_lock_import +typedef void(*gpr_mu_unlock_type)(gpr_mu *mu); +extern gpr_mu_unlock_type gpr_mu_unlock_import; +#define gpr_mu_unlock gpr_mu_unlock_import +typedef int(*gpr_mu_trylock_type)(gpr_mu *mu); +extern gpr_mu_trylock_type gpr_mu_trylock_import; +#define gpr_mu_trylock gpr_mu_trylock_import +typedef void(*gpr_cv_init_type)(gpr_cv *cv); +extern gpr_cv_init_type gpr_cv_init_import; +#define gpr_cv_init gpr_cv_init_import +typedef void(*gpr_cv_destroy_type)(gpr_cv *cv); +extern gpr_cv_destroy_type gpr_cv_destroy_import; +#define gpr_cv_destroy gpr_cv_destroy_import +typedef int(*gpr_cv_wait_type)(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline); +extern gpr_cv_wait_type gpr_cv_wait_import; +#define gpr_cv_wait gpr_cv_wait_import +typedef void(*gpr_cv_signal_type)(gpr_cv *cv); +extern gpr_cv_signal_type gpr_cv_signal_import; +#define gpr_cv_signal gpr_cv_signal_import +typedef void(*gpr_cv_broadcast_type)(gpr_cv *cv); +extern gpr_cv_broadcast_type gpr_cv_broadcast_import; +#define gpr_cv_broadcast gpr_cv_broadcast_import +typedef void(*gpr_once_init_type)(gpr_once *once, void (*init_routine)(void)); +extern gpr_once_init_type gpr_once_init_import; +#define gpr_once_init gpr_once_init_import +typedef void(*gpr_event_init_type)(gpr_event *ev); +extern gpr_event_init_type gpr_event_init_import; +#define gpr_event_init gpr_event_init_import +typedef void(*gpr_event_set_type)(gpr_event *ev, void *value); +extern gpr_event_set_type gpr_event_set_import; +#define gpr_event_set gpr_event_set_import +typedef void *(*gpr_event_get_type)(gpr_event *ev); +extern gpr_event_get_type gpr_event_get_import; +#define gpr_event_get gpr_event_get_import +typedef void *(*gpr_event_wait_type)(gpr_event *ev, gpr_timespec abs_deadline); +extern gpr_event_wait_type gpr_event_wait_import; +#define gpr_event_wait gpr_event_wait_import +typedef void(*gpr_ref_init_type)(gpr_refcount *r, int n); +extern gpr_ref_init_type gpr_ref_init_import; +#define gpr_ref_init gpr_ref_init_import +typedef void(*gpr_ref_type)(gpr_refcount *r); +extern gpr_ref_type gpr_ref_import; +#define gpr_ref gpr_ref_import +typedef void(*gpr_refn_type)(gpr_refcount *r, int n); +extern gpr_refn_type gpr_refn_import; +#define gpr_refn gpr_refn_import +typedef int(*gpr_unref_type)(gpr_refcount *r); +extern gpr_unref_type gpr_unref_import; +#define gpr_unref gpr_unref_import +typedef void(*gpr_stats_init_type)(gpr_stats_counter *c, intptr_t n); +extern gpr_stats_init_type gpr_stats_init_import; +#define gpr_stats_init gpr_stats_init_import +typedef void(*gpr_stats_inc_type)(gpr_stats_counter *c, intptr_t inc); +extern gpr_stats_inc_type gpr_stats_inc_import; +#define gpr_stats_inc gpr_stats_inc_import +typedef intptr_t(*gpr_stats_read_type)(const gpr_stats_counter *c); +extern gpr_stats_read_type gpr_stats_read_import; +#define gpr_stats_read gpr_stats_read_import +typedef gpr_timespec(*gpr_time_0_type)(gpr_clock_type type); +extern gpr_time_0_type gpr_time_0_import; +#define gpr_time_0 gpr_time_0_import +typedef gpr_timespec(*gpr_inf_future_type)(gpr_clock_type type); +extern gpr_inf_future_type gpr_inf_future_import; +#define gpr_inf_future gpr_inf_future_import +typedef gpr_timespec(*gpr_inf_past_type)(gpr_clock_type type); +extern gpr_inf_past_type gpr_inf_past_import; +#define gpr_inf_past gpr_inf_past_import +typedef void(*gpr_time_init_type)(void); +extern gpr_time_init_type gpr_time_init_import; +#define gpr_time_init gpr_time_init_import +typedef gpr_timespec(*gpr_now_type)(gpr_clock_type clock); +extern gpr_now_type gpr_now_import; +#define gpr_now gpr_now_import +typedef gpr_timespec(*gpr_convert_clock_type_type)(gpr_timespec t, gpr_clock_type target_clock); +extern gpr_convert_clock_type_type gpr_convert_clock_type_import; +#define gpr_convert_clock_type gpr_convert_clock_type_import +typedef int(*gpr_time_cmp_type)(gpr_timespec a, gpr_timespec b); +extern gpr_time_cmp_type gpr_time_cmp_import; +#define gpr_time_cmp gpr_time_cmp_import +typedef gpr_timespec(*gpr_time_max_type)(gpr_timespec a, gpr_timespec b); +extern gpr_time_max_type gpr_time_max_import; +#define gpr_time_max gpr_time_max_import +typedef gpr_timespec(*gpr_time_min_type)(gpr_timespec a, gpr_timespec b); +extern gpr_time_min_type gpr_time_min_import; +#define gpr_time_min gpr_time_min_import +typedef gpr_timespec(*gpr_time_add_type)(gpr_timespec a, gpr_timespec b); +extern gpr_time_add_type gpr_time_add_import; +#define gpr_time_add gpr_time_add_import +typedef gpr_timespec(*gpr_time_sub_type)(gpr_timespec a, gpr_timespec b); +extern gpr_time_sub_type gpr_time_sub_import; +#define gpr_time_sub gpr_time_sub_import +typedef gpr_timespec(*gpr_time_from_micros_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_micros_type gpr_time_from_micros_import; +#define gpr_time_from_micros gpr_time_from_micros_import +typedef gpr_timespec(*gpr_time_from_nanos_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_nanos_type gpr_time_from_nanos_import; +#define gpr_time_from_nanos gpr_time_from_nanos_import +typedef gpr_timespec(*gpr_time_from_millis_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_millis_type gpr_time_from_millis_import; +#define gpr_time_from_millis gpr_time_from_millis_import +typedef gpr_timespec(*gpr_time_from_seconds_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_seconds_type gpr_time_from_seconds_import; +#define gpr_time_from_seconds gpr_time_from_seconds_import +typedef gpr_timespec(*gpr_time_from_minutes_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_minutes_type gpr_time_from_minutes_import; +#define gpr_time_from_minutes gpr_time_from_minutes_import +typedef gpr_timespec(*gpr_time_from_hours_type)(int64_t x, gpr_clock_type clock_type); +extern gpr_time_from_hours_type gpr_time_from_hours_import; +#define gpr_time_from_hours gpr_time_from_hours_import +typedef int32_t(*gpr_time_to_millis_type)(gpr_timespec timespec); +extern gpr_time_to_millis_type gpr_time_to_millis_import; +#define gpr_time_to_millis gpr_time_to_millis_import +typedef int(*gpr_time_similar_type)(gpr_timespec a, gpr_timespec b, gpr_timespec threshold); +extern gpr_time_similar_type gpr_time_similar_import; +#define gpr_time_similar gpr_time_similar_import +typedef void(*gpr_sleep_until_type)(gpr_timespec until); +extern gpr_sleep_until_type gpr_sleep_until_import; +#define gpr_sleep_until gpr_sleep_until_import +typedef double(*gpr_timespec_to_micros_type)(gpr_timespec t); +extern gpr_timespec_to_micros_type gpr_timespec_to_micros_import; +#define gpr_timespec_to_micros gpr_timespec_to_micros_import +typedef gpr_avl(*gpr_avl_create_type)(const gpr_avl_vtable *vtable); +extern gpr_avl_create_type gpr_avl_create_import; +#define gpr_avl_create gpr_avl_create_import +typedef gpr_avl(*gpr_avl_ref_type)(gpr_avl avl); +extern gpr_avl_ref_type gpr_avl_ref_import; +#define gpr_avl_ref gpr_avl_ref_import +typedef void(*gpr_avl_unref_type)(gpr_avl avl); +extern gpr_avl_unref_type gpr_avl_unref_import; +#define gpr_avl_unref gpr_avl_unref_import +typedef gpr_avl(*gpr_avl_add_type)(gpr_avl avl, void *key, void *value); +extern gpr_avl_add_type gpr_avl_add_import; +#define gpr_avl_add gpr_avl_add_import +typedef gpr_avl(*gpr_avl_remove_type)(gpr_avl avl, void *key); +extern gpr_avl_remove_type gpr_avl_remove_import; +#define gpr_avl_remove gpr_avl_remove_import +typedef void *(*gpr_avl_get_type)(gpr_avl avl, void *key); +extern gpr_avl_get_type gpr_avl_get_import; +#define gpr_avl_get gpr_avl_get_import +typedef gpr_cmdline *(*gpr_cmdline_create_type)(const char *description); +extern gpr_cmdline_create_type gpr_cmdline_create_import; +#define gpr_cmdline_create gpr_cmdline_create_import +typedef void(*gpr_cmdline_add_int_type)(gpr_cmdline *cl, const char *name, const char *help, int *value); +extern gpr_cmdline_add_int_type gpr_cmdline_add_int_import; +#define gpr_cmdline_add_int gpr_cmdline_add_int_import +typedef void(*gpr_cmdline_add_flag_type)(gpr_cmdline *cl, const char *name, const char *help, int *value); +extern gpr_cmdline_add_flag_type gpr_cmdline_add_flag_import; +#define gpr_cmdline_add_flag gpr_cmdline_add_flag_import +typedef void(*gpr_cmdline_add_string_type)(gpr_cmdline *cl, const char *name, const char *help, char **value); +extern gpr_cmdline_add_string_type gpr_cmdline_add_string_import; +#define gpr_cmdline_add_string gpr_cmdline_add_string_import +typedef void(*gpr_cmdline_on_extra_arg_type)(gpr_cmdline *cl, const char *name, const char *help, void (*on_extra_arg)(void *user_data, const char *arg), void *user_data); +extern gpr_cmdline_on_extra_arg_type gpr_cmdline_on_extra_arg_import; +#define gpr_cmdline_on_extra_arg gpr_cmdline_on_extra_arg_import +typedef void(*gpr_cmdline_set_survive_failure_type)(gpr_cmdline *cl); +extern gpr_cmdline_set_survive_failure_type gpr_cmdline_set_survive_failure_import; +#define gpr_cmdline_set_survive_failure gpr_cmdline_set_survive_failure_import +typedef int(*gpr_cmdline_parse_type)(gpr_cmdline *cl, int argc, char **argv); +extern gpr_cmdline_parse_type gpr_cmdline_parse_import; +#define gpr_cmdline_parse gpr_cmdline_parse_import +typedef void(*gpr_cmdline_destroy_type)(gpr_cmdline *cl); +extern gpr_cmdline_destroy_type gpr_cmdline_destroy_import; +#define gpr_cmdline_destroy gpr_cmdline_destroy_import +typedef char *(*gpr_cmdline_usage_string_type)(gpr_cmdline *cl, const char *argv0); +extern gpr_cmdline_usage_string_type gpr_cmdline_usage_string_import; +#define gpr_cmdline_usage_string gpr_cmdline_usage_string_import +typedef unsigned(*gpr_cpu_num_cores_type)(void); +extern gpr_cpu_num_cores_type gpr_cpu_num_cores_import; +#define gpr_cpu_num_cores gpr_cpu_num_cores_import +typedef unsigned(*gpr_cpu_current_cpu_type)(void); +extern gpr_cpu_current_cpu_type gpr_cpu_current_cpu_import; +#define gpr_cpu_current_cpu gpr_cpu_current_cpu_import +typedef gpr_histogram *(*gpr_histogram_create_type)(double resolution, double max_bucket_start); +extern gpr_histogram_create_type gpr_histogram_create_import; +#define gpr_histogram_create gpr_histogram_create_import +typedef void(*gpr_histogram_destroy_type)(gpr_histogram *h); +extern gpr_histogram_destroy_type gpr_histogram_destroy_import; +#define gpr_histogram_destroy gpr_histogram_destroy_import +typedef void(*gpr_histogram_add_type)(gpr_histogram *h, double x); +extern gpr_histogram_add_type gpr_histogram_add_import; +#define gpr_histogram_add gpr_histogram_add_import +typedef int(*gpr_histogram_merge_type)(gpr_histogram *dst, const gpr_histogram *src); +extern gpr_histogram_merge_type gpr_histogram_merge_import; +#define gpr_histogram_merge gpr_histogram_merge_import +typedef double(*gpr_histogram_percentile_type)(gpr_histogram *histogram, double percentile); +extern gpr_histogram_percentile_type gpr_histogram_percentile_import; +#define gpr_histogram_percentile gpr_histogram_percentile_import +typedef double(*gpr_histogram_mean_type)(gpr_histogram *histogram); +extern gpr_histogram_mean_type gpr_histogram_mean_import; +#define gpr_histogram_mean gpr_histogram_mean_import +typedef double(*gpr_histogram_stddev_type)(gpr_histogram *histogram); +extern gpr_histogram_stddev_type gpr_histogram_stddev_import; +#define gpr_histogram_stddev gpr_histogram_stddev_import +typedef double(*gpr_histogram_variance_type)(gpr_histogram *histogram); +extern gpr_histogram_variance_type gpr_histogram_variance_import; +#define gpr_histogram_variance gpr_histogram_variance_import +typedef double(*gpr_histogram_maximum_type)(gpr_histogram *histogram); +extern gpr_histogram_maximum_type gpr_histogram_maximum_import; +#define gpr_histogram_maximum gpr_histogram_maximum_import +typedef double(*gpr_histogram_minimum_type)(gpr_histogram *histogram); +extern gpr_histogram_minimum_type gpr_histogram_minimum_import; +#define gpr_histogram_minimum gpr_histogram_minimum_import +typedef double(*gpr_histogram_count_type)(gpr_histogram *histogram); +extern gpr_histogram_count_type gpr_histogram_count_import; +#define gpr_histogram_count gpr_histogram_count_import +typedef double(*gpr_histogram_sum_type)(gpr_histogram *histogram); +extern gpr_histogram_sum_type gpr_histogram_sum_import; +#define gpr_histogram_sum gpr_histogram_sum_import +typedef double(*gpr_histogram_sum_of_squares_type)(gpr_histogram *histogram); +extern gpr_histogram_sum_of_squares_type gpr_histogram_sum_of_squares_import; +#define gpr_histogram_sum_of_squares gpr_histogram_sum_of_squares_import +typedef const uint32_t *(*gpr_histogram_get_contents_type)(gpr_histogram *histogram, size_t *count); +extern gpr_histogram_get_contents_type gpr_histogram_get_contents_import; +#define gpr_histogram_get_contents gpr_histogram_get_contents_import +typedef void(*gpr_histogram_merge_contents_type)(gpr_histogram *histogram, const uint32_t *data, size_t data_count, double min_seen, double max_seen, double sum, double sum_of_squares, double count); +extern gpr_histogram_merge_contents_type gpr_histogram_merge_contents_import; +#define gpr_histogram_merge_contents gpr_histogram_merge_contents_import +typedef int(*gpr_join_host_port_type)(char **out, const char *host, int port); +extern gpr_join_host_port_type gpr_join_host_port_import; +#define gpr_join_host_port gpr_join_host_port_import +typedef int(*gpr_split_host_port_type)(const char *name, char **host, char **port); +extern gpr_split_host_port_type gpr_split_host_port_import; +#define gpr_split_host_port gpr_split_host_port_import +typedef char *(*gpr_format_message_type)(int messageid); +extern gpr_format_message_type gpr_format_message_import; +#define gpr_format_message gpr_format_message_import +typedef char *(*gpr_strdup_type)(const char *src); +extern gpr_strdup_type gpr_strdup_import; +#define gpr_strdup gpr_strdup_import +typedef int(*gpr_asprintf_type)(char **strp, const char *format, ...); +extern gpr_asprintf_type gpr_asprintf_import; +#define gpr_asprintf gpr_asprintf_import +typedef const char *(*gpr_subprocess_binary_extension_type)(); +extern gpr_subprocess_binary_extension_type gpr_subprocess_binary_extension_import; +#define gpr_subprocess_binary_extension gpr_subprocess_binary_extension_import +typedef gpr_subprocess *(*gpr_subprocess_create_type)(int argc, const char **argv); +extern gpr_subprocess_create_type gpr_subprocess_create_import; +#define gpr_subprocess_create gpr_subprocess_create_import +typedef void(*gpr_subprocess_destroy_type)(gpr_subprocess *p); +extern gpr_subprocess_destroy_type gpr_subprocess_destroy_import; +#define gpr_subprocess_destroy gpr_subprocess_destroy_import +typedef int(*gpr_subprocess_join_type)(gpr_subprocess *p); +extern gpr_subprocess_join_type gpr_subprocess_join_import; +#define gpr_subprocess_join gpr_subprocess_join_import +typedef void(*gpr_subprocess_interrupt_type)(gpr_subprocess *p); +extern gpr_subprocess_interrupt_type gpr_subprocess_interrupt_import; +#define gpr_subprocess_interrupt gpr_subprocess_interrupt_import +typedef int(*gpr_thd_new_type)(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg, const gpr_thd_options *options); +extern gpr_thd_new_type gpr_thd_new_import; +#define gpr_thd_new gpr_thd_new_import +typedef gpr_thd_options(*gpr_thd_options_default_type)(void); +extern gpr_thd_options_default_type gpr_thd_options_default_import; +#define gpr_thd_options_default gpr_thd_options_default_import +typedef void(*gpr_thd_options_set_detached_type)(gpr_thd_options *options); +extern gpr_thd_options_set_detached_type gpr_thd_options_set_detached_import; +#define gpr_thd_options_set_detached gpr_thd_options_set_detached_import +typedef void(*gpr_thd_options_set_joinable_type)(gpr_thd_options *options); +extern gpr_thd_options_set_joinable_type gpr_thd_options_set_joinable_import; +#define gpr_thd_options_set_joinable gpr_thd_options_set_joinable_import +typedef int(*gpr_thd_options_is_detached_type)(const gpr_thd_options *options); +extern gpr_thd_options_is_detached_type gpr_thd_options_is_detached_import; +#define gpr_thd_options_is_detached gpr_thd_options_is_detached_import +typedef int(*gpr_thd_options_is_joinable_type)(const gpr_thd_options *options); +extern gpr_thd_options_is_joinable_type gpr_thd_options_is_joinable_import; +#define gpr_thd_options_is_joinable gpr_thd_options_is_joinable_import +typedef gpr_thd_id(*gpr_thd_currentid_type)(void); +extern gpr_thd_currentid_type gpr_thd_currentid_import; +#define gpr_thd_currentid gpr_thd_currentid_import +typedef void(*gpr_thd_join_type)(gpr_thd_id t); +extern gpr_thd_join_type gpr_thd_join_import; +#define gpr_thd_join gpr_thd_join_import + +void grpc_rb_load_imports(HMODULE library); + +#endif /* GPR_WIN32 */ + +#endif diff --git a/src/ruby/ext/grpc/rb_loader.c b/src/ruby/ext/grpc/rb_loader.c new file mode 100644 index 0000000000..242535f164 --- /dev/null +++ b/src/ruby/ext/grpc/rb_loader.c @@ -0,0 +1,72 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "rb_grpc_imports.generated.h" + +#if GPR_WIN32 +#include <tchar.h> + +int grpc_rb_load_core() { +#if GPR_ARCH_64 + TCHAR fname[] = _T("grpc_c.64.ruby"); +#else + TCHAR fname[] = _T("grpc_c.32.ruby"); +#endif + HMODULE module = GetModuleHandle(_T("grpc_c.so")); + TCHAR path[2048 + 32] = _T(""); + LPTSTR seek_back = NULL; + GetModuleFileName(module, path, 2048); + + seek_back = _tcsrchr(path, _T('\\')); + + while (seek_back) { + HMODULE grpc_c; + _tcscpy(seek_back + 1, fname); + grpc_c = LoadLibrary(path); + if (grpc_c) { + grpc_rb_load_imports(grpc_c); + return 1; + } else { + *seek_back = _T('\0'); + seek_back = _tcsrchr(path, _T('\\')); + } + } + + return 0; +} + +#else + +int grpc_rb_load_core() { return 1; } + +#endif diff --git a/src/objective-c/GRPCClient/private/GRPCUnsecuredChannel.h b/src/ruby/ext/grpc/rb_loader.h index 8528be44c0..d0c1613a64 100644 --- a/src/objective-c/GRPCClient/private/GRPCUnsecuredChannel.h +++ b/src/ruby/ext/grpc/rb_loader.h @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,8 +31,10 @@ * */ -#import "GRPCChannel.h" +#ifndef GRPC_RB_LOADER_H_ +#define GRPC_RB_LOADER_H_ -@interface GRPCUnsecuredChannel : GRPCChannel -- (instancetype)initWithHost:(NSString *)host NS_DESIGNATED_INITIALIZER; -@end +/* Attempts to load the core if necessary, and return non-zero upon succes. */ +int grpc_rb_load_core(); + +#endif /* GRPC_RB_BYTE_BUFFER_H_ */ diff --git a/src/ruby/ext/grpc/rb_server.c b/src/ruby/ext/grpc/rb_server.c index ebdd7e1a34..37cc55a651 100644 --- a/src/ruby/ext/grpc/rb_server.c +++ b/src/ruby/ext/grpc/rb_server.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_server.h" #include <ruby/ruby.h> diff --git a/src/ruby/ext/grpc/rb_server_credentials.c b/src/ruby/ext/grpc/rb_server_credentials.c index de57585e0b..4ea59b6b27 100644 --- a/src/ruby/ext/grpc/rb_server_credentials.c +++ b/src/ruby/ext/grpc/rb_server_credentials.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -31,6 +31,8 @@ * */ +#include <ruby/ruby.h> +#include "rb_grpc_imports.generated.h" #include "rb_server_credentials.h" #include <ruby/ruby.h> @@ -175,7 +177,7 @@ static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs, VALUE key = Qnil; VALUE key_cert = Qnil; int auth_client = 0; - int num_key_certs = 0; + long num_key_certs = 0; int i; if (NIL_P(force_client_auth) || diff --git a/src/ruby/lib/grpc/generic/bidi_call.rb b/src/ruby/lib/grpc/generic/bidi_call.rb index 6b9b785693..213176bd48 100644 --- a/src/ruby/lib/grpc/generic/bidi_call.rb +++ b/src/ruby/lib/grpc/generic/bidi_call.rb @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/src/ruby/lib/grpc/generic/rpc_desc.rb b/src/ruby/lib/grpc/generic/rpc_desc.rb index dd90d8d91d..526b2ba5b6 100644 --- a/src/ruby/lib/grpc/generic/rpc_desc.rb +++ b/src/ruby/lib/grpc/generic/rpc_desc.rb @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb index 410156ff03..ef2997c991 100644 --- a/src/ruby/lib/grpc/generic/rpc_server.rb +++ b/src/ruby/lib/grpc/generic/rpc_server.rb @@ -1,4 +1,4 @@ -# Copyright 2015, Google Inc. +# Copyright 2015-2016, Google Inc. # All rights reserved. # # Redistribution and use in source and binary forms, with or without diff --git a/src/ruby/lib/grpc/grpc.rb b/src/ruby/lib/grpc/grpc.rb new file mode 100644 index 0000000000..d8a4947494 --- /dev/null +++ b/src/ruby/lib/grpc/grpc.rb @@ -0,0 +1,34 @@ +# Copyright 2015-2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +begin + require "grpc/#{RUBY_VERSION.sub(/\.\d$/, '')}/grpc_c" +rescue LoadError + require 'grpc/grpc_c' +end diff --git a/src/ruby/lib/grpc/version.rb b/src/ruby/lib/grpc/version.rb index 956e0222df..9cbd36a355 100644 --- a/src/ruby/lib/grpc/version.rb +++ b/src/ruby/lib/grpc/version.rb @@ -29,5 +29,5 @@ # GRPC contains the General RPC module. module GRPC - VERSION = '0.12.0' + VERSION = '0.14.0-dev' end |