Explorar o código

Merged revisions 1099-1104,1109,1111-1112,1118-1119,1122 via svnmerge from
/trunk

git-svn-id: branches/fixes_2_0@1133 -

peter %!s(int64=20) %!d(string=hai) anos
pai
achega
dcd3180036

+ 1 - 1
fcl/inc/pipes.pp

@@ -30,7 +30,7 @@ Type
 
   TInputPipeStream = Class(THandleStream)
     Private
-      FPos : longint;
+      FPos : Int64;
     public
       Function Write (Const Buffer; Count : Longint) :Longint; Override;
       Function Seek (Offset : Longint;Origin : Word) : longint;override;

+ 8 - 4
packages/base/libc/sigactionh.inc

@@ -2,10 +2,14 @@
 type
    P_sigaction = ^_sigaction;
    _sigaction = record // Renamed, avoid conflict with sigaction function
-     sa_handler : __sighandler_t;
-     sa_mask : __sigset_t;
-     sa_flags : longint;
-     sa_restorer : procedure ;cdecl;
+     case integer of
+       1: (sa_handler : __sighandler_t;
+           sa_mask : __sigset_t;
+           sa_flags : longint;
+           sa_restorer : procedure ;cdecl;
+          );
+       // Kylix compatibility
+       2: (__sigaction_handler: __sighandler_t);
    end;
 
 const

+ 83 - 0
rtl/inc/genmath.inc

@@ -1175,3 +1175,86 @@ function fpc_int64_to_double(i : int64): double; compilerproc;
 {$endif FPC_SYSTEM_HAS_REAL2DOUBLE}
 {$endif SUPPORT_DOUBLE}
 
+{$ifdef SUPPORT_EXTENDED}
+{ fast 10^n routine }
+function FPower10(val: Extended; Power: Longint): Extended;
+  const
+    pow32 : array[0..31] of extended =
+      (
+        1e0,1e1,1e2,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,
+        1e11,1e12,1e13,1e14,1e15,1e16,1e17,1e18,1e19,1e20,
+        1e21,1e22,1e23,1e24,1e25,1e26,1e27,1e28,1e29,1e30,
+        1e31
+      );
+    pow512 : array[0..15] of extended =
+      (
+        1,1e32,1e64,1e96,1e128,1e160,1e192,1e224,
+        1e256,1e288,1e320,1e352,1e384,1e416,1e448,
+        1e480
+      );
+    pow4096 : array[0..9] of extended =
+      (1,1e512,1e1024,1e1536,
+       1e2048,1e2560,1e3072,1e3584,
+       1e4096,1e4608
+      );
+
+    negpow32 : array[0..31] of extended =
+      (
+        1e-0,1e-1,1e-2,1e-3,1e-4,1e-5,1e-6,1e-7,1e-8,1e-9,1e-10,
+        1e-11,1e-12,1e-13,1e-14,1e-15,1e-16,1e-17,1e-18,1e-19,1e-20,
+        1e-21,1e-22,1e-23,1e-24,1e-25,1e-26,1e-27,1e-28,1e-29,1e-30,
+        1e-31
+      );
+    negpow512 : array[0..15] of extended =
+      (
+        0,1e-32,1e-64,1e-96,1e-128,1e-160,1e-192,1e-224,
+        1e-256,1e-288,1e-320,1e-352,1e-384,1e-416,1e-448,
+        1e-480
+      );
+    negpow4096 : array[0..9] of extended =
+      (
+        0,1e-512,1e-1024,1e-1536,
+        1e-2048,1e-2560,1e-3072,1e-3584,
+        1e-4096,1e-4608
+      );
+
+  begin
+    if Power<0 then
+      begin
+        Power:=-Power;
+        result:=val*negpow32[Power and $1f];
+        power:=power shr 5;
+        if power<>0 then
+          begin
+            result:=result*negpow512[Power and $f];
+            power:=power shr 4;
+            if power<>0 then
+              begin
+                if power<=9 then
+                  result:=result*negpow4096[Power]
+                else
+                  result:=1.0/0.0;
+              end;
+          end;
+      end
+    else
+      begin
+        result:=val*pow32[Power and $1f];
+        power:=power shr 5;
+        if power<>0 then
+          begin
+            result:=result*pow512[Power and $f];
+            power:=power shr 4;
+            if power<>0 then
+              begin
+                if power<=9 then
+                  result:=result*pow4096[Power]
+                else
+                  result:=1.0/0.0;
+              end;
+          end;
+      end;     
+  end;
+{$endif SUPPORT_EXTENDED}
+
+

+ 3 - 0
rtl/inc/mathh.inc

@@ -65,6 +65,9 @@
     function round(c : comp) : int64;
 {$endif FPC_CURRENCY_IS_INT64}
 
+{$ifdef SUPPORT_EXTENDED}
+    function FPower10(val: Extended; Power: Longint): Extended;
+{$endif SUPPORT_EXTENDED}
 
     type
        real48 = array[0..5] of byte;

+ 2 - 0
rtl/objpas/sysutils/filutilh.inc

@@ -23,6 +23,7 @@ Type
 {$ifdef unix}
     FindHandle : Pointer;
     Mode : TMode;
+    PathOnly : AnsiString;
 {$else unix}
     FindHandle : THandle;
 {$endif unix}
@@ -48,6 +49,7 @@ Const
   faVolumeId  = $00000008;
   faDirectory = $00000010;
   faArchive   = $00000020;
+  faSymLink   = $00000040;
   faAnyFile   = $0000003f;
 
   { File open modes }

+ 2 - 0
rtl/objpas/sysutils/sysinth.inc

@@ -127,6 +127,8 @@ Const
   { Currency notation. Default is $ for dollars. }
   CurrencyString : String[7] = '$';
 
+  ListSeparator: Char = ',';
+
 type
   TSysLocale = record
     { Delphi compat fields}

+ 5 - 0
rtl/objpas/sysutils/sysstr.inc

@@ -1144,6 +1144,11 @@ Begin
   End;
 End;
 
+Function CurrToStrF(Value: Currency; Format: TFloatFormat; Digits: Integer): string;
+  begin
+    result:=FloatToStrF(Value,Format,19,Digits);
+  end;
+
 Function FloatToDateTime (Const Value : Extended) : TDateTime;
 begin
   If (Value<MinDateTime) or (Value>MaxDateTime) then

+ 1 - 0
rtl/objpas/sysutils/sysstrh.inc

@@ -114,6 +114,7 @@ Function StrFmt(Buffer,Fmt : PChar; Const args: Array of const) : Pchar;
 Function StrLFmt(Buffer : PCHar; Maxlen : Cardinal;Fmt : PChar; Const args: Array of const) : Pchar;
 Procedure FmtStr(Var Res: String; Const Fmt : String; Const args: Array of const);
 Function FloatToStrF(Value: Extended; format: TFloatFormat; Precision, Digits: Integer): String;
+Function CurrToStrF(Value: Currency; Format: TFloatFormat; Digits: Integer): string;
 Function FloatToStr(Value: Extended): String;
 Function StrToFloat(Const S : String) : Extended;
 Function StrToFloatDef(Const S: String; Const Default: Extended): Extended;

+ 3 - 0
rtl/unix/dl.pp

@@ -21,6 +21,9 @@ Function dlopen(Name : PChar; Flags : longint) : Pointer; cdecl; external libdl;
 FUnction dlsym(Lib : Pointer; Name : Pchar) : Pointer; cdecl; external Libdl;
 Function dlclose(Lib : Pointer) : Longint; cdecl; external libdl;
 Function dlerror() : Pchar; cdecl; external libdl;
+{ overloaded for compatibility with hmodule }
+FUnction dlsym(Lib : PtrInt; Name : Pchar) : Pointer; cdecl; external Libdl;
+Function dlclose(Lib : PtrInt) : Longint; cdecl; external libdl;
 
 implementation
 

+ 4 - 3
rtl/unix/dynlibs.inc

@@ -20,10 +20,11 @@
   ---------------------------------------------------------------------}
 
 Type
-  TLibHandle = Pointer;
+  { using PtrInt here is compliant with the other platforms }
+  TLibHandle = PtrInt;
 
 Const
-  NilHandle = Nil;
+  NilHandle : TLibHandle = 0;
 
 {$else}
 
@@ -36,7 +37,7 @@ uses dl;
 Function LoadLibrary(Name : AnsiString) : TLibHandle;
 
 begin
-  Result:=dlopen(Pchar(Name),RTLD_LAZY);
+  Result:=TLibHandle(dlopen(Pchar(Name),RTLD_LAZY));
 end;
 
 Function GetProcedureAddress(Lib : TLibHandle; ProcName : AnsiString) : Pointer;

+ 41 - 0
rtl/unix/sysutils.pp

@@ -36,12 +36,50 @@ uses
 
 Procedure AddDisk(const path:string);
 
+{ the following is Kylix compatibility stuff, it should be moved to a
+  special compatibilty unit (FK) }
+  const
+    RTL_SIGINT     = 0;
+    RTL_SIGFPE     = 1;
+    RTL_SIGSEGV    = 2;
+    RTL_SIGILL     = 3;
+    RTL_SIGBUS     = 4;
+    RTL_SIGQUIT    = 5;
+    RTL_SIGLAST    = RTL_SIGQUIT;
+    RTL_SIGDEFAULT = -1;
+
+  type
+    TSignalState = (ssNotHooked, ssHooked, ssOverridden);
+
+function InquireSignal(RtlSigNum: Integer): TSignalState;
+procedure AbandonSignalHandler(RtlSigNum: Integer);
+procedure HookSignal(RtlSigNum: Integer);
+procedure UnhookSignal(RtlSigNum: Integer; OnlyIfHooked: Boolean = True);
 
 implementation
 
 Uses
   {$ifdef FPC_USE_LIBC}initc{$ELSE}Syscall{$ENDIF}, Baseunix, unixutil;
 
+function InquireSignal(RtlSigNum: Integer): TSignalState;
+  begin
+  end;
+
+
+procedure AbandonSignalHandler(RtlSigNum: Integer);
+  begin
+  end;
+
+
+procedure HookSignal(RtlSigNum: Integer);
+  begin
+  end;
+
+
+procedure UnhookSignal(RtlSigNum: Integer; OnlyIfHooked: Boolean = True);
+  begin
+  end;
+
 {$Define OS_FILEISREADONLY} // Specific implementation for Unix.
 
 Function getenv(name:shortstring):Pchar; external name 'FPC_SYSC_FPGETENV';
@@ -280,6 +318,8 @@ begin
      Result:=Result or faReadOnly;
   If fpS_ISSOCK(Info.st_mode) or fpS_ISBLK(Info.st_mode) or fpS_ISCHR(Info.st_mode) or fpS_ISFIFO(Info.st_mode) Then
      Result:=Result or faSysFile;
+  If fpS_ISLNK(Info.st_mode) Then
+    Result:=Result or faSymLink;
 end;
 
 type
@@ -520,6 +560,7 @@ begin
     begin
     GlobSearchRec^.GlobHandle:=P^.Next;
     Result:=Fpstat(GlobSearchRec^.Path+StrPas(p^.name),SInfo)>=0;
+    Info.PathOnly:=GlobSearchRec^.Path;
     If Result then
       begin
       Info.Attr:=LinuxToWinAttr(p^.name,SInfo);