Работа над дневником

This commit is contained in:
2026-05-05 03:13:47 +05:00
parent 51fa314d86
commit de3edc8486
12 changed files with 155 additions and 64 deletions
+9 -30
View File
@@ -1,36 +1,15 @@
#include <threads.h>
#include <Windows.h>
#include "FXAlloc.h"
#include <threads.h>
void* fxalloc_local_init(size_t _NBytes);
// В этой переменной настраиваем градации и предположительное количесвто блоков
static const FXGrade grades[] = {
{ 32, 200 }, { 64, 200 }, { 128, 8000 },
{ 256, 4000 }, { 512, 2000 }, { 1024, 1200 },
{ 4096, 200 }, { 0x10000, 4 },
{ 0 } // Ноль-терминант
};
void fxfree_prod(void* _Ptr);
void fxfree_summ(void* _Ptr);
void fxfree_prof(void* _Ptr);
#ifdef _WIN32
// Windows-версия
__declspec(thread) extern void* (*fxalloc)(size_t _NBytes);
__declspec(thread) extern void (*fxfree)(void* _Ptr);
#else
// POSIX-версия
extern static pthread_key_t thread_key;
extern void* (*fxalloc)(size_t _NBytes);
extern void (*fxfree)(void* _Ptr);
#endif
extern static pthread_key_t thread_key;
thread_local void* (*fxalloc)(size_t _NBytes) = fxalloc_local_init;
void (*fxfree)(void* _Ptr) = fxfree_prod;
void* fastalloc();
void init_tls() {
pthread_setspecific(thread_key, (void*)fxalloc);
fxalloc = fastalloc;
// или более сложный вариант с хранением структуры
}