SDL
2.0
SDL_sysloadso.c
Go to the documentation of this file.
1
/*
2
Simple DirectMedia Layer
3
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
4
5
This software is provided 'as-is', without any express or implied
6
warranty. In no event will the authors be held liable for any damages
7
arising from the use of this software.
8
9
Permission is granted to anyone to use this software for any purpose,
10
including commercial applications, and to alter it and redistribute it
11
freely, subject to the following restrictions:
12
13
1. The origin of this software must not be misrepresented; you must not
14
claim that you wrote the original software. If you use this software
15
in a product, an acknowledgment in the product documentation would be
16
appreciated but is not required.
17
2. Altered source versions must be plainly marked as such, and must not be
18
misrepresented as being the original software.
19
3. This notice may not be removed or altered from any source distribution.
20
*/
21
#include "../../SDL_internal.h"
22
23
#ifdef SDL_LOADSO_DLOPEN
24
25
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
26
/* System dependent library loading routines */
27
28
#include <stdio.h>
29
#include <dlfcn.h>
30
31
#include "
SDL_loadso.h
"
32
33
#if SDL_VIDEO_DRIVER_UIKIT
34
#include "../../video/uikit/SDL_uikitvideo.h"
35
#endif
36
37
void
*
38
SDL_LoadObject
(
const
char
*sofile)
39
{
40
void
*
handle
;
41
const
char
*loaderror;
42
43
#if SDL_VIDEO_DRIVER_UIKIT
44
if
(!
UIKit_IsSystemVersionAtLeast
(8.0)) {
45
SDL_SetError
(
"SDL_LoadObject requires iOS 8+"
);
46
return
NULL
;
47
}
48
#endif
49
50
handle
= dlopen(sofile, RTLD_NOW|RTLD_LOCAL);
51
loaderror = (
char
*) dlerror();
52
if
(
handle
==
NULL
) {
53
SDL_SetError
(
"Failed loading %s: %s"
, sofile, loaderror);
54
}
55
return
(
handle
);
56
}
57
58
void
*
59
SDL_LoadFunction
(
void
*
handle
,
const
char
*
name
)
60
{
61
void
*symbol = dlsym(
handle
,
name
);
62
if
(symbol ==
NULL
) {
63
/* append an underscore for platforms that need that. */
64
SDL_bool
isstack;
65
size_t
len
= 1 +
SDL_strlen
(
name
) + 1;
66
char
*_name =
SDL_small_alloc
(
char
,
len
, &isstack);
67
_name[0] =
'_'
;
68
SDL_strlcpy
(&_name[1],
name
,
len
);
69
symbol = dlsym(
handle
, _name);
70
SDL_small_free
(_name, isstack);
71
if
(symbol ==
NULL
) {
72
SDL_SetError
(
"Failed loading %s: %s"
,
name
,
73
(
const
char
*) dlerror());
74
}
75
}
76
return
(symbol);
77
}
78
79
void
80
SDL_UnloadObject
(
void
*
handle
)
81
{
82
if
(
handle
!=
NULL
) {
83
dlclose(
handle
);
84
}
85
}
86
87
#endif
/* SDL_LOADSO_DLOPEN */
88
89
/* vi: set ts=4 sw=4 expandtab: */
SDL_strlcpy
#define SDL_strlcpy
Definition:
SDL_dynapi_overrides.h:394
SDL_small_free
#define SDL_small_free(ptr, isstack)
Definition:
SDL_internal.h:40
NULL
#define NULL
Definition:
begin_code.h:167
handle
EGLImageKHR EGLint EGLint * handle
Definition:
eglext.h:937
SDL_UnloadObject
#define SDL_UnloadObject
Definition:
SDL_dynapi_overrides.h:234
SDL_small_alloc
#define SDL_small_alloc(type, count, pisstack)
Definition:
SDL_internal.h:39
SDL_LoadObject
#define SDL_LoadObject
Definition:
SDL_dynapi_overrides.h:232
len
GLenum GLsizei len
Definition:
SDL_opengl_glext.h:2926
name
GLuint const GLchar * name
Definition:
SDL_opengl_glext.h:660
UIKit_IsSystemVersionAtLeast
SDL_bool UIKit_IsSystemVersionAtLeast(double version)
SDL_SetError
#define SDL_SetError
Definition:
SDL_dynapi_overrides.h:30
SDL_LoadFunction
void * SDL_LoadFunction(void *handle, const char *name)
SDL_strlen
#define SDL_strlen
Definition:
SDL_dynapi_overrides.h:393
SDL_loadso.h
SDL_bool
SDL_bool
Definition:
SDL_stdinc.h:161
src
loadso
dlopen
SDL_sysloadso.c
Generated by
1.8.17