11bc0e688031a13ad968aacbee4eb0b2e4145a6f
[ghc.git] / rts / RtsSymbols.c
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 2000-2015
4 *
5 * RTS Symbols
6 *
7 * ---------------------------------------------------------------------------*/
8
9 #include "ghcplatform.h"
10 #include "RtsSymbols.h"
11
12 #include "Rts.h"
13 #include "HsFFI.h"
14
15 #include "sm/Storage.h"
16
17 #if !defined(mingw32_HOST_OS)
18 #include "posix/Signals.h"
19 #endif
20
21 #if defined(mingw32_HOST_OS)
22 #include <sys/stat.h>
23 #include <io.h>
24 #include <windows.h>
25 #include <shfolder.h> /* SHGetFolderPathW */
26 #endif
27
28 /* -----------------------------------------------------------------------------
29 * Symbols to be inserted into the RTS symbol table.
30 */
31
32 #define Maybe_Stable_Names SymI_HasProto(stg_mkWeakzh) \
33 SymI_HasProto(stg_mkWeakNoFinalizzerzh) \
34 SymI_HasProto(stg_addCFinalizzerToWeakzh) \
35 SymI_HasProto(stg_makeStableNamezh) \
36 SymI_HasProto(stg_finalizzeWeakzh)
37
38 #define RTS_LIBDW_SYMBOLS \
39 SymE_HasProto(backtraceFree) \
40 SymE_HasProto(libdwGetBacktrace) \
41 SymE_HasProto(libdwLookupLocation) \
42 SymE_HasProto(libdwPoolTake) \
43 SymE_HasProto(libdwPoolRelease) \
44 SymE_HasProto(libdwPoolClear)
45
46 #if !defined (mingw32_HOST_OS)
47 #define RTS_POSIX_ONLY_SYMBOLS \
48 SymI_HasProto(__hscore_get_saved_termios) \
49 SymI_HasProto(__hscore_set_saved_termios) \
50 SymI_HasProto(shutdownHaskellAndSignal) \
51 SymI_HasProto(signal_handlers) \
52 SymI_HasProto(stg_sig_install) \
53 SymI_HasProto(rtsTimerSignal) \
54 SymI_HasProto(atexit) \
55 SymI_NeedsDataProto(nocldstop)
56 #endif
57
58 #if defined(mingw32_HOST_OS)
59 #define RTS_POSIX_ONLY_SYMBOLS /**/
60
61 #if defined(i386_HOST_ARCH)
62 #define RTS_WIN32_ONLY(X) X
63 #else
64 #define RTS_WIN32_ONLY(X) /**/
65 #endif
66
67 #if defined(x86_64_HOST_ARCH)
68 #define RTS_WIN64_ONLY(X) X
69 #else
70 #define RTS_WIN64_ONLY(X) /**/
71 #endif
72
73 #define RTS_MINGW_ONLY_SYMBOLS \
74 SymI_HasProto(stg_asyncReadzh) \
75 SymI_HasProto(stg_asyncWritezh) \
76 SymI_HasProto(stg_asyncDoProczh) \
77 SymI_HasProto(getWin32ProgArgv) \
78 SymI_HasProto(setWin32ProgArgv) \
79 SymI_HasProto(rts_InstallConsoleEvent) \
80 SymI_HasProto(rts_ConsoleHandlerDone) \
81 SymI_HasProto(atexit) \
82 RTS_WIN32_ONLY(SymI_NeedsProto(__chkstk_ms)) \
83 RTS_WIN64_ONLY(SymI_NeedsProto(___chkstk_ms)) \
84 RTS_WIN32_ONLY(SymI_HasProto(_imp___environ)) \
85 RTS_WIN64_ONLY(SymI_HasProto(__imp__environ)) \
86 RTS_WIN32_ONLY(SymI_HasProto(_imp___iob)) \
87 RTS_WIN64_ONLY(SymI_HasProto(__iob_func))
88
89 #else
90 #define RTS_MINGW_ONLY_SYMBOLS /**/
91 #endif
92
93
94 #if defined(darwin_HOST_OS) && HAVE_PRINTF_LDBLSTUB
95 #define RTS_DARWIN_ONLY_SYMBOLS \
96 SymI_NeedsProto(asprintf$LDBLStub) \
97 SymI_NeedsProto(err$LDBLStub) \
98 SymI_NeedsProto(errc$LDBLStub) \
99 SymI_NeedsProto(errx$LDBLStub) \
100 SymI_NeedsProto(fprintf$LDBLStub) \
101 SymI_NeedsProto(fscanf$LDBLStub) \
102 SymI_NeedsProto(fwprintf$LDBLStub) \
103 SymI_NeedsProto(fwscanf$LDBLStub) \
104 SymI_NeedsProto(printf$LDBLStub) \
105 SymI_NeedsProto(scanf$LDBLStub) \
106 SymI_NeedsProto(snprintf$LDBLStub) \
107 SymI_NeedsProto(sprintf$LDBLStub) \
108 SymI_NeedsProto(sscanf$LDBLStub) \
109 SymI_NeedsProto(strtold$LDBLStub) \
110 SymI_NeedsProto(swprintf$LDBLStub) \
111 SymI_NeedsProto(swscanf$LDBLStub) \
112 SymI_NeedsProto(syslog$LDBLStub) \
113 SymI_NeedsProto(vasprintf$LDBLStub) \
114 SymI_NeedsProto(verr$LDBLStub) \
115 SymI_NeedsProto(verrc$LDBLStub) \
116 SymI_NeedsProto(verrx$LDBLStub) \
117 SymI_NeedsProto(vfprintf$LDBLStub) \
118 SymI_NeedsProto(vfscanf$LDBLStub) \
119 SymI_NeedsProto(vfwprintf$LDBLStub) \
120 SymI_NeedsProto(vfwscanf$LDBLStub) \
121 SymI_NeedsProto(vprintf$LDBLStub) \
122 SymI_NeedsProto(vscanf$LDBLStub) \
123 SymI_NeedsProto(vsnprintf$LDBLStub) \
124 SymI_NeedsProto(vsprintf$LDBLStub) \
125 SymI_NeedsProto(vsscanf$LDBLStub) \
126 SymI_NeedsProto(vswprintf$LDBLStub) \
127 SymI_NeedsProto(vswscanf$LDBLStub) \
128 SymI_NeedsProto(vsyslog$LDBLStub) \
129 SymI_NeedsProto(vwarn$LDBLStub) \
130 SymI_NeedsProto(vwarnc$LDBLStub) \
131 SymI_NeedsProto(vwarnx$LDBLStub) \
132 SymI_NeedsProto(vwprintf$LDBLStub) \
133 SymI_NeedsProto(vwscanf$LDBLStub) \
134 SymI_NeedsProto(warn$LDBLStub) \
135 SymI_NeedsProto(warnc$LDBLStub) \
136 SymI_NeedsProto(warnx$LDBLStub) \
137 SymI_NeedsProto(wcstold$LDBLStub) \
138 SymI_NeedsProto(wprintf$LDBLStub) \
139 SymI_NeedsProto(wscanf$LDBLStub)
140 #else
141 #define RTS_DARWIN_ONLY_SYMBOLS
142 #endif
143
144 #if defined(openbsd_HOST_OS)
145 #define RTS_OPENBSD_ONLY_SYMBOLS \
146 SymE_NeedsProto(__guard_local) \
147 SymE_NeedsProto(_DYNAMIC)
148 #else
149 #define RTS_OPENBSD_ONLY_SYMBOLS
150 #endif
151
152 #ifndef SMP
153 # define MAIN_CAP_SYM SymI_HasProto(MainCapability)
154 #else
155 # define MAIN_CAP_SYM
156 #endif
157
158 #if !defined(mingw32_HOST_OS)
159 #define RTS_USER_SIGNALS_SYMBOLS \
160 SymI_HasProto(setIOManagerControlFd) \
161 SymI_HasProto(setTimerManagerControlFd) \
162 SymI_HasProto(setIOManagerWakeupFd) \
163 SymI_HasProto(ioManagerWakeup) \
164 SymI_HasProto(blockUserSignals) \
165 SymI_HasProto(unblockUserSignals)
166 #else
167 #define RTS_USER_SIGNALS_SYMBOLS \
168 SymI_HasProto(ioManagerWakeup) \
169 SymI_HasProto(sendIOManagerEvent) \
170 SymI_HasProto(readIOManagerEvent) \
171 SymI_HasProto(getIOManagerEvent) \
172 SymI_HasProto(console_handler)
173 #endif
174
175 #define RTS_LIBFFI_SYMBOLS \
176 SymE_NeedsProto(ffi_prep_cif) \
177 SymE_NeedsProto(ffi_call) \
178 SymE_NeedsDataProto(ffi_type_void) \
179 SymE_NeedsDataProto(ffi_type_float) \
180 SymE_NeedsDataProto(ffi_type_double) \
181 SymE_NeedsDataProto(ffi_type_sint64) \
182 SymE_NeedsDataProto(ffi_type_uint64) \
183 SymE_NeedsDataProto(ffi_type_sint32) \
184 SymE_NeedsDataProto(ffi_type_uint32) \
185 SymE_NeedsDataProto(ffi_type_sint16) \
186 SymE_NeedsDataProto(ffi_type_uint16) \
187 SymE_NeedsDataProto(ffi_type_sint8) \
188 SymE_NeedsDataProto(ffi_type_uint8) \
189 SymE_NeedsDataProto(ffi_type_pointer)
190
191 #ifdef TABLES_NEXT_TO_CODE
192 #define RTS_RET_SYMBOLS /* nothing */
193 #else
194 #define RTS_RET_SYMBOLS \
195 SymI_HasProto(stg_enter_ret) \
196 SymI_HasProto(stg_gc_fun_ret) \
197 SymI_HasProto(stg_ap_v_ret) \
198 SymI_HasProto(stg_ap_f_ret) \
199 SymI_HasProto(stg_ap_d_ret) \
200 SymI_HasProto(stg_ap_l_ret) \
201 SymI_HasProto(stg_ap_v16_ret) \
202 SymI_HasProto(stg_ap_v32_ret) \
203 SymI_HasProto(stg_ap_v64_ret) \
204 SymI_HasProto(stg_ap_n_ret) \
205 SymI_HasProto(stg_ap_p_ret) \
206 SymI_HasProto(stg_ap_pv_ret) \
207 SymI_HasProto(stg_ap_pp_ret) \
208 SymI_HasProto(stg_ap_ppv_ret) \
209 SymI_HasProto(stg_ap_ppp_ret) \
210 SymI_HasProto(stg_ap_pppv_ret) \
211 SymI_HasProto(stg_ap_pppp_ret) \
212 SymI_HasProto(stg_ap_ppppp_ret) \
213 SymI_HasProto(stg_ap_pppppp_ret)
214 #endif
215
216 /* Modules compiled with -ticky may mention ticky counters */
217 /* This list should marry up with the one in $(TOP)/includes/stg/Ticky.h */
218 #define RTS_TICKY_SYMBOLS \
219 SymI_NeedsDataProto(ticky_entry_ctrs) \
220 SymI_NeedsDataProto(top_ct) \
221 \
222 SymI_HasProto(ENT_VIA_NODE_ctr) \
223 SymI_HasProto(ENT_STATIC_THK_SINGLE_ctr) \
224 SymI_HasProto(ENT_STATIC_THK_MANY_ctr) \
225 SymI_HasProto(ENT_DYN_THK_SINGLE_ctr) \
226 SymI_HasProto(ENT_DYN_THK_MANY_ctr) \
227 SymI_HasProto(ENT_STATIC_FUN_DIRECT_ctr) \
228 SymI_HasProto(ENT_DYN_FUN_DIRECT_ctr) \
229 SymI_HasProto(ENT_STATIC_CON_ctr) \
230 SymI_HasProto(ENT_DYN_CON_ctr) \
231 SymI_HasProto(ENT_STATIC_IND_ctr) \
232 SymI_HasProto(ENT_DYN_IND_ctr) \
233 SymI_HasProto(ENT_PERM_IND_ctr) \
234 SymI_HasProto(ENT_PAP_ctr) \
235 SymI_HasProto(ENT_AP_ctr) \
236 SymI_HasProto(ENT_AP_STACK_ctr) \
237 SymI_HasProto(ENT_BH_ctr) \
238 SymI_HasProto(ENT_LNE_ctr) \
239 SymI_HasProto(UNKNOWN_CALL_ctr) \
240 SymI_HasProto(SLOW_CALL_fast_v16_ctr) \
241 SymI_HasProto(SLOW_CALL_fast_v_ctr) \
242 SymI_HasProto(SLOW_CALL_fast_f_ctr) \
243 SymI_HasProto(SLOW_CALL_fast_d_ctr) \
244 SymI_HasProto(SLOW_CALL_fast_l_ctr) \
245 SymI_HasProto(SLOW_CALL_fast_n_ctr) \
246 SymI_HasProto(SLOW_CALL_fast_p_ctr) \
247 SymI_HasProto(SLOW_CALL_fast_pv_ctr) \
248 SymI_HasProto(SLOW_CALL_fast_pp_ctr) \
249 SymI_HasProto(SLOW_CALL_fast_ppv_ctr) \
250 SymI_HasProto(SLOW_CALL_fast_ppp_ctr) \
251 SymI_HasProto(SLOW_CALL_fast_pppv_ctr) \
252 SymI_HasProto(SLOW_CALL_fast_pppp_ctr) \
253 SymI_HasProto(SLOW_CALL_fast_ppppp_ctr) \
254 SymI_HasProto(SLOW_CALL_fast_pppppp_ctr) \
255 SymI_HasProto(VERY_SLOW_CALL_ctr) \
256 SymI_HasProto(ticky_slow_call_unevald) \
257 SymI_HasProto(SLOW_CALL_ctr) \
258 SymI_HasProto(MULTI_CHUNK_SLOW_CALL_ctr) \
259 SymI_HasProto(MULTI_CHUNK_SLOW_CALL_CHUNKS_ctr) \
260 SymI_HasProto(KNOWN_CALL_ctr) \
261 SymI_HasProto(KNOWN_CALL_TOO_FEW_ARGS_ctr) \
262 SymI_HasProto(KNOWN_CALL_EXTRA_ARGS_ctr) \
263 SymI_HasProto(SLOW_CALL_FUN_TOO_FEW_ctr) \
264 SymI_HasProto(SLOW_CALL_FUN_CORRECT_ctr) \
265 SymI_HasProto(SLOW_CALL_FUN_TOO_MANY_ctr) \
266 SymI_HasProto(SLOW_CALL_PAP_TOO_FEW_ctr) \
267 SymI_HasProto(SLOW_CALL_PAP_CORRECT_ctr) \
268 SymI_HasProto(SLOW_CALL_PAP_TOO_MANY_ctr) \
269 SymI_HasProto(SLOW_CALL_UNEVALD_ctr) \
270 SymI_HasProto(UPDF_OMITTED_ctr) \
271 SymI_HasProto(UPDF_PUSHED_ctr) \
272 SymI_HasProto(CATCHF_PUSHED_ctr) \
273 SymI_HasProto(UPDF_RCC_PUSHED_ctr) \
274 SymI_HasProto(UPDF_RCC_OMITTED_ctr) \
275 SymI_HasProto(UPD_SQUEEZED_ctr) \
276 SymI_HasProto(UPD_CON_IN_NEW_ctr) \
277 SymI_HasProto(UPD_CON_IN_PLACE_ctr) \
278 SymI_HasProto(UPD_PAP_IN_NEW_ctr) \
279 SymI_HasProto(UPD_PAP_IN_PLACE_ctr) \
280 SymI_HasProto(ALLOC_HEAP_ctr) \
281 SymI_HasProto(ALLOC_HEAP_tot) \
282 SymI_HasProto(HEAP_CHK_ctr) \
283 SymI_HasProto(STK_CHK_ctr) \
284 SymI_HasProto(ALLOC_RTS_ctr) \
285 SymI_HasProto(ALLOC_RTS_tot) \
286 SymI_HasProto(ALLOC_FUN_ctr) \
287 SymI_HasProto(ALLOC_FUN_adm) \
288 SymI_HasProto(ALLOC_FUN_gds) \
289 SymI_HasProto(ALLOC_FUN_slp) \
290 SymI_HasProto(UPD_NEW_IND_ctr) \
291 SymI_HasProto(UPD_NEW_PERM_IND_ctr) \
292 SymI_HasProto(UPD_OLD_IND_ctr) \
293 SymI_HasProto(UPD_OLD_PERM_IND_ctr) \
294 SymI_HasProto(UPD_CAF_BH_UPDATABLE_ctr) \
295 SymI_HasProto(UPD_CAF_BH_SINGLE_ENTRY_ctr) \
296 SymI_HasProto(GC_SEL_ABANDONED_ctr) \
297 SymI_HasProto(GC_SEL_MINOR_ctr) \
298 SymI_HasProto(GC_SEL_MAJOR_ctr) \
299 SymI_HasProto(GC_FAILED_PROMOTION_ctr) \
300 SymI_HasProto(ALLOC_UP_THK_ctr) \
301 SymI_HasProto(ALLOC_SE_THK_ctr) \
302 SymI_HasProto(ALLOC_THK_adm) \
303 SymI_HasProto(ALLOC_THK_gds) \
304 SymI_HasProto(ALLOC_THK_slp) \
305 SymI_HasProto(ALLOC_CON_ctr) \
306 SymI_HasProto(ALLOC_CON_adm) \
307 SymI_HasProto(ALLOC_CON_gds) \
308 SymI_HasProto(ALLOC_CON_slp) \
309 SymI_HasProto(ALLOC_TUP_ctr) \
310 SymI_HasProto(ALLOC_TUP_adm) \
311 SymI_HasProto(ALLOC_TUP_gds) \
312 SymI_HasProto(ALLOC_TUP_slp) \
313 SymI_HasProto(ALLOC_BH_ctr) \
314 SymI_HasProto(ALLOC_BH_adm) \
315 SymI_HasProto(ALLOC_BH_gds) \
316 SymI_HasProto(ALLOC_BH_slp) \
317 SymI_HasProto(ALLOC_PRIM_ctr) \
318 SymI_HasProto(ALLOC_PRIM_adm) \
319 SymI_HasProto(ALLOC_PRIM_gds) \
320 SymI_HasProto(ALLOC_PRIM_slp) \
321 SymI_HasProto(ALLOC_PAP_ctr) \
322 SymI_HasProto(ALLOC_PAP_adm) \
323 SymI_HasProto(ALLOC_PAP_gds) \
324 SymI_HasProto(ALLOC_PAP_slp) \
325 SymI_HasProto(ALLOC_TSO_ctr) \
326 SymI_HasProto(ALLOC_TSO_adm) \
327 SymI_HasProto(ALLOC_TSO_gds) \
328 SymI_HasProto(ALLOC_TSO_slp) \
329 SymI_HasProto(RET_NEW_ctr) \
330 SymI_HasProto(RET_OLD_ctr) \
331 SymI_HasProto(RET_UNBOXED_TUP_ctr) \
332 SymI_HasProto(RET_SEMI_loads_avoided) \
333 SymI_HasProto(RET_NEW_hst) \
334 SymI_HasProto(RET_OLD_hst) \
335 SymI_HasProto(RET_UNBOXED_TUP_hst)
336
337
338 // On most platforms, the garbage collector rewrites references
339 // to small integer and char objects to a set of common, shared ones.
340 //
341 // We don't do this when compiling to Windows DLLs at the moment because
342 // it doesn't support cross package data references well.
343 //
344 #if defined(COMPILING_WINDOWS_DLL)
345 #define RTS_INTCHAR_SYMBOLS
346 #else
347 #define RTS_INTCHAR_SYMBOLS \
348 SymI_HasProto(stg_CHARLIKE_closure) \
349 SymI_HasProto(stg_INTLIKE_closure)
350 #endif
351
352 #if defined(PROFILING)
353 #define RTS_PROF_SYMBOLS \
354 SymI_HasProto(CCS_DONT_CARE) \
355 SymI_HasProto(CC_LIST) \
356 SymI_HasProto(CC_ID) \
357 SymI_HasProto(CCS_LIST) \
358 SymI_HasProto(CCS_ID) \
359 SymI_HasProto(stg_restore_cccs_info) \
360 SymI_HasProto(enterFunCCS) \
361 SymI_HasProto(pushCostCentre) \
362 SymI_HasProto(mkCostCentre) \
363 SymI_HasProto(era)
364 #else
365 #define RTS_PROF_SYMBOLS /* empty */
366 #endif
367
368 #define RTS_SYMBOLS \
369 Maybe_Stable_Names \
370 RTS_TICKY_SYMBOLS \
371 RTS_PROF_SYMBOLS \
372 RTS_LIBDW_SYMBOLS \
373 SymI_HasProto(StgReturn) \
374 SymI_HasProto(stg_gc_noregs) \
375 SymI_HasProto(stg_ret_v_info) \
376 SymI_HasProto(stg_ret_p_info) \
377 SymI_HasProto(stg_ret_n_info) \
378 SymI_HasProto(stg_ret_f_info) \
379 SymI_HasProto(stg_ret_d_info) \
380 SymI_HasProto(stg_ret_l_info) \
381 SymI_HasProto(stg_gc_prim_p) \
382 SymI_HasProto(stg_gc_prim_pp) \
383 SymI_HasProto(stg_gc_prim_n) \
384 SymI_HasProto(stg_enter_info) \
385 SymI_HasProto(__stg_gc_enter_1) \
386 SymI_HasProto(stg_gc_unpt_r1) \
387 SymI_HasProto(stg_gc_unbx_r1) \
388 SymI_HasProto(stg_gc_f1) \
389 SymI_HasProto(stg_gc_d1) \
390 SymI_HasProto(stg_gc_l1) \
391 SymI_HasProto(stg_gc_pp) \
392 SymI_HasProto(stg_gc_ppp) \
393 SymI_HasProto(stg_gc_pppp) \
394 SymI_HasProto(__stg_gc_fun) \
395 SymI_HasProto(stg_gc_fun_info) \
396 SymI_HasProto(stg_yield_noregs) \
397 SymI_HasProto(stg_yield_to_interpreter) \
398 SymI_HasProto(stg_block_noregs) \
399 SymI_HasProto(stg_block_takemvar) \
400 SymI_HasProto(stg_block_readmvar) \
401 SymI_HasProto(stg_block_putmvar) \
402 MAIN_CAP_SYM \
403 SymI_HasProto(addDLL) \
404 SymI_HasProto(addLibrarySearchPath) \
405 SymI_HasProto(removeLibrarySearchPath) \
406 SymI_HasProto(findSystemLibrary) \
407 SymI_HasProto(__int_encodeDouble) \
408 SymI_HasProto(__word_encodeDouble) \
409 SymI_HasProto(__int_encodeFloat) \
410 SymI_HasProto(__word_encodeFloat) \
411 SymI_HasProto(stg_atomicallyzh) \
412 SymI_HasProto(barf) \
413 SymI_HasProto(deRefStablePtr) \
414 SymI_HasProto(debugBelch) \
415 SymI_HasProto(errorBelch) \
416 SymI_HasProto(sysErrorBelch) \
417 SymI_HasProto(stg_getMaskingStatezh) \
418 SymI_HasProto(stg_maskAsyncExceptionszh) \
419 SymI_HasProto(stg_maskUninterruptiblezh) \
420 SymI_HasProto(stg_catchzh) \
421 SymI_HasProto(stg_catchRetryzh) \
422 SymI_HasProto(stg_catchSTMzh) \
423 SymI_HasProto(stg_checkzh) \
424 SymI_HasProto(stg_clearCCSzh) \
425 SymI_HasProto(closure_flags) \
426 SymI_HasProto(cmp_thread) \
427 SymI_HasProto(createAdjustor) \
428 SymI_HasProto(stg_decodeDoublezu2Intzh) \
429 SymI_HasProto(stg_decodeDoublezuInt64zh) \
430 SymI_HasProto(stg_decodeFloatzuIntzh) \
431 SymI_HasProto(stg_delayzh) \
432 SymI_HasProto(stg_deRefWeakzh) \
433 SymI_HasProto(stg_deRefStablePtrzh) \
434 SymI_HasProto(dirty_MUT_VAR) \
435 SymI_HasProto(dirty_TVAR) \
436 SymI_HasProto(stg_forkzh) \
437 SymI_HasProto(stg_forkOnzh) \
438 SymI_HasProto(forkProcess) \
439 SymI_HasProto(forkOS_createThread) \
440 SymI_HasProto(freeHaskellFunctionPtr) \
441 SymI_HasProto(getOrSetGHCConcSignalSignalHandlerStore) \
442 SymI_HasProto(getOrSetGHCConcWindowsPendingDelaysStore) \
443 SymI_HasProto(getOrSetGHCConcWindowsIOManagerThreadStore) \
444 SymI_HasProto(getOrSetGHCConcWindowsProddingStore) \
445 SymI_HasProto(getOrSetSystemEventThreadEventManagerStore) \
446 SymI_HasProto(getOrSetSystemEventThreadIOManagerThreadStore) \
447 SymI_HasProto(getOrSetSystemTimerThreadEventManagerStore) \
448 SymI_HasProto(getOrSetSystemTimerThreadIOManagerThreadStore) \
449 SymI_HasProto(getOrSetLibHSghcFastStringTable) \
450 SymI_HasProto(getGCStats) \
451 SymI_HasProto(getGCStatsEnabled) \
452 SymI_HasProto(genericRaise) \
453 SymI_HasProto(getProgArgv) \
454 SymI_HasProto(getFullProgArgv) \
455 SymI_HasProto(getStablePtr) \
456 SymI_HasProto(foreignExportStablePtr) \
457 SymI_HasProto(hs_init) \
458 SymI_HasProto(hs_exit) \
459 SymI_HasProto(hs_set_argv) \
460 SymI_HasProto(hs_add_root) \
461 SymI_HasProto(hs_perform_gc) \
462 SymI_HasProto(hs_lock_stable_tables) \
463 SymI_HasProto(hs_unlock_stable_tables) \
464 SymI_HasProto(hs_free_stable_ptr) \
465 SymI_HasProto(hs_free_stable_ptr_unsafe) \
466 SymI_HasProto(hs_free_fun_ptr) \
467 SymI_HasProto(hs_hpc_rootModule) \
468 SymI_HasProto(hs_hpc_module) \
469 SymI_HasProto(initLinker) \
470 SymI_HasProto(initLinker_) \
471 SymI_HasProto(stg_unpackClosurezh) \
472 SymI_HasProto(stg_getApStackValzh) \
473 SymI_HasProto(stg_getSparkzh) \
474 SymI_HasProto(stg_numSparkszh) \
475 SymI_HasProto(stg_isCurrentThreadBoundzh) \
476 SymI_HasProto(stg_isEmptyMVarzh) \
477 SymI_HasProto(stg_killThreadzh) \
478 SymI_HasProto(loadArchive) \
479 SymI_HasProto(loadObj) \
480 SymI_HasProto(insertSymbol) \
481 SymI_HasProto(lookupSymbol) \
482 SymI_HasProto(stg_makeStablePtrzh) \
483 SymI_HasProto(stg_mkApUpd0zh) \
484 SymI_HasProto(stg_myThreadIdzh) \
485 SymI_HasProto(stg_labelThreadzh) \
486 SymI_HasProto(stg_newArrayzh) \
487 SymI_HasProto(stg_copyArrayzh) \
488 SymI_HasProto(stg_copyMutableArrayzh) \
489 SymI_HasProto(stg_copyArrayArrayzh) \
490 SymI_HasProto(stg_copyMutableArrayArrayzh) \
491 SymI_HasProto(stg_cloneArrayzh) \
492 SymI_HasProto(stg_cloneMutableArrayzh) \
493 SymI_HasProto(stg_freezzeArrayzh) \
494 SymI_HasProto(stg_thawArrayzh) \
495 SymI_HasProto(stg_newArrayArrayzh) \
496 SymI_HasProto(stg_casArrayzh) \
497 SymI_HasProto(stg_newSmallArrayzh) \
498 SymI_HasProto(stg_unsafeThawSmallArrayzh) \
499 SymI_HasProto(stg_cloneSmallArrayzh) \
500 SymI_HasProto(stg_cloneSmallMutableArrayzh) \
501 SymI_HasProto(stg_freezzeSmallArrayzh) \
502 SymI_HasProto(stg_thawSmallArrayzh) \
503 SymI_HasProto(stg_copySmallArrayzh) \
504 SymI_HasProto(stg_copySmallMutableArrayzh) \
505 SymI_HasProto(stg_casSmallArrayzh) \
506 SymI_HasProto(stg_newBCOzh) \
507 SymI_HasProto(stg_newByteArrayzh) \
508 SymI_HasProto(stg_casIntArrayzh) \
509 SymI_HasProto(stg_newMVarzh) \
510 SymI_HasProto(stg_newMutVarzh) \
511 SymI_HasProto(stg_newTVarzh) \
512 SymI_HasProto(stg_noDuplicatezh) \
513 SymI_HasProto(stg_atomicModifyMutVarzh) \
514 SymI_HasProto(stg_casMutVarzh) \
515 SymI_HasProto(stg_newPinnedByteArrayzh) \
516 SymI_HasProto(stg_newAlignedPinnedByteArrayzh) \
517 SymI_HasProto(stg_shrinkMutableByteArrayzh) \
518 SymI_HasProto(stg_resizzeMutableByteArrayzh) \
519 SymI_HasProto(newSpark) \
520 SymI_HasProto(performGC) \
521 SymI_HasProto(performMajorGC) \
522 SymI_HasProto(prog_argc) \
523 SymI_HasProto(prog_argv) \
524 SymI_HasProto(stg_putMVarzh) \
525 SymI_HasProto(stg_raisezh) \
526 SymI_HasProto(stg_raiseIOzh) \
527 SymI_HasProto(stg_readTVarzh) \
528 SymI_HasProto(stg_readTVarIOzh) \
529 SymI_HasProto(resumeThread) \
530 SymI_HasProto(setNumCapabilities) \
531 SymI_HasProto(getNumberOfProcessors) \
532 SymI_HasProto(resolveObjs) \
533 SymI_HasProto(stg_retryzh) \
534 SymI_HasProto(rts_apply) \
535 SymI_HasProto(rts_checkSchedStatus) \
536 SymI_HasProto(rts_eval) \
537 SymI_HasProto(rts_evalIO) \
538 SymI_HasProto(rts_evalLazyIO) \
539 SymI_HasProto(rts_evalStableIO) \
540 SymI_HasProto(rts_eval_) \
541 SymI_HasProto(rts_getBool) \
542 SymI_HasProto(rts_getChar) \
543 SymI_HasProto(rts_getDouble) \
544 SymI_HasProto(rts_getFloat) \
545 SymI_HasProto(rts_getInt) \
546 SymI_HasProto(rts_getInt8) \
547 SymI_HasProto(rts_getInt16) \
548 SymI_HasProto(rts_getInt32) \
549 SymI_HasProto(rts_getInt64) \
550 SymI_HasProto(rts_getPtr) \
551 SymI_HasProto(rts_getFunPtr) \
552 SymI_HasProto(rts_getStablePtr) \
553 SymI_HasProto(rts_getThreadId) \
554 SymI_HasProto(rts_getWord) \
555 SymI_HasProto(rts_getWord8) \
556 SymI_HasProto(rts_getWord16) \
557 SymI_HasProto(rts_getWord32) \
558 SymI_HasProto(rts_getWord64) \
559 SymI_HasProto(rts_lock) \
560 SymI_HasProto(rts_mkBool) \
561 SymI_HasProto(rts_mkChar) \
562 SymI_HasProto(rts_mkDouble) \
563 SymI_HasProto(rts_mkFloat) \
564 SymI_HasProto(rts_mkInt) \
565 SymI_HasProto(rts_mkInt8) \
566 SymI_HasProto(rts_mkInt16) \
567 SymI_HasProto(rts_mkInt32) \
568 SymI_HasProto(rts_mkInt64) \
569 SymI_HasProto(rts_mkPtr) \
570 SymI_HasProto(rts_mkFunPtr) \
571 SymI_HasProto(rts_mkStablePtr) \
572 SymI_HasProto(rts_mkString) \
573 SymI_HasProto(rts_mkWord) \
574 SymI_HasProto(rts_mkWord8) \
575 SymI_HasProto(rts_mkWord16) \
576 SymI_HasProto(rts_mkWord32) \
577 SymI_HasProto(rts_mkWord64) \
578 SymI_HasProto(rts_unlock) \
579 SymI_HasProto(rts_unsafeGetMyCapability) \
580 SymI_HasProto(rtsSupportsBoundThreads) \
581 SymI_HasProto(rts_isProfiled) \
582 SymI_HasProto(rts_isDynamic) \
583 SymI_HasProto(rts_getThreadAllocationCounter) \
584 SymI_HasProto(rts_setThreadAllocationCounter) \
585 SymI_HasProto(rts_enableThreadAllocationLimit) \
586 SymI_HasProto(rts_disableThreadAllocationLimit) \
587 SymI_HasProto(setProgArgv) \
588 SymI_HasProto(startupHaskell) \
589 SymI_HasProto(shutdownHaskell) \
590 SymI_HasProto(shutdownHaskellAndExit) \
591 SymI_HasProto(stable_name_table) \
592 SymI_HasProto(stable_ptr_table) \
593 SymI_HasProto(stackOverflow) \
594 SymI_HasProto(stg_CAF_BLACKHOLE_info) \
595 SymI_HasProto(stg_BLACKHOLE_info) \
596 SymI_HasProto(__stg_EAGER_BLACKHOLE_info) \
597 SymI_HasProto(stg_BLOCKING_QUEUE_CLEAN_info) \
598 SymI_HasProto(stg_BLOCKING_QUEUE_DIRTY_info) \
599 SymI_HasProto(startTimer) \
600 SymI_HasProto(stg_MVAR_CLEAN_info) \
601 SymI_HasProto(stg_MVAR_DIRTY_info) \
602 SymI_HasProto(stg_TVAR_CLEAN_info) \
603 SymI_HasProto(stg_TVAR_DIRTY_info) \
604 SymI_HasProto(stg_IND_STATIC_info) \
605 SymI_HasProto(stg_ARR_WORDS_info) \
606 SymI_HasProto(stg_MUT_ARR_PTRS_DIRTY_info) \
607 SymI_HasProto(stg_MUT_ARR_PTRS_FROZEN_info) \
608 SymI_HasProto(stg_MUT_ARR_PTRS_FROZEN0_info) \
609 SymI_HasProto(stg_SMALL_MUT_ARR_PTRS_DIRTY_info) \
610 SymI_HasProto(stg_SMALL_MUT_ARR_PTRS_FROZEN_info) \
611 SymI_HasProto(stg_SMALL_MUT_ARR_PTRS_FROZEN0_info) \
612 SymI_HasProto(stg_MUT_VAR_CLEAN_info) \
613 SymI_HasProto(stg_MUT_VAR_DIRTY_info) \
614 SymI_HasProto(stg_WEAK_info) \
615 SymI_HasProto(stg_ap_v_info) \
616 SymI_HasProto(stg_ap_f_info) \
617 SymI_HasProto(stg_ap_d_info) \
618 SymI_HasProto(stg_ap_l_info) \
619 SymI_HasProto(stg_ap_v16_info) \
620 SymI_HasProto(stg_ap_v32_info) \
621 SymI_HasProto(stg_ap_v64_info) \
622 SymI_HasProto(stg_ap_n_info) \
623 SymI_HasProto(stg_ap_p_info) \
624 SymI_HasProto(stg_ap_pv_info) \
625 SymI_HasProto(stg_ap_pp_info) \
626 SymI_HasProto(stg_ap_ppv_info) \
627 SymI_HasProto(stg_ap_ppp_info) \
628 SymI_HasProto(stg_ap_pppv_info) \
629 SymI_HasProto(stg_ap_pppp_info) \
630 SymI_HasProto(stg_ap_ppppp_info) \
631 SymI_HasProto(stg_ap_pppppp_info) \
632 SymI_HasProto(stg_ap_0_fast) \
633 SymI_HasProto(stg_ap_v_fast) \
634 SymI_HasProto(stg_ap_f_fast) \
635 SymI_HasProto(stg_ap_d_fast) \
636 SymI_HasProto(stg_ap_l_fast) \
637 SymI_HasProto(stg_ap_v16_fast) \
638 SymI_HasProto(stg_ap_v32_fast) \
639 SymI_HasProto(stg_ap_v64_fast) \
640 SymI_HasProto(stg_ap_n_fast) \
641 SymI_HasProto(stg_ap_p_fast) \
642 SymI_HasProto(stg_ap_pv_fast) \
643 SymI_HasProto(stg_ap_pp_fast) \
644 SymI_HasProto(stg_ap_ppv_fast) \
645 SymI_HasProto(stg_ap_ppp_fast) \
646 SymI_HasProto(stg_ap_pppv_fast) \
647 SymI_HasProto(stg_ap_pppp_fast) \
648 SymI_HasProto(stg_ap_ppppp_fast) \
649 SymI_HasProto(stg_ap_pppppp_fast) \
650 SymI_HasProto(stg_ap_1_upd_info) \
651 SymI_HasProto(stg_ap_2_upd_info) \
652 SymI_HasProto(stg_ap_3_upd_info) \
653 SymI_HasProto(stg_ap_4_upd_info) \
654 SymI_HasProto(stg_ap_5_upd_info) \
655 SymI_HasProto(stg_ap_6_upd_info) \
656 SymI_HasProto(stg_ap_7_upd_info) \
657 SymI_HasProto(stg_exit) \
658 SymI_HasProto(stg_sel_0_upd_info) \
659 SymI_HasProto(stg_sel_1_upd_info) \
660 SymI_HasProto(stg_sel_2_upd_info) \
661 SymI_HasProto(stg_sel_3_upd_info) \
662 SymI_HasProto(stg_sel_4_upd_info) \
663 SymI_HasProto(stg_sel_5_upd_info) \
664 SymI_HasProto(stg_sel_6_upd_info) \
665 SymI_HasProto(stg_sel_7_upd_info) \
666 SymI_HasProto(stg_sel_8_upd_info) \
667 SymI_HasProto(stg_sel_9_upd_info) \
668 SymI_HasProto(stg_sel_10_upd_info) \
669 SymI_HasProto(stg_sel_11_upd_info) \
670 SymI_HasProto(stg_sel_12_upd_info) \
671 SymI_HasProto(stg_sel_13_upd_info) \
672 SymI_HasProto(stg_sel_14_upd_info) \
673 SymI_HasProto(stg_sel_15_upd_info) \
674 SymI_HasProto(stg_sel_0_noupd_info) \
675 SymI_HasProto(stg_sel_1_noupd_info) \
676 SymI_HasProto(stg_sel_2_noupd_info) \
677 SymI_HasProto(stg_sel_3_noupd_info) \
678 SymI_HasProto(stg_sel_4_noupd_info) \
679 SymI_HasProto(stg_sel_5_noupd_info) \
680 SymI_HasProto(stg_sel_6_noupd_info) \
681 SymI_HasProto(stg_sel_7_noupd_info) \
682 SymI_HasProto(stg_sel_8_noupd_info) \
683 SymI_HasProto(stg_sel_9_noupd_info) \
684 SymI_HasProto(stg_sel_10_noupd_info) \
685 SymI_HasProto(stg_sel_11_noupd_info) \
686 SymI_HasProto(stg_sel_12_noupd_info) \
687 SymI_HasProto(stg_sel_13_noupd_info) \
688 SymI_HasProto(stg_sel_14_noupd_info) \
689 SymI_HasProto(stg_sel_15_noupd_info) \
690 SymI_HasProto(stg_upd_frame_info) \
691 SymI_HasProto(stg_bh_upd_frame_info) \
692 SymI_HasProto(suspendThread) \
693 SymI_HasProto(stg_takeMVarzh) \
694 SymI_HasProto(stg_readMVarzh) \
695 SymI_HasProto(stg_threadStatuszh) \
696 SymI_HasProto(stg_tryPutMVarzh) \
697 SymI_HasProto(stg_tryTakeMVarzh) \
698 SymI_HasProto(stg_tryReadMVarzh) \
699 SymI_HasProto(stg_unmaskAsyncExceptionszh) \
700 SymI_HasProto(unloadObj) \
701 SymI_HasProto(stg_unsafeThawArrayzh) \
702 SymI_HasProto(stg_waitReadzh) \
703 SymI_HasProto(stg_waitWritezh) \
704 SymI_HasProto(stg_writeTVarzh) \
705 SymI_HasProto(stg_yieldzh) \
706 SymI_NeedsProto(stg_interp_constr_entry) \
707 SymI_HasProto(stg_arg_bitmaps) \
708 SymI_HasProto(large_alloc_lim) \
709 SymI_HasProto(g0) \
710 SymI_HasProto(allocate) \
711 SymI_HasProto(allocateExec) \
712 SymI_HasProto(flushExec) \
713 SymI_HasProto(freeExec) \
714 SymI_HasProto(getAllocations) \
715 SymI_HasProto(revertCAFs) \
716 SymI_HasProto(RtsFlags) \
717 SymI_NeedsDataProto(rts_breakpoint_io_action) \
718 SymI_NeedsDataProto(rts_stop_next_breakpoint) \
719 SymI_NeedsDataProto(rts_stop_on_exception) \
720 SymI_HasProto(stopTimer) \
721 SymI_HasProto(n_capabilities) \
722 SymI_HasProto(enabled_capabilities) \
723 SymI_HasProto(stg_traceCcszh) \
724 SymI_HasProto(stg_traceEventzh) \
725 SymI_HasProto(stg_traceMarkerzh) \
726 SymI_HasProto(getMonotonicNSec) \
727 SymI_HasProto(lockFile) \
728 SymI_HasProto(unlockFile) \
729 SymI_HasProto(startProfTimer) \
730 SymI_HasProto(stopProfTimer) \
731 SymI_HasProto(atomic_inc) \
732 SymI_HasProto(atomic_dec) \
733 SymI_HasProto(hs_spt_lookup) \
734 SymI_HasProto(hs_spt_insert) \
735 SymI_HasProto(hs_spt_remove) \
736 SymI_HasProto(hs_spt_keys) \
737 SymI_HasProto(hs_spt_key_count) \
738 RTS_USER_SIGNALS_SYMBOLS \
739 RTS_INTCHAR_SYMBOLS
740
741
742 // 64-bit support functions in libgcc.a
743 #if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32)
744 #define RTS_LIBGCC_SYMBOLS \
745 SymI_NeedsProto(__divdi3) \
746 SymI_NeedsProto(__udivdi3) \
747 SymI_NeedsProto(__moddi3) \
748 SymI_NeedsProto(__umoddi3) \
749 SymI_NeedsProto(__muldi3) \
750 SymI_NeedsProto(__ashldi3) \
751 SymI_NeedsProto(__ashrdi3) \
752 SymI_NeedsProto(__lshrdi3) \
753 SymI_NeedsProto(__fixunsdfdi)
754 #else
755 #define RTS_LIBGCC_SYMBOLS
756 #endif
757
758 #if defined(darwin_HOST_OS) && defined(powerpc_HOST_ARCH)
759 // Symbols that don't have a leading underscore
760 // on Mac OS X. They have to receive special treatment,
761 // see machoInitSymbolsWithoutUnderscore()
762 #define RTS_MACHO_NOUNDERLINE_SYMBOLS \
763 SymI_NeedsProto(saveFP) \
764 SymI_NeedsProto(restFP)
765 #endif
766
767 /* entirely bogus claims about types of these symbols */
768 #define SymI_NeedsProto(vvv) extern void vvv(void);
769 #define SymI_NeedsDataProto(vvv) extern StgWord vvv[];
770 #if defined(COMPILING_WINDOWS_DLL)
771 #define SymE_HasProto(vvv) SymE_HasProto(vvv);
772 # if defined(x86_64_HOST_ARCH)
773 # define SymE_NeedsProto(vvv) extern void __imp_ ## vvv (void);
774 # define SymE_NeedsDataProto(vvv) SymE_NeedsProto(vvv)
775 # else
776 # define SymE_NeedsProto(vvv) extern void _imp__ ## vvv (void);
777 # define SymE_NeedsDataProto(vvv) SymE_NeedsProto(vvv)
778 # endif
779 #else
780 #define SymE_NeedsProto(vvv) SymI_NeedsProto(vvv);
781 #define SymE_NeedsDataProto(vvv) SymI_NeedsDataProto(vvv);
782 #define SymE_HasProto(vvv) SymI_HasProto(vvv)
783 #endif
784 #define SymI_HasProto(vvv) /**/
785 #define SymI_HasProto_redirect(vvv,xxx) /**/
786 RTS_SYMBOLS
787 RTS_RET_SYMBOLS
788 RTS_POSIX_ONLY_SYMBOLS
789 RTS_MINGW_ONLY_SYMBOLS
790 RTS_DARWIN_ONLY_SYMBOLS
791 RTS_OPENBSD_ONLY_SYMBOLS
792 RTS_LIBGCC_SYMBOLS
793 RTS_LIBFFI_SYMBOLS
794 #undef SymI_NeedsProto
795 #undef SymI_NeedsDataProto
796 #undef SymI_HasProto
797 #undef SymI_HasProto_redirect
798 #undef SymE_HasProto
799 #undef SymE_HasDataProto
800 #undef SymE_NeedsProto
801 #undef SymE_NeedsDataProto
802
803 #define SymI_HasProto(vvv) { MAYBE_LEADING_UNDERSCORE_STR(#vvv), \
804 (void*)(&(vvv)) },
805 #define SymI_HasDataProto(vvv) \
806 SymI_HasProto(vvv)
807 #define SymE_HasProto(vvv) { MAYBE_LEADING_UNDERSCORE_STR(#vvv), \
808 (void*)DLL_IMPORT_DATA_REF(vvv) },
809 #define SymE_HasDataProto(vvv) \
810 SymE_HasProto(vvv)
811
812 #define SymI_NeedsProto(vvv) SymI_HasProto(vvv)
813 #define SymI_NeedsDataProto(vvv) SymI_HasDataProto(vvv)
814 #define SymE_NeedsProto(vvv) SymE_HasProto(vvv)
815 #define SymE_NeedsDataProto(vvv) SymE_HasDataProto(vvv)
816
817 // SymI_HasProto_redirect allows us to redirect references to one symbol to
818 // another symbol. See newCAF/newRetainedCAF/newGCdCAF for an example.
819 #define SymI_HasProto_redirect(vvv,xxx) \
820 { MAYBE_LEADING_UNDERSCORE_STR(#vvv), \
821 (void*)(&(xxx)) },
822
823 RtsSymbolVal rtsSyms[] = {
824 RTS_SYMBOLS
825 RTS_RET_SYMBOLS
826 RTS_POSIX_ONLY_SYMBOLS
827 RTS_MINGW_ONLY_SYMBOLS
828 RTS_DARWIN_ONLY_SYMBOLS
829 RTS_OPENBSD_ONLY_SYMBOLS
830 RTS_LIBGCC_SYMBOLS
831 RTS_LIBFFI_SYMBOLS
832 #if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH)
833 // dyld stub code contains references to this,
834 // but it should never be called because we treat
835 // lazy pointers as nonlazy.
836 { "dyld_stub_binding_helper", (void*)0xDEADBEEF },
837 #endif
838 { 0, 0 } /* sentinel */
839 };