2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
8 #include <aros/config.h>
10 #include "x11gfx_intern.h"
13 #include <aros/symbolsets.h>
15 #include <proto/hostlib.h>
17 #include LC_LIBDEFS_FILE
19 void *x11_handle
= NULL
;
20 void *libc_handle
= NULL
;
21 void *xf86vm_handle
= NULL
;
23 struct x11_func x11_func
;
24 struct libc_func libc_func
;
25 struct xf86vm_func xf86vm_func
;
27 static const char *xf86vm_func_names
[] = {
28 "XF86VidModeGetAllModeLines",
29 "XF86VidModeSwitchToMode",
30 "XF86VidModeSetViewPort",
31 "XF86VidModeQueryVersion",
32 "XF86VidModeQueryExtension"
35 #define XF86VM_NUM_FUNCS (5)
37 static const char *x11_func_names
[] = {
45 "XCreatePixmapCursor",
49 "XCreateSimpleWindow",
53 "XVisualIDFromVisual",
64 "XChangeWindowAttributes",
88 "XGetWindowAttributes",
98 "XRefreshKeyboardMapping",
103 "XSetClipRectangles",
108 "XSetSelectionOwner",
120 #if DEBUG_X11_SYNCHRON
125 #if DEBUG_X11_SYNCHRON
126 #define X11_NUM_FUNCS (83)
128 #define X11_NUM_FUNCS (82)
132 static const char *libc_func_names
[] = {
144 #define LIBC_NUM_FUNCS (6)
146 #define LIBC_NUM_FUNCS (1)
151 void *x11_hostlib_load_so(const char *sofile
, const char **names
, int nfuncs
, void **funcptr
)
157 D(bug("[X11host] %s('%s')\n", __PRETTY_FUNCTION__
, sofile
));
159 D(bug("[X11host] %s: attempting to load %d functions\n", __PRETTY_FUNCTION__
, nfuncs
));
161 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
162 bug("[X11host] %s: failed to open '%s': %s\n", __PRETTY_FUNCTION__
, sofile
, err
);
166 for (i
= 0; i
< nfuncs
; i
++) {
167 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
168 D(bug("[X11host] %s: 0x%p = '%s'\n", __PRETTY_FUNCTION__
, funcptr
[i
], names
[i
]));
170 bug("[X11host] %s: failed to get symbol '%s' (%s)\n", __PRETTY_FUNCTION__
, names
[i
], err
);
171 HostLib_Close(handle
, NULL
);
179 static int x11_hostlib_init(LIBBASETYPEPTR LIBBASE
)
181 D(bug("[X11host] %s()\n", __PRETTY_FUNCTION__
));
183 if ((HostLibBase
= OpenResource("hostlib.resource")) == NULL
) {
184 bug("[X11host] %s: failed to open hostlib.resource!\n", __PRETTY_FUNCTION__
);
187 if ((xf86vm_handle
= x11_hostlib_load_so(XF86VM_SOFILE
, xf86vm_func_names
, XF86VM_NUM_FUNCS
, (void **) &xf86vm_func
)) == NULL
)
190 if ((x11_handle
= x11_hostlib_load_so(X11_SOFILE
, x11_func_names
, X11_NUM_FUNCS
, (void **) &x11_func
)) == NULL
)
193 if ((libc_handle
= x11_hostlib_load_so(LIBC_SOFILE
, libc_func_names
, LIBC_NUM_FUNCS
, (void **) &libc_func
)) == NULL
) {
194 HostLib_Close(x11_handle
, NULL
);
201 static int x11_hostlib_expunge(LIBBASETYPEPTR LIBBASE
)
203 D(bug("[X11host] %s()\n", __PRETTY_FUNCTION__
));
205 if (xf86vm_handle
!= NULL
)
206 HostLib_Close(xf86vm_handle
, NULL
);
208 if (x11_handle
!= NULL
)
209 HostLib_Close(x11_handle
, NULL
);
211 if (libc_handle
!= NULL
)
212 HostLib_Close(libc_handle
, NULL
);
217 ADD2INITLIB(x11_hostlib_init
, 0)
218 ADD2EXPUNGELIB(x11_hostlib_expunge
, 0)