2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
6 #include <aros/config.h>
8 #include "x11gfx_intern.h"
11 #include <aros/symbolsets.h>
13 #include <proto/hostlib.h>
15 #include LC_LIBDEFS_FILE
18 #include <aros/debug.h>
20 void *x11_handle
= NULL
;
21 void *libc_handle
= NULL
;
22 void *xf86vm_handle
= NULL
;
24 struct x11_func x11_func
;
25 struct libc_func libc_func
;
26 struct xf86vm_func xf86vm_func
;
28 static const char *xf86vm_func_names
[] = {
29 "XF86VidModeGetAllModeLines",
30 "XF86VidModeSwitchToMode",
31 "XF86VidModeSetViewPort",
32 "XF86VidModeQueryVersion",
33 "XF86VidModeQueryExtension"
36 #define XF86VM_NUM_FUNCS (5)
38 static const char *x11_func_names
[] = {
46 "XCreatePixmapCursor",
50 "XCreateSimpleWindow",
54 "XVisualIDFromVisual",
64 "XChangeWindowAttributes",
88 "XGetWindowAttributes",
98 "XRefreshKeyboardMapping",
103 "XSetClipRectangles",
108 "XSetSelectionOwner",
119 #if DEBUG_X11_SYNCHRON
124 #if DEBUG_X11_SYNCHRON
125 #define X11_NUM_FUNCS (81)
127 #define X11_NUM_FUNCS (80)
131 static const char *libc_func_names
[] = {
143 #define LIBC_NUM_FUNCS (6)
145 #define LIBC_NUM_FUNCS (1)
150 void *x11_hostlib_load_so(const char *sofile
, const char **names
, int nfuncs
, void **funcptr
) {
155 D(bug("[x11] loading %d functions from %s\n", nfuncs
, sofile
));
157 if ((handle
= HostLib_Open(sofile
, &err
)) == NULL
) {
158 kprintf("[x11] couldn't open '%s': %s\n", sofile
, err
);
162 for (i
= 0; i
< nfuncs
; i
++) {
163 funcptr
[i
] = HostLib_GetPointer(handle
, names
[i
], &err
);
164 D(bug("%s(%x)\n", names
[i
], funcptr
[i
]));
166 kprintf("[x11] couldn't get symbol '%s' from '%s': %s\n", names
[i
], sofile
, err
);
167 HostLib_Close(handle
, NULL
);
172 D(bug("[x11] done\n"));
177 static int x11_hostlib_init(LIBBASETYPEPTR LIBBASE
) {
178 D(bug("[x11] hostlib init\n"));
180 if ((HostLibBase
= OpenResource("hostlib.resource")) == NULL
) {
181 kprintf("[x11] couldn't open hostlib.resource\n");
184 if ((xf86vm_handle
= x11_hostlib_load_so(XF86VM_SOFILE
, xf86vm_func_names
, XF86VM_NUM_FUNCS
, (void **) &xf86vm_func
)) == NULL
)
187 if ((x11_handle
= x11_hostlib_load_so(X11_SOFILE
, x11_func_names
, X11_NUM_FUNCS
, (void **) &x11_func
)) == NULL
)
190 if ((libc_handle
= x11_hostlib_load_so(LIBC_SOFILE
, libc_func_names
, LIBC_NUM_FUNCS
, (void **) &libc_func
)) == NULL
) {
191 HostLib_Close(x11_handle
, NULL
);
198 static int x11_hostlib_expunge(LIBBASETYPEPTR LIBBASE
) {
199 D(bug("[x11] hostlib expunge\n"));
201 if (xf86vm_handle
!= NULL
)
202 HostLib_Close(xf86vm_handle
, NULL
);
204 if (x11_handle
!= NULL
)
205 HostLib_Close(x11_handle
, NULL
);
207 if (libc_handle
!= NULL
)
208 HostLib_Close(libc_handle
, NULL
);
213 ADD2INITLIB(x11_hostlib_init
, 0)
214 ADD2EXPUNGELIB(x11_hostlib_expunge
, 0)