Recent

Author Topic: __llmod() equivalent  (Read 368 times)

denis.totoliciu

  • New Member
  • *
  • Posts: 21
__llmod() equivalent
« on: July 08, 2020, 10:53:09 pm »
Hello,

There is a routine declared as procedure __llmod() in the System unit in Delphi. The comment above it says: { 64-bit Integer helper routines }.
Looked for an equivalent with the same name in FPC, but couldn't find it. Maybe there is one, but with a different name.

The interest in this particular procedure comes from the attempt to compile the JCL package with FPC 32-bit. It resulted with an error that it can't find __llmod.

Do you know of such an equivalent routine?

Thank you!

jamie

  • Hero Member
  • *****
  • Posts: 3526
Re: __llmod() equivalent
« Reply #1 on: July 08, 2020, 11:01:49 pm »
its most likely a MOD operator which Fpc supports naturally ..

Please show a couple of lines of its use so others can determine what it is.
The only true wisdom is knowing you know nothing

denis.totoliciu

  • New Member
  • *
  • Posts: 21
Re: __llmod() equivalent
« Reply #2 on: July 08, 2020, 11:07:40 pm »
Here is a sequence from zlibh.pas:
Code: Pascal  [Select][+][-]
  1. {$IFDEF CPU32}
  2. procedure __llmod; cdecl;
  3. asm
  4.   jmp System.@_llmod;
  5. end;
  6. {$ENDIF CPU32}
  7.  
  8. {$ENDIF ZLIB_STATICLINK}
  9. {$ENDIF ~ZLIB_RTL}
  10.  
It is not used in other parts of JCL.

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8729
  • FPC developer.
Re: __llmod() equivalent
« Reply #3 on: July 08, 2020, 11:07:54 pm »
Procedures starting with __ are internal, undocumented ones. They are not guaranteed to stay the same between Delphi versions either.

Maybe JCL used it because they use a lot of assembler, and such functions are easier to call in assembler, so the easiest solution is to let JCL take the pascal instead of the assembler code.

PascalDragon

  • Hero Member
  • *****
  • Posts: 2131
  • Compiler Developer
Re: __llmod() equivalent
« Reply #4 on: July 09, 2020, 09:39:33 am »
Here is a sequence from zlibh.pas:
Code: Pascal  [Select][+][-]
  1. {$IFDEF CPU32}
  2. procedure __llmod; cdecl;
  3. asm
  4.   jmp System.@_llmod;
  5. end;
  6. {$ENDIF CPU32}
  7.  
  8. {$ENDIF ZLIB_STATICLINK}
  9. {$ENDIF ~ZLIB_RTL}
  10.  
It is not used in other parts of JCL.

I think replacing it with the following should work (not tested):

Code: Pascal  [Select][+][-]
  1. {$IFDEF CPU32}
  2. {$IFNDEF FPC}
  3. procedure __llmod; cdecl;
  4. asm
  5.   jmp System.@_llmod;
  6. end;
  7. {$ELSE FPC}
  8. function __llmod(n,z: Int64): Int64; cdecl;
  9. begin
  10.   Result := n mod z;
  11. end;
  12. {$ENDIF FPC}
  13. {$ENDIF CPU32}
  14.  

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8729
  • FPC developer.
Re: __llmod() equivalent
« Reply #5 on: July 09, 2020, 10:30:07 am »
Of course this will move the problem only to the next bit, linking Delphi's zlib objs

PascalDragon

  • Hero Member
  • *****
  • Posts: 2131
  • Compiler Developer
Re: __llmod() equivalent
« Reply #6 on: July 09, 2020, 11:30:00 am »
The object files are part of JCL and are simple COFF object files. The other missing functions are fullfilled by imports from MSVCRT.

 

TinyPortal © 2005-2018