aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support
diff options
context:
space:
mode:
authorGravatar Jan Tattermusch <jtattermusch@google.com>2015-12-04 09:33:05 -0800
committerGravatar Jan Tattermusch <jtattermusch@google.com>2015-12-07 17:59:27 -0800
commit4b3ecdf765b5d15e3ae65e6d977d56d2272bddd0 (patch)
tree8a8df2d56935b7d8eb7bdbde0ba4d784a816aad9 /src/core/support
parent56bab33bbfbb374d2262c58d03c5bb0e9523b497 (diff)
make grpc compile on win64bit
Diffstat (limited to 'src/core/support')
-rw-r--r--src/core/support/string.c21
-rw-r--r--src/core/support/string.h10
2 files changed, 31 insertions, 0 deletions
diff --git a/src/core/support/string.c b/src/core/support/string.c
index e0ffeb8a4a..fad0b4008b 100644
--- a/src/core/support/string.c
+++ b/src/core/support/string.c
@@ -173,6 +173,27 @@ int gpr_ltoa(long value, char *string) {
return i;
}
+int gpr_int64toa(gpr_int64 value, char *string) {
+ int i = 0;
+ int neg = value < 0;
+
+ if (value == 0) {
+ string[0] = '0';
+ string[1] = 0;
+ return 1;
+ }
+
+ if (neg) value = -value;
+ while (value) {
+ string[i++] = (char)('0' + value % 10);
+ value /= 10;
+ }
+ if (neg) string[i++] = '-';
+ gpr_reverse_bytes(string, i);
+ string[i] = 0;
+ return i;
+}
+
char *gpr_strjoin(const char **strs, size_t nstrs, size_t *final_length) {
return gpr_strjoin_sep(strs, nstrs, "", final_length);
}
diff --git a/src/core/support/string.h b/src/core/support/string.h
index a28e00fd3e..9b604ac5bf 100644
--- a/src/core/support/string.h
+++ b/src/core/support/string.h
@@ -70,6 +70,16 @@ int gpr_parse_bytes_to_uint32(const char *data, size_t length,
output must be at least GPR_LTOA_MIN_BUFSIZE bytes long. */
int gpr_ltoa(long value, char *output);
+/* Minimum buffer size for calling int64toa */
+#define GPR_INT64TOA_MIN_BUFSIZE (3 * sizeof(gpr_int64))
+
+/* Convert an int64 to a string in base 10; returns the length of the
+output string (or 0 on failure).
+output must be at least GPR_INT64TOA_MIN_BUFSIZE bytes long.
+NOTE: This function ensures sufficient bit width even on Win x64,
+where long is 32bit is size.*/
+int gpr_int64toa(gpr_int64 value, char *output);
+
/* Reverse a run of bytes */
void gpr_reverse_bytes(char *str, int len);