| Index: third_party/grpc/test/core/iomgr/socket_utils_test.c
|
| diff --git a/third_party/tcmalloc/vendor/src/base/spinlock_posix-inl.h b/third_party/grpc/test/core/iomgr/socket_utils_test.c
|
| similarity index 65%
|
| copy from third_party/tcmalloc/vendor/src/base/spinlock_posix-inl.h
|
| copy to third_party/grpc/test/core/iomgr/socket_utils_test.c
|
| index e1d43b7db29fb7076d7d4b2012ea309bc05c7fdc..58c3fbc0ae3e561ad870dd2487f4c8de6e3d422f 100644
|
| --- a/third_party/tcmalloc/vendor/src/base/spinlock_posix-inl.h
|
| +++ b/third_party/grpc/test/core/iomgr/socket_utils_test.c
|
| @@ -1,10 +1,12 @@
|
| -/* Copyright (c) 2009, Google Inc.
|
| +/*
|
| + *
|
| + * 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
|
| * met:
|
| - *
|
| + *
|
| * * Redistributions of source code must retain the above copyright
|
| * notice, this list of conditions and the following disclaimer.
|
| * * Redistributions in binary form must reproduce the above
|
| @@ -14,7 +16,7 @@
|
| * * Neither the name of Google Inc. nor the names of its
|
| * contributors may be used to endorse or promote products derived from
|
| * this software without specific prior written permission.
|
| - *
|
| + *
|
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
| @@ -27,36 +29,34 @@
|
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| *
|
| - * ---
|
| - * This file is a Posix-specific part of spinlock_internal.cc
|
| */
|
|
|
| -#include <config.h>
|
| +#include <grpc/support/port_platform.h>
|
| +#include "src/core/iomgr/socket_utils_posix.h"
|
| +
|
| #include <errno.h>
|
| -#ifdef HAVE_SCHED_H
|
| -#include <sched.h> /* For sched_yield() */
|
| -#endif
|
| -#include <time.h> /* For nanosleep() */
|
| -
|
| -namespace base {
|
| -namespace internal {
|
| -
|
| -void SpinLockDelay(volatile Atomic32 *w, int32 value, int loop) {
|
| - int save_errno = errno;
|
| - if (loop == 0) {
|
| - } else if (loop == 1) {
|
| - sched_yield();
|
| - } else {
|
| - struct timespec tm;
|
| - tm.tv_sec = 0;
|
| - tm.tv_nsec = base::internal::SuggestedDelayNS(loop);
|
| - nanosleep(&tm, NULL);
|
| - }
|
| - errno = save_errno;
|
| -}
|
| +#include <string.h>
|
|
|
| -void SpinLockWake(volatile Atomic32 *w, bool all) {
|
| -}
|
| +#include <grpc/support/log.h>
|
| +#include "test/core/util/test_config.h"
|
| +
|
| +int main(int argc, char **argv) {
|
| + int sock;
|
| + grpc_test_init(argc, argv);
|
| +
|
| + sock = socket(PF_INET, SOCK_STREAM, 0);
|
| + GPR_ASSERT(sock > 0);
|
|
|
| -} // namespace internal
|
| -} // namespace base
|
| + GPR_ASSERT(grpc_set_socket_nonblocking(sock, 1));
|
| + GPR_ASSERT(grpc_set_socket_nonblocking(sock, 0));
|
| + GPR_ASSERT(grpc_set_socket_cloexec(sock, 1));
|
| + GPR_ASSERT(grpc_set_socket_cloexec(sock, 0));
|
| + GPR_ASSERT(grpc_set_socket_reuse_addr(sock, 1));
|
| + GPR_ASSERT(grpc_set_socket_reuse_addr(sock, 0));
|
| + GPR_ASSERT(grpc_set_socket_low_latency(sock, 1));
|
| + GPR_ASSERT(grpc_set_socket_low_latency(sock, 0));
|
| +
|
| + close(sock);
|
| +
|
| + return 0;
|
| +}
|
|
|