]>
Commit | Line | Data |
---|---|---|
e9ce8d39 A |
1 | /* |
2 | * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
6 | * The contents of this file constitute Original Code as defined in and | |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
11 | * | |
12 | * This Original Code and all software distributed under the License are | |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, | |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the | |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
19 | * | |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | ** This file contains interfaces to the symbols defined int the crt modules. | |
24 | ** 3 April 1995 | |
25 | ** Matt Watson (mwatson@next.com) | |
26 | ** | |
27 | */ | |
28 | ||
29 | #if defined(__DYNAMIC__) | |
30 | #include "mach-o/dyld.h" /* defines _dyld_lookup_and_bind() */ | |
31 | #define STRINGIFY(a) # a | |
32 | #define DECLARE_VAR(var, type) \ | |
33 | static type * var ## _pointer = 0 | |
34 | #define SETUP_VAR(var) \ | |
35 | if ( var ## _pointer == 0) { \ | |
36 | _dyld_lookup_and_bind( STRINGIFY(_ ## var), \ | |
37 | (unsigned long *) & var ## _pointer, 0); \ | |
38 | } | |
39 | #define USE_VAR(var) (var ## _pointer) | |
40 | #else | |
41 | #define DECLARE_VAR(var, type) extern type var | |
42 | #define SETUP_VAR(var) | |
43 | #define USE_VAR(var) (& var) | |
44 | #endif | |
45 | ||
46 | char ***_NSGetArgv(void) { | |
47 | DECLARE_VAR(NXArgv, char **); | |
48 | SETUP_VAR(NXArgv); | |
49 | return(USE_VAR(NXArgv)); | |
50 | } | |
51 | ||
52 | int *_NSGetArgc(void) { | |
53 | DECLARE_VAR(NXArgc, int); | |
54 | SETUP_VAR(NXArgc); | |
55 | return(USE_VAR(NXArgc)); | |
56 | } | |
57 | ||
58 | char ***_NSGetEnviron(void) { | |
59 | DECLARE_VAR(environ, char **); | |
60 | SETUP_VAR(environ); | |
61 | return(USE_VAR(environ)); | |
62 | } | |
63 | ||
5b2abdfb A |
64 | char **_NSGetProgname(void) { |
65 | DECLARE_VAR(__progname, char *); | |
66 | SETUP_VAR(__progname); | |
67 | return(USE_VAR(__progname)); | |
68 | } | |
69 | ||
e9ce8d39 A |
70 | struct mach_header *_NSGetMachExecuteHeader(void) { |
71 | DECLARE_VAR(_mh_execute_header, struct mach_header); | |
72 | SETUP_VAR(_mh_execute_header); | |
73 | return(USE_VAR(_mh_execute_header)); | |
74 | } | |
75 | ||
76 | /* | |
77 | * Fix for Radar bug 2200596 -- | |
78 | * EH symbol definitions for gcc 2.7.2.x implementation of | |
79 | * C++ exception handling. The problem: the EH implementation | |
80 | * has "throw" store stuff into these pointers, and then as the | |
81 | * stack is unwound, the code generated into each function (for | |
82 | * checking whether this function contains a relevant "catch" | |
83 | * clause and for calling destructors for local variables) looks | |
84 | * at these globals to find the type and value thrown. | |
85 | * | |
86 | * The problem was that the compiler generated the symbols as | |
87 | * "common" symbols, and common symbols cannot be placed in | |
88 | * dynamic shared libraries. So we must put these guys as | |
89 | * "data" symbols into crt0.o or the System Framework (library), | |
90 | * and the compiler must generate code that defines the symbols | |
91 | * as external references instead of common. | |
92 | * | |
93 | * I changed the symbol names (added the "_272") to be utterly | |
94 | * paranoid about any possible future use of similar names by | |
95 | * any future versions of gcc. | |
96 | * -- D. Landauer, Jan. 1998 | |
97 | */ | |
98 | ||
99 | void *__eh_pc_gcc_272 = (void *)0; | |
100 | void *__eh_type_gcc_272 = (void *)0; | |
101 | void *__eh_value_gcc_272 = (void *)0; | |
102 | ||
103 | /* This is what egcs uses for its global data pointer */ | |
104 | void *__eh_global_dataptr = (void *)0; | |
105 | ||
106 | void *__keymgr_global[3] = { (void *)0 }; |