| Index: third_party/grpc/test/core/util/parse_hexstring.c
|
| diff --git a/third_party/tcmalloc/chromium/src/base/synchronization_profiling.h b/third_party/grpc/test/core/util/parse_hexstring.c
|
| similarity index 64%
|
| copy from third_party/tcmalloc/chromium/src/base/synchronization_profiling.h
|
| copy to third_party/grpc/test/core/util/parse_hexstring.c
|
| index cf02c218a111806189f71f7b528a83b5ceb164a4..3ad7ce5828b06a53994236f2c9eda8560dda76e9 100644
|
| --- a/third_party/tcmalloc/chromium/src/base/synchronization_profiling.h
|
| +++ b/third_party/grpc/test/core/util/parse_hexstring.c
|
| @@ -1,4 +1,6 @@
|
| -/* Copyright (c) 2010, Google Inc.
|
| +/*
|
| + *
|
| + * Copyright 2015, Google Inc.
|
| * All rights reserved.
|
| *
|
| * Redistribution and use in source and binary forms, with or without
|
| @@ -27,24 +29,42 @@
|
| * (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: Chris Ruemmler
|
| */
|
|
|
| -#ifndef BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_
|
| -#define BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_
|
| +#include "test/core/util/parse_hexstring.h"
|
| +#include <grpc/support/log.h>
|
| +
|
| +gpr_slice parse_hexstring(const char *hexstring) {
|
| + size_t nibbles = 0;
|
| + const char *p = 0;
|
| + uint8_t *out;
|
| + uint8_t temp;
|
| + gpr_slice slice;
|
| +
|
| + for (p = hexstring; *p; p++) {
|
| + nibbles += (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f');
|
| + }
|
|
|
| -#include "base/basictypes.h"
|
| + GPR_ASSERT((nibbles & 1) == 0);
|
|
|
| -namespace base {
|
| + slice = gpr_slice_malloc(nibbles / 2);
|
| + out = GPR_SLICE_START_PTR(slice);
|
|
|
| -// We can do contention-profiling of SpinLocks, but the code is in
|
| -// mutex.cc, which is not always linked in with spinlock. Hence we
|
| -// provide a weak definition, which are used if mutex.cc isn't linked in.
|
| + nibbles = 0;
|
| + temp = 0;
|
| + for (p = hexstring; *p; p++) {
|
| + if (*p >= '0' && *p <= '9') {
|
| + temp = (uint8_t)(temp << 4) | (uint8_t)(*p - '0');
|
| + nibbles++;
|
| + } else if (*p >= 'a' && *p <= 'f') {
|
| + temp = (uint8_t)(temp << 4) | (uint8_t)(*p - 'a' + 10);
|
| + nibbles++;
|
| + }
|
| + if (nibbles == 2) {
|
| + *out++ = temp;
|
| + nibbles = 0;
|
| + }
|
| + }
|
|
|
| -// Submit the number of cycles the spinlock spent contending.
|
| -ATTRIBUTE_WEAK extern void SubmitSpinLockProfileData(const void *, int64);
|
| -extern void SubmitSpinLockProfileData(const void *contendedlock,
|
| - int64 wait_cycles) {}
|
| + return slice;
|
| }
|
| -#endif // BASE_AUXILIARY_SYNCHRONIZATION_PROFILING_H_
|
|
|