summaryrefslogtreecommitdiffstats
path: root/pbn_init.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2012-03-12 22:01:59 -0700
committerH. Peter Anvin <hpa@zytor.com>2012-03-12 22:01:59 -0700
commitfc3eb93a04d2b9d0ab7821b6bbf95e852d13c847 (patch)
tree7d0d73c134d9822418aa31731cd26b3a2dd42dea /pbn_init.c
parentd58300585648dc798ac0a6d1d55590ea9ce26cd3 (diff)
downloadpbn-fc3eb93a04d2b9d0ab7821b6bbf95e852d13c847.tar.gz
pbn-fc3eb93a04d2b9d0ab7821b6bbf95e852d13c847.tar.xz
pbn-fc3eb93a04d2b9d0ab7821b6bbf95e852d13c847.zip
Switch terminology from "atom" to the more standard "limb"
The "limb" terminology ("like a digit but larger") seems to have become standard enough that we might as well follow suit.
Diffstat (limited to 'pbn_init.c')
-rw-r--r--pbn_init.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/pbn_init.c b/pbn_init.c
index b34f218..07d490b 100644
--- a/pbn_init.c
+++ b/pbn_init.c
@@ -23,7 +23,7 @@ struct pbn *pbn_new(int len)
{
struct pbn *pbn;
- pbn = _pbn_zalloc(sizeof(struct pbn)+(len-1)*sizeof(pbn_atom_t));
+ pbn = _pbn_zalloc(sizeof(struct pbn)+(len-1)*sizeof(pbn_limb_t));
if (!pbn)
return NULL;
@@ -33,25 +33,25 @@ struct pbn *pbn_new(int len)
return pbn;
}
-#if PBN_ATOM_BITS != 32 && PBN_ATOM_BITS != 64
-# error "Fix pbn_ilog2p1 for new PBN_ATOM_BITS size"
+#if PBN_LIMB_BITS != 32 && PBN_LIMB_BITS != 64
+# error "Fix pbn_ilog2p1 for new PBN_LIMB_BITS size"
#endif
-static int pbn_ilog2p1(pbn_atom_t v)
+static int pbn_ilog2p1(pbn_limb_t v)
{
int p = 1;
#if defined(__GNUC__) && __GNUC__ >= 4
- if (sizeof(pbn_atom_t) == sizeof(int))
- return (__builtin_clz(v) ^ (PBN_ATOM_BITS-1)) + 1;
- if (sizeof(pbn_atom_t) == sizeof(long))
- return (__builtin_clzl(v) ^ (PBN_ATOM_BITS-1)) + 1;
- if (sizeof(pbn_atom_t) == sizeof(long long))
- return (__builtin_clzll(v) ^ (PBN_ATOM_BITS-1)) + 1;
+ if (sizeof(pbn_limb_t) == sizeof(int))
+ return (__builtin_clz(v) ^ (PBN_LIMB_BITS-1)) + 1;
+ if (sizeof(pbn_limb_t) == sizeof(long))
+ return (__builtin_clzl(v) ^ (PBN_LIMB_BITS-1)) + 1;
+ if (sizeof(pbn_limb_t) == sizeof(long long))
+ return (__builtin_clzll(v) ^ (PBN_LIMB_BITS-1)) + 1;
/* else fall through, wtf... */
#endif
-#if PBN_ATOM_BITS >= 64
+#if PBN_LIMB_BITS >= 64
if (v & 0xffffffff00000000) {
p += 32;
v >>= 32;
@@ -82,7 +82,7 @@ static int pbn_ilog2p1(pbn_atom_t v)
return p;
}
-struct pbn *pbn_int(pbn_satom_t v)
+struct pbn *pbn_int(pbn_slimb_t v)
{
struct pbn *pbn = pbn_new(1);
if (!pbn)
@@ -103,7 +103,7 @@ struct pbn *pbn_int(pbn_satom_t v)
return pbn;
}
-struct pbn *pbn_uint(pbn_atom_t v)
+struct pbn *pbn_uint(pbn_limb_t v)
{
struct pbn *pbn = pbn_new(1);
if (!pbn)
@@ -117,7 +117,7 @@ struct pbn *pbn_uint(pbn_atom_t v)
/* Produce a duplicate */
struct pbn *pbn_dup(const struct pbn *src)
{
- int bytes = sizeof(struct pbn)+(src->len-1)*sizeof(pbn_atom_t);
+ int bytes = sizeof(struct pbn)+(src->len-1)*sizeof(pbn_limb_t);
struct pbn *dst = _pbn_malloc(bytes);
memcpy(dst, src, bytes);
@@ -130,15 +130,15 @@ struct pbn *pbn_dup(const struct pbn *src)
struct pbn *pbn_dupx(const struct pbn *src, int len)
{
int slack = src->len >= len ? 0 : len-src->len;
- int bytes = sizeof(struct pbn)+(src->len-1)*sizeof(pbn_atom_t);
- struct pbn *dst = _pbn_malloc(bytes+slack*sizeof(pbn_atom_t));
+ int bytes = sizeof(struct pbn)+(src->len-1)*sizeof(pbn_limb_t);
+ struct pbn *dst = _pbn_malloc(bytes+slack*sizeof(pbn_limb_t));
if (!dst)
return NULL;
memcpy(dst, src, bytes);
dst->ref = 1;
- memset(&dst->num[slack], 0, slack*sizeof(pbn_atom_t));
+ memset(&dst->num[slack], 0, slack*sizeof(pbn_limb_t));
return dst;
}
@@ -152,10 +152,10 @@ struct pbn *pbn_cow(struct pbn *src, int len)
src->ref = 1;
if (len > olen) {
src = _pbn_realloc(src, sizeof(struct pbn)+
- (len-1)*sizeof(pbn_atom_t));
+ (len-1)*sizeof(pbn_limb_t));
src->len = len;
}
- memset(&src->num[olen], 0, (len-olen)*sizeof(pbn_atom_t));
+ memset(&src->num[olen], 0, (len-olen)*sizeof(pbn_limb_t));
return src;
}
@@ -169,12 +169,12 @@ struct pbn *pbn_cow(struct pbn *src, int len)
struct pbn *pbn_adjust_bits(struct pbn *pbn)
{
int i;
- pbn_atom_t v;
+ pbn_limb_t v;
for (i = pbn->len-1; i >= 0; i--) {
v = pbn->num[i];
if (v) {
- pbn->bits = i*PBN_ATOM_BITS + pbn_ilog2p1(v);
+ pbn->bits = i*PBN_LIMB_BITS + pbn_ilog2p1(v);
return pbn;
}
}