Index: third_party/grpc/src/core/support/env_win32.c |
diff --git a/third_party/tcmalloc/vendor/src/base/linuxthreads.h b/third_party/grpc/src/core/support/env_win32.c |
similarity index 63% |
copy from third_party/tcmalloc/vendor/src/base/linuxthreads.h |
copy to third_party/grpc/src/core/support/env_win32.c |
index 5c318fed7ec4c47e7bf082e315992e102abcd620..10258283bafe46703841205aa541e6ea9bcf7a72 100644 |
--- a/third_party/tcmalloc/vendor/src/base/linuxthreads.h |
+++ b/third_party/grpc/src/core/support/env_win32.c |
@@ -1,4 +1,6 @@ |
-/* Copyright (c) 2005-2007, Google Inc. |
+/* |
+ * |
+ * Copyright 2015-2016, Google Inc. |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
@@ -27,27 +29,45 @@ |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
* |
- * --- |
- * Author: Markus Gutschke |
*/ |
-#ifndef _LINUXTHREADS_H |
-#define _LINUXTHREADS_H |
+#include <grpc/support/port_platform.h> |
-/* Include thread_lister.h to get the interface that we implement for linux. |
- */ |
+#ifdef GPR_WIN32 |
-/* We currently only support x86-32 and x86-64 on Linux. Porting to other |
- * related platforms should not be difficult. |
- */ |
-#if (defined(__i386__) || defined(__x86_64__) || defined(__ARM_ARCH_3__) || \ |
- defined(__mips__) || defined(__PPC__)) && defined(__linux) |
- |
-/* Define the THREADS symbol to make sure that there is exactly one core dumper |
- * built into the library. |
- */ |
-#define THREADS "Linux /proc" |
+#include "src/core/support/env.h" |
+#include "src/core/support/string.h" |
+#ifdef __MINGW32__ |
+errno_t getenv_s(size_t *size_needed, char *buffer, size_t size, |
+ const char *varname); |
+#else |
+#include <stdlib.h> |
#endif |
-#endif /* _LINUXTHREADS_H */ |
+#include <grpc/support/alloc.h> |
+#include <grpc/support/log.h> |
+#include <grpc/support/string_util.h> |
+ |
+char *gpr_getenv(const char *name) { |
+ size_t size; |
+ char *result = NULL; |
+ errno_t err; |
+ |
+ err = getenv_s(&size, NULL, 0, name); |
+ if (err || (size == 0)) return NULL; |
+ result = gpr_malloc(size); |
+ err = getenv_s(&size, result, size, name); |
+ if (err) { |
+ gpr_free(result); |
+ return NULL; |
+ } |
+ return result; |
+} |
+ |
+void gpr_setenv(const char *name, const char *value) { |
+ errno_t res = _putenv_s(name, value); |
+ GPR_ASSERT(res == 0); |
+} |
+ |
+#endif /* GPR_WIN32 */ |