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

Unified Diff: third_party/grpc/include/grpc/impl/codegen/alloc.h

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
« no previous file with comments | « third_party/grpc/include/grpc/grpc_zookeeper.h ('k') | third_party/grpc/include/grpc/impl/codegen/atm.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/grpc/include/grpc/impl/codegen/alloc.h
diff --git a/third_party/tcmalloc/vendor/src/base/thread_lister.c b/third_party/grpc/include/grpc/impl/codegen/alloc.h
similarity index 53%
copy from third_party/tcmalloc/vendor/src/base/thread_lister.c
copy to third_party/grpc/include/grpc/impl/codegen/alloc.h
index bc180dba7a9f2ba3b8261009c8af85f0b1d4a023..235135443306c331720305d42e93f4facb42a8f3 100644
--- a/third_party/tcmalloc/vendor/src/base/thread_lister.c
+++ b/third_party/grpc/include/grpc/impl/codegen/alloc.h
@@ -1,4 +1,6 @@
-/* Copyright (c) 2005-2007, Google Inc.
+/*
+ *
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,51 +29,46 @@
* (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: Markus Gutschke
*/
-#include "config.h"
-#include <stdio.h> /* needed for NULL on some powerpc platforms (?!) */
-#ifdef HAVE_SYS_PRCTL
-# include <sys/prctl.h>
+#ifndef GRPC_IMPL_CODEGEN_ALLOC_H
+#define GRPC_IMPL_CODEGEN_ALLOC_H
+
+#include <stddef.h>
+
+#include <grpc/impl/codegen/port_platform.h>
+
+#ifdef __cplusplus
+extern "C" {
#endif
-#include "base/thread_lister.h"
-#include "base/linuxthreads.h"
-/* Include other thread listers here that define THREADS macro
- * only when they can provide a good implementation.
- */
-#ifndef THREADS
+typedef struct gpr_allocation_functions {
+ void *(*malloc_fn)(size_t size);
+ void *(*realloc_fn)(void *ptr, size_t size);
+ void (*free_fn)(void *ptr);
+} gpr_allocation_functions;
-/* Default trivial thread lister for single-threaded applications,
- * or if the multi-threading code has not been ported, yet.
- */
+/* malloc, never returns NULL */
+GPRAPI void *gpr_malloc(size_t size);
+/* free */
+GPRAPI void gpr_free(void *ptr);
+/* realloc, never returns NULL */
+GPRAPI void *gpr_realloc(void *p, size_t size);
+/* aligned malloc, never returns NULL, will align to 1 << alignment_log */
+GPRAPI void *gpr_malloc_aligned(size_t size, size_t alignment_log);
+/* free memory allocated by gpr_malloc_aligned */
+GPRAPI void gpr_free_aligned(void *ptr);
-int ListAllProcessThreads(void *parameter,
- ListAllProcessThreadsCallBack callback, ...) {
- int rc;
- va_list ap;
- pid_t pid;
+/** Request the family of allocation functions in \a functions be used. NOTE
+ * that this request will be honored in a *best effort* basis and that no
+ * guarantees are made about the default functions (eg, malloc) being called. */
+GPRAPI void gpr_set_allocation_functions(gpr_allocation_functions functions);
-#ifdef HAVE_SYS_PRCTL
- int dumpable = prctl(PR_GET_DUMPABLE, 0);
- if (!dumpable)
- prctl(PR_SET_DUMPABLE, 1);
-#endif
- va_start(ap, callback);
- pid = getpid();
- rc = callback(parameter, 1, &pid, ap);
- va_end(ap);
-#ifdef HAVE_SYS_PRCTL
- if (!dumpable)
- prctl(PR_SET_DUMPABLE, 0);
-#endif
- return rc;
-}
+/** Return the family of allocation functions currently in effect. */
+GPRAPI gpr_allocation_functions gpr_get_allocation_functions();
-int ResumeAllProcessThreads(int num_threads, pid_t *thread_pids) {
- return 1;
+#ifdef __cplusplus
}
+#endif
-#endif /* ifndef THREADS */
+#endif /* GRPC_IMPL_CODEGEN_ALLOC_H */
« no previous file with comments | « third_party/grpc/include/grpc/grpc_zookeeper.h ('k') | third_party/grpc/include/grpc/impl/codegen/atm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698