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