Linker.c 233 KB
Newer Older
1 2
/* -----------------------------------------------------------------------------
 *
3
 * (c) The GHC Team, 2000-2004
4 5 6 7 8
 *
 * RTS Object Linker
 *
 * ---------------------------------------------------------------------------*/

sof's avatar
sof committed
9
#if 0
10
#include "PosixSource.h"
sof's avatar
sof committed
11
#endif
12

13
/* Linux needs _GNU_SOURCE to get RTLD_DEFAULT from <dlfcn.h> and
14 15
   MREMAP_MAYMOVE from <sys/mman.h>.
 */
16 17
#if defined(__linux__)  || defined(__GLIBC__)
#define _GNU_SOURCE 1
18 19
#endif

20 21
#include "Rts.h"
#include "HsFFI.h"
Simon Marlow's avatar
Simon Marlow committed
22 23

#include "sm/Storage.h"
Simon Marlow's avatar
Simon Marlow committed
24
#include "Stats.h"
25
#include "Hash.h"
26
#include "LinkerInternals.h"
27
#include "RtsUtils.h"
28
#include "Trace.h"
Simon Marlow's avatar
Simon Marlow committed
29 30 31 32 33 34
#include "StgPrimFloat.h" // for __int_encodeFloat etc.
#include "Stable.h"

#if !defined(mingw32_HOST_OS)
#include "posix/Signals.h"
#endif
35

Simon Marlow's avatar
Simon Marlow committed
36 37 38
// get protos for is*()
#include <ctype.h>

39
#ifdef HAVE_SYS_TYPES_H
40
#include <sys/types.h>
41 42
#endif

Ian Lynagh's avatar
Ian Lynagh committed
43
#include <inttypes.h>
44 45
#include <stdlib.h>
#include <string.h>
46 47
#include <stdio.h>
#include <assert.h>
48

49
#ifdef HAVE_SYS_STAT_H
50
#include <sys/stat.h>
51
#endif
52

53
#if defined(HAVE_DLFCN_H)
54
#include <dlfcn.h>
55
#endif
56

57
#if defined(cygwin32_HOST_OS)
sof's avatar
sof committed
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
#ifdef HAVE_DIRENT_H
#include <dirent.h>
#endif

#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <regex.h>
#include <sys/fcntl.h>
#include <sys/termios.h>
#include <sys/utime.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#endif

73 74 75 76 77 78
#if !defined(powerpc_HOST_ARCH) && \
    (   defined(linux_HOST_OS    ) || defined(freebsd_HOST_OS) || \
        defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS ) || \
        defined(openbsd_HOST_OS  ) || defined(darwin_HOST_OS ) || \
        defined(kfreebsdgnu_HOST_OS) )
/* Don't use mmap on powerpc_HOST_ARCH as mmap doesn't support
79 80 81 82
 * reallocating but we need to allocate jump islands just after each
 * object images. Otherwise relative branches to jump islands can fail
 * due to 24-bits displacement overflow.
 */
83 84 85
#define USE_MMAP
#include <fcntl.h>
#include <sys/mman.h>
dons's avatar
dons committed
86 87 88 89 90

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

91 92
#endif

93
#if defined(linux_HOST_OS) || defined(solaris2_HOST_OS) || defined(freebsd_HOST_OS) || defined(kfreebsdgnu_HOST_OS) || defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS) || defined(openbsd_HOST_OS)
94
#  define OBJFORMAT_ELF
Ian Lynagh's avatar
Ian Lynagh committed
95 96
#  include <regex.h>    // regex is already used by dlopen() so this is OK
                        // to use here without requiring an additional lib
97
#elif defined(cygwin32_HOST_OS) || defined (mingw32_HOST_OS)
98
#  define OBJFORMAT_PEi386
99
#  include <windows.h>
sof's avatar
sof committed
100
#  include <math.h>
101
#elif defined(darwin_HOST_OS)
102
#  define OBJFORMAT_MACHO
103
#  include <regex.h>
Ian Lynagh's avatar
Ian Lynagh committed
104 105
#  include <mach/machine.h>
#  include <mach-o/fat.h>
106 107 108
#  include <mach-o/loader.h>
#  include <mach-o/nlist.h>
#  include <mach-o/reloc.h>
109
#if !defined(HAVE_DLFCN_H)
110
#  include <mach-o/dyld.h>
111
#endif
112 113 114
#if defined(powerpc_HOST_ARCH)
#  include <mach-o/ppc/reloc.h>
#endif
115 116 117
#if defined(x86_64_HOST_ARCH)
#  include <mach-o/x86_64/reloc.h>
#endif
118 119
#endif

120 121 122 123
#if defined(x86_64_HOST_ARCH) && defined(darwin_HOST_OS)
#define ALWAYS_PIC
#endif

124
/* Hash table mapping symbol names to Symbol */
125
static /*Str*/HashTable *symhash;
126

127 128 129
/* Hash table mapping symbol names to StgStablePtr */
static /*Str*/HashTable *stablehash;

130
/* List of currently loaded objects */
Ian Lynagh's avatar
Ian Lynagh committed
131
ObjectCode *objects = NULL;     /* initially empty */
132

133
static HsInt loadOc( ObjectCode* oc );
134
static ObjectCode* mkOc( pathchar *path, char *image, int imageSize,
135
                         char *archiveMemberName
136 137 138 139 140 141 142
#ifndef USE_MMAP
#ifdef darwin_HOST_OS
                       , int misalignment
#endif
#endif
                       );

143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
// Use wchar_t for pathnames on Windows (#5697)
#if defined(mingw32_HOST_OS)
#define pathcmp wcscmp
#define pathlen wcslen
#define pathopen _wfopen
#define pathstat _wstat
#define struct_stat struct _stat
#define open wopen
#define WSTR(s) L##s
#define PATH_FMT "S"
#else
#define pathcmp strcmp
#define pathlen strlen
#define pathopen fopen
#define pathstat stat
#define struct_stat struct stat
#define WSTR(s) s
#define PATH_FMT "s"
#endif

static pathchar* pathdup(pathchar *path)
{
    pathchar *ret;
#if defined(mingw32_HOST_OS)
    ret = wcsdup(path);
#else
    /* sigh, strdup() isn't a POSIX function, so do it the long way */
    ret = stgMallocBytes( strlen(path)+1, "loadObj" );
    strcpy(ret, path);
#endif
    return ret;
}


177
#if defined(OBJFORMAT_ELF)
178 179 180
static int ocVerifyImage_ELF    ( ObjectCode* oc );
static int ocGetNames_ELF       ( ObjectCode* oc );
static int ocResolve_ELF        ( ObjectCode* oc );
Ben Gamari's avatar
Ben Gamari committed
181
#if defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH) || defined(arm_HOST_ARCH)
182
static int ocAllocateSymbolExtras_ELF ( ObjectCode* oc );
183
#endif
184
#elif defined(OBJFORMAT_PEi386)
185 186 187
static int ocVerifyImage_PEi386 ( ObjectCode* oc );
static int ocGetNames_PEi386    ( ObjectCode* oc );
static int ocResolve_PEi386     ( ObjectCode* oc );
188 189
static void *lookupSymbolInDLLs ( unsigned char *lbl );
static void zapTrailingAtSign   ( unsigned char *sym );
190 191 192 193
#elif defined(OBJFORMAT_MACHO)
static int ocVerifyImage_MachO    ( ObjectCode* oc );
static int ocGetNames_MachO       ( ObjectCode* oc );
static int ocResolve_MachO        ( ObjectCode* oc );
194

Ian Lynagh's avatar
Ian Lynagh committed
195
#ifndef USE_MMAP
196
static int machoGetMisalignment( FILE * );
Ian Lynagh's avatar
Ian Lynagh committed
197
#endif
198 199 200
#if defined(powerpc_HOST_ARCH) || defined(x86_64_HOST_ARCH)
static int ocAllocateSymbolExtras_MachO ( ObjectCode* oc );
#endif
201
#ifdef powerpc_HOST_ARCH
202
static void machoInitSymbolsWithoutUnderscore( void );
203
#endif
204
#endif
205

206 207 208 209 210 211 212 213 214 215 216 217 218
/* on x86_64 we have a problem with relocating symbol references in
 * code that was compiled without -fPIC.  By default, the small memory
 * model is used, which assumes that symbol references can fit in a
 * 32-bit slot.  The system dynamic linker makes this work for
 * references to shared libraries by either (a) allocating a jump
 * table slot for code references, or (b) moving the symbol at load
 * time (and copying its contents, if necessary) for data references.
 *
 * We unfortunately can't tell whether symbol references are to code
 * or data.  So for now we assume they are code (the vast majority
 * are), and allocate jump-table slots.  Unfortunately this will
 * SILENTLY generate crashing code for data references.  This hack is
 * enabled by X86_64_ELF_NONPIC_HACK.
Ian Lynagh's avatar
Ian Lynagh committed
219
 *
220 221 222 223 224 225 226 227
 * One workaround is to use shared Haskell libraries.  This is
 * coming.  Another workaround is to keep the static libraries but
 * compile them with -fPIC, because that will generate PIC references
 * to data which can be relocated.  The PIC code is still too green to
 * do this systematically, though.
 *
 * See bug #781
 * See thread http://www.haskell.org/pipermail/cvs-ghc/2007-September/038458.html
228 229 230 231 232 233 234 235 236 237 238 239
 *
 * Naming Scheme for Symbol Macros
 *
 * SymI_*: symbol is internal to the RTS. It resides in an object
 *         file/library that is statically.
 * SymE_*: symbol is external to the RTS library. It might be linked
 *         dynamically.
 *
 * Sym*_HasProto  : the symbol prototype is imported in an include file
 *                  or defined explicitly
 * Sym*_NeedsProto: the symbol is undefined and we add a dummy
 *                  default proto extern void sym(void);
240 241
 */
#define X86_64_ELF_NONPIC_HACK 1
242

243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
/* Link objects into the lower 2Gb on x86_64.  GHC assumes the
 * small memory model on this architecture (see gcc docs,
 * -mcmodel=small).
 *
 * MAP_32BIT not available on OpenBSD/amd64
 */
#if defined(x86_64_HOST_ARCH) && defined(MAP_32BIT)
#define TRY_MAP_32BIT MAP_32BIT
#else
#define TRY_MAP_32BIT 0
#endif

/*
 * Due to the small memory model (see above), on x86_64 we have to map
 * all our non-PIC object files into the low 2Gb of the address space
 * (why 2Gb and not 4Gb?  Because all addresses must be reachable
 * using a 32-bit signed PC-relative offset). On Linux we can do this
 * using the MAP_32BIT flag to mmap(), however on other OSs
 * (e.g. *BSD, see #2063, and also on Linux inside Xen, see #2512), we
 * can't do this.  So on these systems, we have to pick a base address
 * in the low 2Gb of the address space and try to allocate memory from
 * there.
 *
 * We pick a default address based on the OS, but also make this
 * configurable via an RTS flag (+RTS -xm)
 */
269
#if !defined(ALWAYS_PIC) && defined(x86_64_HOST_ARCH)
270 271 272 273 274 275 276 277 278

#if defined(MAP_32BIT)
// Try to use MAP_32BIT
#define MMAP_32BIT_BASE_DEFAULT 0
#else
// A guess: 1Gb.
#define MMAP_32BIT_BASE_DEFAULT 0x40000000
#endif

Ian Lynagh's avatar
Ian Lynagh committed
279
static void *mmap_32bit_base = (void *)MMAP_32BIT_BASE_DEFAULT;
280 281 282 283 284 285 286
#endif

/* MAP_ANONYMOUS is MAP_ANON on some systems, e.g. OpenBSD */
#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
#define MAP_ANONYMOUS MAP_ANON
#endif

287 288 289 290
/* -----------------------------------------------------------------------------
 * Built-in symbols from the RTS
 */

291 292 293 294 295
typedef struct _RtsSymbolVal {
    char   *lbl;
    void   *addr;
} RtsSymbolVal;

Ian Lynagh's avatar
Ian Lynagh committed
296
#define Maybe_Stable_Names      SymI_HasProto(stg_mkWeakzh)                     \
297
                                SymI_HasProto(stg_mkWeakNoFinalizzerzh)         \
Ian Lynagh's avatar
Ian Lynagh committed
298 299 300
                                SymI_HasProto(stg_mkWeakForeignEnvzh)           \
                                SymI_HasProto(stg_makeStableNamezh)             \
                                SymI_HasProto(stg_finalizzeWeakzh)
301

302
#if !defined (mingw32_HOST_OS)
303
#define RTS_POSIX_ONLY_SYMBOLS                  \
Ian Lynagh's avatar
Ian Lynagh committed
304 305 306
      SymI_HasProto(__hscore_get_saved_termios) \
      SymI_HasProto(__hscore_set_saved_termios) \
      SymI_HasProto(shutdownHaskellAndSignal)   \
Simon Marlow's avatar
Simon Marlow committed
307 308
      SymI_HasProto(lockFile)                   \
      SymI_HasProto(unlockFile)                 \
Ian Lynagh's avatar
Ian Lynagh committed
309 310
      SymI_HasProto(signal_handlers)            \
      SymI_HasProto(stg_sig_install)            \
311
      SymI_HasProto(rtsTimerSignal)             \
Simon Marlow's avatar
Simon Marlow committed
312
      SymI_HasProto(atexit)                     \
313
      SymI_NeedsProto(nocldstop)
sof's avatar
sof committed
314
#endif
315

316
#if defined (cygwin32_HOST_OS)
sof's avatar
sof committed
317 318 319
#define RTS_MINGW_ONLY_SYMBOLS /**/
/* Don't have the ability to read import libs / archives, so
 * we have to stupidly list a lot of what libcygwin.a
320
 * exports; sigh.
sof's avatar
sof committed
321
 */
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
#define RTS_CYGWIN_ONLY_SYMBOLS                          \
      SymI_HasProto(regfree)                             \
      SymI_HasProto(regexec)                             \
      SymI_HasProto(regerror)                            \
      SymI_HasProto(regcomp)                             \
      SymI_HasProto(__errno)                             \
      SymI_HasProto(access)                              \
      SymI_HasProto(chmod)                               \
      SymI_HasProto(chdir)                               \
      SymI_HasProto(close)                               \
      SymI_HasProto(creat)                               \
      SymI_HasProto(dup)                                 \
      SymI_HasProto(dup2)                                \
      SymI_HasProto(fstat)                               \
      SymI_HasProto(fcntl)                               \
      SymI_HasProto(getcwd)                              \
      SymI_HasProto(getenv)                              \
      SymI_HasProto(lseek)                               \
      SymI_HasProto(open)                                \
      SymI_HasProto(fpathconf)                           \
      SymI_HasProto(pathconf)                            \
      SymI_HasProto(stat)                                \
      SymI_HasProto(pow)                                 \
      SymI_HasProto(tanh)                                \
      SymI_HasProto(cosh)                                \
      SymI_HasProto(sinh)                                \
      SymI_HasProto(atan)                                \
      SymI_HasProto(acos)                                \
      SymI_HasProto(asin)                                \
      SymI_HasProto(tan)                                 \
      SymI_HasProto(cos)                                 \
      SymI_HasProto(sin)                                 \
      SymI_HasProto(exp)                                 \
      SymI_HasProto(log)                                 \
      SymI_HasProto(sqrt)                                \
      SymI_HasProto(localtime_r)                         \
      SymI_HasProto(gmtime_r)                            \
      SymI_HasProto(mktime)                              \
      SymI_NeedsProto(_imp___tzname)                     \
      SymI_HasProto(gettimeofday)                        \
      SymI_HasProto(timezone)                            \
      SymI_HasProto(tcgetattr)                           \
      SymI_HasProto(tcsetattr)                           \
      SymI_HasProto(memcpy)                              \
      SymI_HasProto(memmove)                             \
      SymI_HasProto(realloc)                             \
      SymI_HasProto(malloc)                              \
      SymI_HasProto(free)                                \
      SymI_HasProto(fork)                                \
      SymI_HasProto(lstat)                               \
      SymI_HasProto(isatty)                              \
      SymI_HasProto(mkdir)                               \
      SymI_HasProto(opendir)                             \
      SymI_HasProto(readdir)                             \
      SymI_HasProto(rewinddir)                           \
      SymI_HasProto(closedir)                            \
      SymI_HasProto(link)                                \
      SymI_HasProto(mkfifo)                              \
      SymI_HasProto(pipe)                                \
      SymI_HasProto(read)                                \
      SymI_HasProto(rename)                              \
      SymI_HasProto(rmdir)                               \
      SymI_HasProto(select)                              \
      SymI_HasProto(system)                              \
      SymI_HasProto(write)                               \
      SymI_HasProto(strcmp)                              \
      SymI_HasProto(strcpy)                              \
      SymI_HasProto(strncpy)                             \
      SymI_HasProto(strerror)                            \
      SymI_HasProto(sigaddset)                           \
      SymI_HasProto(sigemptyset)                         \
      SymI_HasProto(sigprocmask)                         \
      SymI_HasProto(umask)                               \
      SymI_HasProto(uname)                               \
      SymI_HasProto(unlink)                              \
      SymI_HasProto(utime)                               \
      SymI_HasProto(waitpid)
399

Ian Lynagh's avatar
Ian Lynagh committed
400
#elif defined(mingw32_HOST_OS)
sof's avatar
sof committed
401 402
#define RTS_POSIX_ONLY_SYMBOLS  /**/
#define RTS_CYGWIN_ONLY_SYMBOLS /**/
403

404
#if HAVE_GETTIMEOFDAY
405
#define RTS_MINGW_GETTIMEOFDAY_SYM SymI_NeedsProto(gettimeofday)
406 407 408 409
#else
#define RTS_MINGW_GETTIMEOFDAY_SYM /**/
#endif

410 411 412 413 414 415
#if HAVE___MINGW_VFPRINTF
#define RTS___MINGW_VFPRINTF_SYM SymI_HasProto(__mingw_vfprintf)
#else
#define RTS___MINGW_VFPRINTF_SYM /**/
#endif

Ian Lynagh's avatar
Ian Lynagh committed
416
#if defined(i386_HOST_ARCH)
417
#define RTS_WIN32_ONLY(X) X
Ian Lynagh's avatar
Ian Lynagh committed
418
#else
419 420 421 422 423 424 425
#define RTS_WIN32_ONLY(X) /**/
#endif

#if defined(x86_64_HOST_ARCH)
#define RTS_WIN64_ONLY(X) X
#else
#define RTS_WIN64_ONLY(X) /**/
Ian Lynagh's avatar
Ian Lynagh committed
426 427
#endif

428 429
/* These are statically linked from the mingw libraries into the ghc
   executable, so we have to employ this hack. */
430
#define RTS_MINGW_ONLY_SYMBOLS                           \
Ian Lynagh's avatar
Ian Lynagh committed
431 432 433
      SymI_HasProto(stg_asyncReadzh)                     \
      SymI_HasProto(stg_asyncWritezh)                    \
      SymI_HasProto(stg_asyncDoProczh)                   \
434 435
      SymI_HasProto(getWin32ProgArgv)                    \
      SymI_HasProto(setWin32ProgArgv)                    \
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456
      SymI_HasProto(memset)                              \
      SymI_HasProto(inet_ntoa)                           \
      SymI_HasProto(inet_addr)                           \
      SymI_HasProto(htonl)                               \
      SymI_HasProto(recvfrom)                            \
      SymI_HasProto(listen)                              \
      SymI_HasProto(bind)                                \
      SymI_HasProto(shutdown)                            \
      SymI_HasProto(connect)                             \
      SymI_HasProto(htons)                               \
      SymI_HasProto(ntohs)                               \
      SymI_HasProto(getservbyname)                       \
      SymI_HasProto(getservbyport)                       \
      SymI_HasProto(getprotobynumber)                    \
      SymI_HasProto(getprotobyname)                      \
      SymI_HasProto(gethostbyname)                       \
      SymI_HasProto(gethostbyaddr)                       \
      SymI_HasProto(gethostname)                         \
      SymI_HasProto(strcpy)                              \
      SymI_HasProto(strncpy)                             \
      SymI_HasProto(abort)                               \
457
      RTS_WIN32_ONLY(SymI_NeedsProto(_alloca))           \
Ian Lynagh's avatar
Ian Lynagh committed
458 459 460 461 462 463 464 465 466 467 468
      SymI_HasProto(isxdigit)                            \
      SymI_HasProto(isupper)                             \
      SymI_HasProto(ispunct)                             \
      SymI_HasProto(islower)                             \
      SymI_HasProto(isspace)                             \
      SymI_HasProto(isprint)                             \
      SymI_HasProto(isdigit)                             \
      SymI_HasProto(iscntrl)                             \
      SymI_HasProto(isalpha)                             \
      SymI_HasProto(isalnum)                             \
      SymI_HasProto(isascii)                             \
469
      RTS___MINGW_VFPRINTF_SYM                           \
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
      SymI_HasProto(strcmp)                              \
      SymI_HasProto(memmove)                             \
      SymI_HasProto(realloc)                             \
      SymI_HasProto(malloc)                              \
      SymI_HasProto(pow)                                 \
      SymI_HasProto(tanh)                                \
      SymI_HasProto(cosh)                                \
      SymI_HasProto(sinh)                                \
      SymI_HasProto(atan)                                \
      SymI_HasProto(acos)                                \
      SymI_HasProto(asin)                                \
      SymI_HasProto(tan)                                 \
      SymI_HasProto(cos)                                 \
      SymI_HasProto(sin)                                 \
      SymI_HasProto(exp)                                 \
      SymI_HasProto(log)                                 \
      SymI_HasProto(sqrt)                                \
      SymI_HasProto(powf)                                \
      SymI_HasProto(tanhf)                               \
      SymI_HasProto(coshf)                               \
      SymI_HasProto(sinhf)                               \
      SymI_HasProto(atanf)                               \
      SymI_HasProto(acosf)                               \
      SymI_HasProto(asinf)                               \
      SymI_HasProto(tanf)                                \
      SymI_HasProto(cosf)                                \
      SymI_HasProto(sinf)                                \
      SymI_HasProto(expf)                                \
      SymI_HasProto(logf)                                \
      SymI_HasProto(sqrtf)                               \
Ian Lynagh's avatar
Ian Lynagh committed
500
      SymI_HasProto(erf)                                 \
501 502 503
      SymI_HasProto(erfc)                                \
      SymI_HasProto(erff)                                \
      SymI_HasProto(erfcf)                               \
504 505 506 507
      SymI_HasProto(memcpy)                              \
      SymI_HasProto(rts_InstallConsoleEvent)             \
      SymI_HasProto(rts_ConsoleHandlerDone)              \
      SymI_NeedsProto(mktime)                            \
508 509 510 511 512
      RTS_WIN32_ONLY(SymI_NeedsProto(_imp___timezone))   \
      RTS_WIN32_ONLY(SymI_NeedsProto(_imp___tzname))     \
      RTS_WIN32_ONLY(SymI_NeedsProto(_imp__tzname))      \
      RTS_WIN32_ONLY(SymI_NeedsProto(_imp___iob))        \
      RTS_WIN32_ONLY(SymI_NeedsProto(_imp___osver))      \
513 514 515 516 517
      SymI_NeedsProto(localtime)                         \
      SymI_NeedsProto(gmtime)                            \
      SymI_NeedsProto(opendir)                           \
      SymI_NeedsProto(readdir)                           \
      SymI_NeedsProto(rewinddir)                         \
518 519 520
      RTS_WIN32_ONLY(SymI_NeedsProto(_imp____mb_cur_max)) \
      RTS_WIN32_ONLY(SymI_NeedsProto(_imp___pctype))     \
      RTS_WIN32_ONLY(SymI_NeedsProto(__chkstk))          \
521 522 523 524 525 526
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp___iob_func))  \
      RTS_WIN64_ONLY(SymI_NeedsProto(___chkstk_ms))      \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_localeconv))  \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_islower))     \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_isspace))     \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_isxdigit))    \
527 528 529 530 531
      RTS_WIN64_ONLY(SymI_HasProto(close))               \
      RTS_WIN64_ONLY(SymI_HasProto(read))                \
      RTS_WIN64_ONLY(SymI_HasProto(dup))                 \
      RTS_WIN64_ONLY(SymI_HasProto(dup2))                \
      RTS_WIN64_ONLY(SymI_HasProto(write))               \
532
      SymI_NeedsProto(getpid)                            \
533
      RTS_WIN64_ONLY(SymI_HasProto(access))              \
534
      SymI_HasProto(chmod)                               \
535 536
      RTS_WIN64_ONLY(SymI_HasProto(creat))               \
      RTS_WIN64_ONLY(SymI_HasProto(umask))               \
537
      SymI_HasProto(unlink)                              \
538 539
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp__errno))      \
      RTS_WIN64_ONLY(SymI_NeedsProto(ftruncate64))       \
540
      RTS_WIN64_ONLY(SymI_HasProto(setmode))             \
541 542 543
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp__wstat64))    \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp__fstat64))    \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp__wsopen))     \
544
      RTS_WIN64_ONLY(SymI_HasProto(__imp__environ))      \
545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GetFileType))                 \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GetLastError))                \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_QueryPerformanceFrequency))   \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_QueryPerformanceCounter))     \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GetTickCount))                \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_WaitForSingleObject))         \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_PeekConsoleInputA))           \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_ReadConsoleInputA))           \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_PeekNamedPipe))               \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp__isatty))                     \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_select))                      \
      RTS_WIN64_ONLY(SymI_HasProto(isatty))                              \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp__get_osfhandle))              \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GetConsoleMode))              \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_SetConsoleMode))              \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_FlushConsoleInputBuffer))     \
561
      RTS_WIN64_ONLY(SymI_HasProto(free))                                \
Ian Lynagh's avatar
Ian Lynagh committed
562
      RTS_WIN64_ONLY(SymI_NeedsProto(raise))                             \
Ian Lynagh's avatar
Ian Lynagh committed
563
      RTS_WIN64_ONLY(SymI_NeedsProto(_getpid))                           \
Ian Lynagh's avatar
Ian Lynagh committed
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
      RTS_WIN64_ONLY(SymI_HasProto(getc))                                \
      RTS_WIN64_ONLY(SymI_HasProto(ungetc))                              \
      RTS_WIN64_ONLY(SymI_HasProto(puts))                                \
      RTS_WIN64_ONLY(SymI_HasProto(putc))                                \
      RTS_WIN64_ONLY(SymI_HasProto(putchar))                             \
      RTS_WIN64_ONLY(SymI_HasProto(fputc))                               \
      RTS_WIN64_ONLY(SymI_HasProto(fread))                               \
      RTS_WIN64_ONLY(SymI_HasProto(fwrite))                              \
      RTS_WIN64_ONLY(SymI_HasProto(ferror))                              \
      RTS_WIN64_ONLY(SymI_HasProto(printf))                              \
      RTS_WIN64_ONLY(SymI_HasProto(fprintf))                             \
      RTS_WIN64_ONLY(SymI_HasProto(sprintf))                             \
      RTS_WIN64_ONLY(SymI_HasProto(vsprintf))                            \
      RTS_WIN64_ONLY(SymI_HasProto(sscanf))                              \
      RTS_WIN64_ONLY(SymI_HasProto(ldexp))                               \
      RTS_WIN64_ONLY(SymI_HasProto(strlen))                              \
      RTS_WIN64_ONLY(SymI_HasProto(strnlen))                             \
      RTS_WIN64_ONLY(SymI_HasProto(strchr))                              \
      RTS_WIN64_ONLY(SymI_HasProto(strtol))                              \
      RTS_WIN64_ONLY(SymI_HasProto(strerror))                            \
Ian Lynagh's avatar
Ian Lynagh committed
584 585 586 587
      RTS_WIN64_ONLY(SymI_HasProto(memchr))                              \
      RTS_WIN64_ONLY(SymI_HasProto(memcmp))                              \
      RTS_WIN64_ONLY(SymI_HasProto(wcscpy))                              \
      RTS_WIN64_ONLY(SymI_HasProto(wcslen))                              \
Ian Lynagh's avatar
Ian Lynagh committed
588
      RTS_WIN64_ONLY(SymI_HasProto(_lseeki64))                           \
Ian Lynagh's avatar
Ian Lynagh committed
589
      RTS_WIN64_ONLY(SymI_HasProto(_wchmod))                             \
Ian Lynagh's avatar
Ian Lynagh committed
590 591 592 593 594
      RTS_WIN64_ONLY(SymI_HasProto(closesocket))                         \
      RTS_WIN64_ONLY(SymI_HasProto(send))                                \
      RTS_WIN64_ONLY(SymI_HasProto(recv))                                \
      RTS_WIN64_ONLY(SymI_HasProto(bsearch))                             \
      RTS_WIN64_ONLY(SymI_HasProto(CommandLineToArgvW))                  \
Ian Lynagh's avatar
Ian Lynagh committed
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
      RTS_WIN64_ONLY(SymI_HasProto(CreateBitmap))                        \
      RTS_WIN64_ONLY(SymI_HasProto(CreateBitmapIndirect))                \
      RTS_WIN64_ONLY(SymI_HasProto(CreateCompatibleBitmap))              \
      RTS_WIN64_ONLY(SymI_HasProto(CreateDIBPatternBrushPt))             \
      RTS_WIN64_ONLY(SymI_HasProto(CreateDIBitmap))                      \
      RTS_WIN64_ONLY(SymI_HasProto(SetBitmapDimensionEx))                \
      RTS_WIN64_ONLY(SymI_HasProto(GetBitmapDimensionEx))                \
      RTS_WIN64_ONLY(SymI_HasProto(GetStockObject))                      \
      RTS_WIN64_ONLY(SymI_HasProto(GetObjectW))                          \
      RTS_WIN64_ONLY(SymI_HasProto(DeleteObject))                        \
      RTS_WIN64_ONLY(SymI_HasProto(SetDIBits))                           \
      RTS_WIN64_ONLY(SymI_HasProto(GetDIBits))                           \
      RTS_WIN64_ONLY(SymI_HasProto(CreateSolidBrush))                    \
      RTS_WIN64_ONLY(SymI_HasProto(CreateHatchBrush))                    \
      RTS_WIN64_ONLY(SymI_HasProto(CreatePatternBrush))                  \
      RTS_WIN64_ONLY(SymI_HasProto(CreateFontW))                         \
      RTS_WIN64_ONLY(SymI_HasProto(AngleArc)) \
      RTS_WIN64_ONLY(SymI_HasProto(Arc)) \
      RTS_WIN64_ONLY(SymI_HasProto(ArcTo)) \
      RTS_WIN64_ONLY(SymI_HasProto(BeginPath)) \
      RTS_WIN64_ONLY(SymI_HasProto(BitBlt)) \
      RTS_WIN64_ONLY(SymI_HasProto(CancelDC)) \
      RTS_WIN64_ONLY(SymI_HasProto(Chord)) \
      RTS_WIN64_ONLY(SymI_HasProto(CloseFigure)) \
      RTS_WIN64_ONLY(SymI_HasProto(CombineRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(CreateCompatibleDC)) \
      RTS_WIN64_ONLY(SymI_HasProto(CreateEllipticRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(CreateEllipticRgnIndirect)) \
      RTS_WIN64_ONLY(SymI_HasProto(CreatePen)) \
      RTS_WIN64_ONLY(SymI_HasProto(CreatePolygonRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(CreateRectRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(CreateRectRgnIndirect)) \
      RTS_WIN64_ONLY(SymI_HasProto(CreateRoundRectRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(DeleteDC)) \
      RTS_WIN64_ONLY(SymI_HasProto(Ellipse)) \
      RTS_WIN64_ONLY(SymI_HasProto(EndPath)) \
      RTS_WIN64_ONLY(SymI_HasProto(EqualRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(ExtSelectClipRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(FillPath)) \
      RTS_WIN64_ONLY(SymI_HasProto(FillRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(FlattenPath)) \
      RTS_WIN64_ONLY(SymI_HasProto(FrameRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetArcDirection)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetBkColor)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetBkMode)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetBrushOrgEx)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetCurrentObject)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetDCOrgEx)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetGraphicsMode)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetMiterLimit)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetPolyFillMode)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetRgnBox)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetStretchBltMode)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetTextAlign)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetTextCharacterExtra)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetTextColor)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetTextExtentPoint32W)) \
      RTS_WIN64_ONLY(SymI_HasProto(InvertRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(LineTo)) \
      RTS_WIN64_ONLY(SymI_HasProto(MaskBlt)) \
      RTS_WIN64_ONLY(SymI_HasProto(MoveToEx)) \
      RTS_WIN64_ONLY(SymI_HasProto(OffsetRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(PaintRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(PathToRegion)) \
      RTS_WIN64_ONLY(SymI_HasProto(Pie)) \
      RTS_WIN64_ONLY(SymI_HasProto(PlgBlt)) \
      RTS_WIN64_ONLY(SymI_HasProto(PolyBezier)) \
      RTS_WIN64_ONLY(SymI_HasProto(PolyBezierTo)) \
      RTS_WIN64_ONLY(SymI_HasProto(Polygon)) \
      RTS_WIN64_ONLY(SymI_HasProto(Polyline)) \
      RTS_WIN64_ONLY(SymI_HasProto(PolylineTo)) \
      RTS_WIN64_ONLY(SymI_HasProto(PtInRegion)) \
      RTS_WIN64_ONLY(SymI_HasProto(Rectangle)) \
      RTS_WIN64_ONLY(SymI_HasProto(RectInRegion)) \
      RTS_WIN64_ONLY(SymI_HasProto(RestoreDC)) \
      RTS_WIN64_ONLY(SymI_HasProto(RoundRect)) \
      RTS_WIN64_ONLY(SymI_HasProto(SaveDC)) \
      RTS_WIN64_ONLY(SymI_HasProto(SelectClipPath)) \
      RTS_WIN64_ONLY(SymI_HasProto(SelectClipRgn)) \
      RTS_WIN64_ONLY(SymI_HasProto(SelectObject)) \
      RTS_WIN64_ONLY(SymI_HasProto(SelectPalette)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetArcDirection)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetBkColor)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetBkMode)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetBrushOrgEx)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetGraphicsMode)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetMiterLimit)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetPolyFillMode)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetStretchBltMode)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetTextAlign)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetTextCharacterExtra)) \
      RTS_WIN64_ONLY(SymI_HasProto(SetTextColor)) \
      RTS_WIN64_ONLY(SymI_HasProto(StretchBlt)) \
      RTS_WIN64_ONLY(SymI_HasProto(StrokeAndFillPath)) \
      RTS_WIN64_ONLY(SymI_HasProto(StrokePath)) \
      RTS_WIN64_ONLY(SymI_HasProto(TextOutW)) \
      RTS_WIN64_ONLY(SymI_HasProto(timeGetTime)) \
      RTS_WIN64_ONLY(SymI_HasProto(WidenPath)) \
      RTS_WIN64_ONLY(SymI_HasProto(GetFileSecurityW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegCloseKey)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegConnectRegistryW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegCreateKeyExW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegCreateKeyW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegDeleteKeyW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegDeleteValueW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegEnumKeyW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegEnumValueW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegFlushKey)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegLoadKeyW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegNotifyChangeKeyValue)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegOpenKeyExW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegOpenKeyW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegQueryInfoKeyW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegQueryValueExW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegQueryValueW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegReplaceKeyW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegRestoreKeyW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegSaveKeyW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegSetValueExW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegSetValueW)) \
      RTS_WIN64_ONLY(SymI_HasProto(RegUnLoadKeyW)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(SHGetFolderPathW)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_SetWindowLongPtrW)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GetWindowLongPtrW)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_MenuItemFromPoint)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_ChildWindowFromPoint)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_ChildWindowFromPointEx)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_DeleteObject)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_UnmapViewOfFile)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_CloseHandle)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_FreeLibrary)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GetMessageW)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_TranslateMessage)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_DispatchMessageW)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_DefWindowProcW)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GetDIBits)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GlobalAlloc)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GlobalFree)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_CreateFileW)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_WriteFile)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_CreateCompatibleBitmap)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_SelectObject)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_Polygon)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_FormatMessageW)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp__localtime64)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp__tzname)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp__timezone)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_CreatePipe)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_SetHandleInformation)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GetStdHandle)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GetCurrentProcess)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_DuplicateHandle)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_CreateProcessW)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_TerminateProcess)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp__open_osfhandle)) \
      RTS_WIN64_ONLY(SymI_NeedsProto(__imp_GetExitCodeProcess)) \
Ian Lynagh's avatar
Ian Lynagh committed
751
      RTS_MINGW_GETTIMEOFDAY_SYM                         \
752
      SymI_NeedsProto(closedir)
Ian Lynagh's avatar
Ian Lynagh committed
753 754 755 756

#else
#define RTS_MINGW_ONLY_SYMBOLS /**/
#define RTS_CYGWIN_ONLY_SYMBOLS /**/
757
#endif
758

759

760
#if defined(darwin_HOST_OS) && HAVE_PRINTF_LDBLSTUB
Ian Lynagh's avatar
Ian Lynagh committed
761
#define RTS_DARWIN_ONLY_SYMBOLS                             \
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805
     SymI_NeedsProto(asprintf$LDBLStub)                     \
     SymI_NeedsProto(err$LDBLStub)                          \
     SymI_NeedsProto(errc$LDBLStub)                         \
     SymI_NeedsProto(errx$LDBLStub)                         \
     SymI_NeedsProto(fprintf$LDBLStub)                      \
     SymI_NeedsProto(fscanf$LDBLStub)                       \
     SymI_NeedsProto(fwprintf$LDBLStub)                     \
     SymI_NeedsProto(fwscanf$LDBLStub)                      \
     SymI_NeedsProto(printf$LDBLStub)                       \
     SymI_NeedsProto(scanf$LDBLStub)                        \
     SymI_NeedsProto(snprintf$LDBLStub)                     \
     SymI_NeedsProto(sprintf$LDBLStub)                      \
     SymI_NeedsProto(sscanf$LDBLStub)                       \
     SymI_NeedsProto(strtold$LDBLStub)                      \
     SymI_NeedsProto(swprintf$LDBLStub)                     \
     SymI_NeedsProto(swscanf$LDBLStub)                      \
     SymI_NeedsProto(syslog$LDBLStub)                       \
     SymI_NeedsProto(vasprintf$LDBLStub)                    \
     SymI_NeedsProto(verr$LDBLStub)                         \
     SymI_NeedsProto(verrc$LDBLStub)                        \
     SymI_NeedsProto(verrx$LDBLStub)                        \
     SymI_NeedsProto(vfprintf$LDBLStub)                     \
     SymI_NeedsProto(vfscanf$LDBLStub)                      \
     SymI_NeedsProto(vfwprintf$LDBLStub)                    \
     SymI_NeedsProto(vfwscanf$LDBLStub)                     \
     SymI_NeedsProto(vprintf$LDBLStub)                      \
     SymI_NeedsProto(vscanf$LDBLStub)                       \
     SymI_NeedsProto(vsnprintf$LDBLStub)                    \
     SymI_NeedsProto(vsprintf$LDBLStub)                     \
     SymI_NeedsProto(vsscanf$LDBLStub)                      \
     SymI_NeedsProto(vswprintf$LDBLStub)                    \
     SymI_NeedsProto(vswscanf$LDBLStub)                     \
     SymI_NeedsProto(vsyslog$LDBLStub)                      \
     SymI_NeedsProto(vwarn$LDBLStub)                        \
     SymI_NeedsProto(vwarnc$LDBLStub)                       \
     SymI_NeedsProto(vwarnx$LDBLStub)                       \
     SymI_NeedsProto(vwprintf$LDBLStub)                     \
     SymI_NeedsProto(vwscanf$LDBLStub)                      \
     SymI_NeedsProto(warn$LDBLStub)                         \
     SymI_NeedsProto(warnc$LDBLStub)                        \
     SymI_NeedsProto(warnx$LDBLStub)                        \
     SymI_NeedsProto(wcstold$LDBLStub)                      \
     SymI_NeedsProto(wprintf$LDBLStub)                      \
     SymI_NeedsProto(wscanf$LDBLStub)
806 807 808 809
#else
#define RTS_DARWIN_ONLY_SYMBOLS
#endif

sof's avatar
sof committed
810
#ifndef SMP
811
# define MAIN_CAP_SYM SymI_HasProto(MainCapability)
sof's avatar
sof committed
812 813 814
#else
# define MAIN_CAP_SYM
#endif
815

sof's avatar
sof committed
816
#if !defined(mingw32_HOST_OS)
Ian Lynagh's avatar
Ian Lynagh committed
817
#define RTS_USER_SIGNALS_SYMBOLS        \
818
   SymI_HasProto(setIOManagerControlFd) \
Ian Lynagh's avatar
Ian Lynagh committed
819 820 821
   SymI_HasProto(setIOManagerWakeupFd)  \
   SymI_HasProto(ioManagerWakeup)       \
   SymI_HasProto(blockUserSignals)      \
822
   SymI_HasProto(unblockUserSignals)
sof's avatar
sof committed
823
#else
Ian Lynagh's avatar
Ian Lynagh committed
824 825 826 827 828
#define RTS_USER_SIGNALS_SYMBOLS        \
   SymI_HasProto(ioManagerWakeup)       \
   SymI_HasProto(sendIOManagerEvent)    \
   SymI_HasProto(readIOManagerEvent)    \
   SymI_HasProto(getIOManagerEvent)     \
829
   SymI_HasProto(console_handler)
sof's avatar
sof committed
830 831
#endif

832 833 834 835 836 837 838 839 840 841 842 843 844 845 846
#define RTS_LIBFFI_SYMBOLS                                  \
     SymE_NeedsProto(ffi_prep_cif)                          \
     SymE_NeedsProto(ffi_call)                              \
     SymE_NeedsProto(ffi_type_void)                         \
     SymE_NeedsProto(ffi_type_float)                        \
     SymE_NeedsProto(ffi_type_double)                       \
     SymE_NeedsProto(ffi_type_sint64)                       \
     SymE_NeedsProto(ffi_type_uint64)                       \
     SymE_NeedsProto(ffi_type_sint32)                       \
     SymE_NeedsProto(ffi_type_uint32)                       \
     SymE_NeedsProto(ffi_type_sint16)                       \
     SymE_NeedsProto(ffi_type_uint16)                       \
     SymE_NeedsProto(ffi_type_sint8)                        \
     SymE_NeedsProto(ffi_type_uint8)                        \
     SymE_NeedsProto(ffi_type_pointer)
847

848 849 850
#ifdef TABLES_NEXT_TO_CODE
#define RTS_RET_SYMBOLS /* nothing */
#else
Ian Lynagh's avatar
Ian Lynagh committed
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866
#define RTS_RET_SYMBOLS                                 \
      SymI_HasProto(stg_enter_ret)                      \
      SymI_HasProto(stg_gc_fun_ret)                     \
      SymI_HasProto(stg_ap_v_ret)                       \
      SymI_HasProto(stg_ap_f_ret)                       \
      SymI_HasProto(stg_ap_d_ret)                       \
      SymI_HasProto(stg_ap_l_ret)                       \
      SymI_HasProto(stg_ap_n_ret)                       \
      SymI_HasProto(stg_ap_p_ret)                       \
      SymI_HasProto(stg_ap_pv_ret)                      \
      SymI_HasProto(stg_ap_pp_ret)                      \
      SymI_HasProto(stg_ap_ppv_ret)                     \
      SymI_HasProto(stg_ap_ppp_ret)                     \
      SymI_HasProto(stg_ap_pppv_ret)                    \
      SymI_HasProto(stg_ap_pppp_ret)                    \
      SymI_HasProto(stg_ap_ppppp_ret)                   \
867
      SymI_HasProto(stg_ap_pppppp_ret)
868 869
#endif

870 871
/* Modules compiled with -ticky may mention ticky counters */
/* This list should marry up with the one in $(TOP)/includes/stg/Ticky.h */
Ian Lynagh's avatar
Ian Lynagh committed
872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905
#define RTS_TICKY_SYMBOLS                               \
      SymI_NeedsProto(ticky_entry_ctrs)                 \
      SymI_NeedsProto(top_ct)                           \
                                                        \
      SymI_HasProto(ENT_VIA_NODE_ctr)                   \
      SymI_HasProto(ENT_STATIC_THK_ctr)                 \
      SymI_HasProto(ENT_DYN_THK_ctr)                    \
      SymI_HasProto(ENT_STATIC_FUN_DIRECT_ctr)          \
      SymI_HasProto(ENT_DYN_FUN_DIRECT_ctr)             \
      SymI_HasProto(ENT_STATIC_CON_ctr)                 \
      SymI_HasProto(ENT_DYN_CON_ctr)                    \
      SymI_HasProto(ENT_STATIC_IND_ctr)                 \
      SymI_HasProto(ENT_DYN_IND_ctr)                    \
      SymI_HasProto(ENT_PERM_IND_ctr)                   \
      SymI_HasProto(ENT_PAP_ctr)                        \
      SymI_HasProto(ENT_AP_ctr)                         \
      SymI_HasProto(ENT_AP_STACK_ctr)                   \
      SymI_HasProto(ENT_BH_ctr)                         \
      SymI_HasProto(UNKNOWN_CALL_ctr)                   \
      SymI_HasProto(SLOW_CALL_v_ctr)                    \
      SymI_HasProto(SLOW_CALL_f_ctr)                    \
      SymI_HasProto(SLOW_CALL_d_ctr)                    \
      SymI_HasProto(SLOW_CALL_l_ctr)                    \
      SymI_HasProto(SLOW_CALL_n_ctr)                    \
      SymI_HasProto(SLOW_CALL_p_ctr)                    \
      SymI_HasProto(SLOW_CALL_pv_ctr)                   \
      SymI_HasProto(SLOW_CALL_pp_ctr)                   \
      SymI_HasProto(SLOW_CALL_ppv_ctr)                  \
      SymI_HasProto(SLOW_CALL_ppp_ctr)                  \
      SymI_HasProto(SLOW_CALL_pppv_ctr)                 \
      SymI_HasProto(SLOW_CALL_pppp_ctr)                 \
      SymI_HasProto(SLOW_CALL_ppppp_ctr)                \
      SymI_HasProto(SLOW_CALL_pppppp_ctr)               \
      SymI_HasProto(SLOW_CALL_OTHER_ctr)                \
906
      SymI_HasProto(ticky_slow_call_unevald)            \
Ian Lynagh's avatar
Ian Lynagh committed
907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979
      SymI_HasProto(SLOW_CALL_ctr)                      \
      SymI_HasProto(MULTI_CHUNK_SLOW_CALL_ctr)          \
      SymI_HasProto(MULTI_CHUNK_SLOW_CALL_CHUNKS_ctr)   \
      SymI_HasProto(KNOWN_CALL_ctr)                     \
      SymI_HasProto(KNOWN_CALL_TOO_FEW_ARGS_ctr)        \
      SymI_HasProto(KNOWN_CALL_EXTRA_ARGS_ctr)          \
      SymI_HasProto(SLOW_CALL_FUN_TOO_FEW_ctr)          \
      SymI_HasProto(SLOW_CALL_FUN_CORRECT_ctr)          \
      SymI_HasProto(SLOW_CALL_FUN_TOO_MANY_ctr)         \
      SymI_HasProto(SLOW_CALL_PAP_TOO_FEW_ctr)          \
      SymI_HasProto(SLOW_CALL_PAP_CORRECT_ctr)          \
      SymI_HasProto(SLOW_CALL_PAP_TOO_MANY_ctr)         \
      SymI_HasProto(SLOW_CALL_UNEVALD_ctr)              \
      SymI_HasProto(UPDF_OMITTED_ctr)                   \
      SymI_HasProto(UPDF_PUSHED_ctr)                    \
      SymI_HasProto(CATCHF_PUSHED_ctr)                  \
      SymI_HasProto(UPDF_RCC_PUSHED_ctr)                \
      SymI_HasProto(UPDF_RCC_OMITTED_ctr)               \
      SymI_HasProto(UPD_SQUEEZED_ctr)                   \
      SymI_HasProto(UPD_CON_IN_NEW_ctr)                 \
      SymI_HasProto(UPD_CON_IN_PLACE_ctr)               \
      SymI_HasProto(UPD_PAP_IN_NEW_ctr)                 \
      SymI_HasProto(UPD_PAP_IN_PLACE_ctr)               \
      SymI_HasProto(ALLOC_HEAP_ctr)                     \
      SymI_HasProto(ALLOC_HEAP_tot)                     \
      SymI_HasProto(ALLOC_FUN_ctr)                      \
      SymI_HasProto(ALLOC_FUN_adm)                      \
      SymI_HasProto(ALLOC_FUN_gds)                      \
      SymI_HasProto(ALLOC_FUN_slp)                      \
      SymI_HasProto(UPD_NEW_IND_ctr)                    \
      SymI_HasProto(UPD_NEW_PERM_IND_ctr)               \
      SymI_HasProto(UPD_OLD_IND_ctr)                    \
      SymI_HasProto(UPD_OLD_PERM_IND_ctr)               \
      SymI_HasProto(UPD_BH_UPDATABLE_ctr)               \
      SymI_HasProto(UPD_BH_SINGLE_ENTRY_ctr)            \
      SymI_HasProto(UPD_CAF_BH_UPDATABLE_ctr)           \
      SymI_HasProto(UPD_CAF_BH_SINGLE_ENTRY_ctr)        \
      SymI_HasProto(GC_SEL_ABANDONED_ctr)               \
      SymI_HasProto(GC_SEL_MINOR_ctr)                   \
      SymI_HasProto(GC_SEL_MAJOR_ctr)                   \
      SymI_HasProto(GC_FAILED_PROMOTION_ctr)            \
      SymI_HasProto(ALLOC_UP_THK_ctr)                   \
      SymI_HasProto(ALLOC_SE_THK_ctr)                   \
      SymI_HasProto(ALLOC_THK_adm)                      \
      SymI_HasProto(ALLOC_THK_gds)                      \
      SymI_HasProto(ALLOC_THK_slp)                      \
      SymI_HasProto(ALLOC_CON_ctr)                      \
      SymI_HasProto(ALLOC_CON_adm)                      \
      SymI_HasProto(ALLOC_CON_gds)                      \
      SymI_HasProto(ALLOC_CON_slp)                      \
      SymI_HasProto(ALLOC_TUP_ctr)                      \
      SymI_HasProto(ALLOC_TUP_adm)                      \
      SymI_HasProto(ALLOC_TUP_gds)                      \
      SymI_HasProto(ALLOC_TUP_slp)                      \
      SymI_HasProto(ALLOC_BH_ctr)                       \
      SymI_HasProto(ALLOC_BH_adm)                       \
      SymI_HasProto(ALLOC_BH_gds)                       \
      SymI_HasProto(ALLOC_BH_slp)                       \
      SymI_HasProto(ALLOC_PRIM_ctr)                     \
      SymI_HasProto(ALLOC_PRIM_adm)                     \
      SymI_HasProto(ALLOC_PRIM_gds)                     \
      SymI_HasProto(ALLOC_PRIM_slp)                     \
      SymI_HasProto(ALLOC_PAP_ctr)                      \
      SymI_HasProto(ALLOC_PAP_adm)                      \
      SymI_HasProto(ALLOC_PAP_gds)                      \
      SymI_HasProto(ALLOC_PAP_slp)                      \
      SymI_HasProto(ALLOC_TSO_ctr)                      \
      SymI_HasProto(ALLOC_TSO_adm)                      \
      SymI_HasProto(ALLOC_TSO_gds)                      \
      SymI_HasProto(ALLOC_TSO_slp)                      \
      SymI_HasProto(RET_NEW_ctr)                        \
      SymI_HasProto(RET_OLD_ctr)                        \
      SymI_HasProto(RET_UNBOXED_TUP_ctr)                \
980 981 982
      SymI_HasProto(RET_SEMI_loads_avoided)


983
// On most platforms, the garbage collector rewrites references
Ian Lynagh's avatar
Ian Lynagh committed
984
//      to small integer and char objects to a set of common, shared ones.
985 986
//
// We don't do this when compiling to Windows DLLs at the moment because
Ian Lynagh's avatar
Ian Lynagh committed
987
//      it doesn't support cross package data references well.
988
//
989
#if defined(COMPILING_WINDOWS_DLL)
990 991
#define RTS_INTCHAR_SYMBOLS
#else
Ian Lynagh's avatar
Ian Lynagh committed
992 993 994
#define RTS_INTCHAR_SYMBOLS                             \
      SymI_HasProto(stg_CHARLIKE_closure)               \
      SymI_HasProto(stg_INTLIKE_closure)
995 996 997
#endif


Ian Lynagh's avatar
Ian Lynagh committed
998 999
#define RTS_SYMBOLS                                     \
      Maybe_Stable_Names                                \
1000
      RTS_TICKY_SYMBOLS                                 \
Ian Lynagh's avatar
Ian Lynagh committed
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029
      SymI_HasProto(StgReturn)                          \
      SymI_HasProto(stg_enter_info)                     \
      SymI_HasProto(stg_gc_void_info)                   \
      SymI_HasProto(__stg_gc_enter_1)                   \
      SymI_HasProto(stg_gc_noregs)                      \
      SymI_HasProto(stg_gc_unpt_r1_info)                \
      SymI_HasProto(stg_gc_unpt_r1)                     \
      SymI_HasProto(stg_gc_unbx_r1_info)                \
      SymI_HasProto(stg_gc_unbx_r1)                     \
      SymI_HasProto(stg_gc_f1_info)                     \
      SymI_HasProto(stg_gc_f1)                          \
      SymI_HasProto(stg_gc_d1_info)                     \
      SymI_HasProto(stg_gc_d1)                          \
      SymI_HasProto(stg_gc_l1_info)                     \
      SymI_HasProto(stg_gc_l1)                          \
      SymI_HasProto(__stg_gc_fun)                       \
      SymI_HasProto(stg_gc_fun_info)                    \
      SymI_HasProto(stg_gc_gen)                         \
      SymI_HasProto(stg_gc_gen_info)                    \
      SymI_HasProto(stg_gc_gen_hp)                      \
      SymI_HasProto(stg_gc_ut)                          \
      SymI_HasProto(stg_gen_yield)                      \
      SymI_HasProto(stg_yield_noregs)                   \
      SymI_HasProto(stg_yield_to_interpreter)           \
      SymI_HasProto(stg_gen_block)                      \
      SymI_HasProto(stg_block_noregs)                   \
      SymI_HasProto(stg_block_1)                        \
      SymI_HasProto(stg_block_takemvar)                 \
      SymI_HasProto(stg_block_putmvar)                  \
1030
      MAIN_CAP_SYM                                      \
Ian Lynagh's avatar
Ian Lynagh committed
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044
      SymI_HasProto(MallocFailHook)                     \
      SymI_HasProto(OnExitHook)                         \
      SymI_HasProto(OutOfHeapHook)                      \
      SymI_HasProto(StackOverflowHook)                  \
      SymI_HasProto(addDLL)                             \
      SymI_HasProto(__int_encodeDouble)                 \
      SymI_HasProto(__word_encodeDouble)                \
      SymI_HasProto(__2Int_encodeDouble)                \
      SymI_HasProto(__int_encodeFloat)                  \
      SymI_HasProto(__word_encodeFloat)                 \
      SymI_HasProto(stg_atomicallyzh)                   \
      SymI_HasProto(barf)                               \
      SymI_HasProto(debugBelch)                         \
      SymI_HasProto(errorBelch)                         \
Simon Marlow's avatar
Simon Marlow committed
1045
      SymI_HasProto(sysErrorBelch)                      \
Ian Lynagh's avatar
Ian Lynagh committed
1046 1047 1048 1049 1050 1051
      SymI_HasProto(stg_getMaskingStatezh)              \
      SymI_HasProto(stg_maskAsyncExceptionszh)          \
      SymI_HasProto(stg_maskUninterruptiblezh)          \
      SymI_HasProto(stg_catchzh)                        \
      SymI_HasProto(stg_catchRetryzh)                   \
      SymI_HasProto(stg_catchSTMzh)                     \
1052
      SymI_HasProto(stg_checkzh)                        \
1053
      SymI_HasProto(closure_flags)                      \
Ian Lynagh's avatar
Ian Lynagh committed
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073
      SymI_HasProto(cmp_thread)                         \
      SymI_HasProto(createAdjustor)                     \
      SymI_HasProto(stg_decodeDoublezu2Intzh)           \
      SymI_HasProto(stg_decodeFloatzuIntzh)             \
      SymI_HasProto(defaultsHook)                       \
      SymI_HasProto(stg_delayzh)                        \
      SymI_HasProto(stg_deRefWeakzh)                    \
      SymI_HasProto(stg_deRefStablePtrzh)               \
      SymI_HasProto(dirty_MUT_VAR)                      \
      SymI_HasProto(stg_forkzh)                         \
      SymI_HasProto(stg_forkOnzh)                       \
      SymI_HasProto(forkProcess)                        \
      SymI_HasProto(forkOS_createThread)                \
      SymI_HasProto(freeHaskellFunctionPtr)             \
      SymI_HasProto(getOrSetGHCConcSignalSignalHandlerStore)            \
      SymI_HasProto(getOrSetGHCConcWindowsPendingDelaysStore)           \
      SymI_HasProto(getOrSetGHCConcWindowsIOManagerThreadStore)         \
      SymI_HasProto(getOrSetGHCConcWindowsProddingStore)                \
      SymI_HasProto(getOrSetSystemEventThreadEventManagerStore)         \
      SymI_HasProto(getOrSetSystemEventThreadIOManagerThreadStore)      \
1074
      SymI_HasProto(getGCStats)                         \
Ian Lynagh's avatar
Ian Lynagh committed
1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
      SymI_HasProto(genSymZh)                           \
      SymI_HasProto(genericRaise)                       \
      SymI_HasProto(getProgArgv)                        \
      SymI_HasProto(getFullProgArgv)                    \
      SymI_HasProto(getStablePtr)                       \
      SymI_HasProto(hs_init)                            \
      SymI_HasProto(hs_exit)                            \
      SymI_HasProto(hs_set_argv)                        \
      SymI_HasProto(hs_add_root)                        \
      SymI_HasProto(hs_perform_gc)                      \
      SymI_HasProto(hs_free_stable_ptr)                 \
      SymI_HasProto(hs_free_fun_ptr)                    \
      SymI_HasProto(hs_hpc_rootModule)                  \
      SymI_HasProto(hs_hpc_module)                      \
      SymI_HasProto(initLinker)                         \
1090 1091 1092
      SymI_HasProto(stg_unpackClosurezh)                \
      SymI_HasProto(stg_getApStackValzh)                \
      SymI_HasProto(stg_getSparkzh)                     \
Simon Marlow's avatar
Simon Marlow committed
1093
      SymI_HasProto(stg_numSparkszh)                    \
Ian Lynagh's avatar
Ian Lynagh committed
1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104
      SymI_HasProto(stg_isCurrentThreadBoundzh)         \
      SymI_HasProto(stg_isEmptyMVarzh)                  \
      SymI_HasProto(stg_killThreadzh)                   \
      SymI_HasProto(loadArchive)                        \
      SymI_HasProto(loadObj)                            \
      SymI_HasProto(insertStableSymbol)                 \
      SymI_HasProto(insertSymbol)                       \
      SymI_HasProto(lookupSymbol)                       \
      SymI_HasProto(stg_makeStablePtrzh)                \
      SymI_HasProto(stg_mkApUpd0zh)                     \
      SymI_HasProto(stg_myThreadIdzh)                   \
1105
      SymI_HasProto(stg_labelThreadzh)                  \
Ian Lynagh's avatar
Ian Lynagh committed
1106
      SymI_HasProto(stg_newArrayzh)                     \
1107
      SymI_HasProto(stg_newArrayArrayzh)                     \
Ian Lynagh's avatar
Ian Lynagh committed
1108 1109 1110 1111 1112 1113 1114 1115
      SymI_HasProto(stg_newBCOzh)                       \
      SymI_HasProto(stg_newByteArrayzh)                 \
      SymI_HasProto_redirect(newCAF, newDynCAF)         \
      SymI_HasProto(stg_newMVarzh)                      \
      SymI_HasProto(stg_newMutVarzh)                    \
      SymI_HasProto(stg_newTVarzh)                      \
      SymI_HasProto(stg_noDuplicatezh)                  \
      SymI_HasProto(stg_atomicModifyMutVarzh)           \
Simon Marlow's avatar
Simon Marlow committed
1116
      SymI_HasProto(stg_casMutVarzh)                    \
Ian Lynagh's avatar
Ian Lynagh committed
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129
      SymI_HasProto(stg_newPinnedByteArrayzh)           \
      SymI_HasProto(stg_newAlignedPinnedByteArrayzh)    \
      SymI_HasProto(newSpark)                           \
      SymI_HasProto(performGC)                          \
      SymI_HasProto(performMajorGC)                     \
      SymI_HasProto(prog_argc)                          \
      SymI_HasProto(prog_argv)                          \
      SymI_HasProto(stg_putMVarzh)                      \
      SymI_HasProto(stg_raisezh)                        \
      SymI_HasProto(stg_raiseIOzh)                      \
      SymI_HasProto(stg_readTVarzh)                     \
      SymI_HasProto(stg_readTVarIOzh)                   \
      SymI_HasProto(resumeThread)                       \
1130
      SymI_HasProto(setNumCapabilities)                 \
1131
      SymI_HasProto(getNumberOfProcessors)              \
1132
      SymI_HasProto(resolveObjs)                        \
1133
      SymI_HasProto(stg_retryzh)                        \
Ian Lynagh's avatar
Ian Lynagh committed
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178
      SymI_HasProto(rts_apply)                          \
      SymI_HasProto(rts_checkSchedStatus)               \
      SymI_HasProto(rts_eval)                           \
      SymI_HasProto(rts_evalIO)                         \
      SymI_HasProto(rts_evalLazyIO)                     \
      SymI_HasProto(rts_evalStableIO)                   \
      SymI_HasProto(rts_eval_)                          \
      SymI_HasProto(rts_getBool)                        \
      SymI_HasProto(rts_getChar)                        \
      SymI_HasProto(rts_getDouble)                      \
      SymI_HasProto(rts_getFloat)                       \
      SymI_HasProto(rts_getInt)                         \
      SymI_HasProto(rts_getInt8)                        \
      SymI_HasProto(rts_getInt16)                       \
      SymI_HasProto(rts_getInt32)                       \
      SymI_HasProto(rts_getInt64)                       \
      SymI_HasProto(rts_getPtr)                         \
      SymI_HasProto(rts_getFunPtr)                      \
      SymI_HasProto(rts_getStablePtr)                   \
      SymI_HasProto(rts_getThreadId)                    \
      SymI_HasProto(rts_getWord)                        \
      SymI_HasProto(rts_getWord8)                       \
      SymI_HasProto(rts_getWord16)                      \
      SymI_HasProto(rts_getWord32)                      \
      SymI_HasProto(rts_getWord64)                      \
      SymI_HasProto(rts_lock)                           \
      SymI_HasProto(rts_mkBool)                         \
      SymI_HasProto(rts_mkChar)                         \
      SymI_HasProto(rts_mkDouble)                       \
      SymI_HasProto(rts_mkFloat)                        \
      SymI_HasProto(rts_mkInt)                          \
      SymI_HasProto(rts_mkInt8)                         \
      SymI_HasProto(rts_mkInt16)                        \
      SymI_HasProto(rts_mkInt32)                        \
      SymI_HasProto(rts_mkInt64)                        \
      SymI_HasProto(rts_mkPtr)                          \
      SymI_HasProto(rts_mkFunPtr)                       \
      SymI_HasProto(rts_mkStablePtr)                    \
      SymI_HasProto(rts_mkString)                       \
      SymI_HasProto(rts_mkWord)                         \
      SymI_HasProto(rts_mkWord8)                        \
      SymI_HasProto(rts_mkWord16)                       \
      SymI_HasProto(rts_mkWord32)                       \
      SymI_HasProto(rts_mkWord64)                       \
      SymI_HasProto(rts_unlock)                         \
1179
      SymI_HasProto(rts_unsafeGetMyCapability)          \
Ian Lynagh's avatar
Ian Lynagh committed
1180
      SymI_HasProto(rtsSupportsBoundThreads)            \
1181
      SymI_HasProto(rts_isProfiled)                     \
Ian Lynagh's avatar
Ian Lynagh committed
1182 1183 1184 1185 1186 1187 1188 1189 1190
      SymI_HasProto(setProgArgv)                        \
      SymI_HasProto(startupHaskell)                     \
      SymI_HasProto(shutdownHaskell)                    \
      SymI_HasProto(shutdownHaskellAndExit)             \
      SymI_HasProto(stable_ptr_table)                   \
      SymI_HasProto(stackOverflow)                      \
      SymI_HasProto(stg_CAF_BLACKHOLE_info)             \
      SymI_HasProto(stg_BLACKHOLE_info)                 \
      SymI_HasProto(__stg_EAGER_BLACKHOLE_info)         \
1191
      SymI_HasProto(stg_BLOCKING_QUEUE_CLEAN_info)      \
Ian Lynagh's avatar
Ian Lynagh committed
1192
      SymI_HasProto(stg_BLOCKING_QUEUE_DIRTY_info)      \
1193
      SymI_HasProto(startTimer)                         \
Ian Lynagh's avatar
Ian Lynagh committed
1194 1195 1196
      SymI_HasProto(stg_MVAR_CLEAN_info)                \
      SymI_HasProto(stg_MVAR_DIRTY_info)                \
      SymI_HasProto(stg_IND_STATIC_info)                \
1197
      SymI_HasProto(stg_ARR_WORDS_info)                 \
Ian Lynagh's avatar
Ian Lynagh committed
1198 1199 1200
      SymI_HasProto(stg_MUT_ARR_PTRS_DIRTY_info)        \
      SymI_HasProto(stg_MUT_ARR_PTRS_FROZEN_info)       \
      SymI_HasProto(stg_MUT_ARR_PTRS_FROZEN0_info)      \
1201
      SymI_HasProto(stg_WEAK_info)                      \
Ian Lynagh's avatar
Ian Lynagh committed
1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262
      SymI_HasProto(stg_ap_v_info)                      \
      SymI_HasProto(stg_ap_f_info)                      \
      SymI_HasProto(stg_ap_d_info)                      \
      SymI_HasProto(stg_ap_l_info)                      \
      SymI_HasProto(stg_ap_n_info)                      \
      SymI_HasProto(stg_ap_p_info)                      \
      SymI_HasProto(stg_ap_pv_info)                     \
      SymI_HasProto(stg_ap_pp_info)                     \
      SymI_HasProto(stg_ap_ppv_info)                    \
      SymI_HasProto(stg_ap_ppp_info)                    \
      SymI_HasProto(stg_ap_pppv_info)                   \
      SymI_HasProto(stg_ap_pppp_info)                   \
      SymI_HasProto(stg_ap_ppppp_info)                  \
      SymI_HasProto(stg_ap_pppppp_info)                 \
      SymI_HasProto(stg_ap_0_fast)                      \
      SymI_HasProto(stg_ap_v_fast)                      \
      SymI_HasProto(stg_ap_f_fast)                      \
      SymI_HasProto(stg_ap_d_fast)                      \
      SymI_HasProto(stg_ap_l_fast)                      \
      SymI_HasProto(stg_ap_n_fast)                      \
      SymI_HasProto(stg_ap_p_fast)                      \
      SymI_HasProto(stg_ap_pv_fast)                     \
      SymI_HasProto(stg_ap_pp_fast)                     \
      SymI_HasProto(stg_ap_ppv_fast)                    \
      SymI_HasProto(stg_ap_ppp_fast)                    \
      SymI_HasProto(stg_ap_pppv_fast)                   \
      SymI_HasProto(stg_ap_pppp_fast)                   \
      SymI_HasProto(stg_ap_ppppp_fast)                  \
      SymI_HasProto(stg_ap_pppppp_fast)                 \
      SymI_HasProto(stg_ap_1_upd_info)                  \
      SymI_HasProto(stg_ap_2_upd_info)                  \
      SymI_HasProto(stg_ap_3_upd_info)                  \
      SymI_HasProto(stg_ap_4_upd_info)                  \
      SymI_HasProto(stg_ap_5_upd_info)                  \
      SymI_HasProto(stg_ap_6_upd_info)                  \
      SymI_HasProto(stg_ap_7_upd_info)                  \
      SymI_HasProto(stg_exit)                           \
      SymI_HasProto(stg_sel_0_upd_info)                 \
      SymI_HasProto(stg_sel_10_upd_info)                \
      SymI_HasProto(stg_sel_11_upd_info)                \
      SymI_HasProto(stg_sel_12_upd_info)                \
      SymI_HasProto(stg_sel_13_upd_info)                \
      SymI_HasProto(stg_sel_14_upd_info)                \
      SymI_HasProto(stg_sel_15_upd_info)                \
      SymI_HasProto(stg_sel_1_upd_info)                 \
      SymI_HasProto(stg_sel_2_upd_info)                 \
      SymI_HasProto(stg_sel_3_upd_info)                 \
      SymI_HasProto(stg_sel_4_upd_info)                 \
      SymI_HasProto(stg_sel_5_upd_info)                 \
      SymI_HasProto(stg_sel_6_upd_info)                 \
      SymI_HasProto(stg_sel_7_upd_info)                 \
      SymI_HasProto(stg_sel_8_upd_info)                 \
      SymI_HasProto(stg_sel_9_upd_info)                 \
      SymI_HasProto(stg_upd_frame_info)                 \
      SymI_HasProto(stg_bh_upd_frame_info)              \
      SymI_HasProto(suspendThread)                      \
      SymI_HasProto(stg_takeMVarzh)                     \
      SymI_HasProto(stg_threadStatuszh)                 \
      SymI_HasProto(stg_tryPutMVarzh)                   \
      SymI_HasProto(stg_tryTakeMVarzh)                  \
      SymI_HasProto(stg_unmaskAsyncExceptionszh)        \
1263
      SymI_HasProto(unloadObj)                          \
Ian Lynagh's avatar
Ian Lynagh committed
1264 1265 1266 1267
      SymI_HasProto(stg_unsafeThawArrayzh)              \
      SymI_HasProto(stg_waitReadzh)                     \
      SymI_HasProto(stg_waitWritezh)                    \
      SymI_HasProto(stg_writeTVarzh)                    \
1268
      SymI_HasProto(stg_yieldzh)                        \
1269
      SymI_NeedsProto(stg_interp_constr_entry)          \
1270
      SymI_HasProto(stg_arg_bitmaps)                    \
1271
      SymI_HasProto(large_alloc_lim)                    \
Simon Marlow's avatar
Simon Marlow committed
1272
      SymI_HasProto(g0)                                 \
1273
      SymI_HasProto(allocate)                           \
Ian Lynagh's avatar
Ian Lynagh committed
1274 1275
      SymI_HasProto(allocateExec)                       \
      SymI_HasProto(freeExec)                           \
1276 1277 1278
      SymI_HasProto(getAllocations)                     \
      SymI_HasProto(revertCAFs)                         \
      SymI_HasProto(RtsFlags)                           \
Ian Lynagh's avatar
Ian Lynagh committed
1279 1280 1281 1282 1283
      SymI_NeedsProto(rts_breakpoint_io_action)         \
      SymI_NeedsProto(rts_stop_next_breakpoint)         \
      SymI_NeedsProto(rts_stop_on_exception)            \
      SymI_HasProto(stopTimer)                          \
      SymI_HasProto(n_capabilities)                     \
1284
      SymI_HasProto(stg_traceCcszh)                     \
1285
      SymI_HasProto(stg_traceEventzh)                   \
1286
      SymI_HasProto(getMonotonicNSec)                   \
Ian Lynagh's avatar
Ian Lynagh committed
1287
      RTS_USER_SIGNALS_SYMBOLS                          \
1288
      RTS_INTCHAR_SYMBOLS
1289

1290

1291 1292
// 64-bit support functions in libgcc.a
#if defined(__GNUC__) && SIZEOF_VOID_P <= 4
Ian Lynagh's avatar
Ian Lynagh committed
1293
#define RTS_LIBGCC_SYMBOLS                             \
1294 1295 1296
      SymI_NeedsProto(__divdi3)                        \
      SymI_NeedsProto(__udivdi3)                       \
      SymI_NeedsProto(__moddi3)                        \
Ian Lynagh's avatar
Ian Lynagh committed
1297 1298 1299 1300
      SymI_NeedsProto(__umoddi3)                       \
      SymI_NeedsProto(__muldi3)                        \
      SymI_NeedsProto(__ashldi3)                       \
      SymI_NeedsProto(__ashrdi3)                       \
1301 1302
      SymI_NeedsProto(__lshrdi3)                       \
      SymI_NeedsProto(__fixunsdfdi)
1303 1304 1305 1306
#else
#define RTS_LIBGCC_SYMBOLS
#endif

1307
#if defined(darwin_HOST_OS) && defined(powerpc_HOST_ARCH)
1308 1309 1310
      // Symbols that don't have a leading underscore
      // on Mac OS X. They have to receive special treatment,
      // see machoInitSymbolsWithoutUnderscore()
Ian Lynagh's avatar
Ian Lynagh committed
1311 1312
#define RTS_MACHO_NOUNDERLINE_SYMBOLS                   \
      SymI_NeedsProto(saveFP)                           \
1313
      SymI_NeedsProto(restFP)
1314
#endif
1315 1316

/* entirely bogus claims about types of these symbols */
1317
#define SymI_NeedsProto(vvv)  extern void vvv(void);
1318
#if defined(COMPILING_WINDOWS_DLL)
1319
#define SymE_HasProto(vvv)    SymE_HasProto(vvv);
Ian Lynagh's avatar
Ian Lynagh committed
1320 1321 1322 1323 1324
#  if defined(x86_64_HOST_ARCH)
#    define SymE_NeedsProto(vvv)    extern void __imp_ ## vvv (void);
#  else
#    define SymE_NeedsProto(vvv)    extern void _imp__ ## vvv (void);
#  endif
1325
#else
1326 1327
#define SymE_NeedsProto(vvv)  SymI_NeedsProto(vvv);
#define SymE_HasProto(vvv)    SymI_HasProto(vvv)
1328
#endif
1329 1330
#define SymI_HasProto(vvv) /**/
#define SymI_HasProto_redirect(vvv,xxx) /**/
1331
RTS_SYMBOLS
1332
RTS_RET_SYMBOLS
1333
RTS_POSIX_ONLY_SYMBOLS