src/loadso/mint/SDL_loadso.c
changeset 1361 19418e4422cb
parent 1360 70a9cfb4cf1b
child 1362 88ddeb76c9c1
equal deleted inserted replaced
1360:70a9cfb4cf1b 1361:19418e4422cb
     1 /*
       
     2     SDL - Simple DirectMedia Layer
       
     3     Copyright (C) 1997-2006 Sam Lantinga
       
     4 
       
     5     This library is free software; you can redistribute it and/or
       
     6     modify it under the terms of the GNU Lesser General Public
       
     7     License as published by the Free Software Foundation; either
       
     8     version 2.1 of the License, or (at your option) any later version.
       
     9 
       
    10     This library is distributed in the hope that it will be useful,
       
    11     but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
       
    13     Lesser General Public License for more details.
       
    14 
       
    15     You should have received a copy of the GNU Lesser General Public
       
    16     License along with this library; if not, write to the Free Software
       
    17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
       
    18 
       
    19     Sam Lantinga
       
    20     slouken@libsdl.org
       
    21 */
       
    22 
       
    23 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
       
    24 /* System dependent library loading routines                           */
       
    25 
       
    26 #if !SDL_INTERNAL_BUILDING_LOADSO
       
    27 #error Do not compile directly...compile src/SDL_loadso.c instead!
       
    28 #endif
       
    29 
       
    30 /* please use the "dummy" driver if you don't have LDG support enabled. */
       
    31 #if !defined(__MINT__) || !defined(ENABLE_LDG)
       
    32 #error Compiling for the wrong platform?
       
    33 #endif
       
    34 
       
    35 #include <stdio.h>
       
    36 #include <gem.h>
       
    37 #include <ldg.h>
       
    38 
       
    39 #include "SDL_loadso.h"
       
    40 
       
    41 void *SDL_LoadObject(const char *sofile)
       
    42 {
       
    43 	const char *loaderror = "Unknown error";
       
    44 	void *handle = (void *)ldg_open((char *)sofile, ldg_global);
       
    45 	if ( handle == NULL ) {
       
    46 		SDL_SetError("Failed loading %s: %s", sofile, loaderror);
       
    47 	}
       
    48 	return(handle);
       
    49 }
       
    50 
       
    51 void *SDL_LoadFunction(void *handle, const char *name)
       
    52 {
       
    53 	const char *loaderror = "Unknown error";
       
    54 	void *symbol = (void *)ldg_find((char *)name, (LDG *)handle);
       
    55 	if ( symbol == NULL ) {
       
    56 		SDL_SetError("Failed loading %s: %s", name, loaderror);
       
    57 	}
       
    58 	return(symbol);
       
    59 }
       
    60 
       
    61 void SDL_UnloadObject(void *handle)
       
    62 {
       
    63 	if ( handle != NULL ) {
       
    64 		ldg_close((LDG *)handle, ldg_global);
       
    65 	}
       
    66 }
       
    67