What differences in c/c++ language in arm and x86 architectures -



What differences in c/c++ language in arm and x86 architectures -

i'm trying port code written x86 architecture arm.

https://github.com/sdlash3d

originally developed msvc/win32 , has many bugs in code, there may ub.

code working on x86 when compiled gcc, on arm has different behaviour. seems lose info in arrays , weapon switch not work. affected both server , client libraries.

application single-threaded, not synchronization problem.

char unsigned default on arm, add together -fsigned-char compiler flags, didn't solved problem. other differences there between arm , x86 c code?

i tried compile code on arm gcc , clang , there no differences, not compiler bug.

p.s compiled code x86 gcc-4.9 (instead of 4.8) , got same behaviour. after combined 2 compilers , found problem in net_encode.c.

by time, sebastien chevalier found that

ivalue /= pfield->multiplier; ivalue *= pfield->multiplier;

when ivalue integer , pfield->multiplier==1.0f changes integer values.

it can fixed adding check if pfield->multiplier != 1.0f before multiply.

almost impossible without seeing code, seek reply generally.

one huge difference between x86 , arm way x86 instructions internally atomic, arm has no such thing - have explicitly "execute set of instructions exclusively". if have info updated multiple threads, may nail you.

there differences in how individual instructions behave. without knowing code does, hard if affects code or not, 1 thing can nail "unaligned access", valid (albeit not optimal) in x86, invalid (in models) on arm processors. pointers must aligned size of item accesses.

and of course, different code generation in compilers, may take different decisions based on input code, , end code behaves differently in manner of ways. 1 has nail me more 1 time "execution order of argument function calls":

func(func1(), func2());

note func1() or func2() may execute first. if relying on such ordering, need do:

t1 = func1(); t2 = func2(); func(t1, t2);

hints:

if don't already, enable much warnings can (-wall @ least). , prepare warnings

check #pragma pack or similar "pack info structures", , casts char * int * etc, these can lead unaligned access problems.

edit: , of course, different compilers have different bugs may or may not create difference in particular compiler, processor , code combination. although rather unlikely of clang gives same problem.

c++ c x86 arm

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -