clang-format

pull/4965/head
Craig Tiller 9 years ago
parent 9b42637047
commit d6546c9640
  1. 51
      include/grpc/census.h
  2. 13
      include/grpc/compression.h
  3. 94
      include/grpc/grpc.h
  4. 52
      include/grpc/grpc_security.h
  5. 9
      include/grpc/impl/codegen/byte_buffer.h
  6. 6
      include/grpc/impl/codegen/log.h
  7. 4
      include/grpc/impl/codegen/slice.h
  8. 13
      include/grpc/impl/codegen/slice_buffer.h
  9. 10
      include/grpc/impl/codegen/time.h
  10. 12
      include/grpc/support/cmdline.h
  11. 15
      include/grpc/support/histogram.h
  12. 2
      include/grpc/support/thd.h

@ -90,8 +90,8 @@ typedef struct census_context census_context;
*
* TODO(aveitch): determine how best to communicate required/max buffer size
* so caller doesn't have to guess. */
CENSUS_API size_t census_context_serialize(const census_context *context, char *buffer,
size_t buf_size);
CENSUS_API size_t census_context_serialize(const census_context *context,
char *buffer, size_t buf_size);
/* Distributed traces can have a number of options. */
enum census_trace_mask_values {
@ -212,7 +212,8 @@ CENSUS_API census_context *census_start_client_rpc_op(
/**
Add peer information to a context representing a client RPC operation.
*/
CENSUS_API void census_set_rpc_client_peer(census_context *context, const char *peer);
CENSUS_API void census_set_rpc_client_peer(census_context *context,
const char *peer);
/**
Start a server RPC operation. Returns a new context to be used in future
@ -262,8 +263,9 @@ CENSUS_API census_context *census_start_server_rpc_op(
@return A new census context.
*/
CENSUS_API census_context *census_start_op(census_context *context, const char *family,
const char *name, int trace_mask);
CENSUS_API census_context *census_start_op(census_context *context,
const char *family, const char *name,
int trace_mask);
/**
End an operation started by any of the census_start_*_op*() calls. The
@ -287,7 +289,7 @@ CENSUS_API void census_end_op(census_context *context, int status);
@param n Number of bytes in buffer
*/
CENSUS_API void census_trace_print(census_context *context, uint32_t type,
const char *buffer, size_t n);
const char *buffer, size_t n);
/** Trace record. */
typedef struct {
@ -416,18 +418,19 @@ typedef struct {
/* Initialize a tag set iterator. Must be called before first use of the
iterator. */
CENSUS_API void census_tag_set_initialize_iterator(const census_tag_set *tags,
census_tag_set_iterator *iterator);
CENSUS_API void census_tag_set_initialize_iterator(
const census_tag_set *tags, census_tag_set_iterator *iterator);
/* Get the contents of the "next" tag in the tag set. If there are no more
tags in the tag set, returns 0 (and 'tag' contents will be unchanged),
otherwise returns 1. */
CENSUS_API int census_tag_set_next_tag(census_tag_set_iterator *iterator, census_tag *tag);
CENSUS_API int census_tag_set_next_tag(census_tag_set_iterator *iterator,
census_tag *tag);
/* Get a tag by its key. Returns 0 if the key is not present in the tag
set. */
CENSUS_API int census_tag_set_get_tag_by_key(const census_tag_set *tags, const char *key,
census_tag *tag);
CENSUS_API int census_tag_set_get_tag_by_key(const census_tag_set *tags,
const char *key, census_tag *tag);
/* Tag set encode/decode functionality. These functionas are intended
for use by RPC systems only, for purposes of transmitting/receiving tag
@ -450,13 +453,15 @@ CENSUS_API int census_tag_set_get_tag_by_key(const census_tag_set *tags, const c
[returned-ptr, returned-ptr + *bin_buf_size) (and the return value
should be buffer + *print_buf_size) */
CENSUS_API char *census_tag_set_encode(const census_tag_set *tags, char *buffer,
size_t buf_size, size_t *print_buf_size,
size_t *bin_buf_size);
size_t buf_size, size_t *print_buf_size,
size_t *bin_buf_size);
/* Decode tag set buffers encoded with census_tag_set_encode_*(). Returns NULL
if there is an error in parsing either buffer. */
CENSUS_API census_tag_set *census_tag_set_decode(const char *buffer, size_t size,
const char *bin_buffer, size_t bin_size);
CENSUS_API census_tag_set *census_tag_set_decode(const char *buffer,
size_t size,
const char *bin_buffer,
size_t bin_size);
/* Get a contexts tag set. */
CENSUS_API census_tag_set *census_context_tag_set(census_context *context);
@ -490,8 +495,8 @@ typedef struct {
} census_value;
/* Record new usage values against the given context. */
CENSUS_API void census_record_values(census_context *context, census_value *values,
size_t nvalues);
CENSUS_API void census_record_values(census_context *context,
census_value *values, size_t nvalues);
/** Type representing a particular aggregation */
typedef struct census_aggregation_ops census_aggregation_ops;
@ -521,9 +526,9 @@ typedef struct census_view census_view;
@return A new census view
*/
CENSUS_API census_view *census_view_create(uint32_t metric_id, const census_tag_set *tags,
const census_aggregation *aggregations,
size_t naggregations);
CENSUS_API census_view *census_view_create(
uint32_t metric_id, const census_tag_set *tags,
const census_aggregation *aggregations, size_t naggregations);
/** Destroy a previously created view. */
CENSUS_API void census_view_delete(census_view *view);
@ -538,7 +543,8 @@ CENSUS_API size_t census_view_naggregations(const census_view *view);
CENSUS_API const census_tag_set *census_view_tags(const census_view *view);
/** Get aggregation descriptors associated with a view. */
CENSUS_API const census_aggregation *census_view_aggregrations(const census_view *view);
CENSUS_API const census_aggregation *census_view_aggregrations(
const census_view *view);
/** Holds all the aggregation data for a particular view instantiation. Forms
part of the data returned by census_view_data(). */
@ -557,7 +563,8 @@ typedef struct {
@param view View from which to get data.
@return Full set of data for all aggregations for the view.
*/
CENSUS_API const census_view_data *census_view_get_data(const census_view *view);
CENSUS_API const census_view_data *census_view_get_data(
const census_view *view);
/** Reset all view data to zero for the specified view */
CENSUS_API void census_view_reset(census_view *view);

@ -46,19 +46,20 @@ extern "C" {
/** Parses the first \a name_length bytes of \a name as a
* grpc_compression_algorithm instance, updating \a algorithm. Returns 1 upon
* success, 0 otherwise. */
GRPC_API int grpc_compression_algorithm_parse(const char *name, size_t name_length,
grpc_compression_algorithm *algorithm);
GRPC_API int grpc_compression_algorithm_parse(
const char *name, size_t name_length,
grpc_compression_algorithm *algorithm);
/** Updates \a name with the encoding name corresponding to a valid \a
* algorithm. Returns 1 upon success, 0 otherwise. */
GRPC_API int grpc_compression_algorithm_name(grpc_compression_algorithm algorithm,
char **name);
GRPC_API int grpc_compression_algorithm_name(
grpc_compression_algorithm algorithm, char **name);
/** Returns the compression algorithm corresponding to \a level.
*
* It abort()s for unknown levels . */
GRPC_API grpc_compression_algorithm grpc_compression_algorithm_for_level(
grpc_compression_level level);
GRPC_API grpc_compression_algorithm
grpc_compression_algorithm_for_level(grpc_compression_level level);
GRPC_API void grpc_compression_options_init(grpc_compression_options *opts);

@ -102,7 +102,8 @@ GRPC_API grpc_completion_queue *grpc_completion_queue_create(void *reserved);
Callers must not call grpc_completion_queue_next and
grpc_completion_queue_pluck simultaneously on the same completion queue. */
GRPC_API grpc_event grpc_completion_queue_next(grpc_completion_queue *cq,
gpr_timespec deadline, void *reserved);
gpr_timespec deadline,
void *reserved);
/** Blocks until an event with tag 'tag' is available, the completion queue is
being shutdown or deadline is reached.
@ -115,8 +116,9 @@ GRPC_API 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. */
GRPC_API grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag,
gpr_timespec deadline, void *reserved);
GRPC_API 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 */
@ -141,8 +143,8 @@ GRPC_API void grpc_completion_queue_destroy(grpc_completion_queue *cq);
* 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). */
GRPC_API grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq, gpr_timespec deadline,
void *tag);
GRPC_API grpc_alarm *grpc_alarm_create(grpc_completion_queue *cq,
gpr_timespec deadline, void *tag);
/** Cancel a completion queue alarm. Calling this function over an alarm that
* has already fired has no effect. */
@ -152,8 +154,9 @@ GRPC_API void grpc_alarm_cancel(grpc_alarm *alarm);
GRPC_API void grpc_alarm_destroy(grpc_alarm *alarm);
/** Check the connectivity state of a channel. */
GRPC_API grpc_connectivity_state grpc_channel_check_connectivity_state(
grpc_channel *channel, int try_to_connect);
GRPC_API grpc_connectivity_state
grpc_channel_check_connectivity_state(grpc_channel *channel,
int try_to_connect);
/** Watch for a change in connectivity state.
Once the channel connectivity state is different from last_observed_state,
@ -170,21 +173,21 @@ GRPC_API void grpc_channel_watch_connectivity_state(
If parent_call is non-NULL, it must be a server-side call. It will be used
to propagate properties from the server call to this new client call.
*/
GRPC_API grpc_call *grpc_channel_create_call(grpc_channel *channel,
grpc_call *parent_call,
uint32_t propagation_mask,
grpc_completion_queue *completion_queue,
const char *method, const char *host,
gpr_timespec deadline, void *reserved);
GRPC_API grpc_call *grpc_channel_create_call(
grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask,
grpc_completion_queue *completion_queue, const char *method,
const char *host, gpr_timespec deadline, void *reserved);
/** Ping the channels peer (load balanced channels will select one sub-channel
to ping); if the channel is not connected, posts a failed. */
GRPC_API void grpc_channel_ping(grpc_channel *channel, grpc_completion_queue *cq,
void *tag, void *reserved);
GRPC_API void grpc_channel_ping(grpc_channel *channel,
grpc_completion_queue *cq, void *tag,
void *reserved);
/** Pre-register a method/host pair on a channel. */
GRPC_API void *grpc_channel_register_call(grpc_channel *channel, const char *method,
const char *host, void *reserved);
GRPC_API 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 */
GRPC_API grpc_call *grpc_channel_create_registered_call(
@ -203,8 +206,9 @@ GRPC_API grpc_call *grpc_channel_create_registered_call(
needs to be synchronized. As an optimization, you may synchronize batches
containing just send operations independently from batches containing just
receive operations. */
GRPC_API grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops,
size_t nops, void *tag, void *reserved);
GRPC_API 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
@ -221,7 +225,7 @@ struct census_context;
/* Set census context for a call; Must be called before first call to
grpc_call_start_batch(). */
GRPC_API void grpc_census_call_set_context(grpc_call *call,
struct census_context *context);
struct census_context *context);
/* Retrieve the calls current census context. */
GRPC_API struct census_context *grpc_census_call_get_context(grpc_call *call);
@ -235,14 +239,12 @@ GRPC_API char *grpc_channel_get_target(grpc_channel *channel);
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. */
GRPC_API grpc_channel *grpc_insecure_channel_create(const char *target,
const grpc_channel_args *args,
void *reserved);
GRPC_API 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. */
GRPC_API grpc_channel *grpc_lame_client_channel_create(const char *target,
grpc_status_code error_code,
const char *error_message);
GRPC_API 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 */
GRPC_API void grpc_channel_destroy(grpc_channel *channel);
@ -266,10 +268,9 @@ GRPC_API grpc_call_error grpc_call_cancel(grpc_call *call, void *reserved);
and description passed in.
Importantly, this function does not send status nor description to the
remote endpoint. */
GRPC_API grpc_call_error grpc_call_cancel_with_status(grpc_call *call,
grpc_status_code status,
const char *description,
void *reserved);
GRPC_API grpc_call_error
grpc_call_cancel_with_status(grpc_call *call, grpc_status_code status,
const char *description, void *reserved);
/** Destroy a call.
THREAD SAFETY: grpc_call_destroy is thread-compatible */
@ -283,11 +284,13 @@ GRPC_API void grpc_call_destroy(grpc_call *call);
to \a cq_bound_to_call.
Note that \a cq_for_notification must have been registered to the server via
\a grpc_server_register_completion_queue. */
GRPC_API 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_API 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);
/** Registers a method in the server.
Methods to this (host, method) pair will not be reported by
@ -296,8 +299,9 @@ GRPC_API grpc_call_error grpc_server_request_call(
registered_method (as returned by this function).
Must be called before grpc_server_start.
Returns NULL on failure. */
GRPC_API void *grpc_server_register_method(grpc_server *server, const char *method,
const char *host);
GRPC_API void *grpc_server_register_method(grpc_server *server,
const char *method,
const char *host);
/** Request notification of a new pre-registered call. 'cq_for_notification'
must have been registered to the server via
@ -313,20 +317,22 @@ GRPC_API grpc_call_error grpc_server_request_registered_call(
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. */
GRPC_API grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved);
GRPC_API 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. */
GRPC_API void grpc_server_register_completion_queue(grpc_server *server,
grpc_completion_queue *cq,
void *reserved);
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 */
GRPC_API int grpc_server_add_insecure_http2_port(grpc_server *server, const char *addr);
GRPC_API int grpc_server_add_insecure_http2_port(grpc_server *server,
const char *addr);
/** Start a server - tells all listeners to start listening */
GRPC_API void grpc_server_start(grpc_server *server);
@ -339,7 +345,8 @@ GRPC_API void grpc_server_start(grpc_server *server);
grpc_server_shutdown_and_notify calls are made. 'cq' must have been
registered to this server via grpc_server_register_completion_queue. */
GRPC_API void grpc_server_shutdown_and_notify(grpc_server *server,
grpc_completion_queue *cq, void *tag);
grpc_completion_queue *cq,
void *tag);
/** Cancel all in-progress calls.
Only usable after shutdown. */
@ -366,7 +373,8 @@ GRPC_API int grpc_header_key_is_legal(const char *key, size_t length);
/** Check whether a non-binary metadata value is legal (will be accepted by
core) */
GRPC_API int grpc_header_nonbin_value_is_legal(const char *value, size_t length);
GRPC_API int grpc_header_nonbin_value_is_legal(const char *value,
size_t length);
/** Check whether a metadata key corresponds to a binary value */
GRPC_API int grpc_is_binary_header(const char *key, size_t length);

@ -69,18 +69,19 @@ GRPC_API const grpc_auth_property *grpc_auth_property_iterator_next(
grpc_auth_property_iterator *it);
/* Iterates over the auth context. */
GRPC_API grpc_auth_property_iterator grpc_auth_context_property_iterator(
const grpc_auth_context *ctx);
GRPC_API grpc_auth_property_iterator
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. */
GRPC_API grpc_auth_property_iterator grpc_auth_context_peer_identity(
const grpc_auth_context *ctx);
GRPC_API grpc_auth_property_iterator
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. */
GRPC_API grpc_auth_property_iterator grpc_auth_context_find_properties_by_name(
const grpc_auth_context *ctx, const char *name);
GRPC_API grpc_auth_property_iterator
grpc_auth_context_find_properties_by_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. */
@ -88,7 +89,8 @@ GRPC_API const char *grpc_auth_context_peer_identity_property_name(
const grpc_auth_context *ctx);
/* Returns 1 if the peer is authenticated, 0 otherwise. */
GRPC_API int grpc_auth_context_peer_is_authenticated(const grpc_auth_context *ctx);
GRPC_API int grpc_auth_context_peer_is_authenticated(
const grpc_auth_context *ctx);
/* Gets the auth context from the call. Caller needs to call
grpc_auth_context_release on the returned context. */
@ -103,18 +105,20 @@ GRPC_API void grpc_auth_context_release(grpc_auth_context *context);
-- */
/* Add a property. */
GRPC_API void grpc_auth_context_add_property(grpc_auth_context *ctx, const char *name,
const char *value, size_t value_length);
GRPC_API 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. */
GRPC_API void grpc_auth_context_add_cstring_property(grpc_auth_context *ctx,
const char *name,
const char *value);
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). */
GRPC_API int grpc_auth_context_set_peer_identity_property_name(grpc_auth_context *ctx,
const char *name);
GRPC_API int grpc_auth_context_set_peer_identity_property_name(
grpc_auth_context *ctx, const char *name);
/* --- grpc_channel_credentials object. ---
@ -203,8 +207,10 @@ extern const 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. */
GRPC_API grpc_call_credentials *grpc_service_account_jwt_access_credentials_create(
const char *json_key, gpr_timespec token_lifetime, void *reserved);
GRPC_API grpc_call_credentials *
grpc_service_account_jwt_access_credentials_create(const char *json_key,
gpr_timespec token_lifetime,
void *reserved);
/* Creates an Oauth2 Refresh Token credentials object for connecting to Google.
May return NULL if the input is invalid.
@ -289,10 +295,9 @@ GRPC_API grpc_call_credentials *grpc_metadata_credentials_create_from_plugin(
/* --- Secure channel creation. --- */
/* Creates a secure channel using the passed-in credentials. */
GRPC_API grpc_channel *grpc_secure_channel_create(grpc_channel_credentials *creds,
const char *target,
const grpc_channel_args *args,
void *reserved);
GRPC_API grpc_channel *grpc_secure_channel_create(
grpc_channel_credentials *creds, const char *target,
const grpc_channel_args *args, void *reserved);
/* --- grpc_server_credentials object. ---
@ -325,15 +330,16 @@ GRPC_API grpc_server_credentials *grpc_ssl_server_credentials_create(
/* Add a HTTP2 over an encrypted link over tcp listener.
Returns bound port number on success, 0 on failure.
REQUIRES: server not started */
GRPC_API int grpc_server_add_secure_http2_port(grpc_server *server, const char *addr,
grpc_server_credentials *creds);
GRPC_API 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. */
GRPC_API grpc_call_error grpc_call_set_credentials(grpc_call *call,
grpc_call_credentials *creds);
GRPC_API grpc_call_error
grpc_call_set_credentials(grpc_call *call, grpc_call_credentials *creds);
/* --- Auth Metadata Processing --- */

@ -66,7 +66,7 @@ typedef struct grpc_byte_buffer grpc_byte_buffer;
* Increases the reference count for all \a slices processed. The user is
* responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/
GRPC_API grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices,
size_t nslices);
size_t nslices);
/** Returns a *compressed* RAW byte buffer instance over the given slices (up to
* \a nslices). The \a compression argument defines the compression algorithm
@ -95,7 +95,7 @@ typedef struct grpc_byte_buffer_reader grpc_byte_buffer_reader;
/** Initialize \a reader to read over \a buffer */
GRPC_API void grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader,
grpc_byte_buffer *buffer);
grpc_byte_buffer *buffer);
/** Cleanup and destroy \a reader */
GRPC_API void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader);
@ -104,10 +104,11 @@ GRPC_API void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader);
* 1. Returns 0 at the end of the stream. Caller is responsible for calling
* gpr_slice_unref on the result. */
GRPC_API int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader,
gpr_slice *slice);
gpr_slice *slice);
/** Merge all data from \a reader into single slice */
GRPC_API gpr_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader);
GRPC_API gpr_slice
grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader);
/** Returns a RAW byte buffer instance from the output of \a reader. */
GRPC_API grpc_byte_buffer *grpc_raw_byte_buffer_from_reader(

@ -72,10 +72,10 @@ 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 */
GPR_API void gpr_log(const char *file, int line, gpr_log_severity severity,
const char *format, ...);
const char *format, ...);
GPR_API void gpr_log_message(const char *file, int line, gpr_log_severity severity,
const char *message);
GPR_API 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 */

@ -122,8 +122,8 @@ GPR_API gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *));
/* Equivalent to gpr_slice_new, but with a two argument destroy function that
also takes the slice length. */
GPR_API gpr_slice gpr_slice_new_with_len(void *p, size_t len,
void (*destroy)(void *, size_t));
GPR_API gpr_slice
gpr_slice_new_with_len(void *p, size_t len, void (*destroy)(void *, size_t));
/* Equivalent to gpr_slice_new(malloc(len), len, free), but saves one malloc()
call.

@ -73,8 +73,10 @@ GPR_API void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_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. */
GPR_API size_t gpr_slice_buffer_add_indexed(gpr_slice_buffer *sb, gpr_slice slice);
GPR_API void gpr_slice_buffer_addn(gpr_slice_buffer *sb, gpr_slice *slices, size_t n);
GPR_API size_t
gpr_slice_buffer_add_indexed(gpr_slice_buffer *sb, gpr_slice slice);
GPR_API void gpr_slice_buffer_addn(gpr_slice_buffer *sb, gpr_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 */
GPR_API uint8_t *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t len);
@ -85,13 +87,14 @@ GPR_API void gpr_slice_buffer_reset_and_unref(gpr_slice_buffer *sb);
/* swap the contents of two slice buffers */
GPR_API void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b);
/* move all of the elements of src into dst */
GPR_API void gpr_slice_buffer_move_into(gpr_slice_buffer *src, gpr_slice_buffer *dst);
GPR_API void gpr_slice_buffer_move_into(gpr_slice_buffer *src,
gpr_slice_buffer *dst);
/* remove n bytes from the end of a slice buffer */
GPR_API void gpr_slice_buffer_trim_end(gpr_slice_buffer *src, size_t n,
gpr_slice_buffer *garbage);
gpr_slice_buffer *garbage);
/* move the first n bytes of src into dst */
GPR_API void gpr_slice_buffer_move_first(gpr_slice_buffer *src, size_t n,
gpr_slice_buffer *dst);
gpr_slice_buffer *dst);
/* take the first slice in the slice buffer */
GPR_API gpr_slice gpr_slice_buffer_take_first(gpr_slice_buffer *src);

@ -69,7 +69,8 @@ typedef struct gpr_timespec {
} gpr_timespec;
/* Time constants. */
GPR_API gpr_timespec gpr_time_0(gpr_clock_type type); /* The zero time interval. */
GPR_API gpr_timespec
gpr_time_0(gpr_clock_type type); /* The zero time interval. */
GPR_API gpr_timespec gpr_inf_future(gpr_clock_type type); /* The far future */
GPR_API gpr_timespec gpr_inf_past(gpr_clock_type type); /* The far past. */
@ -87,8 +88,8 @@ GPR_API void gpr_time_init(void);
GPR_API gpr_timespec gpr_now(gpr_clock_type clock);
/* Convert a timespec from one clock to another */
GPR_API gpr_timespec gpr_convert_clock_type(gpr_timespec t,
gpr_clock_type target_clock);
GPR_API gpr_timespec
gpr_convert_clock_type(gpr_timespec t, gpr_clock_type target_clock);
/* Return -ve, 0, or +ve according to whether a < b, a == b, or a > b
respectively. */
@ -114,7 +115,8 @@ GPR_API int32_t gpr_time_to_millis(gpr_timespec timespec);
/* Return 1 if two times are equal or within threshold of each other,
0 otherwise */
GPR_API int gpr_time_similar(gpr_timespec a, gpr_timespec b, gpr_timespec threshold);
GPR_API int gpr_time_similar(gpr_timespec a, gpr_timespec b,
gpr_timespec threshold);
/* Sleep until at least 'until' - an absolute timeout */
GPR_API void gpr_sleep_until(gpr_timespec until);

@ -73,14 +73,14 @@ typedef struct gpr_cmdline gpr_cmdline;
GPR_API 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) */
GPR_API void gpr_cmdline_add_int(gpr_cmdline *cl, const char *name, const char *help,
int *value);
GPR_API void gpr_cmdline_add_int(gpr_cmdline *cl, const char *name,
const char *help, int *value);
/* The same, for a boolean flag */
GPR_API void gpr_cmdline_add_flag(gpr_cmdline *cl, const char *name, const char *help,
int *value);
GPR_API void gpr_cmdline_add_flag(gpr_cmdline *cl, const char *name,
const char *help, int *value);
/* And for a string */
GPR_API void gpr_cmdline_add_string(gpr_cmdline *cl, const char *name, const char *help,
char **value);
GPR_API void gpr_cmdline_add_string(gpr_cmdline *cl, const char *name,
const char *help, char **value);
/* Set a callback for non-named arguments */
GPR_API void gpr_cmdline_on_extra_arg(
gpr_cmdline *cl, const char *name, const char *help,

@ -43,7 +43,8 @@ extern "C" {
typedef struct gpr_histogram gpr_histogram;
GPR_API gpr_histogram *gpr_histogram_create(double resolution, double max_bucket_start);
GPR_API gpr_histogram *gpr_histogram_create(double resolution,
double max_bucket_start);
GPR_API void gpr_histogram_destroy(gpr_histogram *h);
GPR_API void gpr_histogram_add(gpr_histogram *h, double x);
@ -52,7 +53,8 @@ GPR_API void gpr_histogram_add(gpr_histogram *h, double x);
on success */
GPR_API int gpr_histogram_merge(gpr_histogram *dst, const gpr_histogram *src);
GPR_API double gpr_histogram_percentile(gpr_histogram *histogram, double percentile);
GPR_API double gpr_histogram_percentile(gpr_histogram *histogram,
double percentile);
GPR_API double gpr_histogram_mean(gpr_histogram *histogram);
GPR_API double gpr_histogram_stddev(gpr_histogram *histogram);
GPR_API double gpr_histogram_variance(gpr_histogram *histogram);
@ -63,11 +65,12 @@ GPR_API double gpr_histogram_sum(gpr_histogram *histogram);
GPR_API double gpr_histogram_sum_of_squares(gpr_histogram *histogram);
GPR_API const uint32_t *gpr_histogram_get_contents(gpr_histogram *histogram,
size_t *count);
size_t *count);
GPR_API 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);
const uint32_t *data,
size_t data_count, double min_seen,
double max_seen, double sum,
double sum_of_squares, double count);
#ifdef __cplusplus
}

@ -60,7 +60,7 @@ typedef struct {
If options==NULL, default options are used.
The thread is immediately runnable, and exits when (*thd_body)() returns. */
GPR_API int gpr_thd_new(gpr_thd_id *t, void (*thd_body)(void *arg), void *arg,
const gpr_thd_options *options);
const gpr_thd_options *options);
/* Return a gpr_thd_options struct with all fields set to defaults. */
GPR_API gpr_thd_options gpr_thd_options_default(void);

Loading…
Cancel
Save