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
@@ -59,13 +59,13 @@ typedef struct {
59
59
  } gpr_slice_buffer;
60
60
 
61
61
  /* initialize a slice buffer */
62
- GPR_API void gpr_slice_buffer_init(gpr_slice_buffer *sb);
62
+ GPRAPI void gpr_slice_buffer_init(gpr_slice_buffer *sb);
63
63
  /* destroy a slice buffer - unrefs any held elements */
64
- GPR_API void gpr_slice_buffer_destroy(gpr_slice_buffer *sb);
64
+ GPRAPI void gpr_slice_buffer_destroy(gpr_slice_buffer *sb);
65
65
  /* Add an element to a slice buffer - takes ownership of the slice.
66
66
  This function is allowed to concatenate the passed in slice to the end of
67
67
  some other slice if desired by the slice buffer. */
68
- GPR_API void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice slice);
68
+ GPRAPI void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice slice);
69
69
  /* add an element to a slice buffer - takes ownership of the slice and returns
70
70
  the index of the slice.
71
71
  Guarantees that the slice will not be concatenated at the end of another
@@ -73,30 +73,30 @@ GPR_API void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice slice);
73
73
  slice at the returned index in sb->slices)
74
74
  The implementation MAY decide to concatenate data at the end of a small
75
75
  slice added in this fashion. */
76
- GPR_API size_t
76
+ GPRAPI size_t
77
77
  gpr_slice_buffer_add_indexed(gpr_slice_buffer *sb, gpr_slice slice);
78
- GPR_API void gpr_slice_buffer_addn(gpr_slice_buffer *sb, gpr_slice *slices,
79
- size_t n);
78
+ GPRAPI void gpr_slice_buffer_addn(gpr_slice_buffer *sb, gpr_slice *slices,
79
+ size_t n);
80
80
  /* add a very small (less than 8 bytes) amount of data to the end of a slice
81
81
  buffer: returns a pointer into which to add the data */
82
- GPR_API uint8_t *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t len);
82
+ GPRAPI uint8_t *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t len);
83
83
  /* pop the last buffer, but don't unref it */
84
- GPR_API void gpr_slice_buffer_pop(gpr_slice_buffer *sb);
84
+ GPRAPI void gpr_slice_buffer_pop(gpr_slice_buffer *sb);
85
85
  /* clear a slice buffer, unref all elements */
86
- GPR_API void gpr_slice_buffer_reset_and_unref(gpr_slice_buffer *sb);
86
+ GPRAPI void gpr_slice_buffer_reset_and_unref(gpr_slice_buffer *sb);
87
87
  /* swap the contents of two slice buffers */
88
- GPR_API void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b);
88
+ GPRAPI void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b);
89
89
  /* move all of the elements of src into dst */
90
- GPR_API void gpr_slice_buffer_move_into(gpr_slice_buffer *src,
91
- gpr_slice_buffer *dst);
90
+ GPRAPI void gpr_slice_buffer_move_into(gpr_slice_buffer *src,
91
+ gpr_slice_buffer *dst);
92
92
  /* remove n bytes from the end of a slice buffer */
93
- GPR_API void gpr_slice_buffer_trim_end(gpr_slice_buffer *src, size_t n,
94
- gpr_slice_buffer *garbage);
93
+ GPRAPI void gpr_slice_buffer_trim_end(gpr_slice_buffer *src, size_t n,
94
+ gpr_slice_buffer *garbage);
95
95
  /* move the first n bytes of src into dst */
96
- GPR_API void gpr_slice_buffer_move_first(gpr_slice_buffer *src, size_t n,
97
- gpr_slice_buffer *dst);
96
+ GPRAPI void gpr_slice_buffer_move_first(gpr_slice_buffer *src, size_t n,
97
+ gpr_slice_buffer *dst);
98
98
  /* take the first slice in the slice buffer */
99
- GPR_API gpr_slice gpr_slice_buffer_take_first(gpr_slice_buffer *src);
99
+ GPRAPI gpr_slice gpr_slice_buffer_take_first(gpr_slice_buffer *src);
100
100
 
101
101
  #ifdef __cplusplus
102
102
  }
@@ -78,26 +78,26 @@ extern "C" {
78
78
  gpr_mu are uninitialized when first declared. */
79
79
 
80
80
  /* Initialize *mu. Requires: *mu uninitialized. */
81
- GPR_API void gpr_mu_init(gpr_mu *mu);
81
+ GPRAPI void gpr_mu_init(gpr_mu *mu);
82
82
 
83
83
  /* Cause *mu no longer to be initialized, freeing any memory in use. Requires:
84
84
  *mu initialized; no other concurrent operation on *mu. */
85
- GPR_API void gpr_mu_destroy(gpr_mu *mu);
85
+ GPRAPI void gpr_mu_destroy(gpr_mu *mu);
86
86
 
87
87
  /* Wait until no thread has a lock on *mu, cause the calling thread to own an
88
88
  exclusive lock on *mu, then return. May block indefinitely or crash if the
89
89
  calling thread has a lock on *mu. Requires: *mu initialized. */
90
- GPR_API void gpr_mu_lock(gpr_mu *mu);
90
+ GPRAPI void gpr_mu_lock(gpr_mu *mu);
91
91
 
92
92
  /* Release an exclusive lock on *mu held by the calling thread. Requires: *mu
93
93
  initialized; the calling thread holds an exclusive lock on *mu. */
94
- GPR_API void gpr_mu_unlock(gpr_mu *mu);
94
+ GPRAPI void gpr_mu_unlock(gpr_mu *mu);
95
95
 
96
96
  /* Without blocking, attempt to acquire an exclusive lock on *mu for the
97
97
  calling thread, then return non-zero iff success. Fail, if any thread holds
98
98
  the lock; succeeds with high probability if no thread holds the lock.
99
99
  Requires: *mu initialized. */
100
- GPR_API int gpr_mu_trylock(gpr_mu *mu);
100
+ GPRAPI int gpr_mu_trylock(gpr_mu *mu);
101
101
 
102
102
  /* --- Condition variable interface ---
103
103
 
@@ -106,11 +106,11 @@ GPR_API int gpr_mu_trylock(gpr_mu *mu);
106
106
  uninitialized when first declared. */
107
107
 
108
108
  /* Initialize *cv. Requires: *cv uninitialized. */
109
- GPR_API void gpr_cv_init(gpr_cv *cv);
109
+ GPRAPI void gpr_cv_init(gpr_cv *cv);
110
110
 
111
111
  /* Cause *cv no longer to be initialized, freeing any memory in use. Requires:
112
112
  *cv initialized; no other concurrent operation on *cv.*/
113
- GPR_API void gpr_cv_destroy(gpr_cv *cv);
113
+ GPRAPI void gpr_cv_destroy(gpr_cv *cv);
114
114
 
115
115
  /* Atomically release *mu and wait on *cv. When the calling thread is woken
116
116
  from *cv or the deadline abs_deadline is exceeded, execute gpr_mu_lock(mu)
@@ -119,16 +119,16 @@ GPR_API void gpr_cv_destroy(gpr_cv *cv);
119
119
  an absolute deadline, or a GPR_TIMESPAN. May return even when not
120
120
  woken explicitly. Requires: *mu and *cv initialized; the calling thread
121
121
  holds an exclusive lock on *mu. */
122
- GPR_API int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline);
122
+ GPRAPI int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline);
123
123
 
124
124
  /* If any threads are waiting on *cv, wake at least one.
125
125
  Clients may treat this as an optimization of gpr_cv_broadcast()
126
126
  for use in the case where waking more than one waiter is not useful.
127
127
  Requires: *cv initialized. */
128
- GPR_API void gpr_cv_signal(gpr_cv *cv);
128
+ GPRAPI void gpr_cv_signal(gpr_cv *cv);
129
129
 
130
130
  /* Wake all threads waiting on *cv. Requires: *cv initialized. */
131
- GPR_API void gpr_cv_broadcast(gpr_cv *cv);
131
+ GPRAPI void gpr_cv_broadcast(gpr_cv *cv);
132
132
 
133
133
  /* --- One-time initialization ---
134
134
 
@@ -141,7 +141,7 @@ GPR_API void gpr_cv_broadcast(gpr_cv *cv);
141
141
  If multiple threads call gpr_once() on the same gpr_once instance, one of
142
142
  them will call (*init_routine)(), and the others will block until that call
143
143
  finishes.*/
144
- GPR_API void gpr_once_init(gpr_once *once, void (*init_routine)(void));
144
+ GPRAPI void gpr_once_init(gpr_once *once, void (*init_routine)(void));
145
145
 
146
146
  /* --- One-time event notification ---
147
147
 
@@ -151,43 +151,47 @@ GPR_API void gpr_once_init(gpr_once *once, void (*init_routine)(void));
151
151
  It requires no destruction. */
152
152
 
153
153
  /* Initialize *ev. */
154
- GPR_API void gpr_event_init(gpr_event *ev);
154
+ GPRAPI void gpr_event_init(gpr_event *ev);
155
155
 
156
156
  /* Set *ev so that gpr_event_get() and gpr_event_wait() will return value.
157
157
  Requires: *ev initialized; value != NULL; no prior or concurrent calls to
158
158
  gpr_event_set(ev, ...) since initialization. */
159
- GPR_API void gpr_event_set(gpr_event *ev, void *value);
159
+ GPRAPI void gpr_event_set(gpr_event *ev, void *value);
160
160
 
161
161
  /* Return the value set by gpr_event_set(ev, ...), or NULL if no such call has
162
162
  completed. If the result is non-NULL, all operations that occurred prior to
163
163
  the gpr_event_set(ev, ...) set will be visible after this call returns.
164
164
  Requires: *ev initialized. This operation is faster than acquiring a mutex
165
165
  on most platforms. */
166
- GPR_API void *gpr_event_get(gpr_event *ev);
166
+ GPRAPI void *gpr_event_get(gpr_event *ev);
167
167
 
168
168
  /* Wait until *ev is set by gpr_event_set(ev, ...), or abs_deadline is
169
169
  exceeded, then return gpr_event_get(ev). Requires: *ev initialized. Use
170
170
  abs_deadline==gpr_inf_future for no deadline. When the event has been
171
171
  signalled before the call, this operation is faster than acquiring a mutex
172
172
  on most platforms. */
173
- GPR_API void *gpr_event_wait(gpr_event *ev, gpr_timespec abs_deadline);
173
+ GPRAPI void *gpr_event_wait(gpr_event *ev, gpr_timespec abs_deadline);
174
174
 
175
175
  /* --- Reference counting ---
176
176
 
177
177
  These calls act on the type gpr_refcount. It requires no destruction. */
178
178
 
179
179
  /* Initialize *r to value n. */
180
- GPR_API void gpr_ref_init(gpr_refcount *r, int n);
180
+ GPRAPI void gpr_ref_init(gpr_refcount *r, int n);
181
181
 
182
182
  /* Increment the reference count *r. Requires *r initialized. */
183
- GPR_API void gpr_ref(gpr_refcount *r);
183
+ GPRAPI void gpr_ref(gpr_refcount *r);
184
+
185
+ /* Increment the reference count *r. Requires *r initialized.
186
+ Crashes if refcount is zero */
187
+ GPRAPI void gpr_ref_non_zero(gpr_refcount *r);
184
188
 
185
189
  /* Increment the reference count *r by n. Requires *r initialized, n > 0. */
186
- GPR_API void gpr_refn(gpr_refcount *r, int n);
190
+ GPRAPI void gpr_refn(gpr_refcount *r, int n);
187
191
 
188
192
  /* Decrement the reference count *r and return non-zero iff it has reached
189
193
  zero. . Requires *r initialized. */
190
- GPR_API int gpr_unref(gpr_refcount *r);
194
+ GPRAPI int gpr_unref(gpr_refcount *r);
191
195
 
192
196
  /* --- Stats counters ---
193
197
 
@@ -198,13 +202,13 @@ GPR_API int gpr_unref(gpr_refcount *r);
198
202
  synchronize other events. */
199
203
 
200
204
  /* Initialize *c to the value n. */
201
- GPR_API void gpr_stats_init(gpr_stats_counter *c, intptr_t n);
205
+ GPRAPI void gpr_stats_init(gpr_stats_counter *c, intptr_t n);
202
206
 
203
207
  /* *c += inc. Requires: *c initialized. */
204
- GPR_API void gpr_stats_inc(gpr_stats_counter *c, intptr_t inc);
208
+ GPRAPI void gpr_stats_inc(gpr_stats_counter *c, intptr_t inc);
205
209
 
206
210
  /* Return *c. Requires: *c initialized. */
207
- GPR_API intptr_t gpr_stats_read(const gpr_stats_counter *c);
211
+ GPRAPI intptr_t gpr_stats_read(const gpr_stats_counter *c);
208
212
 
209
213
  /* ==================Example use of interface===================
210
214
  A producer-consumer queue of up to N integers,
@@ -69,10 +69,10 @@ typedef struct gpr_timespec {
69
69
  } gpr_timespec;
70
70
 
71
71
  /* Time constants. */
72
- GPR_API gpr_timespec
72
+ GPRAPI gpr_timespec
73
73
  gpr_time_0(gpr_clock_type type); /* The zero time interval. */
74
- GPR_API gpr_timespec gpr_inf_future(gpr_clock_type type); /* The far future */
75
- GPR_API gpr_timespec gpr_inf_past(gpr_clock_type type); /* The far past. */
74
+ GPRAPI gpr_timespec gpr_inf_future(gpr_clock_type type); /* The far future */
75
+ GPRAPI gpr_timespec gpr_inf_past(gpr_clock_type type); /* The far past. */
76
76
 
77
77
  #define GPR_MS_PER_SEC 1000
78
78
  #define GPR_US_PER_SEC 1000000
@@ -82,48 +82,46 @@ GPR_API gpr_timespec gpr_inf_past(gpr_clock_type type); /* The far past. */
82
82
  #define GPR_US_PER_MS 1000
83
83
 
84
84
  /* initialize time subsystem */
85
- GPR_API void gpr_time_init(void);
85
+ GPRAPI void gpr_time_init(void);
86
86
 
87
87
  /* Return the current time measured from the given clocks epoch. */
88
- GPR_API gpr_timespec gpr_now(gpr_clock_type clock);
88
+ GPRAPI gpr_timespec gpr_now(gpr_clock_type clock);
89
89
 
90
90
  /* Convert a timespec from one clock to another */
91
- GPR_API gpr_timespec
91
+ GPRAPI gpr_timespec
92
92
  gpr_convert_clock_type(gpr_timespec t, gpr_clock_type target_clock);
93
93
 
94
94
  /* Return -ve, 0, or +ve according to whether a < b, a == b, or a > b
95
95
  respectively. */
96
- GPR_API int gpr_time_cmp(gpr_timespec a, gpr_timespec b);
96
+ GPRAPI int gpr_time_cmp(gpr_timespec a, gpr_timespec b);
97
97
 
98
- GPR_API gpr_timespec gpr_time_max(gpr_timespec a, gpr_timespec b);
99
- GPR_API gpr_timespec gpr_time_min(gpr_timespec a, gpr_timespec b);
98
+ GPRAPI gpr_timespec gpr_time_max(gpr_timespec a, gpr_timespec b);
99
+ GPRAPI gpr_timespec gpr_time_min(gpr_timespec a, gpr_timespec b);
100
100
 
101
101
  /* Add and subtract times. Calculations saturate at infinities. */
102
- GPR_API gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b);
103
- GPR_API gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b);
102
+ GPRAPI gpr_timespec gpr_time_add(gpr_timespec a, gpr_timespec b);
103
+ GPRAPI gpr_timespec gpr_time_sub(gpr_timespec a, gpr_timespec b);
104
104
 
105
105
  /* Return a timespec representing a given number of time units. INT64_MIN is
106
106
  interpreted as gpr_inf_past, and INT64_MAX as gpr_inf_future. */
107
- GPR_API gpr_timespec gpr_time_from_micros(int64_t x, gpr_clock_type clock_type);
108
- GPR_API gpr_timespec gpr_time_from_nanos(int64_t x, gpr_clock_type clock_type);
109
- GPR_API gpr_timespec gpr_time_from_millis(int64_t x, gpr_clock_type clock_type);
110
- GPR_API gpr_timespec
111
- gpr_time_from_seconds(int64_t x, gpr_clock_type clock_type);
112
- GPR_API gpr_timespec
113
- gpr_time_from_minutes(int64_t x, gpr_clock_type clock_type);
114
- GPR_API gpr_timespec gpr_time_from_hours(int64_t x, gpr_clock_type clock_type);
107
+ GPRAPI gpr_timespec gpr_time_from_micros(int64_t x, gpr_clock_type clock_type);
108
+ GPRAPI gpr_timespec gpr_time_from_nanos(int64_t x, gpr_clock_type clock_type);
109
+ GPRAPI gpr_timespec gpr_time_from_millis(int64_t x, gpr_clock_type clock_type);
110
+ GPRAPI gpr_timespec gpr_time_from_seconds(int64_t x, gpr_clock_type clock_type);
111
+ GPRAPI gpr_timespec gpr_time_from_minutes(int64_t x, gpr_clock_type clock_type);
112
+ GPRAPI gpr_timespec gpr_time_from_hours(int64_t x, gpr_clock_type clock_type);
115
113
 
116
- GPR_API int32_t gpr_time_to_millis(gpr_timespec timespec);
114
+ GPRAPI int32_t gpr_time_to_millis(gpr_timespec timespec);
117
115
 
118
116
  /* Return 1 if two times are equal or within threshold of each other,
119
117
  0 otherwise */
120
- GPR_API int gpr_time_similar(gpr_timespec a, gpr_timespec b,
121
- gpr_timespec threshold);
118
+ GPRAPI int gpr_time_similar(gpr_timespec a, gpr_timespec b,
119
+ gpr_timespec threshold);
122
120
 
123
121
  /* Sleep until at least 'until' - an absolute timeout */
124
- GPR_API void gpr_sleep_until(gpr_timespec until);
122
+ GPRAPI void gpr_sleep_until(gpr_timespec until);
125
123
 
126
- GPR_API double gpr_timespec_to_micros(gpr_timespec t);
124
+ GPRAPI double gpr_timespec_to_micros(gpr_timespec t);
127
125
 
128
126
  #ifdef __cplusplus
129
127
  }
@@ -69,23 +69,24 @@ typedef struct gpr_avl {
69
69
  } gpr_avl;
70
70
 
71
71
  /** create an immutable AVL tree */
72
- GPR_API gpr_avl gpr_avl_create(const gpr_avl_vtable *vtable);
72
+ GPRAPI gpr_avl gpr_avl_create(const gpr_avl_vtable *vtable);
73
73
  /** add a reference to an existing tree - returns
74
74
  the tree as a convenience */
75
- GPR_API gpr_avl gpr_avl_ref(gpr_avl avl);
75
+ GPRAPI gpr_avl gpr_avl_ref(gpr_avl avl);
76
76
  /** remove a reference to a tree - destroying it if there
77
77
  are no references left */
78
- GPR_API void gpr_avl_unref(gpr_avl avl);
78
+ GPRAPI void gpr_avl_unref(gpr_avl avl);
79
79
  /** return a new tree with (key, value) added to avl.
80
80
  implicitly unrefs avl to allow easy chaining.
81
81
  if key exists in avl, the new tree's key entry updated
82
82
  (i.e. a duplicate is not created) */
83
- GPR_API gpr_avl gpr_avl_add(gpr_avl avl, void *key, void *value);
84
- /** return a new tree with key deleted */
85
- GPR_API gpr_avl gpr_avl_remove(gpr_avl avl, void *key);
83
+ GPRAPI gpr_avl gpr_avl_add(gpr_avl avl, void *key, void *value);
84
+ /** return a new tree with key deleted
85
+ implicitly unrefs avl to allow easy chaining. */
86
+ GPRAPI gpr_avl gpr_avl_remove(gpr_avl avl, void *key);
86
87
  /** lookup key, and return the associated value.
87
88
  does not mutate avl.
88
89
  returns NULL if key is not found. */
89
- GPR_API void *gpr_avl_get(gpr_avl avl, void *key);
90
+ GPRAPI void *gpr_avl_get(gpr_avl avl, void *key);
90
91
 
91
- #endif
92
+ #endif /* GRPC_SUPPORT_AVL_H */
@@ -70,31 +70,31 @@ typedef struct gpr_cmdline gpr_cmdline;
70
70
 
71
71
  /* Construct a command line parser: takes a short description of the tool
72
72
  doing the parsing */
73
- GPR_API gpr_cmdline *gpr_cmdline_create(const char *description);
73
+ GPRAPI gpr_cmdline *gpr_cmdline_create(const char *description);
74
74
  /* Add an integer parameter, with a name (used on the command line) and some
75
75
  helpful text (used in the command usage) */
76
- GPR_API void gpr_cmdline_add_int(gpr_cmdline *cl, const char *name,
77
- const char *help, int *value);
76
+ GPRAPI void gpr_cmdline_add_int(gpr_cmdline *cl, const char *name,
77
+ const char *help, int *value);
78
78
  /* The same, for a boolean flag */
79
- GPR_API void gpr_cmdline_add_flag(gpr_cmdline *cl, const char *name,
80
- const char *help, int *value);
79
+ GPRAPI void gpr_cmdline_add_flag(gpr_cmdline *cl, const char *name,
80
+ const char *help, int *value);
81
81
  /* And for a string */
82
- GPR_API void gpr_cmdline_add_string(gpr_cmdline *cl, const char *name,
83
- const char *help, char **value);
82
+ GPRAPI void gpr_cmdline_add_string(gpr_cmdline *cl, const char *name,
83
+ const char *help, char **value);
84
84
  /* Set a callback for non-named arguments */
85
- GPR_API void gpr_cmdline_on_extra_arg(
85
+ GPRAPI void gpr_cmdline_on_extra_arg(
86
86
  gpr_cmdline *cl, const char *name, const char *help,
87
87
  void (*on_extra_arg)(void *user_data, const char *arg), void *user_data);
88
88
  /* Enable surviving failure: default behavior is to exit the process */
89
- GPR_API void gpr_cmdline_set_survive_failure(gpr_cmdline *cl);
89
+ GPRAPI void gpr_cmdline_set_survive_failure(gpr_cmdline *cl);
90
90
  /* Parse the command line; returns 1 on success, on failure either dies
91
91
  (by default) or returns 0 if gpr_cmdline_set_survive_failure() has been
92
92
  called */
93
- GPR_API int gpr_cmdline_parse(gpr_cmdline *cl, int argc, char **argv);
93
+ GPRAPI int gpr_cmdline_parse(gpr_cmdline *cl, int argc, char **argv);
94
94
  /* Destroy the parser */
95
- GPR_API void gpr_cmdline_destroy(gpr_cmdline *cl);
95
+ GPRAPI void gpr_cmdline_destroy(gpr_cmdline *cl);
96
96
  /* Get a string describing usage */
97
- GPR_API char *gpr_cmdline_usage_string(gpr_cmdline *cl, const char *argv0);
97
+ GPRAPI char *gpr_cmdline_usage_string(gpr_cmdline *cl, const char *argv0);
98
98
 
99
99
  #ifdef __cplusplus
100
100
  }
@@ -44,13 +44,13 @@ extern "C" {
44
44
 
45
45
  /* Return the number of CPU cores on the current system. Will return 0 if
46
46
  the information is not available. */
47
- GPR_API unsigned gpr_cpu_num_cores(void);
47
+ GPRAPI unsigned gpr_cpu_num_cores(void);
48
48
 
49
49
  /* Return the CPU on which the current thread is executing; N.B. This should
50
50
  be considered advisory only - it is possible that the thread is switched
51
51
  to a different CPU at any time. Returns a value in range
52
52
  [0, gpr_cpu_num_cores() - 1] */
53
- GPR_API unsigned gpr_cpu_current_cpu(void);
53
+ GPRAPI unsigned gpr_cpu_current_cpu(void);
54
54
 
55
55
  #ifdef __cplusplus
56
56
  } // extern "C"
@@ -43,34 +43,34 @@ extern "C" {
43
43
 
44
44
  typedef struct gpr_histogram gpr_histogram;
45
45
 
46
- GPR_API gpr_histogram *gpr_histogram_create(double resolution,
47
- double max_bucket_start);
48
- GPR_API void gpr_histogram_destroy(gpr_histogram *h);
49
- GPR_API void gpr_histogram_add(gpr_histogram *h, double x);
46
+ GPRAPI gpr_histogram *gpr_histogram_create(double resolution,
47
+ double max_bucket_start);
48
+ GPRAPI void gpr_histogram_destroy(gpr_histogram *h);
49
+ GPRAPI void gpr_histogram_add(gpr_histogram *h, double x);
50
50
 
51
51
  /* The following merges the second histogram into the first. It only works
52
52
  if they have the same buckets and resolution. Returns 0 on failure, 1
53
53
  on success */
54
- GPR_API int gpr_histogram_merge(gpr_histogram *dst, const gpr_histogram *src);
54
+ GPRAPI int gpr_histogram_merge(gpr_histogram *dst, const gpr_histogram *src);
55
55
 
56
- GPR_API double gpr_histogram_percentile(gpr_histogram *histogram,
57
- double percentile);
58
- GPR_API double gpr_histogram_mean(gpr_histogram *histogram);
59
- GPR_API double gpr_histogram_stddev(gpr_histogram *histogram);
60
- GPR_API double gpr_histogram_variance(gpr_histogram *histogram);
61
- GPR_API double gpr_histogram_maximum(gpr_histogram *histogram);
62
- GPR_API double gpr_histogram_minimum(gpr_histogram *histogram);
63
- GPR_API double gpr_histogram_count(gpr_histogram *histogram);
64
- GPR_API double gpr_histogram_sum(gpr_histogram *histogram);
65
- GPR_API double gpr_histogram_sum_of_squares(gpr_histogram *histogram);
56
+ GPRAPI double gpr_histogram_percentile(gpr_histogram *histogram,
57
+ double percentile);
58
+ GPRAPI double gpr_histogram_mean(gpr_histogram *histogram);
59
+ GPRAPI double gpr_histogram_stddev(gpr_histogram *histogram);
60
+ GPRAPI double gpr_histogram_variance(gpr_histogram *histogram);
61
+ GPRAPI double gpr_histogram_maximum(gpr_histogram *histogram);
62
+ GPRAPI double gpr_histogram_minimum(gpr_histogram *histogram);
63
+ GPRAPI double gpr_histogram_count(gpr_histogram *histogram);
64
+ GPRAPI double gpr_histogram_sum(gpr_histogram *histogram);
65
+ GPRAPI double gpr_histogram_sum_of_squares(gpr_histogram *histogram);
66
66
 
67
- GPR_API const uint32_t *gpr_histogram_get_contents(gpr_histogram *histogram,
68
- size_t *count);
69
- GPR_API void gpr_histogram_merge_contents(gpr_histogram *histogram,
70
- const uint32_t *data,
71
- size_t data_count, double min_seen,
72
- double max_seen, double sum,
73
- double sum_of_squares, double count);
67
+ GPRAPI const uint32_t *gpr_histogram_get_contents(gpr_histogram *histogram,
68
+ size_t *count);
69
+ GPRAPI void gpr_histogram_merge_contents(gpr_histogram *histogram,
70
+ const uint32_t *data,
71
+ size_t data_count, double min_seen,
72
+ double max_seen, double sum,
73
+ double sum_of_squares, double count);
74
74
 
75
75
  #ifdef __cplusplus
76
76
  }
@@ -50,14 +50,14 @@ extern "C" {
50
50
  destroyed using gpr_free().
51
51
 
52
52
  In the unlikely event of an error, returns -1 and sets *out to NULL. */
53
- GPR_API int gpr_join_host_port(char **out, const char *host, int port);
53
+ GPRAPI int gpr_join_host_port(char **out, const char *host, int port);
54
54
 
55
55
  /* Given a name in the form "host:port" or "[ho:st]:port", split into hostname
56
56
  and port number, into newly allocated strings, which must later be
57
57
  destroyed using gpr_free().
58
58
  Return 1 on success, 0 on failure. Guarantees *host and *port == NULL on
59
59
  failure. */
60
- GPR_API int gpr_split_host_port(const char *name, char **host, char **port);
60
+ GPRAPI int gpr_split_host_port(const char *name, char **host, char **port);
61
61
 
62
62
  #ifdef __cplusplus
63
63
  }