mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 04:39:38 +02:00
63 lines
1.5 KiB
PHP
63 lines
1.5 KiB
PHP
{
|
|
This file is part of the Free Pascal run time library.
|
|
Copyright (c) 1999-2004 by the Free Pascal development team
|
|
|
|
Implement OS-dependent part of dynamic library loading.
|
|
|
|
See the file COPYING.FPC, included in this distribution,
|
|
for details about the copyright.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
**********************************************************************}
|
|
|
|
uses libc;
|
|
|
|
Function SysLoadLibraryA(const Name : RawByteString) : TLibHandle;
|
|
|
|
begin
|
|
Result:=dlopen(PAnsiChar(Name),RTLD_LAZY);
|
|
end;
|
|
|
|
Function SysLoadLibraryU(const Name: UnicodeString) : TLibHandle;
|
|
|
|
begin
|
|
Result:=SysLoadLibraryA(ToSingleByteFileSystemEncodedFileName(Name));
|
|
end;
|
|
|
|
Function SysGetProcedureAddress(Lib : TLibHandle; const ProcName : AnsiString) : Pointer;
|
|
|
|
begin
|
|
Result:=dlsym(lib,PAnsiChar(ProcName));
|
|
end;
|
|
|
|
Function SysUnloadLibrary(Lib : TLibHandle) : Boolean;
|
|
|
|
begin
|
|
Result:=dlClose(Lib)=0;
|
|
end;
|
|
|
|
Function SysGetLoadErrorStr: AnsiString;
|
|
|
|
begin
|
|
Result:='';
|
|
end;
|
|
|
|
const
|
|
SysDynLibsManager: TDynLibsManager = (
|
|
LoadLibraryU: @SysLoadLibraryU;
|
|
LoadLibraryA: @SysLoadLibraryA;
|
|
GetProcAddress: @SysGetProcedureAddress;
|
|
GetProcAddressOrdinal: Nil;
|
|
UnloadLibrary: @SysUnloadLibrary;
|
|
GetLoadErrorStr: @SysGetLoadErrorStr;
|
|
);
|
|
|
|
procedure InitDynLibs;
|
|
begin
|
|
SetDynLibsManager(SysDynLibsManager);
|
|
end;
|
|
|