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

Side by Side Diff: nspr/lib/ds/plarena.h

Issue 1504923011: Update NSS to 3.21 RTM and NSPR to 4.11 RTM (Closed) Base URL: http://src.chromium.org/svn/trunk/deps/third_party/nss
Patch Set: Created 5 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public 2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 5
6 #ifndef plarena_h___ 6 #ifndef plarena_h___
7 #define plarena_h___ 7 #define plarena_h___
8 /* 8 /*
9 * Lifetime-based fast allocation, inspired by much prior art, including 9 * Lifetime-based fast allocation, inspired by much prior art, including
10 * "Fast Allocation and Deallocation of Memory Based on Object Lifetimes" 10 * "Fast Allocation and Deallocation of Memory Based on Object Lifetimes"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 #define PL_INIT_ARENA_POOL(pool, name, size) \ 131 #define PL_INIT_ARENA_POOL(pool, name, size) \
132 PL_InitArenaPool(pool, name, size, PL_ARENA_CONST_ALIGN_MASK + 1) 132 PL_InitArenaPool(pool, name, size, PL_ARENA_CONST_ALIGN_MASK + 1)
133 #else 133 #else
134 #define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + (pool)->mask) & ~(pool)->mask) 134 #define PL_ARENA_ALIGN(pool, n) (((PRUword)(n) + (pool)->mask) & ~(pool)->mask)
135 #endif 135 #endif
136 136
137 #define PL_ARENA_ALLOCATE(p, pool, nb) \ 137 #define PL_ARENA_ALLOCATE(p, pool, nb) \
138 PR_BEGIN_MACRO \ 138 PR_BEGIN_MACRO \
139 PLArena *_a = (pool)->current; \ 139 PLArena *_a = (pool)->current; \
140 PRUint32 _nb = PL_ARENA_ALIGN(pool, nb); \ 140 PRUint32 _nb = PL_ARENA_ALIGN(pool, (PRUint32)nb); \
141 PRUword _p = _a->avail; \ 141 PRUword _p = _a->avail; \
142 if (_nb < nb) { \ 142 if (_nb < (PRUint32)nb) { \
143 _p = 0; \ 143 _p = 0; \
144 } else if (_nb > (_a->limit - _a->avail)) { \ 144 } else if (_nb > (_a->limit - _a->avail)) { \
145 _p = (PRUword)PL_ArenaAllocate(pool, _nb); \ 145 _p = (PRUword)PL_ArenaAllocate(pool, _nb); \
146 } else { \ 146 } else { \
147 _a->avail += _nb; \ 147 _a->avail += _nb; \
148 } \ 148 } \
149 p = (void *)_p; \ 149 p = (void *)_p; \
150 if (p) { \ 150 if (p) { \
151 PL_MAKE_MEM_UNDEFINED(p, nb); \ 151 PL_MAKE_MEM_UNDEFINED(p, (PRUint32)nb); \
152 PL_ArenaCountAllocation(pool, nb); \ 152 PL_ArenaCountAllocation(pool, (PRUint32)nb); \
153 } \ 153 } \
154 PR_END_MACRO 154 PR_END_MACRO
155 155
156 #define PL_ARENA_GROW(p, pool, size, incr) \ 156 #define PL_ARENA_GROW(p, pool, size, incr) \
157 PR_BEGIN_MACRO \ 157 PR_BEGIN_MACRO \
158 PLArena *_a = (pool)->current; \ 158 PLArena *_a = (pool)->current; \
159 PRUint32 _incr = PL_ARENA_ALIGN(pool, incr); \ 159 PRUint32 _incr = PL_ARENA_ALIGN(pool, (PRUint32)incr); \
160 if (_incr < incr) { \ 160 if (_incr < (PRUint32)incr) { \
161 p = NULL; \ 161 p = NULL; \
162 } else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \ 162 } else if (_a->avail == (PRUword)(p) + PL_ARENA_ALIGN(pool, size) && \
163 _incr <= (_a->limit - _a->avail)) { \ 163 _incr <= (_a->limit - _a->avail)) { \
164 PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, incr); \ 164 PL_MAKE_MEM_UNDEFINED((unsigned char *)(p) + size, (PRUint32)incr); \
165 _a->avail += _incr; \ 165 _a->avail += _incr; \
166 PL_ArenaCountInplaceGrowth(pool, size, incr); \ 166 PL_ArenaCountInplaceGrowth(pool, size, (PRUint32)incr); \
167 } else { \ 167 } else { \
168 p = PL_ArenaGrow(pool, p, size, incr); \ 168 p = PL_ArenaGrow(pool, p, size, (PRUint32)incr); \
169 } \ 169 } \
170 if (p) {\ 170 if (p) {\
171 PL_ArenaCountGrowth(pool, size, incr); \ 171 PL_ArenaCountGrowth(pool, size, (PRUint32)incr); \
172 } \ 172 } \
173 PR_END_MACRO 173 PR_END_MACRO
174 174
175 #define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail) 175 #define PL_ARENA_MARK(pool) ((void *) (pool)->current->avail)
176 #define PR_UPTRDIFF(p,q) ((PRUword)(p) - (PRUword)(q)) 176 #define PR_UPTRDIFF(p,q) ((PRUword)(p) - (PRUword)(q))
177 177
178 #define PL_CLEAR_UNUSED_PATTERN(a, pattern) \ 178 #define PL_CLEAR_UNUSED_PATTERN(a, pattern) \
179 PR_BEGIN_MACRO \ 179 PR_BEGIN_MACRO \
180 PR_ASSERT((a)->avail <= (a)->limit); \ 180 PR_ASSERT((a)->avail <= (a)->limit); \
181 PL_MAKE_MEM_UNDEFINED((void*)(a)->avail, (a)->limit - (a)->avail); \ 181 PL_MAKE_MEM_UNDEFINED((void*)(a)->avail, (a)->limit - (a)->avail); \
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 #define PL_ArenaCountInplaceGrowth(ap, size, incr) /* nothing */ 249 #define PL_ArenaCountInplaceGrowth(ap, size, incr) /* nothing */
250 #define PL_ArenaCountGrowth(ap, size, incr) /* nothing */ 250 #define PL_ArenaCountGrowth(ap, size, incr) /* nothing */
251 #define PL_ArenaCountRelease(ap, mark) /* nothing */ 251 #define PL_ArenaCountRelease(ap, mark) /* nothing */
252 #define PL_ArenaCountRetract(ap, mark) /* nothing */ 252 #define PL_ArenaCountRetract(ap, mark) /* nothing */
253 253
254 #endif /* !PL_ARENAMETER */ 254 #endif /* !PL_ARENAMETER */
255 255
256 PR_END_EXTERN_C 256 PR_END_EXTERN_C
257 257
258 #endif /* plarena_h___ */ 258 #endif /* plarena_h___ */
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698