Skip to main content

Building Squawk using a compiler that doesn't support 64bit types

4 replies [Last post]
markus_bruckner
Offline
Joined: 2009-06-03
Points: 0

Hello,

my goal is to build squawk for a new processor (and it's os) using the Squawk's native branch. Because of some specialties of the system, I'm forced to use the hardware vendor's compiler which, as I discovered just now, doesn't support 64bit types (long long), which yields a lot of problems when i try to compile the c code.

Is it even possible to compile (or run, for that matter) squawk with this restriction? Currently i tried to hack around by replacing long long definitions with long. however, a lot of warnings remain ("overflow in constant ..."). This doesn't seem to be the right way to do it, anyway.

Can anyone give me directions on how to proceed? Will replacing the definitions and cropping all 64bit constants do?

Thanks, Markus

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
derek_white
Offline
Joined: 2006-09-08
Points: 0

I've never worked with a compiler like that before, but I think that this may be either a slightly hard or very hard problem using that compiler.

First you need to see if the compiler supports passing and returning 64-bit structures.

Roughly somthing like:
struct jlong_t {int hi, int lo} jlong;

jlong myBadAdd(jlong a, jlongb) { return a; } // not very good addition!

If that works, then you have a somewhat hard task of:
1) making sure that the interpreter, etc, are using the proper types
2) Implementing 64 bit functions for (add, sub, mul, div, shifts, compares, etc).
3) Changing the interpreter to use your 64-bit functions instead of relying on the C operators.
4) Doing it all over again for double floating point, if needed.

Plan B is to whine until you get a better compiler :-)

Good luck!

markus_bruckner
Offline
Joined: 2009-06-03
Points: 0

Thanks to both of you for your quick response.

Derek, I was thinking of a solution like that but was also hoping there would be another way.

Your post actually helped me to stumble upon another problem: Although my compiler recognizes the type long, it's actually a 32 bit type. Same goes for double probably.

I discovered the problem because "long long" is used once in a while and this yields an error. "long long" is a 128 bit type then? I guess I have to do a jlong_long type as well, don't i?

Thanks!

PS: Sadly, whining about it will not help :(

derek_white
Offline
Joined: 2006-09-08
Points: 0

So this is a Java vs. C name thing...

In java, an "int" is always a signed 32-bit number, and a "long" is a signed 64-bit number.

In C (someone can correct me with more accurracy), all you can count on is:
sizeof(long long) >= sizeof(long) >= sizeof(int).

In common usage, C ints are [i]usually[/i] 32-bits, but can be 16-bits. Similarly "long" is usually 32 or 64 bits, and "long long" 64 bits. Especially on an 8-bit or 16-bit CPU all bets are off!

So to do a Java port you really, really need to know the default C types for your platform.
We use the "long long type" because we're trying to get a 64-bit type, and plain "long" doesn't mean the right thing on enough platforms.

eric_arseneau
Offline
Joined: 2004-07-15
Points: 0

Not sure why you are running into problems. It could be that the builder is defaulting to 64 bit for some reason.

Are you using the Builder? If so, when you added the new interface for your compiler, did you pass in the 32 flag?

I'll see if Derek can't help out. But it would be good for you to post the output from your trying to do a build.