Mercurial > sdl-ios-xcode
annotate src/loadso/macosx/SDL_dlcompat.c @ 2769:2a46b5912665
Added missing math.h functionality for SDL_audiocvt.c
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 12 Oct 2008 16:30:42 +0000 |
parents | 204be4fc2726 |
children | 3e42ad69f4a3 |
rev | line source |
---|---|
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #ifdef SDL_LOADSO_DLCOMPAT |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 /* Please note that dlcompat apparently ships in current Mac OS X versions |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 * as a system library that provides compatibility with the Unix "dlopen" |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 * interface. In order to allow SDL to work on older OS X releases and also |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 * not conflict with the system lib on newer versions, we include dlcompat |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 * in SDL and change the symbols to prevent symbol clash with any existing |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 * system libraries. --ryan. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 /* here is the dlcompat license: */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 /* |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 Copyright (c) 2002 Jorge Acereda <jacereda@users.sourceforge.net> & |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 Peter O'Gorman <ogorman@users.sourceforge.net> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 Portions may be copyright others, see the AUTHORS file included with this |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 distribution. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 Maintained by Peter O'Gorman <ogorman@users.sourceforge.net> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 Bug Reports and other queries should go to <ogorman@users.sourceforge.net> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 Permission is hereby granted, free of charge, to any person obtaining |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 a copy of this software and associated documentation files (the |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 "Software"), to deal in the Software without restriction, including |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 without limitation the rights to use, copy, modify, merge, publish, |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 distribute, sublicense, and/or sell copies of the Software, and to |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 permit persons to whom the Software is furnished to do so, subject to |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 the following conditions: |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 The above copyright notice and this permission notice shall be |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 included in all copies or substantial portions of the Software. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 #include <pthread.h> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 #include <sys/types.h> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 #include <sys/stat.h> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 #include <stdarg.h> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 #include <limits.h> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 #include <mach-o/dyld.h> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 #include <mach-o/nlist.h> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 #include <mach-o/getsect.h> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
75 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
76 #include "SDL_stdinc.h" |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
77 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
78 /* Just playing to see if it would compile with the freebsd headers, it does, |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
79 * but because of the different values for RTLD_LOCAL etc, it would break binary |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
80 * compat... oh well |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
81 */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
82 #ifndef __BSD_VISIBLE |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
83 #define __BSD_VISIBLE 1 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
84 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
86 /*include "dlfcn.h"*/ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
87 #ifdef __cplusplus |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
88 extern "C" |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
89 { |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
90 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
91 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
92 #if defined (__GNUC__) && __GNUC__ > 3 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
93 #define dl_restrict __restrict |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
94 #else |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
95 #define dl_restrict |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
96 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
97 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
98 #if 0 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
99 #ifndef _POSIX_SOURCE |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
100 /* |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 * Structure filled in by dladdr(). |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
103 typedef struct SDL_OSX_dl_info |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
104 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
105 const char *dli_fname; /* Pathname of shared object */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
106 void *dli_fbase; /* Base address of shared object */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
107 const char *dli_sname; /* Name of nearest symbol */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
108 void *dli_saddr; /* Address of nearest symbol */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
109 } SDL_OSX_Dl_info; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
111 static int SDL_OSX_dladdr(const void *dl_restrict, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
112 SDL_OSX_Dl_info * dl_restrict); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
113 #endif /* ! _POSIX_SOURCE */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
114 #endif /* 0 */ |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
116 static int SDL_OSX_dlclose(void *handle); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
117 static const char *SDL_OSX_dlerror(void); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
118 static void *SDL_OSX_dlopen(const char *path, int mode); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
119 static void *SDL_OSX_dlsym(void *dl_restrict handle, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
120 const char *dl_restrict symbol); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 #define RTLD_LAZY 0x1 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
123 #define RTLD_NOW 0x2 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 #define RTLD_LOCAL 0x4 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 #define RTLD_GLOBAL 0x8 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 #ifndef _POSIX_SOURCE |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
128 #define RTLD_NOLOAD 0x10 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
129 #define RTLD_NODELETE 0x80 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
130 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 /* |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 * Special handle arguments for SDL_OSX_dlsym(). |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
134 #define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
135 #define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
136 #endif /* ! _POSIX_SOURCE */ |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 #ifdef __cplusplus |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 #ifndef dl_restrict |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 #define dl_restrict __restrict |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 /* This is not available on 10.1 */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
146 #ifndef LC_LOAD_WEAK_DYLIB |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 #define LC_LOAD_WEAK_DYLIB (0x18 | LC_REQ_DYLD) |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
149 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
150 /* With this stuff here, this thing may actually compile/run on 10.0 systems |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
151 * Not that I have a 10.0 system to test it on anylonger |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
152 */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
153 #ifndef LC_REQ_DYLD |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
154 #define LC_REQ_DYLD 0x80000000 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
155 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
156 #ifndef NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
157 #define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED 0x4 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
158 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
159 #ifndef NSADDIMAGE_OPTION_RETURN_ON_ERROR |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
160 #define NSADDIMAGE_OPTION_RETURN_ON_ERROR 0x1 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 #ifndef NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 #define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND 0x0 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 #ifndef NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 #define NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR 0x4 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 /* These symbols will be looked for in dyld */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
169 static const struct mach_header *(*dyld_NSAddImage) (const char *, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
170 unsigned long) = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
171 static int (*dyld_NSIsSymbolNameDefinedInImage) (const struct mach_header *, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
172 const char *) = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
173 static NSSymbol(*dyld_NSLookupSymbolInImage) (const struct mach_header *, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
174 const char *, unsigned long) = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
175 0; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 /* Define this to make dlcompat reuse data block. This way in theory we save |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 * a little bit of overhead. However we then couldn't correctly catch excess |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 * calls to SDL_OSX_dlclose(). Hence we don't use this feature |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 #undef REUSE_STATUS |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 /* Size of the internal error message buffer (used by dlerror()) */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 #define ERR_STR_LEN 251 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 /* Maximum number of search paths supported by getSearchPath */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 #define MAX_SEARCH_PATHS 32 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 #define MAGIC_DYLIB_OFI ((NSObjectFileImage) 'DYOF') |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 #define MAGIC_DYLIB_MOD ((NSModule) 'DYMO') |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 /* internal flags */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 #define DL_IN_LIST 0x01 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 /* our mutex */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 static pthread_mutex_t dlcompat_mutex; |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 /* Our thread specific storage |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 static pthread_key_t dlerror_key; |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 struct dlthread |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
204 int lockcnt; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
205 unsigned char errset; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
206 char errstr[ERR_STR_LEN]; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 }; |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 /* This is our central data structure. Whenever a module is loaded via |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 * SDL_OSX_dlopen(), we create such a struct. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 struct dlstatus |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
214 struct dlstatus *next; /* pointer to next element in the linked list */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
215 NSModule module; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
216 const struct mach_header *lib; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
217 int refs; /* reference count */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
218 int mode; /* mode in which this module was loaded */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
219 dev_t device; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
220 ino_t inode; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
221 int flags; /* Any internal flags we may need */ |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 }; |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 /* Head node of the dlstatus list */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
225 static struct dlstatus mainStatus = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
226 { 0, MAGIC_DYLIB_MOD, NULL, -1, RTLD_GLOBAL, 0, 0, 0 }; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 static struct dlstatus *stqueue = &mainStatus; |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 /* Storage for the last error message (used by dlerror()) */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 /* static char err_str[ERR_STR_LEN]; */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 /* static int err_filled = 0; */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 /* Prototypes to internal functions */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 static void debug(const char *fmt, ...); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 static void error(const char *str, ...); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 static const char *safegetenv(const char *s); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
238 static const char *searchList(void); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 static const char *getSearchPath(int i); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 static const char *getFullPath(int i, const char *file); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 static const struct stat *findFile(const char *file, const char **fullPath); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 static int isValidStatus(struct dlstatus *status); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 static inline int isFlagSet(int mode, int flag); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 static struct dlstatus *lookupStatus(const struct stat *sbuf); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 static void insertStatus(struct dlstatus *dls, const struct stat *sbuf); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 static int promoteLocalToGlobal(struct dlstatus *dls); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 static void *reference(struct dlstatus *dls, int mode); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
248 static void *dlsymIntern(struct dlstatus *dls, const char *symbol, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
249 int canSetError); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 static struct dlstatus *allocStatus(void); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
251 static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
252 int mode); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
253 static NSSymbol search_linked_libs(const struct mach_header *mh, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
254 const char *symbol); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 static const char *get_lib_name(const struct mach_header *mh); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 static const struct mach_header *get_mach_header_from_NSModule(NSModule mod); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 static void dlcompat_init_func(void); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 static inline void dlcompat_init_check(void); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 static inline void dolock(void); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 static inline void dounlock(void); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 static void dlerrorfree(void *data); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 static void resetdlerror(void); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
263 static const struct mach_header *my_find_image(const char *name); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 static const struct mach_header *image_for_address(const void *address); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 static inline char *dyld_error_str(void); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 #if FINK_BUILD |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 /* Two Global Functions */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 static void *dlsym_prepend_underscore(void *handle, const char *symbol); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 static void *dlsym_auto_underscore(void *handle, const char *symbol); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 /* And their _intern counterparts */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
273 static void *dlsym_prepend_underscore_intern(void *handle, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
274 const char *symbol); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 static void *dlsym_auto_underscore_intern(void *handle, const char *symbol); |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 /* Functions */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
280 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
281 debug(const char *fmt, ...) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 { |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 #if DEBUG > 1 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
284 va_list arg; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
285 va_start(arg, fmt); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
286 fprintf(stderr, "DLDEBUG: "); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
287 vfprintf(stderr, fmt, arg); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
288 fprintf(stderr, "\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
289 fflush(stderr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
290 va_end(arg); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
294 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
295 error(const char *str, ...) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
297 va_list arg; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
298 struct dlthread *tss; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
299 char *err_str; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
300 va_start(arg, str); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
301 tss = pthread_getspecific(dlerror_key); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
302 err_str = tss->errstr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
303 SDL_strlcpy(err_str, "dlcompat: ", ERR_STR_LEN); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
304 vsnprintf(err_str + 10, ERR_STR_LEN - 10, str, arg); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
305 va_end(arg); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
306 debug("ERROR: %s\n", err_str); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
307 tss->errset = 1; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
310 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
311 warning(const char *str) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 { |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 #if DEBUG > 0 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
314 fprintf(stderr, "WARNING: dlcompat: %s\n", str); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
318 static const char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
319 safegetenv(const char *s) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
321 const char *ss = SDL_getenv(s); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
322 return ss ? ss : ""; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 /* because this is only used for debugging and error reporting functions, we |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 * don't really care about how elegant it is... it could use the load |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 * commands to find the install name of the library, but... |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
329 static const char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
330 get_lib_name(const struct mach_header *mh) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
332 unsigned long count = _dyld_image_count(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
333 unsigned long i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
334 const char *val = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
335 if (mh) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
336 for (i = 0; i < count; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
337 if (mh == _dyld_get_image_header(i)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
338 val = _dyld_get_image_name(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
339 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
340 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
341 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
342 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
343 return val; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 /* Returns the mach_header for the module bu going through all the loaded images |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
347 * and finding the one with the same name as the module. There really ought to be |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 * an api for doing this, would be faster, but there isn't one right now |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
350 static const struct mach_header * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
351 get_mach_header_from_NSModule(NSModule mod) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
353 const char *mod_name = NSNameOfModule(mod); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
354 const struct mach_header *mh = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
355 unsigned long count = _dyld_image_count(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
356 unsigned long i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
357 debug("Module name: %s", mod_name); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
358 for (i = 0; i < count; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
359 if (!SDL_strcmp(mod_name, _dyld_get_image_name(i))) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
360 mh = _dyld_get_image_header(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
361 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
362 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
363 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
364 return mh; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 /* Compute and return a list of all directories that we should search when |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 * trying to locate a module. We first look at the values of LD_LIBRARY_PATH |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 * and DYLD_LIBRARY_PATH, and then finally fall back to looking into |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 * /usr/lib and /lib. Since both of the environments variables can contain a |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 * list of colon seperated paths, we simply concat them and the two other paths |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
373 * into one big string, which we then can easily parse. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
374 * Splitting this string into the actual path list is done by getSearchPath() |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
376 static const char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
377 searchList() |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
379 size_t buf_size; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
380 static char *buf = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
381 const char *ldlp = safegetenv("LD_LIBRARY_PATH"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
382 const char *dyldlp = safegetenv("DYLD_LIBRARY_PATH"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
383 const char *stdpath = SDL_getenv("DYLD_FALLBACK_LIBRARY_PATH"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
384 if (!stdpath) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
385 stdpath = "/usr/local/lib:/lib:/usr/lib"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
386 if (!buf) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
387 buf_size = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
388 SDL_strlen(ldlp) + SDL_strlen(dyldlp) + SDL_strlen(stdpath) + 4; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
389 buf = SDL_malloc(buf_size); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
390 SDL_snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
391 (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""), |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
392 stdpath, '\0'); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
393 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
394 return buf; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
395 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
397 /* Returns the ith search path from the list as computed by searchList() */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
398 static const char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
399 getSearchPath(int i) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
400 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
401 static const char *list = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
402 static char **path = (char **) 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
403 static int end = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
404 static int numsize = MAX_SEARCH_PATHS; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
405 static char **tmp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
406 /* So we can call SDL_free() in the "destructor" we use i=-1 to return the alloc'd array */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
407 if (i == -1) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
408 return (const char *) path; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
409 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
410 if (!path) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
411 path = (char **) SDL_calloc(MAX_SEARCH_PATHS, sizeof(char **)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
412 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
413 if (!list && !end) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
414 list = searchList(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
415 if (i >= (numsize)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
416 debug("Increasing size for long PATH"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
417 tmp = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
418 (char **) SDL_calloc((MAX_SEARCH_PATHS + numsize), |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
419 sizeof(char **)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
420 if (tmp) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
421 SDL_memcpy(tmp, path, sizeof(char **) * numsize); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
422 SDL_free(path); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
423 path = tmp; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
424 numsize += MAX_SEARCH_PATHS; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
425 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
426 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
427 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
428 } |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
429 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
430 while (!path[i] && !end) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
431 path[i] = strsep((char **) &list, ":"); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
432 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
433 if (path[i][0] == 0) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
434 path[i] = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
435 end = (list == 0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
436 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
437 return path[i]; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
440 static const char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
441 getFullPath(int i, const char *file) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
443 static char buf[PATH_MAX]; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
444 const char *path = getSearchPath(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
445 if (path) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
446 SDL_snprintf(buf, PATH_MAX, "%s/%s", path, file); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
447 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
448 return path ? buf : 0; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 /* Given a file name, try to determine the full path for that file. Starts |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 * its search in the current directory, and then tries all paths in the |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
453 * search list in the order they are specified there. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
454 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
455 static const struct stat * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
456 findFile(const char *file, const char **fullPath) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
458 int i = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
459 static struct stat sbuf; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
460 char *fileName; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
461 debug("finding file %s", file); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
462 *fullPath = file; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
463 if (0 == stat(file, &sbuf)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
464 return &sbuf; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
465 if (SDL_strchr(file, '/')) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
466 return 0; /* If the path had a / we don't look in env var places */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
467 fileName = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
468 if (!fileName) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
469 fileName = (char *) file; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
470 while ((*fullPath = getFullPath(i++, fileName))) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
471 if (0 == stat(*fullPath, &sbuf)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
472 return &sbuf; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
473 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
474 ; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
475 return 0; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 /* Determine whether a given dlstatus is valid or not */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
479 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
480 isValidStatus(struct dlstatus *status) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
482 /* Walk the list to verify status is contained in it */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
483 struct dlstatus *dls = stqueue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
484 while (dls && status != dls) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
485 dls = dls->next; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
486 if (dls == 0) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
487 error("invalid handle"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
488 else if ((dls->module == 0) || (dls->refs == 0)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
489 error("handle to closed library"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
490 else |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
491 return TRUE; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
492 return FALSE; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
495 static inline int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
496 isFlagSet(int mode, int flag) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
497 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
498 return (mode & flag) == flag; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
499 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
500 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
501 static struct dlstatus * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
502 lookupStatus(const struct stat *sbuf) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
503 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
504 struct dlstatus *dls = stqueue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
505 debug("looking for status"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
506 while (dls && ( /* isFlagSet(dls->mode, RTLD_UNSHARED) */ 0 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
507 || sbuf->st_dev != dls->device |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
508 || sbuf->st_ino != dls->inode)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
509 dls = dls->next; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
510 return dls; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
511 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
512 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
513 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
514 insertStatus(struct dlstatus *dls, const struct stat *sbuf) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
515 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
516 debug("inserting status"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
517 dls->inode = sbuf->st_ino; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
518 dls->device = sbuf->st_dev; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
519 dls->refs = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
520 dls->mode = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
521 if ((dls->flags & DL_IN_LIST) == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
522 dls->next = stqueue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
523 stqueue = dls; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
524 dls->flags |= DL_IN_LIST; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
525 } |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
526 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
527 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
528 static struct dlstatus * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
529 allocStatus() |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
530 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
531 struct dlstatus *dls; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
532 #ifdef REUSE_STATUS |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
533 dls = stqueue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
534 while (dls && dls->module) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
535 dls = dls->next; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
536 if (!dls) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
537 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
538 dls = SDL_calloc(sizeof(*dls), 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
539 return dls; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
540 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
541 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
542 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
543 promoteLocalToGlobal(struct dlstatus *dls) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
544 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
545 static int (*p) (NSModule module) = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
546 debug("promoting"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
547 if (!p) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
548 _dyld_func_lookup("__dyld_NSMakePrivateModulePublic", (void **) &p); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
549 return (dls->module == MAGIC_DYLIB_MOD) || (p && p(dls->module)); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
550 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
551 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
552 static void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
553 reference(struct dlstatus *dls, int mode) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
554 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
555 if (dls) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
556 if (dls->module == MAGIC_DYLIB_MOD && isFlagSet(mode, RTLD_LOCAL)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
557 warning("trying to open a .dylib with RTLD_LOCAL"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
558 error("unable to open a .dylib with RTLD_LOCAL"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
559 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
560 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
561 if (isFlagSet(mode, RTLD_GLOBAL) && !isFlagSet(dls->mode, RTLD_GLOBAL) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
562 && !promoteLocalToGlobal(dls)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
563 error("unable to promote local module to global"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
564 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
565 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
566 dls->mode |= mode; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
567 dls->refs++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
568 } else |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
569 debug("reference called with NULL argument"); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
570 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
571 return dls; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
572 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
573 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
574 static const struct mach_header * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
575 my_find_image(const char *name) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
576 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
577 const struct mach_header *mh = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
578 const char *id = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
579 int i = _dyld_image_count(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
580 int j; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
581 mh = (struct mach_header *) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
582 dyld_NSAddImage(name, NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
583 NSADDIMAGE_OPTION_RETURN_ON_ERROR); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
584 if (!mh) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
585 for (j = 0; j < i; j++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
586 id = _dyld_get_image_name(j); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
587 if (!SDL_strcmp(id, name)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
588 mh = _dyld_get_image_header(j); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
589 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
590 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
591 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
592 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
593 return mh; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
594 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
595 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
596 /* |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
597 * dyld adds libraries by first adding the directly dependant libraries in link order, and |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
598 * then adding the dependencies for those libraries, so we should do the same... but we don't |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
599 * bother adding the extra dependencies, if the symbols are neither in the loaded image nor |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
600 * any of it's direct dependencies, then it probably isn't there. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
601 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
602 static NSSymbol |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
603 search_linked_libs(const struct mach_header *mh, const char *symbol) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
604 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
605 unsigned int n; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
606 struct load_command *lc = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
607 struct mach_header *wh; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
608 NSSymbol nssym = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
609 if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
610 && dyld_NSLookupSymbolInImage) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
611 lc = (struct load_command *) ((char *) mh + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
612 sizeof(struct mach_header)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
613 for (n = 0; n < mh->ncmds; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
614 n++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
615 if ((LC_LOAD_DYLIB == lc->cmd) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
616 || (LC_LOAD_WEAK_DYLIB == lc->cmd)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
617 if ((wh = (struct mach_header *) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
618 my_find_image((char |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
619 *) (((struct dylib_command *) lc)->dylib. |
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
620 name.offset + (char *) lc)))) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
621 if (dyld_NSIsSymbolNameDefinedInImage(wh, symbol)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
622 nssym = dyld_NSLookupSymbolInImage(wh, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
623 symbol, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
624 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
625 | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
626 NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
627 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
628 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
629 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
630 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
631 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
632 if ((!nssym) && NSIsSymbolNameDefined(symbol)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
633 /* I've never seen this debug message... */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
634 debug("Symbol \"%s\" is defined but was not found", symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
635 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
636 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
637 return nssym; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
638 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
639 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
640 /* Up to the caller to SDL_free() returned string */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
641 static inline char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
642 dyld_error_str() |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
643 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
644 NSLinkEditErrors dylder; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
645 int dylderno; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
646 const char *dylderrstr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
647 const char *dyldfile; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
648 char *retStr = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
649 NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
650 if (dylderrstr && *dylderrstr) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
651 retStr = SDL_strdup(dylderrstr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
652 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
653 return retStr; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
654 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
655 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
656 static void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
657 dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetError) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
658 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
659 NSSymbol nssym = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
660 #ifdef __GCC__ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
661 void *caller = __builtin_return_address(1); /* Be *very* careful about inlining */ |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
662 #else |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
663 void *caller = NULL; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
664 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
665 const struct mach_header *caller_mh = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
666 char *savedErrorStr = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
667 resetdlerror(); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
668 #ifndef RTLD_SELF |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
669 #define RTLD_SELF ((void *) -3) |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
670 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
671 if (NULL == dls) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
672 dls = RTLD_SELF; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
673 if ((RTLD_NEXT == dls) || (RTLD_SELF == dls)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
674 if (dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
675 && caller) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
676 caller_mh = image_for_address(caller); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
677 if (RTLD_SELF == dls) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
678 /* FIXME: We should be using the NSModule api, if SELF is an MH_BUNDLE |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
679 * But it appears to work anyway, and looking at the code in dyld_libfuncs.c |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
680 * this is acceptable. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
681 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
682 if (dyld_NSIsSymbolNameDefinedInImage(caller_mh, symbol)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
683 nssym = dyld_NSLookupSymbolInImage(caller_mh, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
684 symbol, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
685 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
686 | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
687 NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
688 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
689 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
690 if (!nssym) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
691 if (RTLD_SELF == dls) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
692 savedErrorStr = dyld_error_str(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
693 nssym = search_linked_libs(caller_mh, symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
694 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
695 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
696 if (canSetError) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
697 error("RTLD_SELF and RTLD_NEXT are not supported"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
698 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
699 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
700 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
701 if (!nssym) { |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
702 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
703 if (RTLD_DEFAULT == dls) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
704 dls = &mainStatus; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
705 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
706 if (!isValidStatus(dls)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
707 return NULL; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
708 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
709 if (dls->module != MAGIC_DYLIB_MOD) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
710 nssym = NSLookupSymbolInModule(dls->module, symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
711 if (!nssym && NSIsSymbolNameDefined(symbol)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
712 debug("Searching dependencies"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
713 savedErrorStr = dyld_error_str(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
714 nssym = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
715 search_linked_libs(get_mach_header_from_NSModule |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
716 (dls->module), symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
717 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
718 } else if (dls->lib && dyld_NSIsSymbolNameDefinedInImage |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
719 && dyld_NSLookupSymbolInImage) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
720 if (dyld_NSIsSymbolNameDefinedInImage(dls->lib, symbol)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
721 nssym = dyld_NSLookupSymbolInImage(dls->lib, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
722 symbol, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
723 NSLOOKUPSYMBOLINIMAGE_OPTION_BIND |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
724 | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
725 NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
726 } else if (NSIsSymbolNameDefined(symbol)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
727 debug("Searching dependencies"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
728 savedErrorStr = dyld_error_str(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
729 nssym = search_linked_libs(dls->lib, symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
730 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
731 } else if (dls->module == MAGIC_DYLIB_MOD) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
732 /* Global context, use NSLookupAndBindSymbol */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
733 if (NSIsSymbolNameDefined(symbol)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
734 /* There doesn't seem to be a return on error option for this call??? |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
735 this is potentially broken, if binding fails, it will improperly |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
736 exit the application. */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
737 nssym = NSLookupAndBindSymbol(symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
738 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
739 if (savedErrorStr) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
740 SDL_free(savedErrorStr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
741 savedErrorStr = SDL_malloc(256); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
742 SDL_snprintf(savedErrorStr, 256, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
743 "Symbol \"%s\" not in global context", symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
744 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
745 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
746 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
747 /* Error reporting */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
748 if (!nssym) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
749 if (!savedErrorStr || !SDL_strlen(savedErrorStr)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
750 if (savedErrorStr) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
751 SDL_free(savedErrorStr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
752 savedErrorStr = SDL_malloc(256); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
753 SDL_snprintf(savedErrorStr, 256, "Symbol \"%s\" not found", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
754 symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
755 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
756 if (canSetError) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
757 error(savedErrorStr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
758 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
759 debug(savedErrorStr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
760 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
761 if (savedErrorStr) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
762 SDL_free(savedErrorStr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
763 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
764 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
765 return NSAddressOfSymbol(nssym); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
766 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
767 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
768 static struct dlstatus * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
769 loadModule(const char *path, const struct stat *sbuf, int mode) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
770 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
771 NSObjectFileImage ofi = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
772 NSObjectFileImageReturnCode ofirc; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
773 struct dlstatus *dls; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
774 NSLinkEditErrors ler; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
775 int lerno; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
776 const char *errstr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
777 const char *file; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
778 void (*init) (void); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
779 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
780 ofirc = NSCreateObjectFileImageFromFile(path, &ofi); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
781 switch (ofirc) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
782 case NSObjectFileImageSuccess: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
783 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
784 case NSObjectFileImageInappropriateFile: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
785 if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
786 && dyld_NSLookupSymbolInImage) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
787 if (isFlagSet(mode, RTLD_LOCAL)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
788 warning("trying to open a .dylib with RTLD_LOCAL"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
789 error("unable to open this file with RTLD_LOCAL"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
790 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
791 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
792 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
793 error("opening this file is unsupported on this system"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
794 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
795 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
796 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
797 case NSObjectFileImageFailure: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
798 error("object file setup failure"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
799 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
800 case NSObjectFileImageArch: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
801 error("no object for this architecture"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
802 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
803 case NSObjectFileImageFormat: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
804 error("bad object file format"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
805 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
806 case NSObjectFileImageAccess: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
807 error("can't read object file"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
808 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
809 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
810 error("unknown error from NSCreateObjectFileImageFromFile()"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
811 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
812 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
813 dls = lookupStatus(sbuf); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
814 if (!dls) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
815 dls = allocStatus(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
816 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
817 if (!dls) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
818 error("unable to allocate memory"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
819 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
820 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
821 // dls->lib = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
822 if (ofirc == NSObjectFileImageInappropriateFile) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
823 if ((dls->lib = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
824 dyld_NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR))) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
825 debug("Dynamic lib loaded at %ld", dls->lib); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
826 ofi = MAGIC_DYLIB_OFI; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
827 dls->module = MAGIC_DYLIB_MOD; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
828 ofirc = NSObjectFileImageSuccess; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
829 /* Although it is possible with a bit of work to modify this so it works and |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
830 functions with RTLD_NOW, I don't deem it necessary at the moment */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
831 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
832 if (!(dls->module)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
833 NSLinkEditError(&ler, &lerno, &file, &errstr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
834 if (!errstr || (!SDL_strlen(errstr))) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
835 error("Can't open this file type"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
836 else |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
837 error(errstr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
838 if ((dls->flags & DL_IN_LIST) == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
839 SDL_free(dls); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
840 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
841 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
842 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
843 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
844 dls->module = NSLinkModule(ofi, path, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
845 NSLINKMODULE_OPTION_RETURN_ON_ERROR | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
846 NSLINKMODULE_OPTION_PRIVATE | |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
847 (isFlagSet(mode, RTLD_NOW) ? |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
848 NSLINKMODULE_OPTION_BINDNOW : 0)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
849 NSDestroyObjectFileImage(ofi); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
850 if (dls->module) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
851 dls->lib = get_mach_header_from_NSModule(dls->module); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
852 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
853 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
854 if (!dls->module) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
855 NSLinkEditError(&ler, &lerno, &file, &errstr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
856 if ((dls->flags & DL_IN_LIST) == 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
857 SDL_free(dls); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
858 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
859 error(errstr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
860 return NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
861 } |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
862 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
863 insertStatus(dls, sbuf); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
864 dls = reference(dls, mode); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
865 if ((init = dlsymIntern(dls, "__init", 0))) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
866 debug("calling _init()"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
867 init(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
868 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
869 return dls; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
870 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
871 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
872 inline static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
873 dlcompat_init_check(void) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
874 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
875 static pthread_mutex_t l = PTHREAD_MUTEX_INITIALIZER; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
876 static int init_done = 0; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
877 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
878 pthread_mutex_lock(&l); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
879 if (!init_done) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
880 dlcompat_init_func(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
881 init_done = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
882 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
883 pthread_mutex_unlock(&l); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
884 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
885 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
886 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
887 dlcompat_init_func(void) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
888 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
889 _dyld_func_lookup("__dyld_NSAddImage", (void **) &dyld_NSAddImage); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
890 _dyld_func_lookup("__dyld_NSIsSymbolNameDefinedInImage", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
891 (void **) &dyld_NSIsSymbolNameDefinedInImage); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
892 _dyld_func_lookup("__dyld_NSLookupSymbolInImage", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
893 (void **) &dyld_NSLookupSymbolInImage); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
894 if (pthread_mutex_init(&dlcompat_mutex, NULL)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
895 exit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
896 if (pthread_key_create(&dlerror_key, &dlerrorfree)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
897 exit(1); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
898 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
899 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
900 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
901 resetdlerror() |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
902 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
903 struct dlthread *tss; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
904 tss = pthread_getspecific(dlerror_key); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
905 tss->errset = 0; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
906 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
907 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
908 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
909 dlerrorfree(void *data) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
910 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
911 SDL_free(data); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
912 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
913 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
914 /* We kind of want a recursive lock here, but meet a little trouble |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
915 * because they are not available pre OS X 10.2, so we fake it |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
916 * using thread specific storage to keep a lock count |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
917 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
918 static inline void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
919 dolock(void) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
920 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
921 int err = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
922 struct dlthread *tss; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
923 dlcompat_init_check(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
924 tss = pthread_getspecific(dlerror_key); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
925 if (!tss) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
926 tss = SDL_malloc(sizeof(struct dlthread)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
927 tss->lockcnt = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
928 tss->errset = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
929 if (pthread_setspecific(dlerror_key, tss)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
930 fprintf(stderr, "dlcompat: pthread_setspecific failed\n"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
931 exit(1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
932 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
933 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
934 if (!tss->lockcnt) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
935 err = pthread_mutex_lock(&dlcompat_mutex); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
936 tss->lockcnt = tss->lockcnt + 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
937 if (err) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
938 exit(err); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
939 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
940 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
941 static inline void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
942 dounlock(void) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
943 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
944 int err = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
945 struct dlthread *tss; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
946 tss = pthread_getspecific(dlerror_key); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
947 tss->lockcnt = tss->lockcnt - 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
948 if (!tss->lockcnt) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
949 err = pthread_mutex_unlock(&dlcompat_mutex); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
950 if (err) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
951 exit(err); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
952 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
953 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
954 static void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
955 SDL_OSX_dlopen(const char *path, int mode) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
956 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
957 const struct stat *sbuf; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
958 struct dlstatus *dls; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
959 const char *fullPath; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
960 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
961 dolock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
962 resetdlerror(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
963 if (!path) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
964 dls = &mainStatus; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
965 goto dlopenok; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
966 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
967 if (!(sbuf = findFile(path, &fullPath))) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
968 error("file \"%s\" not found", path); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
969 goto dlopenerror; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
970 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
971 /* Now checks that it hasn't been closed already */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
972 if ((dls = lookupStatus(sbuf)) && (dls->refs > 0)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
973 /* debug("status found"); */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
974 dls = reference(dls, mode); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
975 goto dlopenok; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
976 } |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
977 #ifdef RTLD_NOLOAD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
978 if (isFlagSet(mode, RTLD_NOLOAD)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
979 error("no existing handle and RTLD_NOLOAD specified"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
980 goto dlopenerror; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
981 } |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
982 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
983 if (isFlagSet(mode, RTLD_LAZY) && isFlagSet(mode, RTLD_NOW)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
984 error("how can I load something both RTLD_LAZY and RTLD_NOW?"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
985 goto dlopenerror; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
986 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
987 dls = loadModule(fullPath, sbuf, mode); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
988 |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
989 dlopenok: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
990 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
991 return (void *) dls; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
992 dlopenerror: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
993 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
994 return NULL; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
995 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
996 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
997 #if !FINK_BUILD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
998 static void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
999 SDL_OSX_dlsym(void *dl_restrict handle, const char *dl_restrict symbol) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1000 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1001 int sym_len = SDL_strlen(symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1002 void *value = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1003 char *malloc_sym = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1004 dolock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1005 malloc_sym = SDL_malloc(sym_len + 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1006 if (malloc_sym) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1007 SDL_snprintf(malloc_sym, sym_len + 2, "_%s", symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1008 value = dlsymIntern(handle, malloc_sym, 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1009 SDL_free(malloc_sym); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1010 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1011 error("Unable to allocate memory"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1012 goto dlsymerror; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1013 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1014 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1015 return value; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1016 dlsymerror: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1017 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1018 return NULL; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1019 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1020 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1021 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1022 #if FINK_BUILD |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1023 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1024 static void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1025 dlsym_prepend_underscore(void *handle, const char *symbol) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1026 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1027 void *answer; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1028 dolock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1029 answer = dlsym_prepend_underscore_intern(handle, symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1030 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1031 return answer; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1032 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1033 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1034 static void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1035 dlsym_prepend_underscore_intern(void *handle, const char *symbol) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1036 { |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1037 /* |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1038 * A quick and easy way for porting packages which call dlsym(handle,"sym") |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1039 * If the porter adds -Ddlsym=dlsym_prepend_underscore to the CFLAGS then |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1040 * this function will be called, and will add the required underscore. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1041 * |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1042 * Note that I haven't figured out yet which should be "standard", prepend |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1043 * the underscore always, or not at all. These global functions need to go away |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1044 * for opendarwin. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1045 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1046 int sym_len = SDL_strlen(symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1047 void *value = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1048 char *malloc_sym = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1049 malloc_sym = SDL_malloc(sym_len + 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1050 if (malloc_sym) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1051 SDL_snprintf(malloc_sym, sym_len + 2, "_%s", symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1052 value = dlsymIntern(handle, malloc_sym, 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1053 SDL_free(malloc_sym); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1054 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1055 error("Unable to allocate memory"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1056 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1057 return value; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1058 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1059 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1060 static void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1061 dlsym_auto_underscore(void *handle, const char *symbol) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1062 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1063 void *answer; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1064 dolock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1065 answer = dlsym_auto_underscore_intern(handle, symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1066 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1067 return answer; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1068 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1069 } |
2735
204be4fc2726
Final merge of Google Summer of Code 2008 work...
Sam Lantinga <slouken@libsdl.org>
parents:
1895
diff
changeset
|
1070 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1071 static void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1072 dlsym_auto_underscore_intern(void *handle, const char *symbol) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1073 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1074 struct dlstatus *dls = handle; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1075 void *addr = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1076 addr = dlsymIntern(dls, symbol, 0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1077 if (!addr) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1078 addr = dlsym_prepend_underscore_intern(handle, symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1079 return addr; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1080 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1081 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1082 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1083 static void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1084 SDL_OSX_dlsym(void *dl_restrict handle, const char *dl_restrict symbol) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1085 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1086 struct dlstatus *dls = handle; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1087 void *addr = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1088 dolock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1089 addr = dlsymIntern(dls, symbol, 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1090 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1091 return addr; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1092 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1093 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1094 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1095 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1096 SDL_OSX_dlclose(void *handle) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1097 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1098 struct dlstatus *dls = handle; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1099 dolock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1100 resetdlerror(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1101 if (!isValidStatus(dls)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1102 goto dlcloseerror; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1103 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1104 if (dls->module == MAGIC_DYLIB_MOD) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1105 const char *name; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1106 if (!dls->lib) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1107 name = "global context"; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1108 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1109 name = get_lib_name(dls->lib); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1110 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1111 warning("trying to close a .dylib!"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1112 error("Not closing \"%s\" - dynamic libraries cannot be closed", |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1113 name); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1114 goto dlcloseerror; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1115 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1116 if (!dls->module) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1117 error("module already closed"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1118 goto dlcloseerror; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1119 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1120 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1121 if (dls->refs == 1) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1122 unsigned long options = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1123 void (*fini) (void); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1124 if ((fini = dlsymIntern(dls, "__fini", 0))) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1125 debug("calling _fini()"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1126 fini(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1127 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1128 options |= NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1129 #ifdef RTLD_NODELETE |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1130 if (isFlagSet(dls->mode, RTLD_NODELETE)) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1131 options |= NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1132 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1133 if (!NSUnLinkModule(dls->module, options)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1134 error("unable to unlink module"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1135 goto dlcloseerror; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1136 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1137 dls->refs--; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1138 dls->module = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1139 /* Note: the dlstatus struct dls is neither removed from the list |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1140 * nor is the memory it occupies freed. This shouldn't pose a |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1141 * problem in mostly all cases, though. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1142 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1143 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1144 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1145 return 0; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1146 dlcloseerror: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1147 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1148 return 1; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1149 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1150 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1151 static const char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1152 SDL_OSX_dlerror(void) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1153 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1154 struct dlthread *tss; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1155 const char *err_str = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1156 dlcompat_init_check(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1157 tss = pthread_getspecific(dlerror_key); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1158 if (tss != NULL && tss->errset != 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1159 tss->errset = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1160 err_str = tss->errstr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1161 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1162 return (err_str); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1163 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1164 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1165 /* Given an address, return the mach_header for the image containing it |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1166 * or zero if the given address is not contained in any loaded images. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1167 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1168 static const struct mach_header * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1169 image_for_address(const void *address) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1170 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1171 unsigned long i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1172 unsigned long j; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1173 unsigned long count = _dyld_image_count(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1174 const struct mach_header *mh = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1175 struct load_command *lc = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1176 unsigned long addr = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1177 for (i = 0; i < count; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1178 addr = (unsigned long) address - _dyld_get_image_vmaddr_slide(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1179 mh = _dyld_get_image_header(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1180 if (mh) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1181 lc = (struct load_command *) ((char *) mh + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1182 sizeof(struct mach_header)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1183 for (j = 0; j < mh->ncmds; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1184 j++, lc = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1185 (struct load_command *) ((char *) lc + lc->cmdsize)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1186 if (LC_SEGMENT == lc->cmd && |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1187 addr >= ((struct segment_command *) lc)->vmaddr && |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1188 addr < |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1189 ((struct segment_command *) lc)->vmaddr + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1190 ((struct segment_command *) lc)->vmsize) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1191 goto image_found; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1192 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1193 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1194 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1195 mh = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1196 } |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1197 image_found: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1198 return mh; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1199 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1200 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1201 #if 0 /* unused */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1202 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1203 SDL_OSX_dladdr(const void *dl_restrict p, SDL_OSX_Dl_info * dl_restrict info) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1204 { |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1205 /* |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1206 FIXME: USe the routine image_for_address. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1207 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1208 unsigned long i; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1209 unsigned long j; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1210 unsigned long count = _dyld_image_count(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1211 struct mach_header *mh = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1212 struct load_command *lc = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1213 unsigned long addr = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1214 unsigned long table_off = (unsigned long) 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1215 int found = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1216 if (!info) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1217 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1218 dolock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1219 resetdlerror(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1220 info->dli_fname = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1221 info->dli_fbase = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1222 info->dli_sname = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1223 info->dli_saddr = 0; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1224 /* Some of this was swiped from code posted by Douglas Davidson <ddavidso AT apple DOT com> |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1225 * to darwin-development AT lists DOT apple DOT com and slightly modified |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1226 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1227 for (i = 0; i < count; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1228 addr = (unsigned long) p - _dyld_get_image_vmaddr_slide(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1229 mh = _dyld_get_image_header(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1230 if (mh) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1231 lc = (struct load_command *) ((char *) mh + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1232 sizeof(struct mach_header)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1233 for (j = 0; j < mh->ncmds; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1234 j++, lc = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1235 (struct load_command *) ((char *) lc + lc->cmdsize)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1236 if (LC_SEGMENT == lc->cmd && |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1237 addr >= ((struct segment_command *) lc)->vmaddr && |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1238 addr < |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1239 ((struct segment_command *) lc)->vmaddr + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1240 ((struct segment_command *) lc)->vmsize) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1241 info->dli_fname = _dyld_get_image_name(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1242 info->dli_fbase = (void *) mh; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1243 found = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1244 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1245 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1246 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1247 if (found) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1248 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1249 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1250 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1251 if (!found) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1252 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1253 return 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1254 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1255 lc = (struct load_command *) ((char *) mh + sizeof(struct mach_header)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1256 for (j = 0; j < mh->ncmds; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1257 j++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1258 if (LC_SEGMENT == lc->cmd) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1259 if (!SDL_strcmp |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1260 (((struct segment_command *) lc)->segname, "__LINKEDIT")) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1261 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1262 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1263 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1264 table_off = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1265 ((unsigned long) ((struct segment_command *) lc)->vmaddr) - |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1266 ((unsigned long) ((struct segment_command *) lc)->fileoff) + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1267 _dyld_get_image_vmaddr_slide(i); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1268 debug("table off %x", table_off); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1269 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1270 lc = (struct load_command *) ((char *) mh + sizeof(struct mach_header)); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1271 for (j = 0; j < mh->ncmds; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1272 j++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1273 if (LC_SYMTAB == lc->cmd) { |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1274 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1275 struct nlist *symtable = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1276 (struct nlist *) (((struct symtab_command *) lc)->symoff + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1277 table_off); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1278 unsigned long numsyms = ((struct symtab_command *) lc)->nsyms; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1279 struct nlist *nearest = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1280 unsigned long diff = 0xffffffff; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1281 unsigned long strtable = |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1282 (unsigned long) (((struct symtab_command *) lc)->stroff + |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1283 table_off); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1284 debug("symtable %x", symtable); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1285 for (i = 0; i < numsyms; i++) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1286 /* Ignore the following kinds of Symbols */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1287 if ((!symtable->n_value) /* Undefined */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1288 ||(symtable->n_type >= N_PEXT) /* Debug symbol */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1289 ||(!(symtable->n_type & N_EXT)) /* Local Symbol */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1290 ) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1291 symtable++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1292 continue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1293 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1294 if ((addr >= symtable->n_value) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1295 && (diff >= (symtable->n_value - addr))) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1296 diff = (unsigned long) symtable->n_value - addr; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1297 nearest = symtable; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1298 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1299 symtable++; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1300 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1301 if (nearest) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1302 info->dli_saddr = nearest->n_value + ((void *) p - addr); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1303 info->dli_sname = (char *) (strtable + nearest->n_un.n_strx); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1304 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1305 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1306 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1307 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1308 return 1; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1309 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1310 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1311 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1312 /* |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1313 * Implement the dlfunc() interface, which behaves exactly the same as |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1314 * dlsym() except that it returns a function pointer instead of a data |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1315 * pointer. This can be used by applications to avoid compiler warnings |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1316 * about undefined behavior, and is intended as prior art for future |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1317 * POSIX standardization. This function requires that all pointer types |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1318 * have the same representation, which is true on all platforms FreeBSD |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1319 * runs on, but is not guaranteed by the C standard. |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1320 */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1321 #if 0 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1322 static dlfunc_t |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1323 SDL_OSX_dlfunc(void *dl_restrict handle, const char *dl_restrict symbol) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1324 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1325 union |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1326 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1327 void *d; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1328 dlfunc_t f; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1329 } rv; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1330 int sym_len = SDL_strlen(symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1331 char *malloc_sym = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1332 dolock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1333 malloc_sym = SDL_malloc(sym_len + 2); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1334 if (malloc_sym) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1335 SDL_snprintf(malloc_sym, sym_len + 2, "_%s", symbol); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1336 rv.d = dlsymIntern(handle, malloc_sym, 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1337 SDL_free(malloc_sym); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1338 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1339 error("Unable to allocate memory"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1340 goto dlfuncerror; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1341 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1342 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1343 return rv.f; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1344 dlfuncerror: |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1345 dounlock(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1346 return NULL; |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1347 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1348 #endif |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1349 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1350 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1351 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1352 /* dlcompat ends, here's the SDL interface... --ryan. */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1353 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1354 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1355 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1356 /* System dependent library loading routines */ |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1357 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1358 #include "SDL_loadso.h" |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1359 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1360 void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1361 SDL_LoadObject(const char *sofile) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1362 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1363 void *handle = SDL_OSX_dlopen(sofile, RTLD_NOW); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1364 const char *loaderror = SDL_OSX_dlerror(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1365 if (handle == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1366 SDL_SetError("Failed loading %s: %s", sofile, loaderror); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1367 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1368 return (handle); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1369 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1370 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1371 void * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1372 SDL_LoadFunction(void *handle, const char *name) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1373 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1374 void *symbol = SDL_OSX_dlsym(handle, name); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1375 if (symbol == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1376 SDL_SetError("Failed loading %s: %s", name, SDL_OSX_dlerror()); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1377 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1378 return (symbol); |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1379 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1380 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1381 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1382 SDL_UnloadObject(void *handle) |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1383 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1384 if (handle != NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1385 SDL_OSX_dlclose(handle); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1386 } |
1801
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1387 } |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1388 |
e308d020d315
Xcode has trouble compiling different files with the same name for two architectures
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1389 #endif /* SDL_LOADSO_DLCOMPAT */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1801
diff
changeset
|
1390 /* vi: set ts=4 sw=4 expandtab: */ |