mesh-rb 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/ext/mesh/extconf.rb +22 -4
  4. data/ext/mesh/mesh.tar.gz +0 -0
  5. data/lib/mesh/version.rb +1 -1
  6. data/mesh.gemspec +3 -2
  7. metadata +4 -120
  8. data/ext/mesh/mesh/.bazelrc +0 -20
  9. data/ext/mesh/mesh/.bazelversion +0 -1
  10. data/ext/mesh/mesh/.clang-format +0 -15
  11. data/ext/mesh/mesh/.dockerignore +0 -5
  12. data/ext/mesh/mesh/.editorconfig +0 -16
  13. data/ext/mesh/mesh/.gitattributes +0 -4
  14. data/ext/mesh/mesh/.github/workflows/main.yml +0 -144
  15. data/ext/mesh/mesh/.gitignore +0 -51
  16. data/ext/mesh/mesh/AUTHORS +0 -5
  17. data/ext/mesh/mesh/CMakeLists.txt +0 -270
  18. data/ext/mesh/mesh/CODE_OF_CONDUCT.md +0 -77
  19. data/ext/mesh/mesh/Dockerfile +0 -30
  20. data/ext/mesh/mesh/LICENSE +0 -201
  21. data/ext/mesh/mesh/Makefile +0 -81
  22. data/ext/mesh/mesh/README.md +0 -97
  23. data/ext/mesh/mesh/WORKSPACE +0 -50
  24. data/ext/mesh/mesh/bazel +0 -350
  25. data/ext/mesh/mesh/mesh-pldi19-powers.pdf +0 -0
  26. data/ext/mesh/mesh/src/BUILD +0 -222
  27. data/ext/mesh/mesh/src/CMakeLists.txt +0 -85
  28. data/ext/mesh/mesh/src/bitmap.h +0 -590
  29. data/ext/mesh/mesh/src/cheap_heap.h +0 -170
  30. data/ext/mesh/mesh/src/common.h +0 -377
  31. data/ext/mesh/mesh/src/copts.bzl +0 -31
  32. data/ext/mesh/mesh/src/d_assert.cc +0 -75
  33. data/ext/mesh/mesh/src/fixed_array.h +0 -124
  34. data/ext/mesh/mesh/src/global_heap.cc +0 -547
  35. data/ext/mesh/mesh/src/global_heap.h +0 -569
  36. data/ext/mesh/mesh/src/gnu_wrapper.cc +0 -75
  37. data/ext/mesh/mesh/src/internal.h +0 -356
  38. data/ext/mesh/mesh/src/libmesh.cc +0 -239
  39. data/ext/mesh/mesh/src/mac_wrapper.cc +0 -528
  40. data/ext/mesh/mesh/src/measure_rss.cc +0 -44
  41. data/ext/mesh/mesh/src/measure_rss.h +0 -20
  42. data/ext/mesh/mesh/src/meshable_arena.cc +0 -776
  43. data/ext/mesh/mesh/src/meshable_arena.h +0 -309
  44. data/ext/mesh/mesh/src/meshing.h +0 -60
  45. data/ext/mesh/mesh/src/mini_heap.h +0 -532
  46. data/ext/mesh/mesh/src/mmap_heap.h +0 -104
  47. data/ext/mesh/mesh/src/one_way_mmap_heap.h +0 -77
  48. data/ext/mesh/mesh/src/partitioned_heap.h +0 -111
  49. data/ext/mesh/mesh/src/plasma/mesh.h +0 -33
  50. data/ext/mesh/mesh/src/real.cc +0 -52
  51. data/ext/mesh/mesh/src/real.h +0 -36
  52. data/ext/mesh/mesh/src/rng/mwc.h +0 -296
  53. data/ext/mesh/mesh/src/rng/mwc64.h +0 -58
  54. data/ext/mesh/mesh/src/rpl_printf.c +0 -1991
  55. data/ext/mesh/mesh/src/runtime.cc +0 -393
  56. data/ext/mesh/mesh/src/runtime.h +0 -114
  57. data/ext/mesh/mesh/src/shuffle_vector.h +0 -287
  58. data/ext/mesh/mesh/src/size_classes.def +0 -251
  59. data/ext/mesh/mesh/src/static/if.h +0 -36
  60. data/ext/mesh/mesh/src/static/log.h +0 -43
  61. data/ext/mesh/mesh/src/testing/benchmark/local_refill.cc +0 -103
  62. data/ext/mesh/mesh/src/testing/big-alloc.c +0 -28
  63. data/ext/mesh/mesh/src/testing/fragmenter.cc +0 -128
  64. data/ext/mesh/mesh/src/testing/global-large-stress.cc +0 -25
  65. data/ext/mesh/mesh/src/testing/local-alloc.c +0 -16
  66. data/ext/mesh/mesh/src/testing/meshing_benchmark.cc +0 -189
  67. data/ext/mesh/mesh/src/testing/thread.cc +0 -35
  68. data/ext/mesh/mesh/src/testing/unit/alignment.cc +0 -56
  69. data/ext/mesh/mesh/src/testing/unit/bitmap_test.cc +0 -274
  70. data/ext/mesh/mesh/src/testing/unit/concurrent_mesh_test.cc +0 -185
  71. data/ext/mesh/mesh/src/testing/unit/mesh_test.cc +0 -143
  72. data/ext/mesh/mesh/src/testing/unit/rng_test.cc +0 -22
  73. data/ext/mesh/mesh/src/testing/unit/size_class_test.cc +0 -66
  74. data/ext/mesh/mesh/src/testing/unit/triple_mesh_test.cc +0 -285
  75. data/ext/mesh/mesh/src/testing/userfaultfd-kernel-copy.cc +0 -164
  76. data/ext/mesh/mesh/src/thread_local_heap.cc +0 -163
  77. data/ext/mesh/mesh/src/thread_local_heap.h +0 -268
  78. data/ext/mesh/mesh/src/wrapper.cc +0 -433
  79. data/ext/mesh/mesh/support/export_mesh.cmake +0 -28
  80. data/ext/mesh/mesh/support/gen-size-classes +0 -57
  81. data/ext/mesh/mesh/support/install_all_configs +0 -33
  82. data/ext/mesh/mesh/support/remove_export_mesh.cmake +0 -48
  83. data/ext/mesh/mesh/support/update-bazelisk +0 -8
  84. data/ext/mesh/mesh/theory/32m80.png +0 -0
  85. data/ext/mesh/mesh/theory/64m80ind.png +0 -0
  86. data/ext/mesh/mesh/theory/bound_comparison.py +0 -67
  87. data/ext/mesh/mesh/theory/bounds/impdeg+1 +0 -135
  88. data/ext/mesh/mesh/theory/choose.py +0 -43
  89. data/ext/mesh/mesh/theory/common.py +0 -42
  90. data/ext/mesh/mesh/theory/compute_exp_Y.py +0 -134
  91. data/ext/mesh/mesh/theory/createRandomString.py +0 -69
  92. data/ext/mesh/mesh/theory/deg_bound_check.py +0 -100
  93. data/ext/mesh/mesh/theory/degcheck.py +0 -47
  94. data/ext/mesh/mesh/theory/dumps/32,1,80,dumb.txt +0 -81
  95. data/ext/mesh/mesh/theory/dumps/32,2,80,dumb.txt +0 -81
  96. data/ext/mesh/mesh/theory/dumps/32,3,80,dumb.txt +0 -81
  97. data/ext/mesh/mesh/theory/dumps/32,4,80,dumb.txt +0 -81
  98. data/ext/mesh/mesh/theory/dumps/32,5,80,dumb.txt +0 -81
  99. data/ext/mesh/mesh/theory/dumps/32,6,80,dumb.txt +0 -81
  100. data/ext/mesh/mesh/theory/dumps/32,7,80,dumb.txt +0 -81
  101. data/ext/mesh/mesh/theory/dumps/32,8,80,dumb.txt +0 -81
  102. data/ext/mesh/mesh/theory/dumps/32,9,80,dumb.txt +0 -81
  103. data/ext/mesh/mesh/theory/experiment.py +0 -303
  104. data/ext/mesh/mesh/theory/experiment_raw_results/.gitignore +0 -0
  105. data/ext/mesh/mesh/theory/greedy_experiment.py +0 -66
  106. data/ext/mesh/mesh/theory/greedy_experiment_copy.py +0 -46
  107. data/ext/mesh/mesh/theory/greedy_experiment_q.py +0 -75
  108. data/ext/mesh/mesh/theory/makeGraph.py +0 -64
  109. data/ext/mesh/mesh/theory/manyreps.png +0 -0
  110. data/ext/mesh/mesh/theory/manystrings.png +0 -0
  111. data/ext/mesh/mesh/theory/match_vs_color_experiment.py +0 -94
  112. data/ext/mesh/mesh/theory/maxmatch_vs_E[Y].py +0 -162
  113. data/ext/mesh/mesh/theory/maxmatch_vs_greedymatch.py +0 -96
  114. data/ext/mesh/mesh/theory/maxvdeg+1imp++32,80.png +0 -0
  115. data/ext/mesh/mesh/theory/mesh_util.py +0 -322
  116. data/ext/mesh/mesh/theory/meshers.py +0 -452
  117. data/ext/mesh/mesh/theory/meshingBenchmark.py +0 -96
  118. data/ext/mesh/mesh/theory/occupancyComparison.py +0 -133
  119. data/ext/mesh/mesh/theory/randmatch_vs_greedymatch.py +0 -97
  120. data/ext/mesh/mesh/theory/randmatch_vs_greedymatch_q.py +0 -103
  121. data/ext/mesh/mesh/theory/randmatch_vs_greedymatch_time.py +0 -117
  122. data/ext/mesh/mesh/theory/read_mesh_dump.py +0 -82
  123. data/ext/mesh/mesh/theory/test.py +0 -70
  124. data/ext/mesh/mesh/tools/bazel +0 -1
@@ -1,433 +0,0 @@
1
- // -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil -*-
2
- // Copyright 2019 The Heap-Layers and Mesh Authors. All rights reserved.
3
- // Use of this source code is governed by the Apache License,
4
- // Version 2.0, that can be found in the LICENSE file.
5
-
6
- #include <stdint.h>
7
- #include <stdlib.h> // size_t
8
- #include <string.h> // for memcpy and memset
9
-
10
- #include <new>
11
-
12
- #include "common.h"
13
- #include "thread_local_heap.h"
14
-
15
- using namespace mesh;
16
-
17
- extern "C" {
18
-
19
- void *xxmalloc(size_t);
20
- void xxfree(void *);
21
-
22
- // Takes a pointer and returns how much space it holds.
23
- size_t xxmalloc_usable_size(void *);
24
-
25
- // Locks the heap(s), used prior to any invocation of fork().
26
- void xxmalloc_lock();
27
-
28
- // Unlocks the heap(s), after fork().
29
- void xxmalloc_unlock();
30
- }
31
-
32
- #if defined(__APPLE__)
33
- #include <malloc/malloc.h>
34
- #elif defined(__FreeBSD__)
35
- #include <stdlib.h>
36
- #else
37
- #include <malloc.h> // for memalign
38
- #endif
39
-
40
- #ifdef _WIN32
41
- #define WIN32_LEAN_AND_MEAN
42
- #include <windows.h>
43
- // Disable warnings about long (> 255 chars) identifiers.
44
- #pragma warning(disable : 4786)
45
- // Set inlining to the maximum possible depth.
46
- #pragma inline_depth(255)
47
- #pragma warning(disable : 4074) // initializers put in compiler reserved area
48
-
49
- #pragma comment(linker, "/disallowlib:libc.lib")
50
- #pragma comment(linker, "/disallowlib:libcd.lib")
51
- #pragma comment(linker, "/disallowlib:libcmt.lib")
52
- #pragma comment(linker, "/disallowlib:libcmtd.lib")
53
- #pragma comment(linker, "/disallowlib:msvcrtd.lib")
54
-
55
- #else
56
- #include <errno.h>
57
- #endif
58
-
59
- #ifndef CUSTOM_PREFIX
60
- #define CUSTOM_PREFIX(x) x
61
- #endif
62
-
63
- #define CUSTOM_MALLOC(x) CUSTOM_PREFIX(malloc)(x)
64
- #define CUSTOM_FREE(x) CUSTOM_PREFIX(free)(x)
65
- #define CUSTOM_CFREE(x) CUSTOM_PREFIX(cfree)(x)
66
- #define CUSTOM_REALLOC(x, y) CUSTOM_PREFIX(realloc)(x, y)
67
- #define CUSTOM_CALLOC(x, y) CUSTOM_PREFIX(calloc)(x, y)
68
- #define CUSTOM_MEMALIGN(x, y) CUSTOM_PREFIX(memalign)(x, y)
69
- #define CUSTOM_POSIX_MEMALIGN(x, y, z) CUSTOM_PREFIX(posix_memalign)(x, y, z)
70
- #define CUSTOM_ALIGNED_ALLOC(x, y) CUSTOM_PREFIX(aligned_alloc)(x, y)
71
- #define CUSTOM_GETSIZE(x) CUSTOM_PREFIX(malloc_usable_size)(x)
72
- #define CUSTOM_GOODSIZE(x) CUSTOM_PREFIX(malloc_good_size)(x)
73
- #define CUSTOM_VALLOC(x) CUSTOM_PREFIX(valloc)(x)
74
- #define CUSTOM_PVALLOC(x) CUSTOM_PREFIX(pvalloc)(x)
75
- #define CUSTOM_RECALLOC(x, y, z) CUSTOM_PREFIX(recalloc)(x, y, z)
76
- #define CUSTOM_STRNDUP(s, sz) CUSTOM_PREFIX(strndup)(s, sz)
77
- #define CUSTOM_STRDUP(s) CUSTOM_PREFIX(strdup)(s)
78
- #define CUSTOM_GETCWD(b, s) CUSTOM_PREFIX(getcwd)(b, s)
79
- #define CUSTOM_GETENV(s) CUSTOM_PREFIX(getenv)(s)
80
-
81
- // GNU-related routines:
82
- #define CUSTOM_MALLOPT(x, y) CUSTOM_PREFIX(mallopt)(x, y)
83
- #define CUSTOM_MALLOC_TRIM(s) CUSTOM_PREFIX(malloc_trim)(s)
84
- #define CUSTOM_MALLOC_STATS(a) CUSTOM_PREFIX(malloc_stats)(a)
85
- #define CUSTOM_MALLOC_GET_STATE(p) CUSTOM_PREFIX(malloc_get_state)(p)
86
- #define CUSTOM_MALLOC_SET_STATE(p) CUSTOM_PREFIX(malloc_set_state)(p)
87
- #define CUSTOM_MALLINFO(a) CUSTOM_PREFIX(mallinfo)(a)
88
-
89
- #if defined(_WIN32)
90
- #define MYCDECL __cdecl
91
- #if !defined(NO_INLINE)
92
- #define NO_INLINE __declspec(noinline)
93
- #endif
94
- #pragma inline_depth(255)
95
-
96
- #if !defined(NDEBUG)
97
- #define __forceinline inline
98
- #endif
99
-
100
- #else
101
- #define MYCDECL
102
- #endif
103
-
104
- /***** generic malloc functions *****/
105
-
106
- #include <stdio.h>
107
-
108
- // extern "C" void *MYCDECL CUSTOM_MALLOC(size_t);
109
-
110
- #if !defined(_WIN32)
111
- extern "C" MESH_EXPORT int CUSTOM_POSIX_MEMALIGN(void **memptr, size_t alignment, size_t size)
112
- #if !defined(__FreeBSD__) && !defined(__SVR4)
113
- throw()
114
- #endif
115
- {
116
- // Check for non power-of-two alignment.
117
- if ((alignment == 0) || (alignment & (alignment - 1))) {
118
- return EINVAL;
119
- }
120
- void *ptr = CUSTOM_MEMALIGN(alignment, size);
121
- if (!ptr) {
122
- return ENOMEM;
123
- } else {
124
- *memptr = ptr;
125
- return 0;
126
- }
127
- }
128
- #endif
129
-
130
- extern "C" MESH_EXPORT void *MYCDECL CUSTOM_ALIGNED_ALLOC(size_t alignment, size_t size)
131
- #if !defined(__FreeBSD__)
132
- throw()
133
- #endif
134
- {
135
- // Per the man page: "The function aligned_alloc() is the same as
136
- // memalign(), except for the added restriction that size should be
137
- // a multiple of alignment." Rather than check and potentially fail,
138
- // we just enforce this by rounding up the size, if necessary.
139
- size = size + alignment - (size % alignment);
140
- return CUSTOM_MEMALIGN(alignment, size);
141
- }
142
-
143
- extern "C" MESH_EXPORT void MYCDECL CUSTOM_CFREE(void *ptr) {
144
- xxfree(ptr);
145
- }
146
-
147
- extern "C" size_t MYCDECL CUSTOM_GOODSIZE(size_t sz) {
148
- void *ptr = xxmalloc(sz);
149
- size_t objSize = CUSTOM_GETSIZE(ptr);
150
- CUSTOM_FREE(ptr);
151
- return objSize;
152
- }
153
-
154
- #if defined(__linux)
155
-
156
- extern "C" MESH_EXPORT char *MYCDECL CUSTOM_STRNDUP(const char *s, size_t sz) {
157
- char *newString = NULL;
158
- if (s != NULL) {
159
- size_t cappedLength = strnlen(s, sz);
160
- if ((newString = (char *)xxmalloc(cappedLength + 1))) {
161
- strncpy(newString, s, cappedLength);
162
- newString[cappedLength] = '\0';
163
- }
164
- }
165
- return newString;
166
- }
167
- #endif
168
-
169
- extern "C" MESH_EXPORT char *MYCDECL CUSTOM_STRDUP(const char *src) {
170
- if (src == nullptr) {
171
- return nullptr;
172
- }
173
-
174
- // grab the string length once, use it for both malloc and strncpy calls
175
- const auto len = strlen(src) + 1;
176
- char *newString = reinterpret_cast<char *>(xxmalloc(len));
177
- if (newString != nullptr) {
178
- strncpy(newString, src, len);
179
- }
180
-
181
- return newString;
182
- }
183
-
184
- #if !defined(_WIN32)
185
- #include <dlfcn.h>
186
- #include <limits.h>
187
-
188
- #if !defined(RTLD_NEXT)
189
- #define RTLD_NEXT ((void *)-1)
190
- #endif
191
-
192
- typedef char *getcwdFunction(char *, size_t);
193
-
194
- extern "C" MESH_EXPORT char *MYCDECL CUSTOM_GETCWD(char *buf, size_t size) {
195
- static getcwdFunction *real_getcwd =
196
- reinterpret_cast<getcwdFunction *>(reinterpret_cast<uintptr_t>(dlsym(RTLD_NEXT, "getcwd")));
197
-
198
- if (!buf) {
199
- if (size == 0) {
200
- size = PATH_MAX;
201
- }
202
- buf = (char *)xxmalloc(size);
203
- }
204
- return (real_getcwd)(buf, size);
205
- }
206
-
207
- #endif
208
-
209
- extern "C" MESH_EXPORT int CUSTOM_MALLOPT(int /* param */, int /* value */) {
210
- // NOP.
211
- return 1; // success.
212
- }
213
-
214
- extern "C" MESH_EXPORT int CUSTOM_MALLOC_TRIM(size_t /* pad */) {
215
- // NOP.
216
- return 0; // no memory returned to OS.
217
- }
218
-
219
- extern "C" MESH_EXPORT void CUSTOM_MALLOC_STATS() {
220
- // NOP.
221
- }
222
-
223
- extern "C" MESH_EXPORT void *CUSTOM_MALLOC_GET_STATE() {
224
- return NULL; // always returns "error".
225
- }
226
-
227
- extern "C" MESH_EXPORT int CUSTOM_MALLOC_SET_STATE(void * /* ptr */) {
228
- return 0; // success.
229
- }
230
-
231
- #if defined(__GNUC__) && !defined(__FreeBSD__) && defined(__GLIBC__)
232
- extern "C" MESH_EXPORT struct mallinfo CUSTOM_MALLINFO() {
233
- // For now, we return useless stats.
234
- struct mallinfo m;
235
- m.arena = 0;
236
- m.ordblks = 0;
237
- m.smblks = 0;
238
- m.hblks = 0;
239
- m.hblkhd = 0;
240
- m.usmblks = 0;
241
- m.fsmblks = 0;
242
- m.uordblks = 0;
243
- m.fordblks = 0;
244
- m.keepcost = 0;
245
- return m;
246
- }
247
- #endif
248
-
249
- #if defined(__SVR4)
250
- // Apparently we no longer need to replace new and friends for Solaris.
251
- #define NEW_INCLUDED
252
- #endif
253
-
254
- #ifndef NEW_INCLUDED
255
- #define NEW_INCLUDED
256
-
257
- MESH_EXPORT CACHELINE_ALIGNED_FN void *
258
- operator new(size_t sz)
259
- #if defined(_GLIBCXX_THROW)
260
- _GLIBCXX_THROW(std::bad_alloc)
261
- #endif
262
- {
263
- ThreadLocalHeap *localHeap = ThreadLocalHeap::GetHeapIfPresent();
264
- if (unlikely(localHeap == nullptr)) {
265
- return mesh::cxxNewSlowpath(sz);
266
- }
267
-
268
- return localHeap->cxxNew(sz);
269
- }
270
-
271
- MESH_EXPORT CACHELINE_ALIGNED_FN void operator delete(void *ptr)
272
- #if !defined(linux_)
273
- throw()
274
- #endif
275
- {
276
- ThreadLocalHeap *localHeap = ThreadLocalHeap::GetHeapIfPresent();
277
- if (unlikely(localHeap == nullptr)) {
278
- mesh::freeSlowpath(ptr);
279
- return;
280
- }
281
-
282
- return localHeap->free(ptr);
283
- }
284
-
285
- #if !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x420
286
- MESH_EXPORT CACHELINE_ALIGNED_FN void *operator new(size_t sz, const std::nothrow_t &) throw() {
287
- ThreadLocalHeap *localHeap = ThreadLocalHeap::GetHeapIfPresent();
288
- if (unlikely(localHeap == nullptr)) {
289
- return mesh::allocSlowpath(sz);
290
- }
291
-
292
- return localHeap->malloc(sz);
293
- }
294
-
295
- MESH_EXPORT CACHELINE_ALIGNED_FN void *operator new[](size_t sz)
296
- #if defined(_GLIBCXX_THROW)
297
- _GLIBCXX_THROW(std::bad_alloc)
298
- #endif
299
- {
300
- ThreadLocalHeap *localHeap = ThreadLocalHeap::GetHeapIfPresent();
301
- if (unlikely(localHeap == nullptr)) {
302
- return mesh::cxxNewSlowpath(sz);
303
- }
304
-
305
- return localHeap->cxxNew(sz);
306
- }
307
-
308
- MESH_EXPORT CACHELINE_ALIGNED_FN void *operator new[](size_t sz, const std::nothrow_t &) throw() {
309
- ThreadLocalHeap *localHeap = ThreadLocalHeap::GetHeapIfPresent();
310
- if (unlikely(localHeap == nullptr)) {
311
- return mesh::allocSlowpath(sz);
312
- }
313
-
314
- return localHeap->malloc(sz);
315
- }
316
-
317
- MESH_EXPORT CACHELINE_ALIGNED_FN void operator delete[](void *ptr)
318
- #if defined(_GLIBCXX_USE_NOEXCEPT)
319
- _GLIBCXX_USE_NOEXCEPT
320
- #else
321
- #if defined(__GNUC__)
322
- // clang + libcxx on linux
323
- _NOEXCEPT
324
- #endif
325
- #endif
326
- {
327
- ThreadLocalHeap *localHeap = ThreadLocalHeap::GetHeapIfPresent();
328
- if (unlikely(localHeap == nullptr)) {
329
- mesh::freeSlowpath(ptr);
330
- return;
331
- }
332
-
333
- return localHeap->free(ptr);
334
- }
335
-
336
- #if defined(__cpp_sized_deallocation) && __cpp_sized_deallocation >= 201309
337
-
338
- MESH_EXPORT CACHELINE_ALIGNED_FN void operator delete(void *ptr, size_t sz)
339
- #if !defined(linux_)
340
- throw()
341
- #endif
342
- {
343
- ThreadLocalHeap *localHeap = ThreadLocalHeap::GetHeapIfPresent();
344
- if (unlikely(localHeap == nullptr)) {
345
- mesh::freeSlowpath(ptr);
346
- return;
347
- }
348
-
349
- return localHeap->sizedFree(ptr, sz);
350
- }
351
-
352
- MESH_EXPORT CACHELINE_ALIGNED_FN void operator delete[](void *ptr, size_t)
353
- #if defined(__GNUC__)
354
- _GLIBCXX_USE_NOEXCEPT
355
- #endif
356
- {
357
- ThreadLocalHeap *localHeap = ThreadLocalHeap::GetHeapIfPresent();
358
- if (unlikely(localHeap == nullptr)) {
359
- mesh::freeSlowpath(ptr);
360
- return;
361
- }
362
-
363
- return localHeap->free(ptr);
364
- }
365
- #endif
366
-
367
- #endif
368
- #endif
369
-
370
- /***** replacement functions for GNU libc extensions to malloc *****/
371
-
372
- extern "C" MESH_EXPORT void *MYCDECL CUSTOM_VALLOC(size_t sz) {
373
- return CUSTOM_MEMALIGN(4096UL, sz); // Default page size on most architectures.
374
- }
375
-
376
- extern "C" MESH_EXPORT void *MYCDECL CUSTOM_PVALLOC(size_t sz) {
377
- // Rounds up to the next pagesize and then calls valloc. Hoard
378
- // doesn't support aligned memory requests.
379
- return CUSTOM_VALLOC((sz + 4095UL) & ~4095UL);
380
- }
381
-
382
- // The wacky recalloc function, for Windows.
383
- extern "C" MESH_EXPORT void *MYCDECL CUSTOM_RECALLOC(void *p, size_t num, size_t sz) {
384
- void *ptr = CUSTOM_REALLOC(p, num * sz);
385
- if ((p == NULL) && (ptr != NULL)) {
386
- // Clear out the memory.
387
- memset(ptr, 0, CUSTOM_GETSIZE(ptr));
388
- }
389
- return ptr;
390
- }
391
-
392
- #if defined(_WIN32)
393
-
394
- /////// Other replacement functions that call malloc.
395
-
396
- // from http://msdn2.microsoft.com/en-us/library/6ewkz86d(VS.80).aspx
397
- // fgetc, _fgetchar, fgets, fprintf, fputc, _fputchar, fputs, fread, fscanf, fseek, fsetpos
398
- // _fullpath, fwrite, getc, getchar, _getcwd, _getdcwd, gets, _getw, _popen, printf, putc
399
- // putchar, _putenv, puts, _putw, scanf, _searchenv, setvbuf, _strdup, system, _tempnam,
400
- // ungetc, vfprintf, vprintf
401
-
402
- char *CUSTOM_GETENV(const char *str) {
403
- char buf[32767];
404
- int len = GetEnvironmentVariable(str, buf, 32767);
405
- if (len == 0) {
406
- return NULL;
407
- } else {
408
- char *str = new char[len + 1];
409
- strncpy(str, buf, len + 1);
410
- return str;
411
- }
412
- }
413
-
414
- int CUSTOM_PUTENV(char *str) {
415
- char *eqpos = strchr(str, '=');
416
- if (eqpos != NULL) {
417
- char first[32767], second[32767];
418
- int namelen = (size_t)eqpos - (size_t)str;
419
- strncpy(first, str, namelen);
420
- first[namelen] = '\0';
421
- int valuelen = strlen(eqpos + 1);
422
- strncpy(second, eqpos + 1, valuelen);
423
- second[valuelen] = '\0';
424
- char buf[255];
425
- sprintf(buf, "setting %s to %s\n", first, second);
426
- printf(buf);
427
- SetEnvironmentVariable(first, second);
428
- return 0;
429
- }
430
- return -1;
431
- }
432
-
433
- #endif
@@ -1,28 +0,0 @@
1
- #Edit configuration files to export mesh folder and auxiliary variables
2
-
3
- set(LINUX_BASH_FILE /home/${USER}/.bashrc)
4
- set(MAC_BASH_FILE /Users/${USER}/.bash_profile)
5
-
6
- if(SYSWIDE)
7
- #Install to system/public folders (exports the path to the library and refresh cache on Linux). Mac is weird, the library was completely ignored.
8
- if(WIN32)
9
- execute_process(COMMAND setx /M LIBMESH_PATH "${INSTALLATION_DIR}\\lib\\")
10
- elseif(APPLE)
11
- file(APPEND ${MAC_BASH_FILE} "export DYLD_FALLBACK_LIBRARY_PATH=\"${INSTALLATION_DIR}/lib/\"\nexport LIBMESH_PATH=\"${INSTALLATION_DIR}/lib/\"\n")
12
- else()
13
- #Linux
14
- file(WRITE "/etc/ld.so.conf.d/mesh.conf" "${INSTALLATION_DIR}/lib") #write path to libmesh
15
- execute_process(COMMAND ldconfig) # renew shared lib cache
16
- file(APPEND ${LINUX_BASH_FILE} "export LIBMESH_PATH=\"${INSTALLATION_DIR}/lib/\"\n") #not really necessary, but just to make things consistent
17
- endif()
18
- else()
19
- #Install to user profile (just exports a variable containing the path to the library)
20
- if(WIN32)
21
- execute_process(COMMAND setx LIBMESH_PATH "${INSTALLATION_DIR}\\lib\\")
22
- elseif(APPLE)
23
- file(APPEND ${MAC_BASH_FILE} "export LIBMESH_PATH=\"${INSTALLATION_DIR}/lib/\"\n")
24
- else()
25
- #Linux
26
- file(APPEND ${LINUX_BASH_FILE} "export LIBMESH_PATH=\"${INSTALLATION_DIR}/lib/\"\n")
27
- endif()
28
- endif()