ref: 22b11e5411affc4a91204eb45590bd1796274e35
parent: 4b22ab1d70ae00338f3af8dd876e4181194efcc8
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Mar 6 20:54:48 EST 2025
use Plan 9 naming of integer types Second round of renamings.
--- a/3rd/brieflz/brieflz.c
+++ b/3rd/brieflz/brieflz.c
@@ -38,7 +38,7 @@
// This is used to store positions and lengths, so src_size has to be within
// the range of this type.
//
-typedef uint32_t blz_word;
+typedef u32int blz_word;
#define BLZ_WORD_MAX UINT32_MAX
@@ -418,10 +418,10 @@
{
assert(bits > 0 && bits <= 32);
- uint32_t val = (uint32_t) p[0]
- | ((uint32_t) p[1] << 8)
- | ((uint32_t) p[2] << 16)
- | ((uint32_t) p[3] << 24);
+ u32int val = (u32int) p[0]
+ | ((u32int) p[1] << 8)
+ | ((u32int) p[2] << 16)
+ | ((u32int) p[3] << 24);
return (val * 2654435761U) >> (32 - bits);
}
@@ -639,7 +639,7 @@
#endif
extern int
-LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+LLVMFuzzerTestOneInput(const u8int *data, size_t size)
{
if (size > ULONG_MAX / 2) { return 0; }
void *workmem = MEM_MALLOC(blz_workmem_size_level(size, BLZ_FUZZ_LEVEL));
--- a/3rd/brieflz/depacks.c
+++ b/3rd/brieflz/depacks.c
@@ -298,7 +298,7 @@
#include <string.h>
extern int
-LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+LLVMFuzzerTestOneInput(const u8int *data, size_t size)
{
if (size > ULONG_MAX / 2) { return 0; }
void *depacked = MEM_MALLOC(4096);
--- a/3rd/fn.c
+++ b/3rd/fn.c
@@ -36,7 +36,7 @@
// Recurse to find either this leaf (*pkey != nil)
// or the next one (*pkey == nil).
Tbitmap b = twigbit(i, *pkey, *plen);
- uint32_t s, m; TWIGOFFMAX(s, m, i, b);
+ u32int s, m; TWIGOFFMAX(s, m, i, b);
for(; s < m; s++){
if(next_rec(Tbranch_twigs(t)+s, pkey, plen, pval))
return true;
@@ -96,7 +96,7 @@
return nil;
}
Trie *twigs = Tbranch_twigs(p);
- uint32_t m = sl_popcount(Tindex_bitmap(i));
+ u32int m = sl_popcount(Tindex_bitmap(i));
assert(twigs <= t && t < twigs+m);
if(m == 2){
// Move the other twig to the parent branch.
@@ -118,7 +118,7 @@
Tbl *
Tsetl(Tbl *tbl, const char *key, size_t len, void *val)
{
- assert(!Tindex_branch((Tindex)(uintptr_t)val) && len <= Tmaxlen);
+ assert(!Tindex_branch((Tindex)(uintptr)val) && len <= Tmaxlen);
if(val == nil)
return Tdell(tbl, key, len);
// First leaf in an empty tbl?
@@ -144,14 +144,14 @@
// twig we choose since the keys are all the same up to this
// index. Note that blindly using twigoff(t, b) can cause
// an out-of-bounds index if it equals twigmax(t).
- uint32_t s = hastwig(i, b) ? twigoff(i, b) : 0;
+ u32int s = hastwig(i, b) ? twigoff(i, b) : 0;
t = Tbranch_twigs(t) + s;
}
// Do the keys differ, and if so, where?
- uint32_t off, xor, shf;
+ u32int off, xor, shf;
const char *tkey = Tleaf_key(t);
for(off = 0; off <= len; off++){
- xor = (uint8_t)key[off] ^ (uint8_t)tkey[off];
+ xor = (u8int)key[off] ^ (u8int)tkey[off];
if(xor != 0)
goto newkey;
}
@@ -158,8 +158,8 @@
Tset_val(t, val);
return tbl;
newkey:; // We have the branch's byte index; what is its chunk index?
- uint32_t bit = off * 8 + sl_clz(xor) + 8 - sizeof(uint32_t) * 8;
- uint32_t qo = bit / 5;
+ u32int bit = off * 8 + sl_clz(xor) + 8 - sizeof(u32int) * 8;
+ u32int qo = bit / 5;
off = qo * 5 / 8;
shf = qo * 5 % 8;
// re-index keys with adjusted offset
@@ -197,7 +197,7 @@
return tbl;
growbranch:
assert(!hastwig(i, nb));
- uint32_t s, m; TWIGOFFMAX(s, m, i, nb);
+ u32int s, m; TWIGOFFMAX(s, m, i, nb);
twigs = MEM_REALLOC(Tbranch_twigs(t), sizeof(Trie) * (m + 1));
if(twigs == nil)
return nil;
--- a/3rd/fn.h
+++ b/3rd/fn.h
@@ -19,8 +19,8 @@
#pragma once
-typedef uint32_t Tbitmap;
-typedef uint64_t Tindex;
+typedef u32int Tbitmap;
+typedef u64int Tindex;
typedef struct Tbl {
Tindex index;
@@ -39,8 +39,8 @@
Tset_field((void *), ptr, Trie *, twigs);
Tset_field((Tindex), index, Tindex, index);
-Tset_field((void *)(uintptr_t), ptr, const char *, key);
-Tset_field((Tindex)(uintptr_t), index, void *, val);
+Tset_field((void *)(uintptr), ptr, const char *, key);
+Tset_field((Tindex)(uintptr), index, void *, val);
static inline bool Tindex_branch(Tindex i);
@@ -66,7 +66,7 @@
sl_purefn
Tcheck_get(const char *, Tleaf, key, t->ptr);
sl_purefn
-Tcheck_get(void *, Tleaf, val, (void*)(uintptr_t)t->index);
+Tcheck_get(void *, Tleaf, val, (void*)(uintptr)t->index);
// index word layout
@@ -85,7 +85,7 @@
#define Tix_mask(field) ((1ULL << Tix_width_##field) - 1ULL)
#define Tunmask(field, index) \
- ((uint32_t)(((index) >> Tix_base_##field) & Tix_mask(field)))
+ ((u32int)(((index) >> Tix_base_##field) & Tix_mask(field)))
#define Tmaxlen Tix_mask(offset)
@@ -100,14 +100,14 @@
struct dummy
Tindex_get(bool, branch);
-Tindex_get(uint32_t, shift);
-Tindex_get(uint32_t, offset);
+Tindex_get(u32int, shift);
+Tindex_get(u32int, offset);
Tindex_get(Tbitmap, bitmap);
static inline Tindex
-Tindex_new(uint32_t shift, uint32_t offset, Tbitmap bitmap)
+Tindex_new(u32int shift, u32int offset, Tbitmap bitmap)
{
- uint32_t branch = 1;
+ u32int branch = 1;
return
Tix_place(branch) |
Tix_place(shift) |
@@ -147,20 +147,20 @@
// | | | | | | | | |
// shift=0 shift=5 shift=2 shift=7 shift=4 shift=1 shift=6 shift=3
-static inline uint8_t
-knybble(const char *key, uint32_t off, uint32_t shift)
+static inline u8int
+knybble(const char *key, u32int off, u32int shift)
{
- uint32_t word = ((const uint8_t*)key)[off]<<8;
+ u32int word = ((const u8int*)key)[off]<<8;
if(word)
- word |= ((const uint8_t*)key)[off+1];
- uint32_t right = 16 - 5 - shift;
+ word |= ((const u8int*)key)[off+1];
+ u32int right = 16 - 5 - shift;
return (word >> right) & 0x1FU;
}
-static inline uint8_t
+static inline u8int
nibble(Tindex i, const char *key, size_t len)
{
- uint32_t off = Tindex_offset(i);
+ u32int off = Tindex_offset(i);
if(off >= len)
return 0;
return knybble(key, off, Tindex_shift(i));
@@ -178,7 +178,7 @@
return Tindex_bitmap(i) & bit;
}
-static inline uint32_t
+static inline u32int
twigoff(Tindex i, Tbitmap bit)
{
return sl_popcount(Tindex_bitmap(i) & (bit-1));
--- a/3rd/mp/mp.h
+++ b/3rd/mp/mp.h
@@ -1,9 +1,9 @@
#pragma once
#ifdef BITS64
-typedef uint64_t mpdigit;
+typedef u64int mpdigit;
#else
-typedef uint32_t mpdigit;
+typedef u32int mpdigit;
#endif
typedef union FPdbleword FPdbleword;
@@ -12,11 +12,11 @@
double x;
struct {
#if BYTE_ORDER == LITTLE_ENDIAN
- uint32_t lo;
- uint32_t hi;
+ u32int lo;
+ u32int hi;
#else
- uint32_t hi;
- uint32_t lo;
+ u32int hi;
+ u32int lo;
#endif
};
};
@@ -37,8 +37,8 @@
struct mpint
{
mpdigit *p;
- uint32_t size; /* allocated digits */
- uint32_t top; /* significant digits */
+ u32int size; /* allocated digits */
+ u32int top; /* significant digits */
int sign; /* +1 or -1 */
int flags;
};
@@ -63,27 +63,27 @@
void mpassign(mpint *old, mpint *new);
/* random bits */
-mpint* mprand(int bits, void (*gen)(uint8_t*, int), mpint *b);
+mpint* mprand(int bits, void (*gen)(u8int*, int), mpint *b);
/* return uniform random [0..n-1] */
-mpint* mpnrand(mpint *n, void (*gen)(uint8_t*, int), mpint *b);
+mpint* mpnrand(mpint *n, void (*gen)(u8int*, int), mpint *b);
/* conversion */
mpint* strtomp(const char*, char**, int, mpint*); /* ascii */
char* mptoa(mpint*, int, char*, int);
-mpint* letomp(uint8_t*, uint32_t, mpint*); /* byte array, little-endian */
-int mptole(mpint*, uint8_t*, uint32_t, uint8_t**);
-void mptolel(mpint *b, uint8_t *p, int n);
-mpint* betomp(uint8_t*, uint32_t, mpint*); /* byte array, big-endian */
-int mptobe(mpint*, uint8_t*, uint32_t, uint8_t**);
-void mptober(mpint *b, uint8_t *p, int n);
-uint32_t mptoui(mpint*) sl_purefn; /* unsigned int */
-mpint* uitomp(uint32_t, mpint*);
+mpint* letomp(u8int*, u32int, mpint*); /* byte array, little-endian */
+int mptole(mpint*, u8int*, u32int, u8int**);
+void mptolel(mpint *b, u8int *p, int n);
+mpint* betomp(u8int*, u32int, mpint*); /* byte array, big-endian */
+int mptobe(mpint*, u8int*, u32int, u8int**);
+void mptober(mpint *b, u8int *p, int n);
+u32int mptoui(mpint*) sl_purefn; /* unsigned int */
+mpint* uitomp(u32int, mpint*);
int mptoi(mpint*) sl_purefn; /* int */
mpint* itomp(int, mpint*);
-uint64_t mptouv(mpint*) sl_purefn; /* unsigned int64_t */
-mpint* uvtomp(uint64_t, mpint*);
-int64_t mptov(mpint*) sl_purefn; /* int64_t */
-mpint* vtomp(int64_t, mpint*);
+u64int mptouv(mpint*) sl_purefn; /* unsigned s64int */
+mpint* uvtomp(u64int, mpint*);
+s64int mptov(mpint*) sl_purefn; /* s64int */
+mpint* vtomp(s64int, mpint*);
double mptod(mpint*) sl_purefn; /* double */
mpint* dtomp(double, mpint*);
@@ -130,8 +130,8 @@
void mpinvert(mpint *b, mpint *m, mpint *res);
/* bit counting */
-uint32_t mpsignif(mpint*) sl_purefn; /* number of sigificant bits in mantissa */
-uint32_t mplowbits0(mpint*); /* k, where n = 2**k * q for odd q */
+u32int mpsignif(mpint*) sl_purefn; /* number of sigificant bits in mantissa */
+u32int mplowbits0(mpint*); /* k, where n = 2**k * q for odd q */
/* well known constants */
extern mpint *mpzero, *mpone, *mptwo;
--- a/3rd/mp/mpaux.c
+++ b/3rd/mp/mpaux.c
@@ -74,7 +74,7 @@
void
mpbits(mpint *b, int m)
{
- uint32_t n;
+ u32int n;
n = DIGITS(m);
if(b->size >= n){
@@ -166,7 +166,7 @@
}
// number of significant bits in mantissa
-uint32_t
+u32int
mpsignif(mpint *n)
{
int i, j;
@@ -186,10 +186,10 @@
#if 0 // UNUSED
// k, where n = 2**k * q for odd q
-uint32_t
+u32int
mplowbits0(mpint *n)
{
- uint32_t k, bit, digit;
+ u32int k, bit, digit;
mpdigit d;
assert(n->flags & MPnorm);
--- a/3rd/mp/mpdiv.c
+++ b/3rd/mp/mpdiv.c
@@ -23,9 +23,9 @@
// division by one or small powers of two
if(divisor->top == 1 && (divisor->p[0] & (divisor->p[0]-1)) == 0){
- int64_t r = 0;
+ s64int r = 0;
if(dividend->top > 0)
- r = (int64_t)dividend->sign * (dividend->p[0] & (divisor->p[0]-1));
+ r = (s64int)dividend->sign * (dividend->p[0] & (divisor->p[0]-1));
if(quotient != nil){
sign = divisor->sign;
for(s = 0; ((divisor->p[0] >> s) & 1) == 0; s++)
--- a/3rd/mp/mpfmt.c
+++ b/3rd/mp/mpfmt.c
@@ -34,9 +34,9 @@
}
static char *
-modbillion(int rem, uint32_t r, char *out, char *buf)
+modbillion(int rem, u32int r, char *out, char *buf)
{
- uint32_t rr;
+ u32int rr;
int i;
for(i = 0; i < 9; i++){
@@ -90,7 +90,7 @@
{
mpdigit x, y;
char *out;
- uint32_t j;
+ u32int j;
int i;
if(len < 2)
--- a/3rd/mp/mplogic.c
+++ b/3rd/mp/mplogic.c
@@ -17,11 +17,11 @@
*/
static void
-mplogic(mpint *b1, mpint *b2, mpint *sum, uint32_t fl)
+mplogic(mpint *b1, mpint *b2, mpint *sum, u32int fl)
{
mpint *t;
mpdigit *dp1, *dp2, *dpo, d1, d2, d;
- uint32_t c1, c2, co, i;
+ u32int c1, c2, co, i;
assert(((b1->flags | b2->flags | sum->flags) & MPtimesafe) == 0);
if(b1->sign < 0) fl ^= 0x03;
@@ -94,7 +94,7 @@
{
mpint *t;
mpdigit *dp1, *dp2, *dpo, d1, d2, d;
- uint32_t c1, c2, co, i;
+ u32int c1, c2, co, i;
int fl;
assert(((b1->flags | b2->flags | sum->flags) & MPtimesafe) == 0);
@@ -104,7 +104,7 @@
b2 = t;
}
fl = (b1->sign & 10) ^ (b2->sign & 12);
- sum->sign = (int)((uint32_t)fl << 28) >> 31 | 1;
+ sum->sign = (int)((u32int)fl << 28) >> 31 | 1;
mpbits(sum, b1->top*Dbits+1);
dp1 = b1->p;
dp2 = b2->p;
--- a/3rd/mp/mpmodop.c
+++ b/3rd/mp/mpmodop.c
@@ -21,7 +21,7 @@
{
mpint *a, *b;
mpdigit d;
- uint32_t i, j;
+ u32int i, j;
a = modarg(b1, m);
b = modarg(b2, m);
@@ -51,7 +51,7 @@
{
mpint *a, *b;
mpdigit d;
- uint32_t i, j;
+ u32int i, j;
a = modarg(b1, m);
b = modarg(b2, m);
--- a/3rd/mp/mprand.c
+++ b/3rd/mp/mprand.c
@@ -2,7 +2,7 @@
#include "mp.h"
mpint *
-mprand(int bits, void (*gen)(uint8_t*, int), mpint *b)
+mprand(int bits, void (*gen)(u8int*, int), mpint *b)
{
mpdigit mask;
@@ -13,7 +13,7 @@
b->sign = 1;
b->top = DIGITS(bits);
- (*gen)((uint8_t*)b->p, b->top*Dbytes);
+ (*gen)((u8int*)b->p, b->top*Dbytes);
mask = ((mpdigit)1 << (bits%Dbits))-1;
if(mask != 0)
--- a/3rd/mp/mpright.c
+++ b/3rd/mp/mpright.c
@@ -5,7 +5,7 @@
void
mpright(mpint *b, int shift, mpint *res)
{
- uint32_t d, l, r, i;
+ u32int d, l, r, i;
mpdigit this, last;
res->sign = b->sign;
--- a/3rd/mp/mptobe.c
+++ b/3rd/mp/mptobe.c
@@ -5,9 +5,9 @@
// return number of bytes converted
// if p == nil, allocate and result array
int
-mptobe(mpint *b, uint8_t *p, uint32_t n, uint8_t **pp)
+mptobe(mpint *b, u8int *p, u32int n, u8int **pp)
{
- uint32_t m;
+ u32int m;
m = (mpsignif(b)+7)/8;
if(m == 0)
--- a/3rd/mp/mptober.c
+++ b/3rd/mp/mptober.c
@@ -2,7 +2,7 @@
#include "mp.h"
void
-mptober(mpint *b, uint8_t *p, int n)
+mptober(mpint *b, u8int *p, int n)
{
int i, j, m;
mpdigit x;
--- a/3rd/mp/mptod.c
+++ b/3rd/mp/mptod.c
@@ -5,10 +5,10 @@
double
mptod(mpint *a)
{
- uint64_t v;
+ u64int v;
mpdigit w, r;
int sf, i, n;
- uint32_t m, s;
+ u32int m, s;
FPdbleword x;
if(a->top == 0) return 0.0;
@@ -52,7 +52,7 @@
return a->sign < 0 ? D_NINF : D_PINF;
}
x.lo = v;
- x.hi = ((uint32_t)(v >> 32) & ((1<<20) - 1)) | (sf + 1022) << 20 | (a->sign & 1U<<31);
+ x.hi = ((u32int)(v >> 32) & ((1<<20) - 1)) | (sf + 1022) << 20 | (a->sign & 1U<<31);
return x.x;
}
@@ -60,7 +60,7 @@
dtomp(double d, mpint *a)
{
FPdbleword x;
- uint64_t v;
+ u64int v;
int e;
if(a == nil)
@@ -72,7 +72,7 @@
mpassign(mpzero, a);
return a;
}
- v = x.lo | (uint64_t)(x.hi & ((1<<20) - 1)) << 32 | 1ULL<<52;
+ v = x.lo | (u64int)(x.hi & ((1<<20) - 1)) << 32 | 1ULL<<52;
if(e < 1075){
v += (1ULL<<(1074 - e)) - (~v >> (1075 - e) & 1);
v >>= 1075 - e;
--- a/3rd/mp/mptoui.c
+++ b/3rd/mp/mptoui.c
@@ -7,7 +7,7 @@
*/
mpint*
-uitomp(uint32_t i, mpint *b)
+uitomp(u32int i, mpint *b)
{
if(b == nil)
b = mpnew(0);
@@ -18,7 +18,7 @@
return mpnorm(b);
}
-uint32_t
+u32int
mptoui(mpint *b)
{
mpdigit x;
@@ -26,7 +26,7 @@
x = *b->p;
if(b->sign < 0)
x = 0;
- else if((Dbytes > sizeof(uint32_t) && x > UINT32_MAX) || b->top > 1)
+ else if((Dbytes > sizeof(u32int) && x > UINT32_MAX) || b->top > 1)
x = UINT32_MAX;
return x;
}
--- a/3rd/mp/mptouv.c
+++ b/3rd/mp/mptouv.c
@@ -1,14 +1,14 @@
#include "platform.h"
#include "mp.h"
-#define VLDIGITS (int)(sizeof(int64_t)/Dbytes)
+#define VLDIGITS (int)(sizeof(s64int)/Dbytes)
/*
- * this code assumes that a int64_t is an integral number of
+ * this code assumes that a s64int is an integral number of
* mpdigits long.
*/
mpint*
-uvtomp(uint64_t v, mpint *b)
+uvtomp(u64int v, mpint *b)
{
int s;
@@ -27,11 +27,11 @@
return mpnorm(b);
}
-uint64_t
+u64int
mptouv(mpint *b)
{
- uint64_t v;
- uint32_t s;
+ u64int v;
+ u32int s;
if(b->top == 0 || b->sign < 0)
return 0LL;
@@ -41,7 +41,7 @@
v = 0ULL;
for(s = 0; s < b->top; s++)
- v |= (uint64_t)b->p[s]<<(s*Dbits);
+ v |= (u64int)b->p[s]<<(s*Dbits);
return v;
}
--- a/3rd/mp/mptov.c
+++ b/3rd/mp/mptov.c
@@ -1,17 +1,17 @@
#include "platform.h"
#include "mp.h"
-#define VLDIGITS (int)(sizeof(int64_t)/Dbytes)
+#define VLDIGITS (int)(sizeof(s64int)/Dbytes)
/*
- * this code assumes that a int64_t is an integral number of
+ * this code assumes that a s64int is an integral number of
* mpdigits long.
*/
mpint*
-vtomp(int64_t v, mpint *b)
+vtomp(s64int v, mpint *b)
{
int s;
- uint64_t uv;
+ u64int uv;
if(b == nil)
b = mpnew(VLDIGITS*Dbits);
@@ -19,7 +19,7 @@
mpbits(b, VLDIGITS*Dbits);
if(v == INT64_MIN){
b->sign = -1;
- uv = (uint64_t)INT64_MAX+1;
+ uv = (u64int)INT64_MAX+1;
}else{
b->sign = (v >> (sizeof(v)*8 - 1)) | 1;
uv = v * b->sign;
@@ -34,11 +34,11 @@
return mpnorm(b);
}
-int64_t
+s64int
mptov(mpint *b)
{
- uint64_t v;
- uint32_t s;
+ u64int v;
+ u32int s;
if(b->top == 0)
return 0LL;
@@ -48,14 +48,14 @@
v = 0ULL;
for(s = 0; s < b->top; s++)
- v |= (uint64_t)b->p[s]<<(s*Dbits);
+ v |= (u64int)b->p[s]<<(s*Dbits);
if(b->sign > 0){
if(v > INT64_MAX)
v = INT64_MAX;
}else{
- v = v > INT64_MAX ? INT64_MIN : -(int64_t)v;
+ v = v > INT64_MAX ? INT64_MIN : -(s64int)v;
}
- return (int64_t)v;
+ return (s64int)v;
}
--- a/3rd/mp/mpvecadd.c
+++ b/3rd/mp/mpvecadd.c
@@ -6,7 +6,7 @@
mpvecadd(mpdigit *a, int alen, mpdigit *b, int blen, mpdigit *sum)
{
int i;
- uint32_t carry;
+ u32int carry;
mpdigit x, y;
carry = 0;
--- a/3rd/mp/strtomp.c
+++ b/3rd/mp/strtomp.c
@@ -6,7 +6,7 @@
{
const char *p, *next;
mpdigit x;
- uint32_t i;
+ u32int i;
i = 1<<s;
for(p = a; (dec16chr(*p) & 255) < i; p++)
@@ -64,7 +64,7 @@
return next;
}
-static uint32_t mppow10[] = {
+static u32int mppow10[] = {
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
};
@@ -71,7 +71,7 @@
static const char*
from10(const char *a, mpint *b)
{
- uint32_t x, y;
+ u32int x, y;
mpint *pow, *r;
int i;
--- a/3rd/mp/test.c
+++ b/3rd/mp/test.c
@@ -42,7 +42,7 @@
return mptoa(m, 10, b, sizeof(gstr[istr]));
}
-static int64_t
+static s64int
nsec(void)
{
return 0;
@@ -49,7 +49,7 @@
}
static void
-prng(uint8_t *p, int n)
+prng(u8int *p, int n)
{
while(n-- > 0)
*p++ = rand();
@@ -145,7 +145,7 @@
{
mpint *b, *b2;
int i;
- int64_t now;
+ s64int now;
b = strtomp(str, nil, 16, nil);
b2 = mpnew(0);
@@ -159,7 +159,7 @@
if(loops > 1)
printf("%"PRId64" ns for a %"PRIu32"*%d vecdigmul\n", (nsec()-now)/loops, b->top*Dbits, Dbits);
mpnorm(b2);
- printf("0 + %s * %"PRIx64" = %s\n", MP(b), (uint64_t)d, MP(b2));
+ printf("0 + %s * %"PRIx64" = %s\n", MP(b), (u64int)d, MP(b2));
mpfree(b);
mpfree(b2);
@@ -170,7 +170,7 @@
{
mpint *b, *b2;
int i;
- int64_t now;
+ s64int now;
b = strtomp(str, nil, 16, nil);
b2 = mpnew(0);
@@ -184,7 +184,7 @@
if(loops > 1)
printf("%"PRId64" ns for a %"PRIu32"*%d vecdigmul\n", (nsec()-now)/loops, b->top*Dbits, Dbits);
mpnorm(b2);
- printf("0 - %s * %"PRIx64" = %s\n", MP(b), (uint64_t)d, MP(b2));
+ printf("0 - %s * %"PRIx64" = %s\n", MP(b), (u64int)d, MP(b2));
mpfree(b);
mpfree(b2);
@@ -194,7 +194,7 @@
testmul(const char *str)
{
mpint *b, *b1, *b2;
- int64_t now;
+ s64int now;
int i;
b = strtomp(str, nil, 16, nil);
@@ -218,7 +218,7 @@
testmul2(mpint *b, mpint *b1)
{
mpint *b2;
- int64_t now;
+ s64int now;
int i;
b2 = mpnew(0);
@@ -241,7 +241,7 @@
mpint *b;
mpdigit q;
int i;
- int64_t now;
+ s64int now;
b = strtomp(str, nil, 16, nil);
now = nsec();
@@ -249,7 +249,7 @@
mpdigdiv(b->p, d, &q);
if(loops > 1)
printf("%"PRId64" ns for a %d/%d div\n", (nsec()-now)/loops, 2*Dbits, Dbits);
- printf("%s / %"PRIx64" = %"PRIx64"\n", MP(b), (uint64_t)d, (uint64_t)q);
+ printf("%s / %"PRIx64" = %"PRIx64"\n", MP(b), (u64int)d, (u64int)q);
mpfree(b);
}
@@ -257,7 +257,7 @@
testdiv(mpint *x, mpint *y)
{
mpint *b2, *b3;
- int64_t now;
+ s64int now;
int i;
b2 = mpnew(0);
@@ -277,7 +277,7 @@
testmod(mpint *x, mpint *y)
{
mpint *r;
- int64_t now;
+ s64int now;
int i;
r = mpnew(0);
@@ -295,7 +295,7 @@
testinvert(mpint *x, mpint *y)
{
mpint *r, *d1, *d2;
- int64_t now;
+ s64int now;
int i;
r = mpnew(0);
@@ -354,7 +354,7 @@
{
mpint *b, *e, *m, *res;
int i;
- uint64_t now;
+ u64int now;
b = strtomp(base, nil, 16, nil);
e = strtomp(exp, nil, 16, nil);
@@ -385,8 +385,8 @@
{
mpint *a, *b, *d, *x, *y, *t1, *t2;
int i;
- uint64_t now, then;
- uint64_t etime;
+ u64int now, then;
+ u64int etime;
d = mpnew(0);
x = mpnew(0);
--- a/3rd/mp/test/convtest.c
+++ b/3rd/mp/test/convtest.c
@@ -75,7 +75,7 @@
e = sign > 0 ? (1U<<31)-1 : 1U<<31;
MPTOX_END(mptoi, "%d")
-MPTOX(test_mptoui, uint32_t, mptoui)
+MPTOX(test_mptoui, u32int, mptoui)
if(mag < 32 && sign > 0)
e = 1U<<mag;
else
@@ -83,7 +83,7 @@
MPTOX_END(mptoui, "%"PRIu32)
-MPTOX(test_mptov, int64_t, mptov)
+MPTOX(test_mptov, s64int, mptov)
if(mag < 63)
e = sign*(1LL<<mag);
else
@@ -90,7 +90,7 @@
e = sign > 0 ? (1ULL<<63)-1 : 1ULL<<63;
MPTOX_END(mptov, "%"PRId64)
-MPTOX(test_mptouv, uint64_t, mptouv)
+MPTOX(test_mptouv, u64int, mptouv)
if(mag < 64 && sign > 0)
e = 1ULL<<mag;
else
@@ -99,19 +99,19 @@
XTOMP(test_itomp, int, itomp)
if(mag >= 31) continue;
-XTOMP_END(vtomp, int64_t, "%"PRId64)
+XTOMP_END(vtomp, s64int, "%"PRId64)
-XTOMP(test_uitomp, uint32_t, uitomp)
+XTOMP(test_uitomp, u32int, uitomp)
if(mag >= 32 || sign < 0) continue;
-XTOMP_END(uitomp, uint32_t, "%"PRIu32)
+XTOMP_END(uitomp, u32int, "%"PRIu32)
-XTOMP(test_vtomp, int64_t, vtomp)
+XTOMP(test_vtomp, s64int, vtomp)
if(mag >= 63) continue;
-XTOMP_END(vtomp, int64_t, "%"PRId64)
+XTOMP_END(vtomp, s64int, "%"PRId64)
-XTOMP(test_uvtomp, uint64_t, uvtomp)
+XTOMP(test_uvtomp, u64int, uvtomp)
if(mag >= 64 || sign < 0) continue;
-XTOMP_END(uvtomp, int64_t, "%"PRId64)
+XTOMP_END(uvtomp, s64int, "%"PRId64)
void
--- a/3rd/mp/test/dat.h
+++ b/3rd/mp/test/dat.h
@@ -1,8 +1,8 @@
typedef struct ldint ldint;
struct ldint {
- uint32_t n;
- uint8_t *b;
+ u32int n;
+ u8int *b;
};
enum {NTEST = 2 * 257 + 32};
--- a/3rd/mp/test/fns.h
+++ b/3rd/mp/test/fns.h
@@ -25,4 +25,4 @@
char *LFMT(ldint *);
char *MFMT(mpint *);
-void prng(uint8_t *p, int n);
+void prng(u8int *p, int n);
--- a/3rd/mp/test/ld.c
+++ b/3rd/mp/test/ld.c
@@ -4,7 +4,7 @@
#include "fns.h"
static int
-ldget(ldint *a, uint32_t n)
+ldget(ldint *a, u32int n)
{
if(n >= a->n) return a->b[a->n - 1]&1;
return a->b[n]&1;
@@ -40,7 +40,7 @@
ldneg(ldint *a)
{
int c, s, z;
- uint32_t i;
+ u32int i;
c = 1;
s = a->b[a->n - 1];
@@ -89,7 +89,7 @@
ldtomp(ldint *a, mpint *b)
{
int s, c;
- uint32_t i;
+ u32int i;
if(b == nil)
b = mpnew(0);
@@ -111,7 +111,7 @@
static ldint *
itold(int n, ldint *a)
{
- uint32_t i;
+ u32int i;
if(a == nil)
a = ldnew(sizeof(n)*8);
@@ -148,7 +148,7 @@
{
char *b, *p;
int s, c;
- uint32_t i, d;
+ u32int i, d;
istr = (istr+1) % nelem(str);
b = str[istr] + 3;
@@ -215,7 +215,7 @@
int
ldmpeq(ldint *a, mpint *b)
{
- uint32_t i, c;
+ u32int i, c;
if(b->sign > 0){
for(i = 0; i < b->top * Dbits; i++)
@@ -464,10 +464,10 @@
ldleft(ldint *a, int n, ldint *b)
{
int c;
- uint32_t i;
+ u32int i;
if(n < 0){
- if(a->n <= (uint32_t)-n){
+ if(a->n <= (u32int)-n){
b->n = 0;
ldnorm(b);
return;
@@ -474,7 +474,7 @@
}
c = 0;
if(a->b[a->n - 1])
- for(i = 0; i < (uint32_t)-n; i++)
+ for(i = 0; i < (u32int)-n; i++)
if(a->b[i]){
c = 1;
break;
@@ -506,7 +506,7 @@
ldleft(a, -n, b);
return;
}
- if(a->n <= (uint32_t)n){
+ if(a->n <= (u32int)n){
ldbits(b, 1);
b->b[0] = a->b[a->n - 1];
return;
@@ -519,7 +519,7 @@
void
ldnot(ldint *a, ldint *b)
{
- uint32_t i;
+ u32int i;
ldbits(b, a->n);
for(i = 0; i < a->n; i++)
@@ -526,10 +526,10 @@
b->b[i] = a->b[i] ^ 1;
}
-static uint32_t
-xorshift(uint32_t *state)
+static u32int
+xorshift(u32int *state)
{
- uint32_t x = *state;
+ u32int x = *state;
x ^= x << 13;
x ^= x >> 17;
x ^= x << 5;
@@ -540,8 +540,8 @@
void
testgen(int i, ldint *a)
{
- uint32_t j, state;
- uint32_t r = 0;
+ u32int j, state;
+ u32int r = 0;
ldint *b;
if(i < 257)
--- a/3rd/mp/test/main.c
+++ b/3rd/mp/test/main.c
@@ -6,7 +6,7 @@
int anyfail = 0;
void
-prng(uint8_t *p, int n)
+prng(u8int *p, int n)
{
while(n-- > 0)
*p++ = rand();
--- a/3rd/spooky.c
+++ b/3rd/spooky.c
@@ -48,27 +48,27 @@
# define inline __forceinline
#endif
-#define spooky_is_aligned(p, size) ((uintptr_t)(p) % (size) == 0)
+#define spooky_is_aligned(p, size) ((uintptr)(p) % (size) == 0)
//
-// Read uint64_t in little-endian order.
+// Read u64int in little-endian order.
//
sl_purefn
-static inline uint64_t
-spooky_read_le64(const uint64_t *s)
+static inline u64int
+spooky_read_le64(const u64int *s)
{
#if BYTE_ORDER == LITTLE_ENDIAN && defined(MEM_UNALIGNED_ACCESS)
return *s;
#else
- const uint8_t *p = (const uint8_t *) s;
- return (uint64_t) p[0]
- | ((uint64_t) p[1] << 8)
- | ((uint64_t) p[2] << 16)
- | ((uint64_t) p[3] << 24)
- | ((uint64_t) p[4] << 32)
- | ((uint64_t) p[5] << 40)
- | ((uint64_t) p[6] << 48)
- | ((uint64_t) p[7] << 56);
+ const u8int *p = (const u8int *) s;
+ return (u64int) p[0]
+ | ((u64int) p[1] << 8)
+ | ((u64int) p[2] << 16)
+ | ((u64int) p[3] << 24)
+ | ((u64int) p[4] << 32)
+ | ((u64int) p[5] << 40)
+ | ((u64int) p[6] << 48)
+ | ((u64int) p[7] << 56);
#endif
}
@@ -86,7 +86,7 @@
// I tried 3 pairs of each; they all differed by at least 212 bits.
//
static inline void
-spooky_mix(const uint64_t *restrict data, uint64_t *restrict s)
+spooky_mix(const u64int *restrict data, u64int *restrict s)
{
s[0] += spooky_read_le64(&data[0]); s[2] ^= s[10];
s[11] ^= s[0]; s[0] = ROTL64(s[0], 11); s[11] += s[1];
@@ -131,7 +131,7 @@
// 128-bit result is reported, so End() does three iterations.
//
static inline void
-spooky_end_partial(uint64_t *h)
+spooky_end_partial(u64int *h)
{
h[11] += h[1]; h[2] ^= h[11]; h[1] = ROTL64(h[1], 44);
h[0] += h[2]; h[3] ^= h[0]; h[2] = ROTL64(h[2], 15);
@@ -148,7 +148,7 @@
}
static inline void
-spooky_end(const uint64_t *restrict data, uint64_t *restrict h)
+spooky_end(const u64int *restrict data, u64int *restrict h)
{
h[0] += spooky_read_le64(&data[0]);
h[1] += spooky_read_le64(&data[1]);
@@ -183,7 +183,7 @@
// with a base of all zeros plus a counter, or plus another bit, or random
//
static inline void
-spooky_short_mix(uint64_t *h)
+spooky_short_mix(u64int *h)
{
h[2] = ROTL64(h[2], 50); h[2] += h[3]; h[0] ^= h[2];
h[3] = ROTL64(h[3], 52); h[3] += h[0]; h[1] ^= h[3];
@@ -212,7 +212,7 @@
// with probability 50 +- .75% (the worst case is approximately that)
//
static inline void
-spooky_short_end(uint64_t *h)
+spooky_short_end(u64int *h)
{
h[3] ^= h[2]; h[2] = ROTL64(h[2], 15); h[3] += h[2];
h[0] ^= h[3]; h[3] = ROTL64(h[3], 52); h[0] += h[3];
@@ -233,15 +233,15 @@
//
static void
spooky_short(const void *restrict message, size_t length,
- uint64_t *restrict hash1, uint64_t *restrict hash2)
+ u64int *restrict hash1, u64int *restrict hash2)
{
- uint64_t buf[2 * SC_NUMVARS];
+ u64int buf[2 * SC_NUMVARS];
union {
- const uint8_t *p8;
- uint64_t *p64;
+ const u8int *p8;
+ u64int *p64;
} u;
- u.p8 = (const uint8_t *) message;
+ u.p8 = (const u8int *) message;
if (ALLOW_UNALIGNED_READS == 0 && !spooky_is_aligned(u.p8, 8)) {
memcpy(buf, message, length);
@@ -249,7 +249,7 @@
}
size_t left = length % 32;
- uint64_t h[4];
+ u64int h[4];
h[0] = *hash1;
h[1] = *hash2;
h[2] = SC_CONST;
@@ -256,7 +256,7 @@
h[3] = SC_CONST;
if (length > 15) {
- const uint64_t *end = u.p64 + (length / 32) * 4;
+ const u64int *end = u.p64 + (length / 32) * 4;
// handle all complete sets of 32 bytes
for (; u.p64 < end; u.p64 += 4) {
@@ -278,39 +278,39 @@
}
// Handle the last 0..15 bytes, and its length
- h[3] += ((uint64_t) length) << 56;
+ h[3] += ((u64int) length) << 56;
switch (left) {
case 15:
- h[3] += ((uint64_t) u.p8[14]) << 48; // fallthrough
+ h[3] += ((u64int) u.p8[14]) << 48; // fallthrough
case 14:
- h[3] += ((uint64_t) u.p8[13]) << 40; // fallthrough
+ h[3] += ((u64int) u.p8[13]) << 40; // fallthrough
case 13:
- h[3] += ((uint64_t) u.p8[12]) << 32; // fallthrough
+ h[3] += ((u64int) u.p8[12]) << 32; // fallthrough
case 12:
- h[3] += ((uint64_t) u.p8[11]) << 24; // fallthrough
+ h[3] += ((u64int) u.p8[11]) << 24; // fallthrough
case 11:
- h[3] += ((uint64_t) u.p8[10]) << 16; // fallthrough
+ h[3] += ((u64int) u.p8[10]) << 16; // fallthrough
case 10:
- h[3] += ((uint64_t) u.p8[9]) << 8; // fallthrough
+ h[3] += ((u64int) u.p8[9]) << 8; // fallthrough
case 9:
- h[3] += (uint64_t) u.p8[8]; // fallthrough
+ h[3] += (u64int) u.p8[8]; // fallthrough
case 8:
h[2] += spooky_read_le64(&u.p64[0]);
break;
case 7:
- h[2] += ((uint64_t) u.p8[6]) << 48; // fallthrough
+ h[2] += ((u64int) u.p8[6]) << 48; // fallthrough
case 6:
- h[2] += ((uint64_t) u.p8[5]) << 40; // fallthrough
+ h[2] += ((u64int) u.p8[5]) << 40; // fallthrough
case 5:
- h[2] += ((uint64_t) u.p8[4]) << 32; // fallthrough
+ h[2] += ((u64int) u.p8[4]) << 32; // fallthrough
case 4:
- h[2] += ((uint64_t) u.p8[3]) << 24; // fallthrough
+ h[2] += ((u64int) u.p8[3]) << 24; // fallthrough
case 3:
- h[2] += ((uint64_t) u.p8[2]) << 16; // fallthrough
+ h[2] += ((u64int) u.p8[2]) << 16; // fallthrough
case 2:
- h[2] += ((uint64_t) u.p8[1]) << 8; // fallthrough
+ h[2] += ((u64int) u.p8[1]) << 8; // fallthrough
case 1:
- h[2] += (uint64_t) u.p8[0];
+ h[2] += (u64int) u.p8[0];
break;
case 0:
h[2] += SC_CONST;
@@ -321,26 +321,26 @@
*hash2 = h[1];
}
-uint64_t
-spooky_hash64(const void *message, size_t length, uint64_t seed)
+u64int
+spooky_hash64(const void *message, size_t length, u64int seed)
{
- uint64_t hash1 = seed;
+ u64int hash1 = seed;
spooky_hash128(message, length, &hash1, &seed);
return hash1;
}
-uint32_t
-spooky_hash32(const void *message, size_t length, uint32_t seed)
+u32int
+spooky_hash32(const void *message, size_t length, u32int seed)
{
- uint64_t hash1 = seed, hash2 = seed;
+ u64int hash1 = seed, hash2 = seed;
spooky_hash128(message, length, &hash1, &hash2);
- return (uint32_t) hash1;
+ return (u32int) hash1;
}
// do the whole hash in one call
void
spooky_hash128(const void *restrict message, size_t length,
- uint64_t *restrict hash1, uint64_t *restrict hash2)
+ u64int *restrict hash1, u64int *restrict hash2)
{
if (length < SC_BUFSIZE) {
spooky_short(message, length, hash1, hash2);
@@ -347,12 +347,12 @@
return;
}
- uint64_t h[SC_NUMVARS];
- uint64_t buf[SC_NUMVARS];
- uint64_t *end;
+ u64int h[SC_NUMVARS];
+ u64int buf[SC_NUMVARS];
+ u64int *end;
union {
- const uint8_t *p8;
- uint64_t *p64;
+ const u8int *p8;
+ u64int *p64;
} u;
size_t left;
@@ -369,7 +369,7 @@
h[10] = *hash2;
h[11] = SC_CONST;
- u.p8 = (const uint8_t *) message;
+ u.p8 = (const u8int *) message;
end = u.p64 + (length / SC_BLOCKSIZE) * SC_NUMVARS;
// handle all whole SC_BLOCKSIZE blocks of bytes
@@ -388,10 +388,10 @@
}
// handle the last partial block of SC_BLOCKSIZE bytes
- left = length - ((const uint8_t *) end - (const uint8_t *) message);
+ left = length - ((const u8int *) end - (const u8int *) message);
memcpy(buf, end, left);
- memset(((uint8_t *) buf) + left, 0, SC_BLOCKSIZE - left);
- ((uint8_t *) buf)[SC_BLOCKSIZE - 1] = (uint8_t) left;
+ memset(((u8int *) buf) + left, 0, SC_BLOCKSIZE - left);
+ ((u8int *) buf)[SC_BLOCKSIZE - 1] = (u8int) left;
// do some final mixing
spooky_end(buf, h);
@@ -402,7 +402,7 @@
/*
// init spooky state
void
-spooky_init(struct spooky_state *state, uint64_t seed1, uint64_t seed2)
+spooky_init(struct spooky_state *state, u64int seed1, u64int seed2)
{
state->length = 0;
state->left = 0;
@@ -415,20 +415,20 @@
spooky_update(struct spooky_state *restrict state,
const void *restrict message, size_t length)
{
- uint64_t h[SC_NUMVARS];
+ u64int h[SC_NUMVARS];
size_t newLength = length + state->left;
- uint8_t left;
+ u8int left;
union {
- const uint8_t *p8;
- uint64_t *p64;
+ const u8int *p8;
+ u64int *p64;
} u;
- const uint64_t *end;
+ const u64int *end;
// Is this message fragment too short? If it is, stuff it away.
if (newLength < SC_BUFSIZE) {
- memcpy(&((uint8_t *) state->data)[state->left], message, length);
+ memcpy(&((u8int *) state->data)[state->left], message, length);
state->length = length + state->length;
- state->left = (uint8_t) newLength;
+ state->left = (u8int) newLength;
return;
}
@@ -445,21 +445,21 @@
// if we've got anything stuffed away, use it now
if (state->left) {
- uint8_t prefix = SC_BUFSIZE - state->left;
- memcpy(&(((uint8_t *) state->data)[state->left]), message, prefix);
+ u8int prefix = SC_BUFSIZE - state->left;
+ memcpy(&(((u8int *) state->data)[state->left]), message, prefix);
u.p64 = state->data;
spooky_mix(u.p64, h);
spooky_mix(&u.p64[SC_NUMVARS], h);
- u.p8 = ((const uint8_t *) message) + prefix;
+ u.p8 = ((const u8int *) message) + prefix;
length -= prefix;
}
else {
- u.p8 = (const uint8_t *) message;
+ u.p8 = (const u8int *) message;
}
// handle all whole blocks of SC_BLOCKSIZE bytes
end = u.p64 + (length / SC_BLOCKSIZE) * SC_NUMVARS;
- left = (uint8_t) (length - ((const uint8_t *) end - u.p8));
+ left = (u8int) (length - ((const u8int *) end - u.p8));
if (ALLOW_UNALIGNED_READS || spooky_is_aligned(u.p8, 8)) {
while (u.p64 < end) {
spooky_mix(u.p64, h);
@@ -485,7 +485,7 @@
// report the hash for the concatenation of all message fragments so far
void
spooky_final(struct spooky_state *restrict state,
- uint64_t *restrict hash1, uint64_t *restrict hash2)
+ u64int *restrict hash1, u64int *restrict hash2)
{
// init the variables
if (state->length < SC_BUFSIZE) {
@@ -495,10 +495,10 @@
return;
}
- const uint64_t *data = (const uint64_t *) state->data;
- uint8_t left = state->left;
+ const u64int *data = (const u64int *) state->data;
+ u8int left = state->left;
- uint64_t h[SC_NUMVARS];
+ u64int h[SC_NUMVARS];
memcpy(h, state->state, sizeof(state->state));
if (left >= SC_BLOCKSIZE) {
@@ -509,9 +509,9 @@
}
// mix in the last partial block, and the length mod SC_BLOCKSIZE
- memset(&((uint8_t *) data)[left], 0, (SC_BLOCKSIZE - left));
+ memset(&((u8int *) data)[left], 0, (SC_BLOCKSIZE - left));
- ((uint8_t *) data)[SC_BLOCKSIZE - 1] = left;
+ ((u8int *) data)[SC_BLOCKSIZE - 1] = left;
// do some final mixing
spooky_end(data, h);
--- a/3rd/spooky.h
+++ b/3rd/spooky.h
@@ -41,7 +41,7 @@
#pragma once
-// number of uint64_t's in internal state
+// number of u64int's in internal state
#define SC_NUMVARS 12U
// size of the internal state
@@ -51,15 +51,15 @@
#define SC_BUFSIZE (2U * SC_BLOCKSIZE)
struct spooky_state {
- uint64_t data[2 * SC_NUMVARS]; // unhashed data, for partial messages
- uint64_t state[SC_NUMVARS]; // internal state of the hash
+ u64int data[2 * SC_NUMVARS]; // unhashed data, for partial messages
+ u64int state[SC_NUMVARS]; // internal state of the hash
size_t length; // total length of the input so far
- uint8_t left; // length of unhashed data stashed in data
+ u8int left; // length of unhashed data stashed in data
};
-void spooky_hash128(const void *message, size_t length, uint64_t *hash1, uint64_t *hash2);
-uint64_t spooky_hash64(const void *message, size_t length, uint64_t seed);
-uint32_t spooky_hash32(const void *message, size_t length, uint32_t seed);
-//void spooky_init(struct spooky_state *state, uint64_t seed1, uint64_t seed2);
+void spooky_hash128(const void *message, size_t length, u64int *hash1, u64int *hash2);
+u64int spooky_hash64(const void *message, size_t length, u64int seed);
+u32int spooky_hash32(const void *message, size_t length, u32int seed);
+//void spooky_init(struct spooky_state *state, u64int seed1, u64int seed2);
//void spooky_update(struct spooky_state *state, const void *message, size_t length);
-//void spooky_final(struct spooky_state *state, uint64_t *hash1, uint64_t *hash2);
+//void spooky_final(struct spooky_state *state, u64int *hash1, u64int *hash2);
--- a/3rd/utf/rune.c
+++ b/3rd/utf/rune.c
@@ -38,7 +38,7 @@
* one character sequence
* 00000-0007F => T1
*/
- c = *(const uint8_t*)str;
+ c = *(const u8int*)str;
if(c < Tx) {
*rune = c;
return 1;
@@ -48,7 +48,7 @@
* two character sequence
* 0080-07FF => T2 Tx
*/
- c1 = *(const uint8_t*)(str+1) ^ Tx;
+ c1 = *(const u8int*)(str+1) ^ Tx;
if(c1 & Testx)
goto bad;
if(c < T3) {
@@ -65,7 +65,7 @@
* three character sequence
* 0800-FFFF => T3 Tx Tx
*/
- c2 = *(const uint8_t*)(str+2) ^ Tx;
+ c2 = *(const u8int*)(str+2) ^ Tx;
if(c2 & Testx)
goto bad;
if(c < T4) {
@@ -81,7 +81,7 @@
* 10000-10FFFF => T4 Tx Tx Tx
*/
if(UTFmax >= 4) {
- c3 = *(const uint8_t*)(str+3) ^ Tx;
+ c3 = *(const u8int*)(str+3) ^ Tx;
if(c3 & Testx)
goto bad;
if(c < T5) {
@@ -189,7 +189,7 @@
if(n <= 0)
return 0;
- c = *(const uint8_t*)str;
+ c = *(const u8int*)str;
if(c < Tx)
return 1;
if(c < T3)
--- a/3rd/utf/runeistypedata
+++ b/3rd/utf/runeistypedata
@@ -1,5 +1,5 @@
static const
-uint8_t _mergeddata[11769] =
+u8int _mergeddata[11769] =
{
0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,
@@ -739,7 +739,7 @@
0,0,0,0,0,0,0,0,0,
};
static const
-uint16_t _mergedidx2[3755] =
+u16int _mergedidx2[3755] =
{
0,14,30,46,61,66,81,86,97,103,119,130,146,155,170,179,
195,195,195,211,219,229,229,237,252,266,279,292,308,320,334,349,
@@ -978,7 +978,7 @@
11753,11753,11753,11753,11753,11753,11753,11753,11753,11753,11753,
};
static const
-uint16_t _mergedidx1[2048] =
+u16int _mergedidx1[2048] =
{
0,64,128,192,256,320,383,447,511,564,579,643,707,771,771,771,
771,771,771,807,839,839,839,839,839,839,839,839,839,839,839,839,
--- a/3rd/utf/runetotypedata
+++ b/3rd/utf/runetotypedata
@@ -113,7 +113,7 @@
0,0,0,0,0,0,0,0,0,0,0,0,
};
static
-uint16_t _upperidx2[1595] =
+u16int _upperidx2[1595] =
{
0,0,0,0,0,0,15,20,31,31,31,42,48,48,64,73,
89,89,89,105,115,125,125,133,149,163,178,191,207,221,235,251,
@@ -217,7 +217,7 @@
1740,1740,1740,1740,1740,1740,1740,1740,1740,1740,1740,
};
static
-uint16_t _upperidx1[1024] =
+u16int _upperidx1[1024] =
{
0,89,204,268,396,475,558,558,558,558,558,558,558,558,558,558,
558,558,558,558,586,714,774,774,774,774,774,774,774,774,774,786,
@@ -397,7 +397,7 @@
0,0,0,0,
};
static
-uint16_t _loweridx2[1524] =
+u16int _loweridx2[1524] =
{
0,0,0,0,15,20,31,31,31,31,31,31,47,56,71,71,
87,87,87,103,111,121,121,129,144,160,176,192,205,217,231,246,
@@ -497,7 +497,7 @@
1604,1604,1604,1604,
};
static
-uint16_t _loweridx1[1024] =
+u16int _loweridx1[1024] =
{
0,86,204,268,396,473,553,553,553,553,553,553,553,553,553,553,
553,553,553,553,581,709,709,709,709,709,709,709,709,709,709,723,
@@ -683,7 +683,7 @@
0,0,0,0,0,
};
static
-uint16_t _titleidx2[1545] =
+u16int _titleidx2[1545] =
{
0,0,0,0,0,0,15,20,31,31,31,42,48,48,64,73,
89,89,89,105,115,125,125,133,149,163,178,191,207,219,233,249,
@@ -784,7 +784,7 @@
1701,1701,1701,1701,1701,1701,1701,1701,1701,
};
static
-uint16_t _titleidx1[1024] =
+u16int _titleidx1[1024] =
{
0,89,154,218,346,425,508,508,508,508,508,508,508,508,508,508,
508,508,508,508,536,664,724,724,724,724,724,724,724,724,724,736,
--- a/3rd/utf/utf.h
+++ b/3rd/utf/utf.h
@@ -7,7 +7,7 @@
UTFmax = 4,
};
-typedef uint32_t Rune;
+typedef u32int Rune;
int chartorune(Rune *rune, const char *str);
int runetochar(char *str, const Rune *rune);
--- a/3rd/utf/utfnlen.c
+++ b/3rd/utf/utfnlen.c
@@ -11,7 +11,7 @@
es = s + m;
for(n = 0; s < es; n++) {
- c = *(const uint8_t*)s;
+ c = *(const u8int*)s;
if(c < Runeself){
if(c == '\0')
break;
--- a/src/bitvector.c
+++ b/src/bitvector.c
@@ -1,16 +1,16 @@
#include "sl.h"
-uint32_t *
-bitvector_resize(uint32_t *b, uint64_t oldsz, uint64_t newsz, bool zero)
+u32int *
+bitvector_resize(u32int *b, u64int oldsz, u64int newsz, bool zero)
{
- uint32_t *p;
- size_t sz = ((newsz+31)>>5) * sizeof(uint32_t);
+ u32int *p;
+ size_t sz = ((newsz+31)>>5) * sizeof(u32int);
p = MEM_REALLOC(b, sz);
if(p == nil)
return nil;
if(zero && newsz > oldsz){
- size_t osz = ((oldsz+31)>>5) * sizeof(uint32_t);
- memset(&p[osz/sizeof(uint32_t)], 0, sz-osz);
+ size_t osz = ((oldsz+31)>>5) * sizeof(u32int);
+ memset(&p[osz/sizeof(u32int)], 0, sz-osz);
}
return p;
}
--- a/src/bitvector.h
+++ b/src/bitvector.h
@@ -1,7 +1,7 @@
-uint32_t *bitvector_resize(uint32_t *b, uint64_t oldsz, uint64_t newsz, bool zero);
+u32int *bitvector_resize(u32int *b, u64int oldsz, u64int newsz, bool zero);
#define bitvector_new(n, initzero) bitvector_resize(nil, 0, (n), (initzero))
-#define bitvector_nwords(nbits) (((uint64_t)(nbits)+31)>>5)
+#define bitvector_nwords(nbits) (((u64int)(nbits)+31)>>5)
#define bitvector_get(b, n) (b[(n)>>5] & (1U<<((n)&31)))
#define bitvector_set(b, n) do{ \
b[(n)>>5] |= 1U<<((n)&31); \
--- a/src/builtins.c
+++ b/src/builtins.c
@@ -231,7 +231,7 @@
float f = *(float*)data;
if(f < 0)
f = -f;
- if(f <= FLT_MAXINT && (float)(int32_t)f == f)
+ if(f <= FLT_MAXINT && (float)(s32int)f == f)
return sl_t;
}else{
assert(nt == T_DOUBLE);
@@ -238,7 +238,7 @@
double d = *(double*)data;
if(d < 0)
d = -d;
- if(d <= DBL_MAXINT && (double)(int64_t)d == d)
+ if(d <= DBL_MAXINT && (double)(s64int)d == d)
return sl_t;
}
}
@@ -302,11 +302,11 @@
if(d > 0){
if(d > (double)INT64_MAX)
return v;
- return return_from_u64((uint64_t)d);
+ return return_from_u64((u64int)d);
}
if(d > (double)INT64_MAX || d < (double)INT64_MIN)
return args[0];
- return return_from_s64((int64_t)d);
+ return return_from_s64((s64int)d);
}
type_error("number", v);
}
@@ -370,7 +370,7 @@
argcount(nargs, 1);
char *ptr = tostring(args[0]);
double t = parsetime(ptr);
- int64_t it = (int64_t)t;
+ s64int it = (s64int)t;
if((double)it == t && fits_fixnum(it))
return fixnum(it);
return mk_double(t);
--- a/src/cc.h
+++ b/src/cc.h
@@ -2,6 +2,18 @@
#ifdef __GNUC__
+typedef uint8_t u8int;
+typedef uint16_t u16int;
+typedef uint32_t u32int;
+typedef uint64_t u64int;
+typedef uintptr_t uintptr;
+
+typedef int8_t s8int;
+typedef int16_t s16int;
+typedef int32_t s32int;
+typedef int64_t s64int;
+typedef intptr_t intptr;
+
#define sl_unlikely(x) __builtin_expect(!!(x), 0)
#define sl_likely(x) __builtin_expect(!!(x), 1)
#define sl_printfmt(x, y) __attribute__((format(printf, x, y)))
--- a/src/compress.c
+++ b/src/compress.c
@@ -15,7 +15,7 @@
if(!isarray(args[0]))
type_error("array", args[0]);
- uint8_t *in;
+ u8int *in;
size_t insz;
to_sized_ptr(args[0], &in, &insz);
int level = nargs > 1 ? tofixnum(args[1]) : 0;
@@ -25,12 +25,12 @@
level = 10;
value_t v = cvalue(cv_class(ptr(args[0])), blz_max_packed_size(insz));
- uint8_t *out = cvalue_data(v);
+ u8int *out = cvalue_data(v);
size_t worksz = level > 0
? blz_workmem_size_level(insz, level)
: blz_workmem_size(insz);
- uint8_t *work = MEM_ALLOC(worksz);
+ u8int *work = MEM_ALLOC(worksz);
unsigned long n = level > 0
? blz_pack_level(in, out, insz, work, level)
: blz_pack(in, out, insz, work);
@@ -45,13 +45,13 @@
{
argcount(nargs, 3);
- uint8_t *in;
+ u8int *in;
size_t insz;
to_sized_ptr(args[0], &in, &insz);
if(!isarray(args[0]))
type_error("array", args[0]);
size_t outsz;
- uint8_t *out;
+ u8int *out;
value_t v;
if(args[1] == sl_sizesym){
outsz = tosize(args[2]);
--- a/src/cvalues.c
+++ b/src/cvalues.c
@@ -12,7 +12,7 @@
CV_OWNED = 1<<0,
};
-#define owned(cv) ((uintptr_t)(cv)->type & CV_OWNED)
+#define owned(cv) ((uintptr)(cv)->type & CV_OWNED)
#define isinlined(cv) ((cv)->data == (cv)->_space)
static void cvalue_init(sltype_t *type, value_t v, void *dest);
@@ -75,7 +75,7 @@
void
cv_autorelease(cvalue_t *cv)
{
- cv->type = (sltype_t*)(((uintptr_t)cv->type) | CV_OWNED);
+ cv->type = (sltype_t*)(((uintptr)cv->type) | CV_OWNED);
add_finalizer(cv);
}
@@ -82,7 +82,7 @@
static value_t
cprim(sltype_t *type, size_t sz)
{
- assert(!ismanaged((uintptr_t)type));
+ assert(!ismanaged((uintptr)type));
assert(sz == type->size);
cprim_t *pcp = alloc_words(CPRIM_NWORDS+NWORDS(sz));
pcp->type = type;
@@ -219,14 +219,14 @@
*((ctype*)dest) = n; \
}
-num_init(int8_t, s32, T_S8)
-num_init(uint8_t, u32, T_U8)
-num_init(int16_t, s32, T_S16)
-num_init(uint16_t, u32, T_U16)
-num_init(int32_t, s32, T_S32)
-num_init(uint32_t, u32, T_U32)
-num_init(int64_t, s64, T_S64)
-num_init(uint64_t, u64, T_U64)
+num_init(s8int, s32, T_S8)
+num_init(u8int, u32, T_U8)
+num_init(s16int, s32, T_S16)
+num_init(u16int, u32, T_U16)
+num_init(s32int, s32, T_S32)
+num_init(u32int, u32, T_U32)
+num_init(s64int, s64, T_S64)
+num_init(u64int, u64, T_U64)
num_init(float, double, T_FLOAT)
num_init(double, double, T_DOUBLE)
@@ -255,18 +255,18 @@
num_ctor_init(typenam, ctype, tag) \
num_ctor_ctor(typenam, ctype, tag)
-num_ctor_init(s8, int8_t, T_S8)
-num_ctor_init(u8, uint8_t, T_U8)
-num_ctor_init(s16, int16_t, T_S16)
-num_ctor_init(u16, uint16_t, T_U16)
-num_ctor(s32, int32_t, T_S32)
-num_ctor(u32, uint32_t, T_U32)
-num_ctor(s64, int64_t, T_S64)
-num_ctor(u64, uint64_t, T_U64)
-num_ctor_init(byte, uint8_t, T_U8)
+num_ctor_init(s8, s8int, T_S8)
+num_ctor_init(u8, u8int, T_U8)
+num_ctor_init(s16, s16int, T_S16)
+num_ctor_init(u16, u16int, T_U16)
+num_ctor(s32, s32int, T_S32)
+num_ctor(u32, u32int, T_U32)
+num_ctor(s64, s64int, T_S64)
+num_ctor(u64, u64int, T_U64)
+num_ctor_init(byte, u8int, T_U8)
num_ctor(float, float, T_FLOAT)
num_ctor(double, double, T_DOUBLE)
-num_ctor(rune, uint32_t, T_U32)
+num_ctor(rune, u32int, T_U32)
static void
cvalue_mp_init(sltype_t *type, value_t arg, void *dest)
@@ -470,7 +470,7 @@
argcount(nargs, 3);
cnt = tosize(args[1]);
if(cnt < 0)
- lerrorf(sl_errarg, "invalid size: %"PRIu64, (uint64_t)cnt);
+ lerrorf(sl_errarg, "invalid size: %"PRIu64, (u64int)cnt);
sltype_t *type = get_array_type(args[0]);
elsize = type->elsz;
@@ -524,7 +524,7 @@
// get pointer and size for any plain-old-data value
void
-to_sized_ptr(value_t v, uint8_t **pdata, size_t *psz)
+to_sized_ptr(value_t v, u8int **pdata, size_t *psz)
{
if(iscvalue(v)){
cvalue_t *pcv = ptr(v);
@@ -555,7 +555,7 @@
if(issymbol(args[0]) || iscons(args[0]))
return size_wrap(ctype_sizeof(args[0]));
size_t n;
- uint8_t *data;
+ u8int *data;
to_sized_ptr(args[0], &data, &n);
return size_wrap(n);
}
@@ -718,7 +718,7 @@
}
static void
-check_addr_args(value_t arr, value_t ind, uint8_t **data, int *index)
+check_addr_args(value_t arr, value_t ind, u8int **data, int *index)
{
int numel;
cvalue_t *cv = ptr(arr);
@@ -732,7 +732,7 @@
value_t
cvalue_array_aref(value_t *args)
{
- uint8_t *data;
+ u8int *data;
int index;
sltype_t *eltype = cv_class(ptr(args[0]))->eltype;
value_t el = 0;
@@ -742,23 +742,23 @@
check_addr_args(args[0], args[1], &data, &index);
if(nt < T_S32){
if(nt == T_S8)
- return fixnum((int8_t)data[index]);
+ return fixnum((s8int)data[index]);
if(nt == T_U8)
- return fixnum((uint8_t)data[index]);
+ return fixnum((u8int)data[index]);
if(nt == T_S16)
- return fixnum(((int16_t*)data)[index]);
- return fixnum(((uint16_t*)data)[index]);
+ return fixnum(((s16int*)data)[index]);
+ return fixnum(((u16int*)data)[index]);
}
- uint8_t *dest = cptr(el);
+ u8int *dest = cptr(el);
size_t sz = eltype->size;
if(sz == 1)
*dest = data[index];
else if(sz == 2)
- *(int16_t*)dest = ((int16_t*)data)[index];
+ *(s16int*)dest = ((s16int*)data)[index];
else if(sz == 4)
- *(int32_t*)dest = ((int32_t*)data)[index];
+ *(s32int*)dest = ((s32int*)data)[index];
else if(sz == 8)
- *(int64_t*)dest = ((int64_t*)data)[index];
+ *(s64int*)dest = ((s64int*)data)[index];
else
memcpy(dest, data + index*sz, sz);
return el;
@@ -767,10 +767,10 @@
value_t
cvalue_array_aset(value_t *args)
{
- uint8_t *data; int index;
+ u8int *data; int index;
sltype_t *eltype = cv_class(ptr(args[0]))->eltype;
check_addr_args(args[0], args[1], &data, &index);
- uint8_t *dest = data + index*eltype->size;
+ u8int *dest = data + index*eltype->size;
cvalue_init(eltype, args[2], dest);
return args[2];
}
@@ -828,21 +828,21 @@
#define RETURN_NUM_AS(var, type) return(mk_##type(var))
value_t
-return_from_u64(uint64_t Uaccum)
+return_from_u64(u64int Uaccum)
{
if(fits_fixnum(Uaccum))
return fixnum((fixnum_t)Uaccum);
- if(Uaccum > (uint64_t)INT64_MAX)
+ if(Uaccum > (u64int)INT64_MAX)
RETURN_NUM_AS(Uaccum, u64);
- if(Uaccum > (uint64_t)UINT32_MAX)
+ if(Uaccum > (u64int)UINT32_MAX)
RETURN_NUM_AS(Uaccum, s64);
- if(Uaccum > (uint64_t)INT32_MAX)
+ if(Uaccum > (u64int)INT32_MAX)
RETURN_NUM_AS(Uaccum, u32);
RETURN_NUM_AS(Uaccum, s32);
}
value_t
-return_from_s64(int64_t Saccum)
+return_from_s64(s64int Saccum)
{
if(fits_fixnum(Saccum))
return fixnum((fixnum_t)Saccum);
@@ -854,7 +854,7 @@
#define MP_OP mpadd
#define ARITH_OVERFLOW sadd_overflow_64
value_t
-sl_add_any(value_t *args, uint32_t nargs)
+sl_add_any(value_t *args, u32int nargs)
{
#include "sl_arith_any.inc"
}
@@ -864,7 +864,7 @@
#define MP_OP mpmul
#define ARITH_OVERFLOW smul_overflow_64
value_t
-sl_mul_any(value_t *args, uint32_t nargs)
+sl_mul_any(value_t *args, u32int nargs)
{
#include "sl_arith_any.inc"
}
@@ -872,8 +872,8 @@
value_t
sl_neg(value_t n)
{
- int64_t i64;
- uint64_t ui64;
+ s64int i64;
+ u64int ui64;
mpint *mp;
numerictype_t pt;
fixnum_t pi;
@@ -883,31 +883,31 @@
switch(pt){
case T_DOUBLE: return mk_double(-*(double*)a);
case T_FLOAT: return mk_float(-*(float*)a);
- case T_S8: return fixnum(-(fixnum_t)*(int8_t*)a);
- case T_U8: return fixnum(-(fixnum_t)*(uint8_t*)a);
- case T_S16: return fixnum(-(fixnum_t)*(int16_t*)a);
- case T_U16: return fixnum(-(fixnum_t)*(uint16_t*)a);
+ case T_S8: return fixnum(-(fixnum_t)*(s8int*)a);
+ case T_U8: return fixnum(-(fixnum_t)*(u8int*)a);
+ case T_S16: return fixnum(-(fixnum_t)*(s16int*)a);
+ case T_U16: return fixnum(-(fixnum_t)*(u16int*)a);
case T_U32:
- i64 = -(int64_t)*(uint32_t*)a;
+ i64 = -(s64int)*(u32int*)a;
goto i64neg;
case T_S32:
- i64 = -(int64_t)*(int32_t*)a;
+ i64 = -(s64int)*(s32int*)a;
goto i64neg;
case T_S64:
- i64 = *(int64_t*)a;
+ i64 = *(s64int*)a;
if(i64 == INT64_MIN)
- return mk_mp(uvtomp((uint64_t)INT64_MAX+1, nil));
+ return mk_mp(uvtomp((u64int)INT64_MAX+1, nil));
i64 = -i64;
i64neg:
return fits_fixnum(i64) ? fixnum(i64) : mk_mp(vtomp(i64, nil));
case T_U64:
- ui64 = *(uint64_t*)a;
- if(ui64 >= (uint64_t)INT64_MAX+1){
+ ui64 = *(u64int*)a;
+ if(ui64 >= (u64int)INT64_MAX+1){
mp = uvtomp(ui64, nil);
mp->sign = -1;
return mk_mp(mp);
}
- i64 = -(int64_t)ui64;
+ i64 = -(s64int)ui64;
goto i64neg;
case T_MP:
mp = mpcopy(*(mpint**)a);
@@ -1013,8 +1013,8 @@
da = da/db;
- if(ta < T_FLOAT && tb < T_FLOAT && (double)(int64_t)da == da)
- return return_from_s64((int64_t)da);
+ if(ta < T_FLOAT && tb < T_FLOAT && (double)(s64int)da == da)
+ return return_from_s64((s64int)da);
return mk_double(da);
}
@@ -1024,7 +1024,7 @@
fixnum_t ai, bi;
numerictype_t ta, tb;
void *aptr, *bptr;
- int64_t a64, b64;
+ s64int a64, b64;
mpint *x;
if(!num_to_ptr(a, &ai, &ta, &aptr))
@@ -1050,24 +1050,24 @@
}
if(ta == T_U64){
if(tb == T_U64){
- if(*(uint64_t*)bptr == 0)
+ if(*(u64int*)bptr == 0)
goto div_error;
- return return_from_u64(*(uint64_t*)aptr / *(uint64_t*)bptr);
+ return return_from_u64(*(u64int*)aptr / *(u64int*)bptr);
}
b64 = conv_to_s64(bptr, tb);
if(b64 < 0)
- return return_from_s64(-(int64_t)(*(uint64_t*)aptr / (uint64_t)(-b64)));
+ return return_from_s64(-(s64int)(*(u64int*)aptr / (u64int)(-b64)));
if(b64 == 0)
goto div_error;
- return return_from_u64(*(uint64_t*)aptr / (uint64_t)b64);
+ return return_from_u64(*(u64int*)aptr / (u64int)b64);
}
if(tb == T_U64){
- if(*(uint64_t*)bptr == 0)
+ if(*(u64int*)bptr == 0)
goto div_error;
a64 = conv_to_s64(aptr, ta);
if(a64 < 0)
- return return_from_s64(-((int64_t)((uint64_t)(-a64) / *(uint64_t*)bptr)));
- return return_from_u64((uint64_t)a64 / *(uint64_t*)bptr);
+ return return_from_s64(-((s64int)((u64int)(-a64) / *(u64int*)bptr)));
+ return return_from_u64((u64int)a64 / *(u64int*)bptr);
}
b64 = conv_to_s64(bptr, tb);
@@ -1086,7 +1086,7 @@
numerictype_t ta, tb, itmp;
void *aptr = nil, *bptr = nil, *ptmp;
mpint *bmp = nil, *resmp = nil;
- int64_t b64;
+ s64int b64;
if(!num_to_ptr(a, &ai, &ta, &aptr) || ta >= T_FLOAT)
type_error("integer", a);
@@ -1112,14 +1112,14 @@
switch(opcode){
case 0:
switch(ta){
- case T_S8: return fixnum( *(int8_t *)aptr & (int8_t )b64);
- case T_U8: return fixnum( *(uint8_t *)aptr & (uint8_t )b64);
- case T_S16: return fixnum( *(int16_t*)aptr & (int16_t )b64);
- case T_U16: return fixnum( *(uint16_t*)aptr & (uint16_t)b64);
- case T_S32: return mk_s32( *(int32_t*)aptr & (int32_t )b64);
- case T_U32: return mk_u32(*(uint32_t*)aptr & (uint32_t)b64);
- case T_S64: return mk_s64( *(int64_t*)aptr & (int64_t )b64);
- case T_U64: return mk_u64(*(uint64_t*)aptr & (uint64_t)b64);
+ case T_S8: return fixnum( *(s8int *)aptr & (s8int )b64);
+ case T_U8: return fixnum( *(u8int *)aptr & (u8int )b64);
+ case T_S16: return fixnum( *(s16int*)aptr & (s16int )b64);
+ case T_U16: return fixnum( *(u16int*)aptr & (u16int)b64);
+ case T_S32: return mk_s32( *(s32int*)aptr & (s32int )b64);
+ case T_U32: return mk_u32(*(u32int*)aptr & (u32int)b64);
+ case T_S64: return mk_s64( *(s64int*)aptr & (s64int )b64);
+ case T_U64: return mk_u64(*(u64int*)aptr & (u64int)b64);
case T_MP: mpand(*(mpint**)aptr, bmp, resmp); return mk_mp(resmp);
case T_FLOAT:
case T_DOUBLE: assert(0);
@@ -1127,14 +1127,14 @@
break;
case 1:
switch(ta){
- case T_S8: return fixnum( *(int8_t *)aptr | (int8_t )b64);
- case T_U8: return fixnum( *(uint8_t *)aptr | (uint8_t )b64);
- case T_S16: return fixnum( *(int16_t*)aptr | (int16_t )b64);
- case T_U16: return fixnum( *(uint16_t*)aptr | (uint16_t)b64);
- case T_S32: return mk_s32( *(int32_t*)aptr | (int32_t )b64);
- case T_U32: return mk_u32(*(uint32_t*)aptr | (uint32_t)b64);
- case T_S64: return mk_s64( *(int64_t*)aptr | (int64_t )b64);
- case T_U64: return mk_u64(*(uint64_t*)aptr | (uint64_t)b64);
+ case T_S8: return fixnum( *(s8int *)aptr | (s8int )b64);
+ case T_U8: return fixnum( *(u8int *)aptr | (u8int )b64);
+ case T_S16: return fixnum( *(s16int*)aptr | (s16int )b64);
+ case T_U16: return fixnum( *(u16int*)aptr | (u16int)b64);
+ case T_S32: return mk_s32( *(s32int*)aptr | (s32int )b64);
+ case T_U32: return mk_u32(*(u32int*)aptr | (u32int)b64);
+ case T_S64: return mk_s64( *(s64int*)aptr | (s64int )b64);
+ case T_U64: return mk_u64(*(u64int*)aptr | (u64int)b64);
case T_MP: mpor(*(mpint**)aptr, bmp, resmp); return mk_mp(resmp);
case T_FLOAT:
case T_DOUBLE: assert(0);
@@ -1142,14 +1142,14 @@
break;
case 2:
switch(ta){
- case T_S8: return fixnum( *(int8_t *)aptr ^ (int8_t )b64);
- case T_U8: return fixnum( *(uint8_t *)aptr ^ (uint8_t )b64);
- case T_S16: return fixnum( *(int16_t*)aptr ^ (int16_t )b64);
- case T_U16: return fixnum( *(uint16_t*)aptr ^ (uint16_t)b64);
- case T_S32: return mk_s32( *(int32_t*)aptr ^ (int32_t )b64);
- case T_U32: return mk_u32(*(uint32_t*)aptr ^ (uint32_t)b64);
- case T_S64: return mk_s64( *(int64_t*)aptr ^ (int64_t )b64);
- case T_U64: return mk_u64(*(uint64_t*)aptr ^ (uint64_t)b64);
+ case T_S8: return fixnum( *(s8int *)aptr ^ (s8int )b64);
+ case T_U8: return fixnum( *(u8int *)aptr ^ (u8int )b64);
+ case T_S16: return fixnum( *(s16int*)aptr ^ (s16int )b64);
+ case T_U16: return fixnum( *(u16int*)aptr ^ (u16int)b64);
+ case T_S32: return mk_s32( *(s32int*)aptr ^ (s32int )b64);
+ case T_U32: return mk_u32(*(u32int*)aptr ^ (u32int)b64);
+ case T_S64: return mk_s64( *(s64int*)aptr ^ (s64int )b64);
+ case T_U64: return mk_u64(*(u64int*)aptr ^ (u64int)b64);
case T_MP: mpxor(*(mpint**)aptr, bmp, resmp); return mk_mp(resmp);
case T_FLOAT:
case T_DOUBLE: assert(0);
@@ -1222,14 +1222,14 @@
ta = cp_numtype(cp);
aptr = cp_data(cp);
switch(ta){
- case T_S8: return fixnum(~*(int8_t *)aptr);
- case T_U8: return fixnum(~*(uint8_t *)aptr & 0xff);
- case T_S16: return fixnum(~*(int16_t *)aptr);
- case T_U16: return fixnum(~*(uint16_t*)aptr & 0xffff);
- case T_S32: return mk_s32(~*(int32_t *)aptr);
- case T_U32: return mk_u32(~*(uint32_t*)aptr);
- case T_S64: return mk_s64(~*(int64_t *)aptr);
- case T_U64: return mk_u64(~*(uint64_t*)aptr);
+ case T_S8: return fixnum(~*(s8int *)aptr);
+ case T_U8: return fixnum(~*(u8int *)aptr & 0xff);
+ case T_S16: return fixnum(~*(s16int *)aptr);
+ case T_U16: return fixnum(~*(u16int*)aptr & 0xffff);
+ case T_S32: return mk_s32(~*(s32int *)aptr);
+ case T_U32: return mk_u32(~*(u32int*)aptr);
+ case T_S64: return mk_s64(~*(s64int *)aptr);
+ case T_U64: return mk_u64(~*(u64int*)aptr);
}
}
if(iscvalue(a)){
@@ -1248,7 +1248,7 @@
BUILTIN("ash", ash)
{
fixnum_t n;
- int64_t accum;
+ s64int accum;
cprim_t *cp;
int ta;
mpint *mp;
@@ -1260,7 +1260,7 @@
if(isfixnum(a)){
if(n <= 0)
return fixnum(numval(a)>>(-n));
- accum = ((int64_t)numval(a))<<n;
+ accum = ((s64int)numval(a))<<n;
return fits_fixnum(accum) ? fixnum(accum) : return_from_s64(accum);
}
if(iscprim(a) || iscvalue(a)){
@@ -1272,14 +1272,14 @@
if(n < 0){
n = -n;
switch(ta){
- case T_S8: return fixnum((*(int8_t *)aptr) >> n);
- case T_U8: return fixnum((*(uint8_t *)aptr) >> n);
- case T_S16: return fixnum((*(int16_t *)aptr) >> n);
- case T_U16: return fixnum((*(uint16_t*)aptr) >> n);
- case T_S32: return mk_s32((*(int32_t *)aptr) >> n);
- case T_U32: return mk_u32((*(uint32_t*)aptr) >> n);
- case T_S64: return mk_s64((*(int64_t *)aptr) >> n);
- case T_U64: return mk_u64((*(uint64_t*)aptr) >> n);
+ case T_S8: return fixnum((*(s8int *)aptr) >> n);
+ case T_U8: return fixnum((*(u8int *)aptr) >> n);
+ case T_S16: return fixnum((*(s16int *)aptr) >> n);
+ case T_U16: return fixnum((*(u16int*)aptr) >> n);
+ case T_S32: return mk_s32((*(s32int *)aptr) >> n);
+ case T_U32: return mk_u32((*(u32int*)aptr) >> n);
+ case T_S64: return mk_s64((*(s64int *)aptr) >> n);
+ case T_U64: return mk_u64((*(u64int*)aptr) >> n);
case T_MP:
aptr = cv_data(cp);
mp = mpnew(0);
@@ -1294,7 +1294,7 @@
return mk_mp(mp);
}
if(ta == T_U64)
- return return_from_u64((*(uint64_t*)aptr)<<n);
+ return return_from_u64((*(u64int*)aptr)<<n);
if(ta < T_FLOAT)
return return_from_s64(conv_to_s64(aptr, ta)<<n);
}
@@ -1309,16 +1309,16 @@
SL(builtintype) = define_opaque_type(sl_builtinsym, sizeof(builtin_t), nil, nil);
- ctor_cv_intern(s8, T_S8, int8_t);
- ctor_cv_intern(u8, T_U8, uint8_t);
- ctor_cv_intern(s16, T_S16, int16_t);
- ctor_cv_intern(u16, T_U16, uint16_t);
- ctor_cv_intern(s32, T_S32, int32_t);
- ctor_cv_intern(u32, T_U32, uint32_t);
- ctor_cv_intern(s64, T_S64, int64_t);
- ctor_cv_intern(u64, T_U64, uint64_t);
- ctor_cv_intern(byte, T_U8, uint8_t);
- ctor_cv_intern(rune, T_U32, uint32_t);
+ ctor_cv_intern(s8, T_S8, s8int);
+ ctor_cv_intern(u8, T_U8, u8int);
+ ctor_cv_intern(s16, T_S16, s16int);
+ ctor_cv_intern(u16, T_U16, u16int);
+ ctor_cv_intern(s32, T_S32, s32int);
+ ctor_cv_intern(u32, T_U32, u32int);
+ ctor_cv_intern(s64, T_S64, s64int);
+ ctor_cv_intern(u64, T_U64, u64int);
+ ctor_cv_intern(byte, T_U8, u8int);
+ ctor_cv_intern(rune, T_U32, u32int);
ctor_cv_intern(float, T_FLOAT, float);
ctor_cv_intern(double, T_DOUBLE, double);
@@ -1330,16 +1330,16 @@
sl_runestringtypesym = csymbol("*runestring-type*");
setc(sl_runestringtypesym, sl_list2(sl_arraysym, sl_runesym));
- mk_primtype(s8, int8_t);
- mk_primtype(u8, uint8_t);
- mk_primtype(s16, int16_t);
- mk_primtype(u16, uint16_t);
- mk_primtype(s32, int32_t);
- mk_primtype(u32, uint32_t);
- mk_primtype(s64, int64_t);
- mk_primtype(u64, uint64_t);
- mk_primtype(byte, uint8_t);
- mk_primtype(rune, uint32_t);
+ mk_primtype(s8, s8int);
+ mk_primtype(u8, u8int);
+ mk_primtype(s16, s16int);
+ mk_primtype(u16, u16int);
+ mk_primtype(s32, s32int);
+ mk_primtype(u32, u32int);
+ mk_primtype(s64, s64int);
+ mk_primtype(u64, u64int);
+ mk_primtype(byte, u8int);
+ mk_primtype(rune, u32int);
mk_primtype(float, float);
mk_primtype(double, double);
--- a/src/cvalues.h
+++ b/src/cvalues.h
@@ -26,7 +26,7 @@
void cvalue_array_init(sltype_t *ft, value_t arg, void *dest);
size_t cvalue_arraylen(value_t v) sl_purefn;
size_t ctype_sizeof(value_t type);
-void to_sized_ptr(value_t v, uint8_t **pdata, size_t *psz);
+void to_sized_ptr(value_t v, u8int **pdata, size_t *psz);
value_t cvalue_relocate(value_t v);
value_t cvalue_copy(value_t v);
value_t cvalue_compare(value_t a, value_t b) sl_purefn;
@@ -33,11 +33,11 @@
value_t cvalue_array_aref(value_t *args);
value_t cvalue_array_aset(value_t *args);
value_t cbuiltin(const char *name, builtin_t f);
-value_t return_from_u64(uint64_t Uaccum);
-value_t return_from_s64(int64_t Saccum);
-value_t sl_add_any(value_t *args, uint32_t nargs);
+value_t return_from_u64(u64int Uaccum);
+value_t return_from_s64(s64int Saccum);
+value_t sl_add_any(value_t *args, u32int nargs);
value_t sl_neg(value_t n);
-value_t sl_mul_any(value_t *args, uint32_t nargs);
+value_t sl_mul_any(value_t *args, u32int nargs);
bool num_to_ptr(value_t a, fixnum_t *pi, numerictype_t *pt, void **pp);
_Noreturn void divide_by_0_error(void);
value_t sl_div2(value_t a, value_t b);
@@ -46,10 +46,10 @@
value_t mk_double(double n);
value_t mk_float(float n);
-value_t mk_s32(int32_t n);
-value_t mk_u32(uint32_t n);
-value_t mk_s64(int64_t n);
-value_t mk_u64(uint64_t n);
+value_t mk_s32(s32int n);
+value_t mk_u32(u32int n);
+value_t mk_s64(s64int n);
+value_t mk_u64(u64int n);
value_t mk_rune(Rune n);
value_t mk_mp(mpint *n);
--- a/src/dos/sys.c
+++ b/src/dos/sys.c
@@ -7,7 +7,7 @@
return 0.0;
}
-uint64_t
+u64int
nanosec_monotonic(void)
{
return 0;
@@ -41,7 +41,7 @@
}
}
-static const uint8_t boot[] = {
+static const u8int boot[] = {
#include "sl.boot.h"
};
--- a/src/equal.c
+++ b/src/equal.c
@@ -11,7 +11,7 @@
#define MIX(a, b) inthash((value_t)(a) ^ (value_t)(b));
#define doublehash(a) inthash(a)
#else
-#define MIX(a, b) int64to32hash((uint64_t)(a)<<32 | (uint64_t)(b));
+#define MIX(a, b) int64to32hash((u64int)(a)<<32 | (u64int)(b));
#define doublehash(a) int64to32hash(a)
#endif
@@ -314,12 +314,12 @@
*/
// *oob: output argument, means we hit the limit specified by 'bound'
-static uintptr_t
+static uintptr
bounded_hash(value_t a, int bound, bool *oob)
{
union {
double d;
- int64_t i64;
+ s64int i64;
}u;
numerictype_t nt;
size_t i, len;
@@ -326,7 +326,7 @@
cvalue_t *cv;
cprim_t *cp;
void *data;
- uintptr_t h = 0;
+ uintptr h = 0;
int tg = tag(a);
bool oob2;
@@ -354,7 +354,7 @@
cv = ptr(a);
data = cv_data(cv);
if(cv->type == SL(mptype)){
- len = mptobe(*(mpint**)data, nil, 0, (uint8_t**)&data);
+ len = mptobe(*(mpint**)data, nil, 0, (u8int**)&data);
h = memhash(data, len);
MEM_FREE(data);
}else{
@@ -409,7 +409,7 @@
return numval(sl_compare(a, b, true)) == 0;
}
-uintptr_t
+uintptr
hash_lispvalue(value_t a)
{
bool oob = false;
--- a/src/equal.h
+++ b/src/equal.h
@@ -5,7 +5,7 @@
#define eq_comparablep(a) (!((a)&1)) /* mag: UNUSED? */
int equal_lispvalue(value_t a, value_t b);
-uintptr_t hash_lispvalue(value_t a);
+uintptr hash_lispvalue(value_t a);
value_t sl_compare(value_t a, value_t b, bool eq);
int numeric_compare(value_t a, value_t b, bool eq, bool eqnans, bool typeerr);
void comparehash_init(void);
--- a/src/hashing.c
+++ b/src/hashing.c
@@ -25,8 +25,8 @@
return a;
}
-uint32_t
-int64to32hash(uint64_t key)
+u32int
+int64to32hash(u64int key)
{
key = (~key) + (key << 18); // key = (key << 18) - key - 1;
key = key ^ (key >> 31);
@@ -34,11 +34,11 @@
key = key ^ (key >> 11);
key = key + (key << 6);
key = key ^ (key >> 22);
- return (uint32_t)key;
+ return (u32int)key;
}
#endif
-uint64_t
+u64int
memhash(const char *buf, size_t n)
{
return spooky_hash64(buf, n, 0xcafe8881ULL);
--- a/src/hashing.h
+++ b/src/hashing.h
@@ -1,5 +1,5 @@
#pragma once
value_t inthash(value_t a) sl_constfn;
-uint32_t int64to32hash(uint64_t key) sl_constfn;
-uint64_t memhash(const char* buf, size_t n);
+u32int int64to32hash(u64int key) sl_constfn;
+u64int memhash(const char* buf, size_t n);
--- a/src/ios.c
+++ b/src/ios.c
@@ -14,9 +14,9 @@
void *
llt_memrchr(const void *s, int c, size_t n)
{
- const uint8_t *src = (const uint8_t*)s + n;
- uint8_t uc = c;
- while(--src >= (const uint8_t*)s)
+ const u8int *src = (const u8int*)s + n;
+ u8int uc = c;
+ while(--src >= (const u8int*)s)
if(*src == uc)
return (void *)src;
return nil;
@@ -34,7 +34,7 @@
// return error code, #bytes read in *nread
// these wrappers retry operations until success or a fatal error
static int
-_os_read(int fd, uint8_t *buf, size_t n, size_t *nread)
+_os_read(int fd, u8int *buf, size_t n, size_t *nread)
{
ssize_t r;
@@ -61,7 +61,7 @@
}
static int
-_os_read_all(int fd, uint8_t *buf, size_t n, size_t *nread)
+_os_read_all(int fd, u8int *buf, size_t n, size_t *nread)
{
size_t got;
@@ -106,7 +106,7 @@
}
static int
-_os_write_all(int fd, const uint8_t *buf, size_t n, size_t *nwritten)
+_os_write_all(int fd, const u8int *buf, size_t n, size_t *nwritten)
{
size_t wrote;
@@ -126,10 +126,10 @@
/* internal utility functions */
-static uint8_t *
+static u8int *
_buf_realloc(ios_t *s, size_t sz)
{
- uint8_t *temp;
+ u8int *temp;
if((s->buf == nil || s->buf == &s->local[0]) && sz <= IOS_INLSIZE){
/* TODO: if we want to allow shrinking, see if the buffer shrank
@@ -204,7 +204,7 @@
/* interface functions, low level */
static size_t
-_ios_read(ios_t *s, uint8_t *dest, size_t n, int all)
+_ios_read(ios_t *s, u8int *dest, size_t n, int all)
{
size_t tot = 0;
size_t got, avail;
@@ -585,10 +585,10 @@
s->size = s->bpos = 0;
}
-uint8_t *
+u8int *
ios_takebuf(ios_t *s, size_t *psize)
{
- uint8_t *buf;
+ u8int *buf;
ios_flush(s);
@@ -615,7 +615,7 @@
}
int
-ios_setbuf(ios_t *s, uint8_t *buf, size_t size, bool own)
+ios_setbuf(ios_t *s, u8int *buf, size_t size, bool own)
{
ios_flush(s);
size_t nvalid;
@@ -701,7 +701,7 @@
#define LINE_CHUNK_SIZE 160
size_t
-ios_copyuntil(ios_t *to, ios_t *from, uint8_t delim)
+ios_copyuntil(ios_t *to, ios_t *from, u8int delim)
{
size_t total = 0, avail = from->size - from->bpos;
bool first = true;
@@ -712,7 +712,7 @@
avail = ios_readprep(from, LINE_CHUNK_SIZE);
}
size_t written;
- uint8_t *pd = memchr(from->buf+from->bpos, delim, avail);
+ u8int *pd = memchr(from->buf+from->bpos, delim, avail);
if(pd == nil){
written = ios_write(to, from->buf+from->bpos, avail);
from->bpos += avail;
@@ -785,10 +785,10 @@
}
ios_t *
-ios_static_buffer(ios_t *s, const uint8_t *buf, size_t sz)
+ios_static_buffer(ios_t *s, const u8int *buf, size_t sz)
{
ios_mem(s, 0);
- ios_setbuf(s, (uint8_t*)buf, sz, 0);
+ ios_setbuf(s, (u8int*)buf, sz, 0);
s->size = sz;
ios_set_readonly(s);
return s;
@@ -844,7 +844,7 @@
}
static void
-ios_loc(ios_t *s, uint8_t ch)
+ios_loc(ios_t *s, u8int ch)
{
if(ch == '\n'){
s->loc.lineno++;
@@ -868,7 +868,7 @@
int
ios_getc(ios_t *s)
{
- uint8_t ch;
+ u8int ch;
if(s->state == bst_rd && s->bpos < s->size)
ch = s->buf[s->bpos++];
else if(s->_eof || ios_read(s, &ch, 1) < 1)
@@ -881,13 +881,13 @@
ios_peekc(ios_t *s)
{
if(s->bpos < s->size)
- return (uint8_t)s->buf[s->bpos];
+ return (u8int)s->buf[s->bpos];
if(s->_eof)
return IOS_EOF;
size_t n = ios_readprep(s, 1);
if(n == 0)
return IOS_EOF;
- return (uint8_t)s->buf[s->bpos];
+ return (u8int)s->buf[s->bpos];
}
int
--- a/src/ios.h
+++ b/src/ios.h
@@ -20,12 +20,12 @@
typedef struct {
char *filename;
- uint32_t lineno;
- uint32_t colno;
+ u32int lineno;
+ u32int colno;
}ios_loc_t;
typedef struct {
- uint8_t *buf; // start of buffer
+ u8int *buf; // start of buffer
size_t maxsize; // space allocated to buffer
size_t size; // length of valid data in buf, >=ndirty
size_t bpos; // current position in buffer
@@ -51,7 +51,7 @@
// again any number of times. usually only true for files and strings.
bool rereadable;
- uint8_t local[IOS_INLSIZE];
+ u8int local[IOS_INLSIZE];
}ios_t;
void *llt_memrchr(const void *s, int c, size_t n) sl_purefn;
@@ -68,14 +68,14 @@
int ios_flush(ios_t *s);
void ios_close(ios_t *s);
void ios_free(ios_t *s);
-uint8_t *ios_takebuf(ios_t *s, size_t *psize); // null-terminate and release buffer to caller
+u8int *ios_takebuf(ios_t *s, size_t *psize); // null-terminate and release buffer to caller
// set buffer space to use
-int ios_setbuf(ios_t *s, uint8_t *buf, size_t size, bool own);
+int ios_setbuf(ios_t *s, u8int *buf, size_t size, bool own);
int ios_bufmode(ios_t *s, bufmode_t mode);
void ios_set_readonly(ios_t *s);
size_t ios_copy(ios_t *to, ios_t *from, size_t nbytes);
size_t ios_copyall(ios_t *to, ios_t *from);
-size_t ios_copyuntil(ios_t *to, ios_t *from, uint8_t delim);
+size_t ios_copyuntil(ios_t *to, ios_t *from, u8int delim);
int ios_wait(ios_t *s, double ws);
@@ -82,7 +82,7 @@
/* stream creation */
ios_t *ios_file(ios_t *s, char *fname, bool rd, bool wr, bool create, bool trunc);
ios_t *ios_mem(ios_t *s, size_t initsize);
-ios_t *ios_static_buffer(ios_t *s, const uint8_t *buf, size_t sz);
+ios_t *ios_static_buffer(ios_t *s, const u8int *buf, size_t sz);
ios_t *ios_fd(ios_t *s, int fd, bool isfile, bool own);
// todo: ios_socket
extern ios_t *ios_stdin;
@@ -95,7 +95,7 @@
int ios_printf(ios_t *s, const char *format, ...) sl_printfmt(2, 3);
int ios_vprintf(ios_t *s, const char *format, va_list args) sl_printfmt(2, 0);
-void hexdump(ios_t *dest, const uint8_t *buffer, size_t len, size_t startoffs);
+void hexdump(ios_t *dest, const u8int *buffer, size_t len, size_t startoffs);
/* high-level stream functions - input */
int ios_getutf8(ios_t *s, Rune *r);
--- a/src/iostream.c
+++ b/src/iostream.c
@@ -167,7 +167,7 @@
off_t res = ios_skip(s, off);
if(res < 0)
return sl_nil;
- return sizeof(res) == sizeof(int64_t) ? mk_s64(res) : mk_s32(res);
+ return sizeof(res) == sizeof(s64int) ? mk_s64(res) : mk_s32(res);
}
BUILTIN("io-flush", io_flush)
@@ -255,7 +255,7 @@
n = ft->size;
}
value_t cv = cvalue(ft, n);
- uint8_t *data = cptr(cv);
+ u8int *data = cptr(cv);
size_t got = ios_read(s, data, n);
if(got < n)
//lerrorf(sl_errio, "end of input reached");
@@ -265,7 +265,7 @@
// args must contain data[, offset[, count]]
static void
-get_start_count_args(value_t *args, uint32_t nargs, size_t sz, size_t *offs, size_t *nb)
+get_start_count_args(value_t *args, u32int nargs, size_t sz, size_t *offs, size_t *nb)
{
if(nargs > 1){
*offs = tosize(args[1]);
@@ -288,7 +288,7 @@
Rune r = *(Rune*)cp_data(ptr(args[1]));
return fixnum(ios_pututf8(s, r));
}
- uint8_t *data;
+ u8int *data;
size_t sz, offs = 0;
to_sized_ptr(v, &data, &sz);
size_t nb = sz;
@@ -299,7 +299,7 @@
return size_wrap(ios_write(s, data, nb));
}
-static uint8_t
+static u8int
get_delim_arg(value_t arg)
{
size_t uldelim = tosize(arg);
@@ -308,7 +308,7 @@
if((iscprim(arg) && cp_class(ptr(arg)) == SL(runetype)) || uldelim > 0xff)
lerrorf(sl_errarg, "delimiter out of range");
}
- return (uint8_t)uldelim;
+ return (u8int)uldelim;
}
BUILTIN("io-readuntil", io_readuntil)
@@ -316,11 +316,11 @@
argcount(nargs, 2);
value_t str = cvalue_string(80);
cvalue_t *cv = ptr(str);
- uint8_t *data = cv_data(cv);
+ u8int *data = cv_data(cv);
ios_t dest;
ios_mem(&dest, 0);
ios_setbuf(&dest, data, 80, 0);
- uint8_t delim = get_delim_arg(args[1]);
+ u8int delim = get_delim_arg(args[1]);
ios_t *src = toiostream(args[0]);
size_t n = ios_copyuntil(&dest, src, delim);
cv->len = n;
@@ -330,7 +330,7 @@
cv->data = ios_takebuf(&dest, &sz);
cv_autorelease(cv);
}else{
- ((uint8_t*)cv->data)[n] = 0;
+ ((u8int*)cv->data)[n] = 0;
}
if(n == 0 && ios_eof(src))
return sl_eof;
@@ -342,7 +342,7 @@
argcount(nargs, 3);
ios_t *dest = toiostream(args[0]);
ios_t *src = toiostream(args[1]);
- uint8_t delim = get_delim_arg(args[2]);
+ u8int delim = get_delim_arg(args[2]);
return size_wrap(ios_copyuntil(dest, src, delim));
}
@@ -411,7 +411,7 @@
memcpy(cvalue_data(str), st->buf, n);
ios_trunc(st, 0);
}else{
- uint8_t *b = ios_takebuf(st, &n); n--;
+ u8int *b = ios_takebuf(st, &n); n--;
if(n == 0)
return SL(the_empty_string);
b[n] = '\0';
--- a/src/macos/sys.c
+++ b/src/macos/sys.c
@@ -17,7 +17,7 @@
* so need to use cycles() instead, but fall back to
* nsec() in case we can't
*/
-uint64_t
+u64int
nanosec_monotonic(void)
{
return 0;
@@ -73,7 +73,7 @@
char os_version[10];
-static const uint8_t boot[] = {
+static const u8int boot[] = {
#include "sl.boot.h"
};
--- a/src/mem.c
+++ b/src/mem.c
@@ -5,7 +5,7 @@
#define HAVE_MORECORE 1
#define MORECORE sl_sbrk
-static void *sl_sbrk(intptr_t increment);
+static void *sl_sbrk(intptr increment);
#define MORECORE_CONTIGUOUS 0
#define MORECORE_CANNOT_TRIM 1
#define NO_SEGMENT_TRAVERSAL 1
@@ -60,7 +60,7 @@
#if defined(__macos__)
static void *
-sl_sbrk(intptr_t increment)
+sl_sbrk(intptr increment)
{
static char *e = nil;
if(increment == 0)
@@ -74,7 +74,7 @@
}
#else
static void *
-sl_sbrk(intptr_t increment)
+sl_sbrk(intptr increment)
{
return sbrk(increment);
}
--- a/src/operators.c
+++ b/src/operators.c
@@ -5,14 +5,14 @@
conv_to_mp(void *data, numerictype_t tag)
{
switch(tag){
- case T_S8: return itomp(*(int8_t*)data, nil);
- case T_U8: return uitomp(*(uint8_t*)data, nil);
- case T_S16: return itomp(*(int16_t*)data, nil);
- case T_U16: return uitomp(*(uint16_t*)data, nil);
- case T_S32: return itomp(*(int32_t*)data, nil);
- case T_U32: return uitomp(*(uint32_t*)data, nil);
- case T_S64: return vtomp(*(int64_t*)data, nil);
- case T_U64: return uvtomp(*(uint64_t*)data, nil);
+ case T_S8: return itomp(*(s8int*)data, nil);
+ case T_U8: return uitomp(*(u8int*)data, nil);
+ case T_S16: return itomp(*(s16int*)data, nil);
+ case T_U16: return uitomp(*(u16int*)data, nil);
+ case T_S32: return itomp(*(s32int*)data, nil);
+ case T_U32: return uitomp(*(u32int*)data, nil);
+ case T_S64: return vtomp(*(s64int*)data, nil);
+ case T_U64: return uvtomp(*(u64int*)data, nil);
case T_MP: return mpcopy(*(mpint**)data);
case T_FLOAT: return dtomp(*(float*)data, nil);
case T_DOUBLE: return dtomp(*(double*)data, nil);
@@ -26,18 +26,18 @@
{
double d;
switch(tag){
- case T_S8: return *(int8_t*)data;
- case T_U8: return *(uint8_t*)data;
- case T_S16: return *(int16_t*)data;
- case T_U16: return *(uint16_t*)data;
- case T_S32: return *(int32_t*)data;
- case T_U32: return *(uint32_t*)data;
+ case T_S8: return *(s8int*)data;
+ case T_U8: return *(u8int*)data;
+ case T_S16: return *(s16int*)data;
+ case T_U16: return *(u16int*)data;
+ case T_S32: return *(s32int*)data;
+ case T_U32: return *(u32int*)data;
case T_S64:
- d = *(int64_t*)data;
- if(d > 0 && *(int64_t*)data < 0) // can happen!
+ d = *(s64int*)data;
+ if(d > 0 && *(s64int*)data < 0) // can happen!
d = -d;
return d;
- case T_U64: return *(uint64_t*)data;
+ case T_U64: return *(u64int*)data;
case T_MP: return mptod(*(mpint**)data);
case T_FLOAT: return *(float*)data;
case T_DOUBLE: return *(double*)data;
@@ -52,14 +52,14 @@
conv_to_##name(void *data, numerictype_t tag) \
{ \
switch(tag){ \
- case T_S8: return (ctype)*(int8_t*)data; \
- case T_U8: return (ctype)*(uint8_t*)data; \
- case T_S16: return (ctype)*(int16_t*)data; \
- case T_U16: return (ctype)*(uint16_t*)data; \
- case T_S32: return (ctype)*(int32_t*)data; \
- case T_U32: return (ctype)*(uint32_t*)data; \
- case T_S64: return (ctype)*(int64_t*)data; \
- case T_U64: return (ctype)*(uint64_t*)data; \
+ case T_S8: return (ctype)*(s8int*)data; \
+ case T_U8: return (ctype)*(u8int*)data; \
+ case T_S16: return (ctype)*(s16int*)data; \
+ case T_U16: return (ctype)*(u16int*)data; \
+ case T_S32: return (ctype)*(s32int*)data; \
+ case T_U32: return (ctype)*(u32int*)data; \
+ case T_S64: return (ctype)*(s64int*)data; \
+ case T_U64: return (ctype)*(u64int*)data; \
case T_MP: return (ctype)mptov(*(mpint**)data); \
case T_FLOAT: return (ctype)*(float*)data; \
case T_DOUBLE: return (ctype)*(double*)data; \
@@ -67,27 +67,27 @@
return 0; \
}
-CONV_TO_INTTYPE(s64, int64_t)
-CONV_TO_INTTYPE(s32, int32_t)
-CONV_TO_INTTYPE(u32, uint32_t)
+CONV_TO_INTTYPE(s64, s64int)
+CONV_TO_INTTYPE(s32, s32int)
+CONV_TO_INTTYPE(u32, u32int)
// this is needed to work around an UB casting negative
// floats and doubles to uint64. you need to cast to int64
// first.
sl_purefn
-uint64_t
+u64int
conv_to_u64(void *data, numerictype_t tag)
{
- int64_t s;
+ s64int s;
switch(tag){
- case T_S8: return *(int8_t*)data; break;
- case T_U8: return *(uint8_t*)data; break;
- case T_S16: return *(int16_t*)data; break;
- case T_U16: return *(uint16_t*)data; break;
- case T_S32: return *(int32_t*)data; break;
- case T_U32: return *(uint32_t*)data; break;
- case T_S64: return *(int64_t*)data; break;
- case T_U64: return *(uint64_t*)data; break;
+ case T_S8: return *(s8int*)data; break;
+ case T_U8: return *(u8int*)data; break;
+ case T_S16: return *(s16int*)data; break;
+ case T_U16: return *(u16int*)data; break;
+ case T_S32: return *(s32int*)data; break;
+ case T_U32: return *(u32int*)data; break;
+ case T_S64: return *(s64int*)data; break;
+ case T_U64: return *(u64int*)data; break;
case T_MP: return mptouv(*(mpint**)data); break;
case T_FLOAT:
if(*(float*)data >= 0)
@@ -108,14 +108,14 @@
cmp_same_lt(void *a, void *b, numerictype_t tag)
{
switch(tag){
- case T_S8: return *(int8_t*)a < *(int8_t*)b;
- case T_U8: return *(uint8_t*)a < *(uint8_t*)b;
- case T_S16: return *(int16_t*)a < *(int16_t*)b;
- case T_U16: return *(uint16_t*)a < *(uint16_t*)b;
- case T_S32: return *(int32_t*)a < *(int32_t*)b;
- case T_U32: return *(uint32_t*)a < *(uint32_t*)b;
- case T_S64: return *(int64_t*)a < *(int64_t*)b;
- case T_U64: return *(uint64_t*)a < *(uint64_t*)b;
+ case T_S8: return *(s8int*)a < *(s8int*)b;
+ case T_U8: return *(u8int*)a < *(u8int*)b;
+ case T_S16: return *(s16int*)a < *(s16int*)b;
+ case T_U16: return *(u16int*)a < *(u16int*)b;
+ case T_S32: return *(s32int*)a < *(s32int*)b;
+ case T_U32: return *(u32int*)a < *(u32int*)b;
+ case T_S64: return *(s64int*)a < *(s64int*)b;
+ case T_U64: return *(u64int*)a < *(u64int*)b;
case T_MP: return mpcmp(*(mpint**)a, *(mpint**)b) < 0;
case T_FLOAT: return *(float*)a < *(float*)b;
case T_DOUBLE: return *(double*)a < *(double*)b;
@@ -128,14 +128,14 @@
cmp_same_eq(void *a, void *b, numerictype_t tag)
{
switch(tag){
- case T_S8: return *(int8_t*)a == *(int8_t*)b;
- case T_U8: return *(uint8_t*)a == *(uint8_t*)b;
- case T_S16: return *(int16_t*)a == *(int16_t*)b;
- case T_U16: return *(uint16_t*)a == *(uint16_t*)b;
- case T_S32: return *(int32_t*)a == *(int32_t*)b;
- case T_U32: return *(uint32_t*)a == *(uint32_t*)b;
- case T_S64: return *(int64_t*)a == *(int64_t*)b;
- case T_U64: return *(uint64_t*)a == *(uint64_t*)b;
+ case T_S8: return *(s8int*)a == *(s8int*)b;
+ case T_U8: return *(u8int*)a == *(u8int*)b;
+ case T_S16: return *(s16int*)a == *(s16int*)b;
+ case T_U16: return *(u16int*)a == *(u16int*)b;
+ case T_S32: return *(s32int*)a == *(s32int*)b;
+ case T_U32: return *(u32int*)a == *(u32int*)b;
+ case T_S64: return *(s64int*)a == *(s64int*)b;
+ case T_U64: return *(u64int*)a == *(u64int*)b;
case T_MP: return mpcmp(*(mpint**)a, *(mpint**)b) == 0;
case T_FLOAT: return *(float*)a == *(float*)b && !isnan(*(float*)a);
case T_DOUBLE: return *(double*)a == *(double*)b && !isnan(*(double*)b);
@@ -170,31 +170,31 @@
if(atag == T_U64){
if(btag == T_S64)
- return *(int64_t*)b >= 0 && *(uint64_t*)a < (uint64_t)*(int64_t*)b;
+ return *(s64int*)b >= 0 && *(u64int*)a < (u64int)*(s64int*)b;
if(btag == T_DOUBLE)
- return db >= 0 ? *(uint64_t*)a < (uint64_t)*(double*)b : 0;
+ return db >= 0 ? *(u64int*)a < (u64int)*(double*)b : 0;
if(btag == T_MP)
- return mpcmp(uvtomp(*(uint64_t*)a, cmpmpint), *(mpint**)b) < 0;
+ return mpcmp(uvtomp(*(u64int*)a, cmpmpint), *(mpint**)b) < 0;
}
if(atag == T_S64){
if(btag == T_U64)
- return *(int64_t*)a >= 0 && (uint64_t)*(int64_t*)a < *(uint64_t*)b;
+ return *(s64int*)a >= 0 && (u64int)*(s64int*)a < *(u64int*)b;
if(btag == T_DOUBLE)
- return db == db ? *(int64_t*)a < (int64_t)*(double*)b : 0;
+ return db == db ? *(s64int*)a < (s64int)*(double*)b : 0;
if(btag == T_MP)
- return mpcmp(vtomp(*(int64_t*)a, cmpmpint), *(mpint**)b) < 0;
+ return mpcmp(vtomp(*(s64int*)a, cmpmpint), *(mpint**)b) < 0;
}
if(btag == T_U64){
if(atag == T_DOUBLE)
- return da >= 0 ? *(uint64_t*)b > (uint64_t)*(double*)a : 0;
+ return da >= 0 ? *(u64int*)b > (u64int)*(double*)a : 0;
if(atag == T_MP)
- return mpcmp(*(mpint**)a, uvtomp(*(uint64_t*)b, cmpmpint)) < 0;
+ return mpcmp(*(mpint**)a, uvtomp(*(u64int*)b, cmpmpint)) < 0;
}
if(btag == T_S64){
if(atag == T_DOUBLE)
- return da == da ? *(int64_t*)b > (int64_t)*(double*)a : 0;
+ return da == da ? *(s64int*)b > (s64int)*(double*)a : 0;
if(atag == T_MP)
- return mpcmp(*(mpint**)a, vtomp(*(int64_t*)b, cmpmpint)) < 0;
+ return mpcmp(*(mpint**)a, vtomp(*(s64int*)b, cmpmpint)) < 0;
}
return false;
}
@@ -204,7 +204,7 @@
{
union {
double d;
- int64_t i64;
+ s64int i64;
}u, v;
if(atag == btag && (!equalnans || atag < T_FLOAT))
@@ -231,35 +231,35 @@
// this is safe because if a had been bigger than INT64_MAX,
// we would already have concluded that it's bigger than b.
if(btag == T_S64)
- return *(int64_t*)b >= 0 && *(uint64_t*)a == *(uint64_t*)b;
+ return *(s64int*)b >= 0 && *(u64int*)a == *(u64int*)b;
if(btag == T_DOUBLE)
- return *(double*)b >= 0 && *(uint64_t*)a == (uint64_t)*(double*)b;
+ return *(double*)b >= 0 && *(u64int*)a == (u64int)*(double*)b;
if(btag == T_MP)
- return mpcmp(uvtomp(*(uint64_t*)a, cmpmpint), *(mpint**)b) == 0;
+ return mpcmp(uvtomp(*(u64int*)a, cmpmpint), *(mpint**)b) == 0;
}
if(atag == T_S64){
if(btag == T_U64)
- return *(int64_t*)a >= 0 && *(uint64_t*)a == *(uint64_t*)b;
+ return *(s64int*)a >= 0 && *(u64int*)a == *(u64int*)b;
if(btag == T_DOUBLE)
- return *(int64_t*)a == (int64_t)*(double*)b;
+ return *(s64int*)a == (s64int)*(double*)b;
if(btag == T_MP)
- return mpcmp(vtomp(*(int64_t*)a, cmpmpint), *(mpint**)b) == 0;
+ return mpcmp(vtomp(*(s64int*)a, cmpmpint), *(mpint**)b) == 0;
}
if(btag == T_U64){
if(atag == T_S64)
- return *(int64_t*)a >= 0 && *(uint64_t*)b == *(uint64_t*)a;
+ return *(s64int*)a >= 0 && *(u64int*)b == *(u64int*)a;
if(atag == T_DOUBLE)
- return *(double*)a >= 0 && *(uint64_t*)b == (uint64_t)*(double*)a;
+ return *(double*)a >= 0 && *(u64int*)b == (u64int)*(double*)a;
if(atag == T_MP)
- return mpcmp(*(mpint**)a, uvtomp(*(uint64_t*)b, cmpmpint)) == 0;
+ return mpcmp(*(mpint**)a, uvtomp(*(u64int*)b, cmpmpint)) == 0;
}
if(btag == T_S64){
if(atag == T_U64)
- return *(int64_t*)b >= 0 && *(uint64_t*)b == *(uint64_t*)a;
+ return *(s64int*)b >= 0 && *(u64int*)b == *(u64int*)a;
if(atag == T_DOUBLE)
- return *(int64_t*)b == (int64_t)*(double*)a;
+ return *(s64int*)b == (s64int)*(double*)a;
if(atag == T_MP)
- return mpcmp(*(mpint**)a, vtomp(*(int64_t*)b, cmpmpint)) == 0;
+ return mpcmp(*(mpint**)a, vtomp(*(s64int*)b, cmpmpint)) == 0;
}
return true;
}
--- a/src/operators.h
+++ b/src/operators.h
@@ -8,8 +8,8 @@
bool cmp_lt(void *a, numerictype_t atag, void *b, numerictype_t btag);
bool cmp_eq(void *a, numerictype_t atag, void *b, numerictype_t btag, bool equalnans);
-int64_t conv_to_s64(void *data, numerictype_t tag);
-uint64_t conv_to_u64(void *data, numerictype_t tag);
-int32_t conv_to_s32(void *data, numerictype_t tag);
-uint32_t conv_to_u32(void *data, numerictype_t tag);
+s64int conv_to_s64(void *data, numerictype_t tag);
+u64int conv_to_u64(void *data, numerictype_t tag);
+s32int conv_to_s32(void *data, numerictype_t tag);
+u32int conv_to_u32(void *data, numerictype_t tag);
Rune conv_to_Rune(void *data, numerictype_t tag);
--- a/src/plan9/clz.c
+++ b/src/plan9/clz.c
@@ -1,9 +1,9 @@
#include "platform.h"
int
-sl_clz(uint32_t x)
+sl_clz(u32int x)
{
- uint32_t r;
+ u32int r;
if(x == 0)
return 32;
for(r = 0; (x & (1UL<<31)) == 0; x <<= 1, r++);
--- a/src/plan9/platform.h
+++ b/src/plan9/platform.h
@@ -62,8 +62,8 @@
#define towupper toupperrune
#define towlower tolowerrune
#define iswalpha isalpharune
-#define signbit(r) ((*(uint64_t*)&(r)) & (1ULL<<63))
-#define isfinite(d) (((*(uint64_t*)&(d))&0x7ff0000000000000ULL) != 0x7ff0000000000000ULL)
+#define signbit(r) ((*(u64int*)&(r)) & (1ULL<<63))
+#define isfinite(d) (((*(u64int*)&(d))&0x7ff0000000000000ULL) != 0x7ff0000000000000ULL)
#define PRId32 "d"
#define PRIu32 "ud"
@@ -75,7 +75,7 @@
#define INT32_MAX 0x7fffffff
#define UINT32_MAX 0xffffffffU
#define INT32_MIN (-INT32_MAX-1)
-#define INT64_MIN ((int64_t)0x8000000000000000LL)
+#define INT64_MIN ((s64int)0x8000000000000000ULL)
#define INT64_MAX 0x7fffffffffffffffLL
#define UINT64_MAX 0xffffffffffffffffULL
#define ULONG_MAX UINT32_MAX
@@ -115,17 +115,7 @@
#define BYTE_ORDER LITTLE_ENDIAN
#endif
-typedef s8int int8_t;
-typedef s16int int16_t;
-typedef s32int int32_t;
-typedef s64int int64_t;
-typedef u8int uint8_t;
-typedef u16int uint16_t;
-typedef u32int uint32_t;
-typedef u64int uint64_t;
typedef vlong off_t;
-typedef intptr intptr_t;
-typedef uintptr uintptr_t;
typedef intptr ssize_t;
typedef uintptr size_t;
typedef enum { false, true } bool;
--- a/src/posix/sys.c
+++ b/src/posix/sys.c
@@ -31,7 +31,7 @@
sz = PAGEALIGNED(sz);
used = PAGEALIGNED(used);
// it's fine if this fails
- madvise((uint8_t*)s+used, sz-used, MADV_DONTNEED);
+ madvise((u8int*)s+used, sz-used, MADV_DONTNEED);
}
double
@@ -43,10 +43,10 @@
return (double)now.tv_sec + (double)now.tv_nsec/1.0e9;
}
-uint64_t
+u64int
nanosec_monotonic(void)
{
- static int64_t z;
+ static s64int z;
struct timespec now;
if(clock_gettime(CLOCK_MONOTONIC, &now) != 0)
@@ -101,7 +101,7 @@
}
}
-static const uint8_t boot[] = {
+static const u8int boot[] = {
#include "sl.boot.h"
};
--- a/src/print.c
+++ b/src/print.c
@@ -382,10 +382,10 @@
value_t label;
if((label = (value_t)ptrhash_get(&SL(printconses), (void*)v)) != (value_t)HT_NOTFOUND){
if(!ismarked(v)){
- SL(hpos) += ios_printf(f, "#%"PRIdPTR"#", (intptr_t)numval(label));
+ SL(hpos) += ios_printf(f, "#%"PRIdPTR"#", (intptr)numval(label));
return true;
}
- SL(hpos) += ios_printf(f, "#%"PRIdPTR"=", (intptr_t)numval(label));
+ SL(hpos) += ios_printf(f, "#%"PRIdPTR"=", (intptr)numval(label));
}
if(ismanaged(v))
unmark_cons(v);
@@ -510,7 +510,7 @@
print_string(ios_t *f, const char *str, size_t sz)
{
char buf[64];
- uint8_t c;
+ u8int c;
static const char hexdig[] = "0123456789abcdef";
size_t i = 0;
@@ -642,7 +642,7 @@
cvalue_printdata(ios_t *f, void *data, size_t len, value_t type, int weak)
{
if(type == sl_bytesym){
- uint8_t ch = *(uint8_t*)data;
+ u8int ch = *(u8int*)data;
if(SL(print_princ))
outc(f, ch);
else if(weak)
@@ -718,7 +718,7 @@
outc(f, 'f');
}
}else if(type == sl_u64sym){
- uint64_t ui64 = *(uint64_t*)data;
+ u64int ui64 = *(u64int*)data;
if(weak || SL(print_princ))
SL(hpos) += ios_printf(f, "%"PRIu64, ui64);
else
@@ -733,7 +733,7 @@
// at this point, so int64 is big enough to capture everything.
numerictype_t nt = sym_to_numtype(type);
if(valid_numtype(nt)){
- int64_t i64 = conv_to_s64(data, nt);
+ s64int i64 = conv_to_s64(data, nt);
if(weak || SL(print_princ))
SL(hpos) += ios_printf(f, "%"PRId64, i64);
else
--- a/src/ptrhash.c
+++ b/src/ptrhash.c
@@ -6,8 +6,8 @@
#include "sl.h"
#if defined(BITS64)
-static uint64_t
-_pinthash(uint64_t key)
+static u64int
+_pinthash(u64int key)
{
key = (~key) + (key << 21); // key = (key << 21) - key - 1;
key = key ^ (key >> 24);
@@ -19,8 +19,8 @@
return key;
}
#else
-static uint32_t
-_pinthash(uint32_t a)
+static u32int
+_pinthash(u32int a)
{
a = (a+0x7ed55d16) + (a<<12);
a = (a^0xc761c23c) ^ (a>>19);
--- a/src/read.c
+++ b/src/read.c
@@ -16,7 +16,7 @@
typedef struct Rctx Rctx;
struct Rctx {
- uint32_t toktype;
+ u32int toktype;
value_t tokval;
ios_loc_t loc;
char buf[1024];
@@ -30,7 +30,7 @@
sl_read_numtok(const char *tok, value_t *pval, int base)
{
char *end;
- int64_t i64;
+ s64int i64;
double d;
if(*tok == '\0')
@@ -129,7 +129,7 @@
int n;
n = snprintf(msgbuf, sizeof(msgbuf), "%s:%"PRIu64":%"PRIu64": ",
- loc->filename, (uint64_t)loc->lineno, (uint64_t)loc->colno);
+ loc->filename, (u64int)loc->lineno, (u64int)loc->colno);
if(n >= (int)sizeof(msgbuf))
n = 0;
va_start(args, format);
@@ -196,7 +196,7 @@
return (c >= '0' && c <= '9') || (c >= 'a' && c < 'a'+base-10) || (c >= 'A' && c < 'A'+base-10);
}
-static uint32_t
+static u32int
peek(Rctx *ctx)
{
char c, *end;
@@ -411,10 +411,10 @@
}
static value_t
-read_vector(Rctx *ctx, value_t label, uint32_t closer)
+read_vector(Rctx *ctx, value_t label, u32int closer)
{
value_t v = SL(the_empty_vector), elt;
- uint32_t i = 0;
+ u32int i = 0;
PUSH(v);
if(label != UNBOUND)
ptrhash_put(&SL(readstate)->backrefs, (void*)label, (void*)v);
@@ -547,10 +547,10 @@
// can move whenever a new cons is allocated. we have to refer to every cons
// through a handle to a relocatable pointer (i.e. a pointer on the stack).
static void
-read_list(Rctx *ctx, value_t label, uint32_t closer)
+read_list(Rctx *ctx, value_t label, u32int closer)
{
value_t c, *pc, *pval, *ipval, *ipc;
- uint32_t t;
+ u32int t;
ios_loc_t loc0;
loc0 = RS->loc;
@@ -607,7 +607,7 @@
{
value_t v, sym, oldtokval, *head;
value_t *pv;
- uint32_t t;
+ u32int t;
char c;
t = peek(ctx);
@@ -692,7 +692,7 @@
case TOK_LABEL:
// create backreference label
if(ptrhash_has(&SL(readstate)->backrefs, (void*)ctx->tokval))
- parse_error(&ctx->loc, "label %"PRIdPTR" redefined", (intptr_t)numval(ctx->tokval));
+ parse_error(&ctx->loc, "label %"PRIdPTR" redefined", (intptr)numval(ctx->tokval));
oldtokval = ctx->tokval;
v = do_read_sexpr(ctx, ctx->tokval);
ptrhash_put(&SL(readstate)->backrefs, (void*)oldtokval, (void*)v);
@@ -701,7 +701,7 @@
// look up backreference
v = (value_t)ptrhash_get(&SL(readstate)->backrefs, (void*)ctx->tokval);
if(v == (value_t)HT_NOTFOUND)
- parse_error(&ctx->loc, "undefined label %"PRIdPTR, (intptr_t)numval(ctx->tokval));
+ parse_error(&ctx->loc, "undefined label %"PRIdPTR, (intptr)numval(ctx->tokval));
return v;
case TOK_GENSYM:
pv = (value_t*)ptrhash_bp(&SL(readstate)->gensyms, (void*)ctx->tokval);
--- a/src/sl.c
+++ b/src/sl.c
@@ -252,10 +252,10 @@
}
char *
-uint2str(char *dest, size_t len, uint64_t num, int base)
+uint2str(char *dest, size_t len, u64int num, int base)
{
int i = len-1;
- uint64_t b = (uint64_t)base;
+ u64int b = (u64int)base;
char ch;
dest[i--] = '\0';
while(i >= 0){
@@ -359,7 +359,7 @@
if(isfixnum(v))
return v;
- uintptr_t t = tag(v);
+ uintptr t = tag(v);
if(t == TAG_CONS){
// iterative implementation allows arbitrarily long cons chains
pcdr = &first;
@@ -521,7 +521,7 @@
// if we're using > 80% of the space, resize tospace so we have
// more space to fill next time. if we grew tospace last time,
// grow the other half of the heap this time to catch up.
- if(SL(grew) || ((intptr_t)(SL(lim)-SL(curheap)) < (intptr_t)SL(heapsize)/5) || mustgrow){
+ if(SL(grew) || ((intptr)(SL(lim)-SL(curheap)) < (intptr)SL(heapsize)/5) || mustgrow){
sl_segfree(SL(tospace), SL(heapsize));
SL(tospace) = sl_segalloc(SL(heapsize)*2);
if(sl_unlikely(SL(tospace) == nil)){
@@ -539,7 +539,7 @@
temp = bitvector_resize(SL(consflags), 0, SL(heapsize)/sizeof(cons_t), 1);
if(sl_unlikely(temp == nil))
sl_raise(SL(memory_exception_value));
- SL(consflags) = (uint32_t*)temp;
+ SL(consflags) = (u32int*)temp;
}
SL(grew) = !SL(grew);
}
@@ -779,7 +779,7 @@
if(i >= nargs)
goto no_kw;
// now process keywords
- uintptr_t n = vector_size(kwtable)/2;
+ uintptr n = vector_size(kwtable)/2;
do{
i++;
if(sl_unlikely(i >= nargs))
@@ -786,9 +786,9 @@
lerrorf(sl_errarg, "keyword %s requires an argument", symbol_name(v));
value_t hv = fixnum(((symbol_t*)ptr(v))->hash);
fixnum_t lx = numval(hv);
- uintptr_t x = 2*((lx < 0 ? -lx : lx) % n);
+ uintptr x = 2*((lx < 0 ? -lx : lx) % n);
if(sl_likely(vector_elt(kwtable, x) == v)){
- intptr_t idx = numval(vector_elt(kwtable, x+1));
+ intptr idx = numval(vector_elt(kwtable, x+1));
assert(idx < nkw);
idx += nopt;
if(args[idx] == UNBOUND){
@@ -812,7 +812,7 @@
memmove(bp+ntot, bp+i, nrestargs*sizeof(value_t));
memmove(bp+nreq, args, extr*sizeof(value_t));
SL(sp) = bp + nargs;
- assert((intptr_t)(SL(sp)-SL(stack)) < (intptr_t)SL(nstack)-4);
+ assert((intptr)(SL(sp)-SL(stack)) < (intptr)SL(nstack)-4);
PUSH(s4);
PUSH(s3);
PUSH(nargs);
@@ -822,11 +822,11 @@
}
#if BYTE_ORDER == LITTLE_ENDIAN && defined(MEM_UNALIGNED_ACCESS)
-#define GET_S32(a) *(const int32_t*)(a)
-#define GET_S16(a) *(const int16_t*)(a)
+#define GET_S32(a) *(const s32int*)(a)
+#define GET_S16(a) *(const s16int*)(a)
#else
-#define GET_S32(a) (int32_t)((a)[0]<<0 | (a)[1]<<8 | (a)[2]<<16 | (uint32_t)(a)[3]<<24)
-#define GET_S16(a) (int16_t)((a)[0]<<0 | (a)[1]<<8)
+#define GET_S32(a) (s32int)((a)[0]<<0 | (a)[1]<<8 | (a)[2]<<16 | (u32int)(a)[3]<<24)
+#define GET_S16(a) (s16int)((a)[0]<<0 | (a)[1]<<8)
#endif
/*
@@ -847,7 +847,7 @@
{
value_t *top_frame = SL(curr_frame), *bp, *ipd;
register value_t *sp = SL(sp);
- const uint8_t *ip;
+ const u8int *ip;
bool tail;
int n;
@@ -870,7 +870,7 @@
#undef NEXT_OP
#pragma GCC diagnostic pop
#else /* just a usual (portable) switch/case */
- uint8_t op;
+ u8int op;
while(1){
switch(op){
#define NEXT_OP break
@@ -895,12 +895,12 @@
sl_gc_handle(&lst);
while(top > stack){
- const uint8_t *ip1 = (void*)top[-1];
+ const u8int *ip1 = (void*)top[-1];
int sz = top[-2]+1;
value_t *bp = top-4-sz;
value_t func = bp[0];
- const uint8_t *ip0 = cvalue_data(fn_bcode(func));
- intptr_t ip = ip1 - ip0 - 1; /* -1: ip1 is *after* the one that was being executed */
+ const u8int *ip0 = cvalue_data(fn_bcode(func));
+ intptr ip = ip1 - ip0 - 1; /* -1: ip1 is *after* the one that was being executed */
value_t v = alloc_vector(sz+1, 0);
vector_elt(v, 0) = fixnum(ip);
vector_elt(v, 1) = func;
@@ -939,7 +939,7 @@
type_error("vector", args[1]);
cvalue_t *arr = ptr(args[0]);
cv_pin(arr);
- uint8_t *data = cv_data(arr);
+ u8int *data = cv_data(arr);
if(SL(loading)){
// read syntax, shifted 48 for compact text representation
size_t i, sz = cv_len(arr);
@@ -1166,13 +1166,13 @@
USED(args);
argcount(nargs, 0);
ios_printf(ios_stderr, "heap total %10"PRIuPTR" bytes\n", SL(heapsize));
- ios_printf(ios_stderr, "heap free %10"PRIuPTR" bytes\n", (uintptr_t)(SL(lim)-SL(curheap)));
- ios_printf(ios_stderr, "heap used %10"PRIuPTR" bytes\n", (uintptr_t)(SL(curheap)-SL(fromspace)));
- ios_printf(ios_stderr, "stack %10"PRIu64" bytes\n", (uint64_t)SL(nstack)*sizeof(value_t));
- ios_printf(ios_stderr, "finalizers %10"PRIu32"\n", (uint32_t)SL(nfinalizers));
- ios_printf(ios_stderr, "max finalizers %10"PRIu32"\n", (uint32_t)SL(maxfinalizers));
- ios_printf(ios_stderr, "gc handles %10"PRIu32"\n", (uint32_t)SL(ngchandles));
- ios_printf(ios_stderr, "gc calls %10"PRIu64"\n", (uint64_t)SL(gccalls));
+ ios_printf(ios_stderr, "heap free %10"PRIuPTR" bytes\n", (uintptr)(SL(lim)-SL(curheap)));
+ ios_printf(ios_stderr, "heap used %10"PRIuPTR" bytes\n", (uintptr)(SL(curheap)-SL(fromspace)));
+ ios_printf(ios_stderr, "stack %10"PRIu64" bytes\n", (u64int)SL(nstack)*sizeof(value_t));
+ ios_printf(ios_stderr, "finalizers %10"PRIu32"\n", (u32int)SL(nfinalizers));
+ ios_printf(ios_stderr, "max finalizers %10"PRIu32"\n", (u32int)SL(maxfinalizers));
+ ios_printf(ios_stderr, "gc handles %10"PRIu32"\n", (u32int)SL(ngchandles));
+ ios_printf(ios_stderr, "gc calls %10"PRIu64"\n", (u64int)SL(gccalls));
ios_printf(ios_stderr, "opcodes %10d\n", N_OPCODES);
return sl_void;
}
--- a/src/sl.h
+++ b/src/sl.h
@@ -39,16 +39,16 @@
T_DOUBLE,
}numerictype_t;
-typedef uintptr_t value_t;
+typedef uintptr value_t;
#if defined(BITS64)
-typedef int64_t fixnum_t;
+typedef s64int fixnum_t;
#define FIXNUM_BITS 62
#define TOP_BIT (1ULL<<63)
#define T_FIXNUM T_S64
#define PRIdFIXNUM PRId64
#else
-typedef int32_t fixnum_t;
+typedef s32int fixnum_t;
#define FIXNUM_BITS 30
#define TOP_BIT (1U<<31)
#define T_FIXNUM T_S32
@@ -67,18 +67,18 @@
// NOTE: symbol_t MUST have the same fields as gensym_t first
// there are places where gensyms are treated as normal symbols
typedef struct {
- uint64_t hash;
+ u64int hash;
sltype_t *type;
value_t binding; // global value binding
- uint8_t numtype;
- uint8_t size;
- uint8_t flags;
- uint8_t _dummy;
+ u8int numtype;
+ u8int size;
+ u8int flags;
+ u8int _dummy;
const char *name;
}sl_aligned(8) symbol_t;
typedef struct {
- uint64_t id;
+ u64int id;
sltype_t *type;
value_t binding;
}sl_aligned(8) gensym_t;
@@ -100,7 +100,7 @@
#define valid_numtype(v) ((v) <= T_DOUBLE)
#define UNBOUND ((value_t)1) // an invalid value
#define tag(x) ((x) & 7)
-#define ptr(x) ((void*)((uintptr_t)(x) & (~(uintptr_t)7)))
+#define ptr(x) ((void*)((uintptr)(x) & (~(uintptr)7)))
#define tagptr(p, t) ((value_t)(p) | (t))
#define fixnum(x) ((value_t)(x)<<2)
#define numval(x) ((fixnum_t)(x)>>2)
@@ -154,7 +154,7 @@
#define iskeyword(s) ((s)->flags & FLAG_KEYWORD)
#define symbol_value(s) (((symbol_t*)ptr(s))->binding)
#define sym_to_numtype(s) (((symbol_t*)ptr(s))->numtype)
-#define ismanaged(v) ((((uint8_t*)ptr(v)) >= SL(fromspace)) && (((uint8_t*)ptr(v)) < SL(fromspace)+SL(heapsize)))
+#define ismanaged(v) ((((u8int*)ptr(v)) >= SL(fromspace)) && (((u8int*)ptr(v)) < SL(fromspace)+SL(heapsize)))
#define isgensym(x) (issymbol(x) && ismanaged(x))
#define isfunction(x) (tag(x) == TAG_FUNCTION && (x) > (N_BUILTINS<<3))
#define iscbuiltin(x) (iscvalue(x) && cv_class(ptr(x)) == SL(builtintype))
@@ -220,7 +220,7 @@
value_t mk_cons(void) sl_hotfn;
void *alloc_words(int n) sl_hotfn;
-char *uint2str(char *dest, size_t len, uint64_t num, int base);
+char *uint2str(char *dest, size_t len, u64int num, int base);
/* error handling */
typedef struct _sl_readstate_t {
@@ -297,12 +297,12 @@
builtin_t cbuiltin;
};
size_t len; // length of *data in bytes
- uint8_t _space[]; // variable size
+ u8int _space[]; // variable size
}sl_aligned(8) cvalue_t;
typedef struct {
sltype_t *type;
- uint8_t _space[];
+ u8int _space[];
}sl_aligned(8) cprim_t;
typedef struct {
@@ -313,7 +313,7 @@
}sl_aligned(8) function_t;
#define CPRIM_NWORDS sizeof(cprim_t)/sizeof(value_t)
-#define cv_class(cv) ((sltype_t*)(((uintptr_t)((cvalue_t*)cv)->type)&~(uintptr_t)3))
+#define cv_class(cv) ((sltype_t*)(((uintptr)((cvalue_t*)cv)->type)&~(uintptr)3))
#define cv_len(cv) (((cvalue_t*)(cv))->len)
#define cv_type(cv) (cv_class(cv)->type)
#define cv_data(cv) (((cvalue_t*)(cv))->data)
@@ -354,18 +354,18 @@
struct Sl {
value_t *sp;
- uint8_t *curheap;
+ u8int *curheap;
value_t *curr_frame;
- uint8_t *fromspace;
- uint8_t *tospace;
- uint8_t *lim;
+ u8int *fromspace;
+ u8int *tospace;
+ u8int *lim;
value_t *stack;
- uintptr_t heapsize;//bytes
+ uintptr heapsize;//bytes
size_t malloc_pressure;
- uint32_t nstack;
+ u32int nstack;
cvalue_t **finalizers;
size_t nfinalizers;
@@ -397,7 +397,7 @@
sltype_t *stringtype, *runestringtype;
sltype_t *builtintype;
- uint32_t gensym_ctr;
+ u32int gensym_ctr;
// two static buffers for gensym printing so there can be two
// gensym names available at a time, mostly for compare()
char gsname[2][16];
@@ -407,11 +407,11 @@
bool exiting;
bool grew;
- uint32_t *consflags;
+ u32int *consflags;
size_t gccalls;
htable_t printconses;
- uint32_t printlabel;
+ u32int printlabel;
int print_pretty;
int print_princ;
fixnum_t print_length;
@@ -449,4 +449,4 @@
extern value_t sl_bytesym, sl_runesym, sl_floatsym, sl_doublesym;
extern value_t sl_stringtypesym, sl_runestringtypesym;
-_Noreturn void slmain(const uint8_t *boot, int bootsz, int argc, char **argv);
+_Noreturn void slmain(const u8int *boot, int bootsz, int argc, char **argv);
--- a/src/sl_arith_any.inc
+++ b/src/sl_arith_any.inc
@@ -1,12 +1,12 @@
//value_t
-//sl_*_any(value_t *args, uint32_t nargs)
+//sl_*_any(value_t *args, u32int nargs)
// input: ACCUM_DEFAULT ARITH_OP(a,b) MP_OP ARITH_OVERFLOW
// add: 0 a+b mpadd sadd_overflow_64
// mul: 1 a*b mpmul smul_overflow_64
mpint *Maccum = nil, *m = nil;
- int64_t Saccum = ACCUM_DEFAULT, x;
- uint64_t u64;
+ s64int Saccum = ACCUM_DEFAULT, x;
+ u64int u64;
double Faccum = ACCUM_DEFAULT;
bool inexact = false;
value_t arg;
@@ -15,7 +15,7 @@
cprim_t *cp;
cvalue_t *cv;
- uint32_t i, j;
+ u32int i, j;
FOR_ARGS(i, 0, arg, args){
if(isfixnum(arg))
x = numval(arg);
@@ -37,15 +37,15 @@
switch(pt){
case T_DOUBLE: Faccum = ARITH_OP(Faccum, *(double*)a); inexact = true; continue;
case T_FLOAT: Faccum = ARITH_OP(Faccum, *(float*)a); inexact = true; continue;
- case T_S8: x = *(int8_t*)a; break;
- case T_U8: x = *(uint8_t*)a; break;
- case T_S16: x = *(int16_t*)a; break;
- case T_U16: x = *(uint16_t*)a; break;
- case T_S32: x = *(int32_t*)a; break;
- case T_U32: x = *(uint32_t*)a; break;
- case T_S64: x = *(int64_t*)a; break;
+ case T_S8: x = *(s8int*)a; break;
+ case T_U8: x = *(u8int*)a; break;
+ case T_S16: x = *(s16int*)a; break;
+ case T_U16: x = *(u16int*)a; break;
+ case T_S32: x = *(s32int*)a; break;
+ case T_U32: x = *(u32int*)a; break;
+ case T_S64: x = *(s64int*)a; break;
case T_U64:
- u64 = *(uint64_t*)a;
+ u64 = *(u64int*)a;
if(u64 > INT64_MAX){
x = ACCUM_DEFAULT;
goto overflow;
@@ -62,7 +62,7 @@
}
}
- int64_t accu;
+ s64int accu;
if(ARITH_OVERFLOW(Saccum, x, &accu)){
u64 = ACCUM_DEFAULT;
goto overflow;
@@ -107,15 +107,15 @@
switch(pt){
case T_DOUBLE: Faccum = ARITH_OP(Faccum, *(double*)a); inexact = true; continue;
case T_FLOAT: Faccum = ARITH_OP(Faccum, *(float*)a); inexact = true; continue;
- case T_S8: x = *(int8_t*)a; break;
- case T_U8: x = *(uint8_t*)a; break;
- case T_S16: x = *(int16_t*)a; break;
- case T_U16: x = *(uint16_t*)a; break;
- case T_S32: x = *(int32_t*)a; break;
- case T_U32: x = *(uint32_t*)a; break;
- case T_S64: x = *(int64_t*)a; break;
+ case T_S8: x = *(s8int*)a; break;
+ case T_U8: x = *(u8int*)a; break;
+ case T_S16: x = *(s16int*)a; break;
+ case T_U16: x = *(u16int*)a; break;
+ case T_S32: x = *(s32int*)a; break;
+ case T_U32: x = *(u32int*)a; break;
+ case T_S64: x = *(s64int*)a; break;
case T_U64:
- uvtomp(*(uint64_t*)a, m);
+ uvtomp(*(u64int*)a, m);
MP_OP(Maccum, m, Maccum);
continue;
case T_MP:
--- a/src/slmain.c
+++ b/src/slmain.c
@@ -71,7 +71,7 @@
_Noreturn void
-slmain(const uint8_t *boot, int bootsz, int argc, char **argv)
+slmain(const u8int *boot, int bootsz, int argc, char **argv)
{
size_t heapsize = HEAP_SIZE0, stacksize = STACK_SIZE0;
char *e;
@@ -106,9 +106,9 @@
value_t args = argv_list(argc, argv);
sl_gc_handle(&args);
ios_t *s = value2c(ios_t*, f);
- uint8_t *unpacked = nil;
+ u8int *unpacked = nil;
if(boot[0] == 0){
- uint32_t unpackedsz =
+ u32int unpackedsz =
boot[1]<<0 |
boot[2]<<8 |
boot[3]<<16|
--- a/src/string.c
+++ b/src/string.c
@@ -369,7 +369,7 @@
argcount(nargs, 2);
value_t n = args[0];
bool neg = false;
- uint64_t num;
+ u64int num;
int radix = 10;
if(nargs == 2)
radix = get_radix_arg(args[1]);
--- a/src/timefuncs.h
+++ b/src/timefuncs.h
@@ -1,7 +1,7 @@
#pragma once
double sec_realtime(void);
-uint64_t nanosec_monotonic(void);
+u64int nanosec_monotonic(void);
void timestring(double s, char *buf, int sz);
double parsetime(const char *s);
void sleep_ms(int ms);
--- a/src/utf8.c
+++ b/src/utf8.c
@@ -15,7 +15,7 @@
#include "sl.h"
-static const uint32_t offsetsFromUTF8[6] = {
+static const u32int offsetsFromUTF8[6] = {
0x00000000U, 0x00003080U, 0x000E2080U,
0x03C82080U, 0xFA082080U, 0x82082080U
};
@@ -35,7 +35,7 @@
size_t
u8_seqlen(const char *s)
{
- return trailingBytesForUTF8[(uint8_t)s[0]] + 1;
+ return trailingBytesForUTF8[(u8int)s[0]] + 1;
}
size_t
@@ -43,7 +43,7 @@
{
size_t nr, i;
for(i = nr = 0; i < nb; nr++)
- i += trailingBytesForUTF8[(uint8_t)s[i]] + 1;
+ i += trailingBytesForUTF8[(u8int)s[i]] + 1;
return nr;
}
@@ -82,11 +82,11 @@
Rune
u8_nextmemchar(const char *s, size_t *i)
{
- size_t sz = trailingBytesForUTF8[(uint8_t)s[*i]];
+ size_t sz = trailingBytesForUTF8[(u8int)s[*i]];
Rune ch = 0;
for(size_t j = 0; j <= sz; j++){
ch <<= 6;
- ch += (uint8_t)s[(*i)++];
+ ch += (u8int)s[(*i)++];
};
return ch - offsetsFromUTF8[sz];
}
@@ -203,7 +203,7 @@
c = csz = 0;
do{
c <<= 6;
- c += (uint8_t)s[i++];
+ c += (u8int)s[i++];
csz++;
}while(i < sz && !isutf(s[i]));
c -= offsetsFromUTF8[csz-1];
@@ -223,11 +223,11 @@
bool
u8_isvalid(const char *str, int length)
{
- const uint8_t *p, *pend = (const uint8_t*)str + length;
- uint8_t c;
+ const u8int *p, *pend = (const u8int*)str + length;
+ u8int c;
int ab;
- for(p = (const uint8_t*)str; p < pend; p++){
+ for(p = (const u8int*)str; p < pend; p++){
c = *p;
if(c < 128)
continue;
@@ -295,7 +295,7 @@
dest[di = len] = '\0';
for(si = 0; si < len;){
- switch((uint8_t)src[si]>>4){
+ switch((u8int)src[si]>>4){
case 0xf:
di -= 4;
dest[di+0] = src[si++];
--- a/src/vm.inc
+++ b/src/vm.inc
@@ -1,7 +1,7 @@
#define fixnum_neg(x) ( \
- i64 = -(int64_t)(numval(x)), \
+ i64 = -(s64int)(numval(x)), \
i64 == INT64_MIN \
- ? mk_mp(uvtomp((uint64_t)INT64_MAX+1, nil)) \
+ ? mk_mp(uvtomp((u64int)INT64_MAX+1, nil)) \
: (fits_fixnum(i64) ? fixnum(i64) : mk_mp(vtomp(i64, nil))) \
)
@@ -27,7 +27,7 @@
ip += 4;
}
LABEL(do_call):
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
value_t v = sp[-n-1];
if(tag(v) == TAG_FUNCTION){
if(v > (N_BUILTINS<<3)){
@@ -43,7 +43,7 @@
}
function_t *fn = (function_t*)ptr(bp[-1]);
ip = cvalue_data(fn->bcode);
- assert(!ismanaged((uintptr_t)ip));
+ assert(!ismanaged((uintptr)ip));
*sp++ = fn->env;
*sp++ = (value_t)SL(curr_frame);
*sp++ = nargs;
@@ -105,7 +105,7 @@
ip += 4;
}
if(sl_unlikely(nargs != na)){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
arity_error(nargs, na);
}
@@ -126,7 +126,7 @@
}
sp -= 4+nargs;
ipd = SL(curr_frame)-1;
- ip = (uint8_t*)*ipd;
+ ip = (u8int*)*ipd;
nargs = SL(curr_frame)[-2];
bp = SL(curr_frame) - 4 - nargs;
sp[-1] = v;
@@ -159,7 +159,7 @@
assert(issymbol(v));
symbol_t *sym = ptr(v);
if(sl_unlikely(sym->binding == UNBOUND)){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
unbound_error(v);
}
@@ -206,13 +206,13 @@
fixnum_t a, b, q;
value_t v;
LABEL(do_add2):
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
if(0){
OP(OP_SUB2)
LABEL(do_sub2):
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
v = sp[-1];
- int64_t i64;
+ s64int i64;
b = isfixnum(v) ? fixnum_neg(v) : sl_neg(v);
}else{
b = sp[-1];
@@ -230,7 +230,7 @@
}
OP(OP_LOADI8)
- *sp++ = fixnum((int8_t)*ip++);
+ *sp++ = fixnum((s8int)*ip++);
NEXT_OP;
OP(OP_POP)
@@ -255,7 +255,7 @@
if(sl_likely(iscons(v)))
v = car_(v);
else if(sl_unlikely(v != sl_nil)){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
type_error("cons", v);
}
@@ -318,7 +318,7 @@
if(sl_likely(iscons(v)))
v = cdr_(v);
else if(sl_unlikely(v != sl_nil)){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
type_error("cons", v);
}
@@ -358,7 +358,7 @@
SL(curr_frame) = sp;
}
}else if(sl_unlikely(s < 0)){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
lerrorf(sl_errarg, "too few arguments");
}else{
@@ -384,7 +384,7 @@
OP(OP_SETCAR) {
value_t v = sp[-2];
if(sl_unlikely(!iscons(v))){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
type_error("cons", v);
}
@@ -419,7 +419,7 @@
n = 2;
if(0){
OP(OP_AREF)
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
n = 3 + *ip++;
}
LABEL(apply_aref):;
@@ -490,7 +490,7 @@
OP(OP_SETCDR) {
value_t v = sp[-2];
if(sl_unlikely(!iscons(v))){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
type_error("cons", v);
}
@@ -504,7 +504,7 @@
NEXT_OP;
OP(OP_ASET) {
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
value_t v = sp[-3];
n = 3;
if(0){
@@ -614,13 +614,13 @@
int x = GET_S32(ip);
ip += 4;
if(sl_unlikely(nargs < i)){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
lerrorf(sl_errarg, "too few arguments");
}
if(x > 0){
if(sl_unlikely(nargs > x)){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
lerrorf(sl_errarg, "too many arguments");
}
@@ -658,7 +658,7 @@
}
OP(OP_BOUNDP) {
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
symbol_t *sym = tosymbol(sp[-1]);
sp[-1] = sym->binding == UNBOUND ? sl_nil : sl_t;
NEXT_OP;
@@ -698,7 +698,7 @@
}else{
LABEL(cadr_nil):
if(sl_unlikely(v != sl_nil)){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
type_error("cons", v);
}
@@ -722,7 +722,7 @@
v = cdr_(v);
}
if(v != sl_nil){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
lerrorf(sl_errarg, "apply: last argument: not a list");
}
@@ -742,9 +742,9 @@
OP(OP_NEG) {
LABEL(do_neg):
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
value_t v = sp[-1];
- int64_t i64;
+ s64int i64;
sp[-1] = isfixnum(v) ? fixnum_neg(v) : sl_neg(v);
NEXT_OP;
}
@@ -756,7 +756,7 @@
OP(OP_MUL) {
n = *ip++;
LABEL(apply_mul):
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
value_t v = sl_mul_any(sp-n, n);
sp -= n;
*sp++ = v;
@@ -767,7 +767,7 @@
value_t a = sp[-2];
value_t b = sp[-1];
if(sl_unlikely(b == 0)){
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
divide_by_0_error();
}
@@ -775,7 +775,7 @@
if(bothfixnums(a, b))
v = fixnum((fixnum_t)a / (fixnum_t)b);
else{
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
v = sl_idiv2(a, b);
}
sp--;
@@ -786,7 +786,7 @@
OP(OP_DIV) {
n = *ip++;
LABEL(apply_div):
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
value_t *p = sp-n;
if(n == 1){
sp[-1] = sl_div2(fixnum(1), *p);
@@ -821,7 +821,7 @@
NEXT_OP;
OP(OP_FOR) {
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
value_t *p = sp;
value_t v;
fixnum_t s = tofixnum(p[-3]);
@@ -861,7 +861,7 @@
NEXT_OP;
OP(OP_TRYCATCH) {
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
value_t v = do_trycatch();
sp--;
@@ -874,7 +874,7 @@
if(n == 2)
goto LABEL(do_add2);
LABEL(apply_add):
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
value_t v = sl_add_any(sp-n, n);
sp -= n;
*sp++ = v;
@@ -903,7 +903,7 @@
ip += 4;
fixnum_t s = GET_S32(ip);
ip += 4;
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
SL(sp) = sp;
nargs = process_keys(v, i, x, labs(s)-(i+x), bp, nargs, s<0);
sp = SL(sp);
@@ -918,7 +918,7 @@
goto LABEL(do_sub2);
if(n == 1)
goto LABEL(do_neg);
- *ipd = (uintptr_t)ip;
+ *ipd = (uintptr)ip;
value_t *p = sp-n;
// we need to pass the full arglist on to sl_add_any
// so it can handle rest args properly
@@ -925,7 +925,7 @@
*sp++ = *p;
*p = fixnum(0);
value_t v = sl_add_any(p, n);
- int64_t i64;
+ s64int i64;
p[1] = isfixnum(v) ? fixnum_neg(v) : sl_neg(v);
p[0] = *(--sp);
v = sl_add_any(p, 2);
--- a/tools/lzpack.c
+++ b/tools/lzpack.c
@@ -1,7 +1,7 @@
#include "platform.h"
#include "brieflz.h"
-static uint8_t in[256*1024];
+static u8int in[256*1024];
int
main(int argc, char **argv)
@@ -18,10 +18,10 @@
}
if(sz == sizeof(in))
abort();
- uint8_t *out = MEM_ALLOC(1+4+blz_max_packed_size(sz));
+ u8int *out = MEM_ALLOC(1+4+blz_max_packed_size(sz));
if(out == nil)
abort();
- uint8_t *w = MEM_ALLOC(blz_workmem_size_level(sz, 10));
+ u8int *w = MEM_ALLOC(blz_workmem_size_level(sz, 10));
if(w == nil)
abort();
unsigned long osz = blz_pack_level(in, out+1+4, sz, w, 10);