annotate src/SDL_loadso.c @ 701:aaf3b8af6616

Date: Sat, 30 Aug 2003 16:28:10 +0300 From: "Mike Gorchak" Subject: Re: SDL 1.2.6 - minor changes about shared library building under QNX6 into README.QNX - added forgotten libSDLmain.a into distribution, SDL.qpg.in - added header guards to the all headers. - fixed fullscreen double buffered mode. - fixed Photon crashes after/during using fullscreen OpenGL modes. - added GL_MakeCurrent function. - added SDL_VIDEOEXPOSE event, when OpenGL window have been resized - added more HAVE_OPENGL checks to avoid dead code compilation without using OpenGL - finished code reorganization (began into previous patches).
author Sam Lantinga <slouken@libsdl.org>
date Sat, 30 Aug 2003 17:07:59 +0000
parents 35ff0890ac4e
children c67d4fb10a45
rev   line source
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
297
f6ffac90895c Updated copyright information for 2002
Sam Lantinga <slouken@libsdl.org>
parents: 296
diff changeset
3 Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Library General Public License for more details.
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
20 slouken@libsdl.org
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
22
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23 #ifdef SAVE_RCSID
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 static char rcsid =
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
25 "@(#) $Id$";
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 #endif
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 /* System dependent library loading routines */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 #include <stdio.h>
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 #if defined(USE_DLOPEN)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 # include <dlfcn.h>
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34 #elif defined(WIN32)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 # include <windows.h>
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #elif defined(__BEOS__)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37 # include <be/kernel/image.h>
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
38 #elif defined(macintosh)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 # include <string.h>
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40 # include <Strings.h>
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
41 # include <CodeFragments.h>
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
42 # include <Errors.h>
651
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
43 #elif defined(__MINT__) && defined(ENABLE_LDG)
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
44 # include <gem.h>
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
45 # include <ldg.h>
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
46 #else
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47 /*#error Unsupported dynamic link environment*/
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 #endif /* system type */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49
296
fab1ddc4d7bf Removed the API changes to preserve SDL 1.2 stability
Sam Lantinga <slouken@libsdl.org>
parents: 294
diff changeset
50 #include "SDL_types.h"
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 #include "SDL_error.h"
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 #include "SDL_loadso.h"
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54 void *SDL_LoadObject(const char *sofile)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56 void *handle = NULL;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 const char *loaderror = "SDL_LoadObject() not implemented";
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58 #if defined(USE_DLOPEN)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60 handle = dlopen(sofile, RTLD_NOW);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
61 loaderror = (char *)dlerror();
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62 #elif defined(WIN32)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 char errbuf[512];
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 handle = (void *)LoadLibrary(sofile);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 /* Generate an error message if all loads failed */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 if ( handle == NULL ) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 FORMAT_MESSAGE_FROM_SYSTEM),
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 NULL, GetLastError(),
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74 errbuf, SDL_TABLESIZE(errbuf), NULL);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 loaderror = errbuf;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 #elif defined(__BEOS__)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 image_id library_id;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 library_id = load_add_on(sofile);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82 if ( library_id == B_ERROR ) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 loaderror = "BeOS error";
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84 } else {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
85 handle = (void *)(library_id);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 #elif defined(macintosh)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 CFragConnectionID library_id;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 Ptr mainAddr;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 Str255 errName;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 OSErr error;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 char psofile[512];
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
95 strncpy(psofile, sofile, SDL_TABLESIZE(psofile));
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96 psofile[SDL_TABLESIZE(psofile)-1] = '\0';
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch,
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 kLoadCFrag, &library_id, &mainAddr, errName);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 switch (error) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 case noErr:
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101 break;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 case cfragNoLibraryErr:
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 loaderror = "Library not found";
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 break;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 case cfragUnresolvedErr:
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106 loaderror = "Unabled to resolve symbols";
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 break;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 case cfragNoPrivateMemErr:
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 case cfragNoClientMemErr:
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 loaderror = "Out of memory";
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 break;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 default:
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113 loaderror = "Unknown Code Fragment Manager error";
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
114 break;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
115 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
116 if ( loaderror == NULL ) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
117 handle = (void *)(library_id);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 }
651
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
119 #elif defined(__MINT__) && defined(ENABLE_LDG)
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
120 /* * */
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
121 handle = (void *)ldg_open((char *)sofile, ldg_global);
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122 #endif /* system type */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124 if ( handle == NULL ) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 SDL_SetError("Failed loading %s: %s", sofile, loaderror);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 return(handle);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130 void *SDL_LoadFunction(void *handle, const char *name)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 void *symbol = NULL;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 const char *loaderror = "SDL_LoadFunction not implemented";
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 #if defined(USE_DLOPEN)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 symbol = dlsym(handle, name);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137 if ( symbol == NULL ) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 loaderror = (char *)dlerror();
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140 #elif defined(WIN32)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 char errbuf[512];
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 symbol = (void *)GetProcAddress((HMODULE)handle, name);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 if ( symbol == NULL ) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147 FORMAT_MESSAGE_FROM_SYSTEM),
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 NULL, GetLastError(),
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 errbuf, SDL_TABLESIZE(errbuf), NULL);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151 loaderror = errbuf;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153 #elif defined(__BEOS__)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155 image_id library_id = (image_id)handle;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 if ( get_image_symbol(library_id,
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 name, B_SYMBOL_TYPE_TEXT, &symbol) != B_NO_ERROR ) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 loaderror = "Symbol not found";
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 #elif defined(macintosh)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 CFragSymbolClass class;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 CFragConnectionID library_id = (CFragConnectionID)handle;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 char pname[512];
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 strncpy(pname, name, SDL_TABLESIZE(pname));
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 pname[SDL_TABLESIZE(pname)-1] = '\0';
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 if ( FindSymbol(library_id, C2PStr(pname),
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169 (char **)&symbol, &class) != noErr ) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
170 loaderror = "Symbol not found";
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 }
651
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
172 #elif defined(__MINT__) && defined(ENABLE_LDG)
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
173 /* * */
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
174 symbol = (void *)ldg_find((char *)name, (LDG *)handle);
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 #endif /* system type */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 if ( symbol == NULL ) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178 SDL_SetError("Failed loading %s: %s", name, loaderror);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180 return(symbol);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
181 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 void SDL_UnloadObject(void *handle)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184 {
336
745873ea091f BeOS compile fix for shared object loading code
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
185 #if defined(__BEOS__)
745873ea091f BeOS compile fix for shared object loading code
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
186 image_id library_id;
745873ea091f BeOS compile fix for shared object loading code
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
187 #endif
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 if ( handle == NULL ) {
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 return;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 }
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
191 #if defined(USE_DLOPEN)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
192 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 dlclose(handle);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 #elif defined(WIN32)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
196 FreeLibrary((HMODULE)handle);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
197 #elif defined(__BEOS__)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 /* * */
336
745873ea091f BeOS compile fix for shared object loading code
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
199 library_id = (image_id)handle;
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 unload_add_on(library_id);
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 #elif defined(macintosh)
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 /* * */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 CFragConnectionID library_id = (CFragConnectionID)handle;
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
204 CloseConnection(library_id);
651
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
205 #elif defined(__MINT__) && defined(ENABLE_LDG)
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
206 /* * */
35ff0890ac4e pmandin: Added Atari LDG shared object loader
Patrice Mandin <patmandin@gmail.com>
parents: 336
diff changeset
207 ldg_close((LDG *)handle, ldg_global);
294
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 #endif /* system type */
d2d48e10f370 Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209 }