Introduction
Introduction Statistics Contact Development Disclaimer Help
zsetup.c - libzahl - big integer library
git clone git://git.suckless.org/libzahl
Log
Files
Refs
README
LICENSE
---
zsetup.c (1437B)
---
1 /* See LICENSE file for copyright and license details. */
2 #include "internals.h"
3
4 #define X(x, s) z_t x;
5 LIST_TEMPS
6 #undef X
7 #define X(i, x, f, v) z_t x;
8 LIST_CONSTS
9 #undef X
10
11 z_t libzahl_tmp_divmod_ds[BITS_PER_CHAR];
12 jmp_buf libzahl_jmp_buf;
13 int libzahl_set_up = 0;
14 int libzahl_error;
15 zahl_char_t **libzahl_pool[sizeof(size_t) * 8];
16 size_t libzahl_pool_n[sizeof(size_t) * 8];
17 size_t libzahl_pool_alloc[sizeof(size_t) * 8];
18 struct zahl **libzahl_temp_stack;
19 struct zahl **libzahl_temp_stack_head;
20 struct zahl **libzahl_temp_stack_end;
21 void *libzahl_temp_allocation = 0;
22
23 #define X(i, x, f, v) 1 +
24 static zahl_char_t constant_chars[LIST_CONSTS ZAHL_FLUFF];
25 #undef X
26
27
28 void
29 zsetup(jmp_buf env)
30 {
31 size_t i;
32 *libzahl_jmp_buf = *env;
33
34 if (likely(!libzahl_set_up)) {
35 libzahl_set_up = 1;
36
37 memset(libzahl_pool, 0, sizeof(libzahl_pool));
38 memset(libzahl_pool_n, 0, sizeof(libzahl_pool_n));
39 memset(libzahl_pool_alloc, 0, sizeof(libzahl_pool_alloc)…
40
41 #define X(x, s)\
42 zinit(x); if (s) zsetu(x, 1);
43 LIST_TEMPS;
44 #undef X
45 #define X(i, x, f, v)\
46 (x)->alloced = 1, (x)->chars = constant_chars + (i), f(x…
47 LIST_CONSTS;
48 #undef X
49 for (i = BITS_PER_CHAR; i--;)
50 zinit(libzahl_tmp_divmod_ds[i]);
51
52 libzahl_temp_stack = malloc(256 * sizeof(*libzahl_temp_s…
53 if (check(!libzahl_temp_stack))
54 libzahl_memfailure();
55 libzahl_temp_stack_head = libzahl_temp_stack;
56 libzahl_temp_stack_end = libzahl_temp_stack + 256;
57 }
58 }
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.