1#
2#
3#            Nim's Runtime Library
4#        (c) Copyright 2015 Andreas Rumpf
5#
6#    See the file "copying.txt", included in this
7#    distribution, for details about the copyright.
8#
9
10# Pragmas for RTL generation. Has to be an include, because user-defined
11# pragmas cannot be exported.
12
13# There are 3 different usages:
14# 1) Ordinary imported code.
15# 2) Imported from nimrtl.
16#    -> defined(useNimRtl) or appType == "lib" and not defined(createNimRtl)
17# 3) Exported into nimrtl.
18#    -> appType == "lib" and defined(createNimRtl)
19when not defined(nimNewShared):
20  {.pragma: gcsafe.}
21
22when defined(createNimRtl):
23  when defined(useNimRtl):
24    {.error: "Cannot create and use nimrtl at the same time!".}
25  elif appType != "lib":
26    {.error: "nimrtl must be built as a library!".}
27
28when defined(createNimRtl):
29  {.pragma: rtl, exportc: "nimrtl_$1", dynlib, gcsafe.}
30  {.pragma: inl.}
31  {.pragma: compilerRtl, compilerproc, exportc: "nimrtl_$1", dynlib.}
32elif defined(useNimRtl):
33  #[
34  `{.rtl.}` should only be used for non-generic procs.
35  ]#
36  const nimrtl* =
37    when defined(windows): "nimrtl.dll"
38    elif defined(macosx): "libnimrtl.dylib"
39    else: "libnimrtl.so"
40  {.pragma: rtl, importc: "nimrtl_$1", dynlib: nimrtl, gcsafe.}
41  {.pragma: inl.}
42  {.pragma: compilerRtl, compilerproc, importc: "nimrtl_$1", dynlib: nimrtl.}
43else:
44  {.pragma: rtl, gcsafe.}
45  {.pragma: inl, inline.}
46  {.pragma: compilerRtl, compilerproc.}
47
48{.pragma: benign, gcsafe, locks: 0.}
49
50when defined(nimHasSinkInference):
51  {.push sinkInference: on.}
52