65c332bd36
git-svn-id: svn://kolibrios.org@7983 a494cfbc-eb01-0410-851d-a64ba20cac60
65 lines
1.1 KiB
Plaintext
65 lines
1.1 KiB
Plaintext
(*
|
|
BSD 2-Clause License
|
|
|
|
Copyright (c) 2019, Anton Krotov
|
|
All rights reserved.
|
|
*)
|
|
|
|
MODULE Libdl;
|
|
|
|
IMPORT SYSTEM, API;
|
|
|
|
|
|
CONST
|
|
|
|
LAZY* = 1;
|
|
NOW* = 2;
|
|
BINDING_MASK* = 3;
|
|
NOLOAD* = 4;
|
|
LOCAL* = 0;
|
|
GLOBAL* = 256;
|
|
NODELETE* = 4096;
|
|
|
|
|
|
VAR
|
|
|
|
_close: PROCEDURE [linux] (handle: INTEGER): INTEGER;
|
|
_error: PROCEDURE [linux] (): INTEGER;
|
|
|
|
|
|
PROCEDURE open* (file: ARRAY OF CHAR; mode: INTEGER): INTEGER;
|
|
RETURN API.dlopen(SYSTEM.ADR(file[0]), mode)
|
|
END open;
|
|
|
|
|
|
PROCEDURE sym* (handle: INTEGER; name: ARRAY OF CHAR): INTEGER;
|
|
RETURN API.dlsym(handle, SYSTEM.ADR(name[0]))
|
|
END sym;
|
|
|
|
|
|
PROCEDURE close* (handle: INTEGER): INTEGER;
|
|
RETURN _close(handle)
|
|
END close;
|
|
|
|
|
|
PROCEDURE error* (): INTEGER;
|
|
RETURN _error()
|
|
END error;
|
|
|
|
|
|
PROCEDURE init;
|
|
VAR
|
|
lib: INTEGER;
|
|
|
|
BEGIN
|
|
lib := open("libdl.so.2", LAZY);
|
|
SYSTEM.PUT(SYSTEM.ADR(_close), sym(lib, "dlclose"));
|
|
ASSERT(_close # NIL);
|
|
SYSTEM.PUT(SYSTEM.ADR(_error), sym(lib, "dlerror"));
|
|
ASSERT(_error # NIL)
|
|
END init;
|
|
|
|
|
|
BEGIN
|
|
init
|
|
END Libdl. |