YetAnotherForum
Welcome Guest Search | Active Topics | Log In | Register

32bit vs 64bit ints and precompiled code
billbob
#1 Posted : Wednesday, July 06, 2016 1:54:20 AM(UTC)
Rank: Member

Groups: Registered
Joined: 1/19/2015(UTC)
Posts: 10

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I got the precompiled code to work correctly. The code was compiled on a 64bit system (Mac), but when it's loaded on a 32bit system (Win), it fails due to the size of SQInteger being different. Is there a "trick" or setting to remove this? Are there also going to be byte order issues? I'd like one version of the compiled scripts to work across all platforms.
fagiano
#2 Posted : Friday, July 08, 2016 3:53:44 PM(UTC)
Rank: Advanced Member

Groups: Registered, Administrators
Joined: 6/11/2005(UTC)
Posts: 1,054

Thanks: 0 times
Was thanked: 77 time(s) in 59 post(s)
Right now Squirrel's bytecode is architecture dependent. This means if you compile with a 64bits build you can only load the bytecode with a 64bit build and vice-versa. This is mostly because the 32bit builds cannot represent 64bit numbers(the same goes for 32bit float builds vs 64bit floats builds). If you have multi architecture requirements it would be trivial to customize the serialization function to make it work, however keep in mind that you'll not be able to correctly represent 64 bits numbers on a 32 bits build. Personally I recompile per platform if needed.

ciao
Alberto
Follow me on Twitter @squirrellang
billbob
#3 Posted : Friday, July 08, 2016 10:20:27 PM(UTC)
Rank: Member

Groups: Registered
Joined: 1/19/2015(UTC)
Posts: 10

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I have no need for 64bit numbers, so that is not an issue. I noticed you can just unset _SQ64 and it will use 32bit SQInteger. If I did this on the 64bit systems, would that fix the issue? Would there be a significant performance hit in doing that?
billbob
#4 Posted : Saturday, July 23, 2016 9:54:26 PM(UTC)
Rank: Member

Groups: Registered
Joined: 1/19/2015(UTC)
Posts: 10

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
I tried undefining _SQ64 on my 64bit machine (OS X) so it would use 32 bit ints and I'd have cross platform scripts, but I'm getting errors from this now...

#define hashptr(p) ((SQHash)(((SQInteger)p) >> 3))

sqtable.h:21:21: Cast from pointer to smaller type 'SQInteger' (aka 'int') loses information

I need to have precompiled squirrel bytecode that run on both 32 and 64 bit computers. I was hoping that compiling squirrel using 32 bit ints would fix my issue. Is there a better way to do what I need (common pre-compiled scripts running on 32 and 64 bit machines)?

I have also noticed that pre-compiled squirrel bytecode is not byte-order safe, so that is a bridge I might need to cross down the road. Even if I was going to compile different code for different architecture, I'd need to do it some a single machine.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Clean Slate theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.080 seconds.