Index: third_party/grpc/src/core/support/tmpfile_posix.c |
diff --git a/third_party/WebKit/Source/build/win/Precompile.h b/third_party/grpc/src/core/support/tmpfile_posix.c |
similarity index 58% |
copy from third_party/WebKit/Source/build/win/Precompile.h |
copy to third_party/grpc/src/core/support/tmpfile_posix.c |
index 8a0ff29c353fc1d30c92d27f369d7c422a579bc8..b16eeacf9d4a9594060455ac07423cd8ba10748b 100644 |
--- a/third_party/WebKit/Source/build/win/Precompile.h |
+++ b/third_party/grpc/src/core/support/tmpfile_posix.c |
@@ -1,5 +1,7 @@ |
/* |
- * Copyright (C) 2012 Google Inc. All rights reserved. |
+ * |
+ * Copyright 2015-2016, Google Inc. |
+ * All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are |
@@ -26,43 +28,58 @@ |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
- */ |
- |
-/* |
- * Precompiled header for WebKit when built on Windows using |
- * GYP-generated project files. Not used by other build |
- * configurations. |
* |
- * Using precompiled headers speeds the build up significantly. On a |
- * fast machine (HP Z600, 12 GB of RAM), an ~18% decrease in full |
- * build time was measured. |
*/ |
-#if defined(WinPrecompile_h_) |
-#error You shouldn't include the precompiled header file more than once. |
-#endif |
- |
-#define WinPrecompile_h_ |
+#include <grpc/support/port_platform.h> |
-#define _USE_MATH_DEFINES // Make math.h behave like other platforms. |
+#ifdef GPR_POSIX_FILE |
-#include <Windows.h> |
+#include "src/core/support/tmpfile.h" |
#include <errno.h> |
-#include <fcntl.h> |
-#include <limits.h> |
-#include <math.h> |
-#include <stdarg.h> |
-#include <stddef.h> |
-#include <stdio.h> |
#include <stdlib.h> |
#include <string.h> |
-#include <time.h> |
+#include <unistd.h> |
+ |
+#include <grpc/support/alloc.h> |
+#include <grpc/support/log.h> |
+#include <grpc/support/string_util.h> |
+ |
+#include "src/core/support/string.h" |
+ |
+FILE *gpr_tmpfile(const char *prefix, char **tmp_filename) { |
+ FILE *result = NULL; |
+ char *template; |
+ int fd; |
+ |
+ if (tmp_filename != NULL) *tmp_filename = NULL; |
+ |
+ gpr_asprintf(&template, "/tmp/%s_XXXXXX", prefix); |
+ GPR_ASSERT(template != NULL); |
+ |
+ fd = mkstemp(template); |
+ if (fd == -1) { |
+ gpr_log(GPR_ERROR, "mkstemp failed for template %s with error %s.", |
+ template, strerror(errno)); |
+ goto end; |
+ } |
+ result = fdopen(fd, "w+"); |
+ if (result == NULL) { |
+ gpr_log(GPR_ERROR, "Could not open file %s from fd %d (error = %s).", |
+ template, fd, strerror(errno)); |
+ unlink(template); |
+ close(fd); |
+ goto end; |
+ } |
+ |
+end: |
+ if (result != NULL && tmp_filename != NULL) { |
+ *tmp_filename = template; |
+ } else { |
+ gpr_free(template); |
+ } |
+ return result; |
+} |
-#include <algorithm> |
-#include <ciso646> |
-#include <cmath> |
-#include <cstddef> |
-#include <limits> |
-#include <string> |
-#include <utility> |
+#endif /* GPR_POSIX_FILE */ |