diff options
author | Craig Tiller <ctiller@google.com> | 2015-01-13 16:11:30 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-01-13 16:11:30 -0800 |
commit | 375605b65f9d58b7544b4af8bc93d4cf8489f010 (patch) | |
tree | bc0e1a8861a3dfdb6e8b0bb43a219d31efb88064 /include | |
parent | 80fa15c15121a7d0ec020dec8bfa3697a96058b6 (diff) | |
parent | 49a06a6cb843b8ce592312c28b43c9dc527b99ee (diff) |
Merge github.com:google/grpc into api
Diffstat (limited to 'include')
38 files changed, 429 insertions, 44 deletions
diff --git a/include/grpc++/async_server_context.h b/include/grpc++/async_server_context.h index 237a6856a4..c038286ac1 100644 --- a/include/grpc++/async_server_context.h +++ b/include/grpc++/async_server_context.h @@ -87,7 +87,7 @@ class AsyncServerContext { system_clock::time_point absolute_deadline_; google::protobuf::Message* request_; // not owned - grpc_call* call_; // owned + grpc_call* call_; // owned }; } // namespace grpc diff --git a/include/grpc++/channel_interface.h b/include/grpc++/channel_interface.h index 4b9d76e0d1..9ed35422b8 100644 --- a/include/grpc++/channel_interface.h +++ b/include/grpc++/channel_interface.h @@ -57,10 +57,10 @@ class ChannelInterface { const google::protobuf::Message& request, google::protobuf::Message* result) = 0; - virtual StreamContextInterface* CreateStream(const RpcMethod& method, - ClientContext* context, - const google::protobuf::Message* request, - google::protobuf::Message* result) = 0; + virtual StreamContextInterface* CreateStream( + const RpcMethod& method, ClientContext* context, + const google::protobuf::Message* request, + google::protobuf::Message* result) = 0; }; } // namespace grpc diff --git a/include/grpc++/config.h b/include/grpc++/config.h index 153b288f0c..52913fbf0f 100644 --- a/include/grpc++/config.h +++ b/include/grpc++/config.h @@ -39,7 +39,6 @@ namespace grpc { typedef std::string string; - } #endif // __GRPCPP_CONFIG_H__ diff --git a/include/grpc++/create_channel.h b/include/grpc++/create_channel.h index 3253c9f180..a8ce8b8ec8 100644 --- a/include/grpc++/create_channel.h +++ b/include/grpc++/create_channel.h @@ -46,6 +46,7 @@ class ChannelInterface; std::shared_ptr<ChannelInterface> CreateChannel(const grpc::string& target, const ChannelArguments& args); +// If creds does not hold an object or is invalid, a lame channel is returned. std::shared_ptr<ChannelInterface> CreateChannel( const grpc::string& target, const std::unique_ptr<Credentials>& creds, const ChannelArguments& args); diff --git a/include/grpc++/credentials.h b/include/grpc++/credentials.h index 3ad12edaae..987d890b4f 100644 --- a/include/grpc++/credentials.h +++ b/include/grpc++/credentials.h @@ -34,6 +34,7 @@ #ifndef __GRPCPP_CREDENTIALS_H_ #define __GRPCPP_CREDENTIALS_H_ +#include <chrono> #include <memory> #include <grpc++/config.h> @@ -49,6 +50,7 @@ namespace grpc { class Credentials final { public: ~Credentials(); + // TODO(abhikumar): Specify a plugin API here to be implemented by // credentials that do not have a corresponding implementation in C. @@ -63,6 +65,15 @@ class Credentials final { }; // Options used to build SslCredentials +// pem_roots_cert is the buffer containing the PEM encoding of the server root +// certificates. This parameter cannot be empty. +// pem_private_key is the buffer containing the PEM encoding of the client's +// private key. This parameter can be empty if the client does not have a +// private key. +// pem_cert_chain is the buffer containing the PEM encoding of the client's +// certificate chain. This parameter can be empty if the client does not have +// a certificate chain. +// TODO(jboeuf) Change it to point to a file. struct SslCredentialsOptions { grpc::string pem_root_certs; grpc::string pem_private_key; @@ -70,6 +81,10 @@ struct SslCredentialsOptions { }; // Factory for building different types of Credentials +// The methods may return empty unique_ptr when credentials cannot be created. +// If a Credentials pointer is returned, it can still be invalid when used to +// create a channel. A lame channel will be created then and all rpcs will +// fail on it. class CredentialsFactory { public: // Builds credentials with reasonable defaults. @@ -82,6 +97,20 @@ class CredentialsFactory { // Builds credentials for use when running in GCE static std::unique_ptr<Credentials> ComputeEngineCredentials(); + // Builds service account credentials. + // json_key is the JSON key string containing the client's private key. + // scope is a space-delimited list of the requested permissions. + // token_lifetime is the lifetime of each token acquired through this service + // account credentials. It should be positive and should not exceed + // grpc_max_auth_token_lifetime or will be cropped to this value. + static std::unique_ptr<Credentials> ServiceAccountCredentials( + const grpc::string& json_key, const grpc::string& scope, + std::chrono::seconds token_lifetime); + + // Builds IAM credentials. + static std::unique_ptr<Credentials> IAMCredentials( + const grpc::string& authorization_token, + const grpc::string& authority_selector); // Combines two credentials objects into a composite credentials static std::unique_ptr<Credentials> ComposeCredentials( diff --git a/include/grpc++/impl/internal_stub.h b/include/grpc++/impl/internal_stub.h new file mode 100644 index 0000000000..b32fb3a27c --- /dev/null +++ b/include/grpc++/impl/internal_stub.h @@ -0,0 +1,60 @@ +/* + * + * Copyright 2014, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __GRPCPP_IMPL_INTERNAL_STUB_H__ +#define __GRPCPP_IMPL_INTERNAL_STUB_H__ + +#include <memory> + +#include <grpc++/channel_interface.h> + +namespace grpc { + +class InternalStub { + public: + InternalStub() {} + virtual ~InternalStub() {} + + void set_channel(const std::shared_ptr<ChannelInterface>& channel) { + channel_ = channel; + } + + ChannelInterface* channel() { return channel_.get(); } + + private: + std::shared_ptr<ChannelInterface> channel_; +}; + +} // namespace grpc + +#endif // __GRPCPP_IMPL_INTERNAL_STUB_H__ diff --git a/include/grpc++/impl/rpc_method.h b/include/grpc++/impl/rpc_method.h new file mode 100644 index 0000000000..75fec356dd --- /dev/null +++ b/include/grpc++/impl/rpc_method.h @@ -0,0 +1,69 @@ +/* + * + * Copyright 2014, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __GRPCPP_IMPL_RPC_METHOD_H__ +#define __GRPCPP_IMPL_RPC_METHOD_H__ + +namespace google { +namespace protobuf { +class Message; +} +} + +namespace grpc { + +class RpcMethod { + public: + enum RpcType { + NORMAL_RPC = 0, + CLIENT_STREAMING, // request streaming + SERVER_STREAMING, // response streaming + BIDI_STREAMING + }; + + explicit RpcMethod(const char* name) + : name_(name), method_type_(NORMAL_RPC) {} + RpcMethod(const char* name, RpcType type) : name_(name), method_type_(type) {} + + const char* name() const { return name_; } + + RpcType method_type() const { return method_type_; } + + private: + const char* name_; + const RpcType method_type_; +}; + +} // namespace grpc + +#endif // __GRPCPP_IMPL_RPC_METHOD_H__ diff --git a/include/grpc++/impl/rpc_service_method.h b/include/grpc++/impl/rpc_service_method.h new file mode 100644 index 0000000000..620de5e67f --- /dev/null +++ b/include/grpc++/impl/rpc_service_method.h @@ -0,0 +1,218 @@ +/* + * + * Copyright 2014, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef __GRPCPP_IMPL_RPC_SERVICE_METHOD_H__ +#define __GRPCPP_IMPL_RPC_SERVICE_METHOD_H__ + +#include <functional> +#include <map> +#include <memory> +#include <vector> + +#include <grpc++/impl/rpc_method.h> +#include <grpc++/status.h> +#include <grpc++/stream.h> +#include <google/protobuf/message.h> + +namespace grpc { +class ServerContext; +class StreamContextInterface; + +// TODO(rocking): we might need to split this file into multiple ones. + +// Base class for running an RPC handler. +class MethodHandler { + public: + virtual ~MethodHandler() {} + struct HandlerParameter { + HandlerParameter(ServerContext* context, + const google::protobuf::Message* req, + google::protobuf::Message* resp) + : server_context(context), + request(req), + response(resp), + stream_context(nullptr) {} + HandlerParameter(ServerContext* context, + const google::protobuf::Message* req, + google::protobuf::Message* resp, + StreamContextInterface* stream) + : server_context(context), + request(req), + response(resp), + stream_context(stream) {} + ServerContext* server_context; + const google::protobuf::Message* request; + google::protobuf::Message* response; + StreamContextInterface* stream_context; + }; + virtual Status RunHandler(const HandlerParameter& param) = 0; +}; + +// A wrapper class of an application provided rpc method handler. +template <class ServiceType, class RequestType, class ResponseType> +class RpcMethodHandler : public MethodHandler { + public: + RpcMethodHandler( + std::function<Status(ServiceType*, ServerContext*, const RequestType*, + ResponseType*)> func, + ServiceType* service) + : func_(func), service_(service) {} + + Status RunHandler(const HandlerParameter& param) final { + // Invoke application function, cast proto messages to their actual types. + return func_(service_, param.server_context, + dynamic_cast<const RequestType*>(param.request), + dynamic_cast<ResponseType*>(param.response)); + } + + private: + // Application provided rpc handler function. + std::function<Status(ServiceType*, ServerContext*, const RequestType*, + ResponseType*)> func_; + // The class the above handler function lives in. + ServiceType* service_; +}; + +// A wrapper class of an application provided client streaming handler. +template <class ServiceType, class RequestType, class ResponseType> +class ClientStreamingHandler : public MethodHandler { + public: + ClientStreamingHandler( + std::function<Status(ServiceType*, ServerContext*, + ServerReader<RequestType>*, ResponseType*)> func, + ServiceType* service) + : func_(func), service_(service) {} + + Status RunHandler(const HandlerParameter& param) final { + ServerReader<RequestType> reader(param.stream_context); + return func_(service_, param.server_context, &reader, + dynamic_cast<ResponseType*>(param.response)); + } + + private: + std::function<Status(ServiceType*, ServerContext*, ServerReader<RequestType>*, + ResponseType*)> func_; + ServiceType* service_; +}; + +// A wrapper class of an application provided server streaming handler. +template <class ServiceType, class RequestType, class ResponseType> +class ServerStreamingHandler : public MethodHandler { + public: + ServerStreamingHandler( + std::function<Status(ServiceType*, ServerContext*, const RequestType*, + ServerWriter<ResponseType>*)> func, + ServiceType* service) + : func_(func), service_(service) {} + + Status RunHandler(const HandlerParameter& param) final { + ServerWriter<ResponseType> writer(param.stream_context); + return func_(service_, param.server_context, + dynamic_cast<const RequestType*>(param.request), &writer); + } + + private: + std::function<Status(ServiceType*, ServerContext*, const RequestType*, + ServerWriter<ResponseType>*)> func_; + ServiceType* service_; +}; + +// A wrapper class of an application provided bidi-streaming handler. +template <class ServiceType, class RequestType, class ResponseType> +class BidiStreamingHandler : public MethodHandler { + public: + BidiStreamingHandler( + std::function<Status(ServiceType*, ServerContext*, + ServerReaderWriter<ResponseType, RequestType>*)> + func, + ServiceType* service) + : func_(func), service_(service) {} + + Status RunHandler(const HandlerParameter& param) final { + ServerReaderWriter<ResponseType, RequestType> stream(param.stream_context); + return func_(service_, param.server_context, &stream); + } + + private: + std::function<Status(ServiceType*, ServerContext*, + ServerReaderWriter<ResponseType, RequestType>*)> func_; + ServiceType* service_; +}; + +// Server side rpc method class +class RpcServiceMethod : public RpcMethod { + public: + // Takes ownership of the handler and two prototype objects. + RpcServiceMethod(const char* name, RpcMethod::RpcType type, + MethodHandler* handler, + google::protobuf::Message* request_prototype, + google::protobuf::Message* response_prototype) + : RpcMethod(name, type), + handler_(handler), + request_prototype_(request_prototype), + response_prototype_(response_prototype) {} + + MethodHandler* handler() { return handler_.get(); } + + google::protobuf::Message* AllocateRequestProto() { + return request_prototype_->New(); + } + google::protobuf::Message* AllocateResponseProto() { + return response_prototype_->New(); + } + + private: + std::unique_ptr<MethodHandler> handler_; + std::unique_ptr<google::protobuf::Message> request_prototype_; + std::unique_ptr<google::protobuf::Message> response_prototype_; +}; + +// This class contains all the method information for an rpc service. It is +// used for registering a service on a grpc server. +class RpcService { + public: + // Takes ownership. + void AddMethod(RpcServiceMethod* method) { + methods_.push_back(std::unique_ptr<RpcServiceMethod>(method)); + } + + RpcServiceMethod* GetMethod(int i) { return methods_[i].get(); } + int GetMethodCount() const { return methods_.size(); } + + private: + std::vector<std::unique_ptr<RpcServiceMethod>> methods_; +}; + +} // namespace grpc + +#endif // __GRPCPP_IMPL_RPC_SERVICE_METHOD_H__ diff --git a/include/grpc++/status_code_enum.h b/include/grpc++/status_code_enum.h index 964420dcc4..4e0fda13db 100644 --- a/include/grpc++/status_code_enum.h +++ b/include/grpc++/status_code_enum.h @@ -34,7 +34,6 @@ #ifndef __GRPCPP_STATUS_CODE_ENUM_H__ #define __GRPCPP_STATUS_CODE_ENUM_H__ - namespace grpc { enum StatusCode { diff --git a/include/grpc/byte_buffer.h b/include/grpc/byte_buffer.h index 27ca63e6fa..094d3016e1 100644 --- a/include/grpc/byte_buffer.h +++ b/include/grpc/byte_buffer.h @@ -47,4 +47,4 @@ struct grpc_byte_buffer { } data; }; -#endif /* __GRPC_BYTE_BUFFER_H__ */ +#endif /* __GRPC_BYTE_BUFFER_H__ */ diff --git a/include/grpc/byte_buffer_reader.h b/include/grpc/byte_buffer_reader.h index 5f1c160e15..6386db6592 100644 --- a/include/grpc/byte_buffer_reader.h +++ b/include/grpc/byte_buffer_reader.h @@ -46,4 +46,4 @@ struct grpc_byte_buffer_reader { } current; }; -#endif /* __GRPC_BYTE_BUFFER_READER_H__ */ +#endif /* __GRPC_BYTE_BUFFER_READER_H__ */ diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index f479fb8a40..cc7ed4a9fb 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -433,7 +433,8 @@ grpc_call_error grpc_server_request_call(grpc_server *server, void *tag_new); grpc_server *grpc_server_create(grpc_completion_queue *cq, const grpc_channel_args *args); -/* Add a http2 over tcp listener; returns 1 on success, 0 on failure +/* Add a http2 over tcp listener. + Returns bound port number on success, 0 on failure. REQUIRES: server not started */ int grpc_server_add_http2_port(grpc_server *server, const char *addr); @@ -457,4 +458,4 @@ void grpc_server_destroy(grpc_server *server); } #endif -#endif /* __GRPC_GRPC_H__ */ +#endif /* __GRPC_GRPC_H__ */ diff --git a/include/grpc/grpc_security.h b/include/grpc/grpc_security.h index 26f373d5ca..644b31f763 100644 --- a/include/grpc/grpc_security.h +++ b/include/grpc/grpc_security.h @@ -97,7 +97,6 @@ grpc_credentials *grpc_fake_transport_security_credentials_create(void); grpc_credentials *grpc_iam_credentials_create(const char *authorization_token, const char *authority_selector); - /* --- Secure channel creation. --- */ /* The caller of the secure_channel_create functions may override the target @@ -152,7 +151,6 @@ grpc_server_credentials *grpc_ssl_server_credentials_create( grpc_server_credentials *grpc_fake_transport_security_server_credentials_create( void); - /* --- Secure server creation. --- */ /* Creates a secure server using the passed-in server credentials. */ diff --git a/include/grpc/status.h b/include/grpc/status.h index a4ce312bf2..630b7769fd 100644 --- a/include/grpc/status.h +++ b/include/grpc/status.h @@ -34,7 +34,6 @@ #ifndef __GRPC_STATUS_H__ #define __GRPC_STATUS_H__ - #ifdef __cplusplus extern "C" { #endif @@ -200,4 +199,4 @@ typedef enum { } #endif -#endif /* __GRPC_STATUS_H__ */ +#endif /* __GRPC_STATUS_H__ */ diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h index d613d85683..fa9cc4bf7c 100644 --- a/include/grpc/support/alloc.h +++ b/include/grpc/support/alloc.h @@ -55,4 +55,4 @@ void gpr_free_aligned(void *ptr); } #endif -#endif /* __GRPC_SUPPORT_ALLOC_H__ */ +#endif /* __GRPC_SUPPORT_ALLOC_H__ */ diff --git a/include/grpc/support/atm.h b/include/grpc/support/atm.h index d9fd383209..5e613f1ba9 100644 --- a/include/grpc/support/atm.h +++ b/include/grpc/support/atm.h @@ -89,4 +89,4 @@ #error could not determine platform for atm #endif -#endif /* __GRPC_SUPPORT_ATM_H__ */ +#endif /* __GRPC_SUPPORT_ATM_H__ */ diff --git a/include/grpc/support/atm_gcc_atomic.h b/include/grpc/support/atm_gcc_atomic.h index 4e0a7ab1c6..896dd842ec 100644 --- a/include/grpc/support/atm_gcc_atomic.h +++ b/include/grpc/support/atm_gcc_atomic.h @@ -66,4 +66,4 @@ static __inline int gpr_atm_rel_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { __ATOMIC_RELAXED); } -#endif /* __GRPC_SUPPORT_ATM_GCC_ATOMIC_H__ */ +#endif /* __GRPC_SUPPORT_ATM_GCC_ATOMIC_H__ */ diff --git a/include/grpc/support/atm_gcc_sync.h b/include/grpc/support/atm_gcc_sync.h index 976f2977bb..1a3a10c911 100644 --- a/include/grpc/support/atm_gcc_sync.h +++ b/include/grpc/support/atm_gcc_sync.h @@ -70,4 +70,4 @@ static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) { #define gpr_atm_acq_cas(p, o, n) (__sync_bool_compare_and_swap((p), (o), (n))) #define gpr_atm_rel_cas(p, o, n) gpr_atm_acq_cas((p), (o), (n)) -#endif /* __GRPC_SUPPORT_ATM_GCC_SYNC_H__ */ +#endif /* __GRPC_SUPPORT_ATM_GCC_SYNC_H__ */ diff --git a/include/grpc/support/atm_win32.h b/include/grpc/support/atm_win32.h index d32ffd46a2..19881e83ad 100644 --- a/include/grpc/support/atm_win32.h +++ b/include/grpc/support/atm_win32.h @@ -55,8 +55,8 @@ static __inline void gpr_atm_rel_store(gpr_atm *p, gpr_atm value) { } static __inline int gpr_atm_no_barrier_cas(gpr_atm *p, gpr_atm o, gpr_atm n) { - /* InterlockedCompareExchangePointerNoFence() not available on vista or - windows7 */ +/* InterlockedCompareExchangePointerNoFence() not available on vista or + windows7 */ #ifdef GPR_ARCH_64 return o == (gpr_atm)InterlockedCompareExchangeAcquire64(p, n, o); #else diff --git a/include/grpc/support/cancellable_platform.h b/include/grpc/support/cancellable_platform.h index d67302dd90..db099b8381 100644 --- a/include/grpc/support/cancellable_platform.h +++ b/include/grpc/support/cancellable_platform.h @@ -53,4 +53,4 @@ typedef struct { struct gpr_cancellable_list_ waiters; } gpr_cancellable; -#endif /* __GRPC_SUPPORT_CANCELLABLE_PLATFORM_H__ */ +#endif /* __GRPC_SUPPORT_CANCELLABLE_PLATFORM_H__ */ diff --git a/include/grpc/support/cmdline.h b/include/grpc/support/cmdline.h index 60e8035c75..ba3ffe42cc 100644 --- a/include/grpc/support/cmdline.h +++ b/include/grpc/support/cmdline.h @@ -92,4 +92,4 @@ void gpr_cmdline_destroy(gpr_cmdline *cl); } #endif -#endif /* __GRPC_SUPPORT_CMDLINE_H__ */ +#endif /* __GRPC_SUPPORT_CMDLINE_H__ */ diff --git a/include/grpc/support/histogram.h b/include/grpc/support/histogram.h index 13dce3bdcd..e67323d5d3 100644 --- a/include/grpc/support/histogram.h +++ b/include/grpc/support/histogram.h @@ -63,4 +63,4 @@ double gpr_histogram_sum_of_squares(gpr_histogram *histogram); } #endif -#endif /* __GRPC_SUPPORT_HISTOGRAM_H__ */ +#endif /* __GRPC_SUPPORT_HISTOGRAM_H__ */ diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h index 5d0b790867..1c2857dad3 100644 --- a/include/grpc/support/log.h +++ b/include/grpc/support/log.h @@ -72,9 +72,21 @@ const char *gpr_log_severity_string(gpr_log_severity severity); void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format, ...); -/* Same as above, but using a va_list instead. */ -void gpr_vlog(const char *file, int line, gpr_log_severity severity, - const char *format, va_list args); +void gpr_log_message(const char *file, int line, gpr_log_severity severity, + const char *message); + +/* Log overrides: applications can use this API to intercept logging calls + and use their own implementations */ + +typedef struct { + const char *file; + int line; + gpr_log_severity severity; + const char *message; +} gpr_log_func_args; + +typedef void (*gpr_log_func)(gpr_log_func_args *args); +void gpr_set_log_function(gpr_log_func func); /* abort() the process if x is zero, having written a line to the log. @@ -93,4 +105,4 @@ void gpr_vlog(const char *file, int line, gpr_log_severity severity, } #endif -#endif /* __GRPC_SUPPORT_LOG_H__ */ +#endif /* __GRPC_SUPPORT_LOG_H__ */ diff --git a/include/grpc/support/port_platform.h b/include/grpc/support/port_platform.h index 27a7b5529f..9c999b9c81 100644 --- a/include/grpc/support/port_platform.h +++ b/include/grpc/support/port_platform.h @@ -126,8 +126,8 @@ #error Must define exactly one of GPR_ARCH_32, GPR_ARCH_64 #endif -#if defined(GPR_CPU_LINUX) + defined(GPR_CPU_POSIX) != 1 -#error Must define exactly one of GPR_CPU_LINUX, GPR_CPU_POSIX +#if defined(GPR_CPU_LINUX) + defined(GPR_CPU_POSIX) + defined(GPR_WIN32) != 1 +#error Must define exactly one of GPR_CPU_LINUX, GPR_CPU_POSIX, GPR_WIN32 #endif typedef int16_t gpr_int16; diff --git a/include/grpc/support/slice.h b/include/grpc/support/slice.h index a89073c56a..597b5688fc 100644 --- a/include/grpc/support/slice.h +++ b/include/grpc/support/slice.h @@ -173,4 +173,4 @@ int gpr_slice_str_cmp(gpr_slice a, const char *b); } #endif -#endif /* __GRPC_SUPPORT_SLICE_H__ */ +#endif /* __GRPC_SUPPORT_SLICE_H__ */ diff --git a/include/grpc/support/slice_buffer.h b/include/grpc/support/slice_buffer.h index e4d204b827..0ad735a47a 100644 --- a/include/grpc/support/slice_buffer.h +++ b/include/grpc/support/slice_buffer.h @@ -81,4 +81,4 @@ void gpr_slice_buffer_reset_and_unref(gpr_slice_buffer *sb); } #endif -#endif /* __GRPC_SUPPORT_SLICE_BUFFER_H__ */ +#endif /* __GRPC_SUPPORT_SLICE_BUFFER_H__ */ diff --git a/include/grpc/support/string.h b/include/grpc/support/string.h index a7acfdab88..68e7452a7f 100644 --- a/include/grpc/support/string.h +++ b/include/grpc/support/string.h @@ -74,4 +74,4 @@ int gpr_asprintf(char **strp, const char *format, ...); } #endif -#endif /* __GRPC_SUPPORT_STRING_H__ */ +#endif /* __GRPC_SUPPORT_STRING_H__ */ diff --git a/include/grpc/support/sync.h b/include/grpc/support/sync.h index 3e435a6e4c..6f0f684ae7 100644 --- a/include/grpc/support/sync.h +++ b/include/grpc/support/sync.h @@ -345,4 +345,4 @@ gpr_intptr gpr_stats_read(const gpr_stats_counter *c); } #endif -#endif /* __GRPC_SUPPORT_SYNC_H__ */ +#endif /* __GRPC_SUPPORT_SYNC_H__ */ diff --git a/include/grpc/support/sync_generic.h b/include/grpc/support/sync_generic.h index 0c8a992439..1a595e7ffc 100644 --- a/include/grpc/support/sync_generic.h +++ b/include/grpc/support/sync_generic.h @@ -52,4 +52,4 @@ typedef struct { gpr_atm value; } gpr_stats_counter; #define GPR_STATS_INIT \ { 0 } -#endif /* __GRPC_SUPPORT_SYNC_GENERIC_H__ */ +#endif /* __GRPC_SUPPORT_SYNC_GENERIC_H__ */ diff --git a/include/grpc/support/sync_posix.h b/include/grpc/support/sync_posix.h index 6787695cfb..d51c268dc9 100644 --- a/include/grpc/support/sync_posix.h +++ b/include/grpc/support/sync_posix.h @@ -45,4 +45,4 @@ typedef pthread_once_t gpr_once; #define GPR_ONCE_INIT PTHREAD_ONCE_INIT -#endif /* __GRPC_SUPPORT_SYNC_POSIX_H__ */ +#endif /* __GRPC_SUPPORT_SYNC_POSIX_H__ */ diff --git a/include/grpc/support/sync_win32.h b/include/grpc/support/sync_win32.h index b3230dcc0d..6e25666350 100644 --- a/include/grpc/support/sync_win32.h +++ b/include/grpc/support/sync_win32.h @@ -49,4 +49,4 @@ typedef CONDITION_VARIABLE gpr_cv; typedef INIT_ONCE gpr_once; #define GPR_ONCE_INIT INIT_ONCE_STATIC_INIT -#endif /* __GRPC_SUPPORT_SYNC_WIN32_H__ */ +#endif /* __GRPC_SUPPORT_SYNC_WIN32_H__ */ diff --git a/include/grpc/support/thd.h b/include/grpc/support/thd.h index 18a1e80d06..91e0c9f16f 100644 --- a/include/grpc/support/thd.h +++ b/include/grpc/support/thd.h @@ -76,4 +76,4 @@ gpr_thd_options gpr_thd_options_default(void); } #endif -#endif /* __GRPC_SUPPORT_THD_H__ */ +#endif /* __GRPC_SUPPORT_THD_H__ */ diff --git a/include/grpc/support/thd_posix.h b/include/grpc/support/thd_posix.h index 3cfa512402..b688e45bc5 100644 --- a/include/grpc/support/thd_posix.h +++ b/include/grpc/support/thd_posix.h @@ -39,4 +39,4 @@ typedef pthread_t gpr_thd_id; -#endif /* __GRPC_SUPPORT_THD_POSIX_H__ */ +#endif /* __GRPC_SUPPORT_THD_POSIX_H__ */ diff --git a/include/grpc/support/thd_win32.h b/include/grpc/support/thd_win32.h index 6fa576e4a4..b4ab3c7271 100644 --- a/include/grpc/support/thd_win32.h +++ b/include/grpc/support/thd_win32.h @@ -41,4 +41,4 @@ typedef int gpr_thd_id; -#endif /* __GRPC_SUPPORT_THD_WIN32_H__ */ +#endif /* __GRPC_SUPPORT_THD_WIN32_H__ */ diff --git a/include/grpc/support/time.h b/include/grpc/support/time.h index d5ab9f5305..6327a2cffb 100644 --- a/include/grpc/support/time.h +++ b/include/grpc/support/time.h @@ -113,4 +113,4 @@ double gpr_timespec_to_micros(gpr_timespec t); } #endif -#endif /* __GRPC_SUPPORT_TIME_H__ */ +#endif /* __GRPC_SUPPORT_TIME_H__ */ diff --git a/include/grpc/support/time_posix.h b/include/grpc/support/time_posix.h index 72ebf5f3fd..9ff6f7f493 100644 --- a/include/grpc/support/time_posix.h +++ b/include/grpc/support/time_posix.h @@ -40,4 +40,4 @@ typedef struct timespec gpr_timespec; -#endif /* __GRPC_SUPPORT_TIME_POSIX_H__ */ +#endif /* __GRPC_SUPPORT_TIME_POSIX_H__ */ diff --git a/include/grpc/support/time_win32.h b/include/grpc/support/time_win32.h index 2450550bd6..e62ad64b8f 100644 --- a/include/grpc/support/time_win32.h +++ b/include/grpc/support/time_win32.h @@ -43,4 +43,4 @@ typedef struct gpr_timespec { long tv_nsec; } gpr_timespec; -#endif /* __GRPC_SUPPORT_TIME_WIN32_H__ */ +#endif /* __GRPC_SUPPORT_TIME_WIN32_H__ */ diff --git a/include/grpc/support/useful.h b/include/grpc/support/useful.h index c44d8e05a1..c451e9cc83 100644 --- a/include/grpc/support/useful.h +++ b/include/grpc/support/useful.h @@ -45,4 +45,4 @@ #define GPR_ARRAY_SIZE(array) (sizeof(array) / sizeof(*(array))) -#endif /* __GRPC_SUPPORT_USEFUL_H__ */ +#endif /* __GRPC_SUPPORT_USEFUL_H__ */ |