28.05.2015 10:49, Marco van de Voort пишет:
In our previous episode, Edmund Grimley Evans said:
- How to do the equivalent of C longjmp in Pascal, used in
x86_64/gprt0.as, for example?
There are fpc_longjmp and fpc_setjmp symbols but they are related to
exception handling. In an emergency, simply asm jmp $x end;
It is not an emergency case. Libc expects 'main' to return and then executes finalization code.
FPC's PASCALMAIN terminates the process and does not return. So in order to get correct library
finalization (including profiling with grpof) we have to simulate a return using something like longjmp.
It's basically a dirty hack. A much cleaner solution could be to change code generation so it calls
FPC_LIB_EXIT instead of FPC_EXIT at the end of PASCALMAIN (so that _haltproc is not called and
PASCALMAIN normally returns), and call _haltproc explicitly in code of prt0.as. But whoever goes for
that will have to change and test all startup files for all targets, which is pretty time-consuming.
Regards,
Sergei
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel