Skip to content

Commit

Permalink
Merge branch 'r3_64' into community
Browse files Browse the repository at this point in the history
  • Loading branch information
ladislav committed Dec 20, 2013
2 parents e936d8d + deb6694 commit b909f15
Show file tree
Hide file tree
Showing 31 changed files with 175 additions and 263 deletions.
4 changes: 2 additions & 2 deletions src/boot/platforms.r
Expand Up @@ -16,8 +16,8 @@ REBOL [

Amiga [1 m68k20+ 2 m68k 3 ppc]
Macintosh [1 mac-ppc 2 mac-m68k 3 mac-misc 4 osx-ppc 5 osx-x86]
Windows [1 win32-x86 2 dec-alpha]
Linux [1 libc5-x86 2 libc6-2-3-x86 3 libc6-2-5-x86 4 libc6-2-11-x86 10 libc6-ppc 20 libc6-arm 30 libc6-mips]
Windows [1 win32-x86 2 dec-alpha 3 win32-x64]
Linux [1 libc5-x86 2 libc6-2-3-x86 3 libc6-2-5-x86 4 libc6-2-11-x86 10 libc6-ppc 20 libc6-arm 30 libc6-mips 40 libc-x64]
Haiku [75 x86-32]
BSDi [1 x86]
FreeBSD [1 x86 2 elf-x86]
Expand Down
16 changes: 8 additions & 8 deletions src/core/a-lib.c
Expand Up @@ -104,21 +104,21 @@ extern int Do_Callback(REBSER *obj, u32 name, RXIARG *args, RXIARG *result);
***********************************************************************/
{
int marker;
REBCNT bounds;
REBUPT bounds;

Host_Lib = lib;

if (Host_Lib->size < HOST_LIB_SIZE) return 1;
if (((HOST_LIB_VER << 16) + HOST_LIB_SUM) != Host_Lib->ver_sum) return 2;

bounds = OS_CONFIG(1, 0);
if (bounds == 0) bounds = STACK_BOUNDS;
bounds = (REBUPT)OS_CONFIG(1, 0);
if (bounds == 0) bounds = (REBUPT)STACK_BOUNDS;

#ifdef OS_STACK_GROWS_UP
Stack_Limit = (REBCNT)(&marker) + bounds;
Stack_Limit = (REBUPT)(&marker) + bounds;
#else
if (bounds > (REBCNT)(&marker)) Stack_Limit = 100;
else Stack_Limit = (REBCNT)(&marker) - bounds;
if (bounds > (REBUPT) &marker) Stack_Limit = 100;
else Stack_Limit = (REBUPT)&marker - bounds;
#endif

Init_Core(rargs);
Expand Down Expand Up @@ -708,7 +708,7 @@ RL_API u32 RL_Find_Word(u32 *words, u32 word)
return 0;
}

RL_API int RL_Series(REBSER *series, REBCNT what)
RL_API REBUPT RL_Series(REBSER *series, REBCNT what)
/*
** Get series information.
**
Expand All @@ -722,7 +722,7 @@ RL_API int RL_Series(REBSER *series, REBCNT what)
*/
{
switch (what) {
case RXI_SER_DATA: return (int)SERIES_DATA(series); // problem for 64 bit !!
case RXI_SER_DATA: return (REBUPT)SERIES_DATA(series);
case RXI_SER_TAIL: return SERIES_TAIL(series);
case RXI_SER_LEFT: return SERIES_AVAIL(series);
case RXI_SER_SIZE: return SERIES_REST(series);
Expand Down
11 changes: 8 additions & 3 deletions src/core/b-init.c
Expand Up @@ -96,9 +96,14 @@ extern const REBYTE Str_Banner[];
#endif

ASSERT(VAL_TYPE(&val) == 123, RP_REBVAL_ALIGNMENT);
ASSERT(sizeof(REBVAL) == 16, RP_REBVAL_ALIGNMENT);
if (sizeof(void *) == 8) {
ASSERT(sizeof(REBVAL) == 32, RP_REBVAL_ALIGNMENT);
ASSERT1(sizeof(REBGOB) == 84, RP_BAD_SIZE);
} else {
ASSERT(sizeof(REBVAL) == 16, RP_REBVAL_ALIGNMENT);
ASSERT1(sizeof(REBGOB) == 64, RP_BAD_SIZE);
}
ASSERT1(sizeof(REBDAT) == 4, RP_BAD_SIZE);
ASSERT1(sizeof(REBGOB) == 64, RP_BAD_SIZE);
}


Expand Down Expand Up @@ -320,7 +325,7 @@ extern const REBYTE Str_Banner[];
{
Action_Count++;
if (Action_Count >= A_MAX_ACTION) Crash(RP_ACTION_OVERFLOW);
Make_Native(ds, VAL_SERIES(D_ARG(1)), (REBFUN)Action_Count, REB_ACTION);
Make_Native(ds, VAL_SERIES(D_ARG(1)), (REBFUN)(REBUPT)Action_Count, REB_ACTION);
return R_RET;
}

Expand Down
7 changes: 4 additions & 3 deletions src/core/d-dump.c
Expand Up @@ -71,7 +71,7 @@

cp = buf;
for (l = 0; l < max_lines; l++) {
cp = Form_Hex_Pad(cp, (REBCNT) bp, 8);
cp = Form_Hex_Pad(cp, (REBUPT) bp, 8);

*cp++ = ':';
*cp++ = ' ';
Expand Down Expand Up @@ -122,7 +122,8 @@

cp = buf;
for (l = 0; l < count; l++) {
cp = Form_Hex_Pad(cp, (REBCNT) l, 4);
cp = Form_Hex_Pad(cp, l, 8);

*cp++ = ':';
*cp++ = ' ';

Expand All @@ -132,7 +133,7 @@
else *cp++ = ' ';
}
*cp++ = ' ';
for (n = 0; n < 4; n++) {
for (n = 0; n < sizeof(REBVAL) / sizeof(REBCNT); n++) {
cp = Form_Hex_Pad(cp, *bp++, 8);
*cp++ = ' ';
}
Expand Down
22 changes: 16 additions & 6 deletions src/core/d-print.c
Expand Up @@ -613,13 +613,23 @@ static REBREQ *Req_SIO;
**
***********************************************************************/
{
up[0] = Hex_Digits[(val >> 20) & 0xf];
up[1] = Hex_Digits[(val >> 16) & 0xf];
#ifdef ENDIAN_LITTLE
up[0] = Hex_Digits[(val >> 4) & 0xf];
up[1] = Hex_Digits[val & 0xf];
up[2] = Hex_Digits[(val >> 12) & 0xf];
up[3] = Hex_Digits[(val >> 8) & 0xf];
up[4] = Hex_Digits[(val >> 4) & 0xf];
up[5] = Hex_Digits[val & 0xf];
up[4] = Hex_Digits[(val >> 20) & 0xf];
up[5] = Hex_Digits[(val >> 16) & 0xf];
#else
up[0] = Hex_Digits[(val >> 28) & 0xf];
up[1] = Hex_Digits[(val >> 24) & 0xf];
up[2] = Hex_Digits[(val >> 20) & 0xf];
up[3] = Hex_Digits[(val >> 16) & 0xf];
up[4] = Hex_Digits[(val >> 12) & 0xf];
up[5] = Hex_Digits[(val >> 8) & 0xf];
#endif
up[6] = 0;

return up+6;
}

Expand Down Expand Up @@ -706,7 +716,7 @@ static REBREQ *Req_SIO;

case 's':
cp = va_arg(args, REBYTE *);
if ((REBCNT)cp < 100) cp = (REBYTE*)Bad_Ptr;
if ((REBUPT)cp < 100) cp = (REBYTE*)Bad_Ptr;
if (pad == 1) pad = LEN_BYTES(cp);
if (pad < 0) {
pad = -pad;
Expand Down Expand Up @@ -751,7 +761,7 @@ static REBREQ *Req_SIO;
if (len + MAX_HEX_LEN + 1 < max) { // A cheat, but it is safe.
*bp++ = '#';
if (pad == 1) pad = 8;
cp = Form_Hex_Pad(bp, (REBCNT)(va_arg(args, REBYTE*)), pad);
cp = Form_Hex_Pad(bp, (REBU64)(REBUPT)(va_arg(args, REBYTE*)), pad);
len += 1 + (REBCNT)(cp - bp);
bp = cp;
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/f-deci.c
Expand Up @@ -536,8 +536,8 @@ REBDEC deci_to_decimal (const deci a) {
deci decimal_to_deci (REBDEC a) {
deci result;
REBI64 d; /* decimal significand */
int e; /* decimal exponent */
int s; /* sign */
REBINT e; /* decimal exponent */
REBINT s; /* sign */
REBYTE *c;
REBYTE *rve;

Expand Down
155 changes: 2 additions & 153 deletions src/core/f-math.c
Expand Up @@ -22,7 +22,7 @@
** Module: f-math.c
** Summary: basic math conversions
** Section: functional
** Author: Carl Sassenrath
** Author: Carl Sassenrath, Ladislav Mecir
** Notes:
** Do not underestimate what it takes to make some parts of this
** portable over all systems. Modifications to this code should be
Expand Down Expand Up @@ -210,7 +210,6 @@
return buf + len;
}


/***********************************************************************
**
*/ REBYTE *Form_Integer(REBYTE *buf, REBI64 val)
Expand All @@ -236,163 +235,14 @@
}


#ifdef OLDER
/***********************************************************************
**
xx*/ REBCNT Set_Random(REBCNT seed)
/*
***********************************************************************/
{
REBCNT save = next;
next = seed;
return save;
}


/***********************************************************************
**
xx*/ REBCNT Random_Int(REBFLG secure)
/*
** Return random integer. Secure uses SHA1 for better quality.
** Be careful of endian-ness.
**
***********************************************************************/
{
REBCNT tmp;

next = next * 1103515245L + 12345L;
tmp = next & 0xffff0000;
next = next * 1103515245L + 12345L;
tmp |= (next >> 16);

if (secure) {
REBYTE srcbuf[20], dstbuf[20];
REBCNT i;

Long_To_Bytes(srcbuf, tmp);
for(i = sizeof(tmp); i < 20; i += sizeof(tmp))
memcpy(srcbuf + i, srcbuf, sizeof(tmp));
SHA1(srcbuf, i, dstbuf);
tmp = Bytes_To_Long(dstbuf);
}

return tmp;
}
#endif

#ifdef OLD_DEC_TO_STR
static int Convert_Decimal(REBDEC d, REBI64 *sig, REBINT *point)
{
REBDEC e;
REBDEC n;

// Check if num needs exp format:
e = floor(log10(d));
if (e > 15 || e < -6) return 0; // use gcvt

modf(d * pow(10, (15-e)), &n);
*sig = (REBI64)n;
*point = 1 + (REBINT)e;
return 1;
}

/***********************************************************************
**
*/ REBINT Emit_Decimal(REBYTE *cp, REBDEC d, REBFLG percent, REBYTE point, REBINT digits)
/*
***********************************************************************/
{
REBYTE out[MAX_NUMCHR];
REBINT len;
REBINT n;
REBINT i;
REBI64 sig;
REBINT pt;
REBFLG neg;
REBYTE *start = cp;

*cp = out[0] = 0;

// Deal with 0 as special case:
if (d == 0.0 || d == -0.0) {
*cp++ = '0';
if (!percent) {
*cp++ = '.';
*cp++ = '0';
}
}
else {

if (percent) d *= 100.0;

if (NZ(neg = (d < 0))) d = -d;

if (Convert_Decimal(d, &sig, &pt)) {
// Not exp format.
len = Form_Integer(out, sig) - out;
if (neg) *cp++ = '-';

// Trim un-needed trailing zeros:
for (len--; len > 0 && len >= pt; len--) {
if (out[len] == '0') out[len] = 0;
else break;
}

// Leading zero, as in 0.1
if (pt <= 0) *cp++ = '0';

// Other leading digits:
for (n = 0; out[n] && n < pt; n++) *cp++ = out[n];

if (!percent || n <= len) {
// Decimal point:
*cp++ = point;

// Zeros before first significant digit:
for (i = 0; i > pt; i--) *cp++ = '0';

// All remaining digits:
for (; n <= len; n++) *cp++ = out[n];

// Force extra zero in 1.0 cases:
if (cp[-1] == point) *cp++ = '0';
}
}
else {
REBYTE *pp;

// Requires exp format:
if (percent) Trap0(RE_OVERFLOW);
len = Get_System_Int(SYS_OPTIONS, OPTIONS_DECIMAL_DIGITS, MAX_DIGITS);
if (len > MAX_DIGITS) len = MAX_DIGITS;
gcvt(d, len, cp); // returns 1.2e123 (also 1e123)
pp = strchr(cp, '.');
if (pp && (pp[1] == 'e' || pp[1] == 'E')) {
memcpy(pp, pp+1, strlen(pp));
}
if (point != '.' && pp) {
cp = strchr(cp, '.');
if (cp) *cp = point;
}
cp = start + LEN_BYTES(start);
}
}

if (percent) *cp++ = '%';
*cp = 0;

return cp - start;
}

#else // NEW_DEC_TO_STR

#define MIN_DIGITS 1
/* this is appropriate for 64-bit IEEE754 binary floating point format */
#define MAX_DIGITS 17

REBINT Emit_Decimal(REBYTE *cp, REBDEC d, REBFLG trim, REBYTE point, REBINT decimal_digits) {
REBYTE *start = cp, *sig, *rve;
int e, sgn;
REBINT e, sgn;
REBINT digits_obtained;

/* sanity checks */
Expand Down Expand Up @@ -470,4 +320,3 @@ REBINT Emit_Decimal(REBYTE *cp, REBDEC d, REBFLG trim, REBYTE point, REBINT deci
*cp = 0;
return cp - start;
}
#endif // NEW_DEC_TO_STR
2 changes: 1 addition & 1 deletion src/core/f-round.c
Expand Up @@ -86,7 +86,7 @@ enum {
***********************************************************************/
{
REBDEC r;
int e;
REBINT e;
REBFLG v;
union {REBDEC d; REBI64 i;} m;
REBI64 j;
Expand Down
13 changes: 7 additions & 6 deletions src/core/f-stubs.c
Expand Up @@ -32,27 +32,28 @@

/***********************************************************************
**
*/ void Long_To_Bytes(REBYTE *out, REBCNT in)
*/ void REBCNT_To_Bytes(REBYTE *out, REBCNT in)
/*
***********************************************************************/
{
ASSERT(sizeof(REBCNT) == 4, RP_BAD_SIZE);
out[0] = (REBYTE) in;
out[1] = (REBYTE)(in >> 8);
out[2] = (REBYTE)(in >> 16);
out[3] = (REBYTE)(in >> 24);
}


/***********************************************************************
**
*/ REBCNT Bytes_To_Long(REBYTE *in)
*/ REBCNT Bytes_To_REBCNT(REBYTE *in)
/*
***********************************************************************/
{
ASSERT(sizeof(REBCNT) == 4, RP_BAD_SIZE);
return (REBCNT) in[0] // & 0xFF
| (REBCNT) (in[1] << 8) // & 0xFF00;
| (REBCNT) (in[2] << 16) // & 0xFF0000;
| (REBCNT) (in[3] << 24); // & 0xFF000000;
| (REBCNT) in[1] << 8 // & 0xFF00;
| (REBCNT) in[2] << 16 // & 0xFF0000;
| (REBCNT) in[3] << 24; // & 0xFF000000;
}


Expand Down

0 comments on commit b909f15

Please sign in to comment.