Re: [fpc-pascal] Currency and Int64 casting

2018-05-18 Thread Vojtěch Čihák

Hi,
 
I have
unit1.pas:36                              i:=Int64(c);
0046EEE0 488b45e8                 mov    -0x18(%rbp),%rax
0046EEE4 488945e0                 mov    %rax,-0x20(%rbp)
unit1.pas:38                              writeln(i);
at Level0 andunit1.pas:36                              
i:=Int64(c);0046EECD 4c8b2424                 mov    
(%rsp),%r12unit1.pas:38                              writeln(i);at Level3.I 
just noticed that you wrote you are expecting 1000. You should expect 1 
since currency has four decimals.V.  
__

Od: LacaK 
Komu: fpc-pascal@lists.freepascal.org
Datum: 18.05.2018 07:54
Předmět: Re: [fpc-pascal] Currency and Int64 casting



 
Linux 64-bit Lazarus 1.9.0 r57948M FPC 3.1.1 x86_64-linux-qt gives
 
 1.00E+00 1
What is dissassembly for:
  i:=Int64(c);?

I have for Win32:
test_curr_int64.lpr:19    i1 := Int64(c);
0040158D a100c04200   mov    0x42c000,%eax
00401592 a310c04200   mov    %eax,0x42c010
00401597 a104c04200   mov    0x42c004,%eax
0040159C a314c04200   mov    %eax,0x42c014

and for Win64:
test_curr_int64.lpr:19    i1 := Int64(c);
000115BD 488b0d3caa0300   mov    0x3aa3c(%rip),%rcx    # 
0x10003c000
000115C4 48b84b598638d6c56d34 movabs $0x346dc5d63886594b,%rax
000115CE 48f7e9   imul   %rcx
000115D1 48c1fa0b sar    $0xb,%rdx
000115D5 48c1e93f shr    $0x3f,%rcx
000115D9 4801ca   add    %rcx,%rdx
000115DC 4889152daa0300   mov    %rdx,0x3aa2d(%rip)    # 
0x10003c010


L.
__
> Od: LacaK  
> Komu: FPC-Pascal users discussions  

> Datum: 17.05.2018 13:33
> Předmět: [fpc-pascal] Currency and Int64 casting
>
Hi,

consider following program:

var
  c: currency;

begin
  c := 1;
  writeln(c,' ',Int64(c));
  readln;
end.

FPC 3.0.4
On Win32/x86 I get: 1, 1000  (what I am expecting)
On Win64/x86_64 I get: 1, 1

Is is as expected ?

Is there safe way for both platforms how to get 1000 (beside that I can 
use: i: int64 absolute c;)


Thanks

-Laco.

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org 

http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal  


___fpc-pascal maillist  -  
fpc-pascal@lists.freepascal.org 
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
 


--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal 

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Currency and Int64 casting

2018-05-18 Thread LacaK

Than you,



I have

unit1.pas:36 i:=Int64(c);

0046EEE0 488b45e8 mov-0x18(%rbp),%rax

0046EEE4 488945e0 mov%rax,-0x20(%rbp)

unit1.pas:38 writeln(i);

at Level0 and
unit1.pas:36  i:=Int64(c);
0046EECD 4c8b2424 mov (%rsp),%r12
unit1.pas:38  writeln(i);
at Level3.
So we can clearly say, that x64_86 output is different on Linux and 
Windows64
It is at least strange from my POV because I would expect consistent 
results across platforms.


I just noticed that you wrote you are expecting 1000. You should 
expect 1 since currency has four decimals.

Yes, it was typo. Of course I expect 1

L.


V.

__
> Od: LacaK 
> Komu: fpc-pascal@lists.freepascal.org
> Datum: 18.05.2018 07:54
> Předmět: Re: [fpc-pascal] Currency and Int64 casting
>


Linux 64-bit Lazarus 1.9.0 r57948M FPC 3.1.1 x86_64-linux-qt gives

 1.00E+00 1

What is dissassembly for:
  i:=Int64(c);?

I have for Win32:
test_curr_int64.lpr:19i1 := Int64(c);
0040158D a100c04200   mov0x42c000,%eax
00401592 a310c04200   mov%eax,0x42c010
00401597 a104c04200   mov0x42c004,%eax
0040159C a314c04200   mov%eax,0x42c014

and for Win64:
test_curr_int64.lpr:19i1 := Int64(c);
000115BD 488b0d3caa0300   mov 
0x3aa3c(%rip),%rcx# 0x10003c000

000115C4 48b84b598638d6c56d34 movabs $0x346dc5d63886594b,%rax
000115CE 48f7e9   imul   %rcx
000115D1 48c1fa0b sar$0xb,%rdx
000115D5 48c1e93f shr$0x3f,%rcx
000115D9 4801ca   add%rcx,%rdx
000115DC 4889152daa0300   mov 
%rdx,0x3aa2d(%rip)# 0x10003c010



L.

__
> Od: LacaK  
> Komu: FPC-Pascal users discussions


> Datum: 17.05.2018 13:33
> Předmět: [fpc-pascal] Currency and Int64 casting
>

Hi,

consider following program:

var
  c: currency;

begin
  c := 1;
  writeln(c,' ',Int64(c));
  readln;
end.

FPC 3.0.4
On Win32/x86 I get: 1, 1000  (what I am expecting)
On Win64/x86_64 I get: 1, 1

Is is as expected ?

Is there safe way for both platforms how to get 1000 (beside that
I can
use: i: int64 absolute c;)

Thanks

-Laco.

___
fpc-pascal maillist  - fpc-pascal@lists.freepascal.org

http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -fpc-pascal@lists.freepascal.org

http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




--

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Currency and Int64 casting

2018-05-18 Thread LacaK

Moreover:

var
  c: currency;
  i1: int64;
  i2: int64 absolute c;

begin
  c := 68719476736;
  i1 := Trunc(c*1);
  writeln(c,', ',i1,', ',i2);
  readln;
end.

Win32 (as expected):  6.8719476736E+10, 68719476736, 
68719476736
Win64 (wrong)  :  6.8719476736E+10, 53550614319 
, 68719476736


L.


Than you,



I have

unit1.pas:36   i:=Int64(c);

0046EEE0 488b45e8 mov-0x18(%rbp),%rax

0046EEE4 488945e0 mov%rax,-0x20(%rbp)

unit1.pas:38   writeln(i);

at Level0 and
unit1.pas:36  i:=Int64(c);
0046EECD 4c8b2424 mov (%rsp),%r12
unit1.pas:38  writeln(i);
at Level3.
So we can clearly say, that x64_86 output is different on Linux and 
Windows64
It is at least strange from my POV because I would expect consistent 
results across platforms.


I just noticed that you wrote you are expecting 1000. You should 
expect 1 since currency has four decimals.

Yes, it was typo. Of course I expect 1

L.


V.

__
> Od: LacaK 
> Komu: fpc-pascal@lists.freepascal.org
> Datum: 18.05.2018 07:54
> Předmět: Re: [fpc-pascal] Currency and Int64 casting
>


Linux 64-bit Lazarus 1.9.0 r57948M FPC 3.1.1 x86_64-linux-qt gives

 1.00E+00 1

What is dissassembly for:
  i:=Int64(c);?

I have for Win32:
test_curr_int64.lpr:19i1 := Int64(c);
0040158D a100c04200   mov0x42c000,%eax
00401592 a310c04200   mov%eax,0x42c010
00401597 a104c04200   mov0x42c004,%eax
0040159C a314c04200   mov%eax,0x42c014

and for Win64:
test_curr_int64.lpr:19i1 := Int64(c);
000115BD 488b0d3caa0300   mov 
0x3aa3c(%rip),%rcx# 0x10003c000

000115C4 48b84b598638d6c56d34 movabs $0x346dc5d63886594b,%rax
000115CE 48f7e9   imul   %rcx
000115D1 48c1fa0b sar$0xb,%rdx
000115D5 48c1e93f shr$0x3f,%rcx
000115D9 4801ca   add%rcx,%rdx
000115DC 4889152daa0300   mov 
%rdx,0x3aa2d(%rip)# 0x10003c010



L.

__
> Od: LacaK  
> Komu: FPC-Pascal users discussions


> Datum: 17.05.2018 13:33
> Předmět: [fpc-pascal] Currency and Int64 casting
>

Hi,

consider following program:

var
  c: currency;

begin
  c := 1;
  writeln(c,' ',Int64(c));
  readln;
end.

FPC 3.0.4
On Win32/x86 I get: 1, 1000  (what I am expecting)
On Win64/x86_64 I get: 1, 1

Is is as expected ?

Is there safe way for both platforms how to get 1000 (beside that
I can
use: i: int64 absolute c;)

Thanks

-Laco.

___
fpc-pascal maillist  - fpc-pascal@lists.freepascal.org

http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -fpc-pascal@lists.freepascal.org

http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




--

___
fpc-pascal maillist  - fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal




___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Currency and Int64 casting

2018-05-18 Thread LacaK



Moreover:

var
  c: currency;
  i1: int64;
  i2: int64 absolute c;

begin
  c := 68719476736;
  i1 := Trunc(c*1);
  writeln(c,', ',i1,', ',i2);
  readln;
end.

Win32 (as expected):  6.8719476736E+10, 68719476736, 
68719476736
Win64 (wrong)  :  6.8719476736E+10, 
53550614319 , 68719476736



I have created bug report:
https://bugs.freepascal.org/view.php?id=33758


L.


___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Undocumented SetLength functionality

2018-05-18 Thread Sven Barth via fpc-pascal
Michael Van Canneyt  schrieb am Di., 15. Mai 2018,
14:29:

>
>
> On Tue, 15 May 2018, Sven Barth via fpc-pascal wrote:
>
> > Torsten Bonde Christiansen  schrieb am Di., 15. Mai
> 2018,
> > 12:03:
> >
> >> Is this a feature, bug or undocumented behaviour?
> >>
> >
> > This is a feature and absolutely by design.
> >
> >
> >> Afair, this was allowed back in Delphi7 (which is where i copied some of
> >> my old code from), but i'm not sure whether it was documented.
> >>
> >> At least the current RTL documentation on SetLength does not include
> >> other variants than the one with just a single length specifier.
> >> https://www.freepascal.org/docs-html/rtl/system/setlength.html
> >
> >
> > While it's not explicitly mentioned it's at least used in one f the
> > examples for dynamic arrays in the language guide:
> > https://freepascal.org/docs-html/current/ref/refse14.html#QQ2-38-57
> > Maybe this can indeed be clarified a bit.
>
> Indeed. Please enter a bugreport so I do not forget it.
>

Done: https://bugs.freepascal.org/view.php?id=33759

Regards,
Sven

>
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Undocumented SetLength functionality

2018-05-18 Thread Michael Van Canneyt



On Fri, 18 May 2018, Sven Barth via fpc-pascal wrote:


Michael Van Canneyt  schrieb am Di., 15. Mai 2018,
14:29:




On Tue, 15 May 2018, Sven Barth via fpc-pascal wrote:


Torsten Bonde Christiansen  schrieb am Di., 15. Mai

2018,

12:03:


Is this a feature, bug or undocumented behaviour?



This is a feature and absolutely by design.



Afair, this was allowed back in Delphi7 (which is where i copied some of
my old code from), but i'm not sure whether it was documented.

At least the current RTL documentation on SetLength does not include
other variants than the one with just a single length specifier.
https://www.freepascal.org/docs-html/rtl/system/setlength.html



While it's not explicitly mentioned it's at least used in one f the
examples for dynamic arrays in the language guide:
https://freepascal.org/docs-html/current/ref/refse14.html#QQ2-38-57
Maybe this can indeed be clarified a bit.


Indeed. Please enter a bugreport so I do not forget it.



Done: https://bugs.freepascal.org/view.php?id=33759


Thank you. With examples and all, I couldn't wish for more... :)

Michael.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] ExceptProc no longer gets Frames if DLL host uses a different memory manager

2018-05-18 Thread OBones

Hello,

I have a Win64 DLL compiled with FreePascal 2.6.0 in which I install a 
ExceptProc handler which signature is as follows:


procedure MyExceptProc(Obj: TObject; Addr: Pointer; FrameCount: LongInt; 
Frame: PPointer);


Up until recently, FrameCount was greater than zero and I could walk the 
frames just fine.
However, without recompiling the DLL, this has suddenly stopped working, 
FrameCount is now zero.


After a bit of investigation, it turns out that the host application 
that calls the DLL changed its memory allocator from TBBMalloc to 
libtcmalloc and this is that change that makes the frames disappear.
As I also have access to the sources for libtcmalloc, I looked into its 
code to see what it is doing, but I could not find anything obvious that 
would have the observed impact on my DLL.
That being said, I'm not familiar with the code that fills the 
FrameCount and Frame parameters when calling ExceptProc which is why I'm 
writing this message.
Would any of you have any suggestion as to what I should be looking for 
to explain that behavior?


Thanks in advance for your help.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

[fpc-pascal] Anyone know where Blaise Thorne is?

2018-05-18 Thread Zoë Peterson
Has anyone had any contact with Blaise Thorne in the past couple of 
months?  In mid-March he told me he would have an updated version of the 
closure branch ready in a couple of days and then went silent.  I only 
have his email address and haven't been able to get a response.


Thanks,
Zoë Peterson
Scooter Software

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal