grpc 0.13.0 → 0.13.1.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of grpc might be problematic. Click here for more details.

Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/Makefile +1114 -937
  4. data/include/grpc/census.h +71 -89
  5. data/include/grpc/compression.h +7 -7
  6. data/include/grpc/grpc.h +65 -68
  7. data/include/grpc/grpc_security.h +38 -38
  8. data/include/grpc/impl/codegen/alloc.h +7 -7
  9. data/include/grpc/impl/codegen/byte_buffer.h +13 -13
  10. data/include/grpc/impl/codegen/grpc_types.h +7 -2
  11. data/include/grpc/impl/codegen/log.h +5 -5
  12. data/include/grpc/impl/codegen/port_platform.h +14 -6
  13. data/include/grpc/impl/codegen/slice.h +15 -15
  14. data/include/grpc/impl/codegen/slice_buffer.h +17 -17
  15. data/include/grpc/impl/codegen/sync.h +26 -22
  16. data/include/grpc/impl/codegen/time.h +22 -24
  17. data/include/grpc/support/avl.h +9 -8
  18. data/include/grpc/support/cmdline.h +12 -12
  19. data/include/grpc/support/cpu.h +2 -2
  20. data/include/grpc/support/histogram.h +22 -22
  21. data/include/grpc/support/host_port.h +2 -2
  22. data/include/grpc/support/log_win32.h +1 -1
  23. data/include/grpc/support/string_util.h +2 -2
  24. data/include/grpc/support/subprocess.h +5 -5
  25. data/include/grpc/support/thd.h +9 -9
  26. data/include/grpc/support/useful.h +3 -1
  27. data/src/core/census/context.c +64 -85
  28. data/src/core/census/grpc_filter.c +2 -2
  29. data/src/core/census/mlog.c +600 -0
  30. data/src/core/census/mlog.h +95 -0
  31. data/src/core/channel/channel_args.c +67 -6
  32. data/src/core/channel/channel_args.h +7 -1
  33. data/src/core/channel/client_channel.c +26 -36
  34. data/src/core/channel/client_uchannel.c +1 -1
  35. data/src/core/channel/http_client_filter.c +2 -2
  36. data/src/core/channel/http_server_filter.c +2 -2
  37. data/src/core/channel/subchannel_call_holder.c +5 -7
  38. data/src/core/client_config/connector.c +3 -2
  39. data/src/core/client_config/connector.h +2 -2
  40. data/src/core/client_config/lb_policies/load_balancer_api.c +163 -0
  41. data/src/core/client_config/lb_policies/load_balancer_api.h +85 -0
  42. data/src/core/client_config/lb_policies/pick_first.c +10 -11
  43. data/src/core/client_config/lb_policies/round_robin.c +7 -8
  44. data/src/core/client_config/lb_policy.c +3 -3
  45. data/src/core/client_config/lb_policy.h +3 -2
  46. data/src/core/client_config/subchannel.c +51 -21
  47. data/src/core/client_config/subchannel.h +15 -6
  48. data/src/core/client_config/subchannel_index.c +261 -0
  49. data/src/core/client_config/subchannel_index.h +77 -0
  50. data/src/core/compression/{algorithm.c → compression_algorithm.c} +0 -0
  51. data/src/core/httpcli/httpcli.c +13 -11
  52. data/src/core/httpcli/httpcli.h +3 -2
  53. data/src/core/httpcli/httpcli_security_connector.c +7 -7
  54. data/src/core/iomgr/fd_posix.c +4 -2
  55. data/src/core/iomgr/iocp_windows.c +10 -6
  56. data/src/core/iomgr/iocp_windows.h +9 -2
  57. data/src/core/iomgr/iomgr.c +18 -2
  58. data/src/core/iomgr/iomgr_internal.h +5 -1
  59. data/src/core/iomgr/pollset.h +9 -10
  60. data/src/core/iomgr/pollset_multipoller_with_epoll.c +1 -0
  61. data/src/core/iomgr/pollset_multipoller_with_poll_posix.c +10 -5
  62. data/src/core/iomgr/pollset_posix.c +30 -35
  63. data/src/core/iomgr/pollset_posix.h +10 -6
  64. data/src/core/iomgr/pollset_set.h +3 -9
  65. data/src/core/iomgr/pollset_set_posix.c +23 -3
  66. data/src/core/iomgr/pollset_set_posix.h +2 -18
  67. data/src/core/iomgr/pollset_set_windows.c +3 -3
  68. data/src/core/iomgr/pollset_set_windows.h +2 -2
  69. data/src/core/iomgr/pollset_windows.c +24 -21
  70. data/src/core/iomgr/pollset_windows.h +1 -5
  71. data/src/core/iomgr/tcp_client_posix.c +7 -5
  72. data/src/core/iomgr/tcp_posix.c +4 -2
  73. data/src/core/iomgr/tcp_server_windows.c +1 -2
  74. data/src/core/iomgr/timer.c +2 -3
  75. data/src/core/iomgr/timer.h +21 -1
  76. data/src/core/iomgr/timer_heap.c +10 -12
  77. data/src/core/iomgr/udp_server.c +5 -4
  78. data/src/core/iomgr/udp_server.h +1 -0
  79. data/src/core/iomgr/workqueue_posix.c +1 -0
  80. data/src/core/iomgr/workqueue_posix.h +3 -1
  81. data/src/core/proto/grpc/lb/v0/load_balancer.pb.c +119 -0
  82. data/src/core/proto/grpc/lb/v0/load_balancer.pb.h +182 -0
  83. data/src/core/security/{base64.c → b64.c} +1 -1
  84. data/src/core/security/{base64.h → b64.h} +1 -1
  85. data/src/core/security/client_auth_filter.c +0 -1
  86. data/src/core/security/credentials.c +12 -5
  87. data/src/core/security/credentials.h +3 -3
  88. data/src/core/security/google_default_credentials.c +24 -19
  89. data/src/core/security/handshake.c +15 -7
  90. data/src/core/security/handshake.h +2 -1
  91. data/src/core/security/json_token.c +1 -1
  92. data/src/core/security/jwt_verifier.c +1 -1
  93. data/src/core/security/security_connector.c +84 -64
  94. data/src/core/security/security_connector.h +42 -22
  95. data/src/core/security/security_context.c +8 -3
  96. data/src/core/security/server_auth_filter.c +2 -2
  97. data/src/core/security/server_secure_chttp2.c +7 -7
  98. data/src/core/support/avl.c +2 -2
  99. data/src/core/support/env_linux.c +17 -0
  100. data/src/core/support/{file.c → load_file.c} +2 -2
  101. data/src/core/support/{file.h → load_file.h} +4 -12
  102. data/src/core/support/sync.c +6 -1
  103. data/src/core/support/time_posix.c +1 -1
  104. data/src/core/{iomgr/timer_internal.h → support/tmpfile.h} +17 -23
  105. data/src/core/support/{file_posix.c → tmpfile_posix.c} +2 -2
  106. data/src/core/support/{file_win32.c → tmpfile_win32.c} +2 -2
  107. data/src/core/surface/alarm.c +3 -2
  108. data/src/core/surface/call.c +102 -52
  109. data/src/core/surface/channel_create.c +1 -1
  110. data/src/core/surface/completion_queue.c +73 -41
  111. data/src/core/surface/init.c +4 -0
  112. data/src/core/surface/lame_client.c +1 -2
  113. data/src/core/surface/secure_channel_create.c +6 -7
  114. data/src/core/surface/server.c +13 -5
  115. data/src/core/surface/validate_metadata.c +1 -1
  116. data/src/core/surface/version.c +1 -1
  117. data/src/core/transport/chttp2/internal.h +22 -10
  118. data/src/core/transport/chttp2/parsing.c +3 -3
  119. data/src/core/transport/chttp2/stream_lists.c +39 -21
  120. data/src/core/transport/chttp2/writing.c +19 -28
  121. data/src/core/transport/chttp2_transport.c +80 -37
  122. data/src/core/transport/metadata.c +8 -0
  123. data/src/core/transport/static_metadata.c +17 -17
  124. data/src/core/transport/static_metadata.h +3 -3
  125. data/src/core/transport/transport.c +2 -1
  126. data/src/core/transport/transport.h +12 -5
  127. data/src/ruby/ext/grpc/extconf.rb +1 -0
  128. data/src/ruby/ext/grpc/rb_call.c +6 -0
  129. data/src/ruby/ext/grpc/rb_call_credentials.c +12 -14
  130. data/src/ruby/ext/grpc/rb_channel.c +8 -14
  131. data/src/ruby/ext/grpc/rb_channel_credentials.c +11 -12
  132. data/src/ruby/ext/grpc/rb_grpc.c +19 -18
  133. data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +4 -0
  134. data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +8 -2
  135. data/src/ruby/lib/grpc/core/time_consts.rb +2 -2
  136. data/src/ruby/lib/grpc/errors.rb +2 -2
  137. data/src/ruby/lib/grpc/generic/rpc_server.rb +58 -39
  138. data/src/ruby/lib/grpc/version.rb +1 -1
  139. data/src/ruby/pb/README.md +2 -2
  140. data/src/ruby/pb/generate_proto_ruby.sh +2 -2
  141. data/src/ruby/pb/grpc/health/checker.rb +11 -11
  142. data/src/ruby/pb/grpc/health/v1/health.rb +28 -0
  143. data/src/ruby/pb/grpc/health/{v1alpha → v1}/health_services.rb +4 -4
  144. data/src/ruby/spec/client_server_spec.rb +2 -1
  145. data/src/ruby/spec/generic/rpc_server_spec.rb +3 -22
  146. data/src/ruby/spec/pb/health/checker_spec.rb +22 -36
  147. data/third_party/nanopb/pb.h +547 -0
  148. data/third_party/nanopb/pb_common.c +97 -0
  149. data/third_party/nanopb/pb_common.h +42 -0
  150. data/third_party/nanopb/pb_decode.c +1319 -0
  151. data/third_party/nanopb/pb_decode.h +149 -0
  152. data/third_party/nanopb/pb_encode.c +690 -0
  153. data/third_party/nanopb/pb_encode.h +154 -0
  154. metadata +32 -16
  155. data/src/ruby/pb/grpc/health/v1alpha/health.rb +0 -29
@@ -65,39 +65,39 @@ typedef struct grpc_auth_property {
65
65
  } grpc_auth_property;
66
66
 
67
67
  /* Returns NULL when the iterator is at the end. */
68
- GRPC_API const grpc_auth_property *grpc_auth_property_iterator_next(
68
+ GRPCAPI const grpc_auth_property *grpc_auth_property_iterator_next(
69
69
  grpc_auth_property_iterator *it);
70
70
 
71
71
  /* Iterates over the auth context. */
72
- GRPC_API grpc_auth_property_iterator
72
+ GRPCAPI grpc_auth_property_iterator
73
73
  grpc_auth_context_property_iterator(const grpc_auth_context *ctx);
74
74
 
75
75
  /* Gets the peer identity. Returns an empty iterator (first _next will return
76
76
  NULL) if the peer is not authenticated. */
77
- GRPC_API grpc_auth_property_iterator
77
+ GRPCAPI grpc_auth_property_iterator
78
78
  grpc_auth_context_peer_identity(const grpc_auth_context *ctx);
79
79
 
80
80
  /* Finds a property in the context. May return an empty iterator (first _next
81
81
  will return NULL) if no property with this name was found in the context. */
82
- GRPC_API grpc_auth_property_iterator
82
+ GRPCAPI grpc_auth_property_iterator
83
83
  grpc_auth_context_find_properties_by_name(const grpc_auth_context *ctx,
84
84
  const char *name);
85
85
 
86
86
  /* Gets the name of the property that indicates the peer identity. Will return
87
87
  NULL if the peer is not authenticated. */
88
- GRPC_API const char *grpc_auth_context_peer_identity_property_name(
88
+ GRPCAPI const char *grpc_auth_context_peer_identity_property_name(
89
89
  const grpc_auth_context *ctx);
90
90
 
91
91
  /* Returns 1 if the peer is authenticated, 0 otherwise. */
92
- GRPC_API int grpc_auth_context_peer_is_authenticated(
92
+ GRPCAPI int grpc_auth_context_peer_is_authenticated(
93
93
  const grpc_auth_context *ctx);
94
94
 
95
95
  /* Gets the auth context from the call. Caller needs to call
96
96
  grpc_auth_context_release on the returned context. */
97
- GRPC_API grpc_auth_context *grpc_call_auth_context(grpc_call *call);
97
+ GRPCAPI grpc_auth_context *grpc_call_auth_context(grpc_call *call);
98
98
 
99
99
  /* Releases the auth context returned from grpc_call_auth_context. */
100
- GRPC_API void grpc_auth_context_release(grpc_auth_context *context);
100
+ GRPCAPI void grpc_auth_context_release(grpc_auth_context *context);
101
101
 
102
102
  /* --
103
103
  The following auth context methods should only be called by a server metadata
@@ -105,19 +105,18 @@ GRPC_API void grpc_auth_context_release(grpc_auth_context *context);
105
105
  -- */
106
106
 
107
107
  /* Add a property. */
108
- GRPC_API void grpc_auth_context_add_property(grpc_auth_context *ctx,
109
- const char *name,
110
- const char *value,
111
- size_t value_length);
108
+ GRPCAPI void grpc_auth_context_add_property(grpc_auth_context *ctx,
109
+ const char *name, const char *value,
110
+ size_t value_length);
112
111
 
113
112
  /* Add a C string property. */
114
- GRPC_API void grpc_auth_context_add_cstring_property(grpc_auth_context *ctx,
115
- const char *name,
116
- const char *value);
113
+ GRPCAPI void grpc_auth_context_add_cstring_property(grpc_auth_context *ctx,
114
+ const char *name,
115
+ const char *value);
117
116
 
118
117
  /* Sets the property name. Returns 1 if successful or 0 in case of failure
119
118
  (which means that no property with this name exists). */
120
- GRPC_API int grpc_auth_context_set_peer_identity_property_name(
119
+ GRPCAPI int grpc_auth_context_set_peer_identity_property_name(
121
120
  grpc_auth_context *ctx, const char *name);
122
121
 
123
122
  /* --- grpc_channel_credentials object. ---
@@ -129,7 +128,7 @@ typedef struct grpc_channel_credentials grpc_channel_credentials;
129
128
 
130
129
  /* Releases a channel credentials object.
131
130
  The creator of the credentials object is responsible for its release. */
132
- GRPC_API void grpc_channel_credentials_release(grpc_channel_credentials *creds);
131
+ GRPCAPI void grpc_channel_credentials_release(grpc_channel_credentials *creds);
133
132
 
134
133
  /* Environment variable that points to the google default application
135
134
  credentials json key or refresh token. Used in the
@@ -139,7 +138,7 @@ GRPC_API void grpc_channel_credentials_release(grpc_channel_credentials *creds);
139
138
  /* Creates default credentials to connect to a google gRPC service.
140
139
  WARNING: Do NOT use this credentials to connect to a non-google service as
141
140
  this could result in an oauth2 token leak. */
142
- GRPC_API grpc_channel_credentials *grpc_google_default_credentials_create(void);
141
+ GRPCAPI grpc_channel_credentials *grpc_google_default_credentials_create(void);
143
142
 
144
143
  /* Environment variable that points to the default SSL roots file. This file
145
144
  must be a PEM encoded file with all the roots such as the one that can be
@@ -168,7 +167,8 @@ typedef grpc_ssl_roots_override_result (*grpc_ssl_roots_override_callback)(
168
167
  before any ssl credentials are created to have the desired side effect.
169
168
  If GRPC_DEFAULT_SSL_ROOTS_FILE_PATH environment is set to a valid path, the
170
169
  callback will not be called. */
171
- void grpc_set_ssl_roots_override_callback(grpc_ssl_roots_override_callback cb);
170
+ GRPCAPI void grpc_set_ssl_roots_override_callback(
171
+ grpc_ssl_roots_override_callback cb);
172
172
 
173
173
  /* Object that holds a private key / certificate chain pair in PEM format. */
174
174
  typedef struct {
@@ -192,7 +192,7 @@ typedef struct {
192
192
  - pem_key_cert_pair is a pointer on the object containing client's private
193
193
  key and certificate chain. This parameter can be NULL if the client does
194
194
  not have such a key/cert pair. */
195
- GRPC_API grpc_channel_credentials *grpc_ssl_credentials_create(
195
+ GRPCAPI grpc_channel_credentials *grpc_ssl_credentials_create(
196
196
  const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pair,
197
197
  void *reserved);
198
198
 
@@ -206,32 +206,32 @@ typedef struct grpc_call_credentials grpc_call_credentials;
206
206
 
207
207
  /* Releases a call credentials object.
208
208
  The creator of the credentials object is responsible for its release. */
209
- GRPC_API void grpc_call_credentials_release(grpc_call_credentials *creds);
209
+ GRPCAPI void grpc_call_credentials_release(grpc_call_credentials *creds);
210
210
 
211
211
  /* Creates a composite channel credentials object. */
212
- GRPC_API grpc_channel_credentials *grpc_composite_channel_credentials_create(
212
+ GRPCAPI grpc_channel_credentials *grpc_composite_channel_credentials_create(
213
213
  grpc_channel_credentials *channel_creds, grpc_call_credentials *call_creds,
214
214
  void *reserved);
215
215
 
216
216
  /* Creates a composite call credentials object. */
217
- GRPC_API grpc_call_credentials *grpc_composite_call_credentials_create(
217
+ GRPCAPI grpc_call_credentials *grpc_composite_call_credentials_create(
218
218
  grpc_call_credentials *creds1, grpc_call_credentials *creds2,
219
219
  void *reserved);
220
220
 
221
221
  /* Creates a compute engine credentials object for connecting to Google.
222
222
  WARNING: Do NOT use this credentials to connect to a non-google service as
223
223
  this could result in an oauth2 token leak. */
224
- GRPC_API grpc_call_credentials *grpc_google_compute_engine_credentials_create(
224
+ GRPCAPI grpc_call_credentials *grpc_google_compute_engine_credentials_create(
225
225
  void *reserved);
226
226
 
227
- GRPC_API gpr_timespec grpc_max_auth_token_lifetime();
227
+ GRPCAPI gpr_timespec grpc_max_auth_token_lifetime();
228
228
 
229
229
  /* Creates a JWT credentials object. May return NULL if the input is invalid.
230
230
  - json_key is the JSON key string containing the client's private key.
231
231
  - token_lifetime is the lifetime of each Json Web Token (JWT) created with
232
232
  this credentials. It should not exceed grpc_max_auth_token_lifetime or
233
233
  will be cropped to this value. */
234
- GRPC_API grpc_call_credentials *
234
+ GRPCAPI grpc_call_credentials *
235
235
  grpc_service_account_jwt_access_credentials_create(const char *json_key,
236
236
  gpr_timespec token_lifetime,
237
237
  void *reserved);
@@ -242,16 +242,16 @@ grpc_service_account_jwt_access_credentials_create(const char *json_key,
242
242
  this could result in an oauth2 token leak.
243
243
  - json_refresh_token is the JSON string containing the refresh token itself
244
244
  along with a client_id and client_secret. */
245
- GRPC_API grpc_call_credentials *grpc_google_refresh_token_credentials_create(
245
+ GRPCAPI grpc_call_credentials *grpc_google_refresh_token_credentials_create(
246
246
  const char *json_refresh_token, void *reserved);
247
247
 
248
248
  /* Creates an Oauth2 Access Token credentials with an access token that was
249
249
  aquired by an out of band mechanism. */
250
- GRPC_API grpc_call_credentials *grpc_access_token_credentials_create(
250
+ GRPCAPI grpc_call_credentials *grpc_access_token_credentials_create(
251
251
  const char *access_token, void *reserved);
252
252
 
253
253
  /* Creates an IAM credentials object for connecting to Google. */
254
- GRPC_API grpc_call_credentials *grpc_google_iam_credentials_create(
254
+ GRPCAPI grpc_call_credentials *grpc_google_iam_credentials_create(
255
255
  const char *authorization_token, const char *authority_selector,
256
256
  void *reserved);
257
257
 
@@ -313,13 +313,13 @@ typedef struct {
313
313
  } grpc_metadata_credentials_plugin;
314
314
 
315
315
  /* Creates a credentials object from a plugin. */
316
- GRPC_API grpc_call_credentials *grpc_metadata_credentials_create_from_plugin(
316
+ GRPCAPI grpc_call_credentials *grpc_metadata_credentials_create_from_plugin(
317
317
  grpc_metadata_credentials_plugin plugin, void *reserved);
318
318
 
319
319
  /* --- Secure channel creation. --- */
320
320
 
321
321
  /* Creates a secure channel using the passed-in credentials. */
322
- GRPC_API grpc_channel *grpc_secure_channel_create(
322
+ GRPCAPI grpc_channel *grpc_secure_channel_create(
323
323
  grpc_channel_credentials *creds, const char *target,
324
324
  const grpc_channel_args *args, void *reserved);
325
325
 
@@ -332,7 +332,7 @@ typedef struct grpc_server_credentials grpc_server_credentials;
332
332
  /* Releases a server_credentials object.
333
333
  The creator of the server_credentials object is responsible for its release.
334
334
  */
335
- GRPC_API void grpc_server_credentials_release(grpc_server_credentials *creds);
335
+ GRPCAPI void grpc_server_credentials_release(grpc_server_credentials *creds);
336
336
 
337
337
  /* Creates an SSL server_credentials object.
338
338
  - pem_roots_cert is the NULL-terminated string containing the PEM encoding of
@@ -345,7 +345,7 @@ GRPC_API void grpc_server_credentials_release(grpc_server_credentials *creds);
345
345
  - force_client_auth, if set to non-zero will force the client to authenticate
346
346
  with an SSL cert. Note that this option is ignored if pem_root_certs is
347
347
  NULL. */
348
- GRPC_API grpc_server_credentials *grpc_ssl_server_credentials_create(
348
+ GRPCAPI grpc_server_credentials *grpc_ssl_server_credentials_create(
349
349
  const char *pem_root_certs, grpc_ssl_pem_key_cert_pair *pem_key_cert_pairs,
350
350
  size_t num_key_cert_pairs, int force_client_auth, void *reserved);
351
351
 
@@ -354,15 +354,15 @@ GRPC_API grpc_server_credentials *grpc_ssl_server_credentials_create(
354
354
  /* Add a HTTP2 over an encrypted link over tcp listener.
355
355
  Returns bound port number on success, 0 on failure.
356
356
  REQUIRES: server not started */
357
- GRPC_API int grpc_server_add_secure_http2_port(grpc_server *server,
358
- const char *addr,
359
- grpc_server_credentials *creds);
357
+ GRPCAPI int grpc_server_add_secure_http2_port(grpc_server *server,
358
+ const char *addr,
359
+ grpc_server_credentials *creds);
360
360
 
361
361
  /* --- Call specific credentials. --- */
362
362
 
363
363
  /* Sets a credentials to a call. Can only be called on the client side before
364
364
  grpc_call_start_batch. */
365
- GRPC_API grpc_call_error
365
+ GRPCAPI grpc_call_error
366
366
  grpc_call_set_credentials(grpc_call *call, grpc_call_credentials *creds);
367
367
 
368
368
  /* --- Auth Metadata Processing --- */
@@ -394,7 +394,7 @@ typedef struct {
394
394
  void *state;
395
395
  } grpc_auth_metadata_processor;
396
396
 
397
- GRPC_API void grpc_server_credentials_set_auth_metadata_processor(
397
+ GRPCAPI void grpc_server_credentials_set_auth_metadata_processor(
398
398
  grpc_server_credentials *creds, grpc_auth_metadata_processor processor);
399
399
 
400
400
  #ifdef __cplusplus
@@ -49,23 +49,23 @@ typedef struct gpr_allocation_functions {
49
49
  } gpr_allocation_functions;
50
50
 
51
51
  /* malloc, never returns NULL */
52
- GPR_API void *gpr_malloc(size_t size);
52
+ GPRAPI void *gpr_malloc(size_t size);
53
53
  /* free */
54
- GPR_API void gpr_free(void *ptr);
54
+ GPRAPI void gpr_free(void *ptr);
55
55
  /* realloc, never returns NULL */
56
- GPR_API void *gpr_realloc(void *p, size_t size);
56
+ GPRAPI void *gpr_realloc(void *p, size_t size);
57
57
  /* aligned malloc, never returns NULL, will align to 1 << alignment_log */
58
- GPR_API void *gpr_malloc_aligned(size_t size, size_t alignment_log);
58
+ GPRAPI void *gpr_malloc_aligned(size_t size, size_t alignment_log);
59
59
  /* free memory allocated by gpr_malloc_aligned */
60
- GPR_API void gpr_free_aligned(void *ptr);
60
+ GPRAPI void gpr_free_aligned(void *ptr);
61
61
 
62
62
  /** Request the family of allocation functions in \a functions be used. NOTE
63
63
  * that this request will be honored in a *best effort* basis and that no
64
64
  * guarantees are made about the default functions (eg, malloc) being called. */
65
- GPR_API void gpr_set_allocation_functions(gpr_allocation_functions functions);
65
+ GPRAPI void gpr_set_allocation_functions(gpr_allocation_functions functions);
66
66
 
67
67
  /** Return the family of allocation functions currently in effect. */
68
- GPR_API gpr_allocation_functions gpr_get_allocation_functions();
68
+ GPRAPI gpr_allocation_functions gpr_get_allocation_functions();
69
69
 
70
70
  #ifdef __cplusplus
71
71
  }
@@ -65,8 +65,8 @@ typedef struct grpc_byte_buffer grpc_byte_buffer;
65
65
  *
66
66
  * Increases the reference count for all \a slices processed. The user is
67
67
  * responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/
68
- GRPC_API grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices,
69
- size_t nslices);
68
+ GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices,
69
+ size_t nslices);
70
70
 
71
71
  /** Returns a *compressed* RAW byte buffer instance over the given slices (up to
72
72
  * \a nslices). The \a compression argument defines the compression algorithm
@@ -74,44 +74,44 @@ GRPC_API grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices,
74
74
  *
75
75
  * Increases the reference count for all \a slices processed. The user is
76
76
  * responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/
77
- GRPC_API grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create(
77
+ GRPCAPI grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create(
78
78
  gpr_slice *slices, size_t nslices, grpc_compression_algorithm compression);
79
79
 
80
80
  /** Copies input byte buffer \a bb.
81
81
  *
82
82
  * Increases the reference count of all the source slices. The user is
83
83
  * responsible for calling grpc_byte_buffer_destroy over the returned copy. */
84
- GRPC_API grpc_byte_buffer *grpc_byte_buffer_copy(grpc_byte_buffer *bb);
84
+ GRPCAPI grpc_byte_buffer *grpc_byte_buffer_copy(grpc_byte_buffer *bb);
85
85
 
86
86
  /** Returns the size of the given byte buffer, in bytes. */
87
- GRPC_API size_t grpc_byte_buffer_length(grpc_byte_buffer *bb);
87
+ GRPCAPI size_t grpc_byte_buffer_length(grpc_byte_buffer *bb);
88
88
 
89
89
  /** Destroys \a byte_buffer deallocating all its memory. */
90
- GRPC_API void grpc_byte_buffer_destroy(grpc_byte_buffer *byte_buffer);
90
+ GRPCAPI void grpc_byte_buffer_destroy(grpc_byte_buffer *byte_buffer);
91
91
 
92
92
  /** Reader for byte buffers. Iterates over slices in the byte buffer */
93
93
  struct grpc_byte_buffer_reader;
94
94
  typedef struct grpc_byte_buffer_reader grpc_byte_buffer_reader;
95
95
 
96
96
  /** Initialize \a reader to read over \a buffer */
97
- GRPC_API void grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader,
98
- grpc_byte_buffer *buffer);
97
+ GRPCAPI void grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader,
98
+ grpc_byte_buffer *buffer);
99
99
 
100
100
  /** Cleanup and destroy \a reader */
101
- GRPC_API void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader);
101
+ GRPCAPI void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader);
102
102
 
103
103
  /** Updates \a slice with the next piece of data from from \a reader and returns
104
104
  * 1. Returns 0 at the end of the stream. Caller is responsible for calling
105
105
  * gpr_slice_unref on the result. */
106
- GRPC_API int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader,
107
- gpr_slice *slice);
106
+ GRPCAPI int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader,
107
+ gpr_slice *slice);
108
108
 
109
109
  /** Merge all data from \a reader into single slice */
110
- GRPC_API gpr_slice
110
+ GRPCAPI gpr_slice
111
111
  grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader);
112
112
 
113
113
  /** Returns a RAW byte buffer instance from the output of \a reader. */
114
- GRPC_API grpc_byte_buffer *grpc_raw_byte_buffer_from_reader(
114
+ GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_from_reader(
115
115
  grpc_byte_buffer_reader *reader);
116
116
 
117
117
  #ifdef __cplusplus
@@ -68,6 +68,12 @@ typedef enum {
68
68
  GRPC_ARG_POINTER
69
69
  } grpc_arg_type;
70
70
 
71
+ typedef struct grpc_arg_pointer_vtable {
72
+ void *(*copy)(void *p);
73
+ void (*destroy)(void *p);
74
+ int (*cmp)(void *p, void *q);
75
+ } grpc_arg_pointer_vtable;
76
+
71
77
  /** A single argument... each argument has a key and a value
72
78
 
73
79
  A note on naming keys:
@@ -88,8 +94,7 @@ typedef struct {
88
94
  int integer;
89
95
  struct {
90
96
  void *p;
91
- void *(*copy)(void *p);
92
- void (*destroy)(void *p);
97
+ const grpc_arg_pointer_vtable *vtable;
93
98
  } pointer;
94
99
  } value;
95
100
  } grpc_arg;
@@ -71,11 +71,11 @@ const char *gpr_log_severity_string(gpr_log_severity severity);
71
71
 
72
72
  /* Log a message. It's advised to use GPR_xxx above to generate the context
73
73
  * for each message */
74
- GPR_API void gpr_log(const char *file, int line, gpr_log_severity severity,
75
- const char *format, ...);
74
+ GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity,
75
+ const char *format, ...);
76
76
 
77
- GPR_API void gpr_log_message(const char *file, int line,
78
- gpr_log_severity severity, const char *message);
77
+ GPRAPI void gpr_log_message(const char *file, int line,
78
+ gpr_log_severity severity, const char *message);
79
79
 
80
80
  /* Log overrides: applications can use this API to intercept logging calls
81
81
  and use their own implementations */
@@ -88,7 +88,7 @@ typedef struct {
88
88
  } gpr_log_func_args;
89
89
 
90
90
  typedef void (*gpr_log_func)(gpr_log_func_args *args);
91
- GPR_API void gpr_set_log_function(gpr_log_func func);
91
+ GPRAPI void gpr_set_log_function(gpr_log_func func);
92
92
 
93
93
  /* abort() the process if x is zero, having written a line to the log.
94
94
 
@@ -34,6 +34,14 @@
34
34
  #ifndef GRPC_IMPL_CODEGEN_PORT_PLATFORM_H
35
35
  #define GRPC_IMPL_CODEGEN_PORT_PLATFORM_H
36
36
 
37
+ /*
38
+ * Define GPR_BACKWARDS_COMPATIBILITY_MODE to try harder to be ABI
39
+ * compatible with older platforms (currently only on Linux)
40
+ * Causes:
41
+ * - some libc calls to be gotten via dlsym
42
+ * - some syscalls to be made directly
43
+ */
44
+
37
45
  /* Get windows.h included everywhere (we need it) */
38
46
  #if defined(_WIN64) || defined(WIN64) || defined(_WIN32) || defined(WIN32)
39
47
  #ifndef WIN32_LEAN_AND_MEAN
@@ -347,16 +355,16 @@ typedef unsigned __int64 uint64_t;
347
355
  } while (0)
348
356
  #endif /* GPR_FORBID_UNREACHABLE_CODE */
349
357
 
350
- #ifndef GPR_API
351
- #define GPR_API
358
+ #ifndef GPRAPI
359
+ #define GPRAPI
352
360
  #endif
353
361
 
354
- #ifndef GRPC_API
355
- #define GRPC_API GPR_API
362
+ #ifndef GRPCAPI
363
+ #define GRPCAPI GPRAPI
356
364
  #endif
357
365
 
358
- #ifndef CENSUS_API
359
- #define CENSUS_API GRPC_API
366
+ #ifndef CENSUSAPI
367
+ #define CENSUSAPI GRPCAPI
360
368
  #endif
361
369
 
362
370
  #endif /* GRPC_IMPL_CODEGEN_PORT_PLATFORM_H */
@@ -105,7 +105,7 @@ typedef struct gpr_slice {
105
105
 
106
106
  /* Increment the refcount of s. Requires slice is initialized.
107
107
  Returns s. */
108
- GPR_API gpr_slice gpr_slice_ref(gpr_slice s);
108
+ GPRAPI gpr_slice gpr_slice_ref(gpr_slice s);
109
109
 
110
110
  /* Decrement the ref count of s. If the ref count of s reaches zero, all
111
111
  slices sharing the ref count are destroyed, and considered no longer
@@ -113,22 +113,22 @@ GPR_API gpr_slice gpr_slice_ref(gpr_slice s);
113
113
  len, dest) where dest!=NULL , then (*dest)(start) is called, else if s is
114
114
  ultimately derived from a call to gpr_slice_new_with_len(start, len, dest)
115
115
  where dest!=NULL , then (*dest)(start, len). Requires s initialized. */
116
- GPR_API void gpr_slice_unref(gpr_slice s);
116
+ GPRAPI void gpr_slice_unref(gpr_slice s);
117
117
 
118
118
  /* Create a slice pointing at some data. Calls malloc to allocate a refcount
119
119
  for the object, and arranges that destroy will be called with the pointer
120
120
  passed in at destruction. */
121
- GPR_API gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *));
121
+ GPRAPI gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *));
122
122
 
123
123
  /* Equivalent to gpr_slice_new, but with a two argument destroy function that
124
124
  also takes the slice length. */
125
- GPR_API gpr_slice
125
+ GPRAPI gpr_slice
126
126
  gpr_slice_new_with_len(void *p, size_t len, void (*destroy)(void *, size_t));
127
127
 
128
128
  /* Equivalent to gpr_slice_new(malloc(len), len, free), but saves one malloc()
129
129
  call.
130
130
  Aborts if malloc() fails. */
131
- GPR_API gpr_slice gpr_slice_malloc(size_t length);
131
+ GPRAPI gpr_slice gpr_slice_malloc(size_t length);
132
132
 
133
133
  /* Create a slice by copying a string.
134
134
  Does not preserve null terminators.
@@ -136,44 +136,44 @@ GPR_API gpr_slice gpr_slice_malloc(size_t length);
136
136
  size_t len = strlen(source);
137
137
  gpr_slice slice = gpr_slice_malloc(len);
138
138
  memcpy(slice->data, source, len); */
139
- GPR_API gpr_slice gpr_slice_from_copied_string(const char *source);
139
+ GPRAPI gpr_slice gpr_slice_from_copied_string(const char *source);
140
140
 
141
141
  /* Create a slice by copying a buffer.
142
142
  Equivalent to:
143
143
  gpr_slice slice = gpr_slice_malloc(len);
144
144
  memcpy(slice->data, source, len); */
145
- GPR_API gpr_slice gpr_slice_from_copied_buffer(const char *source, size_t len);
145
+ GPRAPI gpr_slice gpr_slice_from_copied_buffer(const char *source, size_t len);
146
146
 
147
147
  /* Create a slice pointing to constant memory */
148
- GPR_API gpr_slice gpr_slice_from_static_string(const char *source);
148
+ GPRAPI gpr_slice gpr_slice_from_static_string(const char *source);
149
149
 
150
150
  /* Return a result slice derived from s, which shares a ref count with s, where
151
151
  result.data==s.data+begin, and result.length==end-begin.
152
152
  The ref count of s is increased by one.
153
153
  Requires s initialized, begin <= end, begin <= s.length, and
154
154
  end <= source->length. */
155
- GPR_API gpr_slice gpr_slice_sub(gpr_slice s, size_t begin, size_t end);
155
+ GPRAPI gpr_slice gpr_slice_sub(gpr_slice s, size_t begin, size_t end);
156
156
 
157
157
  /* The same as gpr_slice_sub, but without altering the ref count */
158
- GPR_API gpr_slice gpr_slice_sub_no_ref(gpr_slice s, size_t begin, size_t end);
158
+ GPRAPI gpr_slice gpr_slice_sub_no_ref(gpr_slice s, size_t begin, size_t end);
159
159
 
160
160
  /* Splits s into two: modifies s to be s[0:split], and returns a new slice,
161
161
  sharing a refcount with s, that contains s[split:s.length].
162
162
  Requires s intialized, split <= s.length */
163
- GPR_API gpr_slice gpr_slice_split_tail(gpr_slice *s, size_t split);
163
+ GPRAPI gpr_slice gpr_slice_split_tail(gpr_slice *s, size_t split);
164
164
 
165
165
  /* Splits s into two: modifies s to be s[split:s.length], and returns a new
166
166
  slice, sharing a refcount with s, that contains s[0:split].
167
167
  Requires s intialized, split <= s.length */
168
- GPR_API gpr_slice gpr_slice_split_head(gpr_slice *s, size_t split);
168
+ GPRAPI gpr_slice gpr_slice_split_head(gpr_slice *s, size_t split);
169
169
 
170
- GPR_API gpr_slice gpr_empty_slice(void);
170
+ GPRAPI gpr_slice gpr_empty_slice(void);
171
171
 
172
172
  /* Returns <0 if a < b, ==0 if a == b, >0 if a > b
173
173
  The order is arbitrary, and is not guaranteed to be stable across different
174
174
  versions of the API. */
175
- GPR_API int gpr_slice_cmp(gpr_slice a, gpr_slice b);
176
- GPR_API int gpr_slice_str_cmp(gpr_slice a, const char *b);
175
+ GPRAPI int gpr_slice_cmp(gpr_slice a, gpr_slice b);
176
+ GPRAPI int gpr_slice_str_cmp(gpr_slice a, const char *b);
177
177
 
178
178
  #ifdef __cplusplus
179
179
  }