mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-12 22:39:36 +02:00
Change libc statx function to weakexternal
Test if statx is nil before call
(cherry picked from commit be1cc68a99
)
This commit is contained in:
parent
61059435dd
commit
3b45e9c5bb
@ -538,7 +538,7 @@ Type
|
|||||||
end;
|
end;
|
||||||
pstatx = ^tstatx;
|
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
|
Type
|
||||||
kernel_time64_t = clonglong;
|
kernel_time64_t = clonglong;
|
||||||
|
@ -580,7 +580,8 @@ begin
|
|||||||
|
|
||||||
{$ifdef USE_STATX}
|
{$ifdef USE_STATX}
|
||||||
{ first try 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
|
begin
|
||||||
Result:=Infox.stx_mtime.tv_sec;
|
Result:=Infox.stx_mtime.tv_sec;
|
||||||
exit;
|
exit;
|
||||||
@ -612,7 +613,8 @@ begin
|
|||||||
flags:=0;
|
flags:=0;
|
||||||
if Not FollowLink then
|
if Not FollowLink then
|
||||||
Flags:=AT_SYMLINK_NOFOLLOW;
|
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
|
begin
|
||||||
DateTime.Data:=stx;
|
DateTime.Data:=stx;
|
||||||
Exit(True);
|
Exit(True);
|
||||||
@ -980,10 +982,17 @@ Var
|
|||||||
WinAttr : longint;
|
WinAttr : longint;
|
||||||
begin
|
begin
|
||||||
{$ifdef USE_STATX}
|
{$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
|
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
|
FindGetFileInfo:=statx(AT_FDCWD,pointer(s),AT_SYMLINK_NOFOLLOW,STATX_ALL,stx)=0
|
||||||
else
|
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
|
if FindGetFileInfo then
|
||||||
begin
|
begin
|
||||||
WinAttr:=LinuxToWinAttr(s,stx);
|
WinAttr:=LinuxToWinAttr(s,stx);
|
||||||
@ -1133,7 +1142,8 @@ begin
|
|||||||
Result:=-1;
|
Result:=-1;
|
||||||
{$ifdef USE_STATX}
|
{$ifdef USE_STATX}
|
||||||
Char0:=#0;
|
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
|
Result:=Infox.stx_Mtime.tv_sec
|
||||||
else if fpgeterrno=ESysENOSYS then
|
else if fpgeterrno=ESysENOSYS then
|
||||||
{$endif USE_STATX}
|
{$endif USE_STATX}
|
||||||
|
Loading…
Reference in New Issue
Block a user