Line data Source code
1 : /*
2 : * SPDX-License-Identifier: MPL-2.0
3 : *
4 : * This Source Code Form is subject to the terms of the Mozilla Public
5 : * License, v. 2.0. If a copy of the MPL was not distributed with this
6 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 : *
8 : * Copyright 2024 MonetDB Foundation;
9 : * Copyright August 2008 - 2023 MonetDB B.V.;
10 : * Copyright 1997 - July 2008 CWI.
11 : */
12 :
13 : /* This file should not be included in any file outside of this directory */
14 :
15 : #ifndef LIBGDK
16 : #error this file should not be included outside its source directory
17 : #endif
18 :
19 : /* only check whether we exceed gdk_vm_maxsize when allocating heaps */
20 : #define SIZE_CHECK_IN_HEAPS_ONLY 1
21 :
22 : #include "gdk_system_private.h"
23 :
24 : enum heaptype {
25 : offheap,
26 : varheap,
27 : hashheap,
28 : orderidxheap,
29 : strimpheap,
30 : dataheap
31 : };
32 :
33 : enum range_comp_t {
34 : range_before, /* search range fully before bat range */
35 : range_after, /* search range fully after bat range */
36 : range_atstart, /* search range before + inside */
37 : range_atend, /* search range inside + after */
38 : range_contains, /* search range contains bat range */
39 : range_inside, /* search range inside bat range */
40 : };
41 :
42 : bool ATOMisdescendant(int id, int parentid)
43 : __attribute__((__visibility__("hidden")));
44 : int ATOMunknown_find(const char *nme)
45 : __attribute__((__warn_unused_result__))
46 : __attribute__((__visibility__("hidden")));
47 : const char *ATOMunknown_name(int a)
48 : __attribute__((__visibility__("hidden")));
49 : void ATOMunknown_clean(void)
50 : __attribute__((__visibility__("hidden")));
51 : bool BATcheckhash(BAT *b)
52 : __attribute__((__visibility__("hidden")));
53 : gdk_return BATcheckmodes(BAT *b, bool persistent)
54 : __attribute__((__warn_unused_result__))
55 : __attribute__((__visibility__("hidden")));
56 : BAT *BATcreatedesc(oid hseq, int tt, bool heapnames, role_t role, uint16_t width)
57 : __attribute__((__visibility__("hidden")));
58 : void BATdelete(BAT *b)
59 : __attribute__((__visibility__("hidden")));
60 : void BATdestroy(BAT *b)
61 : __attribute__((__visibility__("hidden")));
62 : void BATfree(BAT *b)
63 : __attribute__((__visibility__("hidden")));
64 : gdk_return BATgroup_internal(BAT **groups, BAT **extents, BAT **histo, BAT *b, BAT *s, BAT *g, BAT *e, BAT *h, bool subsorted)
65 : __attribute__((__warn_unused_result__))
66 : __attribute__((__visibility__("hidden")));
67 : Hash *BAThash_impl(BAT *restrict b, struct canditer *restrict ci, const char *restrict ext)
68 : __attribute__((__visibility__("hidden")));
69 : void BAThashsave(BAT *b, bool dosync)
70 : __attribute__((__visibility__("hidden")));
71 : bool BATiscand(BAT *b)
72 : __attribute__((__visibility__("hidden")));
73 : BAT *BATload_intern(bat bid, bool lock)
74 : __attribute__((__visibility__("hidden")));
75 : gdk_return BATmaterialize(BAT *b, BUN cap)
76 : __attribute__((__warn_unused_result__))
77 : __attribute__((__visibility__("hidden")));
78 : gdk_return BATsave_iter(BAT *bd, BATiter *bi, BUN size)
79 : __attribute__((__visibility__("hidden")));
80 : void BATsetdims(BAT *b, uint16_t width)
81 : __attribute__((__visibility__("hidden")));
82 : gdk_return BBPcacheit(BAT *bn, bool lock)
83 : __attribute__((__warn_unused_result__))
84 : __attribute__((__visibility__("hidden")));
85 : gdk_return BBPchkfarms(void)
86 : __attribute__((__warn_unused_result__))
87 : __attribute__((__visibility__("hidden")));
88 : void BBPclear(bat bid)
89 : __attribute__((__visibility__("hidden")));
90 : void BBPdump(void) /* never called: for debugging only */
91 : __attribute__((__cold__));
92 : void BBPexit(void)
93 : __attribute__((__visibility__("hidden")));
94 : gdk_return BBPinit(bool allow_hge_upgrade)
95 : __attribute__((__visibility__("hidden")));
96 : bat BBPallocbat(int tt)
97 : __attribute__((__warn_unused_result__))
98 : __attribute__((__visibility__("hidden")));
99 : void BBPprintinfo(void)
100 : __attribute__((__visibility__("hidden")));
101 : int BBPselectfarm(role_t role, int type, enum heaptype hptype)
102 : __attribute__((__visibility__("hidden")));
103 : gdk_return BBPsync(int cnt, bat *restrict subcommit, BUN *restrict sizes, lng logno)
104 : __attribute__((__visibility__("hidden")));
105 : BUN binsearch(const oid *restrict indir, oid offset, int type, const void *restrict vals, const char * restrict vars, int width, BUN lo, BUN hi, const void *restrict v, int ordering, int last)
106 : __attribute__((__visibility__("hidden")));
107 : BUN binsearch_bte(const oid *restrict indir, oid offset, const bte *restrict vals, BUN lo, BUN hi, bte v, int ordering, int last)
108 : __attribute__((__visibility__("hidden")));
109 : BUN binsearch_sht(const oid *restrict indir, oid offset, const sht *restrict vals, BUN lo, BUN hi, sht v, int ordering, int last)
110 : __attribute__((__visibility__("hidden")));
111 : BUN binsearch_int(const oid *restrict indir, oid offset, const int *restrict vals, BUN lo, BUN hi, int v, int ordering, int last)
112 : __attribute__((__visibility__("hidden")));
113 : BUN binsearch_lng(const oid *restrict indir, oid offset, const lng *restrict vals, BUN lo, BUN hi, lng v, int ordering, int last)
114 : __attribute__((__visibility__("hidden")));
115 : #ifdef HAVE_HGE
116 : BUN binsearch_hge(const oid *restrict indir, oid offset, const hge *restrict vals, BUN lo, BUN hi, hge v, int ordering, int last)
117 : __attribute__((__visibility__("hidden")));
118 : #endif
119 : BUN binsearch_flt(const oid *restrict indir, oid offset, const flt *restrict vals, BUN lo, BUN hi, flt v, int ordering, int last)
120 : __attribute__((__visibility__("hidden")));
121 : BUN binsearch_dbl(const oid *restrict indir, oid offset, const dbl *restrict vals, BUN lo, BUN hi, dbl v, int ordering, int last)
122 : __attribute__((__visibility__("hidden")));
123 : Heap *createOIDXheap(BAT *b, bool stable)
124 : __attribute__((__visibility__("hidden")));
125 : void doHASHdestroy(BAT *b, Hash *hs)
126 : __attribute__((__visibility__("hidden")));
127 : void gdk_bbp_reset(void)
128 : __attribute__((__visibility__("hidden")));
129 : gdk_return GDKextend(const char *fn, size_t size)
130 : __attribute__((__warn_unused_result__))
131 : __attribute__((__visibility__("hidden")));
132 : gdk_return GDKextendf(int fd, size_t size, const char *fn)
133 : __attribute__((__warn_unused_result__))
134 : __attribute__((__visibility__("hidden")));
135 : int GDKfdlocate(int farmid, const char *nme, const char *mode, const char *ext)
136 : __attribute__((__visibility__("hidden")));
137 : FILE *GDKfilelocate(int farmid, const char *nme, const char *mode, const char *ext)
138 : __attribute__((__visibility__("hidden")));
139 : FILE *GDKfileopen(int farmid, const char *dir, const char *name, const char *extension, const char *mode)
140 : __attribute__((__visibility__("hidden")));
141 : char *GDKload(int farmid, const char *nme, const char *ext, size_t size, size_t *maxsize, storage_t mode)
142 : __attribute__((__visibility__("hidden")));
143 : gdk_return GDKmove(int farmid, const char *dir1, const char *nme1, const char *ext1, const char *dir2, const char *nme2, const char *ext2, bool report)
144 : __attribute__((__warn_unused_result__))
145 : __attribute__((__visibility__("hidden")));
146 : void *GDKmremap(const char *path, int mode, void *old_address, size_t old_size, size_t *new_size)
147 : __attribute__((__visibility__("hidden")));
148 : gdk_return GDKremovedir(int farmid, const char *nme)
149 : __attribute__((__warn_unused_result__))
150 : __attribute__((__visibility__("hidden")));
151 : gdk_return GDKsave(int farmid, const char *nme, const char *ext, void *buf, size_t size, storage_t mode, bool dosync)
152 : __attribute__((__warn_unused_result__))
153 : __attribute__((__visibility__("hidden")));
154 : gdk_return GDKrsort(void *restrict h, void *restrict t, size_t n, size_t hs, size_t ts, bool reverse, bool isuuid)
155 : __attribute__((__warn_unused_result__))
156 : __attribute__((__visibility__("hidden")));
157 : gdk_return GDKssort_rev(void *restrict h, void *restrict t, const void *restrict base, size_t n, int hs, int ts, int tpe)
158 : __attribute__((__warn_unused_result__))
159 : __attribute__((__visibility__("hidden")));
160 : gdk_return GDKssort(void *restrict h, void *restrict t, const void *restrict base, size_t n, int hs, int ts, int tpe)
161 : __attribute__((__warn_unused_result__))
162 : __attribute__((__visibility__("hidden")));
163 : gdk_return GDKtracer_init(const char *dbname, const char *dbtrace)
164 : __attribute__((__visibility__("hidden")));
165 : gdk_return GDKunlink(int farmid, const char *dir, const char *nme, const char *extension)
166 : __attribute__((__visibility__("hidden")));
167 : #define GDKwarning(...) \
168 : GDKtracer_log(__FILE__, __func__, __LINE__, M_WARNING, \
169 : GDK, NULL, __VA_ARGS__)
170 : lng getBBPlogno(void)
171 : __attribute__((__visibility__("hidden")));
172 : BUN HASHappend(BAT *b, BUN i, const void *v)
173 : __attribute__((__visibility__("hidden")));
174 : void HASHappend_locked(BAT *b, BUN i, const void *v)
175 : __attribute__((__visibility__("hidden")));
176 : void HASHfree(BAT *b)
177 : __attribute__((__visibility__("hidden")));
178 : BUN HASHdelete(BATiter *bi, BUN p, const void *v)
179 : __attribute__((__visibility__("hidden")));
180 : void HASHdelete_locked(BATiter *bi, BUN p, const void *v)
181 : __attribute__((__visibility__("hidden")));
182 : BUN HASHinsert(BATiter *bi, BUN p, const void *v)
183 : __attribute__((__visibility__("hidden")));
184 : void HASHinsert_locked(BATiter *bi, BUN p, const void *v)
185 : __attribute__((__visibility__("hidden")));
186 : static inline BUN __attribute__((__const__))
187 848249 : HASHmask(BUN cnt)
188 : {
189 848249 : cnt = cnt * 8 / 7;
190 848249 : if (cnt < BATTINY)
191 33664 : cnt = BATTINY;
192 603436 : return cnt;
193 : }
194 : gdk_return HASHnew(Hash *h, int tpe, BUN size, BUN mask, BUN count, bool bcktonly)
195 : __attribute__((__visibility__("hidden")));
196 : gdk_return HEAPalloc(Heap *h, size_t nitems, size_t itemsize)
197 : __attribute__((__warn_unused_result__))
198 : __attribute__((__visibility__("hidden")));
199 : gdk_return HEAPcopy(Heap *dst, Heap *src, size_t offset)
200 : __attribute__((__warn_unused_result__))
201 : __attribute__((__visibility__("hidden")));
202 : void HEAPfree(Heap *h, bool remove)
203 : __attribute__((__visibility__("hidden")));
204 : gdk_return HEAPgrow(Heap **old, size_t size, bool mayshare)
205 : __attribute__((__visibility__("hidden")));
206 : gdk_return HEAPload(Heap *h, const char *nme, const char *ext, bool trunc)
207 : __attribute__((__warn_unused_result__))
208 : __attribute__((__visibility__("hidden")));
209 : void HEAP_recover(Heap *, const var_t *, BUN)
210 : __attribute__((__visibility__("hidden")));
211 : gdk_return HEAPsave(Heap *h, const char *nme, const char *ext, bool dosync, BUN free, MT_Lock *lock)
212 : __attribute__((__warn_unused_result__))
213 : __attribute__((__visibility__("hidden")));
214 : double joincost(BAT *r, BUN lcount, struct canditer *rci, bool *hash, bool *phash, bool *cand)
215 : __attribute__((__visibility__("hidden")));
216 : void STRMPincref(Strimps *strimps)
217 : __attribute__((__visibility__("hidden")));
218 : void STRMPdecref(Strimps *strimps, bool remove)
219 : __attribute__((__visibility__("hidden")));
220 : void STRMPfree(BAT *b)
221 : __attribute__((__visibility__("hidden")));
222 : void MT_init_posix(void)
223 : __attribute__((__visibility__("hidden")));
224 : void *MT_mmap(const char *path, int mode, size_t len)
225 : __attribute__((__visibility__("hidden")));
226 : void *MT_mremap(const char *path, int mode, void *old_address, size_t old_size, size_t *new_size)
227 : __attribute__((__visibility__("hidden")));
228 : int MT_msync(void *p, size_t len)
229 : __attribute__((__visibility__("hidden")));
230 : int MT_munmap(void *p, size_t len)
231 : __attribute__((__visibility__("hidden")));
232 : void OIDXfree(BAT *b)
233 : __attribute__((__visibility__("hidden")));
234 : void persistOIDX(BAT *b)
235 : __attribute__((__visibility__("hidden")));
236 : void PROPdestroy(BAT *b)
237 : __attribute__((__visibility__("hidden")));
238 : void PROPdestroy_nolock(BAT *b)
239 : __attribute__((__visibility__("hidden")));
240 : void settailname(Heap *restrict tail, const char *restrict physnme, int tt, int width)
241 : __attribute__((__visibility__("hidden")));
242 : void strCleanHash(Heap *hp, bool rebuild)
243 : __attribute__((__visibility__("hidden")));
244 : gdk_return strHeap(Heap *d, size_t cap)
245 : __attribute__((__visibility__("hidden")));
246 : var_t strLocate(Heap *h, const char *v)
247 : __attribute__((__visibility__("hidden")));
248 : var_t strPut(BAT *b, var_t *dst, const void *v)
249 : __attribute__((__visibility__("hidden")));
250 : char *strRead(str a, size_t *dstlen, stream *s, size_t cnt)
251 : __attribute__((__visibility__("hidden")));
252 : ssize_t strToStr(char **restrict dst, size_t *restrict len, const char *restrict src, bool external)
253 : __attribute__((__visibility__("hidden")));
254 : gdk_return strWrite(const char *a, stream *s, size_t cnt)
255 : __attribute__((__visibility__("hidden")));
256 : gdk_return TMcommit(void)
257 : __attribute__((__visibility__("hidden")));
258 : gdk_return unshare_varsized_heap(BAT *b)
259 : __attribute__((__warn_unused_result__))
260 : __attribute__((__visibility__("hidden")));
261 : void VIEWdestroy(BAT *b)
262 : __attribute__((__visibility__("hidden")));
263 : BAT *virtualize(BAT *bn)
264 : __attribute__((__visibility__("hidden")));
265 :
266 : /* calculate the integer 2 logarithm (i.e. position of highest set
267 : * bit) of the argument (with a slight twist: 0 gives 0, 1 gives 1,
268 : * 0x8 to 0xF give 4, etc.) */
269 : static inline unsigned
270 11961 : ilog2(BUN x)
271 : {
272 11961 : if (x == 0)
273 : return 0;
274 : #ifdef __has_builtin
275 : #if SIZEOF_BUN == 8 && __has_builtin(__builtin_clzll)
276 11961 : return (unsigned) (64 - __builtin_clzll((unsigned long long) x));
277 : #define BUILTIN_USED
278 : #elif __has_builtin(__builtin_clz)
279 : return (unsigned) (32 - __builtin_clz((unsigned) x));
280 : #define BUILTIN_USED
281 : #endif
282 : #endif
283 : #ifndef BUILTIN_USED
284 : #if defined(_MSC_VER)
285 : unsigned long n;
286 : if (
287 : #if SIZEOF_BUN == 8
288 : _BitScanReverse64(&n, (unsigned __int64) x)
289 : #else
290 : _BitScanReverse(&n, (unsigned long) x)
291 : #endif
292 : )
293 : return (unsigned) n + 1;
294 : else
295 : return 0;
296 : #else
297 : unsigned n = 0;
298 : BUN y;
299 :
300 : /* use a "binary search" method */
301 : #if SIZEOF_BUN == 8
302 : if ((y = x >> 32) != 0) {
303 : x = y;
304 : n += 32;
305 : }
306 : #endif
307 : if ((y = x >> 16) != 0) {
308 : x = y;
309 : n += 16;
310 : }
311 : if ((y = x >> 8) != 0) {
312 : x = y;
313 : n += 8;
314 : }
315 : if ((y = x >> 4) != 0) {
316 : x = y;
317 : n += 4;
318 : }
319 : if ((y = x >> 2) != 0) {
320 : x = y;
321 : n += 2;
322 : }
323 : if ((y = x >> 1) != 0) {
324 : x = y;
325 : n += 1;
326 : }
327 : return n + (x != 0);
328 : #endif
329 : #endif
330 : #undef BUILTIN_USED
331 : }
332 :
333 : /* some macros to help print info about BATs when using ALGODEBUG */
334 : #define ALGOBATFMT "%s#" BUNFMT "@" OIDFMT "[%s%s]%s%s%s%s%s%s%s%s%s"
335 : #define ALGOBATPAR(b) \
336 : BATgetId(b), \
337 : BATcount(b), \
338 : b->hseqbase, \
339 : ATOMname(b->ttype), \
340 : b->ttype==TYPE_str?b->twidth==1?"1":b->twidth==2?"2":b->twidth==4?"4":"8":"", \
341 : !b->batTransient ? "P" : b->theap && b->theap->parentid != b->batCacheid ? "V" : b->tvheap && b->tvheap->parentid != b->batCacheid ? "v" : "T", \
342 : BATtdense(b) ? "D" : b->ttype == TYPE_void && b->tvheap ? "X" : ATOMstorage(b->ttype) == TYPE_str && GDK_ELIMDOUBLES(b->tvheap) ? "E" : "", \
343 : b->tsorted ? "S" : b->tnosorted ? "!s" : "", \
344 : b->trevsorted ? "R" : b->tnorevsorted ? "!r" : "", \
345 : b->tkey ? "K" : b->tnokey[1] ? "!k" : "", \
346 : b->tnonil ? "N" : "", \
347 : b->thash ? "H" : "", \
348 : b->torderidx ? "O" : "", \
349 : b->tstrimps ? "I" : b->theap && b->theap->parentid && BBP_desc(b->theap->parentid) && BBP_desc(b->theap->parentid)->tstrimps ? "(I)" : ""
350 : /* use ALGOOPTBAT* when BAT is optional (can be NULL) */
351 : #define ALGOOPTBATFMT "%s%s" BUNFMT "%s" OIDFMT "%s%s%s%s%s%s%s%s%s%s%s%s%s"
352 : #define ALGOOPTBATPAR(b) \
353 : b ? BATgetId(b) : "", \
354 : b ? "#" : "", \
355 : b ? BATcount(b) : 0, \
356 : b ? "@" : "", \
357 : b ? b->hseqbase : 0, \
358 : b ? "[" : "", \
359 : b ? ATOMname(b->ttype) : "", \
360 : b ? b->ttype==TYPE_str?b->twidth==1?"1":b->twidth==2?"2":b->twidth==4?"4":"8":"" : "", \
361 : b ? "]" : "", \
362 : b ? !b->batTransient ? "P" : b->theap && b->theap->parentid != b->batCacheid ? "V" : b->tvheap && b->tvheap->parentid != b->batCacheid ? "v" : "T" : "", \
363 : b ? BATtdense(b) ? "D" : b->ttype == TYPE_void && b->tvheap ? "X" : ATOMstorage(b->ttype) == TYPE_str && b->tvheap && GDK_ELIMDOUBLES(b->tvheap) ? "E" : "" : "", \
364 : b ? b->tsorted ? "S" : b->tnosorted ? "!s" : "" : "", \
365 : b ? b->trevsorted ? "R" : b->tnorevsorted ? "!r" : "" : "", \
366 : b ? b->tkey ? "K" : b->tnokey[1] ? "!k" : "" : "", \
367 : b && b->tnonil ? "N" : "", \
368 : b && b->thash ? "H" : "", \
369 : b && b->torderidx ? "O" : "", \
370 : b ? b->tstrimps ? "I" : b->theap && b->theap->parentid && BBP_desc(b->theap->parentid) && BBP_desc(b->theap->parentid)->tstrimps ? "(I)" : "" : ""
371 :
372 : #ifdef __SANITIZE_THREAD__
373 : #define BBP_BATMASK 31
374 : #else
375 : #define BBP_BATMASK ((1 << (SIZEOF_SIZE_T + 5)) - 1)
376 : #endif
377 :
378 : struct PROPrec {
379 : enum prop_t id;
380 : ValRecord v;
381 : struct PROPrec *next; /* simple chain of properties */
382 : };
383 :
384 : typedef uint64_t strimp_masks_t; /* TODO: make this a sparse matrix */
385 :
386 : struct Strimps {
387 : Heap strimps;
388 : uint8_t *sizes_base; /* pointer into strimps heap (pair sizes) */
389 : uint8_t *pairs_base; /* pointer into strimps heap (pairs start) */
390 : void *bitstrings_base; /* pointer into strimps heap (bitstrings
391 : * start) bitstrings_base is a pointer
392 : * to uint64_t */
393 : size_t rec_cnt; /* reconstruction counter: how many
394 : * bitstrings were added after header
395 : * construction. Currently unused. */
396 : strimp_masks_t *masks; /* quick access to masks for
397 : * bitstring construction */
398 : };
399 :
400 : typedef struct {
401 : MT_Lock swap;
402 : } batlock_t;
403 :
404 : typedef char long_str[IDLENGTH]; /* standard GDK static string */
405 :
406 : #define MAXFARMS 32
407 :
408 : extern struct BBPfarm_t {
409 : uint32_t roles; /* bitmask of allowed roles */
410 : const char *dirname; /* farm directory */
411 : FILE *lock_file;
412 : } BBPfarms[MAXFARMS];
413 :
414 : extern batlock_t GDKbatLock[BBP_BATMASK + 1];
415 : extern size_t GDK_mmap_minsize_persistent; /* size after which we use memory mapped files for persistent heaps */
416 : extern size_t GDK_mmap_minsize_transient; /* size after which we use memory mapped files for transient heaps */
417 : extern size_t GDK_mmap_pagesize; /* mmap granularity */
418 :
419 : #define BATcheck(tst, err) \
420 : do { \
421 : if ((tst) == NULL) { \
422 : GDKerror("BAT required.\n"); \
423 : return (err); \
424 : } \
425 : } while (0)
426 : #define ERRORcheck(tst, msg, err) \
427 : do { \
428 : if (tst) { \
429 : GDKerror(msg); \
430 : return (err); \
431 : } \
432 : } while (0)
433 :
434 : #define GDKswapLock(x) GDKbatLock[(x)&BBP_BATMASK].swap
435 :
436 : #define HEAPREMOVE ((ATOMIC_BASE_TYPE) 1 << (sizeof(ATOMIC_BASE_TYPE) * 8 - 1))
437 : #define DELAYEDREMOVE ((ATOMIC_BASE_TYPE) 1 << (sizeof(ATOMIC_BASE_TYPE) * 8 - 2))
438 : #define HEAPREFS (((ATOMIC_BASE_TYPE) 1 << (sizeof(ATOMIC_BASE_TYPE) * 8 - 2)) - 1)
439 :
440 : /* when the number of updates to a BAT is less than 1 in this number, we
441 : * keep the unique_est property */
442 : #define GDK_UNIQUE_ESTIMATE_KEEP_FRACTION 1000
443 : extern BUN gdk_unique_estimate_keep_fraction; /* should become a define once */
444 : /* if the number of unique values is less than 1 in this number, we
445 : * destroy the hash rather than update it in HASH{append,insert,delete} */
446 : #define HASH_DESTROY_UNIQUES_FRACTION 1000
447 : extern BUN hash_destroy_uniques_fraction; /* likewise */
448 : /* if the estimated number of unique values is less than 1 in this
449 : * number, don't build a hash table to do a hashselect */
450 : #define NO_HASH_SELECT_FRACTION 1000
451 : extern dbl no_hash_select_fraction; /* same here */
452 : /* if the hash chain is longer than this number, we delete the hash
453 : * rather than maintaining it in HASHdelete */
454 : #define HASH_DESTROY_CHAIN_LENGTH 1000
455 : extern BUN hash_destroy_chain_length;
456 :
457 : #if !defined(NDEBUG) && !defined(__COVERITY__)
458 : /* see comment in gdk.h */
459 : #ifdef __GNUC__
460 : #define GDKmremap(p, m, oa, os, ns) \
461 : ({ \
462 : const char *_path = (p); \
463 : int _mode = (m); \
464 : void *_oa = (oa); \
465 : size_t _os = (os); \
466 : size_t *_ns = (ns); \
467 : size_t _ons = *_ns; \
468 : void *_res = GDKmremap(_path, _mode, _oa, _os, _ns); \
469 : TRC_DEBUG(ALLOC, \
470 : "GDKmremap(%s,0x%x,%p,%zu,%zu > %zu) -> %p\n", \
471 : _path ? _path : "NULL", (unsigned) _mode, \
472 : _oa, _os, _ons, *_ns, _res); \
473 : _res; \
474 : })
475 : #else
476 : static inline void *
477 : GDKmremap_debug(const char *path, int mode, void *old_address, size_t old_size, size_t *new_size)
478 : {
479 : size_t orig_new_size = *new_size;
480 : void *res = GDKmremap(path, mode, old_address, old_size, new_size);
481 : TRC_DEBUG(ALLOC, "GDKmremap(%s,0x%x,%p,%zu,%zu > %zu) -> %p\n",
482 : path ? path : "NULL", (unsigned) mode,
483 : old_address, old_size, orig_new_size, *new_size, res);
484 : return res;
485 : }
486 : #define GDKmremap(p, m, oa, os, ns) GDKmremap_debug(p, m, oa, os, ns)
487 :
488 : #endif
489 : #endif
|