aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc/impl/codegen/slice.h
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2016-12-05 08:07:13 -0800
committerGravatar GitHub <noreply@github.com>2016-12-05 08:07:13 -0800
commit2d317fbc575742704797033fce284ef234bf021a (patch)
treee3b60c4ac529001fea8fdc0a9fa5fe4005deb1fc /include/grpc/impl/codegen/slice.h
parentf7a75460ade9dcf502a62b7e9ffb4de78500bbc5 (diff)
Revert "Revert "Remove redundant includes from string.h and tmpfile.h""
Diffstat (limited to 'include/grpc/impl/codegen/slice.h')
-rw-r--r--include/grpc/impl/codegen/slice.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/grpc/impl/codegen/slice.h b/include/grpc/impl/codegen/slice.h
index 774ba0e95d..06fed046a9 100644
--- a/include/grpc/impl/codegen/slice.h
+++ b/include/grpc/impl/codegen/slice.h
@@ -37,6 +37,8 @@
#include <stddef.h>
#include <stdint.h>
+#include <grpc/impl/codegen/gpr_slice.h>
+
/* Slice API
A slice represents a contiguous reference counted array of bytes.
@@ -115,4 +117,23 @@ typedef struct {
GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(slice)
#define GRPC_SLICE_IS_EMPTY(slice) (GRPC_SLICE_LENGTH(slice) == 0)
+
+#ifdef GRPC_ALLOW_GPR_SLICE_FUNCTIONS
+
+/* Duplicate GPR_* definitions */
+#define GPR_SLICE_START_PTR(slice) \
+ ((slice).refcount ? (slice).data.refcounted.bytes \
+ : (slice).data.inlined.bytes)
+#define GPR_SLICE_LENGTH(slice) \
+ ((slice).refcount ? (slice).data.refcounted.length \
+ : (slice).data.inlined.length)
+#define GPR_SLICE_SET_LENGTH(slice, newlen) \
+ ((slice).refcount ? ((slice).data.refcounted.length = (size_t)(newlen)) \
+ : ((slice).data.inlined.length = (uint8_t)(newlen)))
+#define GPR_SLICE_END_PTR(slice) \
+ GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(slice)
+#define GPR_SLICE_IS_EMPTY(slice) (GRPC_SLICE_LENGTH(slice) == 0)
+
+#endif /* GRPC_ALLOW_GPR_SLICE_FUNCTIONS */
+
#endif /* GRPC_IMPL_CODEGEN_SLICE_H */