| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
SDL3.Sys.Loadso
Contents
Description
System-dependent library loading routines.
Shared objects are code that is programmatically loadable at runtime. Windows calls these "DLLs", Linux calls them "shared libraries", etc.
To use them, build such a library, then call on it. Once loaded, you can use loadObject on that object to find the address of its exported symbols. When done with the object, call loadFunction to dispose of it.unloadObject
Some things to keep in mind:
- These functions only work on C function names. Other languages may have name mangling and intrinsic language support that varies from compiler to compiler.
- Make sure you declare your function pointers with the same calling convention as the actual library function. Your code will crash mysteriously if you do not do this.
- Avoid namespace collisions. If you load a symbol from the library, it is not defined whether or not it goes into the global symbol namespace for the application. If it does and it conflicts with symbols in your code or other shared libraries, you will not get the results you expect. :)
- Once a library is unloaded, all pointers into it obtained through
become invalid, even if the library is later reloaded. Don't unload a library if you plan to use these pointers in the future. Notably: beware of giving one of these pointers to atexit(), since it may call that pointer after the library unloads. An opaque datatype that represents a loaded shared object.loadFunction
- See also
loadObject,loadFunction,unloadObject
FFI conventions
Unsuffixed aliases are unsafe foreign imports; aliases suffixed Safe are safe. Functions whose callbacks fire during the call export only the Safe alias (the genuine unsafe import stays reachable under SDL3.Sys.Bindgen.Loadso.Unsafe); functions curated unsafe-only export only the unsuffixed one. Each alias's documentation records its flavor and rationale.
Full conventions: SDL3.Sys.
Since: 3.2.0
Synopsis
- module SDL3.Sys.Bindgen.Loadso
- loadObject :: PtrConst CChar -> IO (Ptr SDL_SharedObject)
- loadObjectSafe :: PtrConst CChar -> IO (Ptr SDL_SharedObject)
- loadFunction :: Ptr SDL_SharedObject -> PtrConst CChar -> IO SDL_FunctionPointer
- loadFunctionSafe :: Ptr SDL_SharedObject -> PtrConst CChar -> IO SDL_FunctionPointer
- unloadObject :: Ptr SDL_SharedObject -> IO ()
- unloadObjectSafe :: Ptr SDL_SharedObject -> IO ()
Documentation
module SDL3.Sys.Bindgen.Loadso
Function aliases
Arguments
| :: PtrConst CChar |
|
| -> IO (Ptr SDL_SharedObject) |
Dynamically load a shared object.
- Returns
- an opaque pointer to the object handle or NULL on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
loadFunction,unloadObject
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_LoadObject. The safe flavor isloadObjectSafe. - C declaration
SDL_LoadObject, defined atSDL3/SDL_loadso.h 93:48
Since: 3.2.0
Arguments
| :: PtrConst CChar |
|
| -> IO (Ptr SDL_SharedObject) |
Dynamically load a shared object.
- Returns
- an opaque pointer to the object handle or NULL on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
loadFunction,unloadObject
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_LoadObject. The unsafe flavor isloadObject. - C declaration
SDL_LoadObject, defined atSDL3/SDL_loadso.h 93:48
Since: 3.2.0
Arguments
| :: Ptr SDL_SharedObject |
|
| -> PtrConst CChar |
|
| -> IO SDL_FunctionPointer |
Look up the address of the named function in a shared object.
This function pointer is no longer valid after calling .unloadObject
This function can only look up C function names. Other languages may have name mangling and intrinsic language support that varies from compiler to compiler.
Make sure you declare your function pointers with the same calling convention as the actual library function. Your code will crash mysteriously if you do not do this.
If the requested function doesn't exist, NULL is returned.
- Returns
- a pointer to the function or NULL on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
loadObject
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_LoadFunction. The safe flavor isloadFunctionSafe. - C declaration
SDL_LoadFunction, defined atSDL3/SDL_loadso.h 121:49
Since: 3.2.0
Arguments
| :: Ptr SDL_SharedObject |
|
| -> PtrConst CChar |
|
| -> IO SDL_FunctionPointer |
Look up the address of the named function in a shared object.
This function pointer is no longer valid after calling .unloadObject
This function can only look up C function names. Other languages may have name mangling and intrinsic language support that varies from compiler to compiler.
Make sure you declare your function pointers with the same calling convention as the actual library function. Your code will crash mysteriously if you do not do this.
If the requested function doesn't exist, NULL is returned.
- Returns
- a pointer to the function or NULL on failure; call
getErrorfor more information. - Thread safety
- It is safe to call this function from any thread.
- See also
loadObject
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_LoadFunction. The unsafe flavor isloadFunction. - C declaration
SDL_LoadFunction, defined atSDL3/SDL_loadso.h 121:49
Since: 3.2.0
Arguments
| :: Ptr SDL_SharedObject |
|
| -> IO () |
Unload a shared object from memory.
Note that any pointers from this object looked up through will no longer be valid.loadFunction
- Thread safety
- It is safe to call this function from any thread.
- See also
loadObject
sdl3-bindgen-sys notes
- FFI safety
- Unsafe foreign import of
SDL_UnloadObject. The safe flavor isunloadObjectSafe. - C declaration
SDL_UnloadObject, defined atSDL3/SDL_loadso.h 137:34
Since: 3.2.0
Arguments
| :: Ptr SDL_SharedObject |
|
| -> IO () |
Unload a shared object from memory.
Note that any pointers from this object looked up through will no longer be valid.loadFunction
- Thread safety
- It is safe to call this function from any thread.
- See also
loadObject
sdl3-bindgen-sys notes
- FFI safety
- Safe foreign import of
SDL_UnloadObject. The unsafe flavor isunloadObject. - C declaration
SDL_UnloadObject, defined atSDL3/SDL_loadso.h 137:34
Since: 3.2.0