Mercurial > games > semicongine
comparison fuhtark_test/include/malloc.h @ 1500:91c8c3b7cbf0
add: futhark tests for generating vulkan api
| author | sam <sam@basx.dev> |
|---|---|
| date | Wed, 26 Nov 2025 21:36:48 +0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1499:1f58458b7ef7 | 1500:91c8c3b7cbf0 |
|---|---|
| 1 /** | |
| 2 * This file has no copyright assigned and is placed in the Public Domain. | |
| 3 * This file is part of the w64 mingw-runtime package. | |
| 4 * No warranty is given; refer to the file DISCLAIMER within this package. | |
| 5 */ | |
| 6 #ifndef _MALLOC_H_ | |
| 7 #define _MALLOC_H_ | |
| 8 | |
| 9 #include <_mingw.h> | |
| 10 | |
| 11 #pragma pack(push,_CRT_PACKING) | |
| 12 | |
| 13 #ifndef _MM_MALLOC_H_INCLUDED | |
| 14 #define _MM_MALLOC_H_INCLUDED | |
| 15 #endif | |
| 16 | |
| 17 #ifdef __cplusplus | |
| 18 extern "C" { | |
| 19 #endif | |
| 20 | |
| 21 #ifdef _WIN64 | |
| 22 #define _HEAP_MAXREQ 0xFFFFFFFFFFFFFFE0 | |
| 23 #else | |
| 24 #define _HEAP_MAXREQ 0xFFFFFFE0 | |
| 25 #endif | |
| 26 | |
| 27 #ifndef _STATIC_ASSERT | |
| 28 #define _STATIC_ASSERT(expr) extern void __static_assert_t(int [(expr)?1:-1]) | |
| 29 #endif | |
| 30 | |
| 31 /* Return codes for _heapwalk() */ | |
| 32 #define _HEAPEMPTY (-1) | |
| 33 #define _HEAPOK (-2) | |
| 34 #define _HEAPBADBEGIN (-3) | |
| 35 #define _HEAPBADNODE (-4) | |
| 36 #define _HEAPEND (-5) | |
| 37 #define _HEAPBADPTR (-6) | |
| 38 | |
| 39 /* Values for _heapinfo.useflag */ | |
| 40 #define _FREEENTRY 0 | |
| 41 #define _USEDENTRY 1 | |
| 42 | |
| 43 #ifndef _HEAPINFO_DEFINED | |
| 44 #define _HEAPINFO_DEFINED | |
| 45 /* The structure used to walk through the heap with _heapwalk. */ | |
| 46 typedef struct _heapinfo { | |
| 47 int *_pentry; | |
| 48 size_t _size; | |
| 49 int _useflag; | |
| 50 } _HEAPINFO; | |
| 51 #endif | |
| 52 | |
| 53 extern unsigned int _amblksiz; | |
| 54 | |
| 55 #define _mm_free(a) _aligned_free(a) | |
| 56 #define _mm_malloc(a,b) _aligned_malloc(a,b) | |
| 57 | |
| 58 #ifndef _CRT_ALLOCATION_DEFINED | |
| 59 #define _CRT_ALLOCATION_DEFINED | |
| 60 void *__cdecl calloc(size_t _NumOfElements,size_t _SizeOfElements); | |
| 61 void __cdecl free(void *_Memory); | |
| 62 void *__cdecl malloc(size_t _Size); | |
| 63 void *__cdecl realloc(void *_Memory,size_t _NewSize); | |
| 64 _CRTIMP void *__cdecl _recalloc(void *_Memory,size_t _Count,size_t _Size); | |
| 65 /* _CRTIMP void __cdecl _aligned_free(void *_Memory); | |
| 66 _CRTIMP void *__cdecl _aligned_malloc(size_t _Size,size_t _Alignment); */ | |
| 67 _CRTIMP void *__cdecl _aligned_offset_malloc(size_t _Size,size_t _Alignment,size_t _Offset); | |
| 68 _CRTIMP void *__cdecl _aligned_realloc(void *_Memory,size_t _Size,size_t _Alignment); | |
| 69 _CRTIMP void *__cdecl _aligned_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment); | |
| 70 _CRTIMP void *__cdecl _aligned_offset_realloc(void *_Memory,size_t _Size,size_t _Alignment,size_t _Offset); | |
| 71 _CRTIMP void *__cdecl _aligned_offset_recalloc(void *_Memory,size_t _Count,size_t _Size,size_t _Alignment,size_t _Offset); | |
| 72 #endif | |
| 73 | |
| 74 #define _MAX_WAIT_MALLOC_CRT 60000 | |
| 75 | |
| 76 _CRTIMP int __cdecl _resetstkoflw (void); | |
| 77 _CRTIMP unsigned long __cdecl _set_malloc_crt_max_wait(unsigned long _NewValue); | |
| 78 | |
| 79 _CRTIMP void *__cdecl _expand(void *_Memory,size_t _NewSize); | |
| 80 _CRTIMP size_t __cdecl _msize(void *_Memory); | |
| 81 #ifdef __GNUC__ | |
| 82 #undef _alloca | |
| 83 #define _alloca(x) __builtin_alloca((x)) | |
| 84 #else | |
| 85 /* tcc implements alloca internally and exposes it (since commit d778bde7). | |
| 86 /* alloca is declared at include/stddef.h (which is distributed with tcc). | |
| 87 */ | |
| 88 #ifdef _alloca | |
| 89 #undef _alloca | |
| 90 #endif | |
| 91 #define _alloca(x) alloca((x)) | |
| 92 #endif | |
| 93 _CRTIMP size_t __cdecl _get_sbh_threshold(void); | |
| 94 _CRTIMP int __cdecl _set_sbh_threshold(size_t _NewValue); | |
| 95 _CRTIMP errno_t __cdecl _set_amblksiz(size_t _Value); | |
| 96 _CRTIMP errno_t __cdecl _get_amblksiz(size_t *_Value); | |
| 97 _CRTIMP int __cdecl _heapadd(void *_Memory,size_t _Size); | |
| 98 _CRTIMP int __cdecl _heapchk(void); | |
| 99 _CRTIMP int __cdecl _heapmin(void); | |
| 100 _CRTIMP int __cdecl _heapset(unsigned int _Fill); | |
| 101 _CRTIMP int __cdecl _heapwalk(_HEAPINFO *_EntryInfo); | |
| 102 _CRTIMP size_t __cdecl _heapused(size_t *_Used,size_t *_Commit); | |
| 103 _CRTIMP intptr_t __cdecl _get_heap_handle(void); | |
| 104 | |
| 105 #define _ALLOCA_S_THRESHOLD 1024 | |
| 106 #define _ALLOCA_S_STACK_MARKER 0xCCCC | |
| 107 #define _ALLOCA_S_HEAP_MARKER 0xDDDD | |
| 108 | |
| 109 #if(defined(_X86_) && !defined(__x86_64)) | |
| 110 #define _ALLOCA_S_MARKER_SIZE 8 | |
| 111 #elif defined(__ia64__) || defined(__x86_64) | |
| 112 #define _ALLOCA_S_MARKER_SIZE 16 | |
| 113 #endif | |
| 114 | |
| 115 #if !defined(RC_INVOKED) | |
| 116 static __inline void *_MarkAllocaS(void *_Ptr,unsigned int _Marker) { | |
| 117 if(_Ptr) { | |
| 118 *((unsigned int*)_Ptr) = _Marker; | |
| 119 _Ptr = (char*)_Ptr + _ALLOCA_S_MARKER_SIZE; | |
| 120 } | |
| 121 return _Ptr; | |
| 122 } | |
| 123 #endif | |
| 124 | |
| 125 #undef _malloca | |
| 126 #define _malloca(size) \ | |
| 127 ((((size) + _ALLOCA_S_MARKER_SIZE) <= _ALLOCA_S_THRESHOLD) ? \ | |
| 128 _MarkAllocaS(_alloca((size) + _ALLOCA_S_MARKER_SIZE),_ALLOCA_S_STACK_MARKER) : \ | |
| 129 _MarkAllocaS(malloc((size) + _ALLOCA_S_MARKER_SIZE),_ALLOCA_S_HEAP_MARKER)) | |
| 130 #undef _FREEA_INLINE | |
| 131 #define _FREEA_INLINE | |
| 132 | |
| 133 #ifndef RC_INVOKED | |
| 134 #undef _freea | |
| 135 static __inline void __cdecl _freea(void *_Memory) { | |
| 136 unsigned int _Marker; | |
| 137 if(_Memory) { | |
| 138 _Memory = (char*)_Memory - _ALLOCA_S_MARKER_SIZE; | |
| 139 _Marker = *(unsigned int *)_Memory; | |
| 140 if(_Marker==_ALLOCA_S_HEAP_MARKER) { | |
| 141 free(_Memory); | |
| 142 } | |
| 143 #ifdef _ASSERTE | |
| 144 else if(_Marker!=_ALLOCA_S_STACK_MARKER) { | |
| 145 _ASSERTE(("Corrupted pointer passed to _freea",0)); | |
| 146 } | |
| 147 #endif | |
| 148 } | |
| 149 } | |
| 150 #endif /* RC_INVOKED */ | |
| 151 | |
| 152 #ifndef NO_OLDNAMES | |
| 153 #ifdef __GNUC__ | |
| 154 #undef alloca | |
| 155 #define alloca(x) __builtin_alloca((x)) | |
| 156 #endif | |
| 157 #endif | |
| 158 | |
| 159 #ifdef HEAPHOOK | |
| 160 #ifndef _HEAPHOOK_DEFINED | |
| 161 #define _HEAPHOOK_DEFINED | |
| 162 typedef int (__cdecl *_HEAPHOOK)(int,size_t,void *,void **); | |
| 163 #endif | |
| 164 | |
| 165 _CRTIMP _HEAPHOOK __cdecl _setheaphook(_HEAPHOOK _NewHook); | |
| 166 | |
| 167 #define _HEAP_MALLOC 1 | |
| 168 #define _HEAP_CALLOC 2 | |
| 169 #define _HEAP_FREE 3 | |
| 170 #define _HEAP_REALLOC 4 | |
| 171 #define _HEAP_MSIZE 5 | |
| 172 #define _HEAP_EXPAND 6 | |
| 173 #endif | |
| 174 | |
| 175 #ifdef __cplusplus | |
| 176 } | |
| 177 #endif | |
| 178 | |
| 179 #pragma pack(pop) | |
| 180 | |
| 181 #endif /* _MALLOC_H_ */ |
