annotate src/loadso/mint/SDL_loadso.c @ 1173:e9cf8c1b4590

Split up src/SDL_loadso.c into platform directories.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 17 Nov 2005 03:15:05 +0000
parents
children c9b51268668f
rev   line source
1173
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
1 /*
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
3 Copyright (C) 1997-2004 Sam Lantinga
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
4
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
9
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
13 Library General Public License for more details.
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
14
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
18
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
19 Sam Lantinga
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
20 slouken@libsdl.org
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
21 */
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
22
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
23 #ifdef SAVE_RCSID
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
24 static char rcsid =
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
25 "@(#) $Id$";
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
26 #endif
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
27
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
28 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
29 /* System dependent library loading routines */
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
30
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
31 #if !SDL_INTERNAL_BUILDING_LOADSO
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
32 #error Do not compile directly...compile src/SDL_loadso.c instead!
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
33 #endif
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
34
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
35 /* please use the "dummy" driver if you don't have LDG support enabled. */
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
36 #if !defined(__MINT__) || !defined(ENABLE_LDG)
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
37 #error Compiling for the wrong platform?
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
38 #endif
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
39
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
40 #include <stdio.h>
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
41 #include <gem.h>
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
42 #include <ldg.h>
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
43
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
44 #include "SDL_types.h"
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
45 #include "SDL_error.h"
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
46 #include "SDL_loadso.h"
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
47
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
48 void *SDL_LoadObject(const char *sofile)
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
49 {
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
50 const char *loaderror = "Unknown error";
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
51 void *handle = (void *)ldg_open((char *)sofile, ldg_global);
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
52 if ( handle == NULL ) {
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
53 SDL_SetError("Failed loading %s: %s", sofile, loaderror);
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
54 }
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
55 return(handle);
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
56 }
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
57
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
58 void *SDL_LoadFunction(void *handle, const char *name)
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
59 {
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
60 const char *loaderror = "Unknown error";
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
61 void *symbol = (void *)ldg_find((char *)name, (LDG *)handle);
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
62 if ( symbol == NULL ) {
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
63 SDL_SetError("Failed loading %s: %s", name, loaderror);
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
64 }
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
65 return(symbol);
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
66 }
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
67
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
68 void SDL_UnloadObject(void *handle)
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
69 {
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
70 if ( handle != NULL ) {
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
71 ldg_close((LDG *)handle, ldg_global);
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
72 }
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
73 }
e9cf8c1b4590 Split up src/SDL_loadso.c into platform directories.
Ryan C. Gordon <icculus@icculus.org>
parents:
diff changeset
74