mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-12 15:50:39 +02:00
Change libc statx function to weakexternal
Test if statx is nil before call
This commit is contained in:
parent
3f25438d35
commit
be1cc68a99
rtl
@ -542,7 +542,7 @@ Type
|
||||
end;
|
||||
pstatx = ^tstatx;
|
||||
|
||||
function statx(dfd: cint; filename: pchar; flags,mask: cuint; var buf: tstatx):cint; {$ifdef FPC_USE_LIBC} cdecl; external name 'statx'; {$ENDIF}
|
||||
function statx(dfd: cint; filename: pchar; flags,mask: cuint; var buf: tstatx):cint; {$ifdef FPC_USE_LIBC} cdecl; weakexternal name 'statx'; {$ENDIF}
|
||||
|
||||
Type
|
||||
kernel_time64_t = clonglong;
|
||||
|
@ -580,7 +580,8 @@ begin
|
||||
|
||||
{$ifdef USE_STATX}
|
||||
{ first try statx }
|
||||
if (statx(AT_FDCWD,pchar(SystemFileName),0,STATX_MTIME or STATX_MODE,Infox)>=0) and not(fpS_ISDIR(Infox.stx_mode)) then
|
||||
if {$ifdef FPC_USE_LIBC} (@statx<>nil) and {$endif}
|
||||
(statx(AT_FDCWD,pchar(SystemFileName),0,STATX_MTIME or STATX_MODE,Infox)>=0) and not(fpS_ISDIR(Infox.stx_mode)) then
|
||||
begin
|
||||
Result:=Infox.stx_mtime.tv_sec;
|
||||
exit;
|
||||
@ -612,7 +613,8 @@ begin
|
||||
flags:=0;
|
||||
if Not FollowLink then
|
||||
Flags:=AT_SYMLINK_NOFOLLOW;
|
||||
if (statx(AT_FDCWD,PAnsiChar(FN),FLags,STATXMASK, stx)>=0) then
|
||||
if {$ifdef FPC_USE_LIBC} (@statx<>nil) and {$endif}
|
||||
(statx(AT_FDCWD,PAnsiChar(FN),FLags,STATXMASK, stx)>=0) then
|
||||
begin
|
||||
DateTime.Data:=stx;
|
||||
Exit(True);
|
||||
@ -980,10 +982,17 @@ Var
|
||||
WinAttr : longint;
|
||||
begin
|
||||
{$ifdef USE_STATX}
|
||||
{$ifdef FPC_USE_LIBC}
|
||||
if (@statx=nil) then
|
||||
FindGetFileInfo:=false
|
||||
else
|
||||
{$endif}
|
||||
if Assigned(f.FindHandle) and ( (PUnixFindData(F.FindHandle)^.searchattr and faSymlink) > 0) then
|
||||
FindGetFileInfo:=statx(AT_FDCWD,pointer(s),AT_SYMLINK_NOFOLLOW,STATX_ALL,stx)=0
|
||||
else
|
||||
FindGetFileInfo:=statx(AT_FDCWD,pointer(s),0,STATX_ALL,stx)=0;
|
||||
begin
|
||||
FindGetFileInfo:=statx(AT_FDCWD,pointer(s),0,STATX_ALL,stx)=0;
|
||||
end;
|
||||
if FindGetFileInfo then
|
||||
begin
|
||||
WinAttr:=LinuxToWinAttr(s,stx);
|
||||
@ -1133,7 +1142,8 @@ begin
|
||||
Result:=-1;
|
||||
{$ifdef USE_STATX}
|
||||
Char0:=#0;
|
||||
if statx(Handle,@Char0,AT_EMPTY_PATH,STATX_MTIME,Infox)=0 then
|
||||
if {$ifdef FPC_USE_LIBC} (@statx<>nil) and {$endif}
|
||||
(statx(Handle,@Char0,AT_EMPTY_PATH,STATX_MTIME,Infox)=0) then
|
||||
Result:=Infox.stx_Mtime.tv_sec
|
||||
else if fpgeterrno=ESysENOSYS then
|
||||
{$endif USE_STATX}
|
||||
|
Loading…
Reference in New Issue
Block a user