diff options
author | Alistair Veitch <aveitch@google.com> | 2016-02-03 09:02:46 -0800 |
---|---|---|
committer | Alistair Veitch <aveitch@google.com> | 2016-02-03 09:02:46 -0800 |
commit | 6f2b8993fdf67aa59966c11f73f9d188a2717b42 (patch) | |
tree | 25a1f373b5ce62178135069151cfe30c29389ae9 /src/core | |
parent | ddb163a0e43f9225be067e244b9f06f38a3313e7 (diff) | |
parent | 6b4ec07ec9028e6c4727a3f1b83a166087d44f11 (diff) |
merge
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/support/subprocess_windows.c | 4 | ||||
-rw-r--r-- | src/core/support/time_posix.c | 13 | ||||
-rw-r--r-- | src/core/support/wrap_memcpy.c | 50 |
3 files changed, 63 insertions, 4 deletions
diff --git a/src/core/support/subprocess_windows.c b/src/core/support/subprocess_windows.c index d48c5437f0..2b25ef063a 100644 --- a/src/core/support/subprocess_windows.c +++ b/src/core/support/subprocess_windows.c @@ -59,7 +59,7 @@ gpr_subprocess *gpr_subprocess_create(int argc, const char **argv) { STARTUPINFO si; PROCESS_INFORMATION pi; - char *args = gpr_strjoin_sep(argv, argc, " ", NULL); + char *args = gpr_strjoin_sep(argv, (size_t)argc, " ", NULL); TCHAR *args_tchar; args_tchar = gpr_char_to_tchar(args); @@ -119,7 +119,7 @@ getExitCode: return 0; } if (GetExitCodeProcess(p->pi.hProcess, &dwExitCode)) { - return dwExitCode; + return (int)dwExitCode; } else { return -1; // failed to get exit code } diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c index 06bb78c913..1f92d7f090 100644 --- a/src/core/support/time_posix.c +++ b/src/core/support/time_posix.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015, Google Inc. + * Copyright 2015-2016, Google Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,6 +39,9 @@ #include <stdlib.h> #include <time.h> #include <unistd.h> +#ifdef __linux__ +#include <sys/syscall.h> +#endif #include <grpc/support/log.h> #include <grpc/support/time.h> #include "src/core/support/block_annotate.h" @@ -70,7 +73,8 @@ static gpr_timespec gpr_from_timespec(struct timespec ts, } /** maps gpr_clock_type --> clockid_t for clock_gettime */ -static clockid_t clockid_for_gpr_clock[] = {CLOCK_MONOTONIC, CLOCK_REALTIME}; +static const clockid_t clockid_for_gpr_clock[] = {CLOCK_MONOTONIC, + CLOCK_REALTIME}; void gpr_time_init(void) { gpr_precise_clock_init(); } @@ -82,7 +86,12 @@ gpr_timespec gpr_now(gpr_clock_type clock_type) { gpr_precise_clock_now(&ret); return ret; } else { +#if defined(__linux__) && !defined(GPR_NO_DIRECT_SYSCALLS) + /* avoid ABI problems by invoking syscalls directly */ + syscall(SYS_clock_gettime, clockid_for_gpr_clock[clock_type], &now); +#else clock_gettime(clockid_for_gpr_clock[clock_type], &now); +#endif return gpr_from_timespec(now, clock_type); } } diff --git a/src/core/support/wrap_memcpy.c b/src/core/support/wrap_memcpy.c new file mode 100644 index 0000000000..ac30668ec1 --- /dev/null +++ b/src/core/support/wrap_memcpy.c @@ -0,0 +1,50 @@ +/* + * + * Copyright 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 + * 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 + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * 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 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * 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. + * + */ + +#include <string.h> + +/* Provide a wrapped memcpy for targets that need to be backwards + * compatible with older libc's. + * + * Enable by setting LDFLAGS=-Wl,-wrap,memcpy when linking. + */ + +#ifdef __linux__ +#ifdef __x86_64__ +__asm__(".symver memcpy,memcpy@GLIBC_2.2.5"); +#endif + +void *__wrap_memcpy(void *destination, const void *source, size_t num) { + return memcpy(destination, source, num); +} +#endif |