Introduction
Introduction Statistics Contact Development Disclaimer Help
zbset.c - libzahl - big integer library
git clone git://git.suckless.org/libzahl
Log
Files
Refs
README
LICENSE
---
zbset.c (815B)
---
1 /* See LICENSE file for copyright and license details. */
2 #include "internals.h"
3
4
5 #define PROLOGUE(MAY_INCREASE)\
6 zahl_char_t mask = 1;\
7 size_t chars = FLOOR_BITS_TO_CHARS(bit);\
8 if (MAY_INCREASE) {\
9 if (zzero(a)) {\
10 a->used = 0;\
11 SET_SIGNUM(a, 1);\
12 }\
13 if (unlikely(chars >= a->used)) {\
14 ENSURE_SIZE(a, chars + 1);\
15 zmemset(a->chars + a->used, 0, chars + 1 - a->us…
16 a->used = chars + 1;\
17 }\
18 } else if (unlikely(chars >= a->used)) {\
19 return;\
20 }\
21 bit = BITS_IN_LAST_CHAR(bit);\
22 mask <<= bit
23
24
25 void
26 zbset_ll_set(z_t a, size_t bit)
27 {
28 PROLOGUE(1);
29 a->chars[chars] |= mask;
30 }
31
32 void
33 zbset_ll_clear(z_t a, size_t bit)
34 {
35 PROLOGUE(0);
36 a->chars[chars] &= ~mask;
37 TRIM_AND_ZERO(a);
38 }
39
40 void
41 zbset_ll_flip(z_t a, size_t bit)
42 {
43 PROLOGUE(1);
44 a->chars[chars] ^= mask;
45 TRIM_AND_ZERO(a);
46 }
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.