LMMP 4.3.0
Lamina High-Precision Arithmetic Library
载入中...
搜索中...
未找到
global.c
浏览该文件的文档.
1/**
2 * Copyright (C) 2026 HJimmyK (Jericho Knox)
3 *
4 * This file is part of LMMP.
5 *
6 * LMMP is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as
8 * published by the Free Software Foundation; either version 3 of
9 * the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see
18 * <https://www.gnu.org/licenses/>.
19 *
20 * SPDX-License-Identifier: LGPL-3.0-or-later
21 */
22
23#include "mparam.h"
24#include "impl/prime_table.h"
25#include "impl/str_conv.h"
26#include "impl/trialdiv.h"
27
28
29typedef void (*lmmp_global_hook_fn)(void);
30
35
39
40static void stack_deinit_default_(void) {
41 // 栈式分配器释放(返回-1仅表示此前未初始化,并非错误,故忽略)
42 (void)lmmp_stack_deinit();
43}
44
46 // 栈式分配器+缓冲池:其余资源的分配基础,须最先初始化、最后释放
48 // 质数筛表:首次调用 lmmp_prime_int_table_init_ 时惰性构建,仅注册释放
50 // 十进制幂表:首次调用 lmmp_dec_pow_table_ 时惰性构建,仅注册释放
52 // 试除块表:首次调用 lmmp_trialdiv_ 时惰性构建,仅注册释放
54};
55
56#define GLOBAL_ENTRIES_NUM (sizeof(lmmp_global_entries) / sizeof(lmmp_global_entries[0]))
57
58void lmmp_global_init(void) {
59 for (size_t i = 0; i < GLOBAL_ENTRIES_NUM; ++i) {
60 if (lmmp_global_entries[i].init != NULL)
62 }
63}
64
66 for (size_t i = GLOBAL_ENTRIES_NUM; i-- > 0;) {
67 if (lmmp_global_entries[i].deinit != NULL)
69 }
70}
lmmp_global_hook_fn init
#define GLOBAL_ENTRIES_NUM
static void stack_init_default_(void)
static void stack_deinit_default_(void)
lmmp_global_hook_fn deinit
static const lmmp_global_entry_t lmmp_global_entries[]
void(*) lmmp_global_hook_fn(void)
Copyright (C) 2026 HJimmyK (Jericho Knox)
#define LMMP_POOL_SIZE
int lmmp_stack_deinit(void)
LMMP 全局栈释放函数(通常不需要手动调用)
int lmmp_stack_init(size_t size)
LMMP 全局栈初始化函数(通常不需要手动调用)
void lmmp_global_init(void)
全局初始化函数(线程局部的)
void lmmp_global_deinit(void)
全局释放函数(线程局部的)
void lmmp_prime_int_table_free_(void)
释放全局素数表
void lmmp_dec_pow_table_free_(void)
释放全局十进制幂表(可重入)
void lmmp_trialdiv_table_free_(void)