1import sys
2from typing import Final, Optional
3
4Path = str
5Handle = int
6Address = int
7
8RTLD_LAZY: Final[int] = ...
9RTLD_NOW: Final[int] = ...
10RTLD_GLOBAL: Final[int] = ...
11RTLD_LOCAL: Final[int] = ...
12
13RTLD_NOLOAD: Final[int] = ...
14RTLD_NODELETE: Final[int] = ...
15if sys.platform == 'linux':
16    RTLD_DEEPBIND: Final[int] = ...
17if sys.platform == 'darwin':
18    RTLD_FIRST: Final[int] = ...
19
20RTLD_DEFAULT: Final[Handle] = ...
21RTLD_NEXT: Final[Handle] = ...
22if sys.platform == 'darwin':
23    RTLD_SELF: Final[Handle] = ...
24    RTLD_MAIN_ONLY: Final[Handle] = ...
25
26def dlopen(filename: Optional[Path], mode: int) -> Handle: ...
27def dlclose(handle: Optional[Handle]) -> int: ...
28def dlsym(handle: Optional[Handle], symbol: str) -> Address: ...
29def dlerror() -> Optional[str]: ...
30