Date: Mon, 8 May 2006 14:19:30 -0700
authorSam Lantinga <slouken@libsdl.org>
Tue, 09 May 2006 07:26:58 +0000
changeset 1790828a17e05192
parent 1789 01313c1a2bbe
child 1791 5652192b9c8b
Date: Mon, 8 May 2006 14:19:30 -0700
From: Bob Ippolito
Subject: SDL trunk (r2346) and Mac OS X

The current state of the trunk doesn't quite compile on Mac OS X,
I've attached a series of patches that gets it to compile and kills a
few warnings.

sdl-trunk-r2346-dlcompat-warnings.diff:
The dlcompat thing is just loaded with incorrect type signatures ..
some of them have changed since 10.2 and others are just flat wrong.
This puts it in sync with the latest headers. People on 10.2 will get
the warnings instead of people with new kits.
src/loadso/macosx/SDL_sysloadso.c
     1.1 --- a/src/loadso/macosx/SDL_sysloadso.c	Tue May 09 07:20:32 2006 +0000
     1.2 +++ b/src/loadso/macosx/SDL_sysloadso.c	Tue May 09 07:26:58 2006 +0000
     1.3 @@ -94,6 +94,7 @@
     1.4  #define dl_restrict
     1.5  #endif
     1.6  
     1.7 +#if 0
     1.8  #ifndef _POSIX_SOURCE
     1.9  /*
    1.10   * Structure filled in by dladdr().
    1.11 @@ -107,6 +108,7 @@
    1.12  
    1.13  static int SDL_OSX_dladdr(const void * dl_restrict, SDL_OSX_Dl_info * dl_restrict);
    1.14  #endif /* ! _POSIX_SOURCE */
    1.15 +#endif /* 0 */
    1.16  
    1.17  static int SDL_OSX_dlclose(void * handle);
    1.18  static const char * SDL_OSX_dlerror(void);
    1.19 @@ -238,9 +240,9 @@
    1.20  static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetError);
    1.21  static struct dlstatus *allocStatus(void);
    1.22  static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, int mode);
    1.23 -static NSSymbol *search_linked_libs(const struct mach_header *mh, const char *symbol);
    1.24 +static NSSymbol search_linked_libs(const struct mach_header *mh, const char *symbol);
    1.25  static const char *get_lib_name(const struct mach_header *mh);
    1.26 -static const struct mach_header *get_mach_header_from_NSModule(NSModule * mod);
    1.27 +static const struct mach_header *get_mach_header_from_NSModule(NSModule mod);
    1.28  static void dlcompat_init_func(void);
    1.29  static inline void dlcompat_init_check(void);
    1.30  static inline void dolock(void);
    1.31 @@ -331,10 +333,10 @@
    1.32   * and finding the one with the same name as the module. There really ought to be
    1.33   * an api for doing this, would be faster, but there isn't one right now
    1.34   */
    1.35 -static const struct mach_header *get_mach_header_from_NSModule(NSModule * mod)
    1.36 +static const struct mach_header *get_mach_header_from_NSModule(NSModule mod)
    1.37  {
    1.38  	const char *mod_name = NSNameOfModule(mod);
    1.39 -	struct mach_header *mh = NULL;
    1.40 +	const struct mach_header *mh = NULL;
    1.41  	unsigned long count = _dyld_image_count();
    1.42  	unsigned long i;
    1.43  	debug("Module name: %s", mod_name);
    1.44 @@ -526,7 +528,7 @@
    1.45  	static int (*p) (NSModule module) = 0;
    1.46  	debug("promoting");
    1.47  	if (!p)
    1.48 -		_dyld_func_lookup("__dyld_NSMakePrivateModulePublic", (unsigned long *)&p);
    1.49 +		_dyld_func_lookup("__dyld_NSMakePrivateModulePublic", (void **)&p);
    1.50  	return (dls->module == MAGIC_DYLIB_MOD) || (p && p(dls->module));
    1.51  }
    1.52  
    1.53 @@ -585,12 +587,12 @@
    1.54   * bother adding the extra dependencies, if the symbols are neither in the loaded image nor
    1.55   * any of it's direct dependencies, then it probably isn't there.
    1.56   */
    1.57 -static NSSymbol *search_linked_libs(const struct mach_header * mh, const char *symbol)
    1.58 +static NSSymbol search_linked_libs(const struct mach_header * mh, const char *symbol)
    1.59  {
    1.60  	unsigned int n;
    1.61  	struct load_command *lc = 0;
    1.62  	struct mach_header *wh;
    1.63 -	NSSymbol *nssym = 0;
    1.64 +	NSSymbol nssym = 0;
    1.65  	if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage)
    1.66  	{
    1.67  		lc = (struct load_command *)((char *)mh + sizeof(struct mach_header));
    1.68 @@ -640,7 +642,7 @@
    1.69  
    1.70  static void *dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetError)
    1.71  {
    1.72 -  NSSymbol *nssym = 0;
    1.73 +  NSSymbol nssym = 0;
    1.74  #ifdef __GCC__  
    1.75  	void *caller = __builtin_return_address(1);	/* Be *very* careful about inlining */
    1.76  #else
    1.77 @@ -899,10 +901,10 @@
    1.78  
    1.79  static void dlcompat_init_func(void)
    1.80  {
    1.81 -        _dyld_func_lookup("__dyld_NSAddImage", (unsigned long *)&dyld_NSAddImage);
    1.82 +        _dyld_func_lookup("__dyld_NSAddImage", (void **)&dyld_NSAddImage);
    1.83  	_dyld_func_lookup("__dyld_NSIsSymbolNameDefinedInImage",
    1.84 -			  (unsigned long *)&dyld_NSIsSymbolNameDefinedInImage);
    1.85 -	_dyld_func_lookup("__dyld_NSLookupSymbolInImage", (unsigned long *)&dyld_NSLookupSymbolInImage);
    1.86 +			  (void **)&dyld_NSIsSymbolNameDefinedInImage);
    1.87 +	_dyld_func_lookup("__dyld_NSLookupSymbolInImage", (void **)&dyld_NSLookupSymbolInImage);
    1.88  	if (pthread_mutex_init(&dlcompat_mutex, NULL))
    1.89  	    exit(1);
    1.90  	if (pthread_key_create(&dlerror_key, &dlerrorfree))
    1.91 @@ -1189,9 +1191,9 @@
    1.92  	unsigned long i;
    1.93  	unsigned long j;
    1.94  	unsigned long count = _dyld_image_count();
    1.95 -	struct mach_header *mh = 0;
    1.96 +	const struct mach_header *mh = 0;
    1.97  	struct load_command *lc = 0;
    1.98 -	unsigned long addr = NULL;
    1.99 +	unsigned long addr = 0;
   1.100  	for (i = 0; i < count; i++)
   1.101  	{
   1.102  		addr = (unsigned long)address - _dyld_get_image_vmaddr_slide(i);
   1.103 @@ -1216,6 +1218,7 @@
   1.104  	return mh;
   1.105  }
   1.106  
   1.107 +#if 0 /* unused */
   1.108  static int SDL_OSX_dladdr(const void * dl_restrict p, SDL_OSX_Dl_info * dl_restrict info)
   1.109  {
   1.110  /*
   1.111 @@ -1323,7 +1326,7 @@
   1.112  	dounlock();
   1.113  	return 1;
   1.114  }
   1.115 -
   1.116 +#endif
   1.117  
   1.118  /*
   1.119   * Implement the dlfunc() interface, which behaves exactly the same as