Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2347)

Unified Diff: third_party/grpc/src/core/iomgr/endpoint_pair_posix.c

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/grpc/src/core/iomgr/endpoint_pair_posix.c
diff --git a/third_party/WebKit/Source/build/win/Precompile.h b/third_party/grpc/src/core/iomgr/endpoint_pair_posix.c
similarity index 51%
copy from third_party/WebKit/Source/build/win/Precompile.h
copy to third_party/grpc/src/core/iomgr/endpoint_pair_posix.c
index 8a0ff29c353fc1d30c92d27f369d7c422a579bc8..56f6f146fd34ad164f4d238bd127fe71939b3d24 100644
--- a/third_party/WebKit/Source/build/win/Precompile.h
+++ b/third_party/grpc/src/core/iomgr/endpoint_pair_posix.c
@@ -1,5 +1,7 @@
/*
- * Copyright (C) 2012 Google Inc. All rights reserved.
+ *
+ * Copyright 2015, 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,55 @@
* 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_SOCKET
-#include <Windows.h>
+#include "src/core/iomgr/endpoint_pair.h"
+#include "src/core/iomgr/socket_utils_posix.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 <sys/types.h>
+#include <sys/socket.h>
-#include <algorithm>
-#include <ciso646>
-#include <cmath>
-#include <cstddef>
-#include <limits>
-#include <string>
-#include <utility>
+#include "src/core/iomgr/tcp_posix.h"
+#include "src/core/support/string.h"
+#include <grpc/support/alloc.h>
+#include <grpc/support/log.h>
+#include <grpc/support/string_util.h>
+
+static void create_sockets(int sv[2]) {
+ int flags;
+ GPR_ASSERT(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) == 0);
+ flags = fcntl(sv[0], F_GETFL, 0);
+ GPR_ASSERT(fcntl(sv[0], F_SETFL, flags | O_NONBLOCK) == 0);
+ flags = fcntl(sv[1], F_GETFL, 0);
+ GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0);
+ GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv[0]));
+ GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv[1]));
+}
+
+grpc_endpoint_pair grpc_iomgr_create_endpoint_pair(const char *name,
+ size_t read_slice_size) {
+ int sv[2];
+ grpc_endpoint_pair p;
+ char *final_name;
+ create_sockets(sv);
+
+ gpr_asprintf(&final_name, "%s:client", name);
+ p.client = grpc_tcp_create(grpc_fd_create(sv[1], final_name), read_slice_size,
+ "socketpair-server");
+ gpr_free(final_name);
+ gpr_asprintf(&final_name, "%s:server", name);
+ p.server = grpc_tcp_create(grpc_fd_create(sv[0], final_name), read_slice_size,
+ "socketpair-client");
+ gpr_free(final_name);
+ return p;
+}
+
+#endif
« no previous file with comments | « third_party/grpc/src/core/iomgr/endpoint_pair.h ('k') | third_party/grpc/src/core/iomgr/endpoint_pair_windows.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698