Mercurial > sdl-ios-xcode
comparison src/loadso/macosx/SDL_sysloadso.c @ 1648:9f59d4c5aaea
Mac OS X fat build works! :)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 22 Apr 2006 19:17:14 +0000 |
parents | 92947e3a18db |
children | 828a17e05192 |
comparison
equal
deleted
inserted
replaced
1647:2af911d41a08 | 1648:9f59d4c5aaea |
---|---|
107 | 107 |
108 static int SDL_OSX_dladdr(const void * dl_restrict, SDL_OSX_Dl_info * dl_restrict); | 108 static int SDL_OSX_dladdr(const void * dl_restrict, SDL_OSX_Dl_info * dl_restrict); |
109 #endif /* ! _POSIX_SOURCE */ | 109 #endif /* ! _POSIX_SOURCE */ |
110 | 110 |
111 static int SDL_OSX_dlclose(void * handle); | 111 static int SDL_OSX_dlclose(void * handle); |
112 static char * SDL_OSX_dlerror(void); | 112 static const char * SDL_OSX_dlerror(void); |
113 static void * SDL_OSX_dlopen(const char *path, int mode); | 113 static void * SDL_OSX_dlopen(const char *path, int mode); |
114 static void * SDL_OSX_dlsym(void * dl_restrict handle, const char * dl_restrict symbol); | 114 static void * SDL_OSX_dlsym(void * dl_restrict handle, const char * dl_restrict symbol); |
115 | 115 |
116 #define RTLD_LAZY 0x1 | 116 #define RTLD_LAZY 0x1 |
117 #define RTLD_NOW 0x2 | 117 #define RTLD_NOW 0x2 |
247 static inline void dounlock(void); | 247 static inline void dounlock(void); |
248 static void dlerrorfree(void *data); | 248 static void dlerrorfree(void *data); |
249 static void resetdlerror(void); | 249 static void resetdlerror(void); |
250 static const struct mach_header *my_find_image(const char *name); | 250 static const struct mach_header *my_find_image(const char *name); |
251 static const struct mach_header *image_for_address(const void *address); | 251 static const struct mach_header *image_for_address(const void *address); |
252 static inline const char *dyld_error_str(void); | 252 static inline char *dyld_error_str(void); |
253 | 253 |
254 #if FINK_BUILD | 254 #if FINK_BUILD |
255 /* Two Global Functions */ | 255 /* Two Global Functions */ |
256 static void *dlsym_prepend_underscore(void *handle, const char *symbol); | 256 static void *dlsym_prepend_underscore(void *handle, const char *symbol); |
257 static void *dlsym_auto_underscore(void *handle, const char *symbol); | 257 static void *dlsym_auto_underscore(void *handle, const char *symbol); |
621 } | 621 } |
622 return nssym; | 622 return nssym; |
623 } | 623 } |
624 | 624 |
625 /* Up to the caller to SDL_free() returned string */ | 625 /* Up to the caller to SDL_free() returned string */ |
626 static inline const char *dyld_error_str() | 626 static inline char *dyld_error_str() |
627 { | 627 { |
628 NSLinkEditErrors dylder; | 628 NSLinkEditErrors dylder; |
629 int dylderno; | 629 int dylderno; |
630 const char *dylderrstr; | 630 const char *dylderrstr; |
631 const char *dyldfile; | 631 const char *dyldfile; |
645 void *caller = __builtin_return_address(1); /* Be *very* careful about inlining */ | 645 void *caller = __builtin_return_address(1); /* Be *very* careful about inlining */ |
646 #else | 646 #else |
647 void *caller = NULL; | 647 void *caller = NULL; |
648 #endif | 648 #endif |
649 const struct mach_header *caller_mh = 0; | 649 const struct mach_header *caller_mh = 0; |
650 char* savedErrorStr = NULL; | 650 char *savedErrorStr = NULL; |
651 resetdlerror(); | 651 resetdlerror(); |
652 #ifndef RTLD_SELF | 652 #ifndef RTLD_SELF |
653 #define RTLD_SELF ((void *) -3) | 653 #define RTLD_SELF ((void *) -3) |
654 #endif | 654 #endif |
655 if (NULL == dls) | 655 if (NULL == dls) |
1166 dlcloseerror: | 1166 dlcloseerror: |
1167 dounlock(); | 1167 dounlock(); |
1168 return 1; | 1168 return 1; |
1169 } | 1169 } |
1170 | 1170 |
1171 static char *SDL_OSX_dlerror(void) | 1171 static const char *SDL_OSX_dlerror(void) |
1172 { | 1172 { |
1173 struct dlthread *tss; | 1173 struct dlthread *tss; |
1174 const char * err_str = NULL; | 1174 const char * err_str = NULL; |
1175 dlcompat_init_check(); | 1175 dlcompat_init_check(); |
1176 tss = pthread_getspecific(dlerror_key); | 1176 tss = pthread_getspecific(dlerror_key); |
1376 #include "SDL_loadso.h" | 1376 #include "SDL_loadso.h" |
1377 | 1377 |
1378 void *SDL_LoadObject(const char *sofile) | 1378 void *SDL_LoadObject(const char *sofile) |
1379 { | 1379 { |
1380 void *handle = SDL_OSX_dlopen(sofile, RTLD_NOW); | 1380 void *handle = SDL_OSX_dlopen(sofile, RTLD_NOW); |
1381 const char *loaderror = (char *)SDL_OSX_dlerror(); | 1381 const char *loaderror = SDL_OSX_dlerror(); |
1382 if ( handle == NULL ) { | 1382 if ( handle == NULL ) { |
1383 SDL_SetError("Failed loading %s: %s", sofile, loaderror); | 1383 SDL_SetError("Failed loading %s: %s", sofile, loaderror); |
1384 } | 1384 } |
1385 return(handle); | 1385 return(handle); |
1386 } | 1386 } |
1387 | 1387 |
1388 void *SDL_LoadFunction(void *handle, const char *name) | 1388 void *SDL_LoadFunction(void *handle, const char *name) |
1389 { | 1389 { |
1390 void *symbol = SDL_OSX_dlsym(handle, name); | 1390 void *symbol = SDL_OSX_dlsym(handle, name); |
1391 if ( symbol == NULL ) { | 1391 if ( symbol == NULL ) { |
1392 SDL_SetError("Failed loading %s: %s", name, (const char *)SDL_OSX_dlerror()); | 1392 SDL_SetError("Failed loading %s: %s", name, SDL_OSX_dlerror()); |
1393 } | 1393 } |
1394 return(symbol); | 1394 return(symbol); |
1395 } | 1395 } |
1396 | 1396 |
1397 void SDL_UnloadObject(void *handle) | 1397 void SDL_UnloadObject(void *handle) |