diff options
author | Craig Tiller <ctiller@google.com> | 2017-11-08 09:42:32 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2017-11-08 09:42:32 -0800 |
commit | 660d4aa2d281dbfbc6c3a3e3349b3e4b6a444285 (patch) | |
tree | 592cecc1d6670bb12b9af81c19cd3cb98cc0eeef /include | |
parent | 48d26966646e910f7dd63d428ef831178ca9315e (diff) | |
parent | d9da7387b8057f3bd99a417a5ee905377bce9296 (diff) |
Merge github.com:grpc/grpc into tfix2
Diffstat (limited to 'include')
39 files changed, 599 insertions, 534 deletions
diff --git a/include/grpc++/impl/channel_argument_option.h b/include/grpc++/impl/channel_argument_option.h index e918f57e92..f157ec1d7e 100644 --- a/include/grpc++/impl/channel_argument_option.h +++ b/include/grpc++/impl/channel_argument_option.h @@ -28,9 +28,9 @@ namespace grpc { std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption( - const grpc::string &name, const grpc::string &value); + const grpc::string& name, const grpc::string& value); std::unique_ptr<ServerBuilderOption> MakeChannelArgumentOption( - const grpc::string &name, int value); + const grpc::string& name, int value); } // namespace grpc diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h index 6d51c78d5c..b9ea5fd19c 100644 --- a/include/grpc++/impl/codegen/async_unary_call.h +++ b/include/grpc++/impl/codegen/async_unary_call.h @@ -297,6 +297,6 @@ class default_delete<grpc::ClientAsyncResponseReaderInterface<R>> { public: void operator()(void* p) {} }; -} +} // namespace std #endif // GRPCXX_IMPL_CODEGEN_ASYNC_UNARY_CALL_H diff --git a/include/grpc++/impl/codegen/client_unary_call.h b/include/grpc++/impl/codegen/client_unary_call.h index 170c562cf3..256dd859d3 100644 --- a/include/grpc++/impl/codegen/client_unary_call.h +++ b/include/grpc++/impl/codegen/client_unary_call.h @@ -41,7 +41,7 @@ Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method, return BlockingUnaryCallImpl<InputMessage, OutputMessage>( channel, method, context, request, result) .status(); -}; +} template <class InputMessage, class OutputMessage> class BlockingUnaryCallImpl { diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 14de30a62e..11cc588879 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -164,8 +164,9 @@ class CompletionQueue : private GrpcLibraryCodegen { /// /// \return true if read a regular event, false if the queue is shutting down. bool Next(void** tag, bool* ok) { - return (AsyncNextInternal(tag, ok, g_core_codegen_interface->gpr_inf_future( - GPR_CLOCK_REALTIME)) != SHUTDOWN); + return (AsyncNextInternal(tag, ok, + g_core_codegen_interface->gpr_inf_future( + GPR_CLOCK_REALTIME)) != SHUTDOWN); } /// Request the shutdown of the queue. diff --git a/include/grpc++/impl/codegen/config_protobuf.h b/include/grpc++/impl/codegen/config_protobuf.h index c5e5bdf0db..7387fa25c6 100644 --- a/include/grpc++/impl/codegen/config_protobuf.h +++ b/include/grpc++/impl/codegen/config_protobuf.h @@ -19,6 +19,8 @@ #ifndef GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H #define GRPCXX_IMPL_CODEGEN_CONFIG_PROTOBUF_H +#define GRPC_OPEN_SOURCE_PROTO + #ifndef GRPC_CUSTOM_PROTOBUF_INT64 #include <google/protobuf/stubs/common.h> #define GRPC_CUSTOM_PROTOBUF_INT64 ::google::protobuf::int64 diff --git a/include/grpc++/impl/codegen/core_codegen.h b/include/grpc++/impl/codegen/core_codegen.h index c751c1e734..d7c57bebb9 100644 --- a/include/grpc++/impl/codegen/core_codegen.h +++ b/include/grpc++/impl/codegen/core_codegen.h @@ -50,6 +50,9 @@ class CoreCodegen final : public CoreCodegenInterface { void* gpr_malloc(size_t size) override; void gpr_free(void* p) override; + void grpc_init() override; + void grpc_shutdown() override; + void gpr_mu_init(gpr_mu* mu) override; void gpr_mu_destroy(gpr_mu* mu) override; void gpr_mu_lock(gpr_mu* mu) override; @@ -89,6 +92,7 @@ class CoreCodegen final : public CoreCodegenInterface { grpc_slice grpc_slice_ref(grpc_slice slice) override; grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) override; grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split) override; + grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end) override; void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) override; void grpc_slice_buffer_pop(grpc_slice_buffer* sb) override; grpc_slice grpc_slice_from_static_buffer(const void* buffer, diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h index a4c50dab87..1949cdab76 100644 --- a/include/grpc++/impl/codegen/core_codegen_interface.h +++ b/include/grpc++/impl/codegen/core_codegen_interface.h @@ -63,6 +63,13 @@ class CoreCodegenInterface { virtual void* gpr_malloc(size_t size) = 0; virtual void gpr_free(void* p) = 0; + // These are only to be used to fix edge cases involving grpc_init and + // grpc_shutdown. Calling grpc_init from the codegen interface before + // the real grpc_init is called will cause a crash, so if you use this + // function, ensure that it is not the first call to grpc_init. + virtual void grpc_init() = 0; + virtual void grpc_shutdown() = 0; + virtual void gpr_mu_init(gpr_mu* mu) = 0; virtual void gpr_mu_destroy(gpr_mu* mu) = 0; virtual void gpr_mu_lock(gpr_mu* mu) = 0; @@ -103,6 +110,7 @@ class CoreCodegenInterface { virtual grpc_slice grpc_slice_ref(grpc_slice slice) = 0; virtual grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) = 0; virtual grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split) = 0; + virtual grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end) = 0; virtual void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) = 0; virtual void grpc_slice_buffer_pop(grpc_slice_buffer* sb) = 0; diff --git a/include/grpc++/impl/codegen/metadata_map.h b/include/grpc++/impl/codegen/metadata_map.h index fd4750efdd..8dc7211ba8 100644 --- a/include/grpc++/impl/codegen/metadata_map.h +++ b/include/grpc++/impl/codegen/metadata_map.h @@ -1,20 +1,20 @@ /* -* -* Copyright 2015 gRPC authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -*/ + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ #ifndef GRPCXX_IMPL_CODEGEN_METADATA_MAP_H #define GRPCXX_IMPL_CODEGEN_METADATA_MAP_H @@ -41,11 +41,11 @@ class MetadataMap { } } - std::multimap<grpc::string_ref, grpc::string_ref> *map() { return &map_; } - const std::multimap<grpc::string_ref, grpc::string_ref> *map() const { + std::multimap<grpc::string_ref, grpc::string_ref>* map() { return &map_; } + const std::multimap<grpc::string_ref, grpc::string_ref>* map() const { return &map_; } - grpc_metadata_array *arr() { return &arr_; } + grpc_metadata_array* arr() { return &arr_; } private: grpc_metadata_array arr_; diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h index 67e8f71a89..0f7e115c9a 100644 --- a/include/grpc++/impl/codegen/proto_utils.h +++ b/include/grpc++/impl/codegen/proto_utils.h @@ -39,8 +39,7 @@ class GrpcBufferWriterPeer; const int kGrpcBufferWriterMaxBufferLength = 1024 * 1024; -class GrpcBufferWriter final - : public ::grpc::protobuf::io::ZeroCopyOutputStream { +class GrpcBufferWriter : public ::grpc::protobuf::io::ZeroCopyOutputStream { public: explicit GrpcBufferWriter(grpc_byte_buffer** bp, int block_size) : block_size_(block_size), byte_count_(0), have_backup_(false) { @@ -88,7 +87,7 @@ class GrpcBufferWriter final grpc::protobuf::int64 ByteCount() const override { return byte_count_; } - private: + protected: friend class GrpcBufferWriterPeer; const int block_size_; int64_t byte_count_; @@ -98,8 +97,7 @@ class GrpcBufferWriter final grpc_slice slice_; }; -class GrpcBufferReader final - : public ::grpc::protobuf::io::ZeroCopyInputStream { +class GrpcBufferReader : public ::grpc::protobuf::io::ZeroCopyInputStream { public: explicit GrpcBufferReader(grpc_byte_buffer* buffer) : byte_count_(0), backup_count_(0), status_() { @@ -160,7 +158,7 @@ class GrpcBufferReader final return byte_count_ - backup_count_; } - private: + protected: int64_t byte_count_; int64_t backup_count_; grpc_byte_buffer_reader reader_; @@ -168,57 +166,85 @@ class GrpcBufferReader final Status status_; }; +// BufferWriter must be a subclass of io::ZeroCopyOutputStream. +template <class BufferWriter, class T> +Status GenericSerialize(const grpc::protobuf::Message& msg, + grpc_byte_buffer** bp, bool* own_buffer) { + static_assert( + std::is_base_of<protobuf::io::ZeroCopyOutputStream, BufferWriter>::value, + "BufferWriter must be a subclass of io::ZeroCopyOutputStream"); + *own_buffer = true; + int byte_size = msg.ByteSize(); + if (byte_size <= kGrpcBufferWriterMaxBufferLength) { + grpc_slice slice = g_core_codegen_interface->grpc_slice_malloc(byte_size); + GPR_CODEGEN_ASSERT( + GRPC_SLICE_END_PTR(slice) == + msg.SerializeWithCachedSizesToArray(GRPC_SLICE_START_PTR(slice))); + *bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(&slice, 1); + g_core_codegen_interface->grpc_slice_unref(slice); + return g_core_codegen_interface->ok(); + } else { + BufferWriter writer(bp, kGrpcBufferWriterMaxBufferLength); + return msg.SerializeToZeroCopyStream(&writer) + ? g_core_codegen_interface->ok() + : Status(StatusCode::INTERNAL, "Failed to serialize message"); + } +} + +// BufferReader must be a subclass of io::ZeroCopyInputStream. +template <class BufferReader, class T> +Status GenericDeserialize(grpc_byte_buffer* buffer, + grpc::protobuf::Message* msg) { + static_assert( + std::is_base_of<protobuf::io::ZeroCopyInputStream, BufferReader>::value, + "BufferReader must be a subclass of io::ZeroCopyInputStream"); + if (buffer == nullptr) { + return Status(StatusCode::INTERNAL, "No payload"); + } + Status result = g_core_codegen_interface->ok(); + { + BufferReader reader(buffer); + if (!reader.status().ok()) { + return reader.status(); + } + ::grpc::protobuf::io::CodedInputStream decoder(&reader); + decoder.SetTotalBytesLimit(INT_MAX, INT_MAX); + if (!msg->ParseFromCodedStream(&decoder)) { + result = Status(StatusCode::INTERNAL, msg->InitializationErrorString()); + } + if (!decoder.ConsumedEntireMessage()) { + result = Status(StatusCode::INTERNAL, "Did not read entire message"); + } + } + g_core_codegen_interface->grpc_byte_buffer_destroy(buffer); + return result; +} + } // namespace internal +// this is needed so the following class does not conflict with protobuf +// serializers that utilize internal-only tools. +#ifdef GRPC_OPEN_SOURCE_PROTO +// This class provides a protobuf serializer. It translates between protobuf +// objects and grpc_byte_buffers. More information about SerializationTraits can +// be found in include/grpc++/impl/codegen/serialization_traits.h. template <class T> class SerializationTraits<T, typename std::enable_if<std::is_base_of< grpc::protobuf::Message, T>::value>::type> { public: static Status Serialize(const grpc::protobuf::Message& msg, grpc_byte_buffer** bp, bool* own_buffer) { - *own_buffer = true; - int byte_size = msg.ByteSize(); - if (byte_size <= internal::kGrpcBufferWriterMaxBufferLength) { - grpc_slice slice = g_core_codegen_interface->grpc_slice_malloc(byte_size); - GPR_CODEGEN_ASSERT( - GRPC_SLICE_END_PTR(slice) == - msg.SerializeWithCachedSizesToArray(GRPC_SLICE_START_PTR(slice))); - *bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(&slice, 1); - g_core_codegen_interface->grpc_slice_unref(slice); - return g_core_codegen_interface->ok(); - } else { - internal::GrpcBufferWriter writer( - bp, internal::kGrpcBufferWriterMaxBufferLength); - return msg.SerializeToZeroCopyStream(&writer) - ? g_core_codegen_interface->ok() - : Status(StatusCode::INTERNAL, "Failed to serialize message"); - } + return internal::GenericSerialize<internal::GrpcBufferWriter, T>( + msg, bp, own_buffer); } static Status Deserialize(grpc_byte_buffer* buffer, grpc::protobuf::Message* msg) { - if (buffer == nullptr) { - return Status(StatusCode::INTERNAL, "No payload"); - } - Status result = g_core_codegen_interface->ok(); - { - internal::GrpcBufferReader reader(buffer); - if (!reader.status().ok()) { - return reader.status(); - } - ::grpc::protobuf::io::CodedInputStream decoder(&reader); - decoder.SetTotalBytesLimit(INT_MAX, INT_MAX); - if (!msg->ParseFromCodedStream(&decoder)) { - result = Status(StatusCode::INTERNAL, msg->InitializationErrorString()); - } - if (!decoder.ConsumedEntireMessage()) { - result = Status(StatusCode::INTERNAL, "Did not read entire message"); - } - } - g_core_codegen_interface->grpc_byte_buffer_destroy(buffer); - return result; + return internal::GenericDeserialize<internal::GrpcBufferReader, T>(buffer, + msg); } }; +#endif } // namespace grpc diff --git a/include/grpc++/server_builder.h b/include/grpc++/server_builder.h index 0888bef0d9..bf842baf6f 100644 --- a/include/grpc++/server_builder.h +++ b/include/grpc++/server_builder.h @@ -202,7 +202,10 @@ class ServerBuilder { struct SyncServerSettings { SyncServerSettings() - : num_cqs(1), min_pollers(1), max_pollers(2), cq_timeout_msec(10000) {} + : num_cqs(GPR_MAX(1, gpr_cpu_num_cores())), + min_pollers(1), + max_pollers(2), + cq_timeout_msec(10000) {} /// Number of server completion queues to create to listen to incoming RPCs. int num_cqs; diff --git a/include/grpc/compression.h b/include/grpc/compression.h index 13a8dd66ad..b42f428d7d 100644 --- a/include/grpc/compression.h +++ b/include/grpc/compression.h @@ -33,24 +33,24 @@ extern "C" { /** Parses the \a slice as a grpc_compression_algorithm instance and updating \a * algorithm. Returns 1 upon success, 0 otherwise. */ GRPCAPI int grpc_compression_algorithm_parse( - grpc_slice value, grpc_compression_algorithm *algorithm); + grpc_slice value, grpc_compression_algorithm* algorithm); /** Parses the \a slice as a grpc_stream_compression_algorithm instance and * updating \a algorithm. Returns 1 upon success, 0 otherwise. */ int grpc_stream_compression_algorithm_parse( - grpc_slice name, grpc_stream_compression_algorithm *algorithm); + grpc_slice name, grpc_stream_compression_algorithm* algorithm); /** Updates \a name with the encoding name corresponding to a valid \a * algorithm. Note that \a name is statically allocated and must *not* be freed. * Returns 1 upon success, 0 otherwise. */ GRPCAPI int grpc_compression_algorithm_name( - grpc_compression_algorithm algorithm, const char **name); + grpc_compression_algorithm algorithm, const char** name); /** Updates \a name with the encoding name corresponding to a valid \a * algorithm. Note that \a name is statically allocated and must *not* be freed. * Returns 1 upon success, 0 otherwise. */ GRPCAPI int grpc_stream_compression_algorithm_name( - grpc_stream_compression_algorithm algorithm, const char **name); + grpc_stream_compression_algorithm algorithm, const char** name); /** Returns the compression algorithm corresponding to \a level for the * compression algorithms encoded in the \a accepted_encodings bitset. @@ -66,23 +66,23 @@ GRPCAPI grpc_stream_compression_algorithm grpc_stream_compression_algorithm_for_level(grpc_stream_compression_level level, uint32_t accepted_stream_encodings); -GRPCAPI void grpc_compression_options_init(grpc_compression_options *opts); +GRPCAPI void grpc_compression_options_init(grpc_compression_options* opts); /** Mark \a algorithm as enabled in \a opts. */ GRPCAPI void grpc_compression_options_enable_algorithm( - grpc_compression_options *opts, grpc_compression_algorithm algorithm); + grpc_compression_options* opts, grpc_compression_algorithm algorithm); /** Mark \a algorithm as disabled in \a opts. */ GRPCAPI void grpc_compression_options_disable_algorithm( - grpc_compression_options *opts, grpc_compression_algorithm algorithm); + grpc_compression_options* opts, grpc_compression_algorithm algorithm); /** Returns true if \a algorithm is marked as enabled in \a opts. */ GRPCAPI int grpc_compression_options_is_algorithm_enabled( - const grpc_compression_options *opts, grpc_compression_algorithm algorithm); + const grpc_compression_options* opts, grpc_compression_algorithm algorithm); /** Returns true if \a algorithm is marked as enabled in \a opts. */ GRPCAPI int grpc_compression_options_is_stream_compression_algorithm_enabled( - const grpc_compression_options *opts, + const grpc_compression_options* opts, grpc_stream_compression_algorithm algorithm); #ifdef __cplusplus diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 6df3b8086e..f083bc591e 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -40,11 +40,11 @@ extern "C" { * functionality lives in grpc_security.h. */ -GRPCAPI void grpc_metadata_array_init(grpc_metadata_array *array); -GRPCAPI void grpc_metadata_array_destroy(grpc_metadata_array *array); +GRPCAPI void grpc_metadata_array_init(grpc_metadata_array* array); +GRPCAPI void grpc_metadata_array_destroy(grpc_metadata_array* array); -GRPCAPI void grpc_call_details_init(grpc_call_details *details); -GRPCAPI void grpc_call_details_destroy(grpc_call_details *details); +GRPCAPI void grpc_call_details_init(grpc_call_details* details); +GRPCAPI void grpc_call_details_destroy(grpc_call_details* details); /** Registers a plugin to be initialized and destroyed with the library. @@ -73,31 +73,31 @@ GRPCAPI void grpc_init(void); GRPCAPI void grpc_shutdown(void); /** Return a string representing the current version of grpc */ -GRPCAPI const char *grpc_version_string(void); +GRPCAPI const char* grpc_version_string(void); /** Return a string specifying what the 'g' in gRPC stands for */ -GRPCAPI const char *grpc_g_stands_for(void); +GRPCAPI const char* grpc_g_stands_for(void); /** Returns the completion queue factory based on the attributes. MAY return a NULL if no factory can be found */ -GRPCAPI const grpc_completion_queue_factory * +GRPCAPI const grpc_completion_queue_factory* grpc_completion_queue_factory_lookup( - const grpc_completion_queue_attributes *attributes); + const grpc_completion_queue_attributes* attributes); /** Helper function to create a completion queue with grpc_cq_completion_type of GRPC_CQ_NEXT and grpc_cq_polling_type of GRPC_CQ_DEFAULT_POLLING */ -GRPCAPI grpc_completion_queue *grpc_completion_queue_create_for_next( - void *reserved); +GRPCAPI grpc_completion_queue* grpc_completion_queue_create_for_next( + void* reserved); /** Helper function to create a completion queue with grpc_cq_completion_type of GRPC_CQ_PLUCK and grpc_cq_polling_type of GRPC_CQ_DEFAULT_POLLING */ -GRPCAPI grpc_completion_queue *grpc_completion_queue_create_for_pluck( - void *reserved); +GRPCAPI grpc_completion_queue* grpc_completion_queue_create_for_pluck( + void* reserved); /** Create a completion queue */ -GRPCAPI grpc_completion_queue *grpc_completion_queue_create( - const grpc_completion_queue_factory *factory, - const grpc_completion_queue_attributes *attributes, void *reserved); +GRPCAPI grpc_completion_queue* grpc_completion_queue_create( + const grpc_completion_queue_factory* factory, + const grpc_completion_queue_attributes* attributes, void* reserved); /** Blocks until an event is available, the completion queue is being shut down, or deadline is reached. @@ -107,9 +107,9 @@ GRPCAPI grpc_completion_queue *grpc_completion_queue_create( Callers must not call grpc_completion_queue_next and grpc_completion_queue_pluck simultaneously on the same completion queue. */ -GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, +GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue* cq, gpr_timespec deadline, - void *reserved); + void* reserved); /** Blocks until an event with tag 'tag' is available, the completion queue is being shutdown or deadline is reached. @@ -122,9 +122,9 @@ GRPCAPI grpc_event grpc_completion_queue_next(grpc_completion_queue *cq, Completion queues support a maximum of GRPC_MAX_COMPLETION_QUEUE_PLUCKERS concurrently executing plucks at any time. */ -GRPCAPI grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, - void *tag, gpr_timespec deadline, - void *reserved); +GRPCAPI grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, + void* tag, gpr_timespec deadline, + void* reserved); /** Maximum number of outstanding grpc_completion_queue_pluck executions per completion queue */ @@ -137,31 +137,31 @@ GRPCAPI grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, After calling this function applications should ensure that no NEW work is added to be published on this completion queue. */ -GRPCAPI void grpc_completion_queue_shutdown(grpc_completion_queue *cq); +GRPCAPI void grpc_completion_queue_shutdown(grpc_completion_queue* cq); /** Destroy a completion queue. The caller must ensure that the queue is drained and no threads are executing grpc_completion_queue_next */ -GRPCAPI void grpc_completion_queue_destroy(grpc_completion_queue *cq); +GRPCAPI void grpc_completion_queue_destroy(grpc_completion_queue* cq); /*********** EXPERIMENTAL API ************/ /** Initializes a thread local cache for \a cq. - * grpc_flush_cq_tls_cache() MUST be called on the same thread, - * with the same cq. - */ + * grpc_flush_cq_tls_cache() MUST be called on the same thread, + * with the same cq. + */ GRPCAPI void grpc_completion_queue_thread_local_cache_init( - grpc_completion_queue *cq); + grpc_completion_queue* cq); /*********** EXPERIMENTAL API ************/ /** Flushes the thread local cache for \a cq. - * Returns 1 if there was contents in the cache. If there was an event - * in \a cq tls cache, its tag is placed in tag, and ok is set to the - * event success. - */ + * Returns 1 if there was contents in the cache. If there was an event + * in \a cq tls cache, its tag is placed in tag, and ok is set to the + * event success. + */ GRPCAPI int grpc_completion_queue_thread_local_cache_flush( - grpc_completion_queue *cq, void **tag, int *ok); + grpc_completion_queue* cq, void** tag, int* ok); /** Create a completion queue alarm instance */ -GRPCAPI grpc_alarm *grpc_alarm_create(void *reserved); +GRPCAPI grpc_alarm* grpc_alarm_create(void* reserved); /** Set a completion queue alarm instance associated to \a cq. * @@ -169,25 +169,25 @@ GRPCAPI grpc_alarm *grpc_alarm_create(void *reserved); * grpc_alarm_cancel), an event with tag \a tag will be added to \a cq. If the * alarm expired, the event's success bit will be true, false otherwise (ie, * upon cancellation). */ -GRPCAPI void grpc_alarm_set(grpc_alarm *alarm, grpc_completion_queue *cq, - gpr_timespec deadline, void *tag, void *reserved); +GRPCAPI void grpc_alarm_set(grpc_alarm* alarm, grpc_completion_queue* cq, + gpr_timespec deadline, void* tag, void* reserved); /** Cancel a completion queue alarm. Calling this function over an alarm that * has already fired has no effect. */ -GRPCAPI void grpc_alarm_cancel(grpc_alarm *alarm, void *reserved); +GRPCAPI void grpc_alarm_cancel(grpc_alarm* alarm, void* reserved); /** Destroy the given completion queue alarm, cancelling it in the process. */ -GRPCAPI void grpc_alarm_destroy(grpc_alarm *alarm, void *reserved); +GRPCAPI void grpc_alarm_destroy(grpc_alarm* alarm, void* reserved); /** Check the connectivity state of a channel. */ GRPCAPI grpc_connectivity_state grpc_channel_check_connectivity_state( - grpc_channel *channel, int try_to_connect); + grpc_channel* channel, int try_to_connect); /** Number of active "external connectivity state watchers" attached to a * channel. * Useful for testing. **/ GRPCAPI int grpc_channel_num_external_connectivity_watchers( - grpc_channel *channel); + grpc_channel* channel); /** Watch for a change in connectivity state. Once the channel connectivity state is different from last_observed_state, @@ -195,11 +195,11 @@ GRPCAPI int grpc_channel_num_external_connectivity_watchers( If deadline expires BEFORE the state is changed, tag will be enqueued on cq with success=0. */ GRPCAPI void grpc_channel_watch_connectivity_state( - grpc_channel *channel, grpc_connectivity_state last_observed_state, - gpr_timespec deadline, grpc_completion_queue *cq, void *tag); + grpc_channel* channel, grpc_connectivity_state last_observed_state, + gpr_timespec deadline, grpc_completion_queue* cq, void* tag); /** Check whether a grpc channel supports connectivity watcher */ -GRPCAPI int grpc_channel_support_connectivity_watcher(grpc_channel *channel); +GRPCAPI int grpc_channel_support_connectivity_watcher(grpc_channel* channel); /** Create a call given a grpc_channel, in order to call 'method'. All completions are sent to 'completion_queue'. 'method' and 'host' need only @@ -208,31 +208,31 @@ GRPCAPI int grpc_channel_support_connectivity_watcher(grpc_channel *channel); to propagate properties from the server call to this new client call, depending on the value of \a propagation_mask (see propagation_bits.h for possible values). */ -GRPCAPI grpc_call *grpc_channel_create_call( - grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, - grpc_completion_queue *completion_queue, grpc_slice method, - const grpc_slice *host, gpr_timespec deadline, void *reserved); +GRPCAPI grpc_call* grpc_channel_create_call( + grpc_channel* channel, grpc_call* parent_call, uint32_t propagation_mask, + grpc_completion_queue* completion_queue, grpc_slice method, + const grpc_slice* host, gpr_timespec deadline, void* reserved); /** Ping the channels peer (load balanced channels will select one sub-channel to ping); if the channel is not connected, posts a failed. */ -GRPCAPI void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq, - void *tag, void *reserved); +GRPCAPI void grpc_channel_ping(grpc_channel* channel, grpc_completion_queue* cq, + void* tag, void* reserved); /** Pre-register a method/host pair on a channel. */ -GRPCAPI void *grpc_channel_register_call(grpc_channel *channel, - const char *method, const char *host, - void *reserved); +GRPCAPI void* grpc_channel_register_call(grpc_channel* channel, + const char* method, const char* host, + void* reserved); /** Create a call given a handle returned from grpc_channel_register_call. \sa grpc_channel_create_call. */ -GRPCAPI grpc_call *grpc_channel_create_registered_call( - 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); +GRPCAPI grpc_call* grpc_channel_create_registered_call( + 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); /** Allocate memory in the grpc_call arena: this memory is automatically discarded at call completion */ -GRPCAPI void *grpc_call_arena_alloc(grpc_call *call, size_t size); +GRPCAPI void* grpc_call_arena_alloc(grpc_call* call, size_t size); /** Start a batch of operations defined in the array ops; when complete, post a completion of type 'tag' to the completion queue bound to the call. @@ -251,9 +251,9 @@ GRPCAPI void *grpc_call_arena_alloc(grpc_call *call, size_t size); needs to be synchronized. As an optimization, you may synchronize batches containing just send operations independently from batches containing just receive operations. */ -GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call *call, - const grpc_op *ops, size_t nops, - void *tag, void *reserved); +GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call* call, + const grpc_op* ops, size_t nops, + void* tag, void* reserved); /** Returns a newly allocated string representing the endpoint to which this call is communicating with. The string is in the uri format accepted by @@ -263,43 +263,43 @@ GRPCAPI grpc_call_error grpc_call_start_batch(grpc_call *call, WARNING: this value is never authenticated or subject to any security related code. It must not be used for any authentication related functionality. Instead, use grpc_auth_context. */ -GRPCAPI char *grpc_call_get_peer(grpc_call *call); +GRPCAPI char* grpc_call_get_peer(grpc_call* call); struct census_context; /** Set census context for a call; Must be called before first call to grpc_call_start_batch(). */ -GRPCAPI void grpc_census_call_set_context(grpc_call *call, - struct census_context *context); +GRPCAPI void grpc_census_call_set_context(grpc_call* call, + struct census_context* context); /** Retrieve the calls current census context. */ -GRPCAPI struct census_context *grpc_census_call_get_context(grpc_call *call); +GRPCAPI struct census_context* grpc_census_call_get_context(grpc_call* call); /** Return a newly allocated string representing the target a channel was created for. */ -GRPCAPI char *grpc_channel_get_target(grpc_channel *channel); +GRPCAPI char* grpc_channel_get_target(grpc_channel* channel); /** Request info about the channel. \a channel_info indicates what information is being requested and how that information will be returned. \a channel_info is owned by the caller. */ -GRPCAPI void grpc_channel_get_info(grpc_channel *channel, - const grpc_channel_info *channel_info); +GRPCAPI void grpc_channel_get_info(grpc_channel* channel, + const grpc_channel_info* channel_info); /** Create a client channel to 'target'. Additional channel level configuration MAY be provided by grpc_channel_args, though the expectation is that most clients will want to simply pass NULL. See grpc_channel_args definition for more on this. The data in 'args' need only live through the invocation of this function. */ -GRPCAPI grpc_channel *grpc_insecure_channel_create( - const char *target, const grpc_channel_args *args, void *reserved); +GRPCAPI grpc_channel* grpc_insecure_channel_create( + const char* target, const grpc_channel_args* args, void* reserved); /** Create a lame client: this client fails every operation attempted on it. */ -GRPCAPI grpc_channel *grpc_lame_client_channel_create( - const char *target, grpc_status_code error_code, const char *error_message); +GRPCAPI grpc_channel* grpc_lame_client_channel_create( + const char* target, grpc_status_code error_code, const char* error_message); /** Close and destroy a grpc channel */ -GRPCAPI void grpc_channel_destroy(grpc_channel *channel); +GRPCAPI void grpc_channel_destroy(grpc_channel* channel); /** Error handling for grpc_call Most grpc_call functions return a grpc_error. If the error is not GRPC_OK @@ -312,7 +312,7 @@ GRPCAPI void grpc_channel_destroy(grpc_channel *channel); THREAD-SAFETY grpc_call_cancel and grpc_call_cancel_with_status are thread-safe, and can be called at any point before grpc_call_unref is called.*/ -GRPCAPI grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved); +GRPCAPI grpc_call_error grpc_call_cancel(grpc_call* call, void* reserved); /** Called by clients to cancel an RPC on the server. Can be called multiple times, from any thread. @@ -324,18 +324,18 @@ GRPCAPI grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved); It doesn't need to be alive after the call to grpc_call_cancel_with_status completes. */ -GRPCAPI grpc_call_error grpc_call_cancel_with_status(grpc_call *call, +GRPCAPI grpc_call_error grpc_call_cancel_with_status(grpc_call* call, grpc_status_code status, - const char *description, - void *reserved); + const char* description, + void* reserved); /** Ref a call. THREAD SAFETY: grpc_call_ref is thread-compatible */ -GRPCAPI void grpc_call_ref(grpc_call *call); +GRPCAPI void grpc_call_ref(grpc_call* call); /** Unref a call. THREAD SAFETY: grpc_call_unref is thread-compatible */ -GRPCAPI void grpc_call_unref(grpc_call *call); +GRPCAPI void grpc_call_unref(grpc_call* call); /** Request notification of a new call. Once a call is received, a notification tagged with \a tag_new is added to @@ -346,10 +346,10 @@ GRPCAPI void grpc_call_unref(grpc_call *call); Note that \a cq_for_notification must have been registered to the server via \a grpc_server_register_completion_queue. */ GRPCAPI grpc_call_error grpc_server_request_call( - 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); + 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); /** How to handle payloads for a registered method */ typedef enum { @@ -366,8 +366,8 @@ typedef enum { registered_method (as returned by this function). Must be called before grpc_server_start. Returns NULL on failure. */ -GRPCAPI void *grpc_server_register_method( - grpc_server *server, const char *method, const char *host, +GRPCAPI void* grpc_server_register_method( + grpc_server* server, const char* method, const char* host, grpc_server_register_method_payload_handling payload_handling, uint32_t flags); @@ -375,35 +375,35 @@ GRPCAPI void *grpc_server_register_method( must have been registered to the server via grpc_server_register_completion_queue. */ GRPCAPI grpc_call_error grpc_server_request_registered_call( - 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); + 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); /** Create a server. Additional configuration for each incoming channel can be specified with args. If no additional configuration is needed, args can be NULL. See grpc_channel_args for more. The data in 'args' need only live through the invocation of this function. */ -GRPCAPI grpc_server *grpc_server_create(const grpc_channel_args *args, - void *reserved); +GRPCAPI grpc_server* grpc_server_create(const grpc_channel_args* args, + void* reserved); /** Register a completion queue with the server. Must be done for any notification completion queue that is passed to grpc_server_request_*_call and to grpc_server_shutdown_and_notify. Must be performed prior to grpc_server_start. */ -GRPCAPI void grpc_server_register_completion_queue(grpc_server *server, - grpc_completion_queue *cq, - void *reserved); +GRPCAPI void grpc_server_register_completion_queue(grpc_server* server, + grpc_completion_queue* cq, + void* reserved); /** Add a HTTP2 over plaintext over tcp listener. Returns bound port number on success, 0 on failure. REQUIRES: server not started */ -GRPCAPI int grpc_server_add_insecure_http2_port(grpc_server *server, - const char *addr); +GRPCAPI int grpc_server_add_insecure_http2_port(grpc_server* server, + const char* addr); /** Start a server - tells all listeners to start listening */ -GRPCAPI void grpc_server_start(grpc_server *server); +GRPCAPI void grpc_server_start(grpc_server* server); /** Begin shutting down a server. After completion, no new calls or connections will be admitted. @@ -412,19 +412,19 @@ GRPCAPI void grpc_server_start(grpc_server *server); Shutdown is idempotent, and all tags will be notified at once if multiple grpc_server_shutdown_and_notify calls are made. 'cq' must have been registered to this server via grpc_server_register_completion_queue. */ -GRPCAPI void grpc_server_shutdown_and_notify(grpc_server *server, - grpc_completion_queue *cq, - void *tag); +GRPCAPI void grpc_server_shutdown_and_notify(grpc_server* server, + grpc_completion_queue* cq, + void* tag); /** Cancel all in-progress calls. Only usable after shutdown. */ -GRPCAPI void grpc_server_cancel_all_calls(grpc_server *server); +GRPCAPI void grpc_server_cancel_all_calls(grpc_server* server); /** Destroy a server. Shutdown must have completed beforehand (i.e. all tags generated by grpc_server_shutdown_and_notify must have been received, and at least one call to grpc_server_shutdown_and_notify must have been made). */ -GRPCAPI void grpc_server_destroy(grpc_server *server); +GRPCAPI void grpc_server_destroy(grpc_server* server); /** Enable or disable a tracer. @@ -434,7 +434,7 @@ GRPCAPI void grpc_server_destroy(grpc_server *server); Use of this function is not strictly thread-safe, but the thread-safety issues raised by it should not be of concern. */ -GRPCAPI int grpc_tracer_set_enabled(const char *name, int enabled); +GRPCAPI int grpc_tracer_set_enabled(const char* name, int enabled); /** Check whether a metadata key is legal (will be accepted by core) */ GRPCAPI int grpc_header_key_is_legal(grpc_slice slice); @@ -447,24 +447,24 @@ GRPCAPI int grpc_header_nonbin_value_is_legal(grpc_slice slice); GRPCAPI int grpc_is_binary_header(grpc_slice slice); /** Convert grpc_call_error values to a string */ -GRPCAPI const char *grpc_call_error_to_string(grpc_call_error error); +GRPCAPI const char* grpc_call_error_to_string(grpc_call_error error); /** Create a buffer pool */ -GRPCAPI grpc_resource_quota *grpc_resource_quota_create(const char *trace_name); +GRPCAPI grpc_resource_quota* grpc_resource_quota_create(const char* trace_name); /** Add a reference to a buffer pool */ -GRPCAPI void grpc_resource_quota_ref(grpc_resource_quota *resource_quota); +GRPCAPI void grpc_resource_quota_ref(grpc_resource_quota* resource_quota); /** Drop a reference to a buffer pool */ -GRPCAPI void grpc_resource_quota_unref(grpc_resource_quota *resource_quota); +GRPCAPI void grpc_resource_quota_unref(grpc_resource_quota* resource_quota); /** Update the size of a buffer pool */ -GRPCAPI void grpc_resource_quota_resize(grpc_resource_quota *resource_quota, +GRPCAPI void grpc_resource_quota_resize(grpc_resource_quota* resource_quota, size_t new_size); /** Fetch a vtable for a grpc_channel_arg that points to a grpc_resource_quota */ -GRPCAPI const grpc_arg_pointer_vtable *grpc_resource_quota_arg_vtable(void); +GRPCAPI const grpc_arg_pointer_vtable* grpc_resource_quota_arg_vtable(void); #ifdef __cplusplus } diff --git a/include/grpc/grpc_cronet.h b/include/grpc/grpc_cronet.h index 44330c6e11..127d5d038d 100644 --- a/include/grpc/grpc_cronet.h +++ b/include/grpc/grpc_cronet.h @@ -25,9 +25,9 @@ extern "C" { #endif -GRPCAPI grpc_channel *grpc_cronet_secure_channel_create( - void *engine, const char *target, const grpc_channel_args *args, - void *reserved); +GRPCAPI grpc_channel* grpc_cronet_secure_channel_create( + void* engine, const char* target, const grpc_channel_args* args, + void* reserved); #ifdef __cplusplus } diff --git a/include/grpc/grpc_posix.h b/include/grpc/grpc_posix.h index c7429eaea0..fa7ebced3f 100644 --- a/include/grpc/grpc_posix.h +++ b/include/grpc/grpc_posix.h @@ -37,8 +37,8 @@ extern "C" { /** Create a client channel to 'target' using file descriptor 'fd'. The 'target' argument will be used to indicate the name for this channel. See the comment for grpc_insecure_channel_create for description of 'args' argument. */ -GRPCAPI grpc_channel *grpc_insecure_channel_create_from_fd( - const char *target, int fd, const grpc_channel_args *args); +GRPCAPI grpc_channel* grpc_insecure_channel_create_from_fd( + const char* target, int fd, const grpc_channel_args* args); /** Add the connected communication channel based on file descriptor 'fd' to the 'server'. The 'fd' must be an open file descriptor corresponding to a @@ -48,8 +48,8 @@ GRPCAPI grpc_channel *grpc_insecure_channel_create_from_fd( The 'reserved' pointer MUST be NULL. */ -GRPCAPI void grpc_server_add_insecure_channel_from_fd(grpc_server *server, - void *reserved, int fd); +GRPCAPI void grpc_server_add_insecure_channel_from_fd(grpc_server* server, + void* reserved, int fd); /** GRPC Core POSIX library may internally use signals to optimize some work. The library uses (SIGRTMIN + 6) signal by default. Use this API to instruct diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 758aaf5b6c..7e87217de7 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -32,51 +32,51 @@ extern "C" { typedef struct grpc_auth_context grpc_auth_context; typedef struct grpc_auth_property_iterator { - const grpc_auth_context *ctx; + const grpc_auth_context* ctx; size_t index; - const char *name; + const char* name; } grpc_auth_property_iterator; /** value, if not NULL, is guaranteed to be NULL terminated. */ typedef struct grpc_auth_property { - char *name; - char *value; + char* name; + char* value; size_t value_length; } grpc_auth_property; /** Returns NULL when the iterator is at the end. */ -GRPCAPI const grpc_auth_property *grpc_auth_property_iterator_next( - grpc_auth_property_iterator *it); +GRPCAPI const grpc_auth_property* grpc_auth_property_iterator_next( + grpc_auth_property_iterator* it); /** Iterates over the auth context. */ GRPCAPI grpc_auth_property_iterator -grpc_auth_context_property_iterator(const grpc_auth_context *ctx); +grpc_auth_context_property_iterator(const grpc_auth_context* ctx); /** Gets the peer identity. Returns an empty iterator (first _next will return NULL) if the peer is not authenticated. */ GRPCAPI grpc_auth_property_iterator -grpc_auth_context_peer_identity(const grpc_auth_context *ctx); +grpc_auth_context_peer_identity(const grpc_auth_context* ctx); /** Finds a property in the context. May return an empty iterator (first _next will return NULL) if no property with this name was found in the context. */ GRPCAPI grpc_auth_property_iterator grpc_auth_context_find_properties_by_name( - const grpc_auth_context *ctx, const char *name); + const grpc_auth_context* ctx, const char* name); /** Gets the name of the property that indicates the peer identity. Will return NULL if the peer is not authenticated. */ -GRPCAPI const char *grpc_auth_context_peer_identity_property_name( - const grpc_auth_context *ctx); +GRPCAPI const char* grpc_auth_context_peer_identity_property_name( + const grpc_auth_context* ctx); /** Returns 1 if the peer is authenticated, 0 otherwise. */ GRPCAPI int grpc_auth_context_peer_is_authenticated( - const grpc_auth_context *ctx); + const grpc_auth_context* ctx); /** Gets the auth context from the call. Caller needs to call grpc_auth_context_release on the returned context. */ -GRPCAPI grpc_auth_context *grpc_call_auth_context(grpc_call *call); +GRPCAPI grpc_auth_context* grpc_call_auth_context(grpc_call* call); /** Releases the auth context returned from grpc_call_auth_context. */ -GRPCAPI void grpc_auth_context_release(grpc_auth_context *context); +GRPCAPI void grpc_auth_context_release(grpc_auth_context* context); /** -- The following auth context methods should only be called by a server metadata @@ -84,19 +84,19 @@ GRPCAPI void grpc_auth_context_release(grpc_auth_context *context); -- */ /** Add a property. */ -GRPCAPI void grpc_auth_context_add_property(grpc_auth_context *ctx, - const char *name, const char *value, +GRPCAPI void grpc_auth_context_add_property(grpc_auth_context* ctx, + const char* name, const char* value, size_t value_length); /** Add a C string property. */ -GRPCAPI void grpc_auth_context_add_cstring_property(grpc_auth_context *ctx, - const char *name, - const char *value); +GRPCAPI void grpc_auth_context_add_cstring_property(grpc_auth_context* ctx, + const char* name, + const char* value); /** Sets the property name. Returns 1 if successful or 0 in case of failure (which means that no property with this name exists). */ GRPCAPI int grpc_auth_context_set_peer_identity_property_name( - grpc_auth_context *ctx, const char *name); + grpc_auth_context* ctx, const char* name); /** --- grpc_channel_credentials object. --- @@ -107,12 +107,12 @@ typedef struct grpc_channel_credentials grpc_channel_credentials; /** Releases a channel credentials object. The creator of the credentials object is responsible for its release. */ -GRPCAPI void grpc_channel_credentials_release(grpc_channel_credentials *creds); +GRPCAPI void grpc_channel_credentials_release(grpc_channel_credentials* creds); /** Creates default credentials to connect to a google gRPC service. WARNING: Do NOT use this credentials to connect to a non-google service as this could result in an oauth2 token leak. */ -GRPCAPI grpc_channel_credentials *grpc_google_default_credentials_create(void); +GRPCAPI grpc_channel_credentials* grpc_google_default_credentials_create(void); /** Callback for getting the SSL roots override from the application. In case of success, *pem_roots_certs must be set to a NULL terminated string @@ -121,7 +121,7 @@ GRPCAPI grpc_channel_credentials *grpc_google_default_credentials_create(void); If this function fails and GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment is set to a valid path, it will override the roots specified this func */ typedef grpc_ssl_roots_override_result (*grpc_ssl_roots_override_callback)( - char **pem_root_certs); + char** pem_root_certs); /** Setup a callback to override the default TLS/SSL roots. This function is not thread-safe and must be called at initialization time @@ -135,11 +135,11 @@ GRPCAPI void grpc_set_ssl_roots_override_callback( typedef struct { /** private_key is the NULL-terminated string containing the PEM encoding of the client's private key. */ - const char *private_key; + const char* private_key; /** cert_chain is the NULL-terminated string containing the PEM encoding of the client's certificate chain. */ - const char *cert_chain; + const char* cert_chain; } grpc_ssl_pem_key_cert_pair; /** Creates an SSL credentials object. @@ -153,9 +153,9 @@ typedef struct { - pem_key_cert_pair is a pointer on the object containing client's private key and certificate chain. This parameter can be NULL if the client does not have such a key/cert pair. */ -GRPCAPI grpc_channel_credentials *grpc_ssl_credentials_create( - const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair, - void *reserved); +GRPCAPI grpc_channel_credentials* grpc_ssl_credentials_create( + const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pair, + void* reserved); /** --- grpc_call_credentials object. @@ -167,23 +167,23 @@ typedef struct grpc_call_credentials grpc_call_credentials; /** Releases a call credentials object. The creator of the credentials object is responsible for its release. */ -GRPCAPI void grpc_call_credentials_release(grpc_call_credentials *creds); +GRPCAPI void grpc_call_credentials_release(grpc_call_credentials* creds); /** Creates a composite channel credentials object. */ -GRPCAPI grpc_channel_credentials *grpc_composite_channel_credentials_create( - grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds, - void *reserved); +GRPCAPI grpc_channel_credentials* grpc_composite_channel_credentials_create( + grpc_channel_credentials* channel_creds, grpc_call_credentials* call_creds, + void* reserved); /** Creates a composite call credentials object. */ -GRPCAPI grpc_call_credentials *grpc_composite_call_credentials_create( - grpc_call_credentials *creds1, grpc_call_credentials *creds2, - void *reserved); +GRPCAPI grpc_call_credentials* grpc_composite_call_credentials_create( + grpc_call_credentials* creds1, grpc_call_credentials* creds2, + void* reserved); /** Creates a compute engine credentials object for connecting to Google. WARNING: Do NOT use this credentials to connect to a non-google service as this could result in an oauth2 token leak. */ -GRPCAPI grpc_call_credentials *grpc_google_compute_engine_credentials_create( - void *reserved); +GRPCAPI grpc_call_credentials* grpc_google_compute_engine_credentials_create( + void* reserved); GRPCAPI gpr_timespec grpc_max_auth_token_lifetime(); @@ -192,10 +192,10 @@ GRPCAPI gpr_timespec grpc_max_auth_token_lifetime(); - token_lifetime is the lifetime of each Json Web Token (JWT) created with this credentials. It should not exceed grpc_max_auth_token_lifetime or will be cropped to this value. */ -GRPCAPI grpc_call_credentials * -grpc_service_account_jwt_access_credentials_create(const char *json_key, +GRPCAPI grpc_call_credentials* +grpc_service_account_jwt_access_credentials_create(const char* json_key, gpr_timespec token_lifetime, - void *reserved); + void* reserved); /** Creates an Oauth2 Refresh Token credentials object for connecting to Google. May return NULL if the input is invalid. @@ -203,18 +203,18 @@ grpc_service_account_jwt_access_credentials_create(const char *json_key, this could result in an oauth2 token leak. - json_refresh_token is the JSON string containing the refresh token itself along with a client_id and client_secret. */ -GRPCAPI grpc_call_credentials *grpc_google_refresh_token_credentials_create( - const char *json_refresh_token, void *reserved); +GRPCAPI grpc_call_credentials* grpc_google_refresh_token_credentials_create( + const char* json_refresh_token, void* reserved); /** Creates an Oauth2 Access Token credentials with an access token that was aquired by an out of band mechanism. */ -GRPCAPI grpc_call_credentials *grpc_access_token_credentials_create( - const char *access_token, void *reserved); +GRPCAPI grpc_call_credentials* grpc_access_token_credentials_create( + const char* access_token, void* reserved); /** Creates an IAM credentials object for connecting to Google. */ -GRPCAPI grpc_call_credentials *grpc_google_iam_credentials_create( - const char *authorization_token, const char *authority_selector, - void *reserved); +GRPCAPI grpc_call_credentials* grpc_google_iam_credentials_create( + const char* authorization_token, const char* authority_selector, + void* reserved); /** Callback function to be called by the metadata credentials plugin implementation when the metadata is ready. @@ -228,25 +228,25 @@ GRPCAPI grpc_call_credentials *grpc_google_iam_credentials_create( - error_details contains details about the error if any. In case of success it should be NULL and will be otherwise ignored. */ typedef void (*grpc_credentials_plugin_metadata_cb)( - void *user_data, const grpc_metadata *creds_md, size_t num_creds_md, - grpc_status_code status, const char *error_details); + void* user_data, const grpc_metadata* creds_md, size_t num_creds_md, + grpc_status_code status, const char* error_details); /** Context that can be used by metadata credentials plugin in order to create auth related metadata. */ typedef struct { /** The fully qualifed service url. */ - const char *service_url; + const char* service_url; /** The method name of the RPC being called (not fully qualified). The fully qualified method name can be built from the service_url: full_qualified_method_name = ctx->service_url + '/' + ctx->method_name. */ - const char *method_name; + const char* method_name; /** The auth_context of the channel which gives the server's identity. */ - const grpc_auth_context *channel_auth_context; + const grpc_auth_context* channel_auth_context; /** Reserved for future use. */ - void *reserved; + void* reserved; } grpc_auth_metadata_context; /** Maximum number of metadata entries returnable by a credentials plugin via @@ -278,32 +278,32 @@ typedef struct { \a context is the information that can be used by the plugin to create auth metadata. */ int (*get_metadata)( - void *state, grpc_auth_metadata_context context, - grpc_credentials_plugin_metadata_cb cb, void *user_data, + void* state, grpc_auth_metadata_context context, + grpc_credentials_plugin_metadata_cb cb, void* user_data, grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX], - size_t *num_creds_md, grpc_status_code *status, - const char **error_details); + size_t* num_creds_md, grpc_status_code* status, + const char** error_details); /** Destroys the plugin state. */ - void (*destroy)(void *state); + void (*destroy)(void* state); /** State that will be set as the first parameter of the methods above. */ - void *state; + void* state; /** Type of credentials that this plugin is implementing. */ - const char *type; + const char* type; } grpc_metadata_credentials_plugin; /** Creates a credentials object from a plugin. */ -GRPCAPI grpc_call_credentials *grpc_metadata_credentials_create_from_plugin( - grpc_metadata_credentials_plugin plugin, void *reserved); +GRPCAPI grpc_call_credentials* grpc_metadata_credentials_create_from_plugin( + grpc_metadata_credentials_plugin plugin, void* reserved); /** --- Secure channel creation. --- */ /** Creates a secure channel using the passed-in credentials. */ -GRPCAPI grpc_channel *grpc_secure_channel_create( - grpc_channel_credentials *creds, const char *target, - const grpc_channel_args *args, void *reserved); +GRPCAPI grpc_channel* grpc_secure_channel_create( + grpc_channel_credentials* creds, const char* target, + const grpc_channel_args* args, void* reserved); /** --- grpc_server_credentials object. --- @@ -314,7 +314,7 @@ typedef struct grpc_server_credentials grpc_server_credentials; /** Releases a server_credentials object. The creator of the server_credentials object is responsible for its release. */ -GRPCAPI void grpc_server_credentials_release(grpc_server_credentials *creds); +GRPCAPI void grpc_server_credentials_release(grpc_server_credentials* creds); /** Server certificate config object holds the server's public certificates and associated private keys, as well as any CA certificates needed for client @@ -333,15 +333,15 @@ typedef struct grpc_ssl_server_certificate_config and cert_chain_files parameters. It must be at least 1. - It is the caller's responsibility to free this object via grpc_ssl_server_certificate_config_destroy(). */ -GRPCAPI grpc_ssl_server_certificate_config * +GRPCAPI grpc_ssl_server_certificate_config* grpc_ssl_server_certificate_config_create( - const char *pem_root_certs, - const grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, + const char* pem_root_certs, + const grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs); /** Destroys a grpc_ssl_server_certificate_config object. */ GRPCAPI void grpc_ssl_server_certificate_config_destroy( - grpc_ssl_server_certificate_config *config); + grpc_ssl_server_certificate_config* config); /** Callback to retrieve updated SSL server certificates, private keys, and trusted CAs (for client authentication). @@ -351,7 +351,7 @@ GRPCAPI void grpc_ssl_server_certificate_config_destroy( - The caller assumes ownership of the config. */ typedef grpc_ssl_certificate_config_reload_status ( *grpc_ssl_server_certificate_config_callback)( - void *user_data, grpc_ssl_server_certificate_config **config); + void* user_data, grpc_ssl_server_certificate_config** config); /** Deprecated in favor of grpc_ssl_server_credentials_create_ex. Creates an SSL server_credentials object. @@ -365,19 +365,19 @@ typedef grpc_ssl_certificate_config_reload_status ( - force_client_auth, if set to non-zero will force the client to authenticate with an SSL cert. Note that this option is ignored if pem_root_certs is NULL. */ -GRPCAPI grpc_server_credentials *grpc_ssl_server_credentials_create( - 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); +GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create( + 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); /** Deprecated in favor of grpc_ssl_server_credentials_create_with_options. Same as grpc_ssl_server_credentials_create method except uses grpc_ssl_client_certificate_request_type enum to support more ways to authenticate client cerificates.*/ -GRPCAPI grpc_server_credentials *grpc_ssl_server_credentials_create_ex( - const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs, +GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create_ex( + const char* pem_root_certs, grpc_ssl_pem_key_cert_pair* pem_key_cert_pairs, size_t num_key_cert_pairs, grpc_ssl_client_certificate_request_type client_certificate_request, - void *reserved); + void* reserved); typedef struct grpc_ssl_server_credentials_options grpc_ssl_server_credentials_options; @@ -386,10 +386,10 @@ typedef struct grpc_ssl_server_credentials_options the certificates and keys of the SSL server will not change during the server's lifetime. - Takes ownership of the certificate_config parameter. */ -GRPCAPI grpc_ssl_server_credentials_options * +GRPCAPI grpc_ssl_server_credentials_options* grpc_ssl_server_credentials_create_options_using_config( grpc_ssl_client_certificate_request_type client_certificate_request, - grpc_ssl_server_certificate_config *certificate_config); + grpc_ssl_server_certificate_config* certificate_config); /** Creates an options object using a certificate config fetcher. Use this method to reload the certificates and keys of the SSL server without @@ -398,36 +398,36 @@ grpc_ssl_server_credentials_create_options_using_config( - user_data parameter, if not NULL, contains opaque data which will be passed to the fetcher (see definition of grpc_ssl_server_certificate_config_callback). */ -GRPCAPI grpc_ssl_server_credentials_options * +GRPCAPI grpc_ssl_server_credentials_options* grpc_ssl_server_credentials_create_options_using_config_fetcher( grpc_ssl_client_certificate_request_type client_certificate_request, - grpc_ssl_server_certificate_config_callback cb, void *user_data); + grpc_ssl_server_certificate_config_callback cb, void* user_data); /** Destroys a grpc_ssl_server_credentials_options object. */ GRPCAPI void grpc_ssl_server_credentials_options_destroy( - grpc_ssl_server_credentials_options *options); + grpc_ssl_server_credentials_options* options); /** Creates an SSL server_credentials object using the provided options struct. - Takes ownership of the options parameter. */ -GRPCAPI grpc_server_credentials * +GRPCAPI grpc_server_credentials* grpc_ssl_server_credentials_create_with_options( - grpc_ssl_server_credentials_options *options); + grpc_ssl_server_credentials_options* options); /** --- Server-side secure ports. --- */ /** Add a HTTP2 over an encrypted link over tcp listener. Returns bound port number on success, 0 on failure. REQUIRES: server not started */ -GRPCAPI int grpc_server_add_secure_http2_port(grpc_server *server, - const char *addr, - grpc_server_credentials *creds); +GRPCAPI int grpc_server_add_secure_http2_port(grpc_server* server, + const char* addr, + grpc_server_credentials* creds); /** --- Call specific credentials. --- */ /** Sets a credentials to a call. Can only be called on the client side before grpc_call_start_batch. */ -GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call *call, - grpc_call_credentials *creds); +GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call* call, + grpc_call_credentials* creds); /** --- Auth Metadata Processing --- */ @@ -441,9 +441,9 @@ GRPCAPI grpc_call_error grpc_call_set_credentials(grpc_call *call, GRPC_STATUS PERMISSION_DENIED in case of an authorization failure. - error_details gives details about the error. May be NULL. */ typedef void (*grpc_process_auth_metadata_done_cb)( - void *user_data, const grpc_metadata *consumed_md, size_t num_consumed_md, - const grpc_metadata *response_md, size_t num_response_md, - grpc_status_code status, const char *error_details); + void* user_data, const grpc_metadata* consumed_md, size_t num_consumed_md, + const grpc_metadata* response_md, size_t num_response_md, + grpc_status_code status, const char* error_details); /** Pluggable server-side metadata processor object. */ typedef struct { @@ -451,15 +451,15 @@ typedef struct { channel peer and it is the job of the process function to augment it with properties derived from the passed-in metadata. The lifetime of these objects is guaranteed until cb is invoked. */ - void (*process)(void *state, grpc_auth_context *context, - const grpc_metadata *md, size_t num_md, - grpc_process_auth_metadata_done_cb cb, void *user_data); - void (*destroy)(void *state); - void *state; + void (*process)(void* state, grpc_auth_context* context, + const grpc_metadata* md, size_t num_md, + grpc_process_auth_metadata_done_cb cb, void* user_data); + void (*destroy)(void* state); + void* state; } grpc_auth_metadata_processor; GRPCAPI void grpc_server_credentials_set_auth_metadata_processor( - grpc_server_credentials *creds, grpc_auth_metadata_processor processor); + grpc_server_credentials* creds, grpc_auth_metadata_processor processor); #ifdef __cplusplus } diff --git a/include/grpc/impl/codegen/atm.h b/include/grpc/impl/codegen/atm.h index 764bee5272..00d83f0604 100644 --- a/include/grpc/impl/codegen/atm.h +++ b/include/grpc/impl/codegen/atm.h @@ -79,9 +79,17 @@ #error could not determine platform for atm #endif +#ifdef __cplusplus +extern "C" { +#endif + /** Adds \a delta to \a *value, clamping the result to the range specified by \a min and \a max. Returns the new value. */ -gpr_atm gpr_atm_no_barrier_clamped_add(gpr_atm *value, gpr_atm delta, +gpr_atm gpr_atm_no_barrier_clamped_add(gpr_atm* value, gpr_atm delta, gpr_atm min, gpr_atm max); +#ifdef __cplusplus +} +#endif + #endif /* GRPC_IMPL_CODEGEN_ATM_H */ diff --git a/include/grpc/impl/codegen/atm_gcc_atomic.h b/include/grpc/impl/codegen/atm_gcc_atomic.h index 76ce863914..5879708548 100644 --- a/include/grpc/impl/codegen/atm_gcc_atomic.h +++ b/include/grpc/impl/codegen/atm_gcc_atomic.h @@ -23,6 +23,10 @@ __atomic_* interface. */ #include <grpc/impl/codegen/port_platform.h> +#ifdef __cplusplus +extern "C" { +#endif + typedef intptr_t gpr_atm; #define GPR_ATM_MAX INTPTR_MAX #define GPR_ATM_MIN INTPTR_MIN @@ -57,22 +61,22 @@ extern gpr_atm gpr_counter_atm_add; GPR_ATM_INC_ADD_THEN( \ __atomic_fetch_add((p), (intptr_t)(delta), __ATOMIC_ACQ_REL)) -static __inline int gpr_atm_no_barrier_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { +static __inline int gpr_atm_no_barrier_cas(gpr_atm* p, gpr_atm o, gpr_atm n) { return GPR_ATM_INC_CAS_THEN(__atomic_compare_exchange_n( p, &o, n, 0, __ATOMIC_RELAXED, __ATOMIC_RELAXED)); } -static __inline int gpr_atm_acq_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { +static __inline int gpr_atm_acq_cas(gpr_atm* p, gpr_atm o, gpr_atm n) { return GPR_ATM_INC_CAS_THEN(__atomic_compare_exchange_n( p, &o, n, 0, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)); } -static __inline int gpr_atm_rel_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { +static __inline int gpr_atm_rel_cas(gpr_atm* p, gpr_atm o, gpr_atm n) { return GPR_ATM_INC_CAS_THEN(__atomic_compare_exchange_n( p, &o, n, 0, __ATOMIC_RELEASE, __ATOMIC_RELAXED)); } -static __inline int gpr_atm_full_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { +static __inline int gpr_atm_full_cas(gpr_atm* p, gpr_atm o, gpr_atm n) { return GPR_ATM_INC_CAS_THEN(__atomic_compare_exchange_n( p, &o, n, 0, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED)); } @@ -80,4 +84,8 @@ static __inline int gpr_atm_full_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { #define gpr_atm_full_xchg(p, n) \ GPR_ATM_INC_CAS_THEN(__atomic_exchange_n((p), (n), __ATOMIC_ACQ_REL)) +#ifdef __cplusplus +} +#endif + #endif /* GRPC_IMPL_CODEGEN_ATM_GCC_ATOMIC_H */ diff --git a/include/grpc/impl/codegen/atm_gcc_sync.h b/include/grpc/impl/codegen/atm_gcc_sync.h index a9e4da3a0f..c0010a3469 100644 --- a/include/grpc/impl/codegen/atm_gcc_sync.h +++ b/include/grpc/impl/codegen/atm_gcc_sync.h @@ -38,24 +38,24 @@ typedef intptr_t gpr_atm; #define gpr_atm_full_barrier() (__sync_synchronize()) -static __inline gpr_atm gpr_atm_acq_load(const gpr_atm *p) { +static __inline gpr_atm gpr_atm_acq_load(const gpr_atm* p) { gpr_atm value = *p; GPR_ATM_LS_BARRIER_(); return value; } -static __inline gpr_atm gpr_atm_no_barrier_load(const gpr_atm *p) { +static __inline gpr_atm gpr_atm_no_barrier_load(const gpr_atm* p) { gpr_atm value = *p; GPR_ATM_COMPILE_BARRIER_(); return value; } -static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) { +static __inline void gpr_atm_rel_store(gpr_atm* p, gpr_atm value) { GPR_ATM_LS_BARRIER_(); *p = value; } -static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) { +static __inline void gpr_atm_no_barrier_store(gpr_atm* p, gpr_atm value) { GPR_ATM_COMPILE_BARRIER_(); *p = value; } @@ -72,7 +72,7 @@ static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) { #define gpr_atm_rel_cas(p, o, n) gpr_atm_acq_cas((p), (o), (n)) #define gpr_atm_full_cas(p, o, n) gpr_atm_acq_cas((p), (o), (n)) -static __inline gpr_atm gpr_atm_full_xchg(gpr_atm *p, gpr_atm n) { +static __inline gpr_atm gpr_atm_full_xchg(gpr_atm* p, gpr_atm n) { gpr_atm cur; do { cur = gpr_atm_acq_load(p); diff --git a/include/grpc/impl/codegen/atm_windows.h b/include/grpc/impl/codegen/atm_windows.h index b868d79aef..f6b27e5df7 100644 --- a/include/grpc/impl/codegen/atm_windows.h +++ b/include/grpc/impl/codegen/atm_windows.h @@ -28,70 +28,70 @@ typedef intptr_t gpr_atm; #define gpr_atm_full_barrier MemoryBarrier -static __inline gpr_atm gpr_atm_acq_load(const gpr_atm *p) { +static __inline gpr_atm gpr_atm_acq_load(const gpr_atm* p) { gpr_atm result = *p; gpr_atm_full_barrier(); return result; } -static __inline gpr_atm gpr_atm_no_barrier_load(const gpr_atm *p) { +static __inline gpr_atm gpr_atm_no_barrier_load(const gpr_atm* p) { /* TODO(dklempner): Can we implement something better here? */ return gpr_atm_acq_load(p); } -static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) { +static __inline void gpr_atm_rel_store(gpr_atm* p, gpr_atm value) { gpr_atm_full_barrier(); *p = value; } -static __inline void gpr_atm_no_barrier_store(gpr_atm *p, gpr_atm value) { +static __inline void gpr_atm_no_barrier_store(gpr_atm* p, gpr_atm value) { /* TODO(ctiller): Can we implement something better here? */ gpr_atm_rel_store(p, value); } -static __inline int gpr_atm_no_barrier_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { +static __inline int gpr_atm_no_barrier_cas(gpr_atm* p, gpr_atm o, gpr_atm n) { /** InterlockedCompareExchangePointerNoFence() not available on vista or windows7 */ #ifdef GPR_ARCH_64 return o == (gpr_atm)InterlockedCompareExchangeAcquire64( - (volatile LONGLONG *)p, (LONGLONG)n, (LONGLONG)o); + (volatile LONGLONG*)p, (LONGLONG)n, (LONGLONG)o); #else - return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG *)p, + return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG*)p, (LONG)n, (LONG)o); #endif } -static __inline int gpr_atm_acq_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { +static __inline int gpr_atm_acq_cas(gpr_atm* p, gpr_atm o, gpr_atm n) { #ifdef GPR_ARCH_64 return o == (gpr_atm)InterlockedCompareExchangeAcquire64( - (volatile LONGLONG *)p, (LONGLONG)n, (LONGLONG)o); + (volatile LONGLONG*)p, (LONGLONG)n, (LONGLONG)o); #else - return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG *)p, + return o == (gpr_atm)InterlockedCompareExchangeAcquire((volatile LONG*)p, (LONG)n, (LONG)o); #endif } -static __inline int gpr_atm_rel_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { +static __inline int gpr_atm_rel_cas(gpr_atm* p, gpr_atm o, gpr_atm n) { #ifdef GPR_ARCH_64 return o == (gpr_atm)InterlockedCompareExchangeRelease64( - (volatile LONGLONG *)p, (LONGLONG)n, (LONGLONG)o); + (volatile LONGLONG*)p, (LONGLONG)n, (LONGLONG)o); #else - return o == (gpr_atm)InterlockedCompareExchangeRelease((volatile LONG *)p, + return o == (gpr_atm)InterlockedCompareExchangeRelease((volatile LONG*)p, (LONG)n, (LONG)o); #endif } -static __inline int gpr_atm_full_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { +static __inline int gpr_atm_full_cas(gpr_atm* p, gpr_atm o, gpr_atm n) { #ifdef GPR_ARCH_64 - return o == (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG *)p, + return o == (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG*)p, (LONGLONG)n, (LONGLONG)o); #else - return o == (gpr_atm)InterlockedCompareExchange((volatile LONG *)p, (LONG)n, + return o == (gpr_atm)InterlockedCompareExchange((volatile LONG*)p, (LONG)n, (LONG)o); #endif } -static __inline gpr_atm gpr_atm_no_barrier_fetch_add(gpr_atm *p, +static __inline gpr_atm gpr_atm_no_barrier_fetch_add(gpr_atm* p, gpr_atm delta) { /** Use the CAS operation to get pointer-sized fetch and add */ gpr_atm old; @@ -101,26 +101,26 @@ static __inline gpr_atm gpr_atm_no_barrier_fetch_add(gpr_atm *p, return old; } -static __inline gpr_atm gpr_atm_full_fetch_add(gpr_atm *p, gpr_atm delta) { +static __inline gpr_atm gpr_atm_full_fetch_add(gpr_atm* p, gpr_atm delta) { /** Use a CAS operation to get pointer-sized fetch and add */ gpr_atm old; #ifdef GPR_ARCH_64 do { old = *p; - } while (old != (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG *)p, + } while (old != (gpr_atm)InterlockedCompareExchange64((volatile LONGLONG*)p, (LONGLONG)old + delta, (LONGLONG)old)); #else do { old = *p; } while (old != (gpr_atm)InterlockedCompareExchange( - (volatile LONG *)p, (LONG)old + delta, (LONG)old)); + (volatile LONG*)p, (LONG)old + delta, (LONG)old)); #endif return old; } -static __inline gpr_atm gpr_atm_full_xchg(gpr_atm *p, gpr_atm n) { - return (gpr_atm)InterlockedExchangePointer((PVOID *)p, (PVOID)n); +static __inline gpr_atm gpr_atm_full_xchg(gpr_atm* p, gpr_atm n) { + return (gpr_atm)InterlockedExchangePointer((PVOID*)p, (PVOID)n); } #endif /* GRPC_IMPL_CODEGEN_ATM_WINDOWS_H */ diff --git a/include/grpc/impl/codegen/byte_buffer.h b/include/grpc/impl/codegen/byte_buffer.h index fc33305713..f8dfbd1d7d 100644 --- a/include/grpc/impl/codegen/byte_buffer.h +++ b/include/grpc/impl/codegen/byte_buffer.h @@ -29,7 +29,7 @@ extern "C" { * * Increases the reference count for all \a slices processed. The user is * responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/ -GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_create(grpc_slice *slices, +GRPCAPI grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slices, size_t nslices); /** Returns a *compressed* RAW byte buffer instance over the given slices (up to @@ -38,20 +38,20 @@ GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_create(grpc_slice *slices, * * Increases the reference count for all \a slices processed. The user is * responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/ -GRPCAPI grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create( - grpc_slice *slices, size_t nslices, grpc_compression_algorithm compression); +GRPCAPI grpc_byte_buffer* grpc_raw_compressed_byte_buffer_create( + grpc_slice* slices, size_t nslices, grpc_compression_algorithm compression); /** Copies input byte buffer \a bb. * * Increases the reference count of all the source slices. The user is * responsible for calling grpc_byte_buffer_destroy over the returned copy. */ -GRPCAPI grpc_byte_buffer *grpc_byte_buffer_copy(grpc_byte_buffer *bb); +GRPCAPI grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb); /** Returns the size of the given byte buffer, in bytes. */ -GRPCAPI size_t grpc_byte_buffer_length(grpc_byte_buffer *bb); +GRPCAPI size_t grpc_byte_buffer_length(grpc_byte_buffer* bb); /** Destroys \a byte_buffer deallocating all its memory. */ -GRPCAPI void grpc_byte_buffer_destroy(grpc_byte_buffer *byte_buffer); +GRPCAPI void grpc_byte_buffer_destroy(grpc_byte_buffer* byte_buffer); /** Reader for byte buffers. Iterates over slices in the byte buffer */ struct grpc_byte_buffer_reader; @@ -59,25 +59,25 @@ typedef struct grpc_byte_buffer_reader grpc_byte_buffer_reader; /** Initialize \a reader to read over \a buffer. * Returns 1 upon success, 0 otherwise. */ -GRPCAPI int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader, - grpc_byte_buffer *buffer); +GRPCAPI int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader, + grpc_byte_buffer* buffer); /** Cleanup and destroy \a reader */ -GRPCAPI void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader); +GRPCAPI void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader* reader); /** Updates \a slice with the next piece of data from from \a reader and returns * 1. Returns 0 at the end of the stream. Caller is responsible for calling * grpc_slice_unref on the result. */ -GRPCAPI int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader, - grpc_slice *slice); +GRPCAPI int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader, + grpc_slice* slice); /** Merge all data from \a reader into single slice */ GRPCAPI grpc_slice -grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader); +grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader* reader); /** Returns a RAW byte buffer instance from the output of \a reader. */ -GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_from_reader( - grpc_byte_buffer_reader *reader); +GRPCAPI grpc_byte_buffer* grpc_raw_byte_buffer_from_reader( + grpc_byte_buffer_reader* reader); #ifdef __cplusplus } diff --git a/include/grpc/impl/codegen/byte_buffer_reader.h b/include/grpc/impl/codegen/byte_buffer_reader.h index dc0f15496f..e06e19558a 100644 --- a/include/grpc/impl/codegen/byte_buffer_reader.h +++ b/include/grpc/impl/codegen/byte_buffer_reader.h @@ -26,8 +26,8 @@ extern "C" { struct grpc_byte_buffer; struct grpc_byte_buffer_reader { - struct grpc_byte_buffer *buffer_in; - struct grpc_byte_buffer *buffer_out; + struct grpc_byte_buffer* buffer_in; + struct grpc_byte_buffer* buffer_out; /** Different current objects correspond to different types of byte buffers */ union grpc_byte_buffer_reader_current { /** Index into a slice buffer's array of slices */ diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 65463bb33b..03be610d25 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -39,11 +39,11 @@ typedef enum { } grpc_byte_buffer_type; typedef struct grpc_byte_buffer { - void *reserved; + void* reserved; grpc_byte_buffer_type type; union grpc_byte_buffer_data { struct /* internal */ { - void *reserved[8]; + void* reserved[8]; } reserved; struct grpc_compressed_buffer { grpc_compression_algorithm compression; @@ -84,9 +84,9 @@ typedef enum { } grpc_arg_type; typedef struct grpc_arg_pointer_vtable { - void *(*copy)(void *p); - void (*destroy)(grpc_exec_ctx *exec_ctx, void *p); - int (*cmp)(void *p, void *q); + void* (*copy)(void* p); + void (*destroy)(grpc_exec_ctx* exec_ctx, void* p); + int (*cmp)(void* p, void* q); } grpc_arg_pointer_vtable; /** A single argument... each argument has a key and a value @@ -103,13 +103,13 @@ typedef struct grpc_arg_pointer_vtable { their keys so that it's possible to change them in the future. */ typedef struct { grpc_arg_type type; - char *key; + char* key; union grpc_arg_value { - char *string; + char* string; int integer; struct grpc_arg_pointer { - void *p; - const grpc_arg_pointer_vtable *vtable; + void* p; + const grpc_arg_pointer_vtable* vtable; } pointer; } value; } grpc_arg; @@ -127,7 +127,7 @@ typedef struct { details. */ typedef struct { size_t num_args; - grpc_arg *args; + grpc_arg* args; } grpc_channel_args; /** \defgroup grpc_arg_keys @@ -400,7 +400,7 @@ typedef struct grpc_metadata { There is no need to initialize them, and they will be set to garbage during calls to grpc. */ struct /* internal */ { - void *obfuscated[4]; + void* obfuscated[4]; } internal_data; } grpc_metadata; @@ -428,13 +428,13 @@ typedef struct grpc_event { int success; /** The tag passed to grpc_call_start_batch etc to start this operation. Only GRPC_OP_COMPLETE has a tag. */ - void *tag; + void* tag; } grpc_event; typedef struct { size_t count; size_t capacity; - grpc_metadata *metadata; + grpc_metadata* metadata; } grpc_metadata_array; typedef struct { @@ -442,7 +442,7 @@ typedef struct { grpc_slice host; gpr_timespec deadline; uint32_t flags; - void *reserved; + void* reserved; } grpc_call_details; typedef enum { @@ -498,15 +498,15 @@ typedef struct grpc_op { /** Write flags bitset for grpc_begin_messages */ uint32_t flags; /** Reserved for future usage */ - void *reserved; + void* reserved; union grpc_op_data { /** Reserved for future usage */ struct /* internal */ { - void *reserved[8]; + void* reserved[8]; } reserved; struct grpc_op_send_initial_metadata { size_t count; - grpc_metadata *metadata; + grpc_metadata* metadata; /** If \a is_set, \a compression_level will be used for the call. * Otherwise, \a compression_level won't be considered */ struct grpc_op_send_initial_metadata_maybe_compression_level { @@ -524,16 +524,16 @@ typedef struct grpc_op { * and likely empty. The original owner should still call * grpc_byte_buffer_destroy() on this object however. */ - struct grpc_byte_buffer *send_message; + struct grpc_byte_buffer* send_message; } send_message; struct grpc_op_send_status_from_server { size_t trailing_metadata_count; - grpc_metadata *trailing_metadata; + grpc_metadata* trailing_metadata; grpc_status_code status; /** optional: set to NULL if no details need sending, non-NULL if they do * pointer will not be retained past the start_batch call */ - grpc_slice *status_details; + grpc_slice* status_details; } send_status_from_server; /** ownership of the array is with the caller, but ownership of the elements stays with the call object (ie key, value members are owned by the call @@ -541,13 +541,13 @@ typedef struct grpc_op { After the operation completes, call grpc_metadata_array_destroy on this value, or reuse it in a future op. */ struct grpc_op_recv_initial_metadata { - grpc_metadata_array *recv_initial_metadata; + grpc_metadata_array* recv_initial_metadata; } recv_initial_metadata; /** ownership of the byte buffer is moved to the caller; the caller must call grpc_byte_buffer_destroy on this value, or reuse it in a future op. */ struct grpc_op_recv_message { - struct grpc_byte_buffer **recv_message; + struct grpc_byte_buffer** recv_message; } recv_message; struct grpc_op_recv_status_on_client { /** ownership of the array is with the caller, but ownership of the @@ -555,14 +555,14 @@ typedef struct grpc_op { by the call object, trailing_metadata->array is owned by the caller). After the operation completes, call grpc_metadata_array_destroy on this value, or reuse it in a future op. */ - grpc_metadata_array *trailing_metadata; - grpc_status_code *status; - grpc_slice *status_details; + grpc_metadata_array* trailing_metadata; + grpc_status_code* status; + grpc_slice* status_details; } recv_status_on_client; struct grpc_op_recv_close_on_server { /** out argument, set to 1 if the call failed in any way (seen as a cancellation on the server), or 0 if the call succeeded */ - int *cancelled; + int* cancelled; } recv_close_on_server; } data; } grpc_op; @@ -571,10 +571,10 @@ typedef struct grpc_op { typedef struct { /** If non-NULL, will be set to point to a string indicating the LB * policy name. Caller takes ownership. */ - char **lb_policy_name; + char** lb_policy_name; /** If non-NULL, will be set to point to a string containing the * service config used by the channel in JSON form. */ - char **service_config_json; + char** service_config_json; } grpc_channel_info; typedef struct grpc_resource_quota grpc_resource_quota; diff --git a/include/grpc/impl/codegen/slice.h b/include/grpc/impl/codegen/slice.h index 128fa8e121..11997fcb56 100644 --- a/include/grpc/impl/codegen/slice.h +++ b/include/grpc/impl/codegen/slice.h @@ -42,8 +42,8 @@ typedef struct grpc_slice grpc_slice; constraints (is the callee allowed to modify the slice?) */ typedef struct grpc_slice_refcount_vtable { - void (*ref)(void *); - void (*unref)(grpc_exec_ctx *exec_ctx, void *); + void (*ref)(void*); + void (*unref)(grpc_exec_ctx* exec_ctx, void*); int (*eq)(grpc_slice a, grpc_slice b); uint32_t (*hash)(grpc_slice slice); } grpc_slice_refcount_vtable; @@ -54,20 +54,20 @@ typedef struct grpc_slice_refcount_vtable { Typically client code should not touch this, and use grpc_slice_malloc, grpc_slice_new, or grpc_slice_new_with_len instead. */ typedef struct grpc_slice_refcount { - const grpc_slice_refcount_vtable *vtable; + const grpc_slice_refcount_vtable* vtable; /** If a subset of this slice is taken, use this pointer for the refcount. Typically points back to the refcount itself, however iterning implementations can use this to avoid a verification step on each hash or equality check */ - struct grpc_slice_refcount *sub_refcount; + struct grpc_slice_refcount* sub_refcount; } grpc_slice_refcount; /* Inlined half of grpc_slice is allowed to expand the size of the overall type by this many bytes */ -#define GRPC_SLICE_INLINE_EXTRA_SIZE sizeof(void *) +#define GRPC_SLICE_INLINE_EXTRA_SIZE sizeof(void*) #define GRPC_SLICE_INLINED_SIZE \ - (sizeof(size_t) + sizeof(uint8_t *) - 1 + GRPC_SLICE_INLINE_EXTRA_SIZE) + (sizeof(size_t) + sizeof(uint8_t*) - 1 + GRPC_SLICE_INLINE_EXTRA_SIZE) /** A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. @@ -79,10 +79,10 @@ typedef struct grpc_slice_refcount { If the slice does not have a refcount, it represents an inlined small piece of data that is copied by value. */ struct grpc_slice { - struct grpc_slice_refcount *refcount; + struct grpc_slice_refcount* refcount; union grpc_slice_data { struct grpc_slice_refcounted { - uint8_t *bytes; + uint8_t* bytes; size_t length; } refcounted; struct grpc_slice_inlined { @@ -99,10 +99,10 @@ struct grpc_slice { typedef struct { /** This is for internal use only. External users (i.e any code outside grpc * core) MUST NOT use this field */ - grpc_slice *base_slices; + grpc_slice* base_slices; /** slices in the array (Points to the first valid grpc_slice in the array) */ - grpc_slice *slices; + grpc_slice* slices; /** the number of slices in the array */ size_t count; /** the number of slices allocated in the array. External users (i.e any code diff --git a/include/grpc/impl/codegen/sync_generic.h b/include/grpc/impl/codegen/sync_generic.h index e1eea54298..83f905e120 100644 --- a/include/grpc/impl/codegen/sync_generic.h +++ b/include/grpc/impl/codegen/sync_generic.h @@ -23,16 +23,22 @@ #include <grpc/impl/codegen/atm.h> /* gpr_event */ -typedef struct { gpr_atm state; } gpr_event; +typedef struct { + gpr_atm state; +} gpr_event; #define GPR_EVENT_INIT \ { 0 } /* gpr_refcount */ -typedef struct { gpr_atm count; } gpr_refcount; +typedef struct { + gpr_atm count; +} gpr_refcount; /* gpr_stats_counter */ -typedef struct { gpr_atm value; } gpr_stats_counter; +typedef struct { + gpr_atm value; +} gpr_stats_counter; #define GPR_STATS_INIT \ { 0 } diff --git a/include/grpc/slice.h b/include/grpc/slice.h index 3f3cff1408..10b6a624b3 100644 --- a/include/grpc/slice.h +++ b/include/grpc/slice.h @@ -44,20 +44,20 @@ GPRAPI grpc_slice grpc_slice_copy(grpc_slice s); /** Create a slice pointing at some data. Calls malloc to allocate a refcount for the object, and arranges that destroy will be called with the pointer passed in at destruction. */ -GPRAPI grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *)); +GPRAPI grpc_slice grpc_slice_new(void* p, size_t len, void (*destroy)(void*)); /** Equivalent to grpc_slice_new, but with a separate pointer that is passed to the destroy function. This function can be useful when the data is part of a larger structure that must be destroyed when the data is no longer needed. */ -GPRAPI grpc_slice grpc_slice_new_with_user_data(void *p, size_t len, - void (*destroy)(void *), - void *user_data); +GPRAPI grpc_slice grpc_slice_new_with_user_data(void* p, size_t len, + void (*destroy)(void*), + void* user_data); /** Equivalent to grpc_slice_new, but with a two argument destroy function that also takes the slice length. */ -GPRAPI grpc_slice grpc_slice_new_with_len(void *p, size_t len, - void (*destroy)(void *, size_t)); +GPRAPI grpc_slice grpc_slice_new_with_len(void* p, size_t len, + void (*destroy)(void*, size_t)); /** Equivalent to grpc_slice_new(malloc(len), len, free), but saves one malloc() call. @@ -79,19 +79,19 @@ GPRAPI grpc_slice grpc_slice_intern(grpc_slice slice); size_t len = strlen(source); grpc_slice slice = grpc_slice_malloc(len); memcpy(slice->data, source, len); */ -GPRAPI grpc_slice grpc_slice_from_copied_string(const char *source); +GPRAPI grpc_slice grpc_slice_from_copied_string(const char* source); /** Create a slice by copying a buffer. Equivalent to: grpc_slice slice = grpc_slice_malloc(len); memcpy(slice->data, source, len); */ -GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len); +GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char* source, size_t len); /** Create a slice pointing to constant memory */ -GPRAPI grpc_slice grpc_slice_from_static_string(const char *source); +GPRAPI grpc_slice grpc_slice_from_static_string(const char* source); /** Create a slice pointing to constant memory */ -GPRAPI grpc_slice grpc_slice_from_static_buffer(const void *source, size_t len); +GPRAPI grpc_slice grpc_slice_from_static_buffer(const void* source, size_t len); /** Return a result slice derived from s, which shares a ref count with \a s, where result.data==s.data+begin, and result.length==end-begin. The ref count @@ -106,7 +106,7 @@ GPRAPI grpc_slice grpc_slice_sub_no_ref(grpc_slice s, size_t begin, size_t end); /** Splits s into two: modifies s to be s[0:split], and returns a new slice, sharing a refcount with s, that contains s[split:s.length]. Requires s intialized, split <= s.length */ -GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split); +GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split); typedef enum { GRPC_SLICE_REF_TAIL = 1, @@ -117,13 +117,13 @@ typedef enum { /** The same as grpc_slice_split_tail, but with an option to skip altering * refcounts (grpc_slice_split_tail_maybe_ref(..., true) is equivalent to * grpc_slice_split_tail(...)) */ -GPRAPI grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice *s, size_t split, +GPRAPI grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice* s, size_t split, grpc_slice_ref_whom ref_whom); /** Splits s into two: modifies s to be s[split:s.length], and returns a new slice, sharing a refcount with s, that contains s[0:split]. Requires s intialized, split <= s.length */ -GPRAPI grpc_slice grpc_slice_split_head(grpc_slice *s, size_t split); +GPRAPI grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split); GPRAPI grpc_slice grpc_empty_slice(void); @@ -136,11 +136,10 @@ GPRAPI int grpc_slice_eq(grpc_slice a, grpc_slice b); The order is arbitrary, and is not guaranteed to be stable across different versions of the API. */ GPRAPI int grpc_slice_cmp(grpc_slice a, grpc_slice b); -GPRAPI int grpc_slice_str_cmp(grpc_slice a, const char *b); -GPRAPI int grpc_slice_buf_cmp(grpc_slice a, const void *b, size_t blen); +GPRAPI int grpc_slice_str_cmp(grpc_slice a, const char* b); /** return non-zero if the first blen bytes of a are equal to b */ -GPRAPI int grpc_slice_buf_start_eq(grpc_slice a, const void *b, size_t blen); +GPRAPI int grpc_slice_buf_start_eq(grpc_slice a, const void* b, size_t blen); /** return the index of the last instance of \a c in \a s, or -1 if not found */ GPRAPI int grpc_slice_rchr(grpc_slice s, char c); @@ -162,7 +161,7 @@ GPRAPI grpc_slice grpc_slice_dup(grpc_slice a); /** Return a copy of slice as a C string. Offers no protection against embedded NULL's. Returned string must be freed with gpr_free. */ -GPRAPI char *grpc_slice_to_c_string(grpc_slice s); +GPRAPI char* grpc_slice_to_c_string(grpc_slice s); #ifdef __cplusplus } diff --git a/include/grpc/slice_buffer.h b/include/grpc/slice_buffer.h index de4b86f777..6510c151b3 100644 --- a/include/grpc/slice_buffer.h +++ b/include/grpc/slice_buffer.h @@ -26,13 +26,13 @@ extern "C" { #endif /** initialize a slice buffer */ -GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer *sb); +GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer* sb); /** destroy a slice buffer - unrefs any held elements */ -GPRAPI void grpc_slice_buffer_destroy(grpc_slice_buffer *sb); +GPRAPI void grpc_slice_buffer_destroy(grpc_slice_buffer* sb); /** Add an element to a slice buffer - takes ownership of the slice. This function is allowed to concatenate the passed in slice to the end of some other slice if desired by the slice buffer. */ -GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice); +GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice); /** add an element to a slice buffer - takes ownership of the slice and returns the index of the slice. Guarantees that the slice will not be concatenated at the end of another @@ -40,40 +40,40 @@ GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice); slice at the returned index in sb->slices) The implementation MAY decide to concatenate data at the end of a small slice added in this fashion. */ -GPRAPI size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, +GPRAPI size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer* sb, grpc_slice slice); -GPRAPI void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *slices, +GPRAPI void grpc_slice_buffer_addn(grpc_slice_buffer* sb, grpc_slice* slices, size_t n); /** add a very small (less than 8 bytes) amount of data to the end of a slice buffer: returns a pointer into which to add the data */ -GPRAPI uint8_t *grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t len); +GPRAPI uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t len); /** pop the last buffer, but don't unref it */ -GPRAPI void grpc_slice_buffer_pop(grpc_slice_buffer *sb); +GPRAPI void grpc_slice_buffer_pop(grpc_slice_buffer* sb); /** clear a slice buffer, unref all elements */ -GPRAPI void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer *sb); +GPRAPI void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer* sb); /** swap the contents of two slice buffers */ -GPRAPI void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b); +GPRAPI void grpc_slice_buffer_swap(grpc_slice_buffer* a, grpc_slice_buffer* b); /** move all of the elements of src into dst */ -GPRAPI void grpc_slice_buffer_move_into(grpc_slice_buffer *src, - grpc_slice_buffer *dst); +GPRAPI void grpc_slice_buffer_move_into(grpc_slice_buffer* src, + grpc_slice_buffer* dst); /** remove n bytes from the end of a slice buffer */ -GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer *src, size_t n, - grpc_slice_buffer *garbage); +GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer* src, size_t n, + grpc_slice_buffer* garbage); /** move the first n bytes of src into dst */ -GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, - grpc_slice_buffer *dst); +GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer* src, size_t n, + grpc_slice_buffer* dst); /** move the first n bytes of src into dst without adding references */ -GPRAPI void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer *src, +GPRAPI void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer* src, size_t n, - grpc_slice_buffer *dst); + grpc_slice_buffer* dst); /** move the first n bytes of src into dst (copying them) */ -GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx, - grpc_slice_buffer *src, - size_t n, void *dst); +GPRAPI void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx* exec_ctx, + grpc_slice_buffer* src, + size_t n, void* dst); /** take the first slice in the slice buffer */ -GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *src); +GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* src); /** undo the above with (a possibly different) \a slice */ -GPRAPI void grpc_slice_buffer_undo_take_first(grpc_slice_buffer *src, +GPRAPI void grpc_slice_buffer_undo_take_first(grpc_slice_buffer* src, grpc_slice slice); #ifdef __cplusplus diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h index 4b59e137f2..31cb225638 100644 --- a/include/grpc/support/alloc.h +++ b/include/grpc/support/alloc.h @@ -28,10 +28,10 @@ extern "C" { #endif typedef struct gpr_allocation_functions { - void *(*malloc_fn)(size_t size); - void *(*zalloc_fn)(size_t size); /** if NULL, uses malloc_fn then memset */ - void *(*realloc_fn)(void *ptr, size_t size); - void (*free_fn)(void *ptr); + void* (*malloc_fn)(size_t size); + void* (*zalloc_fn)(size_t size); /** if NULL, uses malloc_fn then memset */ + void* (*realloc_fn)(void* ptr, size_t size); + void (*free_fn)(void* ptr); } gpr_allocation_functions; /** malloc. @@ -39,17 +39,17 @@ typedef struct gpr_allocation_functions { * The pointer returned is suitably aligned for any kind of variable it could * contain. */ -GPRAPI void *gpr_malloc(size_t size); +GPRAPI void* gpr_malloc(size_t size); /** like malloc, but zero all bytes before returning them */ -GPRAPI void *gpr_zalloc(size_t size); +GPRAPI void* gpr_zalloc(size_t size); /** free */ -GPRAPI void gpr_free(void *ptr); +GPRAPI void gpr_free(void* ptr); /** realloc, never returns NULL */ -GPRAPI void *gpr_realloc(void *p, size_t size); +GPRAPI void* gpr_realloc(void* p, size_t size); /** aligned malloc, never returns NULL, will align to 1 << alignment_log */ -GPRAPI void *gpr_malloc_aligned(size_t size, size_t alignment_log); +GPRAPI void* gpr_malloc_aligned(size_t size, size_t alignment_log); /** free memory allocated by gpr_malloc_aligned */ -GPRAPI void gpr_free_aligned(void *ptr); +GPRAPI void gpr_free_aligned(void* ptr); /** Request the family of allocation functions in \a functions be used. NOTE * that this request will be honored in a *best effort* basis and that no diff --git a/include/grpc/support/avl.h b/include/grpc/support/avl.h index d8a5efd2ad..b5a8c0ffa1 100644 --- a/include/grpc/support/avl.h +++ b/include/grpc/support/avl.h @@ -28,10 +28,10 @@ extern "C" { /** internal node of an AVL tree */ typedef struct gpr_avl_node { gpr_refcount refs; - void *key; - void *value; - struct gpr_avl_node *left; - struct gpr_avl_node *right; + void* key; + void* value; + struct gpr_avl_node* left; + struct gpr_avl_node* right; long height; } gpr_avl_node; @@ -42,56 +42,56 @@ typedef struct gpr_avl_node { */ typedef struct gpr_avl_vtable { /** destroy a key */ - void (*destroy_key)(void *key, void *user_data); + void (*destroy_key)(void* key, void* user_data); /** copy a key, returning new value */ - void *(*copy_key)(void *key, void *user_data); + void* (*copy_key)(void* key, void* user_data); /** compare key1, key2; return <0 if key1 < key2, >0 if key1 > key2, 0 if key1 == key2 */ - long (*compare_keys)(void *key1, void *key2, void *user_data); + long (*compare_keys)(void* key1, void* key2, void* user_data); /** destroy a value */ - void (*destroy_value)(void *value, void *user_data); + void (*destroy_value)(void* value, void* user_data); /** copy a value */ - void *(*copy_value)(void *value, void *user_data); + void* (*copy_value)(void* value, void* user_data); } gpr_avl_vtable; /** "pointer" to an AVL tree - this is a reference counted object - use gpr_avl_ref to add a reference, gpr_avl_unref when done with a reference */ typedef struct gpr_avl { - const gpr_avl_vtable *vtable; - gpr_avl_node *root; + const gpr_avl_vtable* vtable; + gpr_avl_node* root; } gpr_avl; /** Create an immutable AVL tree. */ -GPRAPI gpr_avl gpr_avl_create(const gpr_avl_vtable *vtable); +GPRAPI gpr_avl gpr_avl_create(const gpr_avl_vtable* vtable); /** Add a reference to an existing tree - returns the tree as a convenience. The optional user_data will be passed to vtable functions. */ -GPRAPI gpr_avl gpr_avl_ref(gpr_avl avl, void *user_data); +GPRAPI gpr_avl gpr_avl_ref(gpr_avl avl, void* user_data); /** Remove a reference to a tree - destroying it if there are no references left. The optional user_data will be passed to vtable functions. */ -GPRAPI void gpr_avl_unref(gpr_avl avl, void *user_data); +GPRAPI void gpr_avl_unref(gpr_avl avl, void* user_data); /** Return a new tree with (key, value) added to avl. implicitly unrefs avl to allow easy chaining. if key exists in avl, the new tree's key entry updated (i.e. a duplicate is not created). The optional user_data will be passed to vtable functions. */ -GPRAPI gpr_avl gpr_avl_add(gpr_avl avl, void *key, void *value, - void *user_data); +GPRAPI gpr_avl gpr_avl_add(gpr_avl avl, void* key, void* value, + void* user_data); /** Return a new tree with key deleted implicitly unrefs avl to allow easy chaining. The optional user_data will be passed to vtable functions. */ -GPRAPI gpr_avl gpr_avl_remove(gpr_avl avl, void *key, void *user_data); +GPRAPI gpr_avl gpr_avl_remove(gpr_avl avl, void* key, void* user_data); /** Lookup key, and return the associated value. Does not mutate avl. Returns NULL if key is not found. The optional user_data will be passed to vtable functions.*/ -GPRAPI void *gpr_avl_get(gpr_avl avl, void *key, void *user_data); +GPRAPI void* gpr_avl_get(gpr_avl avl, void* key, void* user_data); /** Return 1 if avl contains key, 0 otherwise; if it has the key, sets *value to its value. THe optional user_data will be passed to vtable functions. */ -GPRAPI int gpr_avl_maybe_get(gpr_avl avl, void *key, void **value, - void *user_data); +GPRAPI int gpr_avl_maybe_get(gpr_avl avl, void* key, void** value, + void* user_data); /** Return 1 if avl is empty, 0 otherwise */ GPRAPI int gpr_avl_is_empty(gpr_avl avl); diff --git a/include/grpc/support/cmdline.h b/include/grpc/support/cmdline.h index 9f46491b38..c34a109fbd 100644 --- a/include/grpc/support/cmdline.h +++ b/include/grpc/support/cmdline.h @@ -55,31 +55,31 @@ typedef struct gpr_cmdline gpr_cmdline; /** Construct a command line parser: takes a short description of the tool doing the parsing */ -GPRAPI gpr_cmdline *gpr_cmdline_create(const char *description); +GPRAPI gpr_cmdline* gpr_cmdline_create(const char* description); /** Add an integer parameter, with a name (used on the command line) and some helpful text (used in the command usage) */ -GPRAPI void gpr_cmdline_add_int(gpr_cmdline *cl, const char *name, - const char *help, int *value); +GPRAPI void gpr_cmdline_add_int(gpr_cmdline* cl, const char* name, + const char* help, int* value); /** The same, for a boolean flag */ -GPRAPI void gpr_cmdline_add_flag(gpr_cmdline *cl, const char *name, - const char *help, int *value); +GPRAPI void gpr_cmdline_add_flag(gpr_cmdline* cl, const char* name, + const char* help, int* value); /** And for a string */ -GPRAPI void gpr_cmdline_add_string(gpr_cmdline *cl, const char *name, - const char *help, char **value); +GPRAPI void gpr_cmdline_add_string(gpr_cmdline* cl, const char* name, + const char* help, const char** value); /** Set a callback for non-named arguments */ GPRAPI void gpr_cmdline_on_extra_arg( - gpr_cmdline *cl, const char *name, const char *help, - void (*on_extra_arg)(void *user_data, const char *arg), void *user_data); + gpr_cmdline* cl, const char* name, const char* help, + void (*on_extra_arg)(void* user_data, const char* arg), void* user_data); /** Enable surviving failure: default behavior is to exit the process */ -GPRAPI void gpr_cmdline_set_survive_failure(gpr_cmdline *cl); +GPRAPI void gpr_cmdline_set_survive_failure(gpr_cmdline* cl); /** Parse the command line; returns 1 on success, on failure either dies (by default) or returns 0 if gpr_cmdline_set_survive_failure() has been called */ -GPRAPI int gpr_cmdline_parse(gpr_cmdline *cl, int argc, char **argv); +GPRAPI int gpr_cmdline_parse(gpr_cmdline* cl, int argc, char** argv); /** Destroy the parser */ -GPRAPI void gpr_cmdline_destroy(gpr_cmdline *cl); +GPRAPI void gpr_cmdline_destroy(gpr_cmdline* cl); /** Get a string describing usage */ -GPRAPI char *gpr_cmdline_usage_string(gpr_cmdline *cl, const char *argv0); +GPRAPI char* gpr_cmdline_usage_string(gpr_cmdline* cl, const char* argv0); #ifdef __cplusplus } diff --git a/include/grpc/support/histogram.h b/include/grpc/support/histogram.h index 8489daa27e..d2794d847e 100644 --- a/include/grpc/support/histogram.h +++ b/include/grpc/support/histogram.h @@ -28,31 +28,31 @@ extern "C" { typedef struct gpr_histogram gpr_histogram; -GPRAPI gpr_histogram *gpr_histogram_create(double resolution, +GPRAPI gpr_histogram* gpr_histogram_create(double resolution, double max_bucket_start); -GPRAPI void gpr_histogram_destroy(gpr_histogram *h); -GPRAPI void gpr_histogram_add(gpr_histogram *h, double x); +GPRAPI void gpr_histogram_destroy(gpr_histogram* h); +GPRAPI void gpr_histogram_add(gpr_histogram* h, double x); /** The following merges the second histogram into the first. It only works if they have the same buckets and resolution. Returns 0 on failure, 1 on success */ -GPRAPI int gpr_histogram_merge(gpr_histogram *dst, const gpr_histogram *src); +GPRAPI int gpr_histogram_merge(gpr_histogram* dst, const gpr_histogram* src); -GPRAPI double gpr_histogram_percentile(gpr_histogram *histogram, +GPRAPI double gpr_histogram_percentile(gpr_histogram* histogram, double percentile); -GPRAPI double gpr_histogram_mean(gpr_histogram *histogram); -GPRAPI double gpr_histogram_stddev(gpr_histogram *histogram); -GPRAPI double gpr_histogram_variance(gpr_histogram *histogram); -GPRAPI double gpr_histogram_maximum(gpr_histogram *histogram); -GPRAPI double gpr_histogram_minimum(gpr_histogram *histogram); -GPRAPI double gpr_histogram_count(gpr_histogram *histogram); -GPRAPI double gpr_histogram_sum(gpr_histogram *histogram); -GPRAPI double gpr_histogram_sum_of_squares(gpr_histogram *histogram); +GPRAPI double gpr_histogram_mean(gpr_histogram* histogram); +GPRAPI double gpr_histogram_stddev(gpr_histogram* histogram); +GPRAPI double gpr_histogram_variance(gpr_histogram* histogram); +GPRAPI double gpr_histogram_maximum(gpr_histogram* histogram); +GPRAPI double gpr_histogram_minimum(gpr_histogram* histogram); +GPRAPI double gpr_histogram_count(gpr_histogram* histogram); +GPRAPI double gpr_histogram_sum(gpr_histogram* histogram); +GPRAPI double gpr_histogram_sum_of_squares(gpr_histogram* histogram); -GPRAPI const uint32_t *gpr_histogram_get_contents(gpr_histogram *histogram, - size_t *count); -GPRAPI void gpr_histogram_merge_contents(gpr_histogram *histogram, - const uint32_t *data, +GPRAPI const uint32_t* gpr_histogram_get_contents(gpr_histogram* histogram, + size_t* count); +GPRAPI void gpr_histogram_merge_contents(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); diff --git a/include/grpc/support/host_port.h b/include/grpc/support/host_port.h index 41592dfe26..9805811bfb 100644 --- a/include/grpc/support/host_port.h +++ b/include/grpc/support/host_port.h @@ -35,14 +35,14 @@ extern "C" { destroyed using gpr_free(). In the unlikely event of an error, returns -1 and sets *out to NULL. */ -GPRAPI int gpr_join_host_port(char **out, const char *host, int port); +GPRAPI int gpr_join_host_port(char** out, const char* host, int port); /** Given a name in the form "host:port" or "[ho:st]:port", split into hostname and port number, into newly allocated strings, which must later be destroyed using gpr_free(). Return 1 on success, 0 on failure. Guarantees *host and *port == NULL on failure. */ -GPRAPI int gpr_split_host_port(const char *name, char **host, char **port); +GPRAPI int gpr_split_host_port(const char* name, char** host, char** port); #ifdef __cplusplus } diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h index a22fb6a6e2..497cca9081 100644 --- a/include/grpc/support/log.h +++ b/include/grpc/support/log.h @@ -50,7 +50,7 @@ typedef enum gpr_log_severity { #define GPR_LOG_VERBOSITY_UNSET -1 /** Returns a string representation of the log severity */ -GPRAPI const char *gpr_log_severity_string(gpr_log_severity severity); +GPRAPI const char* gpr_log_severity_string(gpr_log_severity severity); /** Macros to build log contexts at various severity levels */ #define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG @@ -59,11 +59,11 @@ GPRAPI const char *gpr_log_severity_string(gpr_log_severity severity); /** Log a message. It's advised to use GPR_xxx above to generate the context * for each message */ -GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, - const char *format, ...) GPR_PRINT_FORMAT_CHECK(4, 5); +GPRAPI void gpr_log(const char* file, int line, gpr_log_severity severity, + const char* format, ...) GPR_PRINT_FORMAT_CHECK(4, 5); -GPRAPI void gpr_log_message(const char *file, int line, - gpr_log_severity severity, const char *message); +GPRAPI void gpr_log_message(const char* file, int line, + gpr_log_severity severity, const char* message); /** Set global log verbosity */ GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print); @@ -74,13 +74,13 @@ GPRAPI void gpr_log_verbosity_init(); and use their own implementations */ typedef struct { - const char *file; + const char* file; int line; gpr_log_severity severity; - const char *message; + const char* message; } gpr_log_func_args; -typedef void (*gpr_log_func)(gpr_log_func_args *args); +typedef void (*gpr_log_func)(gpr_log_func_args* args); GPRAPI void gpr_set_log_function(gpr_log_func func); /** abort() the process if x is zero, having written a line to the log. diff --git a/include/grpc/support/log_windows.h b/include/grpc/support/log_windows.h index b530fd50d6..e833f9d9df 100644 --- a/include/grpc/support/log_windows.h +++ b/include/grpc/support/log_windows.h @@ -29,7 +29,7 @@ extern "C" { * formatted error message, corresponding to the error messageid. * Use in conjunction with GetLastError() et al. */ -GPRAPI char *gpr_format_message(int messageid); +GPRAPI char* gpr_format_message(int messageid); #ifdef __cplusplus } diff --git a/include/grpc/support/string_util.h b/include/grpc/support/string_util.h index c4fc159d05..2c7460fa15 100644 --- a/include/grpc/support/string_util.h +++ b/include/grpc/support/string_util.h @@ -29,7 +29,7 @@ extern "C" { /** Returns a copy of src that can be passed to gpr_free(). If allocation fails or if src is NULL, returns NULL. */ -GPRAPI char *gpr_strdup(const char *src); +GPRAPI char* gpr_strdup(const char* src); /** printf to a newly-allocated string. The set of supported formats may vary between platforms. @@ -39,7 +39,7 @@ GPRAPI char *gpr_strdup(const char *src); On error, returns -1 and sets *strp to NULL. If the format string is bad, the result is undefined. */ -GPRAPI int gpr_asprintf(char **strp, const char *format, ...) +GPRAPI int gpr_asprintf(char** strp, const char* format, ...) GPR_PRINT_FORMAT_CHECK(2, 3); #ifdef __cplusplus diff --git a/include/grpc/support/subprocess.h b/include/grpc/support/subprocess.h index c06e629637..175f7b50eb 100644 --- a/include/grpc/support/subprocess.h +++ b/include/grpc/support/subprocess.h @@ -28,14 +28,14 @@ extern "C" { typedef struct gpr_subprocess gpr_subprocess; /** .exe on windows, empty on unices */ -GPRAPI const char *gpr_subprocess_binary_extension(); +GPRAPI const char* gpr_subprocess_binary_extension(); -GPRAPI gpr_subprocess *gpr_subprocess_create(int argc, const char **argv); +GPRAPI gpr_subprocess* gpr_subprocess_create(int argc, const char** argv); /** if subprocess has not been joined, kill it */ -GPRAPI void gpr_subprocess_destroy(gpr_subprocess *p); +GPRAPI void gpr_subprocess_destroy(gpr_subprocess* p); /** returns exit status; can be called at most once */ -GPRAPI int gpr_subprocess_join(gpr_subprocess *p); -GPRAPI void gpr_subprocess_interrupt(gpr_subprocess *p); +GPRAPI int gpr_subprocess_join(gpr_subprocess* p); +GPRAPI void gpr_subprocess_interrupt(gpr_subprocess* p); #ifdef __cplusplus } // extern "C" diff --git a/include/grpc/support/sync.h b/include/grpc/support/sync.h index ddb85808c7..75192673a6 100644 --- a/include/grpc/support/sync.h +++ b/include/grpc/support/sync.h @@ -34,26 +34,26 @@ extern "C" { gpr_mu are uninitialized when first declared. */ /** Initialize *mu. Requires: *mu uninitialized. */ -GPRAPI void gpr_mu_init(gpr_mu *mu); +GPRAPI void gpr_mu_init(gpr_mu* mu); /** Cause *mu no longer to be initialized, freeing any memory in use. Requires: - *mu initialized; no other concurrent operation on *mu. */ -GPRAPI void gpr_mu_destroy(gpr_mu *mu); + *mu initialized; no other concurrent operation on *mu. */ +GPRAPI void gpr_mu_destroy(gpr_mu* mu); /** Wait until no thread has a lock on *mu, cause the calling thread to own an exclusive lock on *mu, then return. May block indefinitely or crash if the calling thread has a lock on *mu. Requires: *mu initialized. */ -GPRAPI void gpr_mu_lock(gpr_mu *mu); +GPRAPI void gpr_mu_lock(gpr_mu* mu); /** Release an exclusive lock on *mu held by the calling thread. Requires: *mu initialized; the calling thread holds an exclusive lock on *mu. */ -GPRAPI void gpr_mu_unlock(gpr_mu *mu); +GPRAPI void gpr_mu_unlock(gpr_mu* mu); /** Without blocking, attempt to acquire an exclusive lock on *mu for the calling thread, then return non-zero iff success. Fail, if any thread holds the lock; succeeds with high probability if no thread holds the lock. Requires: *mu initialized. */ -GPRAPI int gpr_mu_trylock(gpr_mu *mu); +GPRAPI int gpr_mu_trylock(gpr_mu* mu); /** --- Condition variable interface --- @@ -62,11 +62,11 @@ GPRAPI int gpr_mu_trylock(gpr_mu *mu); uninitialized when first declared. */ /** Initialize *cv. Requires: *cv uninitialized. */ -GPRAPI void gpr_cv_init(gpr_cv *cv); +GPRAPI void gpr_cv_init(gpr_cv* cv); /** Cause *cv no longer to be initialized, freeing any memory in use. Requires: - *cv initialized; no other concurrent operation on *cv.*/ -GPRAPI void gpr_cv_destroy(gpr_cv *cv); + *cv initialized; no other concurrent operation on *cv.*/ +GPRAPI void gpr_cv_destroy(gpr_cv* cv); /** Atomically release *mu and wait on *cv. When the calling thread is woken from *cv or the deadline abs_deadline is exceeded, execute gpr_mu_lock(mu) @@ -75,16 +75,16 @@ GPRAPI void gpr_cv_destroy(gpr_cv *cv); an absolute deadline, or a GPR_TIMESPAN. May return even when not woken explicitly. Requires: *mu and *cv initialized; the calling thread holds an exclusive lock on *mu. */ -GPRAPI int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline); +GPRAPI int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline); /** If any threads are waiting on *cv, wake at least one. Clients may treat this as an optimization of gpr_cv_broadcast() for use in the case where waking more than one waiter is not useful. Requires: *cv initialized. */ -GPRAPI void gpr_cv_signal(gpr_cv *cv); +GPRAPI void gpr_cv_signal(gpr_cv* cv); /** Wake all threads waiting on *cv. Requires: *cv initialized. */ -GPRAPI void gpr_cv_broadcast(gpr_cv *cv); +GPRAPI void gpr_cv_broadcast(gpr_cv* cv); /** --- One-time initialization --- @@ -97,7 +97,7 @@ GPRAPI void gpr_cv_broadcast(gpr_cv *cv); If multiple threads call gpr_once() on the same gpr_once instance, one of them will call (*init_routine)(), and the others will block until that call finishes.*/ -GPRAPI void gpr_once_init(gpr_once *once, void (*init_routine)(void)); +GPRAPI void gpr_once_init(gpr_once* once, void (*init_routine)(void)); /** --- One-time event notification --- @@ -107,51 +107,51 @@ GPRAPI void gpr_once_init(gpr_once *once, void (*init_routine)(void)); It requires no destruction. */ /** Initialize *ev. */ -GPRAPI void gpr_event_init(gpr_event *ev); +GPRAPI void gpr_event_init(gpr_event* ev); /** Set *ev so that gpr_event_get() and gpr_event_wait() will return value. Requires: *ev initialized; value != NULL; no prior or concurrent calls to gpr_event_set(ev, ...) since initialization. */ -GPRAPI void gpr_event_set(gpr_event *ev, void *value); +GPRAPI void gpr_event_set(gpr_event* ev, void* value); /** Return the value set by gpr_event_set(ev, ...), or NULL if no such call has completed. If the result is non-NULL, all operations that occurred prior to the gpr_event_set(ev, ...) set will be visible after this call returns. Requires: *ev initialized. This operation is faster than acquiring a mutex on most platforms. */ -GPRAPI void *gpr_event_get(gpr_event *ev); +GPRAPI void* gpr_event_get(gpr_event* ev); /** Wait until *ev is set by gpr_event_set(ev, ...), or abs_deadline is exceeded, then return gpr_event_get(ev). Requires: *ev initialized. Use abs_deadline==gpr_inf_future for no deadline. When the event has been signalled before the call, this operation is faster than acquiring a mutex on most platforms. */ -GPRAPI void *gpr_event_wait(gpr_event *ev, gpr_timespec abs_deadline); +GPRAPI void* gpr_event_wait(gpr_event* ev, gpr_timespec abs_deadline); /** --- Reference counting --- These calls act on the type gpr_refcount. It requires no destruction. */ /** Initialize *r to value n. */ -GPRAPI void gpr_ref_init(gpr_refcount *r, int n); +GPRAPI void gpr_ref_init(gpr_refcount* r, int n); /** Increment the reference count *r. Requires *r initialized. */ -GPRAPI void gpr_ref(gpr_refcount *r); +GPRAPI void gpr_ref(gpr_refcount* r); /** Increment the reference count *r. Requires *r initialized. Crashes if refcount is zero */ -GPRAPI void gpr_ref_non_zero(gpr_refcount *r); +GPRAPI void gpr_ref_non_zero(gpr_refcount* r); /** Increment the reference count *r by n. Requires *r initialized, n > 0. */ -GPRAPI void gpr_refn(gpr_refcount *r, int n); +GPRAPI void gpr_refn(gpr_refcount* r, int n); /** Decrement the reference count *r and return non-zero iff it has reached zero. . Requires *r initialized. */ -GPRAPI int gpr_unref(gpr_refcount *r); +GPRAPI int gpr_unref(gpr_refcount* r); /** Return non-zero iff the reference count of *r is one, and thus is owned by exactly one object. */ -GPRAPI int gpr_ref_is_unique(gpr_refcount *r); +GPRAPI int gpr_ref_is_unique(gpr_refcount* r); /** --- Stats counters --- @@ -162,13 +162,13 @@ GPRAPI int gpr_ref_is_unique(gpr_refcount *r); synchronize other events. */ /** Initialize *c to the value n. */ -GPRAPI void gpr_stats_init(gpr_stats_counter *c, intptr_t n); +GPRAPI void gpr_stats_init(gpr_stats_counter* c, intptr_t n); /** *c += inc. Requires: *c initialized. */ -GPRAPI void gpr_stats_inc(gpr_stats_counter *c, intptr_t inc); +GPRAPI void gpr_stats_inc(gpr_stats_counter* c, intptr_t inc); /** Return *c. Requires: *c initialized. */ -GPRAPI intptr_t gpr_stats_read(const gpr_stats_counter *c); +GPRAPI intptr_t gpr_stats_read(const gpr_stats_counter* c); /** ==================Example use of interface=================== A producer-consumer queue of up to N integers, @@ -280,14 +280,14 @@ namespace grpc_core { class mu_guard { public: - mu_guard(gpr_mu *mu) : mu_(mu) { gpr_mu_lock(mu); } + mu_guard(gpr_mu* mu) : mu_(mu) { gpr_mu_lock(mu); } ~mu_guard() { gpr_mu_unlock(mu_); } - mu_guard(const mu_guard &) = delete; - mu_guard &operator=(const mu_guard &) = delete; + mu_guard(const mu_guard&) = delete; + mu_guard& operator=(const mu_guard&) = delete; private: - gpr_mu *const mu_; + gpr_mu* const mu_; }; } // namespace grpc_core diff --git a/include/grpc/support/thd.h b/include/grpc/support/thd.h index 25bd8f1238..225d9d6c75 100644 --- a/include/grpc/support/thd.h +++ b/include/grpc/support/thd.h @@ -44,23 +44,23 @@ typedef struct { in *t, and return true. If there are insufficient resources, return false. If options==NULL, default options are used. The thread is immediately runnable, and exits when (*thd_body)() returns. */ -GPRAPI int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg, - const gpr_thd_options *options); +GPRAPI int gpr_thd_new(gpr_thd_id* t, void (*thd_body)(void* arg), void* arg, + const gpr_thd_options* options); /** Return a gpr_thd_options struct with all fields set to defaults. */ GPRAPI gpr_thd_options gpr_thd_options_default(void); /** Set the thread to become detached on startup - this is the default. */ -GPRAPI void gpr_thd_options_set_detached(gpr_thd_options *options); +GPRAPI void gpr_thd_options_set_detached(gpr_thd_options* options); /** Set the thread to become joinable - mutually exclusive with detached. */ -GPRAPI void gpr_thd_options_set_joinable(gpr_thd_options *options); +GPRAPI void gpr_thd_options_set_joinable(gpr_thd_options* options); /** Returns non-zero if the option detached is set. */ -GPRAPI int gpr_thd_options_is_detached(const gpr_thd_options *options); +GPRAPI int gpr_thd_options_is_detached(const gpr_thd_options* options); /** Returns non-zero if the option joinable is set. */ -GPRAPI int gpr_thd_options_is_joinable(const gpr_thd_options *options); +GPRAPI int gpr_thd_options_is_joinable(const gpr_thd_options* options); /** Returns the identifier of the current thread. */ GPRAPI gpr_thd_id gpr_thd_currentid(void); diff --git a/include/grpc/support/tls_gcc.h b/include/grpc/support/tls_gcc.h index e6d8c01447..019acdf122 100644 --- a/include/grpc/support/tls_gcc.h +++ b/include/grpc/support/tls_gcc.h @@ -30,7 +30,7 @@ struct gpr_gcc_thread_local { intptr_t value; - bool *inited; + bool* inited; }; #define GPR_TLS_DECL(name) \ diff --git a/include/grpc/support/tls_pthread.h b/include/grpc/support/tls_pthread.h index a68b45569a..fb0edd8e74 100644 --- a/include/grpc/support/tls_pthread.h +++ b/include/grpc/support/tls_pthread.h @@ -37,7 +37,7 @@ struct gpr_pthread_thread_local { #ifdef __cplusplus extern "C" { #endif -intptr_t gpr_tls_set(struct gpr_pthread_thread_local *tls, intptr_t value); +intptr_t gpr_tls_set(struct gpr_pthread_thread_local* tls, intptr_t value); #ifdef __cplusplus } #endif |