Sfoglia il codice sorgente

* Make clongdouble:
- 8 bytes on windows
- For other platforms: 12 bytes on 32-bit and 16 bytes on 64-bit cpus.
... using a record with assignment overloads.

git-svn-id: trunk@8112 -

daniel 18 anni fa
parent
commit
2fbe0038b9
1 ha cambiato i file con 34 aggiunte e 1 eliminazioni
  1. 34 1
      rtl/inc/ctypes.pp

+ 34 - 1
rtl/inc/ctypes.pp

@@ -72,7 +72,21 @@ type
 
   cfloat                 = single;             pcfloat                = ^cfloat;
   cdouble                = double;             pcdouble               = ^cdouble;
-  clongdouble            = extended;           pclongdouble           = ^clongdouble;
+
+{$ifdef windows}
+  clongdouble=double;
+{$else}
+  {$define longdouble_assignment_overload}
+  clongdouble = packed record
+    value:extended;
+  {$ifdef cpu64}
+    padding:array[0..5] of byte;
+  {$else}
+    padding:array[0..1] of byte;
+  {$endif}
+  end;
+{$endif}
+  Pclongdouble=^clongdouble;
 
 // Kylix compat types
   u_long  = culong;
@@ -80,6 +94,25 @@ type
 
 {$endif}
 
+{$ifdef longdouble_assignment_overload}
+operator := (const v:clongdouble):r:extended;
+operator := (const v:extended):r:clongdouble;
+{$endif}
+
 implementation
 
+{$ifdef longdouble_assignment_overload}
+operator := (const v:clongdouble):r:extended;inline;
+
+begin
+  r:=v.value;
+end;
+
+operator := (const v:extended):r:clongdouble;inline;
+
+begin
+  r.value:=v;
+end;
+{$endif}
+
 end.