[OpenBIOS] r436 - openbios-devel/kernel
svn at openbios.org
svn at openbios.org
Sat Jan 31 17:42:01 CET 2009
Author: blueswirl
Date: 2009-01-31 17:42:01 +0100 (Sat, 31 Jan 2009)
New Revision: 436
Modified:
openbios-devel/kernel/bootstrap.c
openbios-devel/kernel/cross.h
openbios-devel/kernel/dict.c
openbios-devel/kernel/forth.c
Log:
Fix Sparc64 cross compilation in 32 bit environment, closes #17
Modified: openbios-devel/kernel/bootstrap.c
===================================================================
--- openbios-devel/kernel/bootstrap.c 2009-01-31 13:33:07 UTC (rev 435)
+++ openbios-devel/kernel/bootstrap.c 2009-01-31 16:42:01 UTC (rev 436)
@@ -116,7 +116,7 @@
bit=i&~(-BITS);
if(d1[i]==d2[i]) {
- reloc_table[pos] &= target_ucell(~((ucell)1UL<<bit));
+ reloc_table[pos] &= target_ucell(~((ucell)1ULL << bit));
// This check might bring false positives in data.
//if(d1[i] >= pointer2cell(dict_one) &&
@@ -124,7 +124,7 @@
// printk("\nWARNING: inconsistent relocation (%x:%x)!\n", d1[i], d2[i]);
} else {
/* This is a pointer, it needs relocation, d2==dict */
- reloc_table[pos] |= target_ucell((ucell)1UL<<bit);
+ reloc_table[pos] |= target_ucell((ucell)1ULL << bit);
d2[i] = target_ucell(target_ucell(d2[i]) - pointer2cell(d2));
}
}
@@ -175,8 +175,9 @@
.checksum = 0,
.compression = 0,
.relocation = -1,
- .length = target_ulong(dicthead),
- .last = target_ucell(((unsigned long)last-(unsigned long)dict)),
+ .length = target_ulong((uint32_t)dicthead),
+ .last = target_ucell((ucell)((unsigned long)last
+ - (unsigned long)dict)),
.reserved[0] = 0,
.reserved[1] = 0,
.reserved[2] = 0,
@@ -464,7 +465,7 @@
{
FILE *f;
char tib[160];
- long num;
+ cell num;
char *test;
const ucell SEMIS = (ucell)findword("(semis)");
@@ -627,11 +628,12 @@
u8 flags = read_byte((u8*)cell2pointer(res) -
sizeof(cell) - 1);
#ifdef CONFIG_DEBUG_INTERPRETER
- printk("%s is 0x%p\n", tib, (ucell) res);
+ printk("%s is 0x%" FMT_CELL_x "\n", tib, (ucell) res);
#endif
if (!(*state) || (flags & 3)) {
#ifdef CONFIG_DEBUG_INTERPRETER
- printk("executing %s, %p (flags: %s %s)\n",
+ printk("executing %s, %" FMT_CELL_d
+ " (flags: %s %s)\n",
tib, res,
(flags & 1) ? "immediate" : "",
(flags & 2) ? "compile-only" : "");
@@ -649,9 +651,9 @@
/* if not look if it's a number */
if (tib[0] == '-')
- num = strtol(tib, &test, read_ucell(base));
+ num = strtoll(tib, &test, read_ucell(base));
else
- num = strtoul(tib, &test, read_ucell(base));
+ num = strtoull(tib, &test, read_ucell(base));
if (*test != 0) {
@@ -667,12 +669,12 @@
if (*state == 0) {
#ifdef CONFIG_DEBUG_INTERPRETER
- printk("pushed %x to stack\n\n", num);
+ printk("pushed %" FMT_CELL_x " to stack\n\n", num);
#endif
PUSH(num);
} else {
#ifdef CONFIG_DEBUG_INTERPRETER
- printk("writing lit, %x to dict\n\n", num);
+ printk("writing lit, %" FMT_CELL_x " to dict\n\n", num);
#endif
writecell(LIT); /* lit */
writecell(num);
Modified: openbios-devel/kernel/cross.h
===================================================================
--- openbios-devel/kernel/cross.h 2009-01-31 13:33:07 UTC (rev 435)
+++ openbios-devel/kernel/cross.h 2009-01-31 16:42:01 UTC (rev 436)
@@ -46,16 +46,13 @@
#define target_ucell(value) ((ucell)target_long(value))
#define target_cell(value) ((cell)target_long(value))
#elif BITS==64
-#ifdef NATIVE_BITWIDTH_LARGER_THAN_HOST_BITWIDTH
-#define target_ucell(value) ( ((ucell)target_long((value)&0xffffffff))<<32 )
-#define target_cell(value) ( ((cell)target_long((value)&0xffffffff))<<32 )
+#define target_ucell(value) \
+ ((((ucell)target_long((value) & 0xffffffff)) << 32) | \
+ ((ucell)target_long((value) >> 32)))
+#define target_cell(value) \
+ ((((cell)target_long((value) & 0xffffffff)) << 32) | \
+ ((cell)target_long((value) >> 32)))
#else
-#define target_ucell(value) ( ((ucell)target_long((value)&0xffffffff))<<32 | \
- ((ucell)target_long((value)>>32)) )
-#define target_cell(value) ( ((cell)target_long((value)&0xffffffff))<<32 | \
- ((cell)target_long((value)>>32)) )
-#endif
-#else
#error "Endianness not supported. Please report."
#endif
Modified: openbios-devel/kernel/dict.c
===================================================================
--- openbios-devel/kernel/dict.c 2009-01-31 13:33:07 UTC (rev 435)
+++ openbios-devel/kernel/dict.c 2009-01-31 16:42:01 UTC (rev 436)
@@ -167,7 +167,7 @@
l=(walk-(ucell *)dict);
pos=l/BITS;
bit=l&~(-BITS);
- if (reloc_table[pos]&target_ucell(1UL<<bit)) {
+ if (reloc_table[pos] & target_ucell((ucell)1ULL << bit)) {
// printk("%lx, pos %x, bit %d\n",*walk, pos, bit);
write_ucell(walk, read_ucell(walk)+pointer2cell(dict));
}
Modified: openbios-devel/kernel/forth.c
===================================================================
--- openbios-devel/kernel/forth.c 2009-01-31 13:33:07 UTC (rev 435)
+++ openbios-devel/kernel/forth.c 2009-01-31 16:42:01 UTC (rev 436)
@@ -330,8 +330,18 @@
const ucell b = POP();
const ducell a = DPOP();
#ifdef NEED_FAKE_INT128_T
- fprintf(stderr, "mudivmode called\n");
- exit(-1);
+ if (a.hi != 0) {
+ fprintf(stderr, "mudivmod called (0x%016llx %016llx / 0x%016llx)\n",
+ a.hi, a.lo, b);
+ exit(-1);
+ } else {
+ ducell c;
+
+ PUSH(a.lo % b);
+ c.hi = 0;
+ c.lo = a.lo / b;
+ DPUSH(c);
+ }
#else
PUSH(a % b);
DPUSH(a / b);
@@ -480,8 +490,16 @@
const dcell d2 = DPOP();
const dcell d1 = DPOP();
#ifdef NEED_FAKE_INT128_T
- fprintf(stderr, "dplus called\n");
- exit(-1);
+ ducell c;
+
+ if (d1.hi != 0 || d2.hi != 0) {
+ fprintf(stderr, "dplus called (0x%016llx %016llx + 0x%016llx %016llx)\n",
+ d1.hi, d1.lo, d2.hi, d2.lo);
+ exit(-1);
+ }
+ c.hi = 0;
+ c.lo = d1.lo + d2.lo;
+ DPUSH(c);
#else
DPUSH(d1 + d2);
#endif
@@ -497,8 +515,16 @@
const dcell d2 = DPOP();
const dcell d1 = DPOP();
#ifdef NEED_FAKE_INT128_T
- fprintf(stderr, "dminus called\n");
- exit(-1);
+ ducell c;
+
+ if (d1.hi != 0 || d2.hi != 0) {
+ fprintf(stderr, "dminus called (0x%016llx %016llx + 0x%016llx %016llx)\n",
+ d1.hi, d1.lo, d2.hi, d2.lo);
+ exit(-1);
+ }
+ c.hi = 0;
+ c.lo = d1.lo - d2.lo;
+ DPUSH(c);
#else
DPUSH(d1 - d2);
#endif
@@ -514,8 +540,15 @@
const cell u2 = POP();
const cell u1 = POP();
#ifdef NEED_FAKE_INT128_T
- fprintf(stderr, "mmult called\n");
- exit(-1);
+ ducell c;
+
+ if (0) { // XXX How to detect overflow?
+ fprintf(stderr, "mmult called (%016llx * 0x%016llx)\n", u1, u2);
+ exit(-1);
+ }
+ c.hi = 0;
+ c.lo = u1 * u2;
+ DPUSH(c);
#else
DPUSH((dcell) u1 * u2);
#endif
@@ -531,8 +564,15 @@
const ucell u2 = POP();
const ucell u1 = POP();
#ifdef NEED_FAKE_INT128_T
- fprintf(stderr, "ummult called\n");
- exit(-1);
+ ducell c;
+
+ if (0) { // XXX How to detect overflow?
+ fprintf(stderr, "ummult called (%016llx * 0x%016llx)\n", u1, u2);
+ exit(-1);
+ }
+ c.hi = 0;
+ c.lo = u1 * u2;
+ DPUSH(c);
#else
DPUSH((ducell) u1 * u2);
#endif
More information about the OpenBIOS
mailing list