Daily bump.
[official-gcc.git] / boehm-gc / include / gc_local_alloc.h
blob1e58730cfe811152892b83040b410a3157e68084
1 /*
2 * Copyright (c) 2000 by Hewlett-Packard Company. All rights reserved.
4 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
5 * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
7 * Permission is hereby granted to use or copy this program
8 * for any purpose, provided the above notices are retained on all copies.
9 * Permission to modify the code and to distribute modified code is granted,
10 * provided the above notices are retained, and a notice that the code was
11 * modified is included with the above copyright notice.
15 * Interface for thread local allocation. Memory obtained
16 * this way can be used by all threads, as though it were obtained
17 * from an allocator like GC_malloc. The difference is that GC_local_malloc
18 * counts the number of allocations of a given size from the current thread,
19 * and uses GC_malloc_many to perform the allocations once a threashold
20 * is exceeded. Thus far less synchronization may be needed.
21 * Allocation of known large objects should not use this interface.
22 * This interface is designed primarily for fast allocation of small
23 * objects on multiprocessors, e.g. for a JVM running on an MP server.
25 * If this file is included with GC_GCJ_SUPPORT defined, GCJ-style
26 * bitmap allocation primitives will also be included.
28 * If this file is included with GC_REDIRECT_TO_LOCAL defined, then
29 * GC_MALLOC, GC_MALLOC_ATOMIC, and possibly GC_GCJ_MALLOC will
30 * be redefined to use the thread local allocatoor.
32 * The interface is available only if the collector is built with
33 * -DTHREAD_LOCAL_ALLOC, which is currently supported only on Linux.
35 * The debugging allocators use standard, not thread-local allocation.
38 #ifndef GC_LOCAL_ALLOC_H
39 #define GC_LOCAL_ALLOC_H
41 #ifndef _GC_H
42 # include "gc.h"
43 #endif
45 #if defined(GC_GCJ_SUPPORT) && !defined(GC_GCJ_H)
46 # include "gc_gcj.h"
47 #endif
49 /* We assume ANSI C for this interface. */
51 GC_PTR GC_local_malloc(size_t bytes);
53 GC_PTR GC_local_malloc_atomic(size_t bytes);
55 #if defined(GC_GCJ_SUPPORT)
56 GC_PTR GC_local_gcj_malloc(size_t bytes,
57 void * ptr_to_struct_containing_descr);
58 #endif
60 # ifdef GC_DEBUG
61 # define GC_LOCAL_MALLOC(s) GC_debug_malloc(s,GC_EXTRAS)
62 # define GC_LOCAL_MALLOC_ATOMIC(s) GC_debug_malloc_atomic(s,GC_EXTRAS)
63 # ifdef GC_GCJ_SUPPORT
64 # define GC_LOCAL_GCJ_MALLOC(s,d) GC_debug_gcj_malloc(s,d,GC_EXTRAS)
65 # endif
66 # else
67 # define GC_LOCAL_MALLOC(s) GC_local_malloc(s)
68 # define GC_LOCAL_MALLOC_ATOMIC(s) GC_local_malloc_atomic(s)
69 # ifdef GC_GCJ_SUPPORT
70 # define GC_LOCAL_GCJ_MALLOC(s,d) GC_local_gcj_malloc(s,d)
71 # endif
72 # endif
74 # ifdef GC_REDIRECT_TO_LOCAL
75 # undef GC_MALLOC
76 # define GC_MALLOC(s) GC_LOCAL_MALLOC(s)
77 # undef GC_MALLOC_ATOMIC
78 # define GC_MALLOC_ATOMIC(s) GC_LOCAL_MALLOC_ATOMIC(s)
79 # ifdef GC_GCJ_SUPPORT
80 # undef GC_GCJ_MALLOC
81 # define GC_GCJ_MALLOC(s,d) GC_LOCAL_GCJ_MALLOC(s,d)
82 # endif
83 # endif
85 #endif /* GC_LOCAL_ALLOC_H */