SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.

This commit is contained in:
Sam Lantinga
2006-07-10 21:04:37 +00:00
parent 8f3655506a
commit 6bc598ea61
686 changed files with 117556 additions and 98661 deletions

View File

@@ -31,46 +31,50 @@
#include "SDL_loadso.h"
void *SDL_LoadObject(const char *sofile)
void *
SDL_LoadObject(const char *sofile)
{
void *handle = NULL;
const char *loaderror = "Unknown error";
image_id library_id = load_add_on(sofile);
if ( library_id == B_ERROR ) {
loaderror = "BeOS error";
} else {
handle = (void *)(library_id);
}
void *handle = NULL;
const char *loaderror = "Unknown error";
image_id library_id = load_add_on(sofile);
if (library_id == B_ERROR) {
loaderror = "BeOS error";
} else {
handle = (void *) (library_id);
}
if ( handle == NULL ) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return(handle);
if (handle == NULL) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return (handle);
}
void *SDL_LoadFunction(void *handle, const char *name)
void *
SDL_LoadFunction(void *handle, const char *name)
{
void *symbol = NULL;
const char *loaderror = "Unknown error";
image_id library_id = (image_id)handle;
if ( get_image_symbol(library_id,
name, B_SYMBOL_TYPE_TEXT, &symbol) != B_NO_ERROR ) {
loaderror = "Symbol not found";
}
void *symbol = NULL;
const char *loaderror = "Unknown error";
image_id library_id = (image_id) handle;
if (get_image_symbol(library_id,
name, B_SYMBOL_TYPE_TEXT, &symbol) != B_NO_ERROR) {
loaderror = "Symbol not found";
}
if ( symbol == NULL ) {
SDL_SetError("Failed loading %s: %s", name, loaderror);
}
return(symbol);
if (symbol == NULL) {
SDL_SetError("Failed loading %s: %s", name, loaderror);
}
return (symbol);
}
void SDL_UnloadObject(void *handle)
void
SDL_UnloadObject(void *handle)
{
image_id library_id;
if ( handle != NULL ) {
library_id = (image_id)handle;
unload_add_on(library_id);
}
image_id library_id;
if (handle != NULL) {
library_id = (image_id) handle;
unload_add_on(library_id);
}
}
#endif /* SDL_LOADSO_BEOS */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -31,38 +31,43 @@
#include "SDL_loadso.h"
void *SDL_LoadObject(const char *sofile)
void *
SDL_LoadObject(const char *sofile)
{
void *handle = dlopen(sofile, RTLD_NOW);
const char *loaderror = (char *)dlerror();
if ( handle == NULL ) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return(handle);
void *handle = dlopen(sofile, RTLD_NOW);
const char *loaderror = (char *) dlerror();
if (handle == NULL) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return (handle);
}
void *SDL_LoadFunction(void *handle, const char *name)
void *
SDL_LoadFunction(void *handle, const char *name)
{
void *symbol = dlsym(handle, name);
if ( symbol == NULL ) {
size_t len = 1+SDL_strlen(name)+1;
char *_name = SDL_stack_alloc(char, len);
_name[0] = '_';
SDL_strlcpy(&_name[1], name, len);
symbol = dlsym(handle, name);
SDL_stack_free(_name);
if ( symbol == NULL ) {
SDL_SetError("Failed loading %s: %s", name, (const char *)dlerror());
}
}
return(symbol);
void *symbol = dlsym(handle, name);
if (symbol == NULL) {
size_t len = 1 + SDL_strlen(name) + 1;
char *_name = SDL_stack_alloc(char, len);
_name[0] = '_';
SDL_strlcpy(&_name[1], name, len);
symbol = dlsym(handle, name);
SDL_stack_free(_name);
if (symbol == NULL) {
SDL_SetError("Failed loading %s: %s", name,
(const char *) dlerror());
}
}
return (symbol);
}
void SDL_UnloadObject(void *handle)
void
SDL_UnloadObject(void *handle)
{
if ( handle != NULL ) {
dlclose(handle);
}
if (handle != NULL) {
dlclose(handle);
}
}
#endif /* SDL_LOADSO_DLOPEN */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -28,23 +28,27 @@
#include "SDL_loadso.h"
void *SDL_LoadObject(const char *sofile)
void *
SDL_LoadObject(const char *sofile)
{
const char *loaderror = "SDL_LoadObject() not implemented";
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
return(NULL);
const char *loaderror = "SDL_LoadObject() not implemented";
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
return (NULL);
}
void *SDL_LoadFunction(void *handle, const char *name)
void *
SDL_LoadFunction(void *handle, const char *name)
{
const char *loaderror = "SDL_LoadFunction() not implemented";
SDL_SetError("Failed loading %s: %s", name, loaderror);
return(NULL);
const char *loaderror = "SDL_LoadFunction() not implemented";
SDL_SetError("Failed loading %s: %s", name, loaderror);
return (NULL);
}
void SDL_UnloadObject(void *handle)
void
SDL_UnloadObject(void *handle)
{
/* no-op. */
}
#endif /* SDL_LOADSO_DUMMY || SDL_LOADSO_DISABLED */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -35,72 +35,76 @@
#include "SDL_loadso.h"
void *SDL_LoadObject(const char *sofile)
void *
SDL_LoadObject(const char *sofile)
{
void *handle = NULL;
const char *loaderror = NULL;
CFragConnectionID library_id;
Ptr mainAddr;
Str255 errName;
OSErr error;
char psofile[512];
void *handle = NULL;
const char *loaderror = NULL;
CFragConnectionID library_id;
Ptr mainAddr;
Str255 errName;
OSErr error;
char psofile[512];
SDL_strlcpy(psofile, sofile, SDL_arraysize(psofile));
error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch,
kLoadCFrag, &library_id, &mainAddr, errName);
switch (error) {
case noErr:
loaderror = NULL;
break;
case cfragNoLibraryErr:
loaderror = "Library not found";
break;
case cfragUnresolvedErr:
loaderror = "Unabled to resolve symbols";
break;
case cfragNoPrivateMemErr:
case cfragNoClientMemErr:
loaderror = "Out of memory";
break;
default:
loaderror = "Unknown Code Fragment Manager error";
break;
}
if ( loaderror == NULL ) {
handle = (void *)(library_id);
} else {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return(handle);
SDL_strlcpy(psofile, sofile, SDL_arraysize(psofile));
error = GetSharedLibrary(C2PStr(psofile), kCompiledCFragArch,
kLoadCFrag, &library_id, &mainAddr, errName);
switch (error) {
case noErr:
loaderror = NULL;
break;
case cfragNoLibraryErr:
loaderror = "Library not found";
break;
case cfragUnresolvedErr:
loaderror = "Unabled to resolve symbols";
break;
case cfragNoPrivateMemErr:
case cfragNoClientMemErr:
loaderror = "Out of memory";
break;
default:
loaderror = "Unknown Code Fragment Manager error";
break;
}
if (loaderror == NULL) {
handle = (void *) (library_id);
} else {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return (handle);
}
void *SDL_LoadFunction(void *handle, const char *name)
void *
SDL_LoadFunction(void *handle, const char *name)
{
void *symbol = NULL;
const char *loaderror = NULL;
CFragSymbolClass class;
CFragConnectionID library_id = (CFragConnectionID)handle;
char pname[512];
void *symbol = NULL;
const char *loaderror = NULL;
CFragSymbolClass class;
CFragConnectionID library_id = (CFragConnectionID) handle;
char pname[512];
SDL_strlcpy(pname, name, SDL_arraysize(pname));
if ( FindSymbol(library_id, C2PStr(pname),
(char **)&symbol, &class) != noErr ) {
loaderror = "Symbol not found";
}
SDL_strlcpy(pname, name, SDL_arraysize(pname));
if (FindSymbol(library_id, C2PStr(pname),
(char **) &symbol, &class) != noErr) {
loaderror = "Symbol not found";
}
if ( symbol == NULL ) {
SDL_SetError("Failed loading %s: %s", name, loaderror);
}
return(symbol);
if (symbol == NULL) {
SDL_SetError("Failed loading %s: %s", name, loaderror);
}
return (symbol);
}
void SDL_UnloadObject(void *handle)
void
SDL_UnloadObject(void *handle)
{
CFragConnectionID library_id;
if ( handle != NULL ) {
library_id = (CFragConnectionID)handle;
CloseConnection(&library_id);
}
CFragConnectionID library_id;
if (handle != NULL) {
library_id = (CFragConnectionID) handle;
CloseConnection(&library_id);
}
}
#endif /* SDL_LOADSO_MACOS */
/* vi: set ts=4 sw=4 expandtab: */

File diff suppressed because it is too large Load Diff

View File

@@ -32,31 +32,35 @@
#include "SDL_loadso.h"
void *SDL_LoadObject(const char *sofile)
void *
SDL_LoadObject(const char *sofile)
{
const char *loaderror = "Unknown error";
void *handle = (void *)ldg_open((char *)sofile, ldg_global);
if ( handle == NULL ) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return(handle);
const char *loaderror = "Unknown error";
void *handle = (void *) ldg_open((char *) sofile, ldg_global);
if (handle == NULL) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return (handle);
}
void *SDL_LoadFunction(void *handle, const char *name)
void *
SDL_LoadFunction(void *handle, const char *name)
{
const char *loaderror = "Unknown error";
void *symbol = (void *)ldg_find((char *)name, (LDG *)handle);
if ( symbol == NULL ) {
SDL_SetError("Failed loading %s: %s", name, loaderror);
}
return(symbol);
const char *loaderror = "Unknown error";
void *symbol = (void *) ldg_find((char *) name, (LDG *) handle);
if (symbol == NULL) {
SDL_SetError("Failed loading %s: %s", name, loaderror);
}
return (symbol);
}
void SDL_UnloadObject(void *handle)
void
SDL_UnloadObject(void *handle)
{
if ( handle != NULL ) {
ldg_close((LDG *)handle, ldg_global);
}
if (handle != NULL) {
ldg_close((LDG *) handle, ldg_global);
}
}
#endif /* SDL_LOADSO_LDG */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -33,24 +33,27 @@
#include "SDL_loadso.h"
void *SDL_LoadObject(const char *sofile)
void *
SDL_LoadObject(const char *sofile)
{
HMODULE handle = NULL;
char buf[512];
APIRET ulrc = DosLoadModule(buf, sizeof (buf), (char *) sofile, &handle);
APIRET ulrc = DosLoadModule(buf, sizeof(buf), (char *) sofile, &handle);
/* Generate an error message if all loads failed */
if ((ulrc != NO_ERROR) || (handle == NULL))
SDL_SetError("Failed loading %s: %s", sofile, buf);
return((void *) handle);
return ((void *) handle);
}
void *SDL_LoadFunction(void *handle, const char *name)
void *
SDL_LoadFunction(void *handle, const char *name)
{
const char *loaderror = "Unknown error";
void *symbol = NULL;
APIRET ulrc = DosQueryProcAddr((HMODULE)handle, 0, (char *)name, &symbol);
APIRET ulrc =
DosQueryProcAddr((HMODULE) handle, 0, (char *) name, &symbol);
if (ulrc == ERROR_INVALID_HANDLE)
loaderror = "Invalid module handle";
else if (ulrc == ERROR_INVALID_NAME)
@@ -59,13 +62,15 @@ void *SDL_LoadFunction(void *handle, const char *name)
if (symbol == NULL)
SDL_SetError("Failed loading %s: %s", name, loaderror);
return(symbol);
return (symbol);
}
void SDL_UnloadObject(void *handle)
void
SDL_UnloadObject(void *handle)
{
if ( handle != NULL )
if (handle != NULL)
DosFreeModule((HMODULE) handle);
}
#endif /* SDL_LOADSO_OS2 */
/* vi: set ts=4 sw=4 expandtab: */

View File

@@ -31,109 +31,114 @@
#include "SDL_loadso.h"
void *SDL_LoadObject(const char *sofile)
void *
SDL_LoadObject(const char *sofile)
{
void *handle = NULL;
const char *loaderror = "Unknown error";
void *handle = NULL;
const char *loaderror = "Unknown error";
#if defined(_WIN32_WCE)
char errbuf[512];
char errbuf[512];
wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
wchar_t *sofile_t = SDL_malloc((MAX_PATH+1) * sizeof(wchar_t));
wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
wchar_t *sofile_t = SDL_malloc((MAX_PATH + 1) * sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, MAX_PATH);
handle = (void *)LoadLibrary(sofile_t);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t,
MAX_PATH);
handle = (void *) LoadLibrary(sofile_t);
/* Generate an error message if all loads failed */
if ( handle == NULL ) {
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf_t, SDL_arraysize(errbuf), NULL);
WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
loaderror = errbuf;
}
/* Generate an error message if all loads failed */
if (handle == NULL) {
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf_t, SDL_arraysize(errbuf), NULL);
WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
loaderror = errbuf;
}
SDL_free(sofile_t);
SDL_free(errbuf_t);
SDL_free(sofile_t);
SDL_free(errbuf_t);
#else /*if defined(__WIN32__)*/
char errbuf[512];
#else /*if defined(__WIN32__) */
char errbuf[512];
handle = (void *)LoadLibrary(sofile);
handle = (void *) LoadLibrary(sofile);
/* Generate an error message if all loads failed */
if ( handle == NULL ) {
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf, SDL_arraysize(errbuf), NULL);
loaderror = errbuf;
}
/* Generate an error message if all loads failed */
if (handle == NULL) {
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf, SDL_arraysize(errbuf), NULL);
loaderror = errbuf;
}
#endif
if ( handle == NULL ) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return(handle);
if (handle == NULL) {
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
}
return (handle);
}
void *SDL_LoadFunction(void *handle, const char *name)
void *
SDL_LoadFunction(void *handle, const char *name)
{
void *symbol = NULL;
const char *loaderror = "Unknown error";
void *symbol = NULL;
const char *loaderror = "Unknown error";
#if defined(_WIN32_WCE)
char errbuf[512];
int length = SDL_strlen(name);
char errbuf[512];
int length = SDL_strlen(name);
wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t));
wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t));
wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length);
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length);
symbol = (void *)GetProcAddress((HMODULE)handle, name_t);
if ( symbol == NULL ) {
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf_t, SDL_arraysize(errbuf), NULL);
WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
loaderror = errbuf;
}
symbol = (void *) GetProcAddress((HMODULE) handle, name_t);
if (symbol == NULL) {
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf_t, SDL_arraysize(errbuf), NULL);
WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
loaderror = errbuf;
}
SDL_free(name_t);
SDL_free(errbuf_t);
SDL_free(name_t);
SDL_free(errbuf_t);
#else /*if defined(WIN32)*/
char errbuf[512];
#else /*if defined(WIN32) */
char errbuf[512];
symbol = (void *)GetProcAddress((HMODULE)handle, name);
if ( symbol == NULL ) {
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf, SDL_arraysize(errbuf), NULL);
loaderror = errbuf;
}
symbol = (void *) GetProcAddress((HMODULE) handle, name);
if (symbol == NULL) {
FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM),
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
errbuf, SDL_arraysize(errbuf), NULL);
loaderror = errbuf;
}
#endif
if ( symbol == NULL ) {
SDL_SetError("Failed loading %s: %s", name, loaderror);
}
return(symbol);
if (symbol == NULL) {
SDL_SetError("Failed loading %s: %s", name, loaderror);
}
return (symbol);
}
void SDL_UnloadObject(void *handle)
void
SDL_UnloadObject(void *handle)
{
if ( handle != NULL ) {
FreeLibrary((HMODULE)handle);
}
if (handle != NULL) {
FreeLibrary((HMODULE) handle);
}
}
#endif /* SDL_LOADSO_WIN32 */
/* vi: set ts=4 sw=4 expandtab: */