Replace idiosyncratic C types with standard ones

For number types, we rely on classic C types (char, short, int, long) to be
the correct sizes. For precise bit widths, use standard intN_t and uintN_t.
For size_t, just use system size_t.
This commit is contained in:
Lassi Kortela 2019-08-09 21:00:03 +03:00
parent d5d7406276
commit d6a4029dde
24 changed files with 320 additions and 365 deletions

View File

@ -1,21 +1,21 @@
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "dtypes.h"
#include "bitvector.h"
#ifdef WIN32 #ifdef WIN32
#include <malloc.h> #include <malloc.h>
#define alloca _alloca #define alloca _alloca
#endif #endif
#include "dtypes.h"
#include "bitvector.h"
// greater than this # of words we use malloc instead of alloca // greater than this # of words we use malloc instead of alloca
#define MALLOC_CUTOFF 2000 #define MALLOC_CUTOFF 2000
u_int32_t bitreverse(u_int32_t x) uint32_t bitreverse(uint32_t x)
{ {
u_int32_t m; uint32_t m;
#ifdef __INTEL_COMPILER #ifdef __INTEL_COMPILER
x = _bswap(x); x = _bswap(x);
@ -38,9 +38,9 @@ u_int32_t bitreverse(u_int32_t x)
// n is # of int32s to consider, s is shift distance // n is # of int32s to consider, s is shift distance
// lowest bit-index is bit 0 of word 0 // lowest bit-index is bit 0 of word 0
// TODO: handle boundary case of shift distance >= data size? // TODO: handle boundary case of shift distance >= data size?
void bitvector_shr(u_int32_t *b, size_t n, u_int32_t s) void bitvector_shr(uint32_t *b, size_t n, uint32_t s)
{ {
u_int32_t i; uint32_t i;
if (s == 0 || n == 0) if (s == 0 || n == 0)
return; return;
i = (s >> 5); i = (s >> 5);
@ -60,9 +60,9 @@ void bitvector_shr(u_int32_t *b, size_t n, u_int32_t s)
// linear representation when a copy is needed // linear representation when a copy is needed
// assumes that dest has the same amount of space as source, even if it // assumes that dest has the same amount of space as source, even if it
// wouldn't have been necessary to hold the shifted bits // wouldn't have been necessary to hold the shifted bits
void bitvector_shr_to(u_int32_t *dest, u_int32_t *b, size_t n, u_int32_t s) void bitvector_shr_to(uint32_t *dest, uint32_t *b, size_t n, uint32_t s)
{ {
u_int32_t i, j; uint32_t i, j;
if (n == 0) if (n == 0)
return; return;
if (s == 0) { if (s == 0) {
@ -82,9 +82,9 @@ void bitvector_shr_to(u_int32_t *dest, u_int32_t *b, size_t n, u_int32_t s)
dest[i] = b[i] >> s; dest[i] = b[i] >> s;
} }
void bitvector_shl(u_int32_t *b, size_t n, u_int32_t s) void bitvector_shl(uint32_t *b, size_t n, uint32_t s)
{ {
u_int32_t i, scrap = 0, temp; uint32_t i, scrap = 0, temp;
if (s == 0 || n == 0) if (s == 0 || n == 0)
return; return;
i = (s >> 5); i = (s >> 5);
@ -104,10 +104,10 @@ void bitvector_shl(u_int32_t *b, size_t n, u_int32_t s)
// if dest has more space than source, set scrap to true to keep the // if dest has more space than source, set scrap to true to keep the
// top bits that would otherwise be shifted out // top bits that would otherwise be shifted out
void bitvector_shl_to(u_int32_t *dest, u_int32_t *b, size_t n, u_int32_t s, void bitvector_shl_to(uint32_t *dest, uint32_t *b, size_t n, uint32_t s,
bool_t scrap) bool_t scrap)
{ {
u_int32_t i, j, sc = 0; uint32_t i, j, sc = 0;
if (n == 0) if (n == 0)
return; return;
if (s == 0) { if (s == 0) {
@ -131,12 +131,11 @@ void bitvector_shl_to(u_int32_t *dest, u_int32_t *b, size_t n, u_int32_t s,
// set nbits to c, starting at given bit offset // set nbits to c, starting at given bit offset
// assumes offs < 32 // assumes offs < 32
void bitvector_fill(u_int32_t *b, u_int32_t offs, u_int32_t c, void bitvector_fill(uint32_t *b, uint32_t offs, uint32_t c, uint32_t nbits)
u_int32_t nbits)
{ {
index_t i; index_t i;
u_int32_t nw, tail; uint32_t nw, tail;
u_int32_t mask; uint32_t mask;
if (nbits == 0) if (nbits == 0)
return; return;
@ -176,11 +175,11 @@ void bitvector_fill(u_int32_t *b, u_int32_t offs, u_int32_t c,
} }
} }
void bitvector_not(u_int32_t *b, u_int32_t offs, u_int32_t nbits) void bitvector_not(uint32_t *b, uint32_t offs, uint32_t nbits)
{ {
index_t i; index_t i;
u_int32_t nw, tail; uint32_t nw, tail;
u_int32_t mask; uint32_t mask;
if (nbits == 0) if (nbits == 0)
return; return;
@ -210,12 +209,12 @@ void bitvector_not(u_int32_t *b, u_int32_t offs, u_int32_t nbits)
// constant-space bit vector copy in a single pass, with arbitrary // constant-space bit vector copy in a single pass, with arbitrary
// offsets and lengths. to get this right, there are 16 cases to handle! // offsets and lengths. to get this right, there are 16 cases to handle!
#define BITVECTOR_COPY_OP(name, OP) \ #define BITVECTOR_COPY_OP(name, OP) \
void bitvector_##name(u_int32_t *dest, u_int32_t doffs, u_int32_t *src, \ void bitvector_##name(uint32_t *dest, uint32_t doffs, uint32_t *src, \
u_int32_t soffs, u_int32_t nbits) \ uint32_t soffs, uint32_t nbits) \
{ \ { \
index_t i; \ index_t i; \
u_int32_t s, nw, tail, snw; \ uint32_t s, nw, tail, snw; \
u_int32_t mask, scrap; \ uint32_t mask, scrap; \
\ \
if (nbits == 0) \ if (nbits == 0) \
return; \ return; \
@ -319,7 +318,7 @@ BITVECTOR_COPY_OP(not_to, BV_NOT)
// right-shift the bits in one logical "row" of a long 2d bit vector // right-shift the bits in one logical "row" of a long 2d bit vector
/* /*
void bitvector_shr_row(u_int32_t *b, u_int32_t offs, size_t nbits, u_int32_t void bitvector_shr_row(uint32_t *b, uint32_t offs, size_t nbits, uint32_t
s) s)
{ {
} }
@ -329,11 +328,11 @@ s)
// assumes dest offset == 0 // assumes dest offset == 0
// assumes source and dest don't overlap // assumes source and dest don't overlap
// assumes offset < 32 // assumes offset < 32
void bitvector_reverse_to(u_int32_t *dest, u_int32_t *src, u_int32_t soffs, void bitvector_reverse_to(uint32_t *dest, uint32_t *src, uint32_t soffs,
u_int32_t nbits) uint32_t nbits)
{ {
index_t i; index_t i;
u_int32_t nw, tail; uint32_t nw, tail;
if (nbits == 0) if (nbits == 0)
return; return;
@ -352,11 +351,11 @@ void bitvector_reverse_to(u_int32_t *dest, u_int32_t *src, u_int32_t soffs,
bitvector_shr(dest, nw, 32 - tail); bitvector_shr(dest, nw, 32 - tail);
} }
void bitvector_reverse(u_int32_t *b, u_int32_t offs, u_int32_t nbits) void bitvector_reverse(uint32_t *b, uint32_t offs, uint32_t nbits)
{ {
index_t i; index_t i;
u_int32_t nw, tail; uint32_t nw, tail;
u_int32_t *temp; uint32_t *temp;
if (nbits == 0) if (nbits == 0)
return; return;
@ -376,15 +375,15 @@ void bitvector_reverse(u_int32_t *b, u_int32_t offs, u_int32_t nbits)
free(temp); free(temp);
} }
u_int64_t bitvector_count(u_int32_t *b, u_int32_t offs, u_int64_t nbits) uint64_t bitvector_count(uint32_t *b, uint32_t offs, uint64_t nbits)
{ {
size_t i, nw; size_t i, nw;
u_int32_t ntail; uint32_t ntail;
u_int64_t ans; uint64_t ans;
if (nbits == 0) if (nbits == 0)
return 0; return 0;
nw = ((u_int64_t)offs + nbits + 31) >> 5; nw = ((uint64_t)offs + nbits + 31) >> 5;
if (nw == 1) { if (nw == 1) {
return count_bits(b[0] & (lomask(nbits) << offs)); return count_bits(b[0] & (lomask(nbits) << offs));
@ -406,18 +405,18 @@ u_int64_t bitvector_count(u_int32_t *b, u_int32_t offs, u_int64_t nbits)
ans += count_bits(b[i]); ans += count_bits(b[i]);
} }
ntail = (offs + (u_int32_t)nbits) & 31; ntail = (offs + (uint32_t)nbits) & 31;
ans += ans +=
count_bits(b[i] & (ntail > 0 ? lomask(ntail) : ONES32)); // last end cap count_bits(b[i] & (ntail > 0 ? lomask(ntail) : ONES32)); // last end cap
return ans; return ans;
} }
u_int32_t bitvector_any0(u_int32_t *b, u_int32_t offs, u_int32_t nbits) uint32_t bitvector_any0(uint32_t *b, uint32_t offs, uint32_t nbits)
{ {
index_t i; index_t i;
u_int32_t nw, tail; uint32_t nw, tail;
u_int32_t mask; uint32_t mask;
if (nbits == 0) if (nbits == 0)
return 0; return 0;
@ -451,11 +450,11 @@ u_int32_t bitvector_any0(u_int32_t *b, u_int32_t offs, u_int32_t nbits)
return 0; return 0;
} }
u_int32_t bitvector_any1(u_int32_t *b, u_int32_t offs, u_int32_t nbits) uint32_t bitvector_any1(uint32_t *b, uint32_t offs, uint32_t nbits)
{ {
index_t i; index_t i;
u_int32_t nw, tail; uint32_t nw, tail;
u_int32_t mask; uint32_t mask;
if (nbits == 0) if (nbits == 0)
return 0; return 0;
@ -489,8 +488,8 @@ u_int32_t bitvector_any1(u_int32_t *b, u_int32_t offs, u_int32_t nbits)
return 0; return 0;
} }
static void adjust_offset_to(u_int32_t *dest, u_int32_t *src, u_int32_t nw, static void adjust_offset_to(uint32_t *dest, uint32_t *src, uint32_t nw,
u_int32_t soffs, u_int32_t newoffs) uint32_t soffs, uint32_t newoffs)
{ {
if (newoffs > soffs) if (newoffs > soffs)
bitvector_shl_to(dest, src, nw, newoffs - soffs, 1); bitvector_shl_to(dest, src, nw, newoffs - soffs, 1);
@ -498,35 +497,35 @@ static void adjust_offset_to(u_int32_t *dest, u_int32_t *src, u_int32_t nw,
bitvector_shr_to(dest, src, nw, soffs - newoffs); bitvector_shr_to(dest, src, nw, soffs - newoffs);
} }
#define BITVECTOR_BINARY_OP_TO(opname, OP) \ #define BITVECTOR_BINARY_OP_TO(opname, OP) \
void bitvector_##opname##_to( \ void bitvector_##opname##_to(uint32_t *dest, uint32_t doffs, \
u_int32_t *dest, u_int32_t doffs, u_int32_t *a, u_int32_t aoffs, \ uint32_t *a, uint32_t aoffs, uint32_t *b, \
u_int32_t *b, u_int32_t boffs, u_int32_t nbits) \ uint32_t boffs, uint32_t nbits) \
{ \ { \
u_int32_t nw = (doffs + nbits + 31) >> 5; \ uint32_t nw = (doffs + nbits + 31) >> 5; \
u_int32_t *temp = \ uint32_t *temp = \
nw > MALLOC_CUTOFF ? malloc((nw + 1) * 4) : alloca((nw + 1) * 4); \ nw > MALLOC_CUTOFF ? malloc((nw + 1) * 4) : alloca((nw + 1) * 4); \
u_int32_t i, anw, bnw; \ uint32_t i, anw, bnw; \
if (aoffs == boffs) { \ if (aoffs == boffs) { \
anw = (aoffs + nbits + 31) >> 5; \ anw = (aoffs + nbits + 31) >> 5; \
} else if (aoffs == doffs) { \ } else if (aoffs == doffs) { \
bnw = (boffs + nbits + 31) >> 5; \ bnw = (boffs + nbits + 31) >> 5; \
adjust_offset_to(temp, b, bnw, boffs, aoffs); \ adjust_offset_to(temp, b, bnw, boffs, aoffs); \
b = temp; \ b = temp; \
anw = nw; \ anw = nw; \
} else { \ } else { \
anw = (aoffs + nbits + 31) >> 5; \ anw = (aoffs + nbits + 31) >> 5; \
bnw = (boffs + nbits + 31) >> 5; \ bnw = (boffs + nbits + 31) >> 5; \
adjust_offset_to(temp, a, anw, aoffs, boffs); \ adjust_offset_to(temp, a, anw, aoffs, boffs); \
a = temp; \ a = temp; \
aoffs = boffs; \ aoffs = boffs; \
anw = bnw; \ anw = bnw; \
} \ } \
for (i = 0; i < anw; i++) \ for (i = 0; i < anw; i++) \
temp[i] = OP(a[i], b[i]); \ temp[i] = OP(a[i], b[i]); \
bitvector_copy(dest, doffs, temp, aoffs, nbits); \ bitvector_copy(dest, doffs, temp, aoffs, nbits); \
if (nw > MALLOC_CUTOFF) \ if (nw > MALLOC_CUTOFF) \
free(temp); \ free(temp); \
} }
#define BV_AND(a, b) ((a) & (b)) #define BV_AND(a, b) ((a) & (b))

View File

@ -29,8 +29,8 @@
and_to, or_to, and xor_to allow overlap. and_to, or_to, and xor_to allow overlap.
*/ */
#include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
#include "dtypes.h" #include "dtypes.h"
@ -40,10 +40,10 @@
#include <malloc.h> #include <malloc.h>
#endif #endif
u_int32_t *bitvector_resize(u_int32_t *b, uint64_t oldsz, uint64_t newsz, uint32_t *bitvector_resize(uint32_t *b, uint64_t oldsz, uint64_t newsz,
int initzero) int initzero)
{ {
u_int32_t *p; uint32_t *p;
size_t sz = ((newsz + 31) >> 5) * sizeof(uint32_t); size_t sz = ((newsz + 31) >> 5) * sizeof(uint32_t);
p = LLT_REALLOC(b, sz); p = LLT_REALLOC(b, sz);
if (p == NULL) if (p == NULL)
@ -55,14 +55,14 @@ u_int32_t *bitvector_resize(u_int32_t *b, uint64_t oldsz, uint64_t newsz,
return p; return p;
} }
u_int32_t *bitvector_new(u_int64_t n, int initzero) uint32_t *bitvector_new(uint64_t n, int initzero)
{ {
return bitvector_resize(NULL, 0, n, initzero); return bitvector_resize(NULL, 0, n, initzero);
} }
size_t bitvector_nwords(u_int64_t nbits) { return ((nbits + 31) >> 5); } size_t bitvector_nwords(uint64_t nbits) { return ((nbits + 31) >> 5); }
void bitvector_set(u_int32_t *b, u_int64_t n, u_int32_t c) void bitvector_set(uint32_t *b, uint64_t n, uint32_t c)
{ {
if (c) if (c)
b[n >> 5] |= (1 << (n & 31)); b[n >> 5] |= (1 << (n & 31));
@ -70,7 +70,7 @@ void bitvector_set(u_int32_t *b, u_int64_t n, u_int32_t c)
b[n >> 5] &= ~(1 << (n & 31)); b[n >> 5] &= ~(1 << (n & 31));
} }
u_int32_t bitvector_get(u_int32_t *b, u_int64_t n) uint32_t bitvector_get(uint32_t *b, uint64_t n)
{ {
return b[n >> 5] & (1 << (n & 31)); return b[n >> 5] & (1 << (n & 31));
} }

View File

@ -1,12 +1,12 @@
// a mask with n set lo or hi bits // a mask with n set lo or hi bits
#define lomask(n) (u_int32_t)((((u_int32_t)1) << (n)) - 1) #define lomask(n) (uint32_t)((((uint32_t)1) << (n)) - 1)
#define himask(n) (~lomask(32 - n)) #define himask(n) (~lomask(32 - n))
#define ONES32 ((u_int32_t)0xffffffff) #define ONES32 ((uint32_t)0xffffffff)
#ifdef __INTEL_COMPILER #ifdef __INTEL_COMPILER
#define count_bits(b) _popcnt32(b) #define count_bits(b) _popcnt32(b)
#else #else
static inline u_int32_t count_bits(u_int32_t b) static inline uint32_t count_bits(uint32_t b)
{ {
b = b - ((b >> 1) & 0x55555555); b = b - ((b >> 1) & 0x55555555);
b = ((b >> 2) & 0x33333333) + (b & 0x33333333); b = ((b >> 2) & 0x33333333) + (b & 0x33333333);
@ -26,41 +26,40 @@ static inline u_int32_t count_bits(u_int32_t b)
} }
#endif #endif
u_int32_t bitreverse(u_int32_t x); uint32_t bitreverse(uint32_t x);
u_int32_t *bitvector_new(u_int64_t n, int initzero); uint32_t *bitvector_new(uint64_t n, int initzero);
u_int32_t *bitvector_resize(u_int32_t *b, uint64_t oldsz, uint64_t newsz, uint32_t *bitvector_resize(uint32_t *b, uint64_t oldsz, uint64_t newsz,
int initzero); int initzero);
size_t bitvector_nwords(u_int64_t nbits); size_t bitvector_nwords(uint64_t nbits);
void bitvector_set(u_int32_t *b, u_int64_t n, u_int32_t c); void bitvector_set(uint32_t *b, uint64_t n, uint32_t c);
u_int32_t bitvector_get(u_int32_t *b, u_int64_t n); uint32_t bitvector_get(uint32_t *b, uint64_t n);
uint32_t bitvector_next(uint32_t *b, uint64_t n0, uint64_t n); uint32_t bitvector_next(uint32_t *b, uint64_t n0, uint64_t n);
void bitvector_shr(u_int32_t *b, size_t n, u_int32_t s); void bitvector_shr(uint32_t *b, size_t n, uint32_t s);
void bitvector_shr_to(u_int32_t *dest, u_int32_t *b, size_t n, u_int32_t s); void bitvector_shr_to(uint32_t *dest, uint32_t *b, size_t n, uint32_t s);
void bitvector_shl(u_int32_t *b, size_t n, u_int32_t s); void bitvector_shl(uint32_t *b, size_t n, uint32_t s);
void bitvector_shl_to(u_int32_t *dest, u_int32_t *b, size_t n, u_int32_t s, void bitvector_shl_to(uint32_t *dest, uint32_t *b, size_t n, uint32_t s,
bool_t scrap); bool_t scrap);
void bitvector_fill(u_int32_t *b, u_int32_t offs, u_int32_t c, void bitvector_fill(uint32_t *b, uint32_t offs, uint32_t c, uint32_t nbits);
u_int32_t nbits); void bitvector_copy(uint32_t *dest, uint32_t doffs, uint32_t *a,
void bitvector_copy(u_int32_t *dest, u_int32_t doffs, u_int32_t *a, uint32_t aoffs, uint32_t nbits);
u_int32_t aoffs, u_int32_t nbits); void bitvector_not(uint32_t *b, uint32_t offs, uint32_t nbits);
void bitvector_not(u_int32_t *b, u_int32_t offs, u_int32_t nbits); void bitvector_not_to(uint32_t *dest, uint32_t doffs, uint32_t *a,
void bitvector_not_to(u_int32_t *dest, u_int32_t doffs, u_int32_t *a, uint32_t aoffs, uint32_t nbits);
u_int32_t aoffs, u_int32_t nbits); void bitvector_reverse(uint32_t *b, uint32_t offs, uint32_t nbits);
void bitvector_reverse(u_int32_t *b, u_int32_t offs, u_int32_t nbits); void bitvector_reverse_to(uint32_t *dest, uint32_t *src, uint32_t soffs,
void bitvector_reverse_to(u_int32_t *dest, u_int32_t *src, u_int32_t soffs, uint32_t nbits);
u_int32_t nbits); void bitvector_and_to(uint32_t *dest, uint32_t doffs, uint32_t *a,
void bitvector_and_to(u_int32_t *dest, u_int32_t doffs, u_int32_t *a, uint32_t aoffs, uint32_t *b, uint32_t boffs,
u_int32_t aoffs, u_int32_t *b, u_int32_t boffs, uint32_t nbits);
u_int32_t nbits); void bitvector_or_to(uint32_t *dest, uint32_t doffs, uint32_t *a,
void bitvector_or_to(u_int32_t *dest, u_int32_t doffs, u_int32_t *a, uint32_t aoffs, uint32_t *b, uint32_t boffs,
u_int32_t aoffs, u_int32_t *b, u_int32_t boffs, uint32_t nbits);
u_int32_t nbits); void bitvector_xor_to(uint32_t *dest, uint32_t doffs, uint32_t *a,
void bitvector_xor_to(u_int32_t *dest, u_int32_t doffs, u_int32_t *a, uint32_t aoffs, uint32_t *b, uint32_t boffs,
u_int32_t aoffs, u_int32_t *b, u_int32_t boffs, uint32_t nbits);
u_int32_t nbits); uint64_t bitvector_count(uint32_t *b, uint32_t offs, uint64_t nbits);
u_int64_t bitvector_count(u_int32_t *b, u_int32_t offs, u_int64_t nbits); uint32_t bitvector_any0(uint32_t *b, uint32_t offs, uint32_t nbits);
u_int32_t bitvector_any0(u_int32_t *b, u_int32_t offs, u_int32_t nbits); uint32_t bitvector_any1(uint32_t *b, uint32_t offs, uint32_t nbits);
u_int32_t bitvector_any1(u_int32_t *b, u_int32_t offs, u_int32_t nbits);

View File

@ -43,7 +43,7 @@ size_t llength(value_t v)
return n; return n;
} }
static value_t fl_nconc(value_t *args, u_int32_t nargs) static value_t fl_nconc(value_t *args, uint32_t nargs)
{ {
if (nargs == 0) if (nargs == 0)
return FL_NIL; return FL_NIL;
@ -69,7 +69,7 @@ static value_t fl_nconc(value_t *args, u_int32_t nargs)
return first; return first;
} }
static value_t fl_assq(value_t *args, u_int32_t nargs) static value_t fl_assq(value_t *args, uint32_t nargs)
{ {
argcount("assq", nargs, 2); argcount("assq", nargs, 2);
value_t item = args[0]; value_t item = args[0];
@ -85,7 +85,7 @@ static value_t fl_assq(value_t *args, u_int32_t nargs)
return FL_F; return FL_F;
} }
static value_t fl_memq(value_t *args, u_int32_t nargs) static value_t fl_memq(value_t *args, uint32_t nargs)
{ {
argcount("memq", nargs, 2); argcount("memq", nargs, 2);
while (iscons(args[1])) { while (iscons(args[1])) {
@ -97,7 +97,7 @@ static value_t fl_memq(value_t *args, u_int32_t nargs)
return FL_F; return FL_F;
} }
static value_t fl_length(value_t *args, u_int32_t nargs) static value_t fl_length(value_t *args, uint32_t nargs)
{ {
argcount("length", nargs, 1); argcount("length", nargs, 1);
value_t a = args[0]; value_t a = args[0];
@ -123,13 +123,13 @@ static value_t fl_length(value_t *args, u_int32_t nargs)
type_error("length", "sequence", a); type_error("length", "sequence", a);
} }
static value_t fl_f_raise(value_t *args, u_int32_t nargs) static value_t fl_f_raise(value_t *args, uint32_t nargs)
{ {
argcount("raise", nargs, 1); argcount("raise", nargs, 1);
fl_raise(args[0]); fl_raise(args[0]);
} }
static value_t fl_exit(value_t *args, u_int32_t nargs) static value_t fl_exit(value_t *args, uint32_t nargs)
{ {
if (nargs > 0) if (nargs > 0)
exit(tofixnum(args[0], "exit")); exit(tofixnum(args[0], "exit"));
@ -137,7 +137,7 @@ static value_t fl_exit(value_t *args, u_int32_t nargs)
return FL_NIL; return FL_NIL;
} }
static value_t fl_symbol(value_t *args, u_int32_t nargs) static value_t fl_symbol(value_t *args, uint32_t nargs)
{ {
argcount("symbol", nargs, 1); argcount("symbol", nargs, 1);
if (!fl_isstring(args[0])) if (!fl_isstring(args[0]))
@ -145,7 +145,7 @@ static value_t fl_symbol(value_t *args, u_int32_t nargs)
return symbol(cvalue_data(args[0])); return symbol(cvalue_data(args[0]));
} }
static value_t fl_keywordp(value_t *args, u_int32_t nargs) static value_t fl_keywordp(value_t *args, uint32_t nargs)
{ {
argcount("keyword?", nargs, 1); argcount("keyword?", nargs, 1);
return (issymbol(args[0]) && iskeyword((struct symbol *)ptr(args[0]))) return (issymbol(args[0]) && iskeyword((struct symbol *)ptr(args[0])))
@ -153,7 +153,7 @@ static value_t fl_keywordp(value_t *args, u_int32_t nargs)
: FL_F; : FL_F;
} }
static value_t fl_top_level_value(value_t *args, u_int32_t nargs) static value_t fl_top_level_value(value_t *args, uint32_t nargs)
{ {
argcount("top-level-value", nargs, 1); argcount("top-level-value", nargs, 1);
struct symbol *sym = tosymbol(args[0], "top-level-value"); struct symbol *sym = tosymbol(args[0], "top-level-value");
@ -162,7 +162,7 @@ static value_t fl_top_level_value(value_t *args, u_int32_t nargs)
return sym->binding; return sym->binding;
} }
static value_t fl_set_top_level_value(value_t *args, u_int32_t nargs) static value_t fl_set_top_level_value(value_t *args, uint32_t nargs)
{ {
argcount("set-top-level-value!", nargs, 2); argcount("set-top-level-value!", nargs, 2);
struct symbol *sym = tosymbol(args[0], "set-top-level-value!"); struct symbol *sym = tosymbol(args[0], "set-top-level-value!");
@ -184,7 +184,7 @@ static void global_env_list(struct symbol *root, value_t *pv)
extern struct symbol *symtab; extern struct symbol *symtab;
value_t fl_global_env(value_t *args, u_int32_t nargs) value_t fl_global_env(value_t *args, uint32_t nargs)
{ {
(void)args; (void)args;
argcount("environment", nargs, 0); argcount("environment", nargs, 0);
@ -197,7 +197,7 @@ value_t fl_global_env(value_t *args, u_int32_t nargs)
extern value_t QUOTE; extern value_t QUOTE;
static value_t fl_constantp(value_t *args, u_int32_t nargs) static value_t fl_constantp(value_t *args, uint32_t nargs)
{ {
argcount("constant?", nargs, 1); argcount("constant?", nargs, 1);
if (issymbol(args[0])) if (issymbol(args[0]))
@ -210,7 +210,7 @@ static value_t fl_constantp(value_t *args, u_int32_t nargs)
return FL_T; return FL_T;
} }
static value_t fl_integer_valuedp(value_t *args, u_int32_t nargs) static value_t fl_integer_valuedp(value_t *args, uint32_t nargs)
{ {
argcount("integer-valued?", nargs, 1); argcount("integer-valued?", nargs, 1);
value_t v = args[0]; value_t v = args[0];
@ -239,7 +239,7 @@ static value_t fl_integer_valuedp(value_t *args, u_int32_t nargs)
return FL_F; return FL_F;
} }
static value_t fl_integerp(value_t *args, u_int32_t nargs) static value_t fl_integerp(value_t *args, uint32_t nargs)
{ {
argcount("integer?", nargs, 1); argcount("integer?", nargs, 1);
value_t v = args[0]; value_t v = args[0];
@ -249,7 +249,7 @@ static value_t fl_integerp(value_t *args, u_int32_t nargs)
: FL_F; : FL_F;
} }
static value_t fl_fixnum(value_t *args, u_int32_t nargs) static value_t fl_fixnum(value_t *args, uint32_t nargs)
{ {
argcount("fixnum", nargs, 1); argcount("fixnum", nargs, 1);
if (isfixnum(args[0])) { if (isfixnum(args[0])) {
@ -261,7 +261,7 @@ static value_t fl_fixnum(value_t *args, u_int32_t nargs)
type_error("fixnum", "number", args[0]); type_error("fixnum", "number", args[0]);
} }
static value_t fl_truncate(value_t *args, u_int32_t nargs) static value_t fl_truncate(value_t *args, uint32_t nargs)
{ {
argcount("truncate", nargs, 1); argcount("truncate", nargs, 1);
if (isfixnum(args[0])) if (isfixnum(args[0]))
@ -289,7 +289,7 @@ static value_t fl_truncate(value_t *args, u_int32_t nargs)
type_error("truncate", "number", args[0]); type_error("truncate", "number", args[0]);
} }
static value_t fl_vector_alloc(value_t *args, u_int32_t nargs) static value_t fl_vector_alloc(value_t *args, uint32_t nargs)
{ {
fixnum_t i; fixnum_t i;
value_t f, v; value_t f, v;
@ -309,7 +309,7 @@ static value_t fl_vector_alloc(value_t *args, u_int32_t nargs)
return v; return v;
} }
static value_t fl_time_now(value_t *args, u_int32_t nargs) static value_t fl_time_now(value_t *args, uint32_t nargs)
{ {
argcount("time.now", nargs, 0); argcount("time.now", nargs, 0);
(void)args; (void)args;
@ -409,7 +409,7 @@ static value_t fl_os_setenv(value_t *args, uint32_t nargs)
return FL_T; return FL_T;
} }
static value_t fl_rand(value_t *args, u_int32_t nargs) static value_t fl_rand(value_t *args, uint32_t nargs)
{ {
(void)args; (void)args;
(void)nargs; (void)nargs;
@ -421,7 +421,7 @@ static value_t fl_rand(value_t *args, u_int32_t nargs)
#endif #endif
return fixnum(r); return fixnum(r);
} }
static value_t fl_rand32(value_t *args, u_int32_t nargs) static value_t fl_rand32(value_t *args, uint32_t nargs)
{ {
(void)args; (void)args;
(void)nargs; (void)nargs;
@ -432,20 +432,20 @@ static value_t fl_rand32(value_t *args, u_int32_t nargs)
return mk_uint32(r); return mk_uint32(r);
#endif #endif
} }
static value_t fl_rand64(value_t *args, u_int32_t nargs) static value_t fl_rand64(value_t *args, uint32_t nargs)
{ {
(void)args; (void)args;
(void)nargs; (void)nargs;
uint64_t r = (((uint64_t)random()) << 32) | random(); uint64_t r = (((uint64_t)random()) << 32) | random();
return mk_uint64(r); return mk_uint64(r);
} }
static value_t fl_randd(value_t *args, u_int32_t nargs) static value_t fl_randd(value_t *args, uint32_t nargs)
{ {
(void)args; (void)args;
(void)nargs; (void)nargs;
return mk_double(rand_double()); return mk_double(rand_double());
} }
static value_t fl_randf(value_t *args, u_int32_t nargs) static value_t fl_randf(value_t *args, uint32_t nargs)
{ {
(void)args; (void)args;
(void)nargs; (void)nargs;
@ -453,7 +453,7 @@ static value_t fl_randf(value_t *args, u_int32_t nargs)
} }
#define MATH_FUNC_1ARG(name) \ #define MATH_FUNC_1ARG(name) \
static value_t fl_##name(value_t *args, u_int32_t nargs) \ static value_t fl_##name(value_t *args, uint32_t nargs) \
{ \ { \
argcount(#name, nargs, 1); \ argcount(#name, nargs, 1); \
if (iscprim(args[0])) { \ if (iscprim(args[0])) { \

View File

@ -31,9 +31,9 @@ struct fltype *builtintype;
static void cvalue_init(struct fltype *type, value_t v, void *dest); static void cvalue_init(struct fltype *type, value_t v, void *dest);
// cvalues-specific builtins // cvalues-specific builtins
value_t cvalue_new(value_t *args, u_int32_t nargs); value_t cvalue_new(value_t *args, uint32_t nargs);
value_t cvalue_sizeof(value_t *args, u_int32_t nargs); value_t cvalue_sizeof(value_t *args, uint32_t nargs);
value_t cvalue_typeof(value_t *args, u_int32_t nargs); value_t cvalue_typeof(value_t *args, uint32_t nargs);
// trigger unconditional GC after this many bytes are allocated // trigger unconditional GC after this many bytes are allocated
#define ALLOC_LIMIT_TRIGGER 67108864 #define ALLOC_LIMIT_TRIGGER 67108864
@ -241,18 +241,18 @@ void cv_pin(struct cvalue *cv)
static int cvalue_##ctype##_init(struct fltype *type, value_t arg, \ static int cvalue_##ctype##_init(struct fltype *type, value_t arg, \
void *dest) \ void *dest) \
{ \ { \
fl_##ctype##_t n = 0; \ ctype##_t n = 0; \
(void)type; \ (void)type; \
if (isfixnum(arg)) { \ if (isfixnum(arg)) { \
n = numval(arg); \ n = numval(arg); \
} else if (iscprim(arg)) { \ } else if (iscprim(arg)) { \
struct cprim *cp = (struct cprim *)ptr(arg); \ struct cprim *cp = (struct cprim *)ptr(arg); \
void *p = cp_data(cp); \ void *p = cp_data(cp); \
n = (fl_##ctype##_t)conv_to_##cnvt(p, cp_numtype(cp)); \ n = (ctype##_t)conv_to_##cnvt(p, cp_numtype(cp)); \
} else { \ } else { \
return 1; \ return 1; \
} \ } \
*((fl_##ctype##_t *)dest) = n; \ *((ctype##_t *)dest) = n; \
return 0; \ return 0; \
} }
num_init(int8, int32, T_INT8) num_init(uint8, uint32, T_UINT8) num_init(int8, int32, T_INT8) num_init(uint8, uint32, T_UINT8)
@ -262,25 +262,25 @@ num_init(int64, int64, T_INT64) num_init(uint64, uint64, T_UINT64)
num_init(float, double, T_FLOAT) num_init(double, double, T_DOUBLE) num_init(float, double, T_FLOAT) num_init(double, double, T_DOUBLE)
#define num_ctor_init(typenam, ctype, tag) \ #define num_ctor_init(typenam, ctype, tag) \
value_t cvalue_##typenam(value_t *args, u_int32_t nargs) \ value_t cvalue_##typenam(value_t *args, uint32_t nargs) \
{ \ { \
if (nargs == 0) { \ if (nargs == 0) { \
PUSH(fixnum(0)); \ PUSH(fixnum(0)); \
args = &Stack[SP - 1]; \ args = &Stack[SP - 1]; \
} \ } \
value_t cp = cprim(typenam##type, sizeof(fl_##ctype##_t)); \ value_t cp = cprim(typenam##type, sizeof(ctype##_t)); \
if (cvalue_##ctype##_init(typenam##type, args[0], \ if (cvalue_##ctype##_init(typenam##type, args[0], \
cp_data((struct cprim *)ptr(cp)))) \ cp_data((struct cprim *)ptr(cp)))) \
type_error(#typenam, "number", args[0]); \ type_error(#typenam, "number", args[0]); \
return cp; \ return cp; \
} }
#define num_ctor_ctor(typenam, ctype, tag) \ #define num_ctor_ctor(typenam, ctype, tag) \
value_t mk_##typenam(fl_##ctype##_t n) \ value_t mk_##typenam(ctype##_t n) \
{ \ { \
value_t cp = cprim(typenam##type, sizeof(fl_##ctype##_t)); \ value_t cp = cprim(typenam##type, sizeof(ctype##_t)); \
*(fl_##ctype##_t *)cp_data((struct cprim *)ptr(cp)) = n; \ *(ctype##_t *)cp_data((struct cprim *)ptr(cp)) = n; \
return cp; \ return cp; \
} }
#define num_ctor(typenam, ctype, tag) \ #define num_ctor(typenam, ctype, tag) \
@ -350,7 +350,7 @@ static int cvalue_enum_init(struct fltype *ft, value_t arg, void *dest)
return 0; return 0;
} }
value_t cvalue_enum(value_t *args, u_int32_t nargs) value_t cvalue_enum(value_t *args, uint32_t nargs)
{ {
argcount("enum", nargs, 2); argcount("enum", nargs, 2);
value_t type = fl_list2(enumsym, args[0]); value_t type = fl_list2(enumsym, args[0]);
@ -440,7 +440,7 @@ static int cvalue_array_init(struct fltype *ft, value_t arg, void *dest)
return 0; return 0;
} }
value_t cvalue_array(value_t *args, u_int32_t nargs) value_t cvalue_array(value_t *args, uint32_t nargs)
{ {
size_t elsize, cnt, sz, i; size_t elsize, cnt, sz, i;
value_t arg; value_t arg;
@ -595,7 +595,7 @@ void to_sized_ptr(value_t v, char *fname, char **pdata, size_t *psz)
type_error(fname, "plain-old-data", v); type_error(fname, "plain-old-data", v);
} }
value_t cvalue_sizeof(value_t *args, u_int32_t nargs) value_t cvalue_sizeof(value_t *args, uint32_t nargs)
{ {
argcount("sizeof", nargs, 1); argcount("sizeof", nargs, 1);
if (issymbol(args[0]) || iscons(args[0])) { if (issymbol(args[0]) || iscons(args[0])) {
@ -608,7 +608,7 @@ value_t cvalue_sizeof(value_t *args, u_int32_t nargs)
return size_wrap(n); return size_wrap(n);
} }
value_t cvalue_typeof(value_t *args, u_int32_t nargs) value_t cvalue_typeof(value_t *args, uint32_t nargs)
{ {
argcount("typeof", nargs, 1); argcount("typeof", nargs, 1);
switch (tag(args[0])) { switch (tag(args[0])) {
@ -684,7 +684,7 @@ value_t cvalue_copy(value_t v)
return tagptr(ncv, TAG_CVALUE); return tagptr(ncv, TAG_CVALUE);
} }
value_t fl_copy(value_t *args, u_int32_t nargs) value_t fl_copy(value_t *args, uint32_t nargs)
{ {
argcount("copy", nargs, 1); argcount("copy", nargs, 1);
if (iscons(args[0]) || isvector(args[0])) if (iscons(args[0]) || isvector(args[0]))
@ -696,7 +696,7 @@ value_t fl_copy(value_t *args, u_int32_t nargs)
return cvalue_copy(args[0]); return cvalue_copy(args[0]);
} }
value_t fl_podp(value_t *args, u_int32_t nargs) value_t fl_podp(value_t *args, uint32_t nargs)
{ {
argcount("plain-old-data?", nargs, 1); argcount("plain-old-data?", nargs, 1);
return (iscprim(args[0]) || return (iscprim(args[0]) ||
@ -760,7 +760,7 @@ static numerictype_t sym_to_numtype(value_t type)
// this provides (1) a way to allocate values with a shared type for // this provides (1) a way to allocate values with a shared type for
// efficiency, (2) a uniform interface for allocating cvalues of any // efficiency, (2) a uniform interface for allocating cvalues of any
// type, including user-defined. // type, including user-defined.
value_t cvalue_new(value_t *args, u_int32_t nargs) value_t cvalue_new(value_t *args, uint32_t nargs)
{ {
if (nargs < 1 || nargs > 2) if (nargs < 1 || nargs > 2)
argcount("c-value", nargs, 2); argcount("c-value", nargs, 2);
@ -810,7 +810,7 @@ value_t cvalue_compare(value_t a, value_t b)
} }
static void check_addr_args(char *fname, value_t arr, value_t ind, static void check_addr_args(char *fname, value_t arr, value_t ind,
char **data, ulong_t *index) char **data, unsigned long *index)
{ {
size_t numel; size_t numel;
struct cvalue *cv = (struct cvalue *)ptr(arr); struct cvalue *cv = (struct cvalue *)ptr(arr);
@ -824,7 +824,7 @@ static void check_addr_args(char *fname, value_t arr, value_t ind,
static value_t cvalue_array_aref(value_t *args) static value_t cvalue_array_aref(value_t *args)
{ {
char *data; char *data;
ulong_t index; unsigned long index;
struct fltype *eltype = cv_class((struct cvalue *)ptr(args[0]))->eltype; struct fltype *eltype = cv_class((struct cvalue *)ptr(args[0]))->eltype;
value_t el = 0; value_t el = 0;
numerictype_t nt = eltype->numtype; numerictype_t nt = eltype->numtype;
@ -858,7 +858,7 @@ static value_t cvalue_array_aref(value_t *args)
static value_t cvalue_array_aset(value_t *args) static value_t cvalue_array_aset(value_t *args)
{ {
char *data; char *data;
ulong_t index; unsigned long index;
struct fltype *eltype = cv_class((struct cvalue *)ptr(args[0]))->eltype; struct fltype *eltype = cv_class((struct cvalue *)ptr(args[0]))->eltype;
check_addr_args("aset!", args[0], args[1], &data, &index); check_addr_args("aset!", args[0], args[1], &data, &index);
char *dest = data + index * eltype->size; char *dest = data + index * eltype->size;
@ -866,7 +866,7 @@ static value_t cvalue_array_aset(value_t *args)
return args[2]; return args[2];
} }
value_t fl_builtin(value_t *args, u_int32_t nargs) value_t fl_builtin(value_t *args, uint32_t nargs)
{ {
argcount("builtin", nargs, 1); argcount("builtin", nargs, 1);
struct symbol *name = tosymbol(args[0], "builtin"); struct symbol *name = tosymbol(args[0], "builtin");
@ -893,11 +893,11 @@ value_t cbuiltin(char *name, builtin_t f)
return tagptr(cv, TAG_CVALUE); return tagptr(cv, TAG_CVALUE);
} }
static value_t fl_logand(value_t *args, u_int32_t nargs); static value_t fl_logand(value_t *args, uint32_t nargs);
static value_t fl_logior(value_t *args, u_int32_t nargs); static value_t fl_logior(value_t *args, uint32_t nargs);
static value_t fl_logxor(value_t *args, u_int32_t nargs); static value_t fl_logxor(value_t *args, uint32_t nargs);
static value_t fl_lognot(value_t *args, u_int32_t nargs); static value_t fl_lognot(value_t *args, uint32_t nargs);
static value_t fl_ash(value_t *args, u_int32_t nargs); static value_t fl_ash(value_t *args, uint32_t nargs);
static struct builtinspec cvalues_builtin_info[] = { static struct builtinspec cvalues_builtin_info[] = {
{ "c-value", cvalue_new }, { "c-value", cvalue_new },
@ -1017,7 +1017,7 @@ static void cvalues_init(void)
setc(emptystringsym, cvalue_static_cstring("")); setc(emptystringsym, cvalue_static_cstring(""));
} }
#define RETURN_NUM_AS(var, type) return (mk_##type((fl_##type##_t)var)) #define RETURN_NUM_AS(var, type) return (mk_##type((type##_t)var))
value_t return_from_uint64(uint64_t Uaccum) value_t return_from_uint64(uint64_t Uaccum)
{ {
@ -1047,7 +1047,7 @@ value_t return_from_int64(int64_t Saccum)
RETURN_NUM_AS(Saccum, int32); RETURN_NUM_AS(Saccum, int32);
} }
static value_t fl_add_any(value_t *args, u_int32_t nargs, fixnum_t carryIn) static value_t fl_add_any(value_t *args, uint32_t nargs, fixnum_t carryIn)
{ {
uint64_t Uaccum = 0; uint64_t Uaccum = 0;
int64_t Saccum = carryIn; int64_t Saccum = carryIn;
@ -1185,7 +1185,7 @@ static value_t fl_neg(value_t n)
type_error("-", "number", n); type_error("-", "number", n);
} }
static value_t fl_mul_any(value_t *args, u_int32_t nargs, int64_t Saccum) static value_t fl_mul_any(value_t *args, uint32_t nargs, int64_t Saccum)
{ {
uint64_t Uaccum = 1; uint64_t Uaccum = 1;
double Faccum = 1; double Faccum = 1;
@ -1501,7 +1501,7 @@ static value_t fl_bitwise_op(value_t a, value_t b, int opcode, char *fname)
return NIL; return NIL;
} }
static value_t fl_logand(value_t *args, u_int32_t nargs) static value_t fl_logand(value_t *args, uint32_t nargs)
{ {
value_t v, e; value_t v, e;
int i; int i;
@ -1518,7 +1518,7 @@ static value_t fl_logand(value_t *args, u_int32_t nargs)
return v; return v;
} }
static value_t fl_logior(value_t *args, u_int32_t nargs) static value_t fl_logior(value_t *args, uint32_t nargs)
{ {
value_t v, e; value_t v, e;
int i; int i;
@ -1535,7 +1535,7 @@ static value_t fl_logior(value_t *args, u_int32_t nargs)
return v; return v;
} }
static value_t fl_logxor(value_t *args, u_int32_t nargs) static value_t fl_logxor(value_t *args, uint32_t nargs)
{ {
value_t v, e; value_t v, e;
int i; int i;
@ -1552,7 +1552,7 @@ static value_t fl_logxor(value_t *args, u_int32_t nargs)
return v; return v;
} }
static value_t fl_lognot(value_t *args, u_int32_t nargs) static value_t fl_lognot(value_t *args, uint32_t nargs)
{ {
argcount("lognot", nargs, 1); argcount("lognot", nargs, 1);
value_t a = args[0]; value_t a = args[0];
@ -1588,7 +1588,7 @@ static value_t fl_lognot(value_t *args, u_int32_t nargs)
type_error("lognot", "integer", a); type_error("lognot", "integer", a);
} }
static value_t fl_ash(value_t *args, u_int32_t nargs) static value_t fl_ash(value_t *args, uint32_t nargs)
{ {
fixnum_t n; fixnum_t n;
int64_t accum; int64_t accum;

View File

@ -96,62 +96,35 @@ typedef int bool_t;
#if defined(__INTEL_COMPILER) && defined(WIN32) #if defined(__INTEL_COMPILER) && defined(WIN32)
#define STATIC_INLINE static #define STATIC_INLINE static
#define INLINE #define INLINE
#ifdef BITS64
typedef unsigned long size_t;
#else
typedef unsigned int size_t;
#endif
#else #else
#define STATIC_INLINE static inline #define STATIC_INLINE static inline
#define INLINE inline #define INLINE inline
#endif #endif
typedef unsigned char byte_t; /* 1 byte */
#if defined(WIN32)
typedef short int16_t;
typedef int int32_t;
typedef long long int64_t;
typedef unsigned char u_int8_t;
typedef unsigned short u_int16_t;
typedef unsigned int u_int32_t;
#ifdef BITS64
typedef unsigned long u_int64_t;
#else
typedef unsigned long long u_int64_t;
#endif
#ifdef __INTEL_COMPILER
typedef signed char int8_t;
typedef short int16_t;
typedef int int32_t;
#endif
#else
#include <sys/types.h>
#endif
#ifdef BITS64 #ifdef BITS64
#define TOP_BIT 0x8000000000000000 #define TOP_BIT 0x8000000000000000
#define NBITS 64 #define NBITS 64
typedef unsigned long uint_t; // preferred int type on platform typedef unsigned long uint_t; // preferred int type on platform
typedef long int_t; typedef long int_t;
typedef int64_t offset_t; typedef int64_t offset_t;
typedef u_int64_t index_t; typedef uint64_t index_t;
typedef int64_t ptrint_t; // pointer-size int typedef int64_t ptrint_t; // pointer-size int
typedef u_int64_t u_ptrint_t; typedef uint64_t u_ptrint_t;
#else #else
#define TOP_BIT 0x80000000 #define TOP_BIT 0x80000000
#define NBITS 32 #define NBITS 32
typedef unsigned long uint_t; typedef unsigned long uint_t;
typedef long int_t; typedef long int_t;
typedef int32_t offset_t; typedef int32_t offset_t;
typedef u_int32_t index_t; typedef uint32_t index_t;
typedef int32_t ptrint_t; typedef int32_t ptrint_t;
typedef u_int32_t u_ptrint_t; typedef uint32_t u_ptrint_t;
#endif #endif
typedef u_int8_t uint8_t; typedef uint8_t uint8_t;
typedef u_int16_t uint16_t; typedef uint16_t uint16_t;
typedef u_int32_t uint32_t; typedef uint32_t uint32_t;
typedef u_int64_t uint64_t; typedef uint64_t uint64_t;
typedef u_ptrint_t uptrint_t; typedef u_ptrint_t uptrint_t;
#define LLT_ALIGN(x, sz) (((x) + (sz - 1)) & (-sz)) #define LLT_ALIGN(x, sz) (((x) + (sz - 1)) & (-sz))

View File

@ -1,3 +1,5 @@
#include <sys/types.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -395,7 +395,7 @@ uptrint_t hash_lispvalue(value_t a)
return n; return n;
} }
value_t fl_hash(value_t *args, u_int32_t nargs) value_t fl_hash(value_t *args, uint32_t nargs)
{ {
argcount("hash", nargs, 1); argcount("hash", nargs, 1);
return fixnum(hash_lispvalue(args[0])); return fixnum(hash_lispvalue(args[0]));

View File

@ -333,7 +333,7 @@ value_t fl_gensym(value_t *args, uint32_t nargs)
int fl_isgensym(value_t v) { return isgensym(v); } int fl_isgensym(value_t v) { return isgensym(v); }
static value_t fl_gensymp(value_t *args, u_int32_t nargs) static value_t fl_gensymp(value_t *args, uint32_t nargs)
{ {
argcount("gensym?", nargs, 1); argcount("gensym?", nargs, 1);
return isgensym(args[0]) ? FL_T : FL_F; return isgensym(args[0]) ? FL_T : FL_F;
@ -2307,13 +2307,13 @@ static value_t fl_function_name(value_t *args, uint32_t nargs)
return fn_name(v); return fn_name(v);
} }
value_t fl_copylist(value_t *args, u_int32_t nargs) value_t fl_copylist(value_t *args, uint32_t nargs)
{ {
argcount("copy-list", nargs, 1); argcount("copy-list", nargs, 1);
return copy_list(args[0]); return copy_list(args[0]);
} }
value_t fl_append(value_t *args, u_int32_t nargs) value_t fl_append(value_t *args, uint32_t nargs)
{ {
if (nargs == 0) if (nargs == 0)
return NIL; return NIL;
@ -2344,7 +2344,7 @@ value_t fl_append(value_t *args, u_int32_t nargs)
return first; return first;
} }
value_t fl_liststar(value_t *args, u_int32_t nargs) value_t fl_liststar(value_t *args, uint32_t nargs)
{ {
if (nargs == 1) if (nargs == 1)
return args[0]; return args[0];
@ -2353,14 +2353,14 @@ value_t fl_liststar(value_t *args, u_int32_t nargs)
return _list(args, nargs, 1); return _list(args, nargs, 1);
} }
value_t fl_stacktrace(value_t *args, u_int32_t nargs) value_t fl_stacktrace(value_t *args, uint32_t nargs)
{ {
(void)args; (void)args;
argcount("stacktrace", nargs, 0); argcount("stacktrace", nargs, 0);
return _stacktrace(fl_throwing_frame ? fl_throwing_frame : curr_frame); return _stacktrace(fl_throwing_frame ? fl_throwing_frame : curr_frame);
} }
value_t fl_map1(value_t *args, u_int32_t nargs) value_t fl_map1(value_t *args, uint32_t nargs)
{ {
if (nargs < 2) if (nargs < 2)
lerror(ArgError, "map: too few arguments"); lerror(ArgError, "map: too few arguments");

View File

@ -313,24 +313,6 @@ struct function {
(iscprim(v) ? cp_data((struct cprim *)ptr(v)) \ (iscprim(v) ? cp_data((struct cprim *)ptr(v)) \
: cv_data((struct cvalue *)ptr(v))) : cv_data((struct cvalue *)ptr(v)))
/* C type names corresponding to cvalues type names */
typedef int8_t fl_int8_t;
typedef uint8_t fl_uint8_t;
typedef int16_t fl_int16_t;
typedef uint16_t fl_uint16_t;
typedef int32_t fl_int32_t;
typedef uint32_t fl_uint32_t;
typedef int64_t fl_int64_t;
typedef uint64_t fl_uint64_t;
typedef char fl_char_t;
typedef char char_t;
typedef long fl_long_t;
typedef long long_t;
typedef unsigned long fl_ulong_t;
typedef unsigned long ulong_t;
typedef double fl_double_t;
typedef float fl_float_t;
typedef value_t (*builtin_t)(value_t *, uint32_t); typedef value_t (*builtin_t)(value_t *, uint32_t);
extern value_t QUOTE; extern value_t QUOTE;
@ -377,8 +359,8 @@ struct fltype *get_array_type(value_t eltype);
struct fltype *define_opaque_type(value_t sym, size_t sz, struct fltype *define_opaque_type(value_t sym, size_t sz,
struct cvtable *vtab, cvinitfunc_t init); struct cvtable *vtab, cvinitfunc_t init);
value_t mk_double(fl_double_t n); value_t mk_double(double n);
value_t mk_float(fl_float_t n); value_t mk_float(float n);
value_t mk_uint32(uint32_t n); value_t mk_uint32(uint32_t n);
value_t mk_uint64(uint64_t n); value_t mk_uint64(uint64_t n);
value_t mk_wchar(int32_t n); value_t mk_wchar(int32_t n);
@ -408,7 +390,7 @@ struct builtinspec {
void assign_global_builtins(struct builtinspec *b); void assign_global_builtins(struct builtinspec *b);
/* builtins */ /* builtins */
value_t fl_hash(value_t *args, u_int32_t nargs); value_t fl_hash(value_t *args, uint32_t nargs);
value_t cvalue_byte(value_t *args, uint32_t nargs); value_t cvalue_byte(value_t *args, uint32_t nargs);
value_t cvalue_wchar(value_t *args, uint32_t nargs); value_t cvalue_wchar(value_t *args, uint32_t nargs);

View File

@ -43,7 +43,7 @@ uint_t nextipow2(uint_t i)
return i << 1; return i << 1;
} }
u_int32_t int32hash(u_int32_t a) uint32_t int32hash(uint32_t a)
{ {
a = (a + 0x7ed55d16) + (a << 12); a = (a + 0x7ed55d16) + (a << 12);
a = (a ^ 0xc761c23c) ^ (a >> 19); a = (a ^ 0xc761c23c) ^ (a >> 19);
@ -54,7 +54,7 @@ u_int32_t int32hash(u_int32_t a)
return a; return a;
} }
u_int64_t int64hash(u_int64_t key) uint64_t int64hash(uint64_t key)
{ {
key = (~key) + (key << 21); // key = (key << 21) - key - 1; key = (~key) + (key << 21); // key = (key << 21) - key - 1;
key = key ^ (key >> 24); key = key ^ (key >> 24);
@ -66,7 +66,7 @@ u_int64_t int64hash(u_int64_t key)
return key; return key;
} }
u_int32_t int64to32hash(u_int64_t key) uint32_t int64to32hash(uint64_t key)
{ {
key = (~key) + (key << 18); // key = (key << 18) - key - 1; key = (~key) + (key << 18); // key = (key << 18) - key - 1;
key = key ^ (key >> 31); key = key ^ (key >> 31);
@ -74,22 +74,22 @@ u_int32_t int64to32hash(u_int64_t key)
key = key ^ (key >> 11); key = key ^ (key >> 11);
key = key + (key << 6); key = key + (key << 6);
key = key ^ (key >> 22); key = key ^ (key >> 22);
return (u_int32_t)key; return (uint32_t)key;
} }
#include "lookup3.h" #include "lookup3.h"
u_int64_t memhash(const char *buf, size_t n) uint64_t memhash(const char *buf, size_t n)
{ {
u_int32_t c = 0xcafe8881, b = 0x4d6a087c; uint32_t c = 0xcafe8881, b = 0x4d6a087c;
hashlittle2(buf, n, &c, &b); hashlittle2(buf, n, &c, &b);
return (u_int64_t)c | (((u_int64_t)b) << 32); return (uint64_t)c | (((uint64_t)b) << 32);
} }
u_int32_t memhash32(const char *buf, size_t n) uint32_t memhash32(const char *buf, size_t n)
{ {
u_int32_t c = 0xcafe8881, b = 0x4d6a087c; uint32_t c = 0xcafe8881, b = 0x4d6a087c;
hashlittle2(buf, n, &c, &b); hashlittle2(buf, n, &c, &b);
return c; return c;

View File

@ -1,11 +1,11 @@
uint_t nextipow2(uint_t i); uint_t nextipow2(uint_t i);
u_int32_t int32hash(u_int32_t a); uint32_t int32hash(uint32_t a);
u_int64_t int64hash(u_int64_t key); uint64_t int64hash(uint64_t key);
u_int32_t int64to32hash(u_int64_t key); uint32_t int64to32hash(uint64_t key);
#ifdef BITS64 #ifdef BITS64
#define inthash int64hash #define inthash int64hash
#else #else
#define inthash int32hash #define inthash int32hash
#endif #endif
u_int64_t memhash(const char *buf, size_t n); uint64_t memhash(const char *buf, size_t n);
u_int32_t memhash32(const char *buf, size_t n); uint32_t memhash32(const char *buf, size_t n);

View File

@ -119,7 +119,7 @@ value_t fl_file(value_t *args, uint32_t nargs)
return f; return f;
} }
value_t fl_buffer(value_t *args, u_int32_t nargs) value_t fl_buffer(value_t *args, uint32_t nargs)
{ {
argcount("buffer", nargs, 0); argcount("buffer", nargs, 0);
(void)args; (void)args;
@ -130,7 +130,7 @@ value_t fl_buffer(value_t *args, u_int32_t nargs)
return f; return f;
} }
value_t fl_read(value_t *args, u_int32_t nargs) value_t fl_read(value_t *args, uint32_t nargs)
{ {
value_t arg = 0; value_t arg = 0;
if (nargs > 1) { if (nargs > 1) {
@ -149,7 +149,7 @@ value_t fl_read(value_t *args, u_int32_t nargs)
return v; return v;
} }
value_t fl_iogetc(value_t *args, u_int32_t nargs) value_t fl_iogetc(value_t *args, uint32_t nargs)
{ {
argcount("io.getc", nargs, 1); argcount("io.getc", nargs, 1);
struct ios *s = toiostream(args[0], "io.getc"); struct ios *s = toiostream(args[0], "io.getc");
@ -160,7 +160,7 @@ value_t fl_iogetc(value_t *args, u_int32_t nargs)
return mk_wchar(wc); return mk_wchar(wc);
} }
value_t fl_iopeekc(value_t *args, u_int32_t nargs) value_t fl_iopeekc(value_t *args, uint32_t nargs)
{ {
argcount("io.peekc", nargs, 1); argcount("io.peekc", nargs, 1);
struct ios *s = toiostream(args[0], "io.peekc"); struct ios *s = toiostream(args[0], "io.peekc");
@ -170,7 +170,7 @@ value_t fl_iopeekc(value_t *args, u_int32_t nargs)
return mk_wchar(wc); return mk_wchar(wc);
} }
value_t fl_ioputc(value_t *args, u_int32_t nargs) value_t fl_ioputc(value_t *args, uint32_t nargs)
{ {
argcount("io.putc", nargs, 2); argcount("io.putc", nargs, 2);
struct ios *s = toiostream(args[0], "io.putc"); struct ios *s = toiostream(args[0], "io.putc");
@ -181,7 +181,7 @@ value_t fl_ioputc(value_t *args, u_int32_t nargs)
return fixnum(ios_pututf8(s, wc)); return fixnum(ios_pututf8(s, wc));
} }
value_t fl_ioungetc(value_t *args, u_int32_t nargs) value_t fl_ioungetc(value_t *args, uint32_t nargs)
{ {
argcount("io.ungetc", nargs, 2); argcount("io.ungetc", nargs, 2);
struct ios *s = toiostream(args[0], "io.ungetc"); struct ios *s = toiostream(args[0], "io.ungetc");
@ -195,7 +195,7 @@ value_t fl_ioungetc(value_t *args, u_int32_t nargs)
return fixnum(ios_ungetc((int)wc, s)); return fixnum(ios_ungetc((int)wc, s));
} }
value_t fl_ioflush(value_t *args, u_int32_t nargs) value_t fl_ioflush(value_t *args, uint32_t nargs)
{ {
argcount("io.flush", nargs, 1); argcount("io.flush", nargs, 1);
struct ios *s = toiostream(args[0], "io.flush"); struct ios *s = toiostream(args[0], "io.flush");
@ -204,7 +204,7 @@ value_t fl_ioflush(value_t *args, u_int32_t nargs)
return FL_T; return FL_T;
} }
value_t fl_ioclose(value_t *args, u_int32_t nargs) value_t fl_ioclose(value_t *args, uint32_t nargs)
{ {
argcount("io.close", nargs, 1); argcount("io.close", nargs, 1);
struct ios *s = toiostream(args[0], "io.close"); struct ios *s = toiostream(args[0], "io.close");
@ -212,7 +212,7 @@ value_t fl_ioclose(value_t *args, u_int32_t nargs)
return FL_T; return FL_T;
} }
value_t fl_iopurge(value_t *args, u_int32_t nargs) value_t fl_iopurge(value_t *args, uint32_t nargs)
{ {
argcount("io.discardbuffer", nargs, 1); argcount("io.discardbuffer", nargs, 1);
struct ios *s = toiostream(args[0], "io.discardbuffer"); struct ios *s = toiostream(args[0], "io.discardbuffer");
@ -220,14 +220,14 @@ value_t fl_iopurge(value_t *args, u_int32_t nargs)
return FL_T; return FL_T;
} }
value_t fl_ioeof(value_t *args, u_int32_t nargs) value_t fl_ioeof(value_t *args, uint32_t nargs)
{ {
argcount("io.eof?", nargs, 1); argcount("io.eof?", nargs, 1);
struct ios *s = toiostream(args[0], "io.eof?"); struct ios *s = toiostream(args[0], "io.eof?");
return (ios_eof(s) ? FL_T : FL_F); return (ios_eof(s) ? FL_T : FL_F);
} }
value_t fl_ioseek(value_t *args, u_int32_t nargs) value_t fl_ioseek(value_t *args, uint32_t nargs)
{ {
argcount("io.seek", nargs, 2); argcount("io.seek", nargs, 2);
struct ios *s = toiostream(args[0], "io.seek"); struct ios *s = toiostream(args[0], "io.seek");
@ -238,7 +238,7 @@ value_t fl_ioseek(value_t *args, u_int32_t nargs)
return FL_T; return FL_T;
} }
value_t fl_iopos(value_t *args, u_int32_t nargs) value_t fl_iopos(value_t *args, uint32_t nargs)
{ {
argcount("io.pos", nargs, 1); argcount("io.pos", nargs, 1);
struct ios *s = toiostream(args[0], "io.pos"); struct ios *s = toiostream(args[0], "io.pos");
@ -248,7 +248,7 @@ value_t fl_iopos(value_t *args, u_int32_t nargs)
return size_wrap((size_t)res); return size_wrap((size_t)res);
} }
value_t fl_write(value_t *args, u_int32_t nargs) value_t fl_write(value_t *args, uint32_t nargs)
{ {
if (nargs < 1 || nargs > 2) if (nargs < 1 || nargs > 2)
argcount("write", nargs, 1); argcount("write", nargs, 1);
@ -261,7 +261,7 @@ value_t fl_write(value_t *args, u_int32_t nargs)
return args[0]; return args[0];
} }
value_t fl_ioread(value_t *args, u_int32_t nargs) value_t fl_ioread(value_t *args, uint32_t nargs)
{ {
if (nargs != 3) if (nargs != 3)
argcount("io.read", nargs, 2); argcount("io.read", nargs, 2);
@ -306,7 +306,7 @@ static void get_start_count_args(value_t *args, uint32_t nargs, size_t sz,
} }
} }
value_t fl_iowrite(value_t *args, u_int32_t nargs) value_t fl_iowrite(value_t *args, uint32_t nargs)
{ {
if (nargs < 2 || nargs > 4) if (nargs < 2 || nargs > 4)
argcount("io.write", nargs, 2); argcount("io.write", nargs, 2);
@ -330,7 +330,7 @@ value_t fl_iowrite(value_t *args, u_int32_t nargs)
return size_wrap(ios_write(s, data, nb)); return size_wrap(ios_write(s, data, nb));
} }
value_t fl_dump(value_t *args, u_int32_t nargs) value_t fl_dump(value_t *args, uint32_t nargs)
{ {
if (nargs < 1 || nargs > 3) if (nargs < 1 || nargs > 3)
argcount("dump", nargs, 1); argcount("dump", nargs, 1);
@ -360,7 +360,7 @@ static char get_delim_arg(value_t arg, char *fname)
return (char)uldelim; return (char)uldelim;
} }
value_t fl_ioreaduntil(value_t *args, u_int32_t nargs) value_t fl_ioreaduntil(value_t *args, uint32_t nargs)
{ {
argcount("io.readuntil", nargs, 2); argcount("io.readuntil", nargs, 2);
value_t str = cvalue_string(80); value_t str = cvalue_string(80);
@ -384,7 +384,7 @@ value_t fl_ioreaduntil(value_t *args, u_int32_t nargs)
return str; return str;
} }
value_t fl_iocopyuntil(value_t *args, u_int32_t nargs) value_t fl_iocopyuntil(value_t *args, uint32_t nargs)
{ {
argcount("io.copyuntil", nargs, 3); argcount("io.copyuntil", nargs, 3);
struct ios *dest = toiostream(args[0], "io.copyuntil"); struct ios *dest = toiostream(args[0], "io.copyuntil");
@ -393,7 +393,7 @@ value_t fl_iocopyuntil(value_t *args, u_int32_t nargs)
return size_wrap(ios_copyuntil(dest, src, delim)); return size_wrap(ios_copyuntil(dest, src, delim));
} }
value_t fl_iocopy(value_t *args, u_int32_t nargs) value_t fl_iocopy(value_t *args, uint32_t nargs)
{ {
if (nargs < 2 || nargs > 3) if (nargs < 2 || nargs > 3)
argcount("io.copy", nargs, 2); argcount("io.copy", nargs, 2);
@ -426,7 +426,7 @@ value_t stream_to_string(value_t *ps)
return str; return str;
} }
value_t fl_iotostring(value_t *args, u_int32_t nargs) value_t fl_iotostring(value_t *args, uint32_t nargs)
{ {
argcount("io.tostring!", nargs, 1); argcount("io.tostring!", nargs, 1);
struct ios *src = toiostream(args[0], "io.tostring!"); struct ios *src = toiostream(args[0], "io.tostring!");

View File

@ -1,7 +1,7 @@
extern void *memrchr(const void *s, int c, size_t n); extern void *memrchr(const void *s, int c, size_t n);
static struct htable printconses; static struct htable printconses;
static u_int32_t printlabel; static uint32_t printlabel;
static int print_pretty; static int print_pretty;
static int print_princ; static int print_princ;
static fixnum_t print_length; static fixnum_t print_length;

View File

@ -16,7 +16,7 @@
#define OP_EQ(x, y) ((x) == (y)) #define OP_EQ(x, y) ((x) == (y))
#ifdef BITS64 #ifdef BITS64
static u_int64_t _pinthash(u_int64_t key) static uint64_t _pinthash(uint64_t key)
{ {
key = (~key) + (key << 21); // key = (key << 21) - key - 1; key = (~key) + (key << 21); // key = (key << 21) - key - 1;
key = key ^ (key >> 24); key = key ^ (key >> 24);
@ -28,7 +28,7 @@ static u_int64_t _pinthash(u_int64_t key)
return key; return key;
} }
#else #else
static u_int32_t _pinthash(u_int32_t a) static uint32_t _pinthash(uint32_t a)
{ {
a = (a + 0x7ed55d16) + (a << 12); a = (a + 0x7ed55d16) + (a << 12);
a = (a ^ 0xc761c23c) ^ (a >> 19); a = (a ^ 0xc761c23c) ^ (a >> 19);

View File

@ -59,6 +59,6 @@ double randn()
void randomize() void randomize()
{ {
u_int64_t tm = i64time(); uint64_t tm = i64time();
init_by_array((uint32_t *)&tm, 2); init_by_array((uint32_t *)&tm, 2);
} }

View File

@ -6,4 +6,4 @@ double randn();
void randomize(); void randomize();
uint32_t genrand_int32(); uint32_t genrand_int32();
void init_genrand(uint32_t s); void init_genrand(uint32_t s);
u_int64_t i64time(); uint64_t i64time();

View File

@ -113,7 +113,7 @@ static int read_numtok(char *tok, value_t *pval, int base)
return result; return result;
} }
static u_int32_t toktype = TOK_NONE; static uint32_t toktype = TOK_NONE;
static value_t tokval; static value_t tokval;
static char buf[256]; static char buf[256];
@ -190,7 +190,7 @@ terminate:
static value_t do_read_sexpr(value_t label); static value_t do_read_sexpr(value_t label);
static u_int32_t peek(void) static uint32_t peek(void)
{ {
char c, *end; char c, *end;
fixnum_t x; fixnum_t x;
@ -405,10 +405,10 @@ static value_t vector_grow(value_t v)
return POP(); return POP();
} }
static value_t read_vector(value_t label, u_int32_t closer) static value_t read_vector(value_t label, uint32_t closer)
{ {
value_t v = the_empty_vector, elt; value_t v = the_empty_vector, elt;
u_int32_t i = 0; uint32_t i = 0;
PUSH(v); PUSH(v);
if (label != UNBOUND) if (label != UNBOUND)
ptrhash_put(&readstate->backrefs, (void *)label, (void *)v); ptrhash_put(&readstate->backrefs, (void *)label, (void *)v);
@ -439,7 +439,7 @@ static value_t read_string(void)
size_t i = 0, j, sz = 64, ndig; size_t i = 0, j, sz = 64, ndig;
int c; int c;
value_t s; value_t s;
u_int32_t wc = 0; uint32_t wc = 0;
buf = malloc(sz); buf = malloc(sz);
while (1) { while (1) {
@ -516,7 +516,7 @@ static value_t read_string(void)
static void read_list(value_t *pval, value_t label) static void read_list(value_t *pval, value_t label)
{ {
value_t c, *pc; value_t c, *pc;
u_int32_t t; uint32_t t;
PUSH(NIL); PUSH(NIL);
pc = &Stack[SP - 1]; // to keep track of current cons cell pc = &Stack[SP - 1]; // to keep track of current cons cell
@ -560,7 +560,7 @@ static value_t do_read_sexpr(value_t label)
{ {
value_t v, sym, oldtokval, *head; value_t v, sym, oldtokval, *head;
value_t *pv; value_t *pv;
u_int32_t t; uint32_t t;
char c; char c;
t = peek(); t = peek();

View File

@ -32,13 +32,13 @@
#include "flisp.h" #include "flisp.h"
value_t fl_stringp(value_t *args, u_int32_t nargs) value_t fl_stringp(value_t *args, uint32_t nargs)
{ {
argcount("string?", nargs, 1); argcount("string?", nargs, 1);
return fl_isstring(args[0]) ? FL_T : FL_F; return fl_isstring(args[0]) ? FL_T : FL_F;
} }
value_t fl_string_count(value_t *args, u_int32_t nargs) value_t fl_string_count(value_t *args, uint32_t nargs)
{ {
size_t start = 0; size_t start = 0;
if (nargs < 1 || nargs > 3) if (nargs < 1 || nargs > 3)
@ -63,7 +63,7 @@ value_t fl_string_count(value_t *args, u_int32_t nargs)
return size_wrap(u8_charnum(str + start, stop - start)); return size_wrap(u8_charnum(str + start, stop - start));
} }
value_t fl_string_width(value_t *args, u_int32_t nargs) value_t fl_string_width(value_t *args, uint32_t nargs)
{ {
argcount("string.width", nargs, 1); argcount("string.width", nargs, 1);
if (iscprim(args[0])) { if (iscprim(args[0])) {
@ -79,7 +79,7 @@ value_t fl_string_width(value_t *args, u_int32_t nargs)
return size_wrap(u8_strwidth(s)); return size_wrap(u8_strwidth(s));
} }
value_t fl_string_reverse(value_t *args, u_int32_t nargs) value_t fl_string_reverse(value_t *args, uint32_t nargs)
{ {
argcount("string.reverse", nargs, 1); argcount("string.reverse", nargs, 1);
if (!fl_isstring(args[0])) if (!fl_isstring(args[0]))
@ -90,7 +90,7 @@ value_t fl_string_reverse(value_t *args, u_int32_t nargs)
return ns; return ns;
} }
value_t fl_string_encode(value_t *args, u_int32_t nargs) value_t fl_string_encode(value_t *args, uint32_t nargs)
{ {
argcount("string.encode", nargs, 1); argcount("string.encode", nargs, 1);
if (iscvalue(args[0])) { if (iscvalue(args[0])) {
@ -110,7 +110,7 @@ value_t fl_string_encode(value_t *args, u_int32_t nargs)
type_error("string.encode", "wchar array", args[0]); type_error("string.encode", "wchar array", args[0]);
} }
value_t fl_string_decode(value_t *args, u_int32_t nargs) value_t fl_string_decode(value_t *args, uint32_t nargs)
{ {
int term = 0; int term = 0;
if (nargs == 2) { if (nargs == 2) {
@ -136,10 +136,10 @@ value_t fl_string_decode(value_t *args, u_int32_t nargs)
return wcstr; return wcstr;
} }
extern value_t fl_buffer(value_t *args, u_int32_t nargs); extern value_t fl_buffer(value_t *args, uint32_t nargs);
extern value_t stream_to_string(value_t *ps); extern value_t stream_to_string(value_t *ps);
value_t fl_string(value_t *args, u_int32_t nargs) value_t fl_string(value_t *args, uint32_t nargs)
{ {
if (nargs == 1 && fl_isstring(args[0])) if (nargs == 1 && fl_isstring(args[0]))
return args[0]; return args[0];
@ -159,7 +159,7 @@ value_t fl_string(value_t *args, u_int32_t nargs)
return outp; return outp;
} }
value_t fl_string_split(value_t *args, u_int32_t nargs) value_t fl_string_split(value_t *args, uint32_t nargs)
{ {
argcount("string.split", nargs, 2); argcount("string.split", nargs, 2);
char *s = tostring(args[0], "string.split"); char *s = tostring(args[0], "string.split");
@ -203,7 +203,7 @@ value_t fl_string_split(value_t *args, u_int32_t nargs)
return first; return first;
} }
value_t fl_string_sub(value_t *args, u_int32_t nargs) value_t fl_string_sub(value_t *args, uint32_t nargs)
{ {
if (nargs != 2) if (nargs != 2)
argcount("string.sub", nargs, 3); argcount("string.sub", nargs, 3);
@ -227,7 +227,7 @@ value_t fl_string_sub(value_t *args, u_int32_t nargs)
return ns; return ns;
} }
value_t fl_string_char(value_t *args, u_int32_t nargs) value_t fl_string_char(value_t *args, uint32_t nargs)
{ {
argcount("string.char", nargs, 2); argcount("string.char", nargs, 2);
char *s = tostring(args[0], "string.char"); char *s = tostring(args[0], "string.char");
@ -241,7 +241,7 @@ value_t fl_string_char(value_t *args, u_int32_t nargs)
return mk_wchar(u8_nextchar(s, &i)); return mk_wchar(u8_nextchar(s, &i));
} }
value_t fl_char_upcase(value_t *args, u_int32_t nargs) value_t fl_char_upcase(value_t *args, uint32_t nargs)
{ {
argcount("char.upcase", nargs, 1); argcount("char.upcase", nargs, 1);
struct cprim *cp = (struct cprim *)ptr(args[0]); struct cprim *cp = (struct cprim *)ptr(args[0]);
@ -249,7 +249,7 @@ value_t fl_char_upcase(value_t *args, u_int32_t nargs)
type_error("char.upcase", "wchar", args[0]); type_error("char.upcase", "wchar", args[0]);
return mk_wchar(towupper(*(int32_t *)cp_data(cp))); return mk_wchar(towupper(*(int32_t *)cp_data(cp)));
} }
value_t fl_char_downcase(value_t *args, u_int32_t nargs) value_t fl_char_downcase(value_t *args, uint32_t nargs)
{ {
argcount("char.downcase", nargs, 1); argcount("char.downcase", nargs, 1);
struct cprim *cp = (struct cprim *)ptr(args[0]); struct cprim *cp = (struct cprim *)ptr(args[0]);
@ -258,7 +258,7 @@ value_t fl_char_downcase(value_t *args, u_int32_t nargs)
return mk_wchar(towlower(*(int32_t *)cp_data(cp))); return mk_wchar(towlower(*(int32_t *)cp_data(cp)));
} }
value_t fl_char_alpha(value_t *args, u_int32_t nargs) value_t fl_char_alpha(value_t *args, uint32_t nargs)
{ {
argcount("char-alphabetic?", nargs, 1); argcount("char-alphabetic?", nargs, 1);
struct cprim *cp = (struct cprim *)ptr(args[0]); struct cprim *cp = (struct cprim *)ptr(args[0]);
@ -275,7 +275,7 @@ static value_t mem_find_byte(char *s, char c, size_t start, size_t len)
return size_wrap((size_t)(p - s)); return size_wrap((size_t)(p - s));
} }
value_t fl_string_find(value_t *args, u_int32_t nargs) value_t fl_string_find(value_t *args, uint32_t nargs)
{ {
char cbuf[8]; char cbuf[8];
size_t start = 0; size_t start = 0;
@ -323,7 +323,7 @@ value_t fl_string_find(value_t *args, u_int32_t nargs)
return FL_F; return FL_F;
} }
value_t fl_string_inc(value_t *args, u_int32_t nargs) value_t fl_string_inc(value_t *args, uint32_t nargs)
{ {
if (nargs < 2 || nargs > 3) if (nargs < 2 || nargs > 3)
argcount("string.inc", nargs, 2); argcount("string.inc", nargs, 2);
@ -341,7 +341,7 @@ value_t fl_string_inc(value_t *args, u_int32_t nargs)
return size_wrap(i); return size_wrap(i);
} }
value_t fl_string_dec(value_t *args, u_int32_t nargs) value_t fl_string_dec(value_t *args, uint32_t nargs)
{ {
if (nargs < 2 || nargs > 3) if (nargs < 2 || nargs > 3)
argcount("string.dec", nargs, 2); argcount("string.dec", nargs, 2);
@ -370,7 +370,7 @@ static unsigned long get_radix_arg(value_t arg, char *fname)
return radix; return radix;
} }
value_t fl_numbertostring(value_t *args, u_int32_t nargs) value_t fl_numbertostring(value_t *args, uint32_t nargs)
{ {
if (nargs < 1 || nargs > 2) if (nargs < 1 || nargs > 2)
argcount("number->string", nargs, 2); argcount("number->string", nargs, 2);
@ -412,7 +412,7 @@ value_t fl_stringtonumber(value_t *args, uint32_t nargs)
return n; return n;
} }
value_t fl_string_isutf8(value_t *args, u_int32_t nargs) value_t fl_string_isutf8(value_t *args, uint32_t nargs)
{ {
argcount("string.isutf8", nargs, 1); argcount("string.isutf8", nargs, 1);
char *s = tostring(args[0], "string.isutf8"); char *s = tostring(args[0], "string.isutf8");

View File

@ -50,17 +50,17 @@ double diff_time(struct timeval *tv1, struct timeval *tv2)
#endif #endif
// return as many bits of system randomness as we can get our hands on // return as many bits of system randomness as we can get our hands on
u_int64_t i64time() uint64_t i64time()
{ {
u_int64_t a; uint64_t a;
#ifdef WIN32 #ifdef WIN32
struct timeb tstruct; struct timeb tstruct;
ftime(&tstruct); ftime(&tstruct);
a = (((u_int64_t)tstruct.time) << 32) + (u_int64_t)tstruct.millitm; a = (((uint64_t)tstruct.time) << 32) + (uint64_t)tstruct.millitm;
#else #else
struct timeval now; struct timeval now;
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
a = (((u_int64_t)now.tv_sec) << 32) + (u_int64_t)now.tv_usec; a = (((uint64_t)now.tv_sec) << 32) + (uint64_t)now.tv_usec;
#endif #endif
return a; return a;

View File

@ -1,4 +1,4 @@
u_int64_t i64time(); uint64_t i64time();
double clock_now(); double clock_now();
void timestring(double seconds, char *buffer, size_t len); void timestring(double seconds, char *buffer, size_t len);
double parsetime(const char *str); double parsetime(const char *str);

View File

@ -36,9 +36,9 @@
#include "utf8.h" #include "utf8.h"
static const u_int32_t offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, static const uint32_t offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL,
0x000E2080UL, 0x03C82080UL, 0x000E2080UL, 0x03C82080UL,
0xFA082080UL, 0x82082080UL }; 0xFA082080UL, 0x82082080UL };
static const char trailingBytesForUTF8[256] = { static const char trailingBytesForUTF8[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -62,7 +62,7 @@ size_t u8_seqlen(const char *s)
/* returns the # of bytes needed to encode a certain character /* returns the # of bytes needed to encode a certain character
0 means the character cannot (or should not) be encoded. */ 0 means the character cannot (or should not) be encoded. */
size_t u8_charlen(u_int32_t ch) size_t u8_charlen(uint32_t ch)
{ {
if (ch < 0x80) if (ch < 0x80)
return 1; return 1;
@ -75,7 +75,7 @@ size_t u8_charlen(u_int32_t ch)
return 0; return 0;
} }
size_t u8_codingsize(u_int32_t *wcstr, size_t n) size_t u8_codingsize(uint32_t *wcstr, size_t n)
{ {
size_t i, c = 0; size_t i, c = 0;
@ -92,9 +92,9 @@ size_t u8_codingsize(u_int32_t *wcstr, size_t n)
returns # characters converted returns # characters converted
if sz == srcsz+1 (i.e. 4*srcsz+4 bytes), there will always be enough space. if sz == srcsz+1 (i.e. 4*srcsz+4 bytes), there will always be enough space.
*/ */
size_t u8_toucs(u_int32_t *dest, size_t sz, const char *src, size_t srcsz) size_t u8_toucs(uint32_t *dest, size_t sz, const char *src, size_t srcsz)
{ {
u_int32_t ch; uint32_t ch;
const char *src_end = src + srcsz; const char *src_end = src + srcsz;
size_t nb; size_t nb;
size_t i = 0; size_t i = 0;
@ -146,9 +146,9 @@ size_t u8_toucs(u_int32_t *dest, size_t sz, const char *src, size_t srcsz)
returns # bytes stored in dest returns # bytes stored in dest
the destination string will never be bigger than the source string. the destination string will never be bigger than the source string.
*/ */
size_t u8_toutf8(char *dest, size_t sz, const u_int32_t *src, size_t srcsz) size_t u8_toutf8(char *dest, size_t sz, const uint32_t *src, size_t srcsz)
{ {
u_int32_t ch; uint32_t ch;
size_t i = 0; size_t i = 0;
char *dest0 = dest; char *dest0 = dest;
char *dest_end = dest + sz; char *dest_end = dest + sz;
@ -183,7 +183,7 @@ size_t u8_toutf8(char *dest, size_t sz, const u_int32_t *src, size_t srcsz)
return (dest - dest0); return (dest - dest0);
} }
size_t u8_wc_toutf8(char *dest, u_int32_t ch) size_t u8_wc_toutf8(char *dest, uint32_t ch)
{ {
if (ch < 0x80) { if (ch < 0x80) {
dest[0] = (char)ch; dest[0] = (char)ch;
@ -263,7 +263,7 @@ size_t u8_strlen(const char *s)
size_t u8_strwidth(const char *s) size_t u8_strwidth(const char *s)
{ {
u_int32_t ch; uint32_t ch;
size_t nb, tot = 0; size_t nb, tot = 0;
int w; int w;
signed char sc; signed char sc;
@ -311,9 +311,9 @@ size_t u8_strwidth(const char *s)
} }
/* reads the next utf-8 sequence out of a string, updating an index */ /* reads the next utf-8 sequence out of a string, updating an index */
u_int32_t u8_nextchar(const char *s, size_t *i) uint32_t u8_nextchar(const char *s, size_t *i)
{ {
u_int32_t ch = 0; uint32_t ch = 0;
size_t sz = 0; size_t sz = 0;
do { do {
@ -327,9 +327,9 @@ u_int32_t u8_nextchar(const char *s, size_t *i)
} }
/* next character without NUL character terminator */ /* next character without NUL character terminator */
u_int32_t u8_nextmemchar(const char *s, size_t *i) uint32_t u8_nextmemchar(const char *s, size_t *i)
{ {
u_int32_t ch = 0; uint32_t ch = 0;
size_t sz = 0; size_t sz = 0;
do { do {
@ -385,10 +385,10 @@ char read_escape_control_char(char c)
/* assumes that src points to the character after a backslash /* assumes that src points to the character after a backslash
returns number of input characters processed, 0 if error */ returns number of input characters processed, 0 if error */
size_t u8_read_escape_sequence(const char *str, size_t ssz, u_int32_t *dest) size_t u8_read_escape_sequence(const char *str, size_t ssz, uint32_t *dest)
{ {
assert(ssz > 0); assert(ssz > 0);
u_int32_t ch; uint32_t ch;
char digs[10]; char digs[10];
int dno = 0, ndig; int dno = 0, ndig;
size_t i = 1; size_t i = 1;
@ -411,7 +411,7 @@ size_t u8_read_escape_sequence(const char *str, size_t ssz, u_int32_t *dest)
digs[dno] = '\0'; digs[dno] = '\0';
ch = strtol(digs, NULL, 16); ch = strtol(digs, NULL, 16);
} else { } else {
ch = (u_int32_t)read_escape_control_char(c0); ch = (uint32_t)read_escape_control_char(c0);
} }
*dest = ch; *dest = ch;
@ -424,7 +424,7 @@ size_t u8_read_escape_sequence(const char *str, size_t ssz, u_int32_t *dest)
size_t u8_unescape(char *buf, size_t sz, const char *src) size_t u8_unescape(char *buf, size_t sz, const char *src)
{ {
size_t c = 0, amt; size_t c = 0, amt;
u_int32_t ch; uint32_t ch;
char temp[4]; char temp[4];
while (*src && c < sz) { while (*src && c < sz) {
@ -432,7 +432,7 @@ size_t u8_unescape(char *buf, size_t sz, const char *src)
src++; src++;
amt = u8_read_escape_sequence(src, 1000, &ch); amt = u8_read_escape_sequence(src, 1000, &ch);
} else { } else {
ch = (u_int32_t)*src; ch = (uint32_t)*src;
amt = 1; amt = 1;
} }
src += amt; src += amt;
@ -455,7 +455,7 @@ static inline int buf_put2c(char *buf, const char *src)
return 2; return 2;
} }
int u8_escape_wchar(char *buf, size_t sz, u_int32_t ch) int u8_escape_wchar(char *buf, size_t sz, uint32_t ch)
{ {
assert(sz > 2); assert(sz > 2);
if (ch == L'\n') if (ch == L'\n')
@ -479,7 +479,7 @@ int u8_escape_wchar(char *buf, size_t sz, u_int32_t ch)
else if (ch < 32 || ch == 0x7f) else if (ch < 32 || ch == 0x7f)
return snprintf(buf, sz, "\\x%.2hhx", (unsigned char)ch); return snprintf(buf, sz, "\\x%.2hhx", (unsigned char)ch);
else if (ch > 0xFFFF) else if (ch > 0xFFFF)
return snprintf(buf, sz, "\\U%.8x", (u_int32_t)ch); return snprintf(buf, sz, "\\U%.8x", (uint32_t)ch);
else if (ch >= 0x80) else if (ch >= 0x80)
return snprintf(buf, sz, "\\u%.4hx", (unsigned short)ch); return snprintf(buf, sz, "\\u%.4hx", (unsigned short)ch);
@ -492,7 +492,7 @@ size_t u8_escape(char *buf, size_t sz, const char *src, size_t *pi,
size_t end, int escape_quotes, int ascii) size_t end, int escape_quotes, int ascii)
{ {
size_t i = *pi, i0; size_t i = *pi, i0;
u_int32_t ch; uint32_t ch;
char *start = buf; char *start = buf;
char *blim = start + sz - 11; char *blim = start + sz - 11;
assert(sz > 11); assert(sz > 11);
@ -523,10 +523,10 @@ size_t u8_escape(char *buf, size_t sz, const char *src, size_t *pi,
return (buf - start); return (buf - start);
} }
char *u8_strchr(const char *s, u_int32_t ch, size_t *charn) char *u8_strchr(const char *s, uint32_t ch, size_t *charn)
{ {
size_t i = 0, lasti = 0; size_t i = 0, lasti = 0;
u_int32_t c; uint32_t c;
*charn = 0; *charn = 0;
while (s[i]) { while (s[i]) {
@ -541,10 +541,10 @@ char *u8_strchr(const char *s, u_int32_t ch, size_t *charn)
return NULL; return NULL;
} }
char *u8_memchr(const char *s, u_int32_t ch, size_t sz, size_t *charn) char *u8_memchr(const char *s, uint32_t ch, size_t sz, size_t *charn)
{ {
size_t i = 0, lasti = 0; size_t i = 0, lasti = 0;
u_int32_t c; uint32_t c;
int csz; int csz;
*charn = 0; *charn = 0;
@ -566,10 +566,10 @@ char *u8_memchr(const char *s, u_int32_t ch, size_t sz, size_t *charn)
return NULL; return NULL;
} }
char *u8_memrchr(const char *s, u_int32_t ch, size_t sz) char *u8_memrchr(const char *s, uint32_t ch, size_t sz)
{ {
size_t i = sz - 1, tempi = 0; size_t i = sz - 1, tempi = 0;
u_int32_t c; uint32_t c;
if (sz == 0) if (sz == 0)
return NULL; return NULL;
@ -620,7 +620,7 @@ size_t u8_vprintf(const char *fmt, va_list ap)
{ {
size_t cnt, sz = 0, nc, needfree = 0; size_t cnt, sz = 0, nc, needfree = 0;
char *buf; char *buf;
u_int32_t *wcs; uint32_t *wcs;
sz = 512; sz = 512;
buf = (char *)alloca(sz); buf = (char *)alloca(sz);
@ -632,7 +632,7 @@ size_t u8_vprintf(const char *fmt, va_list ap)
needfree = 1; needfree = 1;
vsnprintf(buf, cnt + 1, fmt, ap); vsnprintf(buf, cnt + 1, fmt, ap);
} }
wcs = (u_int32_t *)alloca((cnt + 1) * sizeof(u_int32_t)); wcs = (uint32_t *)alloca((cnt + 1) * sizeof(uint32_t));
nc = u8_toucs(wcs, cnt + 1, buf, cnt); nc = u8_toucs(wcs, cnt + 1, buf, cnt);
wcs[nc] = 0; wcs[nc] = 0;
printf("%ls", (wchar_t *)wcs); printf("%ls", (wchar_t *)wcs);

View File

@ -7,16 +7,16 @@ extern int wcwidth(uint32_t);
/* is c the start of a utf8 sequence? */ /* is c the start of a utf8 sequence? */
#define isutf(c) (((c)&0xC0) != 0x80) #define isutf(c) (((c)&0xC0) != 0x80)
#define UEOF ((u_int32_t)-1) #define UEOF ((uint32_t)-1)
/* convert UTF-8 data to wide character */ /* convert UTF-8 data to wide character */
size_t u8_toucs(u_int32_t *dest, size_t sz, const char *src, size_t srcsz); size_t u8_toucs(uint32_t *dest, size_t sz, const char *src, size_t srcsz);
/* the opposite conversion */ /* the opposite conversion */
size_t u8_toutf8(char *dest, size_t sz, const u_int32_t *src, size_t srcsz); size_t u8_toutf8(char *dest, size_t sz, const uint32_t *src, size_t srcsz);
/* single character to UTF-8, returns # bytes written */ /* single character to UTF-8, returns # bytes written */
size_t u8_wc_toutf8(char *dest, u_int32_t ch); size_t u8_wc_toutf8(char *dest, uint32_t ch);
/* character number to byte offset */ /* character number to byte offset */
size_t u8_offset(const char *str, size_t charnum); size_t u8_offset(const char *str, size_t charnum);
@ -25,10 +25,10 @@ size_t u8_offset(const char *str, size_t charnum);
size_t u8_charnum(const char *s, size_t offset); size_t u8_charnum(const char *s, size_t offset);
/* return next character, updating an index variable */ /* return next character, updating an index variable */
u_int32_t u8_nextchar(const char *s, size_t *i); uint32_t u8_nextchar(const char *s, size_t *i);
/* next character without NUL character terminator */ /* next character without NUL character terminator */
u_int32_t u8_nextmemchar(const char *s, size_t *i); uint32_t u8_nextmemchar(const char *s, size_t *i);
/* move to next character */ /* move to next character */
void u8_inc(const char *s, size_t *i); void u8_inc(const char *s, size_t *i);
@ -40,22 +40,22 @@ void u8_dec(const char *s, size_t *i);
size_t u8_seqlen(const char *s); size_t u8_seqlen(const char *s);
/* returns the # of bytes needed to encode a certain character */ /* returns the # of bytes needed to encode a certain character */
size_t u8_charlen(u_int32_t ch); size_t u8_charlen(uint32_t ch);
/* computes the # of bytes needed to encode a WC string as UTF-8 */ /* computes the # of bytes needed to encode a WC string as UTF-8 */
size_t u8_codingsize(u_int32_t *wcstr, size_t n); size_t u8_codingsize(uint32_t *wcstr, size_t n);
char read_escape_control_char(char c); char read_escape_control_char(char c);
/* assuming src points to the character after a backslash, read an /* assuming src points to the character after a backslash, read an
escape sequence, storing the result in dest and returning the number of escape sequence, storing the result in dest and returning the number of
input characters processed */ input characters processed */
size_t u8_read_escape_sequence(const char *src, size_t ssz, u_int32_t *dest); size_t u8_read_escape_sequence(const char *src, size_t ssz, uint32_t *dest);
/* given a wide character, convert it to an ASCII escape sequence stored in /* given a wide character, convert it to an ASCII escape sequence stored in
buf, where buf is "sz" bytes. returns the number of characters output. buf, where buf is "sz" bytes. returns the number of characters output.
sz must be at least 3. */ sz must be at least 3. */
int u8_escape_wchar(char *buf, size_t sz, u_int32_t ch); int u8_escape_wchar(char *buf, size_t sz, uint32_t ch);
/* convert a string "src" containing escape sequences to UTF-8 */ /* convert a string "src" containing escape sequences to UTF-8 */
size_t u8_unescape(char *buf, size_t sz, const char *src); size_t u8_unescape(char *buf, size_t sz, const char *src);
@ -84,13 +84,13 @@ int hex_digit(char c);
/* return a pointer to the first occurrence of ch in s, or NULL if not /* return a pointer to the first occurrence of ch in s, or NULL if not
found. character index of found character returned in *charn. */ found. character index of found character returned in *charn. */
char *u8_strchr(const char *s, u_int32_t ch, size_t *charn); char *u8_strchr(const char *s, uint32_t ch, size_t *charn);
/* same as the above, but searches a buffer of a given size instead of /* same as the above, but searches a buffer of a given size instead of
a NUL-terminated string. */ a NUL-terminated string. */
char *u8_memchr(const char *s, u_int32_t ch, size_t sz, size_t *charn); char *u8_memchr(const char *s, uint32_t ch, size_t sz, size_t *charn);
char *u8_memrchr(const char *s, u_int32_t ch, size_t sz); char *u8_memrchr(const char *s, uint32_t ch, size_t sz);
/* count the number of characters in a UTF-8 string */ /* count the number of characters in a UTF-8 string */
size_t u8_strlen(const char *s); size_t u8_strlen(const char *s);

View File

@ -34,14 +34,14 @@ int isdigit_base(char c, int base);
#endif #endif
#if !defined(__INTEL_COMPILER) && (defined(ARCH_X86) || defined(ARCH_X86_64)) #if !defined(__INTEL_COMPILER) && (defined(ARCH_X86) || defined(ARCH_X86_64))
STATIC_INLINE u_int16_t ByteSwap16(u_int16_t x) STATIC_INLINE uint16_t ByteSwap16(uint16_t x)
{ {
__asm("xchgb %b0,%h0" : LEGACY_REGS(x) : "0"(x)); __asm("xchgb %b0,%h0" : LEGACY_REGS(x) : "0"(x));
return x; return x;
} }
#define bswap_16(x) ByteSwap16(x) #define bswap_16(x) ByteSwap16(x)
STATIC_INLINE u_int32_t ByteSwap32(u_int32_t x) STATIC_INLINE uint32_t ByteSwap32(uint32_t x)
{ {
#if __CPU__ > 386 #if __CPU__ > 386
__asm("bswap %0" __asm("bswap %0"
@ -60,15 +60,15 @@ STATIC_INLINE u_int32_t ByteSwap32(u_int32_t x)
#define bswap_32(x) ByteSwap32(x) #define bswap_32(x) ByteSwap32(x)
STATIC_INLINE u_int64_t ByteSwap64(u_int64_t x) STATIC_INLINE uint64_t ByteSwap64(uint64_t x)
{ {
#ifdef ARCH_X86_64 #ifdef ARCH_X86_64
__asm("bswap %0" : "=r"(x) : "0"(x)); __asm("bswap %0" : "=r"(x) : "0"(x));
return x; return x;
#else #else
register union { register union {
__extension__ u_int64_t __ll; __extension__ uint64_t __ll;
u_int32_t __l[2]; uint32_t __l[2];
} __x; } __x;
asm("xchgl %0,%1" asm("xchgl %0,%1"
: "=r"(__x.__l[0]), "=r"(__x.__l[1]) : "=r"(__x.__l[0]), "=r"(__x.__l[1])
@ -91,11 +91,11 @@ STATIC_INLINE u_int64_t ByteSwap64(u_int64_t x)
(((x)&0x0000ff00) << 8) | (((x)&0x000000ff) << 24)) (((x)&0x0000ff00) << 8) | (((x)&0x000000ff) << 24))
#endif #endif
STATIC_INLINE u_int64_t ByteSwap64(u_int64_t x) STATIC_INLINE uint64_t ByteSwap64(uint64_t x)
{ {
union { union {
u_int64_t ll; uint64_t ll;
u_int32_t l[2]; uint32_t l[2];
} w, r; } w, r;
w.ll = x; w.ll = x;
r.l[0] = bswap_32(w.l[1]); r.l[0] = bswap_32(w.l[1]);